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


PHP CMbString::filterEmpty方法代码示例

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


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

示例1: writeLocaleFile

 /**
  * Writes a locale file
  * 
  * @param string $language The language code (fr, en, ...)
  * @param array  $locales  The locales
  * @param string $label    A code to istinguish different locales listes
  * 
  * @return void
  */
 static function writeLocaleFile($language, $locales = null, $label = null)
 {
     global $version;
     if (!$locales) {
         $localeFiles = array_merge(glob("./locales/{$language}/*.php"), glob("./modules/*/locales/{$language}.php"), glob("./mobile/modules/*/locales/{$language}.php"));
         foreach ($localeFiles as $localeFile) {
             if (basename($localeFile) != "meta.php") {
                 include $localeFile;
             }
         }
     }
     $path = self::getLocaleFilePath($language, $label);
     if ($fp = fopen($path, 'w')) {
         $locales = CMbString::filterEmpty($locales);
         // TODO: change the invalid keys (with accents) of the locales to simplify this
         $keys = array_map('utf8_encode', array_keys($locales));
         $values = array_map('utf8_encode', array_values($locales));
         foreach ($values as &$_value) {
             $_value = CMbString::unslash($_value);
         }
         $compress = false;
         if ($compress) {
             $delim = "/([\\.-])/";
             $arr = new stdClass();
             foreach ($keys as $_pos => $_key) {
                 $parts = preg_split($delim, $_key, -1, PREG_SPLIT_DELIM_CAPTURE);
                 $_arr = $arr;
                 $last_key = count($parts) - 1;
                 foreach ($parts as $i => $_token) {
                     $last = $i == $last_key;
                     if ($_token === "") {
                         $_token = '_$_';
                     }
                     if ($last) {
                         $_arr->{$_token} = (object) array('$' => $values[$_pos]);
                         break;
                     } elseif (!isset($_arr->{$_token})) {
                         $_arr->{$_token} = new stdClass();
                     }
                     $_arr = $_arr->{$_token};
                 }
                 //unset($_arr);
             }
             self::clearLocalesKeys($arr);
             $json = $arr;
         } else {
             $json = array_combine($keys, $values);
         }
         $script = '//' . $version['build'] . "\nwindow.locales=" . json_encode($json) . ";";
         fwrite($fp, $script);
         fclose($fp);
     }
 }
开发者ID:fbone,项目名称:mediboard4,代码行数:62,代码来源:CJSLoader.class.php

示例2: foreach

 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision$
 */
global $version;
CCanDo::checkEdit();
/////////// Locales
foreach (glob("locales/*", GLOB_ONLYDIR) as $localeDir) {
    $localeName = basename($localeDir);
    $locales = array();
    $localeFiles = CAppUI::getLocaleFilesPaths($localeName);
    foreach ($localeFiles as $localeFile) {
        if (basename($localeFile) != "meta.php") {
            include $localeFile;
        }
    }
    $locales = CMbString::filterEmpty($locales);
    foreach ($locales as &$_locale) {
        $_locale = CMbString::unslash($_locale);
    }
    $path = "./tmp/locales-{$localeName}.js";
    if (!is_file($path)) {
        CAppUI::stepAjax("Locales-javascript-cache-none", UI_MSG_OK, $localeName);
        continue;
    }
    $fp = fopen($path, 'r');
    preg_match('#^//(\\d+)#', fgets($fp), $v);
    if ($v[1] < $version['build']) {
        CAppUI::stepAjax("Locales-javascript-cache-ko", UI_MSG_WARNING, $localeName);
        fclose($fp);
        continue;
    }
开发者ID:OpenXtrem,项目名称:mediboard-test,代码行数:31,代码来源:httpreq_check_shared_memory.php

示例3: loadLocales

 /**
  * Load locales from cache or build the cache
  *
  * @return void
  */
 public static function loadLocales()
 {
     $lang = CAppUI::pref("LOCALE", "fr");
     self::$lang = $lang;
     $shared_name = "locales-{$lang}";
     $locales_prefixes = SHM::get("{$shared_name}-" . self::LOCALES_PREFIX);
     // Load from shared memory if possible
     if ($locales_prefixes) {
         return;
     }
     $mutex = new CMbFileMutex("locales-build");
     $mutex->acquire(5);
     $locales_prefixes = SHM::get("{$shared_name}-" . self::LOCALES_PREFIX);
     // Load from shared memory if possible
     if ($locales_prefixes) {
         $mutex->release();
         return;
     }
     $locales = array();
     foreach (self::getLocaleFilesPaths($lang) as $_path) {
         include_once $_path;
     }
     $locales = CMbString::filterEmpty($locales);
     foreach ($locales as &$_locale) {
         $_locale = CMbString::unslash($_locale);
     }
     unset($_locale);
     // Load overwritten locales if the table exists
     $overwrite = new CTranslationOverwrite();
     if ($overwrite->isInstalled()) {
         $locales = $overwrite->transformLocales($locales, $lang);
     }
     // Prefix = everything before "." and "-"
     $by_prefix = array();
     $hashes = array();
     foreach ($locales as $_key => $_value) {
         /** @var string $_prefix */
         /** @var string $_rest */
         /** @var string $_prefix_raw */
         list($_prefix, $_rest, $_prefix_raw) = self::splitLocale($_key);
         if (!isset($by_prefix[$_prefix])) {
             $hashes[$_prefix] = $_prefix_raw;
             $by_prefix[$_prefix] = array();
         }
         $by_prefix[$_prefix][$_rest] = $_value;
     }
     foreach ($by_prefix as $_prefix => $_locales) {
         self::$locales[$_prefix] = $_locales;
         self::$locales_loaded[$_prefix] = true;
         SHM::put("{$shared_name}-{$_prefix}", $_locales);
     }
     SHM::put("{$shared_name}-" . self::LOCALES_PREFIX, $hashes);
     $mutex->release();
 }
开发者ID:fbone,项目名称:mediboard4,代码行数:59,代码来源:CAppUI.class.php


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