Пример #1
0
 public function setPageType($sPageType, $iPageId, $sLanguageId = null)
 {
     $this->sPageType = $sPageType;
     $oPage = PageQuery::create()->findPk($iPageId);
     if ($oPage === null) {
         throw new Exception("Invalid Page ID: {$iPageId}");
     }
     $this->oPageType = PageTypeModule::getModuleInstance($sPageType, PageQuery::create()->findPk($iPageId), null, $sLanguageId);
 }
Пример #2
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;
 }
 private function renderJournalEntries(JournalEntryQuery $oQuery = null, Template $oEntryTemplatePrototype, Template $oFullTemplate, Template $oCommentTemplate = null, $sContainer = null, $sIdentifier = null)
 {
     if ($oQuery === null) {
         $oQuery = FrontendJournalEntryQuery::create();
     }
     if ($sIdentifier === null) {
         $sIdentifier = 'container';
         if ($sContainer === null) {
             $sContainer = $this->sContainer;
         }
     }
     if (null !== $this->aFilteredJournalIds) {
         $oQuery->filterByJournalId($this->aFilteredJournalIds);
     } else {
         if ($this->aJournalIds) {
             $oQuery->filterByJournalId($this->aJournalIds);
         }
     }
     if (!empty($this->aFilteredTags)) {
         $oQuery->filterByTagName($this->aFilteredTags);
     }
     $this->addPagination($oQuery, $oFullTemplate);
     $aEntries = $oQuery->orderByPublishAt(Criteria::DESC)->find();
     if (count($aEntries) === 0) {
         $oFullTemplate->replaceIdentifier('no_result_info', $this->renderNoResult());
         return;
     }
     // create journal entry button in preview
     if ($this->bIsPreview) {
         $oInnerTemplate = new Template(TemplateIdentifier::constructIdentifier($sIdentifier, $sContainer), null, true);
         $oAddJournals = parent::constructTemplate('preview_add_entry_button');
         $oAddJournals->replaceIdentifier('item_template_name', $oEntryTemplatePrototype->getTemplateName());
         $aJournalsAvailable = JournalQuery::create()->filterById($this->aFilteredJournalIds)->find();
         $bSingleJournals = count($aJournalsAvailable) === 1;
         foreach ($aJournalsAvailable as $oJournal) {
             if (!$bSingleJournals) {
                 $oAddJournals->replaceIdentifierMultiple('journal', array('id' => $oJournal->getId(), 'name' => $oJournal->getName()));
             } else {
                 $oAddJournals->replaceIdentifier('journal_id_data', " data-journal_id={$oJournal->getId()}");
                 continue;
             }
         }
         $oInnerTemplate->replaceIdentifierMultiple($sIdentifier, $oAddJournals, $sContainer);
         $oFullTemplate->replaceIdentifier($sIdentifier, TagWriter::quickTag('div', array('class' => 'journal_list-container'), $oInnerTemplate), $sContainer, Template::LEAVE_IDENTIFIERS);
     }
     foreach ($aEntries as $oEntry) {
         $oFullTemplate->replaceIdentifierMultiple($sIdentifier, $this->renderEntry($oEntry, clone $oEntryTemplatePrototype), $sContainer);
     }
 }
 public function __construct(Page $oPage = null, NavigationItem $oNavigationItem = null)
 {
     parent::__construct($oPage, $oNavigationItem);
 }
 protected function getModuleType()
 {
     return PageTypeModule::getType();
 }
Пример #7
0
 /**
  * getPageTypes()
  * description:
  * called once in page_detail widget prepare
  * @return hash of page_types options
  */
 public function getPageTypes()
 {
     $aResult = array();
     foreach (Module::listModulesByType(PageTypeModule::getType()) as $sKey => $aValues) {
         $aResult[$sKey]['value'] = $sKey;
         $aResult[$sKey]['name'] = TranslationPeer::getString('page_type.' . $aValues['name'], null, StringUtil::makeReadableName($aValues['name']));
     }
     return $aResult;
 }
Пример #8
0
 public function __construct(Page $oPage = null, NavigationItem $oNavigationItem = null, $sLanguageId = null)
 {
     parent::__construct($oPage, $oNavigationItem);
     $this->sLanguageId = $sLanguageId;
 }