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


PHP _mergeCustomAppListStrings函数代码示例

本文整理汇总了PHP中_mergeCustomAppListStrings函数的典型用法代码示例。如果您正苦于以下问题:PHP _mergeCustomAppListStrings函数的具体用法?PHP _mergeCustomAppListStrings怎么用?PHP _mergeCustomAppListStrings使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: testAppendDropDown

 public function testAppendDropDown()
 {
     global $app_list_strings;
     $app_list_strings = array("TestList" => array("A" => "Option A", "B" => "Option B", "C" => "Option C"));
     require_once 'include/utils.php';
     file_put_contents($this->testLangFile, "<?php\n\$exemptDropdowns[] = 'TestList';\n\$app_list_strings['TestList']['D'] = 'Option D';\n?>");
     // Initially TestList should have 3 items
     $this->assertEquals(3, count($app_list_strings['TestList']));
     $app_list_strings = _mergeCustomAppListStrings($this->testLangFile, $app_list_strings);
     // After merge with custom language file, TestList should have 4 items (after-fix behaviour)
     $this->assertEquals(4, count($app_list_strings['TestList']));
     unlink($this->testLangFile);
     unset($GLOBALS['app_list_strings']);
 }
开发者ID:butschster,项目名称:sugarcrm_dev,代码行数:14,代码来源:Bug45525Test.php

示例2: return_app_list_strings_language

/**
 * This function retrieves an application language file and returns the array of strings included in the $app_list_strings var.
 *
 * @param string $language specific language to load
 * @return array lang strings
 */
function return_app_list_strings_language($language)
{
    global $app_list_strings;
    global $sugar_config;
    $cache_key = 'app_list_strings.' . $language;
    // Check for cached value
    $cache_entry = sugar_cache_retrieve($cache_key);
    if (!empty($cache_entry)) {
        return $cache_entry;
    }
    $default_language = $sugar_config['default_language'];
    $temp_app_list_strings = $app_list_strings;
    $langs = array();
    if ($language != 'en_us') {
        $langs[] = 'en_us';
    }
    if ($default_language != 'en_us' && $language != $default_language) {
        $langs[] = $default_language;
    }
    $langs[] = $language;
    $app_list_strings_array = array();
    foreach ($langs as $lang) {
        $app_list_strings = array();
        if (file_exists("include/language/{$lang}.lang.php")) {
            include "include/language/{$lang}.lang.php";
            $GLOBALS['log']->info("Found language file: {$lang}.lang.php");
        }
        if (file_exists("include/language/{$lang}.lang.override.php")) {
            include "include/language/{$lang}.lang.override.php";
            $GLOBALS['log']->info("Found override language file: {$lang}.lang.override.php");
        }
        if (file_exists("include/language/{$lang}.lang.php.override")) {
            include "include/language/{$lang}.lang.php.override";
            $GLOBALS['log']->info("Found override language file: {$lang}.lang.php.override");
        }
        $app_list_strings_array[] = $app_list_strings;
    }
    $app_list_strings = array();
    foreach ($app_list_strings_array as $app_list_strings_item) {
        $app_list_strings = sugarArrayMerge($app_list_strings, $app_list_strings_item);
    }
    foreach ($langs as $lang) {
        if (file_exists("custom/application/Ext/Language/{$lang}.lang.ext.php")) {
            $app_list_strings = _mergeCustomAppListStrings("custom/application/Ext/Language/{$lang}.lang.ext.php", $app_list_strings);
            $GLOBALS['log']->info("Found extended language file: {$lang}.lang.ext.php");
        }
        if (file_exists("custom/include/language/{$lang}.lang.php")) {
            include "custom/include/language/{$lang}.lang.php";
            $GLOBALS['log']->info("Found custom language file: {$lang}.lang.php");
        }
    }
    if (!isset($app_list_strings)) {
        $GLOBALS['log']->fatal("Unable to load the application language file for the selected language ({$language}) or the default language ({$default_language}) or the en_us language");
        return null;
    }
    $return_value = $app_list_strings;
    $app_list_strings = $temp_app_list_strings;
    sugar_cache_put($cache_key, $return_value);
    return $return_value;
}
开发者ID:razorinc,项目名称:sugarcrm-example,代码行数:66,代码来源:utils.php

示例3: fix_dropdown_list


