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


PHP XoopsLists::getLocaleList方法代码示例

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


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

示例1: __construct

 /**
  * @param null $obj
  */
 public function __construct($obj = null)
 {
     $xoops = Xoops::getInstance();
     parent::__construct('', 'xlanguage_form', $xoops->getEnv('PHP_SELF'), 'post', true, 'horizontal');
     // language name
     $xlanguage_select = new Xoops\Form\Select(_AM_XLANGUAGE_NAME, 'xlanguage_name', $obj->getVar('xlanguage_name'));
     $xlanguage_select->addOptionArray(XoopsLists::getLocaleList());
     $this->addElement($xlanguage_select, true);
     // language description
     $this->addElement(new Xoops\Form\Text(_AM_XLANGUAGE_DESCRIPTION, 'xlanguage_description', 5, 30, $obj->getVar('xlanguage_description')), true);
     // language charset
     $autoload = XoopsLoad::loadConfig('xlanguage');
     $charset_select = new Xoops\Form\Select(_AM_XLANGUAGE_CHARSET, 'xlanguage_charset', $obj->getVar('xlanguage_charset'));
     $charset_select->addOptionArray($autoload['charset']);
     $this->addElement($charset_select);
     // language code
     $this->addElement(new Xoops\Form\Text(_AM_XLANGUAGE_CODE, 'xlanguage_code', 5, 10, $obj->getVar('xlanguage_code')), true);
     // language weight
     $this->addElement(new Xoops\Form\Text(_AM_XLANGUAGE_WEIGHT, 'xlanguage_weight', 1, 4, $obj->getVar('xlanguage_weight')));
     // language image
     $image_option_tray = new Xoops\Form\ElementTray(_AM_XLANGUAGE_IMAGE, '');
     $image_array = XoopsLists::getImgListAsArray(\XoopsBaseConfig::get('root-path') . '/media/xoops/images/flags/' . \Xoops\Module\Helper::getHelper('xlanguage')->getConfig('theme') . '/');
     $image_select = new Xoops\Form\Select('', 'xlanguage_image', $obj->getVar('xlanguage_image'));
     $image_select->addOptionArray($image_array);
     $image_select->setExtra("onchange='showImgSelected(\"image\", \"xlanguage_image\", \"/media/xoops/images/flags/" . \Xoops\Module\Helper::getHelper('xlanguage')->getConfig('theme') . "/\", \"\", \"" . \XoopsBaseConfig::get('url') . "\")'");
     $image_tray = new Xoops\Form\ElementTray('', ' ');
     $image_tray->addElement($image_select);
     $image_tray->addElement(new Xoops\Form\Label('', "<div style='padding: 8px;'><img style='width:24px; height:24px; ' src='" . \XoopsBaseConfig::get('url') . "/media/xoops/images/flags/" . \Xoops\Module\Helper::getHelper('xlanguage')->getConfig('theme') . "/" . $obj->getVar("xlanguage_image") . "' name='image' id='image' alt='' /></div>"));
     $image_option_tray->addElement($image_tray);
     $this->addElement($image_option_tray);
     $this->addElement(new Xoops\Form\Hidden('xlanguage_id', $obj->getVar('xlanguage_id')));
     /**
      * Buttons
      */
     $button_tray = new Xoops\Form\ElementTray('', '');
     $button_tray->addElement(new Xoops\Form\Hidden('op', 'save'));
     $button = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit');
     $button->setClass('btn btn-success');
     $button_tray->addElement($button);
     $button_2 = new Xoops\Form\Button('', 'reset', XoopsLocale::A_RESET, 'reset');
     $button_2->setClass('btn btn-warning');
     $button_tray->addElement($button_2);
     switch (basename($xoops->getEnv('PHP_SELF'), '.php')) {
         case 'xoops_xlanguage':
             $button_3 = new Xoops\Form\Button('', 'button', XoopsLocale::A_CLOSE, 'button');
             $button_3->setExtra('onclick="tinyMCEPopup.close();"');
             $button_3->setClass('btn btn-danger');
             $button_tray->addElement($button_3);
             break;
         case 'index':
         default:
             $button_3 = new Xoops\Form\Button('', 'cancel', XoopsLocale::A_CANCEL, 'button');
             $button_3->setExtra("onclick='javascript:history.go(-1);'");
             $button_3->setClass('btn btn-danger');
             $button_tray->addElement($button_3);
             break;
     }
     $this->addElement($button_tray);
 }
开发者ID:redmexico,项目名称:XoopsCore,代码行数:62,代码来源:language.php

示例2: getUserLocales

 /**
  * getUserLocales()
  * Returns the user locales
  * Normally it returns an array like this:
  * 1. Forced language
  * 2. Language in $_GET['lang']
  * 3. Language in $_SESSION['lang']
  * 4. HTTP_ACCEPT_LANGUAGE
  * 5. Fallback language
  * Note: duplicate values are deleted.
  *
  * @return array with the user locales sorted by priority. Highest is best.
  */
 public static function getUserLocales()
 {
     if (empty(self::$_userLocales)) {
         // reset user_lang array
         $userLocales = array();
         // Highest priority: forced language
         //if ($this->forcedLang != NULL) {
         //    $userLocales[] = $this->forcedLang;
         //}
         // 2nd highest priority: GET parameter 'lang'
         if (isset($_GET['lang']) && is_string($_GET['lang'])) {
             $userLocales[] = $_GET['lang'];
         }
         // 3rd highest priority: SESSION parameter 'lang'
         if (isset($_SESSION['lang']) && is_string($_SESSION['lang'])) {
             $userLocales[] = $_SESSION['lang'];
         }
         // 4th highest priority: HTTP_ACCEPT_LANGUAGE
         if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
             foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $part) {
                 if (preg_match("/(.*);q=([0-1]{0,1}\\.\\d{0,4})/i", $part, $matches)) {
                     $userLocales[] = $matches[1];
                 } else {
                     $userLocales[] = $part;
                 }
             }
         }
         $userLocales[] = Xoops::getInstance()->getConfig('locale');
         // Lowest priority: fallback
         $userLocales[] = static::$_defaultLocale;
         $availableLocales = XoopsLists::getLocaleList();
         // remove not allowed characters
         foreach ($userLocales as $key => $value) {
             $value = preg_replace('/[^a-zA-Z0-9_\\-]/', '', $value);
             // only allow a-z, A-Z and 0-9
             if ($value && in_array($value, $availableLocales)) {
                 self::$_userLocales[$key] = str_replace('-', '_', $value);
             }
         }
         // remove duplicate elements
         self::$_userLocales = array_unique(self::$_userLocales);
     }
     return self::$_userLocales;
 }
开发者ID:redmexico,项目名称:XoopsCore,代码行数:57,代码来源:Locale.php

示例3: __construct

 /**
  * Constructor
  *
  * @param string  $caption caption
  * @param string  $name    name
  * @param mixed   $value   Pre-selected value (or array of them). Valid value is
  *                         any name of a XOOPS_ROOT_PATH."/locale/" subdirectory.
  * @param integer $size    Number of rows. "1" makes a drop-down-list.
  */
 public function __construct($caption, $name, $value = null, $size = 1)
 {
     parent::__construct($caption, $name, $value, $size);
     $this->addOptionArray(\XoopsLists::getLocaleList());
 }
开发者ID:redmexico,项目名称:XoopsCore,代码行数:14,代码来源:SelectLocale.php


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