protected function fillAttributes() { FilterModule::getFilters()->handleFillPageAttributes(self::$CURRENT_PAGE, $this->oTemplate); $oMetaIncluder = ResourceIncluder::metaIncluder(); $sKeywords = self::$CURRENT_PAGE->getConsolidatedKeywords(); $sDescription = self::$CURRENT_PAGE->getDescription(); $oMetaIncluder->addMeta('keywords', $sKeywords); $oMetaIncluder->addMeta('description', $sDescription); // FIXME: Deprecated. Use the meta includer for this. $this->oTemplate->replaceIdentifier("meta_keywords", $sKeywords); $this->oTemplate->replaceIdentifier("meta_description", $sDescription); $this->oTemplate->replaceIdentifier("description", self::$CURRENT_NAVIGATION_ITEM->getDescription()); $this->oTemplate->replaceIdentifier("title", self::$CURRENT_NAVIGATION_ITEM->getTitle()); $this->oTemplate->replaceIdentifier("level", self::$CURRENT_NAVIGATION_ITEM->getLevel()); $this->oTemplate->replaceIdentifier("link_text", self::$CURRENT_NAVIGATION_ITEM->getLinkText()); $this->oTemplate->replaceIdentifier("navigation_name", self::$CURRENT_NAVIGATION_ITEM->getName()); $this->oTemplate->replaceIdentifier("navigation_title", self::$CURRENT_NAVIGATION_ITEM->getTitle()); $this->oTemplate->replaceIdentifier("page_link_text", self::$CURRENT_PAGE->getLinkText()); $this->oTemplate->replaceIdentifier("page_name", self::$CURRENT_PAGE->getName()); $this->oTemplate->replaceIdentifier("page_title", self::$CURRENT_PAGE->getPageTitle()); foreach (self::$CURRENT_PAGE->getPageProperties() as $oPageProperty) { $this->oTemplate->replaceIdentifier('pageProperty', $oPageProperty->getValue(), $oPageProperty->getName()); } $this->oTemplate->replaceIdentifier("page_type", self::$CURRENT_PAGE->getPageType()); $this->oTemplate->replaceIdentifier("page_id", self::$CURRENT_PAGE->getId()); $this->oTemplate->replaceIdentifier("page_identifier", self::$CURRENT_NAVIGATION_ITEM->getIdentifier()); $this->oTemplate->replaceIdentifierCallback("page_link", 'FrontendManager', 'replacePageLinkIdentifier'); if (Settings::getSetting('general', 'multilingual', true) && $this->oTemplate->hasIdentifier('language_chooser')) { $this->oTemplate->replaceIdentifier("language_chooser", Navigation::getLanguageChooser($this->oTemplate), null, Template::NO_HTML_ESCAPE); } FilterModule::getFilters()->handleFillAttributesFinished(self::$CURRENT_PAGE, $this->oTemplate); }
/** * @param main template * description: * - @see config.yml section language_chooser * - use parameter replaced in method * @return Template The rendered language chooser */ public static function getLanguageChooser($oMainTemplate) { $oTemplate = new Template(TemplateIdentifier::constructIdentifier('languages'), null, true); $oLanguageTemplate = new Template(Settings::getSetting("language_chooser", 'template', 'language'), array(DIRNAME_TEMPLATES, DIRNAME_NAVIGATION)); $sLinkSeparator = Settings::getSetting("language_chooser", 'link_separator', ' | '); $oLanguageActiveTemplate = null; $bShowActiveLanguage = Settings::getSetting("language_chooser", 'show_active_language', false); $bIsPreview = Manager::getCurrentManager() instanceof PreviewManager; if ($bShowActiveLanguage) { if (Settings::getSetting("language_chooser", 'template_active', false) !== false) { $oLanguageActiveTemplate = new Template(Settings::getSetting("language_chooser", 'template_active', 'language_active'), array(DIRNAME_TEMPLATES, DIRNAME_NAVIGATION)); } else { $oLanguageActiveTemplate = clone $oLanguageTemplate; } } // Find request variables $aParameters = array_diff_assoc($_REQUEST, $_COOKIE); unset($aParameters['path']); unset($aParameters['content_language']); // Check whether manager needs language to be included $bCurrentPathIncludesLanguage = call_user_func(array(Manager::getManagerClassNormalized(null), 'shouldIncludeLanguageInLink')); $aRequestPath = explode("/", Manager::getRequestedPath()); $aLanguages = LanguageQuery::create()->filterByIsActive(true)->exclude($bShowActiveLanguage ? false : ($bIsPreview ? 'edit' : 'current'))->orderBySort()->find(); foreach ($aLanguages as $i => $oLanguage) { $oLangTemplate = null; $oPageString = null; if ($oLanguage->getId() === Session::language()) { $oLangTemplate = $oLanguageActiveTemplate; $oLangTemplate->replaceIdentifier('class', 'active'); } else { $oPageString = PageStringQuery::create()->filterByPage(FrontendManager::$CURRENT_PAGE)->filterByLanguageId($oLanguage->getId())->filterByIsInactive(false)->findOne(); if ($oPageString === null) { continue; } $oLangTemplate = clone $oLanguageTemplate; } // If language is included, replace it by language id and set include_language param to false if ($bCurrentPathIncludesLanguage) { $aRequestPath[0] = $oLanguage->getPathPrefix(); $sLink = LinkUtil::link($aRequestPath, null, $aParameters, false); } else { $sLink = LinkUtil::link($aRequestPath, null, array_merge($aParameters, array('content_language' => $oLanguage->getId()))); } $oLangTemplate->replaceIdentifier('link', $sLink); // Add alternate language links if ($oPageString) { ResourceIncluder::metaIncluder()->addCustomResource(array('template' => 'link', 'rel' => 'alternate', 'lang' => $oLanguage->getId(), 'location' => $sLink, 'title' => $oPageString->getPageTitle())); } $oLangTemplate->replaceIdentifier('id', $oLanguage->getId()); $oLangTemplate->replaceIdentifier('name', $oLanguage->getLanguageName($oLanguage->getId())); $oLangTemplate->replaceIdentifier('name_in_current_lang', $oLanguage->getLanguageName()); $oTemplate->replaceIdentifierMultiple('languages', $oLangTemplate, null, Template::NO_NEWLINE); if ($i + 1 < count($aLanguages)) { $oTemplate->replaceIdentifierMultiple('languages', $sLinkSeparator, null, Template::NO_HTML_ESCAPE | Template::NO_NEWLINE); } } return $oTemplate; }