//.........这里部分代码省略.........
                                if (!empty($GLOBALS['beanList'][$custom_module])) {
                                    $affected_modules[$custom_module] = $GLOBALS['beanList'][$custom_module];
                                }
                            }
                            //while
                        }
                        //Replace all invalid characters with '_' character
                        $new_key = preg_replace('/[^A-Za-z_]/', '_', $key);
                        $affected_keys[$key] = $new_key;
                        $GLOBALS['app_list_strings'][$new_key] = $GLOBALS['app_list_strings'][$key];
                        unset($GLOBALS['app_list_strings'][$key]);
                        $pattern_match = "/(\\[\\s*\\'{$key}\\'\\s*\\])/";
                        $new_key = "['{$new_key}']";
                        $out = preg_replace($pattern_match, $new_key, $contents);
                        $contents = $out;
                        $touched = true;
                    }
                    //if
                }
                //foreach
                //This is a check for g => h instances where the file contents were incorrectly written
                //and also fixes the scenario where via a UI upgrade, the app_list_strings were incorrectly
                //merged with app_list_strings variables declared elsewhere
                if (!$touched) {
                    if (preg_match('/\\$GLOBALS\\s*\\[\\s*[\\"|\']app_list_strings[\\"|\']\\s*\\]\\s*=\\s*array\\s*\\(/', $contents)) {
                        //Now also remove all the non-custom labels that were added
                        if (preg_match('/language\\/([^\\.]+)\\.lang\\.php$/', $file, $matches)) {
                            $language = $matches[1];
                            $app_list_strings = array();
                            if (file_exists("include/language/{$language}.lang.php")) {
                                include "include/language/{$language}.lang.php";
                            }
                            if (file_exists("include/language/{$language}.lang.override.php")) {
                                $app_list_strings = _mergeCustomAppListStrings("include/language/{$language}.lang.override.php", $app_list_strings);
                            }
                            if (file_exists("custom/application/Ext/Language/{$language}.ext.lang.php")) {
                                $app_list_strings = _mergeCustomAppListStrings("custom/application/Ext/Language/{$language}.ext.lang.php", $app_list_strings);
                            }
                            if (file_exists("custom/application/Ext/Language/{$language}.lang.ext.php")) {
                                $app_list_strings = _mergeCustomAppListStrings("custom/application/Ext/Language/{$language}.lang.ext.php", $app_list_strings);
                            }
                            $all_non_custom_include_language_strings = $app_strings;
                            $all_non_custom_include_language_list_strings = $app_list_strings;
                            $unset_keys = array();
                            if (!empty($GLOBALS['app_list_strings'])) {
                                foreach ($GLOBALS['app_list_strings'] as $key => $value) {
                                    $diff = array();
                                    if (isset($all_non_custom_include_language_list_strings[$key])) {
                                        $diff = array_diff($all_non_custom_include_language_list_strings[$key], $GLOBALS['app_list_strings'][$key]);
                                    }
                                    if (!empty($all_non_custom_include_language_list_strings[$key]) && empty($diff)) {
                                        $unset_keys[] = $key;
                                    }
                                }
                            }
                            foreach ($unset_keys as $key) {
                                unset($GLOBALS['app_list_strings'][$key]);
                            }
                            if (!empty($GLOBALS['app_strings'])) {
                                foreach ($GLOBALS['app_strings'] as $key => $value) {
                                    if (!empty($all_non_custom_include_language_strings[$key])) {
                                        unset($GLOBALS['app_strings'][$key]);
                                    }
                                }
                            }
                        }
开发者ID:omusico,项目名称:sugar_work,代码行数:67,代码来源:uw_utils.php

示例4: return_app_list_strings_language

/** This function retrieves an application language file and returns the array of strings included in the $app_list_strings var.
 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
 * All Rights Reserved.
 * Contributor(s): ______________________________________..
 * If you are using the current language, do not call this function unless you are loading it for the first time */
function return_app_list_strings_language($language)
{
    global $app_list_strings;
    global $sugar_config;
    $cache_key = 'app_list_strings.' . $language;
    // Check for cached value
    $cache_entry = sugar_cache_retrieve($cache_key);
    if (!empty($cache_entry)) {
        return $cache_entry;
    }
    $default_language = $sugar_config['default_language'];
    $temp_app_list_strings = $app_list_strings;
    $language_used = $language;
    include "include/language/en_us.lang.php";
    $en_app_list_strings = array();
    if ($language_used != $default_language) {
        require "include/language/{$default_language}.lang.php";
        if (file_exists("include/language/{$default_language}.lang.override.php")) {
            include "include/language/{$default_language}.lang.override.php";
        }
        if (file_exists("include/language/{$default_language}.lang.php.override")) {
            include "include/language/{$default_language}.lang.php.override";
        }
        $en_app_list_strings = $app_list_strings;
    }
    include "include/language/{$language}.lang.php";
    if (file_exists("include/language/{$language}.lang.override.php")) {
        include "include/language/{$language}.lang.override.php";
    }
    if (file_exists("include/language/{$language}.lang.php.override")) {
        include "include/language/{$language}.lang.php.override";
    }
    // cn: bug 6048 - merge en_us with requested language
    if (!empty($en_app_list_strings)) {
        $app_list_strings = sugarArrayMerge($en_app_list_strings, $app_list_strings);
    }
    if (file_exists("custom/application/Ext/Language/en_us.lang.ext.php")) {
        $app_list_strings = _mergeCustomAppListStrings("custom/application/Ext/Language/en_us.lang.ext.php", $app_list_strings);
    }
    if ($language_used != $default_language) {
        if (file_exists("custom/application/Ext/Language/{$default_language}.lang.ext.php")) {
            $app_list_strings = _mergeCustomAppListStrings("custom/application/Ext/Language/{$default_language}.lang.ext.php", $app_list_strings);
            $GLOBALS['log']->info("Found extended language file: {$default_language}.lang.ext.php");
        }
        if (file_exists("custom/include/language/{$default_language}.lang.php")) {
            include "custom/include/language/{$default_language}.lang.php";
            $GLOBALS['log']->info("Found custom language file: {$default_language}.lang.php");
        }
    }
    if (file_exists("custom/application/Ext/Language/{$language}.lang.ext.php")) {
        $app_list_strings = _mergeCustomAppListStrings("custom/application/Ext/Language/{$language}.lang.ext.php", $app_list_strings);
        $GLOBALS['log']->info("Found extended language file: {$language}.lang.ext.php");
    }
    if (file_exists("custom/include/language/{$language}.lang.php")) {
        include "custom/include/language/{$language}.lang.php";
        $GLOBALS['log']->info("Found custom language file: {$language}.lang.php");
    }
    if (!isset($app_list_strings)) {
        $GLOBALS['log']->warn("Unable to find the application language file for language: " . $language);
        $language_used = $default_language;
        $app_list_strings = $en_app_list_strings;
    }
    if (!isset($app_list_strings)) {
        $GLOBALS['log']->fatal("Unable to load the application language file for the selected language({$language}) or the default language({$default_language})");
        return null;
    }
    $return_value = $app_list_strings;
    $app_list_strings = $temp_app_list_strings;
    sugar_cache_put($cache_key, $return_value);
    return $return_value;
}
开发者ID:nerdystudmuffin,项目名称:dashlet-subpanels,代码行数:76,代码来源:utils.php

示例5: return_app_list_strings_language

/**
 * This function retrieves an application language file and returns the array of strings included in the $app_list_strings var.
 *
 * @param string $language specific language to load
 * @param bool $useCache optional use cache for store language data array
 * @return array lang strings
 */
function return_app_list_strings_language($language, $useCache = true)
{
    global $app_list_strings;
    global $sugar_config;
    //$useCache added to fix CRYS-459 memory limit
    if ($useCache) {
        $cache_key = 'app_list_strings.' . $language;
        // Check for cached value
        $cache_entry = sugar_cache_retrieve($cache_key);
        if (!empty($cache_entry)) {
            return $cache_entry;
        }
    }
    $default_language = !empty($sugar_config['default_language']) ? $sugar_config['default_language'] : $language;
    $temp_app_list_strings = $app_list_strings;
    $langs = array('en_us');
    if ($default_language != 'en_us') {
        $langs[] = $default_language;
    }
    if (!in_array($language, $langs) || $default_language != 'en_us' && $language == 'en_us') {
        $langs[] = $language;
    }
    $app_list_strings_array = array();
    //Merge language files together
    foreach ($langs as $key => $lang) {
        $app_list_strings_state = $app_list_strings;
        foreach (SugarAutoLoader::existing("include/language/{$lang}.lang.php", "include/language/{$lang}.lang.override.php", "include/language/{$lang}.lang.php.override") as $file) {
            include $file;
            $GLOBALS['log']->info("Found language file: {$file}");
        }
        $app_list_strings_array[$lang] = $app_list_strings;
        //Return to previous state unless we are on first iteration and do an intersect merge
        if ($key > 0) {
            $app_list_strings = $app_list_strings_state;
            //In case a custom file doesn't exist for the expected language, we want the custom lists from the default language
            //(if there are key additions/deletions) but we want strings in our expected language (as much as possible).
            $app_list_strings = sugarArrayIntersectMerge($app_list_strings, $app_list_strings_array[$lang]);
        }
        $files = SugarAutoLoader::existing("custom/application/Ext/Language/{$lang}.lang.ext.php", "custom/include/language/{$lang}.lang.php");
        $files = sortExtensionFiles($files);
        foreach ($files as $file) {
            $app_list_strings = _mergeCustomAppListStrings($file, $app_list_strings);
            $GLOBALS['log']->info("Found language file: {$file}");
        }
    }
    if (!isset($app_list_strings)) {
        $GLOBALS['log']->fatal("Unable to load the application language file for the selected language ({$language}) or the default language ({$default_language}) or the en_us language");
        return null;
    }
    $return_value = $app_list_strings;
    $app_list_strings = $temp_app_list_strings;
    //Add to the app_list_strings the list of language available in the application.
    $return_value['available_language_dom'] = get_languages();
    if ($useCache) {
        sugar_cache_put($cache_key, $return_value);
    }
    return $return_value;
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:65,代码来源:utils.php


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