当前位置: 首页>>代码示例>>PHP>>正文


PHP FWLanguage::getFallbackLanguageArray方法代码示例

本文整理汇总了PHP中FWLanguage::getFallbackLanguageArray方法的典型用法代码示例。如果您正苦于以下问题:PHP FWLanguage::getFallbackLanguageArray方法的具体用法?PHP FWLanguage::getFallbackLanguageArray怎么用?PHP FWLanguage::getFallbackLanguageArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FWLanguage的用法示例。


在下文中一共展示了FWLanguage::getFallbackLanguageArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructor
  */
 public function __construct()
 {
     $this->em = \Env::get('em');
     if ($this->em) {
         $this->nodeRepo = $this->em->getRepository('\\Cx\\Core\\ContentManager\\Model\\Entity\\Node');
         $this->pageRepo = $this->em->getRepository('\\Cx\\Core\\ContentManager\\Model\\Entity\\Page');
         $this->logRepo = $this->em->getRepository('\\Cx\\Core\\ContentManager\\Model\\Entity\\LogEntry');
     }
     $this->messages = array();
     $fallback_lang_codes = \FWLanguage::getFallbackLanguageArray();
     $active_langs = \FWLanguage::getActiveFrontendLanguages();
     // get all active languages and their fallbacks
     foreach ($active_langs as $lang) {
         $this->fallbacks[\FWLanguage::getLanguageCodeById($lang['id'])] = array_key_exists($lang['id'], $fallback_lang_codes) ? \FWLanguage::getLanguageCodeById($fallback_lang_codes[$lang['id']]) : null;
     }
 }
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:19,代码来源:JsonNode.class.php

示例2: 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;
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:75,代码来源:CacheLib.class.php

