Ejemplo n.º 1
0
 /**
  * Sorts file paths and returns sorted copy
  *
  * @param array $files File paths
  * @return array Sorted file paths
  */
 protected function sortExtensionFiles(array $files)
 {
     return sortExtensionFiles($files);
 }
Ejemplo n.º 2
0
/**
 * 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;
}