public function renderFile()
 {
     $this->oXmlDocument = new DOMDocument();
     $this->oUrl = $this->oXmlDocument->createElement('urlset');
     $this->oUrl->setAttribute('xmlns', $this->sXmlNamespace);
     $this->oXmlDocument->appendChild($this->oUrl);
     $oRootPage = PagePeer::getRootPage();
     $oRootNavigationItem = PageNavigationItem::navigationItemForPage($oRootPage);
     $this->renderNavigationItem($oRootNavigationItem);
     header('Content-Type: application/xml;charset=utf-8');
     print $this->oXmlDocument->saveXML();
 }
 public function pages($bIncludeVirtual = false)
 {
     $aResult = array();
     $cGather = function ($aNavigationItems, $iLevel) use(&$aResult, &$cGather, $bIncludeVirtual) {
         foreach ($aNavigationItems as $oNavigationItem) {
             if (!$bIncludeVirtual && !$oNavigationItem instanceof PageNavigationItem) {
                 continue;
             }
             $oResult = new StdClass();
             $oResult->level = $iLevel;
             $oResult->page_id = $oNavigationItem->getId();
             $oResult->name = $oNavigationItem->getName();
             $aResult[] = $oResult;
             if ($oNavigationItem->hasChildren(null, false, true)) {
                 $cGather($oNavigationItem->getChildren(null, false, true), $iLevel + 1);
             }
         }
     };
     $cGather(array(PageNavigationItem::navigationItemForPage(PagePeer::getRootPage())), 0);
     return $aResult;
 }
