idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
55,800
private function filter ( array $ containerData , array $ whereExpression , array $ withCondition ) { $ data = array_filter ( $ containerData , function ( $ item ) use ( $ whereExpression , $ withCondition ) { foreach ( $ item as $ field => $ value ) { if ( ! $ this -> arrayFilter ( $ value , $ field , $ whereExpressio...
Filtering data based on a where expression .
55,801
private function arrayFilter ( $ value , $ field , array $ where , array $ with ) { if ( $ field == 'is_hidden' && $ with [ 'hidden' ] === false && $ value == 1 ) { return false ; } foreach ( $ where as $ expression ) { if ( $ expression [ 'field' ] == $ field ) { switch ( $ expression [ 'op' ] ) { case '==' : return (...
Filter an array item based on the where expression .
55,802
public function eventAfterUpdate ( ) { $ this -> updateNavItemTimesamp ( ) ; if ( ! empty ( $ this -> _olds ) ) { $ oldPlaceholderVar = $ this -> _olds [ 'placeholder_var' ] ; $ oldPrevId = ( int ) $ this -> _olds [ 'prev_id' ] ; if ( $ oldPlaceholderVar != $ this -> placeholder_var || $ oldPrevId != $ this -> prev_id ...
Event after update
55,803
public function eventBeforeDelete ( ) { $ this -> deleteAllSubBlocks ( $ this -> id ) ; $ this -> _olds = $ this -> getOldAttributes ( ) ; $ class = ( $ this -> block ) ? $ this -> block -> getNameForLog ( ) : '[class has been removed from the filesystem]' ; Log :: add ( 3 , [ 'tableName' => 'cms_nav_item_page_block_it...
Event before delete
55,804
public function eventAfterDelete ( ) { $ this -> updateNavItemTimesamp ( ) ; if ( ! empty ( $ this -> _olds ) ) { $ this -> reindex ( $ this -> _olds [ 'nav_item_page_id' ] , $ this -> _olds [ 'placeholder_var' ] , $ this -> _olds [ 'prev_id' ] ) ; } }
Event after delete
55,805
public function eventAfterInsert ( ) { $ this -> updateNavItemTimesamp ( ) ; $ this -> reindex ( $ this -> nav_item_page_id , $ this -> placeholder_var , $ this -> prev_id ) ; Log :: add ( 1 , [ 'tableName' => 'cms_nav_item_page_block_item' , 'action' => 'insert' , 'row' => $ this -> id , 'pageTitle' => $ this -> dropp...
Event after insert
55,806
private function reindex ( $ navItemPageId , $ placeholderVar , $ prevId ) { $ index = 0 ; $ datas = self :: originalFind ( ) -> andWhere ( [ 'nav_item_page_id' => $ navItemPageId , 'placeholder_var' => $ placeholderVar , 'prev_id' => $ prevId ] ) -> orderBy ( [ 'sort_index' => SORT_ASC , 'timestamp_create' => SORT_DES...
Reindex the page block items in order to get requestd sorting .
55,807
public function actionConfig ( ) { $ keys = [ Config :: HTTP_EXCEPTION_NAV_ID ] ; foreach ( Yii :: $ app -> request -> bodyParams as $ key => $ value ) { if ( in_array ( $ key , $ keys ) ) { Config :: set ( $ key , $ value ) ; } } $ data = [ ] ; $ data [ Config :: HTTP_EXCEPTION_NAV_ID ] = Config :: get ( Config :: HTT...
Return the general cms page configuration .
55,808
public function actionDashboardLog ( ) { $ data = Log :: find ( ) -> orderBy ( [ 'timestamp' => SORT_DESC ] ) -> with ( [ 'user' ] ) -> limit ( 60 ) -> all ( ) ; $ log = [ ] ; foreach ( $ data as $ item ) { $ log [ strtotime ( 'today' , $ item -> timestamp ) ] [ ] = $ item ; } $ array = [ ] ; krsort ( $ log , SORT_NUME...
Get all logs for the cms in order to render the dashboard
55,809
public function actionDataBlocks ( ) { $ favs = Yii :: $ app -> adminuser -> identity -> setting -> get ( "blockfav" , [ ] ) ; $ groups = [ ] ; foreach ( BlockGroup :: find ( ) -> with ( [ 'blocks' ] ) -> all ( ) as $ blockGroup ) { $ blocks = [ ] ; $ groupPosition = null ; foreach ( $ blockGroup -> blocks as $ block )...
Get all blocks which can be dropped into a page grouped by group .
55,810
public function afterDelete ( ) { if ( $ this -> cachedDeletedId ) { foreach ( NavItemPageBlockItem :: find ( ) -> where ( [ 'block_id' => $ this -> cachedDeletedId ] ) -> all ( ) as $ item ) { $ item -> delete ( ) ; } } parent :: afterDelete ( ) ; }
Search for entries with cached block id in cms_nav_item_page_block_item and delete them
55,811
public function getNameForLog ( ) { if ( $ this -> getClassObject ( ) && $ this -> getClassObject ( ) instanceof BlockInterface ) { return $ this -> getClassObject ( ) -> name ( ) ; } return $ this -> class ; }
Try to get the name of the log .
55,812
public static function createObject ( $ class , $ blockId , $ id , $ context , $ pageObject = null ) { if ( ! class_exists ( $ class ) ) { return false ; } $ object = Yii :: createObject ( [ 'class' => $ class , ] ) ; $ object -> setEnvOption ( 'id' , $ id ) ; $ object -> setEnvOption ( 'blockId' , $ blockId ) ; $ obje...
Creates the block object and stores the object within a static block container .
55,813
public static function objectId ( $ blockId , $ id , $ context , $ pageObject = null ) { if ( isset ( self :: $ blocks [ $ blockId ] ) ) { $ block = self :: $ blocks [ $ blockId ] ; } else { $ block = self :: find ( ) -> select ( [ 'class' ] ) -> where ( [ 'id' => $ blockId ] ) -> asArray ( ) -> one ( ) ; static :: $ b...
Get the block object from the database with context informations .
55,814
public function actionLastUpdates ( ) { return NavItem :: find ( ) -> select ( [ 'cms_nav_item.title' , 'timestamp_update' , 'update_user_id' , 'nav_id' ] ) -> limit ( 10 ) -> orderBy ( [ 'timestamp_update' => SORT_DESC ] ) -> joinWith ( [ 'updateUser' => function ( $ q ) { $ q -> select ( [ 'firstname' , 'lastname' , ...
Returns an array of 10 items for last updated pages .
55,815
public function actionDelete ( $ navItemId ) { if ( ! Yii :: $ app -> adminuser -> canRoute ( Module :: ROUTE_PAGE_DELETE ) ) { throw new ForbiddenHttpException ( "Unable to perform this action due to permission restrictions" ) ; } $ model = NavItem :: findOne ( $ navItemId ) ; if ( $ model ) { return $ model -> delete...
Delete a nav item based on the id .
55,816
public function actionNavLangItem ( $ navId , $ langId ) { $ item = NavItem :: find ( ) -> with ( 'nav' ) -> where ( [ 'nav_id' => $ navId , 'lang_id' => $ langId ] ) -> one ( ) ; if ( $ item ) { return [ 'error' => false , 'item' => $ item -> toArray ( ) , 'nav' => $ item -> nav -> toArray ( ) , 'typeData' => ( $ item...
The data api for a nav id and correspoding language .
55,817
public function actionReloadPlaceholder ( $ navItemPageId , $ prevId , $ placeholderVar ) { $ navItemPage = NavItemPage :: findOne ( $ navItemPageId ) ; return NavItemPage :: getPlaceholder ( $ placeholderVar , $ prevId , $ navItemPage ) ; }
Get the data for a given placeholder variable inside a page id .
55,818
public function actionUpdateItemTypeData ( $ navItemId ) { return NavItem :: findOne ( $ navItemId ) -> updateType ( Yii :: $ app -> request -> post ( ) ) ; }
Update data for a given nav item id .
55,819
public function actionChangePageVersionLayout ( ) { $ params = Yii :: $ app -> request -> bodyParams ; $ pageItemId = $ params [ 'pageItemId' ] ; $ layoutId = $ params [ 'layoutId' ] ; $ alias = $ params [ 'alias' ] ; $ model = NavItemPage :: findOne ( [ 'id' => $ pageItemId ] ) ; if ( $ model ) { $ model -> forceNavIt...
Change the layout of a page version .
55,820
public function actionRemovePageVersion ( ) { $ pageId = Yii :: $ app -> request -> getBodyParam ( 'pageId' ) ; $ page = NavItemPage :: findOne ( ( int ) $ pageId ) ; if ( $ page ) { $ page -> forceNavItem -> updateTimestamp ( ) ; return $ page -> delete ( ) ; } return false ; }
Delete a given page from pageId body param .
55,821
public function actionCreatePageVersion ( ) { $ name = Yii :: $ app -> request -> post ( 'name' ) ; $ fromPageId = ( int ) Yii :: $ app -> request -> post ( 'fromPageId' ) ; $ navItemId = ( int ) Yii :: $ app -> request -> post ( 'navItemId' ) ; $ layoutId = Yii :: $ app -> request -> post ( 'layoutId' ) ; if ( empty (...
Create a new cms_nav_item_page for an existing nav_item this is also known as a new version of a page item .
55,822
public function setPostAttribute ( $ model , $ attribute ) { if ( $ attributeValue = Yii :: $ app -> request -> post ( $ attribute , null ) ) { $ model -> setAttribute ( $ attribute , $ attributeValue ) ; } }
extract a post var and set to model attribute with the same name .
55,823
public function actionTypePageContainer ( $ navItemId ) { $ navItem = NavItem :: findOne ( $ navItemId ) ; $ type = $ navItem -> getType ( ) ; $ layout = Layout :: findOne ( $ type -> layout_id ) ; if ( ! empty ( $ layout ) ) { $ layout -> json_config = json_decode ( $ layout -> json_config , true ) ; } return [ 'layou...
returns all the PAGE type specific informations .
55,824
public function actionMoveBefore ( $ moveItemId , $ droppedBeforeItemId ) { $ result = Nav :: moveToBefore ( $ moveItemId , $ droppedBeforeItemId ) ; if ( $ result !== true ) { Yii :: $ app -> response -> setStatusCode ( 422 , 'Found URL alias duplication in drop target "' . $ result [ 'title' ] . '".' ) ; } return [ '...
Move an item before an existing item .
55,825
public function actionMoveAfter ( $ moveItemId , $ droppedAfterItemId ) { $ result = Nav :: moveToAfter ( $ moveItemId , $ droppedAfterItemId ) ; if ( $ result !== true ) { Yii :: $ app -> response -> setStatusCode ( 422 , 'Found URL alias duplication in drop target "' . $ result [ 'title' ] . '".' ) ; } return [ 'succ...
Move an item after an existing item .
55,826
public function actionToggleBlockHidden ( $ blockId , $ hiddenState ) { $ block = NavItemPageBlockItem :: findOne ( $ blockId ) ; if ( $ block ) { $ block -> is_hidden = $ hiddenState ; return $ block -> update ( false ) ; } return false ; }
Toggle visibilty of a block .
55,827
public function actionGetNavItemPath ( $ navId ) { $ data = "" ; $ node = NavItem :: find ( ) -> where ( [ 'nav_id' => $ navId ] ) -> one ( ) ; if ( $ node ) { $ data .= $ node -> title ; $ parentNavId = $ navId ; while ( $ parentNavId != 0 ) { $ parentNavIdModel = Nav :: findOne ( $ parentNavId ) ; if ( $ parentNavIdM...
Get full constructed path of a nav item .
55,828
public function actionGetNavContainerName ( $ navId ) { $ nav = Nav :: findOne ( $ navId ) ; if ( $ nav ) { $ navCoontainer = NavContainer :: findOne ( $ nav -> nav_container_id ) ; if ( $ navCoontainer ) { return $ navCoontainer -> name ; } } return "" ; }
Get Container name for a nav item .
55,829
protected function handleBlockDefinitions ( array $ definitions ) { $ ids = [ ] ; foreach ( $ definitions as $ blockDefinition ) { $ block = Yii :: getAlias ( $ blockDefinition , false ) ; if ( $ block === false ) { $ block = $ blockDefinition ; } if ( is_file ( $ block ) ) { $ ids [ ] = $ this -> saveBlockByPath ( $ b...
Handle an array with defintions whether they are files or folders .
55,830
protected function saveBlocksFromFolder ( $ folder ) { $ ids = [ ] ; if ( is_dir ( $ folder ) ) { foreach ( FileHelper :: findFiles ( $ folder ) as $ blockItem ) { $ ids [ ] = $ this -> saveBlockByPath ( $ blockItem ) ; } } return $ ids ; }
Save all blocks from a given folder .
55,831
protected function saveBlock ( $ fullClassName ) { $ fullClassName = '\\' . ltrim ( $ fullClassName , '\\' ) ; $ model = Block :: find ( ) -> where ( [ 'class' => $ fullClassName ] ) -> one ( ) ; $ blockObject = $ this -> createBlockObject ( $ fullClassName ) ; $ blockGroupId = $ this -> getBlockGroupId ( $ blockObject...
Save a block by its given full class name .
55,832
protected function saveBlockByPath ( $ path ) { $ info = FileHelper :: classInfo ( $ path ) ; if ( $ info ) { $ className = $ info [ 'namespace' ] . '\\' . $ info [ 'class' ] ; return $ this -> saveBlock ( $ className ) ; } $ this -> addLog ( 'Unable to find block namespace for file ' . $ path ) ; return false ; }
Save a block by its path this will extract the namespace of the block in order to save it .
55,833
protected function getBlockGroupId ( BlockInterface $ blockObject ) { $ groupClassName = $ blockObject -> blockGroup ( ) ; $ groupClassName = '\\' . ltrim ( $ groupClassName , '\\' ) ; $ groupObject = Yii :: createObject ( [ 'class' => $ groupClassName ] ) ; $ group = BlockGroup :: findOne ( [ 'identifier' => $ groupOb...
The the group of a block based on the block object .
55,834
public function getAssignedTags ( ) { if ( $ this -> _assignedTags === null ) { $ ids = ArrayHelper :: getColumn ( $ this -> getContextConfigValue ( $ this -> varName , [ ] ) , 'value' ) ; $ this -> _assignedTags = Tag :: find ( ) -> where ( [ 'in' , 'id' , $ ids ] ) -> indexBy ( 'name' ) -> all ( ) ; } return $ this -...
Get assigned models for the current Block .
55,835
protected function injectorSetup ( ) { if ( $ this -> _injectorObjects === null ) { foreach ( $ this -> injectors ( ) as $ varName => $ injector ) { $ injector -> setContext ( $ this ) ; $ injector -> varName = $ varName ; $ injector -> setup ( ) ; $ this -> _injectorObjects [ $ injector -> varName ] = $ injector ; } }...
Setup injectors .
55,836
public function getVarValue ( $ key , $ default = false ) { return ( isset ( $ this -> _varValues [ $ key ] ) && $ this -> _varValues [ $ key ] != '' ) ? $ this -> _varValues [ $ key ] : $ default ; }
Get var value .
55,837
public function getCfgValue ( $ key , $ default = false ) { return ( isset ( $ this -> _cfgValues [ $ key ] ) && $ this -> _cfgValues [ $ key ] != '' ) ? $ this -> _cfgValues [ $ key ] : $ default ; }
Get cfg value .
55,838
public function addVar ( array $ varConfig , $ append = false ) { $ count = count ( $ this -> _vars ) ; $ iteration = $ append ? $ count + 1000 : $ count ; $ this -> _vars [ $ iteration ] = ( new BlockVar ( $ varConfig ) ) -> toArray ( ) ; }
Add a var variable to the config .
55,839
public function addCfg ( array $ cfgConfig , $ append = false ) { $ count = count ( $ this -> _cfgs ) ; $ iteration = $ append ? $ count + 1000 : $ count ; $ this -> _cfgs [ $ iteration ] = ( new BlockCfg ( $ cfgConfig ) ) -> toArray ( ) ; }
Add a cfg variable to the config .
55,840
public function getViewFileName ( $ extension ) { $ className = get_class ( $ this ) ; if ( preg_match ( '/\\\\([\w]+)$/' , $ className , $ matches ) ) { $ className = $ matches [ 1 ] ; } return $ className . '.' . $ extension ; }
Returns the name of the php file to be rendered .
55,841
protected function getPreviewImageSource ( ) { $ imageName = $ this -> getViewFileName ( 'jpg' ) ; $ reflector = new \ ReflectionClass ( $ this ) ; $ dirPath = dirname ( $ reflector -> getFileName ( ) , 2 ) ; $ imagePath = $ dirPath . '/images/blocks/' . $ imageName ; $ data = FileHelper :: getFileContent ( $ imagePath...
Path to the preview image .
55,842
public static function selectArrayOption ( array $ options , $ prompt = null ) { $ transform = [ ] ; if ( $ prompt ) { $ transform [ ] = [ 'value' => 0 , 'label' => $ prompt ] ; } foreach ( $ options as $ key => $ value ) { $ transform [ ] = [ 'value' => $ key , 'label' => $ value ] ; } return $ transform ; }
Create the options array for a zaa - select field based on an key value pairing array .
55,843
public static function checkboxArrayOption ( array $ options ) { $ transform = [ ] ; foreach ( $ options as $ key => $ value ) { $ transform [ ] = [ 'value' => $ key , 'label' => $ value ] ; } return [ 'items' => $ transform ] ; }
Create the Options list in the config for a zaa - checkbox - array based on an key = > value pairing array .
55,844
public static function imageArrayUpload ( $ value , $ applyFilter = false , $ returnObject = false ) { if ( ! empty ( $ value ) && is_array ( $ value ) ) { $ data = [ ] ; foreach ( $ value as $ key => $ item ) { $ image = static :: imageUpload ( $ item [ 'imageId' ] , $ applyFilter , true ) ; if ( $ image ) { if ( $ it...
Get the full array for the specific zaa - file - image - upload type
55,845
public static function fileUpload ( $ fileId , $ returnObject = false ) { if ( ! empty ( $ fileId ) ) { $ file = Yii :: $ app -> storage -> getFile ( $ fileId ) ; if ( $ file ) { if ( $ returnObject ) { return $ file ; } return $ file -> toArray ( ) ; } } return false ; }
Get file information based on input fileId .
55,846
public static function fileArrayUpload ( $ value , $ returnObject = false ) { if ( ! empty ( $ value ) && is_array ( $ value ) ) { $ data = [ ] ; foreach ( $ value as $ key => $ item ) { $ file = static :: fileUpload ( $ item [ 'fileId' ] , true ) ; if ( $ file ) { if ( ! empty ( $ item [ 'caption' ] ) ) { $ file -> ca...
Get the full array for the specific zaa - file - array - upload type
55,847
public function actionIndex ( $ itemId , $ version = false , $ date = false ) { if ( Yii :: $ app -> adminuser -> isGuest ) { throw new ForbiddenHttpException ( 'Unable to see the preview page, session expired or not logged in.' ) ; } $ navItem = NavItem :: findOne ( $ itemId ) ; if ( ! $ navItem ) { throw new NotFound...
Renders the preview action .
55,848
public function accept ( ) { $ event = new MenuItemEvent ( ) ; $ event -> item = $ this -> current ( ) ; if ( isset ( $ this -> getInnerIterator ( ) -> with [ 'hidden' ] ) ) { $ event -> visible = true ; } Yii :: $ app -> menu -> trigger ( Menu :: EVENT_ON_ITEM_FIND , $ event ) ; return $ event -> visible ; }
Verifys if an menu item does have valid event response .
55,849
public function matchRequestPath ( $ requestPath ) { foreach ( [ $ requestPath , urlencode ( $ requestPath ) , urldecode ( $ requestPath ) ] as $ path ) { foreach ( [ $ this -> catch_path , urlencode ( $ this -> catch_path ) , urldecode ( $ this -> catch_path ) ] as $ catch ) { if ( $ this -> pathMatcher ( $ path , $ c...
Match Request Path against catch_path .
55,850
private function pathMatcher ( $ input , $ catchPath ) { $ requestPath = '/' . ltrim ( $ input , '/' ) ; if ( StringHelper :: startsWithWildcard ( $ requestPath , $ catchPath ) ) { return true ; } return ( $ requestPath == $ catchPath ) ; }
Internal path matcher
55,851
public function varValue ( $ key , $ defaultValue = null , $ template = false ) { return $ this -> wrapTemplate ( $ key , $ this -> context -> getVarValue ( $ key , $ defaultValue ) , $ template ) ; }
The the content value of a var .
55,852
public function cfgValue ( $ key , $ defaultValue = null , $ template = false ) { return $ this -> wrapTemplate ( $ key , $ this -> context -> getCfgValue ( $ key , $ defaultValue ) , $ template ) ; }
Get the content of a cfg .
55,853
public function extraValue ( $ key , $ defaultValue = null , $ template = false ) { return $ this -> wrapTemplate ( $ key , $ this -> context -> getExtraValue ( $ key , $ defaultValue ) , $ template ) ; }
Get the value of an extra var .
55,854
public function loadModels ( ) { if ( $ this -> _loadModels === null ) { $ this -> _loadModels = Nav :: find ( ) -> indexBy ( 'id' ) -> where ( [ 'in' , 'id' , ArrayHelper :: getColumn ( $ this -> data , 'nav_id' ) ] ) -> with ( [ 'properties.adminProperty' ] ) -> all ( ) ; } return $ this -> _loadModels ; }
Load all models for ghe given Menu Query .
55,855
public function getLoadedModel ( $ id ) { return isset ( $ this -> _loadModels [ $ id ] ) ? $ this -> _loadModels [ $ id ] : null ; }
Get the model for a given id .
55,856
public function current ( ) { $ data = current ( $ this -> data ) ; return Query :: createItemObject ( $ data , $ this -> lang , $ this -> getLoadedModel ( $ data [ 'id' ] ) ) ; }
Iterator get current element generates a new object for the current item on accessing . s .
55,857
public function updateType ( array $ postData ) { $ model = $ this -> getType ( ) ; $ model -> setAttributes ( $ postData ) ; return $ model -> update ( ) ; }
Update attributes of the current nav item type relation .
55,858
public function verifyAlias ( $ alias , $ langId ) { if ( Yii :: $ app -> hasModule ( $ alias ) && $ this -> parent_nav_id == 0 ) { $ this -> addError ( 'alias' , Module :: t ( 'nav_item_model_error_modulenameexists' , [ 'alias' => $ alias ] ) ) ; return false ; } if ( $ this -> parent_nav_id === null ) { $ this -> add...
Alias verification .
55,859
public function validateAlias ( ) { $ dirty = $ this -> getDirtyAttributes ( [ 'alias' ] ) ; if ( ! isset ( $ dirty [ 'alias' ] ) ) { return true ; } if ( ! $ this -> verifyAlias ( $ this -> alias , $ this -> lang_id ) ) { return false ; } }
Alias Validator .
55,860
public function beforeCreate ( ) { $ this -> timestamp_create = time ( ) ; $ this -> timestamp_update = 0 ; $ this -> create_user_id = Module :: getAuthorUserId ( ) ; $ this -> update_user_id = Module :: getAuthorUserId ( ) ; $ this -> slugifyAlias ( ) ; }
Before create event .
55,861
public function eventBeforeUpdate ( ) { $ this -> timestamp_update = time ( ) ; $ this -> update_user_id = Module :: getAuthorUserId ( ) ; $ this -> slugifyAlias ( ) ; }
Before update event .
55,862
public function getObject ( ) { if ( $ this -> _object === null ) { $ this -> _object = $ this -> adminProperty -> createObject ( $ this -> value ) ; } return $ this -> _object ; }
Create the Property object with the given value .
55,863
public function getControllerClasses ( ) { $ moduleName = $ this -> getVarValue ( 'moduleName' , false ) ; return ( empty ( $ moduleName ) || ! Yii :: $ app -> hasModule ( $ moduleName ) ) ? [ ] : Yii :: $ app -> getModule ( $ moduleName ) -> getControllerFiles ( ) ; }
Get all module related controllers .
55,864
public function getModuleNames ( ) { $ data = [ ] ; foreach ( Yii :: $ app -> getFrontendModules ( ) as $ k => $ f ) { $ data [ ] = [ 'value' => $ k , 'label' => $ k ] ; } return $ data ; }
Get all available frontend modules to make module selection in block .
55,865
public function moduleContent ( $ moduleName ) { if ( $ this -> isAdminContext ( ) || empty ( $ moduleName ) || count ( $ this -> getEnvOptions ( ) ) === 0 || ! Yii :: $ app -> hasModule ( $ moduleName ) ) { return ; } $ module = Yii :: $ app -> getModule ( $ moduleName ) ; $ module -> context = 'cms' ; $ reflection = ...
Return the Module output based on the module name .
55,866
public function actionCatch ( $ path ) { $ compositePath = Yii :: $ app -> composition -> prependTo ( $ path ) ; foreach ( Redirect :: find ( ) -> all ( ) as $ redirect ) { if ( $ redirect -> matchRequestPath ( $ path ) ) { return $ redirect ; } if ( $ path !== $ compositePath ) { if ( $ redirect -> matchRequestPath ( ...
Find a redirect object for a given path info .
55,867
public function getJsonConfig ( $ node = null ) { $ json = Json :: decode ( $ this -> json_config ) ; if ( ! $ node ) { return $ json ; } if ( isset ( $ json [ $ node ] ) ) { return $ json [ $ node ] ; } return [ ] ; }
Get the json config as array .
55,868
public function getParent ( ) { return ( new Query ( ) ) -> where ( [ 'nav_id' => $ this -> parentNavId , 'container' => $ this -> getContainer ( ) ] ) -> with ( $ this -> _with ) -> lang ( $ this -> lang ) -> one ( ) ; }
Returns a Item - Object of the parent element if no parent element exists returns false .
55,869
public function down ( callable $ fn ) { $ parent = $ this -> with ( $ this -> _with ) -> getParent ( ) ; while ( $ parent ) { $ response = call_user_func_array ( $ fn , [ $ parent ] ) ; if ( $ response ) { return $ response ; } $ parent = $ parent -> with ( $ this -> _with ) -> getParent ( ) ; } return false ; }
Go down to a given element which is evalutaed trough a callable .
55,870
public function getSiblings ( ) { return ( new Query ( ) ) -> where ( [ 'parent_nav_id' => $ this -> parentNavId , 'container' => $ this -> container ] ) -> with ( $ this -> _with ) -> lang ( $ this -> lang ) -> all ( ) ; }
Get all sibilings for the current item this also includes the current item iteself .
55,871
public function getNextSibling ( ) { return ( new Query ( ) ) -> where ( [ 'parent_nav_id' => $ this -> parentNavId , 'container' => $ this -> container ] ) -> andWhere ( [ '>' , 'sort_index' , $ this -> sortIndex ] ) -> with ( $ this -> _with ) -> lang ( $ this -> lang ) -> orderBy ( [ 'sort_index' => SORT_ASC ] ) -> ...
Get the next sibling in the current siblings list .
55,872
public function getPrevSibling ( ) { return ( new Query ( ) ) -> where ( [ 'parent_nav_id' => $ this -> parentNavId , 'container' => $ this -> container ] ) -> andWhere ( [ '<' , 'sort_index' , $ this -> sortIndex ] ) -> with ( $ this -> _with ) -> lang ( $ this -> lang ) -> orderBy ( [ 'sort_index' => SORT_DESC ] ) ->...
Get the previous sibling in the current siblings list .
55,873
public function getModel ( ) { if ( $ this -> _model === null ) { $ this -> _model = Nav :: findOne ( $ this -> navId ) ; if ( empty ( $ this -> _model ) ) { throw new Exception ( 'The model active record could not be found for the corresponding nav item. Maybe you have inconsistent Database data.' ) ; } } return $ thi...
Get the ActiveRecord Model for the current Nav Model .
55,874
public function getPropertyValue ( $ varName , $ defaultValue = null ) { return $ this -> getProperty ( $ varName ) ? $ this -> getProperty ( $ varName ) -> getValue ( ) : $ defaultValue ; }
Get the value of a Property Object .
55,875
public function getLanguage ( $ shortCode ) { return ( array_key_exists ( $ shortCode , $ this -> getLanguages ( ) ) ) ? $ this -> getLanguages ( ) [ $ shortCode ] : false ; }
Get languag information for a specific language short code .
55,876
public function getLanguages ( ) { if ( $ this -> _languages === null ) { $ this -> _languages = ( new DbQuery ( ) ) -> select ( [ 'short_code' , 'id' ] ) -> indexBy ( 'short_code' ) -> from ( 'admin_lang' ) -> all ( ) ; } return $ this -> _languages ; }
Get an array with all available system languages based on the admin_lang table .
55,877
public function getRedirectMap ( ) { if ( $ this -> _redirectMap === null ) { $ this -> _redirectMap = ( new DbQuery ( ) ) -> select ( [ 'id' , 'type' , 'value' , 'target' ] ) -> from ( 'cms_nav_item_redirect' ) -> indexBy ( 'id' ) -> all ( ) ; } return $ this -> _redirectMap ; }
Get an array containing all redirect items from the database table cms_nav_item_redirect .
55,878
public function getCurrentAppendix ( ) { if ( $ this -> _current === null ) { $ this -> _current = $ this -> resolveCurrent ( ) ; } return $ this -> _currentAppendix ; }
Returns the parts of the rules who do not belong to the current active menu item link .
55,879
public function getLevelContainer ( $ level , Item $ baseItem = null ) { $ rootLine = ( $ level === 1 ) ? true : false ; $ level -- ; $ i = 1 ; if ( $ baseItem === null ) { $ baseItem = $ this -> getCurrent ( ) ; } foreach ( $ baseItem -> with ( 'hidden' ) -> getTeardown ( ) as $ item ) { if ( $ rootLine && $ i == 1 ) ...
Get all items for a specific level .
55,880
public function findAll ( array $ where , $ preloadModels = false ) { return ( new MenuQuery ( ) ) -> where ( $ where ) -> preloadModels ( $ preloadModels ) -> all ( ) ; }
Wrapper method to get all menu items for the current language without hidden items for the specific where statement .
55,881
private function resolveCurrent ( ) { $ requestPath = $ this -> request -> get ( 'path' , null ) ; if ( empty ( $ requestPath ) ) { $ home = $ this -> getHome ( ) ; if ( ! $ home ) { throw new NotFoundHttpException ( 'Home item could not be found, have you forget to set a default page?' ) ; } $ requestPath = $ home -> ...
Find the current element based on the request get property path .
55,882
public function buildItemLink ( $ alias , $ langShortCode ) { return Yii :: $ app -> getUrlManager ( ) -> prependBaseUrl ( $ this -> composition -> prependTo ( $ alias , $ this -> composition -> createRouteEnsure ( [ 'langShortCode' => $ langShortCode ] ) ) ) ; }
prepand the base url for the provided alias .
55,883
public function getModulesMap ( ) { if ( $ this -> _modulesMap === null ) { $ this -> _modulesMap = NavItemModule :: find ( ) -> select ( [ 'module_name' , 'id' ] ) -> indexBy ( 'id' ) -> asArray ( ) -> all ( ) ; } return $ this -> _modulesMap ; }
Return all nav item modules to request data later in items
55,884
private function getNavData ( $ langId ) { return ( new DbQuery ( ) ) -> from ( [ 'cms_nav_item item' ] ) -> select ( [ 'item.id' , 'item.nav_id' , 'item.title' , 'item.description' , 'item.keywords' , 'item.image_id' , 'item.is_url_strict_parsing_disabled' , 'item.alias' , 'item.title_tag' , 'item.timestamp_create' , ...
load all navigation items for a specific language id .
55,885
private function buildIndexForContainer ( $ data ) { $ this -> _paths = [ ] ; $ this -> _nodes = [ ] ; foreach ( $ data as $ item ) { $ this -> _nodes [ $ item [ 'nav_id' ] ] = [ 'parent_nav_id' => $ item [ 'parent_nav_id' ] , 'alias' => $ item [ 'alias' ] , 'nav_id' => $ item [ 'nav_id' ] ] ; } foreach ( $ this -> _no...
Helper method to build an index with all the alias paths to build the correct links .
55,886
private function aliasMatch ( array $ urlParts , $ strictParsing = false ) { if ( $ strictParsing ) { $ query = ( new MenuQuery ( ) ) -> where ( [ self :: FIELD_ALIAS => implode ( '/' , $ urlParts ) ] ) -> with ( 'hidden' ) -> andWhere ( [ self :: FIELD_TYPE => self :: ITEM_TYPE_MODULE ] ) -> one ( ) ; if ( $ query ) {...
helper method to see if the request url can be found in the active container .
55,887
private function loadLanguageContainer ( $ langShortCode ) { $ cacheKey = $ this -> _cachePrefix . $ langShortCode ; $ languageContainer = $ this -> getHasCache ( $ cacheKey ) ; if ( $ languageContainer === false ) { $ lang = $ this -> getLanguage ( $ langShortCode ) ; if ( ! $ lang ) { throw new NotFoundHttpException ...
Helper method to load all contaienr data for a specific langauge .
55,888
public function flushCache ( ) { foreach ( $ this -> getLanguages ( ) as $ lang ) { $ this -> deleteHasCache ( $ this -> _cachePrefix . $ lang [ 'short_code' ] ) ; } }
Flush all caching data for the menu for each language
55,889
public static function toModuleRoute ( $ moduleName , array $ route ) { $ item = Yii :: $ app -> menu -> find ( ) -> where ( [ 'module_name' => $ moduleName ] ) -> with ( [ 'hidden' ] ) -> one ( ) ; if ( $ item ) { return static :: toMenuItem ( $ item -> id , $ route ) ; } throw new Exception ( "The module route creati...
Helper method to create a route based on the module name and the route and params .
55,890
public static function toMenuNav ( $ navId , array $ route ) { $ menu = Yii :: $ app -> menu -> find ( ) -> where ( [ Menu :: FIELD_NAVID => $ navId ] ) -> with ( [ 'hidden' ] ) -> one ( ) ; return static :: toMenuNavItem ( $ menu -> id , $ route ) ; }
Create an url to a cms page based on the nav id .
55,891
public static function isAssoc ( array $ arr ) { return ( is_array ( $ arr ) && ( ! count ( $ arr ) || count ( array_filter ( array_keys ( $ arr ) , 'is_string' ) ) == count ( $ arr ) ) ) ; }
Test if array is an associative array
55,892
public static function mergeAssocArray ( $ to , $ from , $ clobber = true ) { if ( is_array ( $ from ) ) { foreach ( $ from as $ k => $ v ) { if ( ! isset ( $ to [ $ k ] ) ) { $ to [ $ k ] = $ v ; } else { $ to [ $ k ] = self :: mergeAssocArray ( $ to [ $ k ] , $ v , $ clobber ) ; } } return $ to ; } return $ clobber ?...
Merge contents from one associtative array to another
55,893
public function runDue ( Debugger $ debugger ) { $ debugger -> log ( 'Running commands...' ) ; $ backgroundProcessRunner = App :: make ( 'Indatus\Dispatcher\BackgroundProcessRunner' ) ; $ queue = $ this -> scheduleService -> getQueue ( $ debugger ) ; foreach ( $ queue -> flush ( ) as $ queueItem ) { $ command = $ queue...
Run all commands that are due to be run
55,894
public function runnableInEnvironment ( ScheduledCommandInterface $ command ) { $ environment = $ command -> environment ( ) ; if ( $ environment == '*' || $ environment == App :: environment ( ) ) { return true ; } if ( is_array ( $ environment ) && in_array ( App :: environment ( ) , $ environment ) ) { return true ;...
Determine if a scheduled command is in the correct environment
55,895
public function prepareOptions ( array $ options ) { $ optionPieces = [ ] ; foreach ( $ options as $ opt => $ value ) { if ( is_array ( $ value ) ) { foreach ( $ value as $ optArrayValue ) { $ optionPieces [ ] = '--' . $ opt . '="' . addslashes ( $ optArrayValue ) . '"' ; } } else { $ option = null ; if ( is_numeric ( ...
Prepare a command s options for command line usage
55,896
public function getRunCommand ( ScheduledCommandInterface $ scheduledCommand , array $ arguments = [ ] , array $ options = [ ] ) { $ platform = App :: make ( 'Indatus\Dispatcher\Platform' ) ; $ commandPieces = [ ] ; if ( $ platform -> isHHVM ( ) ) { $ commandPieces [ ] = '/usr/bin/env hhvm' ; } else { $ commandPieces [...
Get a command to run this application
55,897
public function getScheduledCommands ( ) { $ scheduledCommands = [ ] ; foreach ( $ this -> console -> all ( ) as $ command ) { if ( $ command instanceof ScheduledCommandInterface ) { $ scheduledCommands [ ] = $ command ; } } return $ scheduledCommands ; }
Get all commands that are scheduled
55,898
public function getQueue ( Debugger $ debugger ) { $ queue = App :: make ( 'Indatus\Dispatcher\Queue' ) ; foreach ( $ this -> getScheduledCommands ( ) as $ command ) { $ scheduler = App :: make ( 'Indatus\Dispatcher\Scheduling\Schedulable' ) ; $ schedules = $ command -> schedule ( $ scheduler ) ; if ( ! is_array ( $ sc...
Get all commands that are due to be run
55,899
public function getSchedule ( ) { return implode ( ' ' , [ $ this -> getScheduleMonth ( ) , $ this -> getScheduleWeek ( ) , $ this -> getScheduleDayOfMonth ( ) , $ this -> getScheduleDayOfWeek ( ) , $ this -> getScheduleHour ( ) , $ this -> getScheduleMinute ( ) ] ) ; }
Get the scheduling definition in a readable way