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


PHP System::getLanguages方法代码示例

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


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

示例1: run

 /**
  * Run the controller and parse the login template
  *
  * @return Response
  */
 public function run()
 {
     /** @var BackendTemplate|object $objTemplate */
     $objTemplate = new \BackendTemplate('be_login');
     $strHeadline = sprintf($GLOBALS['TL_LANG']['MSC']['loginTo'], \Config::get('websiteTitle'));
     $objTemplate->theme = \Backend::getTheme();
     $objTemplate->messages = \Message::generate();
     $objTemplate->base = \Environment::get('base');
     $objTemplate->language = $GLOBALS['TL_LANGUAGE'];
     $objTemplate->languages = \System::getLanguages(true);
     $objTemplate->title = \StringUtil::specialchars($strHeadline);
     $objTemplate->charset = \Config::get('characterSet');
     $objTemplate->action = ampersand(\Environment::get('request'));
     $objTemplate->userLanguage = $GLOBALS['TL_LANG']['tl_user']['language'][0];
     $objTemplate->headline = $strHeadline;
     $objTemplate->curLanguage = \Input::post('language') ?: str_replace('-', '_', $GLOBALS['TL_LANGUAGE']);
     $objTemplate->curUsername = \Input::post('username') ?: '';
     $objTemplate->uClass = $_POST && empty($_POST['username']) ? ' class="login_error"' : '';
     $objTemplate->pClass = $_POST && empty($_POST['password']) ? ' class="login_error"' : '';
     $objTemplate->loginButton = \StringUtil::specialchars($GLOBALS['TL_LANG']['MSC']['loginBT']);
     $objTemplate->username = $GLOBALS['TL_LANG']['tl_user']['username'][0];
     $objTemplate->password = $GLOBALS['TL_LANG']['MSC']['password'][0];
     $objTemplate->feLink = $GLOBALS['TL_LANG']['MSC']['feLink'];
     $objTemplate->default = $GLOBALS['TL_LANG']['MSC']['default'];
     $objTemplate->jsDisabled = $GLOBALS['TL_LANG']['MSC']['jsDisabled'];
     return $objTemplate->getResponse();
 }
开发者ID:contao,项目名称:core-bundle,代码行数:32,代码来源:BackendIndex.php

示例2: getLanguages

 /**
  * @param bool $blnReload
  * @return array
  */
 public function getLanguages($blnReload = false)
 {
     if ($blnReload || !is_array(self::$arrLanguages) || count(self::$arrLanguages) < 1) {
         // Get all languages
         $arrSystemLanguages = System::getLanguages();
         // Get all used languages
         $arrLanguages = array();
         // If languages are specified
         if ($GLOBALS['TL_CONFIG']['chooseTranslationLanguages'] == '1') {
             $arrTranslationLanguages = deserialize($GLOBALS['TL_CONFIG']['translationLanguages']);
             if (is_array($arrTranslationLanguages) && $arrTranslationLanguages > 0) {
                 foreach ($arrTranslationLanguages as $strLanguage) {
                     $arrLanguages[$strLanguage] = $arrSystemLanguages[$strLanguage];
                 }
             }
         } else {
             $objRootPages = TranslationFieldsPageModel::findRootPages();
             if ($objRootPages !== null) {
                 while ($objRootPages->next()) {
                     $arrLanguages[$objRootPages->language] = $arrSystemLanguages[$objRootPages->language];
                 }
             }
             // If langauge array is empty
             if (count($arrLanguages) < 1) {
                 // Set all available languages
                 $arrLanguages = System::getLanguages(true);
                 // Set the language of the user to the top
                 if (BackendUser::getInstance()->language != null) {
                     // Get langauge value
                     $strLanguageValue = $arrLanguages[BackendUser::getInstance()->language];
                     // Remove the current language from the array
                     unset($arrLanguages[BackendUser::getInstance()->language]);
                     // Add old array to a temp array
                     $arrLanguagesTemp = $arrLanguages;
                     // Generate a new array
                     $arrLanguages = array(BackendUser::getInstance()->language => $strLanguageValue);
                     // Merge the old array into the new array
                     $arrLanguages = array_merge($arrLanguages, $arrLanguagesTemp);
                 }
             }
         }
         self::$arrLanguages = $arrLanguages;
     }
     return self::$arrLanguages;
 }
开发者ID:Craffft,项目名称:translation-fields-bundle,代码行数:49,代码来源:Languages.php

示例3: getLanguageLabel

 /**
  * @param string $languageCode
  *
  * @return string
  */
 protected function getLanguageLabel($languageCode)
 {
     static $languages;
     if (null === $languages) {
         $languages = System::getLanguages();
     }
     if (array_key_exists($languageCode, $languages)) {
         list($label, ) = explode(' - ', $languages[$languageCode], 2);
     } else {
         $label = $languageCode;
     }
     return $label;
 }
开发者ID:terminal42,项目名称:contao-changelanguage,代码行数:18,代码来源:AbstractViewListener.php


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