/** * @param Page $page * * @return Section */ public static function getBySectionOfSite($page) { $identifier = sprintf('/multilingual/section/%s', $page->getCollectionID()); $cache = \Core::make('cache/request'); $item = $cache->getItem($identifier); if (!$item->isMiss()) { $returnID = $item->get(); } else { $item->lock(); if ($page->getPageTypeHandle() == STACKS_PAGE_TYPE) { $parent = Page::getByID($page->getCollectionParentID()); if ($parent->getCollectionPath() == STACKS_PAGE_PATH) { // this is the default multilingual section. return static::getDefaultSection(); } else { // this is a stack category page type $locale = $parent->getCollectionHandle(); return static::getByLocale($locale); } } // looks at the page, traverses its parents until it finds the proper language $nav = \Core::make('helper/navigation'); $pages = $nav->getTrailToCollection($page); $pages = array_reverse($pages); $pages[] = $page; $ids = self::getIDList(); $returnID = false; foreach ($pages as $pc) { if (in_array($pc->getCollectionID(), $ids)) { $returnID = $pc->getCollectionID(); } } $item->set($returnID); } if ($returnID) { return static::getByID($returnID); } }
/** * Gets the cID of the page's parent. * * @return int */ public function getCollectionParentID() { return parent::getCollectionParentID(); }