示例3: getFallbackArray

 protected function getFallbackArray()
 {
     $fallbacks = \FWLanguage::getFallbackLanguageArray();
     $output = array();
     foreach ($fallbacks as $key => $value) {
         $output[\FWLanguage::getLanguageCodeById($key)] = \FWLanguage::getLanguageCodeById($value);
     }
     return $output;
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:9,代码来源:ContentManager.class.php

示例4: resolve

 public function resolve()
 {
     // $this->resolveAlias() also sets $this->page
     $aliaspage = $this->resolveAlias();
     if ($aliaspage != null) {
         $this->lang = $aliaspage->getTargetLangId();
         $aliaspage = clone $aliaspage;
         $aliaspage->setVirtual(true);
     } else {
         $this->lang = \Env::get('init')->getFallbackFrontendLangId();
         //try to find the language in the url
         $extractedLanguage = \FWLanguage::getLanguageIdByCode($this->url->getLangDir());
         $activeLanguages = \FWLanguage::getActiveFrontendLanguages();
         if (!$extractedLanguage) {
             $this->redirectToCorrectLanguageDir();
         }
         if (!in_array($extractedLanguage, array_keys($activeLanguages))) {
             $this->lang = \FWLanguage::getDefaultLangId();
             $this->redirectToCorrectLanguageDir();
         }
         //only set langid according to url if the user has not explicitly requested a language change.
         if (!isset($_REQUEST['setLang'])) {
             $this->lang = $extractedLanguage;
             //the user wants to change the language, but we're still inside the wrong language directory.
         } else {
             if ($this->lang != $extractedLanguage) {
                 $this->redirectToCorrectLanguageDir();
             }
         }
     }
     // used for LinkGenerator
     define('FRONTEND_LANG_ID', $this->lang);
     // used to load template file
     \Env::get('init')->setFrontendLangId($this->lang);
     global $section, $command, $history, $sessionObj, $url, $_CORELANG, $page, $pageId, $themesPages, $page_template, $isRegularPageRequest, $now, $start, $end, $plainSection;
     $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : '';
     $command = isset($_REQUEST['cmd']) ? contrexx_addslashes($_REQUEST['cmd']) : '';
     $history = isset($_REQUEST['history']) ? intval($_REQUEST['history']) : 0;
     // Initialize page meta
     $page = null;
     $pageAccessId = 0;
     $page_protected = $pageId = $themesPages = $page_template = null;
     // If standalone is set, then we will not have to initialize/load any content page related stuff
     $isRegularPageRequest = !isset($_REQUEST['standalone']) || $_REQUEST['standalone'] == 'false';
     // Regular page request
     if ($isRegularPageRequest) {
         // TODO: history (empty($history) ? )
         if (isset($_GET['pagePreview']) && $_GET['pagePreview'] == 1 && empty($sessionObj)) {
             $sessionObj = \cmsSession::getInstance();
         }
         $this->init($url, $this->lang, \Env::get('em'), ASCMS_INSTANCE_OFFSET . \Env::get('virtualLanguageDirectory'), \FWLanguage::getFallbackLanguageArray());
         try {
             $this->resolvePage();
             $page = $this->getPage();
             // TODO: should this check (for type 'application') moved to \Cx\Core\ContentManager\Model\Entity\Page::getCmd()|getModule() ?
             // only set $section and $command if the requested page is an application
             $command = $this->getCmd();
             $section = $this->getSection();
         } catch (\Cx\Core\Routing\ResolverException $e) {
             try {
                 $this->legacyResolve($url, $section, $command);
                 $page = $this->getPage();
                 $command = $this->getCmd();
                 $section = $this->getSection();
             } catch (\Cx\Core\Routing\ResolverException $e) {
                 // legacy resolving also failed.
                 // provoke a 404
                 $page = null;
             }
         }
         if (!$page || !$page->isActive()) {
             //fallback for inexistant error page
             if ($section == 'Error') {
                 // If the error module is not installed, show this
                 die($_CORELANG['TXT_THIS_MODULE_DOESNT_EXISTS']);
             } else {
                 //page not found, redirect to error page.
                 \Cx\Core\Csrf\Controller\Csrf::header('Location: ' . \Cx\Core\Routing\Url::fromModuleAndCmd('Error'));
                 exit;
             }
         }
         // TODO: question: what do we need this for? I think there is no need for this (had been added in r15026)
         //legacy: re-populate cmd and section into $_GET
         $_GET['cmd'] = $command;
         $_GET['section'] = $section;
         // END of TODO question
         //check whether the page is active
         $now = new \DateTime('now');
         $start = $page->getStart();
         $end = $page->getEnd();
         $pageId = $page->getId();
         //access: frontend access id for default requests
         $pageAccessId = $page->getFrontendAccessId();
         //revert the page if a history param has been given
         if ($history) {
             //access: backend access id for history requests
             $pageAccessId = $page->getBackendAccessId();
             $logRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\LogEntry');
             try {
                 $logRepo->revert($page, $history);
//.........这里部分代码省略.........
开发者ID:hbdsklf,项目名称:LimeCMS,代码行数:101,代码来源:Resolver.class.php

示例5: _modifyForm


//.........这里部分代码省略.........
     if (empty($_POST['saveForm'])) {
         // get the saved fields
         $fields = $this->getFormFields($formId);
         $recipients = $this->getRecipients($formId);
     } else {
         $fields = $this->_getFormFieldsFromPost();
         $recipients = $this->getRecipientsFromPost();
     }
     $objCrmLibrary = new \Cx\Modules\Crm\Controller\CrmLibrary('Crm');
     $memberships = array_keys($objCrmLibrary->getMemberships());
     $objCrmLibrary->getMembershipDropdown($this->_objTpl, $memberships, "contactMembership", $crmCustomerGroups);
     // make an empty one so at least one is parsed
     if (empty($fields)) {
         foreach ($arrActiveSystemFrontendLanguages as $lang) {
             $fields[0] = array('type' => 'text', 'order_id' => 0, 'is_required' => false, 'check_type' => 1, 'editType' => 'new');
             $fields[0]['lang'][$lang['id']] = array('name' => '', 'value' => '');
         }
     }
     if (!$formId) {
         $selectedInterfaceLanguage = FRONTEND_LANG_ID;
     } elseif (isset($this->arrForms[$formId]['lang'][FRONTEND_LANG_ID])) {
         $selectedInterfaceLanguage = FRONTEND_LANG_ID;
     } elseif (isset($this->arrForms[$formId]['lang'][\FWLanguage::getDefaultLangId()])) {
         $selectedInterfaceLanguage = \FWLanguage::getDefaultLangId();
     } elseif (count($this->arrForms[$formId]['lang'])) {
         $selectedInterfaceLanguage = key($this->arrForms[$formId]['lang']);
     }
     foreach (\FWLanguage::getLanguageArray() as $language) {
         if ($language['id'] == $selectedInterfaceLanguage && $language["frontend"] == 0) {
             $selectedInterfaceLanguage = \FWLanguage::getDefaultLangId();
         }
     }
     //Get the fallback languages array
     $fallBackArr = \FWLanguage::getFallbackLanguageArray();
     $strJsFallBackArr = '';
     foreach ($fallBackArr as $languageId => $fallBackLanguageId) {
         $strJsFallBackArr .= 'arrFallBackLang[' . $languageId . '] = "' . $fallBackLanguageId . '";' . "\n";
     }
     $this->_objTpl->setVariable(array('FALL_BACK_LANGUAGES' => $strJsFallBackArr, 'DEFAULT_LANGUAGE' => \FWLanguage::getDefaultLangId()));
     foreach ($arrActiveSystemFrontendLanguages as $langId => $lang) {
         $isSelectedInterfaceLanguage = $langId == $selectedInterfaceLanguage;
         $langVars = array('is_active' => $isSelectedInterfaceLanguage, 'name' => '', 'text' => '', 'feedback' => '', 'subject' => '', 'mailTemplate' => self::formMailTemplate);
         if (isset($this->arrForms[$formId]['lang'][$langId])) {
             $langVars = $this->arrForms[$formId]['lang'][$langId];
             $langVars['mailTemplate'] = preg_replace('/\\{([A-Z0-9_]*?)\\}/', '[[\\1]]', $langVars['mailTemplate']);
         }
         if (isset($this->arrForms[$formId]['lang'][$fallBackArr[$lang['id']]])) {
             $optionalLanguageId = $fallBackArr[$lang['id']];
         } elseif (isset($this->arrForms[$formId]['lang'][\FWLanguage::getDefaultLangId()])) {
             $optionalLanguageId = \FWLanguage::getDefaultLangId();
         } else {
             $optionalLanguageId = key($this->arrForms[$formId]['lang']);
         }
         $this->_objTpl->setVariable(array('LANG_ID' => $langId, 'LANG_NAME' => contrexx_raw2xhtml($lang['name']), 'TAB_CLASS_NAME' => $isSelectedInterfaceLanguage ? 'active' : 'inactive', 'CONTACT_LANGTAB_DISPLAY' => $langVars['is_active'] ? 'display:inline;' : 'display:none;'));
         $this->_objTpl->parse('languageTabs');
         $this->_objTpl->setVariable(array('LANG_ID' => $lang['id'], 'LANG_NAME' => contrexx_raw2xhtml($lang['name']), 'LANG_FORM_DISPLAY' => $isSelectedInterfaceLanguage ? 'block' : 'none', 'CONTACT_FORM_MAIL_TEMPLATE_HIDDEN' => !empty($langVars['mailTemplate']) ? contrexx_raw2xhtml($langVars['mailTemplate']) : contrexx_raw2xhtml($this->arrForms[$formId]['lang'][$optionalLanguageId]['mailTemplate']), 'CONTACT_FORM_SUBJECT' => !empty($langVars['subject']) ? contrexx_raw2xhtml($langVars['subject']) : contrexx_raw2xhtml($this->arrForms[$formId]['lang'][$optionalLanguageId]['subject'])));
         $this->_objTpl->parse('notificationLanguageForm');
         $this->_objTpl->setVariable(array('CONTACT_FORM_ID' => $formId, 'LANG_ID' => $lang['id'], 'LANG_FORM_DISPLAY' => $isSelectedInterfaceLanguage ? 'block' : 'none', 'CONTACT_FORM_NAME' => !empty($langVars['name']) ? contrexx_raw2xhtml($langVars['name']) : contrexx_raw2xhtml($this->arrForms[$formId]['lang'][$optionalLanguageId]['name']), 'CONTACT_FORM_FIELD_NEXT_ID' => $lastFieldId + 1, 'CONTACT_FORM_TEXT_HIDDEN' => !empty($langVars['text']) ? contrexx_raw2xhtml($langVars['text']) : contrexx_raw2xhtml($this->arrForms[$formId]['lang'][$optionalLanguageId]['text']), 'CONTACT_FORM_FEEDBACK_HIDDEN' => !empty($langVars['feedback']) ? contrexx_raw2xhtml($langVars['feedback']) : contrexx_raw2xhtml($this->arrForms[$formId]['lang'][$optionalLanguageId]['feedback']), 'CONTACT_FORM_RECIPIENT_NEXT_SORT' => $this->getHighestSortValue($formId) + 2, 'CONTACT_FORM_RECIPIENT_NEXT_ID' => $this->getLastRecipientId(true) + 2, 'CONTACT_FORM_FIELD_NEXT_TEXT_TPL' => $this->_getFormFieldAttribute($lastFieldId + 1, 'text', '', $isSelectedInterfaceLanguage, $lang['id']), 'CONTACT_FORM_FIELD_LABEL_NEXT_TPL' => $this->_getFormFieldAttribute($lastFieldId + 1, 'label', '', $isSelectedInterfaceLanguage, $lang['id']), 'CONTACT_FORM_FIELD_CHECK_MENU_NEXT_TPL' => $this->_getFormFieldCheckTypesMenu('contactFormFieldCheckType[' . ($lastFieldId + 1) . ']', 'contactFormFieldCheckType_' . ($lastFieldId + 1), 'text', 1), 'CONTACT_FORM_FIELD_CHECK_MENU_TPL' => $this->_getFormFieldCheckTypesMenu('contactFormFieldCheckType[0]', 'contactFormFieldCheckType_0', 'text', 1), 'CONTACT_FORM_FIELD_CHECK_BOX_NEXT_TPL' => $this->_getFormFieldRequiredCheckBox('contactFormFieldRequired[' . ($lastFieldId + 1) . ']', 'contactFormFieldRequired_' . ($lastFieldId + 1), 'text', false), 'CONTACT_FORM_FIELD_CHECK_BOX_TPL' => $this->_getFormFieldRequiredCheckBox('contactFormFieldRequired[0]', 'contactFormFieldRequired_0', 'text', false), 'CONTACT_ACTION_TITLE' => $actionTitle, 'CONTACT_FORM_FIELD_TEXT_TPL' => $this->_getFormFieldAttribute(0, 'text', '', false), 'CONTACT_FORM_FIELD_LABEL_TPL' => $this->_getFormFieldAttribute(0, 'label', '', false), 'CONTACT_FORM_FIELD_CHECKBOX_TPL' => $this->_getFormFieldAttribute(0, 'checkbox', 0), 'CONTACT_FORM_FIELD_COUNTRY_TPL' => $this->_getFormFieldAttribute(0, 'country', '', true, 0), 'CONTACT_FORM_FIELD_ACCESS_COUNTRY_TPL' => $this->_getFormFieldAttribute(0, 'access_country', '', true, 0), 'CONTACT_FORM_FIELD_CHECKBOX_GROUP_TPL' => $this->_getFormFieldAttribute(0, 'checkboxGroup', '', false), 'CONTACT_FORM_FIELD_DATE_TPL' => $this->_getFormFieldAttribute(0, 'date', '', false), 'CONTACT_FORM_FIELD_DATETIME_TPL' => $this->_getFormFieldAttribute(0, 'datetime', '', false), 'CONTACT_FORM_FIELD_HIDDEN_TPL' => $this->_getFormFieldAttribute(0, 'hidden', '', false), 'CONTACT_FORM_FIELD_RADIO_TPL' => $this->_getFormFieldAttribute(0, 'radio', '', false), 'CONTACT_FORM_FIELD_SELECT_TPL' => $this->_getFormFieldAttribute(0, 'select', '', false)));
         $this->_objTpl->parse('languageForm');
     }
     $this->_objTpl->setVariable('CONTACT_ACTIVE_LANG_NAME', contrexx_raw2xhtml($arrActiveSystemFrontendLanguages[$selectedInterfaceLanguage]['name']));
     $counter = 1;
     foreach ($fields as $fieldID => $field) {
         $realFieldID = $formId > 0 ? $fieldID : $counter;
         $fieldType = $field['type'] == 'special' ? $field['special_type'] : $field['type'];
         $first = true;
开发者ID:nahakiole,项目名称:cloudrexx,代码行数:67,代码来源:ContactManager.class.php


注:本文中的FWLanguage::getFallbackLanguageArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。