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


PHP LanguageManager::getLanguageCacheKey方法代码示例

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


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

示例1: return_module_language

/**
 * This function retrieves a module's language file and returns the array of strings included.
 *
 * @param string $language specific language to load
 * @param string $module module name to load strings for
 * @param bool $refresh optional, true if you want to rebuild the language strings
 * @return array lang strings
 */
function return_module_language($language, $module, $refresh = false)
{
    global $mod_strings;
    global $sugar_config;
    global $currentModule;
    // Jenny - Bug 8119: Need to check if $module is not empty
    if (empty($module)) {
        $stack = debug_backtrace();
        $GLOBALS['log']->warn("Variable module is not in return_module_language " . var_export($stack, true));
        return array();
    }
    if (!$refresh) {
        $cache_key = LanguageManager::getLanguageCacheKey($module, $language);
        // Check for cached value
        $cache_entry = sugar_cache_retrieve($cache_key);
        if (!empty($cache_entry)) {
            return $cache_entry;
        }
    }
    // Store the current mod strings for later
    $temp_mod_strings = $mod_strings;
    $loaded_mod_strings = array();
    $language_used = $language;
    $default_language = $sugar_config['default_language'];
    if (empty($language)) {
        $language = $default_language;
    }
    // Bug 21559 - So we can get all the strings defined in the template, refresh
    // the vardefs file if the cached language file doesn't exist.
    if (!file_exists($GLOBALS['sugar_config']['cache_dir'] . 'modules/' . $module . '/language/' . $language . '.lang.php') && !empty($GLOBALS['beanList'][$module])) {
        $object = $GLOBALS['beanList'][$module];
        if ($object == 'aCase') {
            $object = 'Case';
        }
        VardefManager::refreshVardefs($module, $object);
    }
    $loaded_mod_strings = LanguageManager::loadModuleLanguage($module, $language, $refresh);
    // cn: bug 6048 - merge en_us with requested language
    if ($language != $sugar_config['default_language']) {
        $loaded_mod_strings = sugarArrayMerge(LanguageManager::loadModuleLanguage($module, $sugar_config['default_language'], $refresh), $loaded_mod_strings);
    }
    // Load in en_us strings by default
    if ($language != 'en_us' && $sugar_config['default_language'] != 'en_us') {
        $loaded_mod_strings = sugarArrayMerge(LanguageManager::loadModuleLanguage($module, 'en_us', $refresh), $loaded_mod_strings);
    }
    // If we are in debug mode for translating, turn on the prefix now!
    if ($sugar_config['translation_string_prefix']) {
        foreach ($loaded_mod_strings as $entry_key => $entry_value) {
            $loaded_mod_strings[$entry_key] = $language_used . ' ' . $entry_value;
        }
    }
    $return_value = $loaded_mod_strings;
    if (!isset($mod_strings)) {
        $mod_strings = $return_value;
    } else {
        $mod_strings = $temp_mod_strings;
    }
    $cache_key = LanguageManager::getLanguageCacheKey($module, $language);
    sugar_cache_put($cache_key, $return_value);
    return $return_value;
}
开发者ID:razorinc,项目名称:sugarcrm-example,代码行数:69,代码来源:utils.php

