本文整理汇总了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;
}
示例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';
}
示例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);
}
}
}
示例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;
}