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


PHP Languages::all方法代码示例

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


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

示例1: constructRulesUsingCallBack

function constructRulesUsingCallBack($rules, \Languages $langs, $task)
{
    foreach ($rules as $fieldType => $rule) {
        foreach ($langs->all() as $lang) {
            $task($langRules, $fieldType, $lang, $rule);
        }
    }
    return $langRules;
}
开发者ID:JoshuaReneDalley,项目名称:php,代码行数:9,代码来源:callback.php

示例2: save

 public function save(array $options = array())
 {
     if (!$this->exists()) {
         parent::save();
     }
     $langs = Languages::all();
     foreach ($langs as $lang) {
         $translation = Translations::find($this->table . "_" . $this->id . "_" . strtolower($lang->code));
         if ($lang->code == Config::get('cms.currlang.code') || !isset($translation->exists)) {
             //check if translation exists
             if (isset($translation->exists)) {
             } else {
                 $translation = new Translations();
             }
             $translation->id = $this->table . "_" . $this->id . "_" . strtolower($lang->code);
             $translation->translation = json_encode($this->getAttributes());
             $translation->save();
         }
     }
     return;
 }
开发者ID:basdog22,项目名称:laracms,代码行数:21,代码来源:Lara.php

示例3: execute

 public function execute(array &$param_pool = null)
 {
     $result = new XMLElement('fl-languages');
     $main_lang = FLang::getMainLang();
     $crt_lc = FLang::getLangCode();
     $lang_names = Languages::all()->listAll();
     $langs = FLang::getLangs();
     $current_language_xml = new XMLElement('current-language', $lang_names[$crt_lc] ? $lang_names[$crt_lc]['name'] : $crt_lc);
     $current_language_xml->setAttribute('handle', $crt_lc);
     $current_language_xml->setAttribute('language', FLang::getLang());
     $current_language_xml->setAttribute('region', FLang::getReg());
     $result->appendChild($current_language_xml);
     $supported_languages_xml = new XMLElement('supported-languages');
     foreach ($langs as $lc) {
         $lang_xml = new XMLElement('item', $lang_names[$lc] ? $lang_names[$lc]['name'] : $lc);
         $lang_xml->setAttribute('handle', $lc);
         if ($lc === $main_lang) {
             $lang_xml->setAttribute('main', 'yes');
         }
         $supported_languages_xml->appendChild($lang_xml);
     }
     $result->appendChild($supported_languages_xml);
     return $result;
 }
开发者ID:siimsoni,项目名称:frontend_localisation,代码行数:24,代码来源:data.fl_languages.php

示例4: findOptions

 /**
  * Get language options for in desired language. Useful to build a Select widget.
  *
  * @param array|string|int $selected - An array of language codes to mark as selected
  * @param array            $pool     (optional) - An array of language codes to be displayed. Leave null to show all.
  * @param string           $lang     (optional) - Get language names for this language.
  *
  * @return array
  */
 public static function findOptions($selected = array(), $pool = null, $lang = null)
 {
     if (!is_array($selected)) {
         $selected = array($selected);
     }
     $native = Languages::all()->listAll('name');
     if (is_array($pool)) {
         $native = array_intersect_key($native, array_flip($pool));
     }
     if ($lang === null) {
         $lang = Lang::get();
     }
     // try to get languages in author language
     $local = Languages::local()->listAll($lang);
     // if languages not found, use english ones
     if ($local === false) {
         $local = Languages::local()->listAll();
     }
     $options = array();
     foreach ($native as $code => $info) {
         $options[] = array($code, in_array($code, $selected), sprintf("[%s] %s%s", strtoupper($code), isset($local[$code]) ? $local[$code] . ' || ' : '', $info['name']));
     }
     return $options;
 }
开发者ID:siimsoni,项目名称:languages,代码行数:33,代码来源:extension.driver.php

示例5: setLangs

 /**
  * Set language codes
  *
  * @param $langs
  *
  * @return boolean
  */
 public static function setLangs($langs)
 {
     $langs = explode(',', General::sanitize($langs));
     // if no language codes, return false
     if ($langs === false || !is_array($langs)) {
         return false;
     }
     $langs = self::cleanLanguageCodes($langs);
     if (count($langs) === 0) {
         return false;
     }
     $new_codes = array();
     $all_codes = array_keys(Languages::all()->listAll());
     // only valid language codes are preserved
     foreach ($langs as $lc) {
         if (in_array($lc, $all_codes)) {
             $new_codes[] = $lc;
         }
     }
     // if no valid language codes, return false
     if (empty($new_codes)) {
         return false;
     }
     // store the new language codes
     self::$_langs = $new_codes;
     return true;
 }
开发者ID:siimsoni,项目名称:frontend_localisation,代码行数:34,代码来源:class.FLang.php


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