示例2: action_SaveLabel

 public function action_SaveLabel()
 {
     if (!empty($_REQUEST['view_module']) && !empty($_REQUEST['labelValue'])) {
         $_REQUEST["label_" . $_REQUEST['label']] = $_REQUEST['labelValue'];
         // Since the following loop will change aspects of the $_REQUEST
         // array read it into a copy to preserve state on $_REQUEST
         $req = $_REQUEST;
         foreach (ModuleBuilder::getModuleAliases($_REQUEST['view_module']) as $key) {
             $req['view_module'] = $key;
             $parser = new ParserLabel($req['view_module'], isset($req['view_package']) ? $req['view_package'] : null);
             $parser->handleSave($req, $GLOBALS['current_language']);
             // Clear the language cache to make sure the view picks up the latest
             $cache_key = LanguageManager::getLanguageCacheKey($req['view_module'], $GLOBALS['current_language']);
             sugar_cache_clear($cache_key);
         }
         MetaDataManager::refreshSectionCache(MetaDataManager::MM_LABELS);
         MetaDataManager::refreshSectionCache(MetaDataManager::MM_ORDEREDLABELS);
     }
     $this->view = 'modulefields';
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:20,代码来源:controller.php

示例3: clearLangCache

 /**
  * Clear the language string cache in sugar_cache, which will get rid of our
  * language file overrides.
  */
 protected function clearLangCache()
 {
     $language = $GLOBALS['current_language'];
     if (isset($this->_strings['app_strings'])) {
         $cache_key = 'app_strings.' . $language;
         sugar_cache_clear($cache_key);
     }
     if (isset($this->_strings['app_list_strings'])) {
         $cache_key = 'app_list_strings.' . $language;
         sugar_cache_clear($cache_key);
     }
     if (isset($this->_strings['mod_strings'])) {
         foreach ($this->_strings['mod_strings'] as $module => $strings) {
             $cache_key = LanguageManager::getLanguageCacheKey($module, $language);
             sugar_cache_clear($cache_key);
         }
     }
 }
开发者ID:jgera,项目名称:sugarcrm_dev,代码行数:22,代码来源:SugarTestLangPackCreator.php

示例4: return_module_language

/**
 * This function retrieves a module's language file and returns the array of strings included.
 *
 * @param string $language specific language to load
 * @param string $module module name to load strings for
 * @param bool $refresh optional, true if you want to rebuild the language strings
 * @return array lang strings
 */
function return_module_language($language, $module, $refresh = false)
{
    global $mod_strings;
    global $sugar_config;
    global $currentModule;
    // Jenny - Bug 8119: Need to check if $module is not empty
    if (empty($module)) {
        $message = "Variable module is not in return_module_language ";
        //If any object in the stack contains a circular reference,
        //debug_backtrace will cause a fatal recursive dependency error without DEBUG_BACKTRACE_IGNORE_ARGS
        if (version_compare(PHP_VERSION, '5.3.6') >= 0) {
            $message .= var_export(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), true);
        }
        $GLOBALS['log']->warn($message);
        return array();
    }
    if (!$refresh) {
        $cache_key = LanguageManager::getLanguageCacheKey($module, $language);
        // Check for cached value
        $cache_entry = sugar_cache_retrieve($cache_key);
        if (!empty($cache_entry) && is_array($cache_entry)) {
            return $cache_entry;
        }
    }
    // Store the current mod strings for later
    $temp_mod_strings = $mod_strings;
    $loaded_mod_strings = array();
    $language_used = $language;
    $default_language = !empty($sugar_config['default_language']) ? $sugar_config['default_language'] : $language;
    $bean = BeanFactory::getBean($module);
    if (empty($language)) {
        $language = $default_language;
    }
    // Bug 21559 - So we can get all the strings defined in the template, refresh
    // the vardefs file if the cached language file doesn't exist.
    if (!file_exists(sugar_cached('modules/') . $module . '/language/' . $language . '.lang.php') && !empty($GLOBALS['beanList'][$module])) {
        $object = BeanFactory::getObjectName($module);
        VardefManager::loadVardef($module, $object);
    }
    $loaded_mod_strings = LanguageManager::loadModuleLanguage($module, $language, $refresh);
    // BR-24 & BR-25, some modules, like Dynamic Fields, don't have a module_dir and this throws a notice
    if ($bean && !empty($bean->module_dir) && $bean->module_dir !== $module) {
        $loaded_mod_strings = sugarLangArrayMerge(LanguageManager::loadModuleLanguage($bean->module_dir, $language, $refresh), $loaded_mod_strings);
    }
    // cn: bug 6048 - merge en_us with requested language
    if ($language != $default_language) {
        $loaded_mod_strings = sugarLangArrayMerge(LanguageManager::loadModuleLanguage($module, $default_language, $refresh), $loaded_mod_strings);
        if ($bean && !empty($bean->module_dir) && $bean->module_dir !== $module) {
            $loaded_mod_strings = sugarLangArrayMerge(LanguageManager::loadModuleLanguage($bean->module_dir, $default_language, $refresh), $loaded_mod_strings);
        }
    }
    // Load in en_us strings by default
    if ($language != 'en_us' && $default_language != 'en_us') {
        $loaded_mod_strings = sugarLangArrayMerge(LanguageManager::loadModuleLanguage($module, 'en_us', $refresh), $loaded_mod_strings);
        if ($bean && $bean->module_dir !== $module) {
            $loaded_mod_strings = sugarLangArrayMerge(LanguageManager::loadModuleLanguage($bean->module_dir, 'en_us', $refresh), $loaded_mod_strings);
        }
    }
    // If we are in debug mode for translating, turn on the prefix now!
    if (!empty($sugar_config['translation_string_prefix']) && isset($loaded_mod_strings)) {
        foreach ($loaded_mod_strings as $entry_key => $entry_value) {
            $loaded_mod_strings[$entry_key] = $language_used . ' ' . $entry_value;
        }
    }
    $return_value = $loaded_mod_strings;
    if (!isset($mod_strings)) {
        $mod_strings = $return_value;
    } else {
        $mod_strings = $temp_mod_strings;
    }
    $cache_key = LanguageManager::getLanguageCacheKey($module, $language);
    sugar_cache_put($cache_key, $return_value);
    return $return_value;
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:82,代码来源:utils.php


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