Exemple #3
0
 /**
  * render()
  */
 public function render()
 {
     FilterModule::getFilters()->handleRequestStarted();
     $bIsDynamic = false;
     $bIsAjaxRequest = Manager::isPost() && Manager::isXMLHttpRequest();
     $aAjaxSections = array('container' => array(), 'navigation' => array());
     ///@todo remove legacy support when the need fades
     $bIsLegacyAjaxRequest = $bIsAjaxRequest && isset($_REQUEST['container_only']);
     if ($bIsAjaxRequest) {
         if ($bIsLegacyAjaxRequest) {
             $_REQUEST['ajax_containers'] = array($_REQUEST['container_only']);
         }
         if (isset($_REQUEST['ajax_containers'])) {
             sort($_REQUEST['ajax_containers']);
             $aAjaxSections['container'] = $_REQUEST['ajax_containers'];
         }
         if (isset($_REQUEST['ajax_navigations'])) {
             sort($_REQUEST['ajax_navigations']);
             $aAjaxSections['navigation'] = $_REQUEST['ajax_navigations'];
         }
         if (isset($_REQUEST['ajax_title'])) {
             $aAjaxSections = array_merge($aAjaxSections, array('page_title' => true, 'link_text' => true, 'title' => true));
         }
         asort($aAjaxSections);
     }
     $sPageType = self::$CURRENT_PAGE->getPageType();
     $this->oPageType = PageTypeModule::getModuleInstance($sPageType, self::$CURRENT_PAGE, self::$CURRENT_NAVIGATION_ITEM);
     $aAllowedParams = $this->oPageType->acceptedRequestParams($bIsAjaxRequest ? $aAjaxSections['container'] : null);
     $bParamsNotAllowed = count(array_intersect($this->aPathRequestParams, $aAllowedParams)) !== count($this->aPathRequestParams);
     $this->bIsNotFound = $this->bIsNotFound || $bParamsNotAllowed;
     FilterModule::getFilters()->handlePageNotFoundDetectionComplete($this->bIsNotFound, self::$CURRENT_PAGE, self::$CURRENT_NAVIGATION_ITEM, array(&$this->bIsNotFound));
     if ($this->bIsNotFound) {
         FilterModule::getFilters()->handlePageNotFound();
         LinkUtil::sendHTTPStatusCode(404, 'Not Found');
         $sErrorPageName = Settings::getSetting('error_pages', 'not_found', null);
         $oPage = null;
         if ($sErrorPageName) {
             $oPage = PageQuery::create()->findOneByName($sErrorPageName);
         }
         if ($oPage === null) {
             die(TranslationPeer::getString('wns.page.not_found'));
         }
         self::$CURRENT_PAGE = $oPage;
         self::$CURRENT_NAVIGATION_ITEM = PageNavigationItem::navigationItemForPage($oPage);
         //Set correct page type of 404 page
         $sPageType = self::$CURRENT_PAGE->getPageType();
         $this->oPageType = PageTypeModule::getModuleInstance($sPageType, self::$CURRENT_PAGE);
     } else {
         $this->addCanonicalLink();
     }
     if (!$bIsAjaxRequest) {
         $oOutput = $this->getXHTMLOutput();
         $oOutput->render();
     } else {
         if (!$bIsLegacyAjaxRequest) {
             header("Content-Type: application/json;charset=utf-8");
         }
     }
     $sPageIdentifier = implode('/', self::$CURRENT_NAVIGATION_ITEM->getLink()) . '_' . Session::language();
     if ($bIsAjaxRequest) {
         $sPageIdentifier .= '_' . serialize($aAjaxSections);
     }
     // Init the template
     if ($bIsLegacyAjaxRequest) {
         $this->oTemplate = new Template(TemplateIdentifier::constructIdentifier('container', $_REQUEST['container_only']), null, true, true);
     } else {
         if ($bIsAjaxRequest) {
             $this->oTemplate = new AjaxTemplate($aAjaxSections, true);
         } else {
             $this->oTemplate = self::$CURRENT_PAGE->getTemplate(true);
         }
     }
     FilterModule::getFilters()->handleBeforePageFill(self::$CURRENT_PAGE, $this->oTemplate);
     if (!$bIsLegacyAjaxRequest) {
         $this->fillAttributes();
         $this->fillNavigation();
         $this->fillAutofill();
     }
     $this->fillContent();
     $this->renderTemplate();
     while (ob_get_level() > 0) {
         ob_end_flush();
     }
     FilterModule::getFilters()->handleRequestFinished(array(self::$CURRENT_PAGE, $bIsDynamic, $bIsAjaxRequest));
 }
 private function index(array $aPath)
 {
     $oNavigationItem = $this->oRootNavigationItem;
     PageNavigationItem::clearCache();
     while (count($aPath) > 0) {
         $oNavigationItem = $oNavigationItem->namedChild(array_shift($aPath), $this->sLanguageId, true, true);
     }
     FilterModule::getFilters()->handleNavigationPathFound($this->oRootNavigationItem, $oNavigationItem);
     FrontendManager::$CURRENT_NAVIGATION_ITEM = $oNavigationItem;
     $oPageNavigationItem = $oNavigationItem;
     while (!$oPageNavigationItem instanceof PageNavigationItem) {
         $oPageNavigationItem = $oPageNavigationItem->getParent();
     }
     FrontendManager::$CURRENT_PAGE = $oPageNavigationItem->getMe();
     $oPage = FrontendManager::$CURRENT_PAGE;
     $bIsNotFound = false;
     FilterModule::getFilters()->handlePageHasBeenSet($oPage, $bIsNotFound, $oNavigationItem);
     FilterModule::getFilters()->handleRequestStarted();
     FilterModule::getFilters()->handlePageNotFoundDetectionComplete($bIsNotFound, $oPage, $oNavigationItem, array(&$bIsNotFound));
     if ($bIsNotFound) {
         return false;
     }
     $sDescription = $oNavigationItem->getDescription($this->sLanguageId);
     if ($sDescription === null) {
         $sDescription = $oPage->getDescription($this->sLanguageId);
     }
     $aKeywords = array();
     foreach ($oPage->getConsolidatedKeywords($this->sLanguageId, true) as $sKeyword) {
         $aKeywords = array_merge($aKeywords, StringUtil::getWords($sKeyword));
     }
     $sTitle = $oNavigationItem->getTitle($this->sLanguageId);
     $sLinkText = $oNavigationItem->getLinkText($this->sLanguageId);
     if (!$sLinkText) {
         $sLinkText = $sTitle;
     }
     $sName = $oNavigationItem->getName();
     // Page type can prevent indexing
     if (!self::doIndex($oPage->getPageType(), $oNavigationItem)) {
         return false;
     }
     $oPageType = PageTypeModule::getModuleInstance($oPage->getPageType(), $oPage, $oNavigationItem);
     $aWords = $oPageType->getWords();
     $aWords = array_merge($aWords, StringUtil::getWords($sDescription), $aKeywords, StringUtil::getWords($sTitle), StringUtil::getWords($sLinkText), array($sName));
     $aPagePath = $oPage->getLink();
     $aNavigationItemPath = $oNavigationItem->getLink();
     $sPath = implode('/', array_diff($aNavigationItemPath, $aPagePath));
     $oSearchIndex = new SearchIndex();
     $oSearchIndex->setPageId($oPage->getId());
     $oSearchIndex->setPath($sPath);
     $oSearchIndex->setLinkText($sLinkText);
     $oSearchIndex->setPageTitle($sTitle);
     $oSearchIndex->setLanguageId($this->sLanguageId);
     $oSearchIndex->save();
     foreach ($aWords as $sWord) {
         $sWord = Synonyms::rootFor($sWord, $this->sLanguageId);
         $oSearchIndexWord = SearchIndexWordQuery::create()->filterBySearchIndex($oSearchIndex)->filterByWord($sWord)->findOne();
         if ($oSearchIndexWord === null) {
             $oSearchIndexWord = new SearchIndexWord();
             $oSearchIndexWord->setSearchIndex($oSearchIndex);
             $oSearchIndexWord->setWord($sWord);
         } else {
             $oSearchIndexWord->incrementCount();
         }
         $oSearchIndexWord->save();
     }
     return true;
 }
 /**
  * renderDateNavigationWidget()
  *
  * description: display date tree configured in journal/config/config.yml
  * @return Template object
  */
 private function renderDateNavigationWidget()
 {
     $oTemplate = $this->constructTemplate('widget_date_navigation');
     if ($this->archiveIsActive()) {
         $sHref = LinkUtil::link($this->oPage->getLinkArray());
         $oTemplate->replaceIdentifier('overview_page_href', $sHref, null, Template::NO_HTML_ESCAPE);
     }
     $oNavigation = new Navigation('journal_date_navigation_widget');
     $oTemplate->replaceIdentifier('date_navigation', $oNavigation->parse(PageNavigationItem::navigationItemForPage($this->oPage)));
     return $oTemplate;
 }
 public static function clearCache()
 {
     self::$NAVIGATION_ITEMS = array();
 }