public static function setCurrentPage($oPage) { FrontendManager::$CURRENT_PAGE = $oPage; }
/** * 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; }
/** sendNewsletter() * * @param mixed string/object recipient * @param object oEmailTemplateInstance * * @return void */ private function sendNewsletter($mRecipient, $oEmailTemplateInstance) { if (is_object($mRecipient)) { $oEmailTemplateInstance->replaceIdentifier('recipient', $mRecipient->getName()); if ($mRecipient instanceof Subscriber && $this->oUnsubscribePage) { $sLanguageId = FrontendManager::shouldIncludeLanguageInLink() ? $this->oNewsletter->getLanguageId() : false; if (method_exists($mRecipient, 'getUnsubscribeQueryParams')) { $sUnsubscribeLink = LinkUtil::absoluteLink(LinkUtil::link($this->oUnsubscribePage->getLink(), 'FrontendManager', $mRecipient->getUnsubscribeQueryParams(), $sLanguageId)); $oEmailTemplateInstance->replaceIdentifier('unsubscribe_link', $sUnsubscribeLink); } } } else { $oEmailTemplateInstance->replaceIdentifier('recipient', $mRecipient); } // Send newsletter and store invalid emails try { $sPlainTextMethod = Settings::getSetting('newsletter', 'plain_text_alternative_method', 'markdown'); $oEMail = null; if ($sPlainTextMethod === null || $sPlainTextMethod === false) { $oEMail = new EMail($this->oNewsletter->getSubject(), $oEmailTemplateInstance, true); } else { $oEMail = new EMail($this->oNewsletter->getSubject(), MIMEMultipart::alternativeMultipartForTemplate($oEmailTemplateInstance, null, null, $sPlainTextMethod), true); } if (is_object($mRecipient)) { $oEMail->addRecipient($mRecipient->getEmail(), $mRecipient->getName() === $mRecipient->getEmail() ? null : $mRecipient->getName()); } else { $oEMail->addRecipient($mRecipient); } $oEMail->setSender($this->sSenderName, $this->sSenderEmailAddress); $oEMail->send(); } catch (Exception $e) { $this->aInvalidEmails[] = new NewsletterSendFailure($e, $mRecipient); } }
public function adminPreview($iObjectId) { if ($this->sLanguageId === null) { $this->sLanguageId = AdminManager::getContentLanguage(); } $oCurrentContentObject = $this->contentObjectById($iObjectId); $oCurrentLanguageObject = $oCurrentContentObject->getLanguageObject($this->sLanguageId); //Some frontend modules use this FrontendManager::$CURRENT_PAGE = $oCurrentContentObject->getPage(); //Some frontend modules generate links into the current manager – those need to be correct PreviewManager::setTemporaryManager(); $oModuleInstance = $this->backendModuleInstanceByLanguageObject($oCurrentLanguageObject); $aResult = array('preview_contents' => $this->getModuleContents($oModuleInstance, false)); PreviewManager::revertTemporaryManager(); return $aResult; }
protected function fillContent() { $this->oPageTypeWidget->setPageTypeModule($this->oPageType); $oResourceIncluder = ResourceIncluder::defaultIncluder(); $oConstants = new Template('constants.js', array(DIRNAME_TEMPLATES, 'preview')); $oConstants->replaceIdentifier('language_id', Session::getSession()->getUser()->getLanguageId()); $oConstants->replaceIdentifier('page_type', $this->oPageType->getModuleName()); $oConstants->replaceIdentifier('page_type_widget_session', $this->oPageTypeWidget->getSessionKey()); $oConstants->replaceIdentifier('admin_menu_widget_session', $this->oAdminMenuWidget->getSessionKey()); $oConstants->replaceIdentifier('current_page_id', self::$CURRENT_PAGE->getId()); $oResourceIncluder->addCustomJs($oConstants); $oResourceIncluder->addResource('preview/preview.js'); return parent::fillContent(); }