public function filterByDisplayLanguage($sLanguageId = null) { if ($sLanguageId === null) { $sLanguageId = Session::language(); } return $this->filterByLanguageId(null, Criteria::ISNULL)->_or()->filterByLanguageId(Session::language()); }
public function renderFrontend() { $aData = unserialize($this->getData()); $oTemplate = new Template($aData['template']); $oItemTemplatePrototype = new Template($aData['template'] . '_item'); $bItemFound = false; // FIXME: Keep track of output $oCorrespondingItems and refuse output if already done foreach ($aData['tags'] as $iTagID) { $oTag = TagQuery::create()->findPk($iTagID); if ($oTag === null) { continue; } $aCorrespondingItems = $oTag->getAllCorrespondingDataEntries($aData['types']); foreach ($aCorrespondingItems as $i => $oCorrespondingItem) { if (!method_exists($oCorrespondingItem, 'renderListItem')) { return; } if (!$oCorrespondingItem->shouldBeIncludedInList(Session::language(), FrontendManager::$CURRENT_PAGE)) { continue; } $bItemFound = true; $oItemTemplate = clone $oItemTemplatePrototype; $oItemTemplate->replaceIdentifier('model', get_class($oCorrespondingItem)); $oItemTemplate->replaceIdentifier('counter', $i + 1); $oCorrespondingItem->renderListItem($oItemTemplate); $oTemplate->replaceIdentifierMultiple("items", $oItemTemplate); } } if (!$bItemFound) { return null; } return $oTemplate; }
public function filterApprovedForLanguage($sLanguageId = null) { $sLanguageId = $sLanguageId === null ? Session::language() : $sLanguageId; $this->condition('language_null', 'Newsletter.LanguageId is null'); $this->condition('language_' . $sLanguageId, 'Newsletter.LanguageId = ?', $sLanguageId); return $this->filterByIsApproved(true)->where(array('language_null', 'language_' . $sLanguageId), Criteria::LOGICAL_OR); }
public function __construct($sSessionKey = null, $sModuleContents = null, $mModuleSettings = null) { parent::__construct($sSessionKey); $this->sModuleContents = $sModuleContents; if ($mModuleSettings === null || is_string($mModuleSettings)) { $this->aModuleSettings = Settings::getSetting('text_module', null, array()); if ($mModuleSettings !== null) { $this->aModuleSettings = array_merge($this->aModuleSettings, Settings::getSetting($mModuleSettings, 'text_module', array())); } } else { $this->aModuleSettings = $mModuleSettings; } $this->cleanupCss(); $this->cleanupStyles(); $this->cleanupFormatTags(); $this->cleanupInsertableParts(); $this->cleanupToolbar(); foreach ($this->aModuleSettings as $sKey => $mSetting) { $this->setSetting($sKey, $mSetting); } // let CKEDITOR find plugins $aPlugins = array(); foreach (ResourceFinder::create()->addPath(DIRNAME_WEB, ResourceIncluder::RESOURCE_TYPE_JS, 'widget', 'ckeditor-plugins')->addDirPath()->addRecursion()->addPath('plugin.js')->returnObjects()->find() as $oPluginPath) { $oPluginPath = $oPluginPath->parent(); $aPlugins[$oPluginPath->getFileName()] = $oPluginPath->getFrontendPath() . '/'; } if (count($aPlugins) === 0) { $aPlugins = null; } $this->setSetting('additional_plugin_paths', $aPlugins); $this->setSetting('language', Session::language()); }
public function getCreatedAtLocalized($sFormat = ' %e. %B %Y') { if (Session::language() === 'en') { $sFormat = ' %e %B %Y'; } return LocaleUtil::localizeDate($this->created_at, null, $sFormat); }
public function renderFile() { $oDocument = new DOMDocument(); $oRoot = $oDocument->createElement("rss"); $oRoot->setAttribute('version', "2.0"); $oDocument->appendChild($oRoot); $oChannel = $oDocument->createElement("channel"); /** * @todo parametrize the argument */ $oQuery = FrontendJournalEntryQuery::create()->mostRecentFirst()->limit(10); if ($this->aJournalIds) { $oQuery->filterByJournalId($this->aJournalIds); } self::addSimpleAttribute($oDocument, $oChannel, 'title', $this->oJournalPage->getPageTitle()); self::addSimpleAttribute($oDocument, $oChannel, 'description', $this->oJournalPage->getDescription()); self::addSimpleAttribute($oDocument, $oChannel, 'link', LinkUtil::absoluteLink(LinkUtil::link($this->oJournalPage->getFullPathArray(), 'FrontendManager'), null, LinkUtil::isSSL())); self::addSimpleAttribute($oDocument, $oChannel, 'language', Session::language()); self::addSimpleAttribute($oDocument, $oChannel, 'ttl', "15"); $oRoot->appendChild($oChannel); $aJournalEntries = $oQuery->find(); foreach ($aJournalEntries as $oJournalEntry) { $oItem = $oDocument->createElement('item'); foreach ($oJournalEntry->getRssAttributes($this->aJournalIds ? $this->oJournalPage : null) as $sAttributeName => $mAttributeValue) { self::attributeToNode($oDocument, $oItem, $sAttributeName, $mAttributeValue); } $oChannel->appendChild($oItem); } print $oDocument->saveXML(); }
public function __construct($sSetting = null, $bPrintDoctype = true, $sClassName = null, $sLanguage = null) { $this->sContentType = "text/html"; if ($sLanguage === null) { $sLanguage = Session::language(); } $this->sLanguage = $sLanguage; $this->sCharset = Settings::getSetting("encoding", "browser", "utf-8"); $this->sSetting = $sSetting; $this->bPrintDoctype = $bPrintDoctype; $this->sClassName = $sClassName; if ($this->sSetting === null) { $this->sSetting = Settings::getSetting('frontend', 'doctype', 'none'); } if ($this->sSetting === self::SETTING_NONE || $this->sSetting === self::SETTING_HTML_4_STRICT || $this->sSetting === self::SETTING_HTML_4_TRANSITIONAL || $this->sSetting === self::SETTING_HTML_5) { return; } if (@stristr(@$_SERVER["HTTP_ACCEPT"], "application/xhtml+xml")) { if (preg_match("/application\\/xhtml\\+xml;q=([01]|0\\.\\d{1,3}|1\\.0)/i", $_SERVER["HTTP_ACCEPT"], $matches)) { $xhtml_q = $matches[1]; if (preg_match("/text\\/html;q=([01]|0\\.\\d{1,3}|1\\.0)/i", $_SERVER["HTTP_ACCEPT"], $matches)) { $html_q = $matches[1]; if ((double) $xhtml_q >= (double) $html_q) { $this->sContentType = "application/xhtml+xml"; } } } else { $this->sContentType = "application/xhtml+xml"; } } }
public function getConsolidatedKeywords($sLanguageId = null, $bReturnArray = false) { if ($sLanguageId == null) { $sLanguageId = Session::language(); } $aKeywords = array(); $aKeywords[] = TranslationPeer::getString('meta.keywords', null, ''); $aTags = TagPeer::tagInstancesForObject($this); foreach ($aTags as $iKey => $oTag) { $aTags[$iKey] = $oTag->getTag()->getName(); } $aKeywords[] = $aTags; $aKeywords[] = Settings::getSetting('frontend', 'keywords', ''); $aKeywords[] = $this->getActivePageString()->getMetaKeywords(); $aResult = array(); foreach ($aKeywords as $iKey => $mKeywords) { if (!is_array($mKeywords)) { $mKeywords = explode(',', $mKeywords); } foreach ($mKeywords as $sKeyword) { $sKeyword = trim($sKeyword); if (!isset($aResult[$sKeyword]) && $sKeyword !== '') { $aResult[$sKeyword] = true; } } } if ($bReturnArray) { return array_keys($aResult); } return implode(', ', array_keys($aResult)); }
public function deleteRow($aRowData, $oCriteria) { $oLanguage = LanguagePeer::doSelectOne($oCriteria); if ($oLanguage->getIsDefault()) { throw new LocalizedException('wns.language.delete_default.denied'); } if ($oLanguage->getIsDefaultEdit()) { throw new LocalizedException('wns.language.delete_default.denied'); } if (LanguagePeer::doCount(new Criteria()) < 2) { throw new LocalizedException('wns.language.delete_last.denied'); } $sLanguageId = $oLanguage->getId(); foreach (LanguageObjectQuery::create()->filterByLanguageId($sLanguageId)->find() as $oLanguageObject) { $oHistory = $oLanguageObject->newHistory(); $oHistory->save(); $oLanguageObject->delete(); } $iResult = $oLanguage->delete(); $oReplacementLanguage = LanguageQuery::create()->findOne(); if (AdminManager::getContentLanguage() === $sLanguageId) { AdminManager::setContentLanguage(Settings::getSetting("session_default", AdminManager::CONTENT_LANGUAGE_SESSION_KEY, $oReplacementLanguage->getId())); } if (Session::language() === $sLanguageId) { Session::getSession()->setLanguage(Settings::getSetting("session_default", Session::SESSION_LANGUAGE_KEY, $oReplacementLanguage->getId())); } }
public function renderFile() { header("Content-Type: application/json;charset=utf-8"); $aRequest = array(); $sContentType = 'application/x-www-form-urlencoded'; if (isset($_SERVER['CONTENT_TYPE'])) { $sContentType = $_SERVER['CONTENT_TYPE']; } if (isset($_SERVER['HTTP_CONTENT_TYPE'])) { $sContentType = $_SERVER['HTTP_CONTENT_TYPE']; } if (StringUtil::startsWith($sContentType, 'application/json')) { $aRequest = json_decode(file_get_contents('php://input'), true); } else { foreach ($_REQUEST as $sKey => $sValue) { $aRequest[$sKey] = json_decode($sValue, true); } } $oSession = Session::getSession(); if (!isset($aRequest['session_language']) && $oSession->isAuthenticated()) { $aRequest['session_language'] = $oSession->getUser()->getLanguageId(); } $sPrevSessionLanguage = null; $sSetSessionLanguage = null; if (isset($aRequest['session_language'])) { $sPrevSessionLanguage = Session::language(); $sSetSessionLanguage = $aRequest['session_language']; $oSession->setLanguage($sSetSessionLanguage); } try { try { $mJSONData = $this->getJSON($aRequest); $sResult = json_encode($mJSONData); $iError = json_last_error(); if ($iError !== JSON_ERROR_NONE) { throw new LocalizedException('wns.error.json', array('json_error' => $iError, 'json_error_message' => self::$JSON_ERRORS[$iError])); } print $sResult; } catch (Exception $e) { //Handle the gift, not the wrapping… if ($e->getPrevious()) { throw $e->getPrevious(); } else { throw $e; } } } catch (LocalizedException $ex) { LinkUtil::sendHTTPStatusCode(500, 'Server Error'); print json_encode(array('exception' => array('message' => $ex->getLocalizedMessage(), 'code' => $ex->getCode(), 'file' => $ex->getFile(), 'line' => $ex->getLine(), 'trace' => $ex->getTrace(), 'parameters' => $ex->getMessageParameters(), 'exception_type' => $ex->getExceptionType()))); } catch (Exception $ex) { LinkUtil::sendHTTPStatusCode(500, 'Server Error'); ErrorHandler::handleException($ex, true); print json_encode(array('exception' => array('message' => "Exception when trying to execute the last action {$ex->getMessage()}", 'code' => $ex->getCode(), 'file' => $ex->getFile(), 'line' => $ex->getLine(), 'trace' => $ex->getTrace(), 'exception_type' => get_class($ex)))); } //If we changed the session language and no widget willfully changed it as well, reset it to the previous state if ($sPrevSessionLanguage !== null && Session::language() === $sSetSessionLanguage) { $oSession->setLanguage($sPrevSessionLanguage); } }
public function display(Template $oTemplate, $bIsPreview = false) { $sTemplateName = $this->oPage->getTemplateNameUsed(); $sLanguageId = Session::language(); $oListTemplate = null; $oItemTemplatePrototype = null; try { $oListTemplate = new Template("search_results/{$sTemplateName}"); $oItemTemplatePrototype = new Template("search_results/{$sTemplateName}_item"); } catch (Exception $e) { $oListTemplate = new Template("search_results/default"); $oItemTemplatePrototype = new Template("search_results/default_item"); } $aResults = array(); $sWords = isset($_REQUEST['q']) ? $_REQUEST['q'] : ''; if ($sWords) { $aWords = StringUtil::getWords($sWords, false, '%'); $oSearchWordQuery = SearchIndexWordQuery::create(); foreach ($aWords as $sWord) { $sWord = Synonyms::rootFor($sWord); $sComparison = Criteria::EQUAL; if (strpos($sWord, '%') !== false) { $sComparison = Criteria::LIKE; } $oSearchWordQuery->addOr(SearchIndexWordPeer::WORD, $sWord, $sComparison); } $oSearchWordQuery->joinSearchIndex()->useQuery('SearchIndex')->joinPage()->useQuery('Page')->active(true)->filterByIsProtected(false)->endUse()->endUse(); foreach ($oSearchWordQuery->find() as $oSearchIndexWord) { $iId = $oSearchIndexWord->getSearchIndexId(); if (isset($aResults[$iId])) { $aResults[$iId] += $oSearchIndexWord->getCount(); } else { $aResults[$iId] = $oSearchIndexWord->getCount(); } } arsort($aResults); } $oListTemplate->replaceIdentifier('count', count($aResults)); $oListTemplate->replaceIdentifier('search_string', $sWords); if (count($aResults) === 0) { $oListTemplate->replaceIdentifier('no_results', TranslationPeer::getString('wns.search.no_results', null, null, array('search_string' => $sWords))); } foreach ($aResults as $iIndexId => $iCount) { $oIndex = SearchIndexQuery::create()->findPk(array($iIndexId, $sLanguageId)); if (!$oIndex || !$oIndex->getPage()) { continue; } $oItemTemplate = clone $oItemTemplatePrototype; $oIndex->renderListItem($oItemTemplate); $oItemTemplate->replaceIdentifier('count', $iCount); $oListTemplate->replaceIdentifierMultiple('items', $oItemTemplate); } $oTemplate->replaceIdentifier('search_results', $oListTemplate); }
private static function &rootWords($sLanguageId = null) { self::init(); if ($sLanguageId === null) { $sLanguageId = Session::language(); } if (!isset(self::$ROOT_WORDS[$sLanguageId])) { self::$ROOT_WORDS[$sLanguageId] = array(); } return self::$ROOT_WORDS[$sLanguageId]; }
public function getLanguageObject($sLanguageId = null) { if ($sLanguageId === null) { $sLanguageId = Session::language(); } $oResult = $this->getLanguageObjectsByLanguage($sLanguageId); if (count($oResult) === 0) { return null; } return $oResult[0]; }
public function partFor($sDocumentationPartKey) { $oResult = new stdClass(); $aData = DocumentationProviderTypeModule::dataForPart($sDocumentationPartKey, Session::language()); if (!$aData) { throw new LocalizedException("wns.documentation.unknown", array('key' => $sDocumentationPartKey, 'language' => Session::language())); } $oResult->title = $aData['title']; $oResult->content = $aData['content']; $oResult->url = $aData['url']; return $oResult; }
public function display(Template $oTemplate, $bIsPreview = false) { $this->bIsPreview = $bIsPreview; if ($this->bIsPreview) { ResourceIncluder::defaultIncluder()->addResource('preview/jquery.ba-resize.min.js'); } if ($this->sLanguageId === null) { $this->sLanguageId = $this->bIsPreview ? AdminManager::getContentLanguage() : Session::language(); } $this->oFrontendTemplate = $oTemplate; $this->iModuleId = 1; $this->oFrontendTemplate->replaceIdentifierCallback("container", $this, "fillContainer", Template::NO_HTML_ESCAPE); }
protected function initLanguage() { $this->sOldSessionLanguage = Session::language(); if (isset($_REQUEST[AdminManager::CONTENT_LANGUAGE_SESSION_KEY]) && LanguageQuery::languageExists($_REQUEST[AdminManager::CONTENT_LANGUAGE_SESSION_KEY])) { AdminManager::setContentLanguage($_REQUEST[AdminManager::CONTENT_LANGUAGE_SESSION_KEY]); unset($_REQUEST[AdminManager::CONTENT_LANGUAGE_SESSION_KEY]); LinkUtil::redirect(LinkUtil::link(Manager::getRequestedPath(), get_class())); } else { if (!LanguageQuery::languageExists(AdminManager::getContentLanguage())) { AdminManager::setContentLanguage($this->sOldSessionLanguage); } if (!LanguageQuery::languageExists(AdminManager::getContentLanguage())) { LinkUtil::redirectToManager('', "AdminManager"); } } Session::getSession()->setLanguage(AdminManager::getContentLanguage()); }
public function renderFile() { $iTemplateFlags = 0; $oResourceFinder = ResourceFinder::create(array(DIRNAME_MODULES, $this->sModuleType, $this->sModuleName, DIRNAME_TEMPLATES))->returnObjects(); $sFileName = "{$this->sModuleName}.{$this->sModuleType}.{$this->sResourceType}"; $oResourceFinder->addPath($sFileName . Template::$SUFFIX); if ($this->sResourceType === ResourceIncluder::RESOURCE_TYPE_CSS) { header("Content-Type: text/css;charset=utf-8"); $oResourceFinder->all(); } else { if ($this->sResourceType === ResourceIncluder::RESOURCE_TYPE_JS) { header("Content-Type: text/javascript;charset=utf-8"); $iTemplateFlags = Template::ESCAPE | Template::NO_HTML_ESCAPE; } else { header("Content-Type: text/html;charset=utf-8"); } } $oCache = new Cache('template_resource-' . $sFileName . '-' . Session::language(), 'resource'); $oTemplate = null; if ($oCache->entryExists() && !$oCache->isOutdated($oResourceFinder)) { $oCache->sendCacheControlHeaders(); $oTemplate = $oCache->getContentsAsVariable(); } else { $oTemplate = new Template(TemplateIdentifier::constructIdentifier('contents'), null, true, false, null, $sFileName); $aResources = $oResourceFinder->find(); if (!$aResources) { $aResources = array(); } if ($aResources instanceof FileResource) { $aResources = array($aResources); } foreach ($aResources as $oResource) { $oSubTemplate = new Template($oResource, null, false, false, null, null, $iTemplateFlags); $oTemplate->replaceIdentifierMultiple('contents', $oSubTemplate, null, Template::LEAVE_IDENTIFIERS); } $oCache->setContents($oTemplate); $oCache->sendCacheControlHeaders(); } print $oTemplate->render(); }
public function exclude($mExclude = false) { if (!$mExclude) { return $this; } if ($mExclude === 'default') { $mExclude = Settings::getSetting("session_default", Session::SESSION_LANGUAGE_KEY, 'de'); } else { if ($mExclude === 'current') { $mExclude = Session::language(); } else { if ($mExclude === 'edit') { $mExclude = AdminManager::getContentLanguage(); } else { if ($mExclude instanceof Language) { $mExclude = $mExclude->getId(); } } } } return $this->filterById($mExclude, Criteria::NOT_EQUAL); }
/** * @deprecated use query methods directly in context */ public static function getLanguages($bActiveOnly = false, $bSortBySort = false, $mExcludeCurrent = false) { $oCriteria = new Criteria(); if ($bActiveOnly) { $oCriteria->add(self::IS_ACTIVE, true); } if ($mExcludeCurrent === 'default') { $mExcludeCurrent = Settings::getSetting("session_default", Session::SESSION_LANGUAGE_KEY, 'de'); } if ($mExcludeCurrent === true) { $mExcludeCurrent = Session::language(); } if ($mExcludeCurrent !== false) { $oCriteria->add(self::ID, $mExcludeCurrent, Criteria::NOT_EQUAL); } if ($bSortBySort) { $oCriteria->addAscendingOrderByColumn(self::SORT); } else { $oCriteria->addAscendingOrderByColumn(self::ID); } return self::doSelect($oCriteria); }
private function prepareChildren() { if ($this->aCustomChildren !== null) { return; } $sCacheKey = Session::language() . '/' . $this->getId(); $oCache = new Cache("{$sCacheKey}/custom-children", 'navigation'); if ($oCache->entryExists()) { // Not setting validators will result in the cache being always up-to-date $bIsOutdated = false; FilterModule::getFilters()->handleNavigationItemChildrenCacheDetectOutdated($this, $oCache, array(&$bIsOutdated)); if (!$bIsOutdated) { $this->aCustomChildren = $oCache->getContentsAsVariable(); foreach ($this->aCustomChildren as $oChildNavigationItem) { $oChildNavigationItem->oParent = $this; } return; } } $this->aCustomChildren = array(); FilterModule::getFilters()->handleNavigationItemChildrenRequested($this); $oCache->setContents($this->aCustomChildren, true); }
public function onNavigationItemChildrenRequested(NavigationItem $oNavigationItem) { if (!($oNavigationItem instanceof PageNavigationItem && $oNavigationItem->getIdentifier() === self::PARENT_PAGE_IDENTIFIER)) { return; } $aDocumentationPartKeys = array(); foreach (DocumentationProviderTypeModule::completeMetaData() as $sPart => $aLanguages) { if (isset($aLanguages[Session::language()])) { $aDocumentationPartKeys[$sPart] = false; } } foreach (DocumentationPartQuery::create()->filterByLanguageId(Session::language())->select('Key')->find() as $sPart) { $aDocumentationPartKeys[$sPart] = true; } ksort($aDocumentationPartKeys); $aDocumentations = DocumentationsFrontendModule::listQuery()->select(array('Key', 'Name', 'Title', 'NameSpace'))->find(); foreach ($aDocumentations as $aParams) { $aConfiguredParts = array(); foreach ($aDocumentationPartKeys as $sKey => $bIsInternal) { if (StringUtil::startsWith($sKey, $aParams['NameSpace'] . '.')) { $aConfiguredParts[$sKey] = $bIsInternal; unset($aDocumentationPartKeys[$sKey]); } else { if ($sKey > $aParams['NameSpace'] . '.') { break; } } } $sTitle = $aParams['Title'] != null ? $aParams['Title'] : $aParams['Name']; $oNavItem = new VirtualNavigationItem(self::ITEM_TYPE, $aParams['Key'], 'Dokumentation ' . $sTitle, $aParams['Name'], $aConfiguredParts); $oNavigationItem->addChild($oNavItem); } // if(count($aDocumentationPartKeys) > 0) { // $oNavItem = new VirtualNavigationItem(self::ITEM_TYPE_UNCATEGORIZED, 'uncategorized', TranslationPeer::getString('documentations.uncategorized'), null, $aDocumentationPartKeys); // $oNavigationItem->addChild($oNavItem); // } }
public function render() { $this->preRender(); $oTemplate = null; if (!Session::getSession()->isAuthenticated() || !Session::getSession()->getUser()->getIsBackendLoginEnabled()) { if (Session::getSession()->isAuthenticated() && !Session::getSession()->getUser()->getIsBackendLoginEnabled()) { Flash::getFlash()->addMessage('admin_login_denied'); Session::getSession()->logout(); } self::setContentLanguage(Session::language()); $oTemplate = new Template('login', array(DIRNAME_TEMPLATES, 'admin'), false, true); $oLoginWindowWidget = new LoginWindowWidgetModule(); LoginWindowWidgetModule::includeResources(); } else { $oTemplate = new Template('main', array(DIRNAME_TEMPLATES, 'admin'), false, true); $this->renderAdmin($oTemplate); } $oTemplate->replaceIdentifier("title", Settings::getSetting('admin', 'title', 'no title set in config/config.yml for admin'), null, Template::LEAVE_IDENTIFIERS); $oTemplate->replaceIdentifier('module_name', $this->sModuleName); $oTemplate->replaceIdentifier('module_display_name', AdminModule::getDisplayNameByName($this->sModuleName)); $oTemplate->render(); }
public function saveData($aNewsletterData) { $oNewsletter = NewsletterQuery::create()->findPk($this->iNewsletterId); if ($oNewsletter === null) { $oNewsletter = new Newsletter(); $oNewsletter->setCreatedBy(Session::getSession()->getUserId()); $oNewsletter->setCreatedAt(date('c')); } // If language is not set (not multilingual), write session language, since it is default language $sLanguageId = isset($aNewsletterData['language_id']) ? $aNewsletterData['language_id'] : Session::language(); $oNewsletter->setLanguageId($sLanguageId); $oNewsletter->setTemplateName($aNewsletterData['template_name']); $oNewsletter->setSubject($aNewsletterData['subject']); $oRichtextUtil = new RichtextUtil(); $oRichtextUtil->setTrackReferences($oNewsletter); $oNewsletter->setNewsletterBody($oRichtextUtil->parseInputFromEditor($aNewsletterData['newsletter_body'])); $this->validate($aNewsletterData, $oNewsletter); if (!Flash::noErrors()) { throw new ValidationException(); } if (isset($aNewsletterData['is_approved'])) { $oNewsletter->setIsApproved($aNewsletterData['is_approved']); } if (isset($aNewsletterData['template_name'])) { $oNewsletter->setTemplateName($aNewsletterData['template_name']); } return $oNewsletter->save(); }
/** * displayNewsletterList() * @param int/array subscriber group ids * @param boolean detail view link type * * Description $bDisplayFileLink * • true > render link to original newsletter view of get_file/display_newsletter/ analog to alternative view linked in newsletter * • false: display database "newsletter_body" only in normal page view * * @return Template */ private function displayNewsletterList($mSubscriberGroupId, $bDisplayFileLink = true) { $oQuery = NewsletterQuery::create()->distinct()->filterApprovedForLanguage(Session::language())->orderByCreatedAt(Criteria::DESC); if ($mSubscriberGroupId) { $oQuery->joinNewsletterMailing()->useQuery('NewsletterMailing')->filterBySubscriberGroupId($mSubscriberGroupId)->endUse(); } $aRecentNewsletters = $oQuery->limit(10)->find(); $bHasNewsletters = count($aRecentNewsletters) > 0; $oTemplate = $this->constructTemplate('newsletter_display_list'); if ($bHasNewsletters === false) { $oTemplate->replaceIdentifier('newsletter_item', TagWriter::quickTag('p', array('class' => 'no_result_message'), TranslationPeer::getString('wns.newsletter.no_newsletter_available'))); } if ($bDisplayFileLink) { $oItemPrototype = $this->constructTemplate('newsletter_list_item_file_module'); } else { $this->setNewsletter($mSubscriberGroupId); $oItemPrototype = $this->constructTemplate('newsletter_list_item'); } $oPage = FrontendManager::$CURRENT_PAGE; foreach ($aRecentNewsletters as $oNewsletter) { $oItemTemplate = clone $oItemPrototype; $oItemTemplate->replaceIdentifier('subject', $oNewsletter->getSubject()); if ($bDisplayFileLink) { $oItemTemplate->replaceIdentifier('newsletter_link', $oNewsletter->getDisplayLink()); } else { if ($oNewsletter === self::$NEWSLETTER) { $oItemTemplate->replaceIdentifier('class_active', ' class="active"', null, Template::NO_HTML_ESCAPE); } $oItemTemplate->replaceIdentifier('newsletter_link', LinkUtil::link($oPage->getFullPathArray(array(self::IDENTIFIER_DETAIL, $oNewsletter->getId())))); } $oItemTemplate->replaceIdentifier('date', $oNewsletter->getLastSent()); $oItemTemplate->replaceIdentifier('template_name', $oNewsletter->getTemplateName()); $oItemTemplate->replaceIdentifier('language_id', $oNewsletter->getLanguageId()); $oTemplate->replaceIdentifierMultiple('newsletter_item', $oItemTemplate); } return $oTemplate; }
/** * Make the cache key depend on the current session language */ public function dependOnLanguage() { $this->aVars['language'] = Session::language(); return $this; }
public function documentationData($sDocumentationName) { return DocumentationProviderTypeModule::dataForPart($sDocumentationName, Session::language()); }
public static function addOrUpdateString($sStringKey, $sContent, $sLanguageId = null) { if ($sLanguageId === null) { $sLanguageId = Session::language(); } $oString = TranslationQuery::create()->findPk(array($sLanguageId, $sStringKey)); if (!$sContent) { if ($oString !== null) { $oString->delete(); } return; } if ($oString === null) { $oString = new Translation(); $oString->setLanguageId($sLanguageId); $oString->setStringKey($sStringKey); } $oString->setText($sContent); $oString->save(); }
public function __construct($sWidgetId = null) { parent::__construct($sWidgetId); $this->setSetting('is_monolingual', self::isMonolingual()); $this->setSetting('session_language', Session::language()); }
protected function addCanonicalLink() { $oCanonical = self::$CURRENT_NAVIGATION_ITEM->getCanonical(Session::language()); if ($oCanonical) { ResourceIncluder::metaIncluder()->addResource($oCanonical, null, null, array('rel' => 'canonical')); } }
public static function link($mPath = false, $mManager = null, $aParameters = array(), $mLanguage = null, $bIncludeLanguage = null) { if ($mPath === null) { // Respect null-links return null; } if (!$mPath) { $mPath = array(); } if (!is_array($mPath)) { $mPath = explode("/", $mPath); } $mManager = Manager::getManagerClassNormalized($mManager); $sPrefix = Manager::getPrefixForManager($mManager); if ($mLanguage === true || $mLanguage === false) { $bIncludeLanguage = $mLanguage; $mLanguage = null; } if ($bIncludeLanguage === null) { $bIncludeLanguage = $mManager::shouldIncludeLanguageInLink(); } if ($bIncludeLanguage) { if ($mLanguage === null) { $mLanguage = Session::language(true); } if ($mLanguage instanceof Language) { array_unshift($mPath, $mLanguage->getPathPrefix()); } else { if (is_string($mLanguage)) { $mLanguage = LanguageQuery::create()->findPk($mLanguage)->getPathPrefix(); array_unshift($mPath, $mLanguage); } } } foreach ($mPath as $iKey => $sValue) { if ($sValue === null || $sValue === "") { unset($mPath[$iKey]); } else { $mPath[$iKey] = rawurlencode($sValue); } } if ($sPrefix !== null && $sPrefix !== "") { $sPrefix .= "/"; } else { $sPrefix = ''; } return MAIN_DIR_FE_PHP . $sPrefix . implode('/', $mPath) . self::prepareLinkParameters($aParameters); }