本文整理汇总了PHP中FWLanguage::getLanguageCodeById方法的典型用法代码示例。如果您正苦于以下问题:PHP FWLanguage::getLanguageCodeById方法的具体用法?PHP FWLanguage::getLanguageCodeById怎么用?PHP FWLanguage::getLanguageCodeById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FWLanguage
的用法示例。
在下文中一共展示了FWLanguage::getLanguageCodeById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
private function __construct()
{
global $objInit;
$backOrFrontend = $objInit->mode;
global $objFWUser;
$langId;
if ($backOrFrontend == "frontend") {
$langId = $objInit->getFrontendLangId();
} else {
//backend
$langId = $objInit->getBackendLangId();
}
$langCode = FWLanguage::getLanguageCodeById($langId);
$this->setVariable(array('path' => ASCMS_PATH_OFFSET . '/update/' . $langCode . '/', 'basePath' => ASCMS_PATH_OFFSET . '/update/', 'cadminPath' => ASCMS_PATH_OFFSET . ASCMS_BACKEND_PATH . '/', 'mode' => $objInit->mode, 'language' => $langCode), 'contrexx');
//let i18n set it's variables
$i18n = new ContrexxJavascriptI18n($langCode);
$i18n->variablesTo($this);
//determine the correct jquery ui css' path.
//the user might have overridden the default css in the theme, so look out for this too.
$jQUiCssPath = 'themes/' . $objInit->getCurrentThemesPath() . '/jquery-ui.css';
//customized css would be here
if ($objInit->mode != 'frontend' || !file_exists(ASCMS_DOCUMENT_ROOT . '/' . $jQUiCssPath)) {
//use standard css
$jQUiCssPath = 'lib/javascript/jquery/ui/css/jquery-ui.css';
}
$this->setVariable(array('jQueryUiCss' => $jQUiCssPath), 'contrexx-ui');
}
示例2: getXHtml
/**
* @override
*/
public function getXHtml($backend = false)
{
global $objInit;
$uploadPath = $this->getUploadPath('jump');
$tpl = new \Cx\Core\Html\Sigma(ASCMS_CORE_MODULE_PATH . '/Upload/template/uploaders');
$tpl->setErrorHandling(PEAR_ERROR_DIE);
$tpl->loadTemplateFile('jump.html');
$basePath = 'index.php?';
$basePath .= $this->isBackendRequest ? 'cmd=Upload&act' : 'section=Upload&cmd';
//act and cmd vary
$appletPath = $basePath . '=jumpUploaderApplet';
$l10nPath = $basePath . '=jumpUploaderL10n';
$langId;
if (!$this->isBackendRequest) {
$langId = $objInit->getFrontendLangId();
} else {
//backend
$langId = $objInit->getBackendLangId();
}
$langCode = \FWLanguage::getLanguageCodeById($langId);
if (!file_exists(ASCMS_CORE_MODULE_PATH . '/Upload/ressources/uploaders/jump/messages_' . $langCode . '.zip')) {
$langCode = 'en';
}
$l10nPath .= '&lang=' . $langCode;
$tpl->setVariable('UPLOAD_CHUNK_LENGTH', \FWSystem::getMaxUploadFileSize() - 1000);
$tpl->setVariable('UPLOAD_APPLET_URL', $appletPath);
$tpl->setVariable('UPLOAD_LANG_URL', $l10nPath);
$tpl->setVariable('UPLOAD_URL', $uploadPath);
$tpl->setVariable('UPLOAD_ID', $this->uploadId);
return $tpl->get();
}
示例3: __construct
public function __construct($langCode = null, $text = '', $type = 'alertbox', $link = '', $linkTarget = '_blank', $showInDashboard = true)
{
$this->langCode = $langCode ? $langCode : \FWLanguage::getLanguageCodeById(LANG_ID);
$this->text = $text;
$this->type = $type;
$this->link = $link;
$this->linkTarget = $linkTarget;
$this->showInDashboard = $showInDashboard;
}
示例4: renderElement
/**
* Override this to do your representation of the tree.
*
* @param string $title
* @param int $level 0-based level of the element
* @param boolean $hasChilds are there children of this element? if yes, they will be processed in the subsequent calls.
* @param int $lang language id
* @param string $path path to this element, e.g. '/CatA/CatB'
* @param boolean $current if a $currentPage has been specified, this will be set to true if either a parent element of the current element or the current element itself is rendered.
*
* @return string your string representation of the element.
*/
protected function renderElement($title, $level, $hasChilds, $lang, $path, $current, $page)
{
$url = (string) \Cx\Core\Routing\NodePlaceholder::fromNode($page->getNode(), null, array());
$pages = $page->getNode()->getPages();
$titles = array();
foreach ($pages as $page) {
$titles[\FWLanguage::getLanguageCodeById($page->getLang())] = $page->getTitle();
}
$this->return[] = array('click' => "javascript:{setUrl('{$url}',null,null,'" . \FWLanguage::getLanguageCodeById(BACKEND_LANG_ID) . $path . "','page')}", 'name' => $titles, 'extension' => 'Html', 'level' => $level - 1, 'url' => $path, 'node' => $url);
}
示例5: addDatepickerJs
/**
* Registers the JavaScript code for jQueryUi.Datepicker
*
* Also activates jQueryUi and tries to load the current language and use
* that as the default.
* Add element specific defaults and code in your method.
*/
static function addDatepickerJs()
{
static $language_code = null;
// Only run once
if ($language_code) {
return;
}
JS::activate('jqueryui');
$language_code = FWLanguage::getLanguageCodeById(FRONTEND_LANG_ID);
//DBG::log("Language ID ".FRONTEND_LANG_ID.", code $language_code");
// Must load timepicker as well, because the region file accesses it
JS::registerJS('lib/javascript/jquery/ui/jquery-ui-timepicker-addon.js');
// TODO: Add more languages to the i18n folder!
JS::registerJS('lib/javascript/jquery/ui/i18n/' . 'jquery.ui.datepicker-' . $language_code . '.js');
JS::registerCode('
cx.jQuery(function() {
cx.jQuery.datepicker.setDefaults(cx.jQuery.datepicker.regional["' . $language_code . '"]);
});
');
}
示例6: performLanguageAction
private function performLanguageAction($action, $params)
{
global $_CORELANG;
// Global access check
if (!\Permission::checkAccess(6, 'static', true) || !\Permission::checkAccess(35, 'static', true)) {
throw new \Cx\Core\ContentManager\ContentManagerException($_CORELANG['TXT_CORE_CM_USAGE_DENIED']);
}
if (!\Permission::checkAccess(53, 'static', true)) {
throw new \Cx\Core\ContentManager\ContentManagerException($_CORELANG['TXT_CORE_CM_COPY_DENIED']);
}
if (!isset($params['get']) || !isset($params['get']['to'])) {
throw new \Cx\Core\ContentManager\ContentManagerException('Illegal parameter list');
}
$em = \Env::get('em');
$nodeRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Node');
$targetLang = contrexx_input2raw($params['get']['to']);
$fromLang = \FWLanguage::getFallbackLanguageIdById($targetLang);
if ($fromLang === false) {
throw new \Cx\Core\ContentManager\ContentManagerException('Language has no fallback to copy/link from');
}
$toLangCode = \FWLanguage::getLanguageCodeById($targetLang);
if ($toLangCode === false) {
throw new \Cx\Core\ContentManager\ContentManagerException('Could not get id for language #"' . $targetLang . '"');
}
$limit = 0;
$offset = 0;
if (isset($params['get']['limit'])) {
$limit = contrexx_input2raw($params['get']['limit']);
}
if (isset($params['get']['offset'])) {
$offset = contrexx_input2raw($params['get']['offset']);
}
$result = $nodeRepo->translateRecursive($nodeRepo->getRoot(), $fromLang, $targetLang, $action == 'copy', $limit, $offset);
return $result;
}
示例7: getCode
public function getCode($tabIndex = null)
{
$tabIndexAttr = '';
if (isset($tabIndex)) {
$tabIndexAttr = "tabindex=\"{$tabIndex}\"";
}
$widget = <<<HTML
<div id="recaptcha_widget" style="display:none">
<div id="recaptcha_image"></div>
<div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect please try again</div>
<span class="recaptcha_only_if_image">Enter the words above:</span>
<span class="recaptcha_only_if_audio">Enter the numbers you hear:</span>
<input type="text" id="recaptcha_response_field" name="recaptcha_response_field" {$tabIndexAttr} />
<div>
<div>
<a title="Get a new challenge" href="javascript:Recaptcha.reload()" id="recaptcha_reload_btn">
<img src="http://www.google.com/recaptcha/api/img/clean/refresh.png" id="recaptcha_reload" alt="Get a new challenge" height="18" width="25">
</a>
</div>
<div class="recaptcha_only_if_image">
<a title="Get an audio challenge" href="javascript:Recaptcha.switch_type('audio');" id="recaptcha_switch_audio_btn" class="recaptcha_only_if_image">
<img src="http://www.google.com/recaptcha/api/img/clean/audio.png" id="recaptcha_switch_audio" alt="Get an audio challenge" height="15" width="25">
</a>
</div>
<div class="recaptcha_only_if_audio">
<a title="Get a visual challenge" href="javascript:Recaptcha.switch_type('image');" id="recaptcha_switch_img_btn" class="recaptcha_only_if_audio">
<img src="http://www.google.com/recaptcha/api/img/clean/text.png" id="recaptcha_switch_img" alt="Get a visual challenge" height="15" width="25">
</a>
</div>
<div>
<a href="javascript:Recaptcha.showhelp()"title="Help" target="_blank" id="recaptcha_whatsthis_btn">
<img alt="Help" src="http://www.google.com/recaptcha/api/img/clean/help.png" id="recaptcha_whatsthis" height="16" width="25">
</a>
</div>
</div>
</div>
<script type="text/javascript" src= "http://www.google.com/recaptcha/api/challenge?k=%1\$s"></script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=%1\$s" height="300" width="500" frameborder="0"></iframe><br />
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge">
</noscript>
HTML;
$lang = \FWLanguage::getLanguageCodeById(FRONTEND_LANG_ID);
//\JS::registerCode("var RecaptchaOptions = { lang : '$lang', theme : 'clean' }");
\JS::registerCode("var RecaptchaOptions = { lang : '{$lang}', theme : 'custom', custom_theme_widget: 'recaptcha_widget' }");
//\JS::registerCSS("lib/reCAPTCHA/recaptcha.widget.clean.css");
$code = sprintf($widget, $this->public_key);
//$code = recaptcha_get_html($this->public_key, $this->error);
return $code;
}
示例8: modifyLanguage
/**
* add and modify language values
*
* @global array
* @global ADONewConnection
* @return boolean True on success, false on failure
*/
function modifyLanguage()
{
global $_ARRAYLANG, $_CONFIG, $objDatabase;
$langRemovalStatus = isset($_POST['removeLangVersion']) ? contrexx_input2raw($_POST['removeLangVersion']) : false;
if (!empty($_POST['submit']) and isset($_POST['addLanguage']) && $_POST['addLanguage'] == "true") {
//-----------------------------------------------
// Add new language with all variables
//-----------------------------------------------
if (!empty($_POST['newLangName']) and !empty($_POST['newLangShortname'])) {
$newLangShortname = addslashes(strip_tags($_POST['newLangShortname']));
$newLangName = addslashes(strip_tags($_POST['newLangName']));
$newLangCharset = addslashes(strip_tags($_POST['newLangCharset']));
$objResult = $objDatabase->Execute("SELECT lang FROM " . DBPREFIX . "languages WHERE lang='" . $newLangShortname . "'");
if ($objResult !== false) {
if ($objResult->RecordCount() >= 1) {
$this->strErrMessage = $_ARRAYLANG['TXT_DATABASE_QUERY_ERROR'];
return false;
} else {
$objDatabase->Execute("INSERT INTO " . DBPREFIX . "languages SET lang='" . $newLangShortname . "',\n name='" . $newLangName . "',\n charset='" . $newLangCharset . "',\n is_default='false'");
$newLanguageId = $objDatabase->Insert_ID();
if (!empty($newLanguageId)) {
$objResult = $objDatabase->SelectLimit("SELECT id FROM " . DBPREFIX . "languages WHERE is_default='true'", 1);
if ($objResult !== false && !$objResult->EOF) {
$defaultLanguage = $objResult->fields['id'];
$objResult = $objDatabase->Execute("SELECT varid,content,module FROM " . DBPREFIX . "language_variable_content WHERE 1 AND lang=" . $defaultLanguage);
if ($objResult !== false) {
while (!$objResult->EOF) {
$arrayLanguageContent[$objResult->fields['varid']] = stripslashes($objResult->fields['content']);
$arrayLanguageModule[$objResult->fields['varid']] = $objResult->fields['module'];
$objResult->MoveNext();
}
foreach ($arrayLanguageContent as $varid => $content) {
$LanguageModule = $arrayLanguageModule[$varid];
$objDatabase->Execute("INSERT INTO " . DBPREFIX . "language_variable_content SET varid=" . $varid . ", content='" . addslashes($content) . "', module=" . $LanguageModule . ", lang=" . $newLanguageId . ", status=0");
}
$this->strOkMessage = $_ARRAYLANG['TXT_NEW_LANGUAGE_ADDED_SUCCESSFUL'];
return true;
}
}
} else {
$this->strErrMessage = $_ARRAYLANG['TXT_DATABASE_QUERY_ERROR'];
return false;
}
}
}
}
} elseif (!empty($_POST['submit']) and $_POST['modLanguage'] == "true") {
$eventArgs = array('langRemovalStatus' => $langRemovalStatus);
$frontendLangIds = array_keys(\FWLanguage::getActiveFrontendLanguages());
$postLangIds = array_keys($_POST['langActiveStatus']);
foreach (array_keys(\FWLanguage::getLanguageArray()) as $langId) {
$isLangInPost = in_array($langId, $postLangIds);
$isLangInFrontend = in_array($langId, $frontendLangIds);
if ($isLangInPost == $isLangInFrontend) {
continue;
}
$eventArgs['langData'][] = array('langId' => $langId, 'status' => $isLangInPost && !$isLangInFrontend);
}
//Trigger the event 'languageStatusUpdate'
//if the language is activated/deactivated for frontend
if (!empty($eventArgs)) {
$evm = \Cx\Core\Core\Controller\Cx::instanciate()->getEvents();
$evm->triggerEvent('languageStatusUpdate', array($eventArgs, new \Cx\Core\Model\RecursiveArrayAccess(array())));
}
//-----------------------------------------------
// Update languages
//-----------------------------------------------
foreach ($_POST['langName'] as $id => $name) {
$active = 0;
if (isset($_POST['langActiveStatus'][$id]) && $_POST['langActiveStatus'][$id] == 1) {
$languageCode = \FWLanguage::getLanguageCodeById($id);
$pageRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
$alias = $pageRepo->findBy(array('type' => \Cx\Core\ContentManager\Model\Entity\Page::TYPE_ALIAS, 'slug' => $languageCode), true);
if (count($alias)) {
if (is_array($alias)) {
$alias = $alias[0];
}
$id = $alias->getNode()->getId();
$config = \Env::get('config');
$link = 'http://' . $config['domainUrl'] . ASCMS_PATH_OFFSET . '/' . $alias->getSlug();
$lang = \Env::get('lang');
$this->strErrMessage = $lang['TXT_CORE_REMOVE_ALIAS_TO_ACTIVATE_LANGUAGE'] . ':<br />
<a href="index.php?cmd=Alias&act=modify&id=' . $id . '" target="_blank">' . $link . '</a>';
return false;
}
$active = 1;
}
$status = "false";
if ($_POST['langDefaultStatus'] == $id) {
$status = "true";
}
$adminstatus = 0;
if (isset($_POST['langAdminStatus'][$id]) && $_POST['langAdminStatus'][$id] == 1) {
//.........这里部分代码省略.........
示例9: getPagesPointingTo
/**
* Generates a list of pages pointing to $page
* @param \Cx\Core\ContentManager\Model\Entity\Page $page Page to get referencing pages for
* @param array $subPages (optional, by reference) Do not use, internal
* @return array List of pages (ID as key, page object as value)
*/
protected function getPagesPointingTo($page, &$subPages = array())
{
$cx = \Cx\Core\Core\Controller\Cx::instanciate();
$em = $cx->getDb()->getEntityManager();
$pageRepo = $em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
$fallback_lang_codes = \FWLanguage::getFallbackLanguageArray();
$active_langs = \FWLanguage::getActiveFrontendLanguages();
// get all active languages and their fallbacks
// $fallbacks[<langId>] = <fallsBackToLangId>
// if <langId> has no fallback <fallsBackToLangId> will be null
$fallbacks = array();
foreach ($active_langs as $lang) {
$fallbacks[\FWLanguage::getLanguageCodeById($lang['id'])] = array_key_exists($lang['id'], $fallback_lang_codes) ? \FWLanguage::getLanguageCodeById($fallback_lang_codes[$lang['id']]) : null;
}
// get all symlinks and fallbacks to it
$query = '
SELECT
p
FROM
Cx\\Core\\ContentManager\\Model\\Entity\\Page p
WHERE
(
p.type = ?1 AND
(
p.target LIKE ?2';
if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION) {
$query .= ' OR
p.target LIKE ?3';
}
$query .= '
)
) OR
(
p.type = ?4 AND
p.node = ' . $page->getNode()->getId() . '
)
';
$q = $em->createQuery($query);
$q->setParameter(1, 'symlink');
$q->setParameter('2', '%NODE_' . $page->getNode()->getId() . '%');
if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION) {
$q->setParameter('3', '%NODE_' . strtoupper($page->getModule()) . '%');
}
$q->setParameter(4, 'fallback');
$result = $q->getResult();
if (!$result) {
return $subPages;
}
foreach ($result as $subPage) {
if ($subPage->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_SYMLINK) {
$subPages[$subPage->getId()] = $subPage;
} else {
if ($subPage->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_FALLBACK) {
// check if $subPage is a fallback to $page
$targetLang = \FWLanguage::getLanguageCodeById($page->getLang());
$currentLang = \FWLanguage::getLanguageCodeById($subPage->getLang());
while ($currentLang && $currentLang != $targetLang) {
$currentLang = $fallbacks[$currentLang];
}
if ($currentLang && !isset($subPages[$subPage->getId()])) {
$subPages[$subPage->getId()] = $subPage;
// recurse!
$this->getPagesPointingTo($subPage, $subPages);
}
}
}
}
return $subPages;
}
示例10: testPagesAtPath
public function testPagesAtPath()
{
$pageRepo = self::$em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
$nodeRepo = self::$em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Node');
$n1 = new \Cx\Core\ContentManager\Model\Entity\Node();
$n2 = new \Cx\Core\ContentManager\Model\Entity\Node();
$n3 = new \Cx\Core\ContentManager\Model\Entity\Node();
$n1->setParent($nodeRepo->getRoot());
$nodeRepo->getRoot()->addChildren($n1);
$n2->setParent($n1);
$n2->addChildren($n1);
$n3->setParent($nodeRepo->getRoot());
$nodeRepo->getRoot()->addChildren($n3);
self::$em->persist($n1);
self::$em->persist($n2);
self::$em->persist($n3);
self::$em->flush();
$p1 = new \Cx\Core\ContentManager\Model\Entity\Page();
$p1->setLang(1);
$p1->setTitle('rootTitle_1');
$p1->setNode($n1);
$p1->setNodeIdShadowed($n1->getId());
$p1->setUseCustomContentForAllChannels('');
$p1->setUseCustomApplicationTemplateForAllChannels('');
$p1->setUseSkinForAllChannels('');
$p1->setCmd('');
$p1->setActive(1);
$p2 = new \Cx\Core\ContentManager\Model\Entity\Page();
$p2->setLang(2);
$p2->setTitle('rootTitle_1');
$p2->setNode($n1);
$p2->setNodeIdShadowed($n1->getId());
$p2->setUseCustomContentForAllChannels('');
$p2->setUseCustomApplicationTemplateForAllChannels('');
$p2->setUseSkinForAllChannels('');
$p2->setCmd('');
$p2->setActive(1);
$p3 = new \Cx\Core\ContentManager\Model\Entity\Page();
$p3->setLang(3);
$p3->setTitle('rootTitle_2');
$p3->setNode($n1);
$p3->setNodeIdShadowed($n1->getId());
$p3->setUseCustomContentForAllChannels('');
$p3->setUseCustomApplicationTemplateForAllChannels('');
$p3->setUseSkinForAllChannels('');
$p3->setCmd('');
$p3->setActive(1);
$p4 = new \Cx\Core\ContentManager\Model\Entity\Page();
$p4->setLang(3);
$p4->setTitle('childTitle');
$p4->setNode($n2);
$p4->setNodeIdShadowed($n2->getId());
$p4->setUseCustomContentForAllChannels('');
$p4->setUseCustomApplicationTemplateForAllChannels('');
$p4->setUseSkinForAllChannels('');
$p4->setCmd('');
$p4->setActive(1);
$p5 = new \Cx\Core\ContentManager\Model\Entity\Page();
$p5->setLang(1);
$p5->setTitle('otherRootChild');
$p5->setNode($n3);
$p5->setNodeIdShadowed($n3->getId());
$p5->setUseCustomContentForAllChannels('');
$p5->setUseCustomApplicationTemplateForAllChannels('');
$p5->setUseSkinForAllChannels('');
$p5->setCmd('');
$p5->setActive(1);
self::$em->persist($n1);
self::$em->persist($n2);
self::$em->persist($n3);
self::$em->persist($p1);
self::$em->persist($p2);
self::$em->persist($p3);
self::$em->persist($p4);
self::$em->persist($p5);
self::$em->flush();
//make sure we re-fetch a correct state
self::$em->refresh($n1);
self::$em->refresh($n2);
self::$em->refresh($n3);
//1 level
$match = $pageRepo->getPagesAtPath('/' . \FWLanguage::getLanguageCodeById(1) . '/rootTitle_1');
$this->assertEquals('rootTitle_1/', $match['matchedPath']);
$this->assertInstanceOf('Cx\\Core\\ContentManager\\Model\\Entity\\Page', $match['page'][1]);
// $this->assertEquals(array(1,2),$match['lang']);
//2 levels
$match = $pageRepo->getPagesAtPath('/' . \FWLanguage::getLanguageCodeById(3) . '/rootTitle_2/childTitle');
$this->assertEquals('rootTitle_2/childTitle/', $match['matchedPath']);
$this->assertEquals('', $match['unmatchedPath']);
$this->assertInstanceOf('Cx\\Core\\ContentManager\\Model\\Entity\\Page', $match['page'][3]);
$this->assertEquals(array(3), $match['lang']);
//3 levels, 2 in tree
$match = $pageRepo->getPagesAtPath('/' . \FWLanguage::getLanguageCodeById(3) . '/rootTitle_2/childTitle/asdfasdf');
$this->assertEquals('rootTitle_2/childTitle/', $match['matchedPath']);
// check unmatched path too
$this->assertEquals('asdfasdf', $match['unmatchedPath']);
$this->assertInstanceOf('Cx\\Core\\ContentManager\\Model\\Entity\\Page', $match['page'][3]);
$this->assertEquals(array(3), $match['lang']);
//3 levels, wrong lang from 2nd level
$match = $pageRepo->getPagesAtPath('/' . \FWLanguage::getLanguageCodeById(1) . '/rootTitle_1/childTitle/asdfasdf');
//.........这里部分代码省略.........
示例11: getSearchResults
/**
* Gets the search results.
*
* @return mixed Parsed content.
*/
public function getSearchResults()
{
global $_ARRAYLANG;
$this->template->addBlockfile('ADMIN_CONTENT', 'search', 'Default.html');
if (!empty($this->term)) {
$pages = $this->getSearchedPages();
$countPages = $this->countSearchedPages();
usort($pages, array($this, 'sortPages'));
if ($countPages > 0) {
$parameter = '&cmd=Search' . (empty($this->term) ? '' : '&term=' . contrexx_raw2encodedUrl($this->term));
$paging = \Paging::get($parameter, '', $countPages, 0, true, null, 'pos');
$this->template->setVariable(array('TXT_SEARCH_RESULTS_COMMENT' => sprintf($_ARRAYLANG['TXT_SEARCH_RESULTS_COMMENT'], $this->term, $countPages), 'TXT_SEARCH_TITLE' => $_ARRAYLANG['TXT_NAVIGATION_TITLE'], 'TXT_SEARCH_CONTENT_TITLE' => $_ARRAYLANG['TXT_PAGETITLE'], 'TXT_SEARCH_SLUG' => $_ARRAYLANG['TXT_CORE_CM_SLUG'], 'TXT_SEARCH_LANG' => $_ARRAYLANG['TXT_LANGUAGE'], 'SEARCH_PAGING' => $paging));
foreach ($pages as $page) {
// used for alias pages, because they have no language
if ($page->getLang() == "") {
$languages = "";
foreach (\FWLanguage::getIdArray('frontend') as $langId) {
$languages[] = \FWLanguage::getLanguageCodeById($langId);
}
} else {
$languages = array(\FWLanguage::getLanguageCodeById($page->getLang()));
}
$aliasLanguages = implode(', ', $languages);
$originalPage = $page;
$link = 'index.php?cmd=ContentManager&page=' . $page->getId();
if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_ALIAS) {
$pageRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
if ($originalPage->isTargetInternal()) {
// is internal target, get target page
$originalPage = $pageRepo->getTargetPage($page);
} else {
// is an external target, set the link to the external targets url
$originalPage = new \Cx\Core\ContentManager\Model\Entity\Page();
$originalPage->setTitle($page->getTarget());
$link = $page->getTarget();
}
}
$this->template->setVariable(array('SEARCH_RESULT_BACKEND_LINK' => $link, 'SEARCH_RESULT_TITLE' => $originalPage->getTitle(), 'SEARCH_RESULT_CONTENT_TITLE' => $originalPage->getContentTitle(), 'SEARCH_RESULT_SLUG' => substr($page->getPath(), 1), 'SEARCH_RESULT_LANG' => $aliasLanguages, 'SEARCH_RESULT_FRONTEND_LINK' => \Cx\Core\Routing\Url::fromPage($page)));
$this->template->parse('search_result_row');
}
} else {
$this->template->setVariable(array('TXT_SEARCH_NO_RESULTS' => sprintf($_ARRAYLANG['TXT_SEARCH_NO_RESULTS'], $this->term)));
}
} else {
$this->template->setVariable(array('TXT_SEARCH_NO_TERM' => $_ARRAYLANG['TXT_SEARCH_NO_TERM']));
}
}
示例12: getClientRecord
/**
* Get the client record
*
* @return GeoIp2\Model\Country
*/
public function getClientRecord()
{
if ($this->clientRecord) {
return $this->clientRecord;
}
//skip the process incase mode is not frontend or GeoIp is deactivated
if (!$this->isGeoIpEnabled()) {
return null;
}
// Get stats controller to get client ip
$statsComponentContoller = $this->getComponent('Stats');
if (!$statsComponentContoller) {
return null;
}
//Get the country name and code by using the ipaddress through GeoIp2 library
$countryDb = $this->getDirectory() . '/Data/GeoLite2-Country.mmdb';
$activeLocale = \FWLanguage::getLanguageCodeById(FRONTEND_LANG_ID);
$locale = in_array($activeLocale, $this->availableLocale) ? $activeLocale : $this->defaultLocale;
try {
$reader = new \GeoIp2\Database\Reader($countryDb, array($locale));
$this->clientRecord = $reader->country($statsComponentContoller->getCounterInstance()->getClientIp());
return $this->clientRecord;
} catch (\Exception $e) {
\DBG::log($e->getMessage());
return null;
}
}
示例13: _showOverview
/**
* Show overview
*
* Show the blocks overview page
*
* @access private
* @global array
* @global ADONewConnection
* @global array
* @see blockLibrary::getBlocks(), blockLibrary::blockNamePrefix
*/
function _showOverview()
{
global $_ARRAYLANG, $objDatabase, $_CORELANG;
if (isset($_POST['displaysubmit'])) {
foreach ($_POST['displayorder'] as $blockId => $value) {
$query = "UPDATE " . DBPREFIX . "module_block_blocks SET `order`='" . intval($value) . "' WHERE id='" . intval($blockId) . "'";
$objDatabase->Execute($query);
}
}
$this->_pageTitle = $_ARRAYLANG['TXT_BLOCK_BLOCKS'];
$this->_objTpl->loadTemplateFile('module_block_overview.html');
$catId = !empty($_REQUEST['catId']) ? intval($_REQUEST['catId']) : 0;
$this->_objTpl->setVariable(array('TXT_BLOCK_BLOCKS' => $_ARRAYLANG['TXT_BLOCK_BLOCKS'], 'TXT_BLOCK_NAME' => $_ARRAYLANG['TXT_BLOCK_NAME'], 'TXT_BLOCK_PLACEHOLDER' => $_ARRAYLANG['TXT_BLOCK_PLACEHOLDER'], 'TXT_BLOCK_SUBMIT_SELECT' => $_ARRAYLANG['TXT_BLOCK_SUBMIT_SELECT'], 'TXT_BLOCK_SUBMIT_DELETE' => $_ARRAYLANG['TXT_BLOCK_SUBMIT_DELETE'], 'TXT_BLOCK_SUBMIT_ACTIVATE' => $_ARRAYLANG['TXT_BLOCK_SUBMIT_ACTIVATE'], 'TXT_BLOCK_SUBMIT_DEACTIVATE' => $_ARRAYLANG['TXT_BLOCK_SUBMIT_DEACTIVATE'], 'TXT_BLOCK_SUBMIT_GLOBAL' => $_ARRAYLANG['TXT_BLOCK_SUBMIT_GLOBAL'], 'TXT_BLOCK_SUBMIT_GLOBAL_OFF' => $_ARRAYLANG['TXT_BLOCK_SUBMIT_GLOBAL_OFF'], 'TXT_BLOCK_SELECT_ALL' => $_ARRAYLANG['TXT_BLOCK_SELECT_ALL'], 'TXT_BLOCK_DESELECT_ALL' => $_ARRAYLANG['TXT_BLOCK_DESELECT_ALL'], 'TXT_BLOCK_PLACEHOLDER' => $_ARRAYLANG['TXT_BLOCK_PLACEHOLDER'], 'TXT_BLOCK_FUNCTIONS' => $_ARRAYLANG['TXT_BLOCK_FUNCTIONS'], 'TXT_BLOCK_DELETE_SELECTED_BLOCKS' => $_ARRAYLANG['TXT_BLOCK_DELETE_SELECTED_BLOCKS'], 'TXT_BLOCK_CONFIRM_DELETE_BLOCK' => $_ARRAYLANG['TXT_BLOCK_CONFIRM_DELETE_BLOCK'], 'TXT_SAVE_CHANGES' => $_CORELANG['TXT_SAVE_CHANGES'], 'TXT_BLOCK_OPERATION_IRREVERSIBLE' => $_ARRAYLANG['TXT_BLOCK_OPERATION_IRREVERSIBLE'], 'TXT_BLOCK_STATUS' => $_ARRAYLANG['TXT_BLOCK_STATUS'], 'TXT_BLOCK_CATEGORY' => $_ARRAYLANG['TXT_BLOCK_CATEGORY'], 'TXT_BLOCK_CATEGORIES_ALL' => $_ARRAYLANG['TXT_BLOCK_CATEGORIES_ALL'], 'TXT_BLOCK_ORDER' => $_ARRAYLANG['TXT_BLOCK_ORDER'], 'TXT_BLOCK_LANGUAGE' => $_ARRAYLANG['TXT_BLOCK_LANGUAGE'], 'TXT_BLOCK_INCLUSION' => $_ARRAYLANG['TXT_BLOCK_INCLUSION'], 'BLOCK_CATEGORIES_DROPDOWN' => $this->_getCategoriesDropdown($catId), 'DIRECTORY_INDEX' => CONTREXX_DIRECTORY_INDEX, 'CSRF_PARAM' => \Cx\Core\Csrf\Controller\Csrf::param()));
$arrBlocks = $this->getBlocks($catId);
if (empty($arrBlocks)) {
return;
}
// create new ContentTree instance
$objContentTree = new \ContentTree();
$pageRepo = \Cx\Core\Core\Controller\Cx::instanciate()->getDb()->getEntityManager()->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
$rowNr = 0;
foreach ($arrBlocks as $blockId => $arrBlock) {
if ($arrBlock['active'] == '1') {
$status = '<a href="index.php?cmd=Block&act=deactivate&blockId=' . $blockId . '" title="' . $_ARRAYLANG['TXT_BLOCK_ACTIVE'] . '"><img src="../core/Core/View/Media/icons/led_green.gif" width="13" height="13" border="0" alt="' . $_ARRAYLANG['TXT_BLOCK_ACTIVE'] . '" /></a>';
} else {
$status = '<a href="index.php?cmd=Block&act=activate&blockId=' . $blockId . '" title="' . $_ARRAYLANG['TXT_BLOCK_INACTIVE'] . '"><img src="../core/Core/View/Media/icons/led_red.gif" width="13" height="13" border="0" alt="' . $_ARRAYLANG['TXT_BLOCK_INACTIVE'] . '" /></a>';
}
$blockPlaceholder = $this->blockNamePrefix . $blockId;
$random1Class = $arrBlock['random'] == 1 ? 'active' : '';
$random2Class = $arrBlock['random2'] == 1 ? 'active' : '';
$random3Class = $arrBlock['random3'] == 1 ? 'active' : '';
$random4Class = $arrBlock['random4'] == 1 ? 'active' : '';
$globalClass = in_array($arrBlock['global'], array(1, 2)) ? 'active' : '';
$random1Info = sprintf($arrBlock['random'] ? $_ARRAYLANG['TXT_BLOCK_RANDOM_INFO_INCLUDED'] : $_ARRAYLANG['TXT_BLOCK_RANDOM_INFO_EXCLUDED'], '[[BLOCK_RANDOMIZER]]');
$random2Info = sprintf($arrBlock['random2'] ? $_ARRAYLANG['TXT_BLOCK_RANDOM_INFO_INCLUDED'] : $_ARRAYLANG['TXT_BLOCK_RANDOM_INFO_EXCLUDED'], '[[BLOCK_RANDOMIZER2]]');
$random3Info = sprintf($arrBlock['random3'] ? $_ARRAYLANG['TXT_BLOCK_RANDOM_INFO_INCLUDED'] : $_ARRAYLANG['TXT_BLOCK_RANDOM_INFO_EXCLUDED'], '[[BLOCK_RANDOMIZER3]]');
$random4Info = sprintf($arrBlock['random4'] ? $_ARRAYLANG['TXT_BLOCK_RANDOM_INFO_INCLUDED'] : $_ARRAYLANG['TXT_BLOCK_RANDOM_INFO_EXCLUDED'], '[[BLOCK_RANDOMIZER4]]');
$lang = array();
foreach ($arrBlock['lang'] as $langId) {
$lang[] = \FWLanguage::getLanguageCodeById($langId);
}
$langString = implode(', ', $lang);
$strGlobalSelectedPages = $arrBlock['global'] == 2 ? $this->getSelectedPages($blockId, 'global', $objContentTree, $pageRepo) : '';
$strDirectSelectedPages = $arrBlock['direct'] == 1 ? $this->getSelectedPages($blockId, 'direct', $objContentTree, $pageRepo) : '';
$targeting = $this->loadTargetingSettings($blockId);
$targetingClass = '';
$targetingInfo = '';
if (!empty($targeting)) {
$targetingClass = 'active';
$arrSelectedCountries = array();
if (!empty($targeting['country']) && !empty($targeting['country']['value'])) {
$targetingInfo = $targeting['country']['filter'] == 'include' ? $_ARRAYLANG['TXT_BLOCK_TARGETING_INFO_INCLUDE'] : $_ARRAYLANG['TXT_BLOCK_TARGETING_INFO_EXCLUDE'];
foreach ($targeting['country']['value'] as $countryId) {
$countryName = \Cx\Core\Country\Controller\Country::getNameById($countryId);
if (!empty($countryName)) {
$arrSelectedCountries[] = '<li>' . contrexx_raw2xhtml($countryName) . '</li>';
}
}
}
if ($arrSelectedCountries) {
$targetingInfo .= '<br /><ul>' . implode($arrSelectedCountries) . '</ul>';
}
}
$blockDirectInfo = sprintf($arrBlock['direct'] == 1 ? $_ARRAYLANG['TXT_BLOCK_DIRECT_INFO_SHOW_SELECTED_PAGES'] : $_ARRAYLANG['TXT_BLOCK_DIRECT_INFO_SHOW_ALL_PAGES'], '[[' . $blockPlaceholder . ']]');
$this->_objTpl->setVariable(array('BLOCK_ROW_CLASS' => $rowNr % 2 ? "row1" : "row2", 'BLOCK_ID' => $blockId, 'BLOCK_RANDOM_1_CLASS' => $random1Class, 'BLOCK_RANDOM_2_CLASS' => $random2Class, 'BLOCK_RANDOM_3_CLASS' => $random3Class, 'BLOCK_RANDOM_4_CLASS' => $random4Class, 'BLOCK_RANDOM_1_INFO' => $random1Info, 'BLOCK_RANDOM_2_INFO' => $random2Info, 'BLOCK_RANDOM_3_INFO' => $random3Info, 'BLOCK_RANDOM_4_INFO' => $random4Info, 'BLOCK_TARGETING_CLASS' => $targetingClass, 'BLOCK_TARGETING_INFO' => !empty($targeting) ? $targetingInfo : $_ARRAYLANG['TXT_BLOCK_LOCATION_BASED_DISPLAY_INFO'], 'BLOCK_GLOBAL_CLASS' => $globalClass, 'BLOCK_GLOBAL_INFO' => $arrBlock['global'] == 1 ? $_ARRAYLANG['TXT_BLOCK_DISPLAY_ALL_PAGE'] : ($arrBlock['global'] == 2 ? $_ARRAYLANG['TXT_BLOCK_DISPLAY_SELECTED_PAGE'] . '<br />' . $strGlobalSelectedPages : $_ARRAYLANG['TXT_BLOCK_DISPLAY_GLOBAL_INACTIVE']), 'BLOCK_CATEGORY_NAME' => $this->_categoryNames[$arrBlock['cat']], 'BLOCK_ORDER' => $arrBlock['order'], 'BLOCK_PLACEHOLDER' => $blockPlaceholder, 'BLOCK_PLACEHOLDER_INFO' => $arrBlock['direct'] == 1 ? $blockDirectInfo . '<br />' . $strDirectSelectedPages : $blockDirectInfo, 'BLOCK_NAME' => contrexx_raw2xhtml($arrBlock['name']), 'BLOCK_MODIFY' => sprintf($_ARRAYLANG['TXT_BLOCK_MODIFY_BLOCK'], contrexx_raw2xhtml($arrBlock['name'])), 'BLOCK_COPY' => sprintf($_ARRAYLANG['TXT_BLOCK_COPY_BLOCK'], contrexx_raw2xhtml($arrBlock['name'])), 'BLOCK_DELETE' => sprintf($_ARRAYLANG['TXT_BLOCK_DELETE_BLOCK'], contrexx_raw2xhtml($arrBlock['name'])), 'BLOCK_STATUS' => $status, 'BLOCK_LANGUAGES_NAME' => $langString));
$this->_objTpl->parse('blockBlockList');
$rowNr++;
}
}
示例14: getTreeCode
private function getTreeCode()
{
if (count($this->arrMigrateLangIds) === 1) {
return true;
}
$jsSimilarPages = array();
$this->similarPages = $this->findSimilarPages();
foreach ($this->similarPages as $nodeId => $arrPageIds) {
$jsSimilarPages[$nodeId] = array_values($arrPageIds);
foreach ($this->arrMigrateLangIds as $migrateLangId) {
if (!isset($arrPageIds[$migrateLangId])) {
$this->similarPages[$nodeId][$migrateLangId] = 0;
}
}
ksort($this->similarPages[$nodeId]);
}
$objCx = \ContrexxJavascript::getInstance();
$objCx->setVariable('similarPages', json_encode($jsSimilarPages), 'update/contentMigration');
$objTemplate = new \HTML_Template_Sigma(UPDATE_TPL);
$objTemplate->setErrorHandling(PEAR_ERROR_DIE);
$objTemplate->loadTemplateFile('page_grouping.html');
$groupedBorderWidth = count($this->arrMigrateLangIds) * 325 - 48;
$objTemplate->setGlobalVariable(array('USERNAME' => $_SESSION['contrexx_update']['username'], 'PASSWORD' => $_SESSION['contrexx_update']['password'], 'CMS_VERSION' => $_SESSION['contrexx_update']['version'], 'MIGRATE_LANG_IDS' => $this->migrateLangIds, 'LANGUAGE_WRAPPER_WIDTH' => 'width: ' . count($this->arrMigrateLangIds) * 330 . 'px;', 'GROUPED_SCROLL_WIDTH' => 'width: ' . count($this->arrMigrateLangIds) * 325 . 'px;', 'GROUPED_BORDER_WIDTH' => 'width: ' . $groupedBorderWidth . 'px;'));
$cl = \Env::get('ClassLoader');
$cl->loadFile(ASCMS_CORE_PATH . '/Tree.class.php');
$cl->loadFile(UPDATE_CORE . '/UpdateTree.class.php');
$pageRepo = self::$em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
$nodeRepo = self::$em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Node');
foreach ($this->arrMigrateLangIds as $lang) {
$objContentTree = new \UpdateContentTree($lang);
foreach ($objContentTree->getTree() as $arrPage) {
$pageId = $arrPage['catid'];
$nodeId = $arrPage['node_id'];
$langId = $arrPage['lang'];
$level = $arrPage['level'];
$title = $arrPage['catname'];
$sort = $nodeRepo->find($nodeId)->getLft();
$grouped = $this->isGrouppedPage($this->similarPages, $pageId) ? 'grouped' : '';
$objTemplate->setVariable(array('TITLE' => $title, 'ID' => $pageId, 'NODE' => $nodeId, 'LANG' => strtoupper(\FWLanguage::getLanguageCodeById($langId)), 'LEVEL' => $level + 1, 'SORT' => $sort, 'GROUPED' => $grouped, 'MARGIN' => 'margin-left: ' . $level * 15 . 'px;'));
$objTemplate->parse('page');
}
$langFull = \FWLanguage::getLanguageParameter($lang, 'name');
$langShort = strtoupper(\FWLanguage::getLanguageParameter($lang, 'lang'));
$objTemplate->setVariable(array('LANG_FULL' => $langFull, 'LANG_SHORT' => $langShort));
$objTemplate->parse('language');
}
$groupedBorderWidth -= 2;
foreach ($this->similarPages as $nodeId => $arrPageIds) {
$node = $nodeRepo->find($nodeId);
$margin = ($node->getLvl() - 1) * 15;
$nodeWidth = $groupedBorderWidth - $margin;
$width = ($groupedBorderWidth - 10) / count($this->arrMigrateLangIds);
$index = 0;
$last = count($arrPageIds) - 1;
foreach ($arrPageIds as $pageLangId => $pageId) {
if ($index === 0) {
$pageWidth = $width - 24;
} elseif ($index === $last) {
$pageWidth = $width - $margin;
} else {
$pageWidth = $width;
}
$index++;
$page = $pageRepo->find($pageId);
if ($page) {
$langCode = strtoupper(\FWLanguage::getLanguageCodeById($page->getLang()));
$objTemplate->setVariable(array('CLASS' => '', 'DATA_ID' => 'data-id="' . $pageId . '"', 'DATA_LANG' => 'data-lang="' . $langCode . '"', 'TITLE' => $page->getTitle(), 'LANG' => $langCode, 'WIDTH' => 'width: ' . $pageWidth . 'px;'));
} else {
$langCode = strtoupper(\FWLanguage::getLanguageCodeById($pageLangId));
$objTemplate->setVariable(array('CLASS' => 'no-page', 'DATA_ID' => '', 'DATA_LANG' => '', 'TITLE' => 'Keine Seite', 'LANG' => $langCode, 'WIDTH' => 'width: ' . $pageWidth . 'px;'));
}
$objTemplate->parse('groupedPage');
}
$objTemplate->setVariable(array('ID' => $nodeId, 'LEVEL' => $node->getLvl(), 'SORT' => $node->getLft(), 'STYLE' => 'width: ' . $nodeWidth . 'px; margin-left: ' . $margin . 'px;'));
$objTemplate->parse('groupedNode');
}
return $objTemplate->get();
}
示例15: getTypeByPage
/**
* Returns the type of the page as string.
*
* @param \Cx\Core\ContentManager\Model\Entity\Page $page
* @return string $type
*/
public function getTypeByPage($page)
{
global $_CORELANG;
switch ($page->getType()) {
case \Cx\Core\ContentManager\Model\Entity\Page::TYPE_REDIRECT:
$criteria = array('nodeIdShadowed' => $page->getTargetNodeId(), 'lang' => $page->getLang());
$targetPage = $this->findOneBy($criteria);
$targetTitle = $targetPage ? $targetPage->getTitle() : $page->getTarget();
$type = $_CORELANG['TXT_CORE_CM_TYPE_REDIRECT'] . ': ';
$type .= $targetTitle;
break;
case \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION:
$type = $_CORELANG['TXT_CORE_CM_TYPE_APPLICATION'] . ': ';
$type .= $page->getModule();
$type .= $page->getCmd() != '' ? ' | ' . $page->getCmd() : '';
break;
case \Cx\Core\ContentManager\Model\Entity\Page::TYPE_FALLBACK:
$fallbackLangId = \FWLanguage::getFallbackLanguageIdById($page->getLang());
if ($fallbackLangId == 0) {
$fallbackLangId = \FWLanguage::getDefaultLangId();
}
$type = $_CORELANG['TXT_CORE_CM_TYPE_FALLBACK'] . ' ';
$type .= \FWLanguage::getLanguageCodeById($fallbackLangId);
break;
default:
$type = $_CORELANG['TXT_CORE_CM_TYPE_CONTENT'];
}
return $type;
}