/** * @param string $name The name of the item * @param NavigationItem $parent The parent of the item */ function __construct($name, $parent = null) { $this->name = $name; $this->disabled = false; if ($parent != null) { $parent->addChild($this); } }
public function build($navigationArray) { foreach ($navigationArray as $module => $items) { foreach ($items as $label => $destination) { if (is_array($destination)) { $children = array_slice($destination, 1); $destination = $destination[0]; $item = new NavigationItem($label, $destination, $module); foreach ($children as $childLabel => $childDestination) { $child = new NavigationItem($childLabel, $childDestination, $module); $item->addChild($child); } } else { $item = new NavigationItem($label, $destination, $module); } $this->items[] = $item; } } }
public function onNavigationItemChildrenRequested(NavigationItem $oNavigationItem) { if (!($oNavigationItem instanceof PageNavigationItem && $oNavigationItem->getIdentifier() === self::PARENT_PAGE_IDENTIFIER)) { return; } $aDocumentationPartKeys = array(); foreach (DocumentationProviderTypeModule::completeMetaData() as $sPart => $aLanguages) { if (isset($aLanguages[Session::language()])) { $aDocumentationPartKeys[$sPart] = false; } } foreach (DocumentationPartQuery::create()->filterByLanguageId(Session::language())->select('Key')->find() as $sPart) { $aDocumentationPartKeys[$sPart] = true; } ksort($aDocumentationPartKeys); $aDocumentations = DocumentationsFrontendModule::listQuery()->select(array('Key', 'Name', 'Title', 'NameSpace'))->find(); foreach ($aDocumentations as $aParams) { $aConfiguredParts = array(); foreach ($aDocumentationPartKeys as $sKey => $bIsInternal) { if (StringUtil::startsWith($sKey, $aParams['NameSpace'] . '.')) { $aConfiguredParts[$sKey] = $bIsInternal; unset($aDocumentationPartKeys[$sKey]); } else { if ($sKey > $aParams['NameSpace'] . '.') { break; } } } $sTitle = $aParams['Title'] != null ? $aParams['Title'] : $aParams['Name']; $oNavItem = new VirtualNavigationItem(self::ITEM_TYPE, $aParams['Key'], 'Dokumentation ' . $sTitle, $aParams['Name'], $aConfiguredParts); $oNavigationItem->addChild($oNavItem); } // if(count($aDocumentationPartKeys) > 0) { // $oNavItem = new VirtualNavigationItem(self::ITEM_TYPE_UNCATEGORIZED, 'uncategorized', TranslationPeer::getString('documentations.uncategorized'), null, $aDocumentationPartKeys); // $oNavigationItem->addChild($oNavItem); // } }