1212use luya \cms \menu \Item ;
1313use luya \cms \menu \InjectItemInterface ;
1414use luya \cms \menu \QueryOperatorFieldInterface ;
15+ use yii \db \Expression ;
1516
1617/**
1718 * Menu container component by language.
@@ -565,16 +566,17 @@ public function getModulesMap()
565566 */
566567 private function getNavData ($ langId )
567568 {
568- return (new DbQuery ())->from (['cms_nav_item item ' ])
569- ->select (['item.id ' , 'item.nav_id ' , 'item.title ' , 'item.description ' , 'item.keywords ' , 'item.alias ' , 'item.title_tag ' , 'item.timestamp_create ' , 'item.timestamp_update ' , 'item.create_user_id ' , 'item.update_user_id ' , 'nav.is_home ' , 'nav.parent_nav_id ' , 'nav.sort_index ' , 'nav.is_hidden ' , 'item.nav_item_type ' , 'item.nav_item_type_id ' , 'nav_container.alias AS container ' ])
570- ->leftJoin ('cms_nav nav ' , 'nav.id=item.nav_id ' )
571- ->leftJoin ('cms_nav_container nav_container ' , 'nav_container.id=nav.nav_container_id ' )
572- ->where (['nav.is_deleted ' => false , 'item.lang_id ' => $ langId , 'nav.is_offline ' => false , 'nav.is_draft ' => false ])
573- ->andWhere (['or ' , ['publish_from ' => null ], ['<= ' , 'publish_from ' , time ()]])
574- ->andWhere (['or ' , ['publish_till ' => null ], ['>= ' , 'publish_till ' , time ()]])
575- ->orderBy (['container ' => 'ASC ' , 'parent_nav_id ' => 'ASC ' , 'nav.sort_index ' => 'ASC ' ])
576- ->indexBy ('id ' )
577- ->all ();
569+ return (new DbQuery ())
570+ ->from (['cms_nav_item item ' ])
571+ ->select (['item.id ' , 'item.nav_id ' , 'item.title ' , 'item.description ' , 'item.keywords ' , 'item.alias ' , 'item.title_tag ' , 'item.timestamp_create ' , 'item.timestamp_update ' , 'item.create_user_id ' , 'item.update_user_id ' , 'nav.is_home ' , 'nav.parent_nav_id ' , 'nav.sort_index ' , 'nav.is_hidden ' , 'item.nav_item_type ' , 'item.nav_item_type_id ' , 'nav_container.alias AS container ' ])
572+ ->leftJoin ('cms_nav nav ' , 'nav.id=item.nav_id ' )
573+ ->leftJoin ('cms_nav_container nav_container ' , 'nav_container.id=nav.nav_container_id ' )
574+ ->where (['nav.is_deleted ' => false , 'item.lang_id ' => $ langId , 'nav.is_offline ' => false , 'nav.is_draft ' => false ])
575+ ->andWhere (['or ' , ['publish_from ' => null ], ['<= ' , 'publish_from ' , new Expression ('UNIX_TIMESTAMP() ' )]])
576+ ->andWhere (['or ' , ['publish_till ' => null ], ['>= ' , 'publish_till ' , new Expression ('UNIX_TIMESTAMP() ' )]])
577+ ->orderBy (['container ' => 'ASC ' , 'parent_nav_id ' => 'ASC ' , 'nav.sort_index ' => 'ASC ' ])
578+ ->indexBy ('id ' )
579+ ->all ();
578580 }
579581
580582 private $ _paths = [];
@@ -597,19 +599,19 @@ private function buildIndexForContainer($data)
597599 }
598600
599601 foreach ($ this ->_nodes as $ node ) {
600- $ this ->_paths [$ node ['nav_id ' ]] = $ this ->processParant ($ node ['nav_id ' ], null );
602+ $ this ->_paths [$ node ['nav_id ' ]] = $ this ->processParent ($ node ['nav_id ' ], null );
601603 }
602604
603605 return $ this ->_paths ;
604606 }
605607
606- private function processParant ($ nodeId , $ path )
608+ private function processParent ($ nodeId , $ path )
607609 {
608610 $ parentId = $ this ->_nodes [$ nodeId ]['parent_nav_id ' ];
609611 $ alias = $ this ->_nodes [$ nodeId ]['alias ' ];
610612
611613 if ($ parentId > 0 && array_key_exists ($ parentId , $ this ->_nodes )) {
612- return $ this ->processParant ($ parentId , $ path ) . '/ ' . $ alias ;
614+ return $ this ->processParent ($ parentId , $ path ) . '/ ' . $ alias ;
613615 }
614616
615617 return $ alias ;
0 commit comments