idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
38,400 | public function handleError ( $ code , $ message , $ file = '' , $ line = 0 , $ context = array ( ) ) { if ( $ file == 'tmpl://com:base.template.stack' || $ code == 1 ) { if ( $ file == 'tmpl://com:base.template.stack' ) { $ file = $ this -> getPath ( ) ; } if ( ini_get ( 'display_errors' ) ) { echo '<strong>' . $ code... | Handle template errors . |
38,401 | protected function _actionAdd ( $ context ) { $ data = $ context -> data ; $ entity = parent :: _actionAdd ( $ context ) ; if ( get_viewer ( ) -> eql ( $ this -> actor ) || ! is_person ( $ this -> actor ) ) { unset ( $ data -> private ) ; } if ( $ data -> private ) { $ entity -> setAccess ( array ( $ this -> actor -> i... | Adds a new post . |
38,402 | public function tag ( $ name , $ content , $ attributes = array ( ) ) { static $ instance ; $ instance = $ instance ? clone $ instance : new LibBaseTemplateHelperHtmlElement ( ) ; $ instance -> name = $ name ; $ instance -> content = $ content ; $ instance -> attributes = $ attributes ; return $ instance ; } | Return a tag object . This method clones a prototype tag instead of instantiating a new tag to optimize memory and speed consumption . |
38,403 | public function select ( $ name , $ options = null , $ attributes = array ( ) ) { $ attributes [ 'name' ] = $ name ; if ( ! isset ( $ attributes [ 'id' ] ) ) { $ attributes [ 'id' ] = str_replace ( array ( '[' , ']' ) , array ( '_' , '' ) , $ name ) ; } if ( is_array ( $ options ) ) { $ options = array_merge ( array ( ... | Create a select tag . |
38,404 | public function textarea ( $ name , $ value = '' , $ attributes = array ( ) ) { return $ this -> tag ( 'textarea' , $ value ) -> set ( array ( 'name' => $ name , 'id' => $ name ) ) -> set ( $ attributes ) ; } | Create a textarea tag . |
38,405 | public function input ( $ type , $ name , $ value = '' , $ attributes = array ( ) ) { $ id = str_replace ( array ( '[' , ']' ) , array ( '_' , '' ) , $ name ) ; return $ this -> tag ( 'input' , null ) -> set ( array ( 'type' => $ type , 'value' => $ value , 'name' => $ name , 'id' => $ id ) ) -> set ( $ attributes ) ; ... | Create an input field tag . |
38,406 | public function button ( $ value , $ name = null , $ attributes = array ( ) ) { $ name = pick ( $ name , $ value ) ; return $ this -> tag ( 'button' , $ value ) -> set ( array ( 'id' => $ name , 'name' => $ name ) ) -> set ( $ attributes ) ; } | Create a button tag . |
38,407 | public function link ( $ content , $ url = '' , $ attributes = array ( ) ) { $ attributes [ 'href' ] = $ url ; return $ this -> tag ( 'a' , $ content , $ attributes ) ; } | Create a link tag . |
38,408 | public static function setAttribute ( AnConfigInterface $ config ) { $ description = $ config -> description ; if ( ! $ description ) { throw new AnDomainAttributeException ( 'description [AnDomainDescriptionAbstract] option is required' ) ; } if ( empty ( $ config -> type ) ) { $ config -> append ( array ( 'column' =>... | Attribute factory method . |
38,409 | public static function setRelationship ( AnConfigInterface $ config ) { $ description = $ config -> description ; if ( ! $ description ) { throw new AnDomainPropertyException ( 'description [AnDomainDescriptionAbstract] option is required' ) ; } if ( empty ( $ config [ 'type' ] ) ) { if ( AnInflector :: isSingular ( $ ... | Relationship factory method . |
38,410 | public function __isset ( $ key ) { if ( ! isset ( $ this -> _object ) && $ key == $ this -> _property ) { return isset ( $ this -> _value ) ; } return parent :: __isset ( $ key ) ; } | Delays retriveing the object to the last moment by checking the property . |
38,411 | public function get ( $ key = null , $ default = null ) { if ( ! isset ( $ this -> _object ) && $ key == $ this -> _property ) { return $ this -> _value ; } return $ this -> getObject ( ) -> get ( $ key , $ default ) ; } | Get a property value directly from the entity . |
38,412 | public function set ( $ key = null , $ value = null ) { $ this -> getObject ( ) -> set ( $ key , $ value ) ; return $ this ; } | Set a property value directly . |
38,413 | public function getObject ( ) { if ( ! isset ( $ this -> _object ) ) { $ condition = array ( $ this -> _property => $ this -> _value ) ; $ repository = AnDomain :: getRepository ( $ this -> getIdentifier ( ) ) ; if ( $ data = $ repository -> find ( $ condition , false ) ) { $ this -> _object = $ data ; return $ this ->... | Get the proxied entity . Since there could many entities proxied . The getObject method will try to load all the proxied entities of the same type in order to reduce the number of calls to the storage later on . |
38,414 | protected function _afterEntityInstantiate ( AnConfig $ config ) { $ data = $ config -> data ; $ data -> append ( array ( 'subscribers' => array ( ) ) ) ; if ( $ data -> object ) { if ( is ( $ data -> object , 'ComBaseDomainEntityComment' ) ) { $ data -> comment = $ data -> object ; $ data -> object = $ data -> comment... | Initializes the options for an entity after being created . |
38,415 | public function setType ( $ type , $ config = array ( ) ) { $ this -> set ( 'type' , $ type ) ; foreach ( $ config as $ key => $ value ) { $ this -> setValue ( $ key , $ value ) ; } return $ this ; } | Sets the type of the notification . If an array of configuration is passed it will store it as the notification configuration . |
38,416 | public function setSubscribers ( $ subscribers ) { $ subscribers = AnHelperArray :: getValues ( AnConfig :: unbox ( $ subscribers ) ) ; $ ids = array ( ) ; foreach ( $ subscribers as $ subscriber ) { if ( is ( $ subscriber , 'AnDomainEntityAbstract' ) ) { $ ids [ ] = $ subscriber -> id ; } else { $ ids [ ] = $ subscrib... | Set a list of notifications subscribers . |
38,417 | public function removeSubscribers ( $ subscribers ) { $ subscribers = AnConfig :: unbox ( $ subscribers ) ; if ( is ( $ subscribers , 'AnDomainEntityAbstract' ) ) { $ subscribers = array ( $ subscribers ) ; } else { $ subscribers = ( array ) $ subscribers ; } $ ids = $ this -> subscriberIds -> toArray ( ) ; foreach ( $... | Removes an array of people or ids from the list of subscribers . |
38,418 | public function shouldNotify ( $ person , $ setting ) { if ( ! $ person -> isNotifiable ( ) ) { return false ; } if ( ! $ this -> target -> allows ( $ person , 'access' ) ) { return false ; } if ( isset ( $ this -> object ) && $ this -> object -> isPrivatable ( ) && ! $ this -> object -> allows ( $ person , 'access' ) ... | Checks with a setting delegate of the notification whether to notify a person or not . |
38,419 | public function navigation ( $ config = array ( ) ) { $ config = array_merge ( $ config , array ( 'tabs' => array ( 'about' => array ( 'label' => 'COM-SETTINGS-ABOUT' , 'url' => 'option=com_settings&view=about' ) , 'settings' => array ( 'label' => 'COM-SETTINGS-SYSTEM' , 'url' => 'option=com_settings&view=settings' ) ,... | Renders navigation bar for settings |
38,420 | public function plugin_types ( $ config = array ( ) ) { $ config = new AnConfig ( $ config ) ; $ config -> append ( array ( 'selected' => '' , 'name' => 'folder' , 'label' => '' , 'params' => array ( ) ) ) ; $ query = AnService :: get ( 'repos:settings.plugin' ) -> getQuery ( ) ; $ query -> order ( 'name' ) -> set ( 'd... | renders a list of plugin folders |
38,421 | public function templates ( $ config = array ( ) ) { $ config = new AnConfig ( $ config ) ; $ exclude = array ( 'base' , 'system' ) ; $ templates = preg_grep ( '/^([^.])/' , scandir ( ANPATH_THEMES ) ) ; $ templates = array_diff ( $ templates , $ exclude ) ; $ options = array ( ) ; foreach ( $ templates as $ template )... | renders a list of available templates |
38,422 | public function languages ( $ config = array ( ) ) { $ config = new AnConfig ( $ config ) ; $ path = ANPATH_SITE . DS . 'language' ; $ languages = preg_grep ( '/^([^.])/' , scandir ( $ path ) ) ; $ options = array ( ) ; foreach ( $ languages as $ language ) { $ manifest = json_decode ( file_get_contents ( $ path . DS .... | renders a list of available languages |
38,423 | public function formfield_text ( $ config = array ( ) ) { $ config = new AnConfig ( $ config ) ; $ config -> append ( array ( 'class' => 'input-block-level' , 'maxlength' => 200 , 'name' => '' , 'id' => '' , 'label' => '' , 'placeholder' => '' , 'description' => '' , 'disabled' => false , 'type' => 'text' , 'pattern' =... | renders a text form field |
38,424 | public function formfield_textarea ( $ config = array ( ) ) { $ config = new AnConfig ( $ config ) ; $ config -> append ( array ( 'class' => 'input-block-level' , 'maxlength' => 1000 , 'name' => '' , 'id' => '' , 'label' => '' , 'placeholder' => '' , 'description' => '' , 'disabled' => false , 'required' => true , 'row... | renders a textarea form field |
38,425 | public function formfield_select ( $ config = array ( ) ) { $ config = new AnConfig ( $ config ) ; $ config -> append ( array ( 'class' => 'input-block-level' , 'name' => '' , 'selected' => '' , 'description' => '' , 'id' => '' , 'label' => '' , 'options' => array ( ) , 'disabled' => false , ) ) ; return $ this -> _ren... | renders a select form field |
38,426 | public function formfield_custom ( $ config ) { $ config = new AnConfig ( $ config ) ; $ config -> append ( array ( 'class' => 'input-block-level' ) ) ; return $ this -> _render ( 'formfield_custom' , $ config ) ; } | renders a custom developed form field |
38,427 | protected function _paramsPlugin ( $ config ) { $ entity = $ config -> entity ; $ element = $ entity -> element ; $ folder = $ entity -> folder ; $ config_file_path = ANPATH_SITE . DS . 'plugins' . DS . $ folder . DS . $ element . '.json' ; if ( file_exists ( $ config_file_path ) ) { $ plugin_config = json_decode ( fil... | renders a plugin s paramters as form fields |
38,428 | protected function _paramsTemplate ( $ config ) { $ entity = $ config -> entity ; $ template = $ entity -> alias ; $ config_file_path = ANPATH_THEMES . DS . $ template . DS . 'template.json' ; if ( ! file_exists ( $ config_file_path ) ) { return AnTranslator :: _ ( 'COM-SETTINGS-PROMPT-NO-CONFIGURATION-AVAILABLE' ) ; }... | renders a template s paramters as form fields |
38,429 | public function find ( $ entity ) { $ conditions = array ( ) ; if ( is_array ( $ entity ) ) { foreach ( $ entity as $ key => $ value ) { $ conditions [ $ this -> _target_property . '.' . $ key ] = $ value ; } } else { $ conditions [ $ this -> _target_property ] = $ entity ; } $ conditions [ $ this -> _property ] = $ th... | Find an entity within this collection . |
38,430 | public function insert ( $ target , $ config = array ( ) ) { if ( AnHelperArray :: isIterable ( $ target ) ) { $ targets = AnHelperArray :: unique ( $ target ) ; $ relations = new AnObjectSet ( ) ; foreach ( $ target as $ target ) { $ relations -> insert ( $ this -> insert ( $ target , $ config ) ) ; } return $ relatio... | Insert an entity to the aggregation . If multiple target is passed then add the all of them to the collection . It prevents adding the same entity into the its existing collection . |
38,431 | public function extract ( $ target ) { $ relation = $ this -> _child -> find ( array ( $ this -> _property => $ this -> _root , $ this -> _target_property => $ target , ) ) ; if ( $ relation ) { $ relation -> delete ( ) ; } return $ relation ; } | Removes an object relation from the aggregation . |
38,432 | public function dispatchEvent ( $ name , $ event = array ( ) ) { $ result = array ( ) ; if ( ! $ event instanceof AnEvent ) { $ event = new AnEvent ( $ event ) ; } $ event -> setName ( $ name ) -> setDispatcher ( $ this ) ; if ( isset ( $ this -> _listeners [ $ name ] ) ) { foreach ( $ this -> _listeners [ $ name ] as ... | Dispatches an event by dispatching arguments to all listeners that handle the event and returning their return values . |
38,433 | public function removeEventSubscriber ( AnEventSubscriberInterface $ subscriber ) { $ handle = $ subscriber -> getHandle ( ) ; if ( isset ( $ this -> _subscribers [ $ handle ] ) ) { $ subscriptions = $ subscriber -> getSubscriptions ( ) ; foreach ( $ subscriptions as $ subscription ) { $ this -> removeEventListener ( $... | Remove an event subscriber |
38,434 | public function hasListeners ( $ name ) { $ result = false ; if ( isset ( $ this -> _listeners [ $ name ] ) ) { $ result = ! empty ( $ this -> _listeners [ $ name ] ) ; } return $ result ; } | Check if we are listening to a specific event |
38,435 | public function setEventPriority ( $ name , AnObjectHandable $ listener , $ priority ) { if ( isset ( $ this -> _listeners [ $ name ] ) ) { $ this -> _listeners [ $ name ] -> setPriority ( $ listener , $ priority ) ; } return $ this ; } | Set the priority of an event |
38,436 | public function isSubscribed ( AnEventSubscriberInterface $ subscriber ) { $ handle = $ subscriber -> getHandle ( ) ; return isset ( $ this -> _subscribers [ $ handle ] ) ; } | Check if the handler is connected to a dispatcher |
38,437 | public function redirectHttps ( AnCommandContext $ context ) { if ( AnRequest :: url ( ) -> scheme === 'http' ) { $ url = clone AnRequest :: url ( ) ; $ url -> scheme = 'https' ; $ context -> response -> setRedirect ( $ url ) ; return false ; } } | Redirects to HTTPs . |
38,438 | public function extract ( $ name = null ) { if ( $ name instanceof LibBaseTemplateObjectInterface ) { $ name = $ name -> getName ( ) ; } if ( is_null ( $ name ) ) { return array_shift ( $ this -> _objects ) ; } elseif ( is_array ( $ name ) ) { $ container = clone $ this ; $ container -> setObjects ( array ( ) ) ; forea... | Unses a object from the queue using its key and returns it . If an array of names is passed then a new container is returned . If no name is passed then return the top element . |
38,439 | public function offsetSet ( $ name , $ object ) { if ( ! $ object instanceof LibBaseTemplateObjectInterface ) { if ( empty ( $ name ) ) { throw new AnConfigException ( 'Template object name must be unique and non empty' ) ; } $ object = LibBaseTemplateObject :: getInstance ( $ name , $ object ) ; } $ this -> _objects [... | Set a value by key . |
38,440 | public function sort ( $ order , $ head = true ) { $ list = array ( ) ; settype ( $ order , 'array' ) ; $ order = array_unique ( $ order ) ; foreach ( $ order as $ item ) { if ( isset ( $ this -> _objects [ $ item ] ) ) { $ list [ $ item ] = $ this -> _objects [ $ item ] ; } } foreach ( $ this -> _objects as $ key => $... | Rearrange the objects according to the order arrangement . If head is set to true then the sort order is applied to the head of the objects if false then it s applied to the tail . |
38,441 | protected function _actionGetcount ( AnCommandContext $ context ) { $ count = $ this -> actor -> numOfNewNotifications ( ) ; return $ this -> getView ( ) -> newNotifications ( $ count ) -> display ( ) ; } | Return the count of new notifications . |
38,442 | protected function _actionBrowse ( $ context ) { $ this -> actor -> resetNotifications ( ) ; if ( $ this -> actor -> eql ( get_viewer ( ) ) ) { $ title = AnTranslator :: _ ( 'COM-NOTIFICATIONS-ACTORBAR-YOUR-NOTIFICATIONS' ) ; } else { $ title = sprintf ( AnTranslator :: _ ( 'COM-NOTIFICATIONS-ACTORBAR-ACTOR-NOTIFICATIO... | Return a set of notification objects . |
38,443 | public function canExecute ( $ action ) { if ( ! $ this -> actor ) { return false ; } if ( ! $ this -> actor -> isNotifiable ( ) ) { return false ; } if ( $ this -> actor -> authorize ( 'access' ) === false ) { return false ; } if ( $ this -> actor -> authorize ( 'administration' ) === false ) { return false ; } return... | Checks if this controller can be executed by the viewer . |
38,444 | protected function _actionBrowse ( AnCommandContext $ context ) { $ entities = parent :: _actionBrowse ( $ context ) ; if ( in_array ( $ this -> sort , array ( 'top' , 'trending' ) ) && $ this -> q == '' ) { $ package = $ this -> getIdentifier ( ) -> package ; $ name = $ this -> getIdentifier ( ) -> name ; $ entities -... | Browse Service . |
38,445 | protected function _actionRead ( AnCommandContext $ context ) { if ( ! $ this -> _state -> viewer -> guest ( ) ) { $ this -> _state -> setItem ( $ this -> _state -> viewer ) ; $ this -> getResponse ( ) -> setRedirect ( route ( $ this -> _state -> viewer -> getURL ( ) ) ) ; } return $ this -> _state -> viewer ; } | Return the session . |
38,446 | protected function _actionAdd ( AnCommandContext $ context ) { $ data = $ context -> data ; dispatch_plugin ( 'user.onBeforeLoginPerson' , array ( 'credentials' => $ data ) ) ; if ( $ data -> return ) { AnRequest :: set ( 'session.return' , $ data -> return ) ; $ context -> url = base64UrlDecode ( $ data -> return ) ; ... | Authenticate a person and create a new session If a username password is passed then the user is first logged in . |
38,447 | protected function _actionDelete ( AnCommandContext $ context ) { $ viewer = $ this -> _state -> viewer ; $ person_id = $ viewer -> id ; dispatch_plugin ( 'user.onBeforeLogoutPerson' , array ( 'person' => $ viewer ) ) ; $ this -> getService ( 'com:people.helper.person' ) -> logout ( $ viewer ) ; dispatch_plugin ( 'user... | Deletes a session and logs out the user . |
38,448 | protected function _actionTokenlogin ( AnCommandContext $ context ) { if ( $ this -> token == '' ) { throw new AnErrorException ( array ( 'No token is provided' ) , AnHttpResponse :: FORBIDDEN ) ; } $ person = $ this -> getService ( 'repos:people.person' ) -> find ( array ( 'activationCode' => $ this -> token ) ) ; if ... | Logs in a user if an activation token is provided . |
38,449 | protected function _sanitize ( $ value ) { $ value = strip_tags ( $ value ) ; $ value = preg_replace ( '|%([a-fA-F0-9][a-fA-F0-9])|' , '---$1---' , $ value ) ; $ value = str_replace ( '%' , '' , $ value ) ; $ value = preg_replace ( '|---([a-fA-F0-9][a-fA-F0-9])---|' , '%$1' , $ value ) ; if ( $ this -> _utf8 ( $ value ... | Sanitize a Value . |
38,450 | protected function _utf8encode ( $ utf8_string , $ length ) { $ unicode = '' ; $ values = array ( ) ; $ num_octets = 1 ; $ unicode_length = 0 ; mbstring_binary_safe_encoding ( ) ; $ string_length = strlen ( $ utf8_string ) ; reset_mbstring_encoding ( ) ; for ( $ i = 0 ; $ i < $ string_length ; $ i ++ ) { $ value = ord ... | Encode the Unicode values to be used in the URI . This method is take from Wodpress formatting . php method utf8_uri_encode . |
38,451 | public function onBeforeLoginPerson ( AnEvent $ event ) { $ credentials = $ event -> credentials ; if ( ! $ this -> _canPerform ( ) ) { return false ; } if ( isset ( $ credentials [ 'username' ] ) ) { $ this -> _createToken ( $ credentials [ 'username' ] ) ; } } | This method should handle any login logic and report back to the subject . |
38,452 | protected function _createToken ( $ username ) { if ( isset ( $ this -> _person ) ) { return ; } $ api = $ this -> _getApi ( ) ; if ( ! $ api || ! $ api -> getUser ( ) -> id ) { return ; } if ( $ token = $ api -> getToken ( ) ) { $ person = AnService :: get ( 'repos:people.person' ) -> find ( array ( 'username' => $ us... | Creates a connect token . |
38,453 | protected function _getApi ( ) { $ post = AnRequest :: get ( 'post' , 'string' ) ; $ api = null ; try { if ( isset ( $ post [ 'oauth_token' ] ) && isset ( $ post [ 'oauth_handler' ] ) ) { $ api = ComConnectHelperApi :: getApi ( $ post [ 'oauth_handler' ] ) ; $ api -> setToken ( $ post [ 'oauth_token' ] , isset ( $ post... | Creates an api object either from the session or the values in the post . |
38,454 | public function group ( $ scopes , $ global = true ) { $ groups = array ( 'posts' => array ( ) , 'actors' => array ( ) , 'other' => array ( ) ) ; $ current = $ this -> _template -> getView ( ) -> current_scope ; foreach ( $ scopes as $ scope ) { if ( $ scope -> type == 'post' ) { $ groups [ 'posts' ] [ ] = $ scope ; } ... | Groups the scopes into posts actors and others . |
38,455 | public function addHashtag ( $ term ) { $ term = trim ( $ term ) ; if ( ! is_string ( $ term ) ) { return ; } if ( $ hashtag = $ this -> getService ( 'repos:hashtags.hashtag' ) -> findOrAddNew ( array ( 'name' => $ term ) ) ) { $ this -> hashtags -> insert ( $ hashtag ) ; return $ this ; } return ; } | Adds a hashtag to a hashtagable mixer entity . |
38,456 | public function removeHashtag ( $ term ) { $ term = trim ( $ term ) ; if ( ! is_string ( $ term ) ) { return ; } if ( $ hashtag = $ this -> getService ( 'repos:hashtags.hashtag' ) -> find ( array ( 'name' => $ term ) ) ) { $ this -> hashtags -> extract ( $ hashtag ) ; } return $ this ; } | Removes a hashtag from a hashtagable mixer entity . |
38,457 | protected function _actionVerify ( $ context ) { $ context -> response -> status = AnHttpResponse :: RESET_CONTENT ; $ this -> getItem ( ) -> verify ( ) ; return ; } | set verify to true |
38,458 | protected function _actionUnverify ( $ context ) { $ context -> response -> status = AnHttpResponse :: RESET_CONTENT ; $ this -> getItem ( ) -> unverify ( ) ; return ; } | set verify to false |
38,459 | public function render ( $ config = array ( ) ) { $ message = $ config [ 'message' ] ; unset ( $ config [ 'message' ] ) ; $ message = '<p>' . $ message . '</p>' ; $ buttons = isset ( $ config [ 'buttons' ] ) ? $ config [ 'buttons' ] : array ( ) ; unset ( $ config [ 'buttons' ] ) ; if ( ! empty ( $ buttons ) ) { foreach... | Renders a message using the passed configuration . |
38,460 | protected function _renderMessage ( $ message , $ config ) { $ config = new AnConfig ( $ config ) ; $ config -> append ( array ( 'type' => 'info' , ) ) ; $ message = '' . '<div class="alert alert-block alert-' . $ config -> type . '">' . '<a class="close" data-dismiss="alert" href="#">×</a>' . $ message . '</div>... | Renders an individual message . |
38,461 | protected function _renderButton ( $ label , $ attrbs ) { $ attrbs = new AnConfig ( $ attrbs ) ; $ attrbs -> append ( array ( 'class' => '' , ) ) ; $ attrbs -> class .= 'btn small' ; if ( isset ( $ attrbs -> type ) ) { $ attrbs -> class .= ' btn-' . $ attrbs -> type ; unset ( $ attrbs -> type ) ; } $ attrbs = AnConfig ... | Renders a button for a message . |
38,462 | public static function _ ( $ string , $ jsSafe = false ) { $ language = AnService :: get ( 'anahita:language' ) ; return $ language -> _ ( $ string , $ jsSafe ) ; } | Translates a string into the current language |
38,463 | public static function sprintf ( $ string ) { $ language = AnService :: get ( 'anahita:language' ) ; $ args = func_get_args ( ) ; if ( ! empty ( $ args ) ) { $ args [ 0 ] = $ language -> _ ( $ args [ 0 ] ) ; return call_user_func_array ( 'sprintf' , $ args ) ; } return '' ; } | Passes a string thru an sprintf |
38,464 | public function getColumn ( $ name ) { $ column = $ this -> _columns [ $ name ] ; if ( $ column -> resource !== $ this ) { $ column = clone $ column ; $ column -> resource = $ this ; $ this -> _columns [ $ name ] = $ column ; } return $ this -> _columns [ $ name ] ; } | Return a column . |
38,465 | public function getColumns ( ) { $ columns = array ( ) ; foreach ( $ this -> _columns as $ name => $ column ) { $ columns [ $ name ] = $ this -> getColumn ( $ name ) ; } return $ columns ; } | Return an array of columns for a table . |
38,466 | public function disconnect ( ) { if ( $ this -> isConnected ( ) ) { $ this -> _connection -> close ( ) ; $ this -> _connection = null ; $ this -> _connected = false ; } return $ this ; } | Disconnect from db |
38,467 | public function lockTable ( $ base , $ name ) { $ query = 'LOCK TABLES ' . $ this -> quoteName ( $ this -> getTableNeedle ( ) . $ base ) . ' WRITE' ; if ( $ base != $ name ) { $ query .= ', ' . $ this -> quoteName ( $ this -> getTableNeedle ( ) . $ name ) . ' READ' ; } $ context = $ this -> getCommandContext ( ) ; $ co... | Lock a table . |
38,468 | public function unlockTable ( ) { $ query = 'UNLOCK TABLES' ; $ context = $ this -> getCommandContext ( ) ; $ context -> table = $ base ; $ context -> query = $ query ; if ( $ this -> getCommandChain ( ) -> run ( 'before.unlocktable' , $ context ) !== false ) { $ context -> result = $ this -> execute ( $ context -> que... | Unlock a table . |
38,469 | protected function _fetchField ( $ result , $ key = 0 ) { $ return = null ; if ( $ row = $ result -> fetch_row ( ) ) { $ return = $ row [ ( int ) $ key ] ; } $ result -> free ( ) ; return $ return ; } | Fetch the first field of the first row |
38,470 | protected function _fetchFieldList ( $ result , $ key = 0 ) { $ array = array ( ) ; while ( $ row = $ result -> fetch_row ( ) ) { $ array [ ] = $ row [ ( int ) $ key ] ; } $ result -> free ( ) ; return $ array ; } | Fetch an array of single field results |
38,471 | protected function _fetchArrayList ( $ result , $ key = '' ) { $ array = array ( ) ; while ( $ row = $ result -> fetch_assoc ( ) ) { if ( $ key ) { $ array [ $ row [ $ key ] ] = $ row ; } else { $ array [ ] = $ row ; } } $ result -> free ( ) ; return $ array ; } | Fetch all result rows of a result set as an array of associative arrays |
38,472 | protected function _fetchObjectList ( $ result , $ key = '' ) { $ array = array ( ) ; while ( $ row = $ result -> fetch_object ( ) ) { if ( $ key ) { $ array [ $ row -> $ key ] = $ row ; } else { $ array [ ] = $ row ; } } $ result -> free ( ) ; return $ array ; } | Fetch all rows of a result set as an array of objects |
38,473 | protected function _parseTableInfo ( $ info ) { $ table = new AnDatabaseSchemaTable ; $ table -> name = $ info -> Name ; $ table -> engine = $ info -> Engine ; $ table -> type = $ info -> Comment == 'VIEW' ? 'VIEW' : 'BASE' ; $ table -> length = $ info -> Data_length ; $ table -> autoinc = $ info -> Auto_increment ; $ ... | Parse the raw table schema information |
38,474 | public static function getComposerFiles ( $ paths ) { settype ( $ paths , 'array' ) ; $ composers = array ( ) ; foreach ( $ paths as $ path ) { $ dirs = new \ DirectoryIterator ( $ path ) ; foreach ( $ dirs as $ dir ) { if ( $ dir -> isDot ( ) || $ dir -> isFile ( ) ) { continue ; } $ composer_file = $ dir -> getPathNa... | Searches a path to find composer . json files |
38,475 | public function priorityLabel ( $ todo ) { switch ( true ) { case $ todo -> priority > 1 : $ label = 'highest' ; break ; case $ todo -> priority == 1 : $ label = 'high' ; break ; case $ todo -> priority == - 1 : $ label = 'low' ; break ; case $ todo -> priority < - 1 : $ label = 'lowest' ; break ; default : $ label = '... | Return a priority label . |
38,476 | public function prioritylist ( $ selected = null ) { $ html = $ this -> _template -> getHelper ( 'html' ) ; if ( ! $ selected ) { $ selected = ComTodosDomainEntityTodo :: PRIORITY_NORMAL ; } $ options = array ( array ( ComTodosDomainEntityTodo :: PRIORITY_HIGHEST , AnTranslator :: _ ( 'COM-TODOS-TODO-PRIORITY-HIGHEST' ... | Todo item priority list . |
38,477 | public function initializeFromJob ( Aoe_Scheduler_Model_Job $ job ) { $ this -> setJobCode ( $ job -> getJobCode ( ) ) ; $ this -> setCronExpr ( $ job -> getCronExpression ( ) ) ; $ this -> setStatus ( Aoe_Scheduler_Model_Schedule :: STATUS_PENDING ) ; return $ this ; } | Initialize from job |
38,478 | public function schedule ( $ time = null ) { if ( is_null ( $ time ) ) { $ time = time ( ) ; } $ this -> setStatus ( Aoe_Scheduler_Model_Schedule :: STATUS_PENDING ) -> setCreatedAt ( strftime ( '%Y-%m-%d %H:%M:%S' , time ( ) ) ) -> setScheduledAt ( strftime ( '%Y-%m-%d %H:%M:00' , $ time ) ) -> save ( ) ; return $ thi... | Schedule this task to be executed at a given time |
38,479 | public function getJob ( ) { if ( is_null ( $ this -> job ) ) { $ this -> job = Mage :: getModel ( 'aoe_scheduler/job' ) -> load ( $ this -> getJobCode ( ) ) ; } return $ this -> job ; } | Get job configuration |
38,480 | public function getDuration ( ) { $ duration = false ; if ( $ this -> getExecutedAt ( ) && ( $ this -> getExecutedAt ( ) != '0000-00-00 00:00:00' ) ) { if ( $ this -> getFinishedAt ( ) && ( $ this -> getFinishedAt ( ) != '0000-00-00 00:00:00' ) ) { $ time = strtotime ( $ this -> getFinishedAt ( ) ) ; } elseif ( $ this ... | Get job duration . |
38,481 | public function isAlive ( ) { if ( $ this -> getStatus ( ) == Aoe_Scheduler_Model_Schedule :: STATUS_RUNNING ) { if ( time ( ) - strtotime ( $ this -> getLastSeen ( ) ) < 2 * 60 ) { return true ; } elseif ( $ this -> getHost ( ) == gethostname ( ) ) { if ( $ this -> checkPid ( ) ) { $ this -> setLastSeen ( strftime ( '... | Is this process still alive? |
38,482 | public function markAsDisappeared ( $ message = null ) { if ( ! is_null ( $ message ) ) { $ this -> setMessages ( $ message ) ; } $ this -> setStatus ( self :: STATUS_DISAPPEARED ) -> setFinishedAt ( $ this -> getLastSeen ( ) ) -> save ( ) ; $ this -> log ( sprintf ( 'Job "%s" (id: %s) disappeared. Message: %s' , $ thi... | Mark task as disappeared |
38,483 | public function kill ( ) { if ( ! $ this -> checkPid ( ) ) { $ this -> markAsDisappeared ( sprintf ( 'Did not kill job "%s" (id: %s), because it was already dead.' , $ this -> getJobCode ( ) , $ this -> getId ( ) ) ) ; return ; } if ( posix_kill ( $ this -> getPid ( ) , SIGINT ) ) { $ this -> log ( sprintf ( 'Sending S... | Kill this process |
38,484 | public function isAlwaysTask ( ) { $ isAlwaysTask = false ; try { $ job = $ this -> getJob ( ) ; $ isAlwaysTask = $ job && $ job -> isAlwaysTask ( ) ; } catch ( Exception $ e ) { Mage :: logException ( $ e ) ; } return $ isAlwaysTask ; } | Check if this is an always task |
38,485 | protected function _beforeSave ( ) { if ( ! $ this -> getScheduledBy ( ) && php_sapi_name ( ) !== 'cli' && Mage :: getSingleton ( 'admin/session' ) -> isLoggedIn ( ) ) { $ this -> setScheduledBy ( Mage :: getSingleton ( 'admin/session' ) -> getUser ( ) -> getId ( ) ) ; } $ collection = Mage :: getModel ( 'cron/schedule... | Processing object before save data |
38,486 | public function canRun ( $ throwException = false ) { if ( $ this -> isAlwaysTask ( ) ) { return true ; } $ now = time ( ) ; $ time = strtotime ( $ this -> getScheduledAt ( ) ) ; if ( $ time > $ now ) { return false ; } $ scheduleLifetime = Mage :: getStoreConfig ( Mage_Cron_Model_Observer :: XML_PATH_SCHEDULE_LIFETIME... | Check if this schedule can be run |
38,487 | protected function jobErrorContext ( ) { if ( ! Mage :: getStoreConfigFlag ( 'system/cron/enableErrorLog' ) ) { return ; } $ settings = array ( 'error_reporting' => intval ( Mage :: getStoreConfig ( 'system/cron/errorLevel' ) ) , 'log_errors' => true , 'display_errors' => true , 'error_log' => $ this -> getErrorLogFile... | Switch the job error context |
38,488 | protected function restoreErrorContext ( ) { if ( ! Mage :: getStoreConfigFlag ( 'system/cron/enableErrorLog' ) ) { return ; } restore_error_handler ( ) ; foreach ( $ this -> errorSettingsBackup as $ key => $ value ) { ini_set ( $ key , $ value ) ; } } | Restore the original error context |
38,489 | public function getErrorLogFile ( ) { $ replace = array ( '###PID###' => $ this -> getPid ( ) , '###ID###' => $ this -> getId ( ) , '###JOBCODE###' => $ this -> getJobCode ( ) ) ; $ basedir = Mage :: getBaseDir ( 'log' ) . DS . 'cron' . DS ; return $ basedir . str_replace ( array_keys ( $ replace ) , array_values ( $ r... | Get error log filename |
38,490 | protected function _startBufferToMessages ( ) { if ( ! Mage :: getStoreConfigFlag ( 'system/cron/enableJobOutputBuffer' ) ) { return $ this ; } if ( $ this -> _redirect ) { return $ this ; } $ this -> addMessages ( '---START---' . PHP_EOL ) ; ob_start ( array ( $ this , '_addBufferToMessages' ) , $ this -> _redirectOut... | Redirect all output to the messages field of this Schedule . We use ob_start with _addBufferToMessages to redirect the output . |
38,491 | protected function _stopBufferToMessages ( ) { if ( ! Mage :: getStoreConfigFlag ( 'system/cron/enableJobOutputBuffer' ) ) { return $ this ; } if ( ! $ this -> _redirect ) { return $ this ; } ob_end_flush ( ) ; $ this -> addMessages ( '---END---' . PHP_EOL ) ; $ this -> _redirect = false ; return $ this ; } | Stop redirecting all output to the messages field of this Schedule . We use ob_end_flush to stop redirecting the output . |
38,492 | public function saveMessages ( ) { if ( ! $ this -> getId ( ) ) { return $ this -> save ( ) ; } $ connection = Mage :: getSingleton ( 'core/resource' ) -> getConnection ( 'core_write' ) ; $ count = $ connection -> update ( $ this -> getResource ( ) -> getMainTable ( ) , array ( 'messages' => $ this -> getMessages ( ) )... | Save the messages directly to the schedule record . |
38,493 | protected function _getPdoWarning ( PDO $ pdo ) { $ originalErrorMode = $ pdo -> getAttribute ( PDO :: ATTR_ERRMODE ) ; $ pdo -> setAttribute ( PDO :: ATTR_ERRMODE , PDO :: ERRMODE_WARNING ) ; $ stm = $ pdo -> query ( 'SHOW WARNINGS' ) ; $ pdo -> setAttribute ( PDO :: ATTR_ERRMODE , $ originalErrorMode ) ; return $ stm... | Retrieve the last PDO warning . |
38,494 | public function setCronExpr ( $ expr ) { if ( $ expr == 'always' ) { $ this -> setData ( 'cron_expr' , $ expr ) ; } else { parent :: setCronExpr ( $ expr ) ; } return $ this ; } | Bypass parent s setCronExpr is the expression is always This will break trySchedule but always tasks will never be tried to scheduled anyway |
38,495 | public function getStatuses ( ) { $ schedules = clone $ this -> getCollection ( ) -> setOrder ( 'status' , Zend_Db_Select :: SQL_ASC ) ; $ schedules -> getSelect ( ) -> group ( 'status' ) -> reset ( Zend_Db_Select :: COLUMNS ) -> columns ( 'status' ) ; $ statuses = $ schedules -> getConnection ( ) -> fetchCol ( $ sched... | Gets statuses that are currently in the scheduler table |
38,496 | public function checkRunningAsCorrectUser ( ) { if ( Mage :: helper ( 'aoe_scheduler' ) -> runningAsConfiguredUser ( ) ) { return true ; } $ kill = Mage :: helper ( 'aoe_scheduler' ) -> getShouldKillOnWrongUser ( ) ; $ optionalKillMessage = ( $ kill ) ? ' Schedule will not run until this is addressed.' : '' ; $ this ->... | Check if the user running the process matches the configured user . Message will capture cases where the user is not set too in its response message . Process may optionally be killed or may be allowed to continue . |
38,497 | public function setLastRunUser ( $ user = null ) { if ( is_null ( $ user ) ) { $ user = Mage :: helper ( 'aoe_scheduler' ) -> getRunningUser ( ) ; } Mage :: getModel ( 'core/variable' ) -> loadByCode ( Aoe_Scheduler_Helper_Data :: VAR_LAST_RUN_USER_CODE ) -> setCode ( Aoe_Scheduler_Helper_Data :: VAR_LAST_RUN_USER_CODE... | Set the user who ran the last successfully started schedule into a core variable |
38,498 | public function decorateStatus ( $ status ) { switch ( $ status ) { case Aoe_Scheduler_Model_Schedule :: STATUS_SUCCESS : case Aoe_Scheduler_Model_Schedule :: STATUS_REPEAT : case Aoe_Scheduler_Model_Schedule :: STATUS_DIDNTDOANYTHING : $ result = '<span class="bar-green"><span>' . $ status . '</span></span>' ; break ;... | Decorate status values |
38,499 | public function decorateTime ( $ value , $ echoToday = false , $ dateFormat = null ) { if ( empty ( $ value ) || $ value == '0000-00-00 00:00:00' ) { $ value = '' ; } else { $ value = Mage :: getModel ( 'core/date' ) -> date ( $ dateFormat , $ value ) ; $ replace = array ( Mage :: getModel ( 'core/date' ) -> date ( 'Y-... | Decorate time values |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.