/** * @param PageModel $currentPage * * @return NavigationItem[] * * @throws \RuntimeException */ public function findNavigationItems(PageModel $currentPage) { $rootPages = $this->pageFinder->findRootPagesForPage($currentPage, false, false); $navigationItems = $this->createNavigationItemsForRootPages($rootPages); $this->setTargetPageForNavigationItems($navigationItems, $rootPages, $this->pageFinder->findAssociatedForPage($currentPage)); foreach ($navigationItems as $k => $item) { if (!$item->hasTargetPage()) { $item->setTargetPage($this->pageFinder->findAssociatedParentForLanguage($currentPage, $item->getLanguageTag()), false); } } $this->languageText->orderNavigationItems($navigationItems); return array_values($navigationItems); }
public function onMasterOptions(DataContainer $dc) { if (($jumpTo = PageModel::findByPk($dc->activeRecord->jumpTo)) === null) { return []; } $associated = []; $pageFinder = new PageFinder(); foreach ($pageFinder->findAssociatedForPage($jumpTo, true) as $page) { $associated[] = $page->id; } if (0 === count($associated)) { return []; } $options = []; $result = Database::getInstance()->prepare(' SELECT id, title FROM ' . $this->table . ' WHERE jumpTo IN (' . implode(',', $associated) . ') AND master=0 ORDER BY title ')->execute($dc->activeRecord->language); while ($result->next()) { $options[$result->id] = sprintf($GLOBALS['TL_LANG'][$this->table]['isSlave'], $result->title); } return $options; }