Exemplo n.º 1
0
 /**
  * Returns an array with an element for each index
  *
  * @return array
  */
 public function getDuplicateCheckIndexes()
 {
     $super_language_pack = sugarLangArrayMerge(return_module_language($GLOBALS['current_language'], $this->_focus->module_dir), $GLOBALS['app_strings']);
     $index_array = array();
     foreach ($this->_getIndexVardefs() as $index) {
         if ($index['type'] == "index") {
             $labelsArray = array();
             foreach ($index['fields'] as $field) {
                 if ($field == 'deleted') {
                     continue;
                 }
                 $fieldDef = $this->_focus->getFieldDefinition($field);
                 if (isset($fieldDef['vname']) && isset($super_language_pack[$fieldDef['vname']])) {
                     $labelsArray[$fieldDef['name']] = $super_language_pack[$fieldDef['vname']];
                 } else {
                     $labelsArray[$fieldDef['name']] = $fieldDef['name'];
                 }
             }
             $index_array[$index['name']] = str_replace(":", "", implode(", ", $labelsArray));
         }
     }
     return $index_array;
 }
Exemplo n.º 2
0
 function getAppListStrings($language = 'en_us')
 {
     $language .= '.lang.php';
     if (!empty($this->appListStrings[$language]) && $language != 'en_us.lang.php') {
         return sugarLangArrayMerge($this->appListStrings['en_us.lang.php'], $this->appListStrings[$language]);
     }
     if (!empty($this->appListStrings['en_us.lang.php'])) {
         return $this->appListStrings['en_us.lang.php'];
     }
     $empty = array();
     return $empty;
 }
Exemplo n.º 3
0
 /**
  * Given a module, search all of the specified locations, and any others as specified
  * in order to refresh the cache file
  *
  * @param string $module the given module we want to load the vardefs for
  * @param string $lang the given language we wish to load
  * @param array $additional_search_paths an array which allows a consumer to pass in additional vardef locations to search
  */
 function refreshLanguage($module, $lang, $loaded_mod_strings = array(), $additional_search_paths = null)
 {
     // Some of the vardefs do not correctly define dictionary as global.  Declare it first.
     $lang_paths = array('modules/' . $module . '/language/' . $lang . '.lang.php', 'modules/' . $module . '/language/' . $lang . '.lang.override.php', 'custom/modules/' . $module . '/Ext/Language/' . $lang . '.lang.ext.php', 'custom/modules/' . $module . '/language/' . $lang . '.lang.php');
     #27023, if this module template language file was not attached , get the template from this module vardef cache file if exsits and load the template language files.
     static $createdModules;
     if (empty($createdModules[$module]) && isset($GLOBALS['beanList'][$module])) {
         $object = $GLOBALS['beanList'][$module];
         if ($object == 'aCase') {
             $object = 'Case';
         }
         if (!empty($GLOBALS["dictionary"]["{$object}"]["templates"])) {
             $templates = $GLOBALS["dictionary"]["{$object}"]["templates"];
             $loaded_mod_strings = LanguageManager::loadTemplateLanguage($module, $templates, $lang, $loaded_mod_strings);
             $createdModules[$module] = true;
         }
     }
     //end of fix #27023
     // Add in additional search paths if they were provided.
     if (!empty($additional_search_paths) && is_array($additional_search_paths)) {
         $lang_paths = array_merge($lang_paths, $additional_search_paths);
     }
     //search a predefined set of locations for the vardef files
     foreach ($lang_paths as $path) {
         if (file_exists($path)) {
             require $path;
             if (!empty($mod_strings)) {
                 if (function_exists('sugarArrayMergeRecursive')) {
                     $loaded_mod_strings = sugarArrayMergeRecursive($loaded_mod_strings, $mod_strings);
                 } else {
                     $loaded_mod_strings = sugarLangArrayMerge($loaded_mod_strings, $mod_strings);
                 }
             }
         }
     }
     //great! now that we have loaded all of our vardefs.
     //let's go save them to the cache file.
     if (!empty($loaded_mod_strings)) {
         LanguageManager::saveCache($module, $lang, $loaded_mod_strings);
     }
 }
Exemplo n.º 4
0
/** This function retrieves an application language file and returns the array of strings included in the $mod_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_mod_list_strings_language($language, $module)
{
    global $mod_list_strings;
    global $sugar_config;
    global $currentModule;
    $cache_key = "mod_list_str_lang." . $language . $module;
    // Check for cached value
    $cache_entry = sugar_cache_retrieve($cache_key);
    if (!empty($cache_entry)) {
        return $cache_entry;
    }
    $language_used = $language;
    $temp_mod_list_strings = $mod_list_strings;
    $default_language = $sugar_config['default_language'];
    if ($currentModule == $module && isset($mod_list_strings) && $mod_list_strings != null) {
        return $mod_list_strings;
    }
    // cn: bug 6351 - include en_us if file langpack not available
    // cn: bug 6048 - merge en_us with requested language
    include "modules/{$module}/language/en_us.lang.php";
    $en_mod_list_strings = array();
    if ($language_used != $default_language) {
        $en_mod_list_strings = $mod_list_strings;
    }
    if (file_exists("modules/{$module}/language/{$language}.lang.php")) {
        include "modules/{$module}/language/{$language}.lang.php";
    }
    if (file_exists("modules/{$module}/language/{$language}.lang.override.php")) {
        include "modules/{$module}/language/{$language}.lang.override.php";
    }
    if (file_exists("modules/{$module}/language/{$language}.lang.php.override")) {
        echo 'Please Change:<br>' . "modules/{$module}/language/{$language}.lang.php.override" . '<br>to<br>' . 'Please Change:<br>' . "modules/{$module}/language/{$language}.lang.override.php";
        include "modules/{$module}/language/{$language}.lang.php.override";
    }
    // cn: bug 6048 - merge en_us with requested language
    $mod_list_strings = sugarLangArrayMerge($en_mod_list_strings, $mod_list_strings);
    // if we still don't have a language pack, then log an error
    if (!isset($mod_list_strings)) {
        $GLOBALS['log']->fatal("Unable to load the application list language file for the selected language({$language}) or the default language({$default_language}) for module({$module})");
        return null;
    }
    $return_value = $mod_list_strings;
    $mod_list_strings = $temp_mod_list_strings;
    sugar_cache_put($cache_key, $return_value);
    return $return_value;
}
Exemplo n.º 5
0
        }
    }
}
if (isset($_POST['language'])) {
    $_SESSION['language'] = str_replace('-', '_', $_POST['language']);
}
$current_language = isset($_SESSION['language']) ? $_SESSION['language'] : $default_lang;
if (file_exists("install/language/{$current_language}.lang.php")) {
    require_once "install/language/{$current_language}.lang.php";
} else {
    require_once "install/language/{$default_lang}.lang.php";
}
if ($current_language != 'en_us') {
    $my_mod_strings = $mod_strings;
    include 'install/language/en_us.lang.php';
    $mod_strings = sugarLangArrayMerge($mod_strings, $my_mod_strings);
}
$app_list_strings = return_app_list_strings_language($current_language);
////	END INSTALLER LANGUAGE
///////////////////////////////////////////////////////////////////////////////
//get the url for the helper link
$help_url = get_help_button_url();
//if this license print, then redirect and exit,
if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'licensePrint') {
    include 'install/licensePrint.php';
    exit;
}
if (isset($_REQUEST['sugar_body_only']) && $_REQUEST['sugar_body_only'] == "1") {
    //if this is a system check, then just run the check and return,
    //this is an ajax call and there is no need for further processing
    if (isset($_REQUEST['uploadLogoFrame']) && $_REQUEST['uploadLogoFrame']) {
Exemplo n.º 6
0
 function save($key_name, $duplicate = false, $rename = false)
 {
     $header = file_get_contents('modules/ModuleBuilder/MB/header.php');
     $save_path = $this->path . '/language';
     mkdir_recursive($save_path);
     foreach ($this->strings as $lang => $values) {
         //Check if the module Label has changed.
         $renameLang = $rename || empty($values) || isset($values['LBL_MODULE_NAME']) && $this->label != $values['LBL_MODULE_NAME'];
         $mod_strings = return_module_language(str_replace('.lang.php', '', $lang), 'ModuleBuilder');
         $required = array('LBL_LIST_FORM_TITLE' => $this->label . " " . $mod_strings['LBL_LIST'], 'LBL_MODULE_NAME' => $this->label, 'LBL_MODULE_TITLE' => $this->label, 'LBL_HOMEPAGE_TITLE' => $mod_strings['LBL_HOMEPAGE_PREFIX'] . " " . $this->label, 'LNK_NEW_RECORD' => $mod_strings['LBL_CREATE'] . " " . $this->label, 'LNK_LIST' => $mod_strings['LBL_VIEW'] . " " . $this->label, 'LNK_IMPORT_' . strtoupper($this->key_name) => translate('LBL_IMPORT') . " " . $this->label, 'LBL_SEARCH_FORM_TITLE' => $mod_strings['LBL_SEARCH'] . " " . $this->label, 'LBL_HISTORY_SUBPANEL_TITLE' => $mod_strings['LBL_HISTORY'], 'LBL_ACTIVITIES_SUBPANEL_TITLE' => $mod_strings['LBL_ACTIVITIES'], 'LBL_' . strtoupper($this->key_name) . '_SUBPANEL_TITLE' => $this->label, 'LBL_NEW_FORM_TITLE' => $mod_strings['LBL_NEW'] . " " . $this->label);
         foreach ($required as $k => $v) {
             if (empty($values[$k]) || $renameLang) {
                 $values[$k] = $v;
             }
         }
         write_array_to_file('mod_strings', $values, $save_path . '/' . $lang, 'w', $header);
     }
     $app_save_path = $this->path . '/../../language/application';
     mkdir_recursive($app_save_path);
     $key_changed = $this->key_name != $key_name;
     foreach ($this->appListStrings as $lang => $values) {
         // Load previously created modules data
         $app_list_strings = array();
         $neededFile = $app_save_path . '/' . $lang;
         if (file_exists($neededFile)) {
             include $neededFile;
         }
         if (!$duplicate) {
             unset($values['moduleList'][$this->key_name]);
         }
         $values = sugarLangArrayMerge($values, $app_list_strings);
         $values['moduleList'][$key_name] = $this->label;
         $appFile = $header . "\n";
         require_once 'include/utils/array_utils.php';
         $this->getGlobalAppListStringsForMB($values);
         foreach ($values as $key => $array) {
             if ($duplicate) {
                 //keep the original when duplicating
                 $appFile .= override_value_to_string_recursive2('app_list_strings', $key, $array);
             }
             $okey = $key;
             if ($key_changed) {
                 $key = str_replace($this->key_name, $key_name, $key);
             }
             if ($key_changed) {
                 $key = str_replace(strtolower($this->key_name), strtolower($key_name), $key);
             }
             // if we aren't duplicating or the key has changed let's add it
             if (!$duplicate || $okey != $key) {
                 $appFile .= override_value_to_string_recursive2('app_list_strings', $key, $array);
             }
         }
         $fp = sugar_fopen($app_save_path . '/' . $lang, 'w');
         fwrite($fp, $appFile);
         fclose($fp);
     }
 }
Exemplo n.º 7
0
 function save($key_name, $duplicate = false, $rename = false)
 {
     $header = file_get_contents('modules/ModuleBuilder/MB/header.php');
     $save_path = $this->path . '/language';
     mkdir_recursive($save_path);
     foreach ($this->strings as $lang => $values) {
         //Check if the module Label or Singular Label has changed.
         $mod_strings = return_module_language(str_replace('.lang.php', '', $lang), 'ModuleBuilder');
         $required = array('LBL_LIST_FORM_TITLE' => $this->label . " " . $mod_strings['LBL_LIST'], 'LBL_MODULE_NAME' => $this->label, 'LBL_MODULE_TITLE' => $this->label, 'LBL_MODULE_NAME_SINGULAR' => $this->label_singular, 'LBL_HOMEPAGE_TITLE' => $mod_strings['LBL_HOMEPAGE_PREFIX'] . " " . $this->label, 'LNK_NEW_RECORD' => $mod_strings['LBL_CREATE'] . " " . $this->label_singular, 'LNK_LIST' => $mod_strings['LBL_VIEW'] . " " . $this->label, 'LNK_IMPORT_' . strtoupper($this->key_name) => translate('LBL_IMPORT') . " " . $this->label_singular, 'LBL_SEARCH_FORM_TITLE' => $mod_strings['LBL_SEARCH'] . " " . $this->label_singular, 'LBL_HISTORY_SUBPANEL_TITLE' => $mod_strings['LBL_HISTORY'], 'LBL_ACTIVITIES_SUBPANEL_TITLE' => $mod_strings['LBL_ACTIVITIES'], 'LBL_' . strtoupper($this->key_name) . '_SUBPANEL_TITLE' => $this->label, 'LBL_NEW_FORM_TITLE' => $mod_strings['LBL_NEW'] . " " . $this->label_singular, 'LNK_IMPORT_VCARD' => translate('LBL_IMPORT') . " " . $this->label_singular . ' vCard', 'LBL_IMPORT' => translate('LBL_IMPORT') . " " . $this->label, 'LBL_IMPORT_VCARDTEXT' => "Automatically create a new {$this->label_singular} record by importing a vCard from your file system.");
         foreach ($required as $k => $v) {
             $values[$k] = $v;
         }
         write_array_to_file('mod_strings', $values, $save_path . '/' . $lang, 'w', $header);
     }
     $app_save_path = $this->path . '/../../language/application';
     sugar_mkdir($app_save_path, null, true);
     $key_changed = $this->key_name != $key_name;
     foreach ($this->appListStrings as $lang => $values) {
         // Load previously created modules data
         $app_list_strings = array();
         $neededFile = $app_save_path . '/' . $lang;
         if (file_exists($neededFile)) {
             include $neededFile;
         }
         if (!$duplicate) {
             unset($values['moduleList'][$this->key_name]);
         }
         $values = sugarLangArrayMerge($values, $app_list_strings);
         $values['moduleList'][$key_name] = $this->label;
         $values['moduleListSingular'][$key_name] = $this->label_singular;
         $appFile = $header . "\n";
         require_once 'include/utils/array_utils.php';
         $this->getGlobalAppListStringsForMB($values);
         foreach ($values as $key => $array) {
             if ($duplicate) {
                 //keep the original when duplicating
                 $appFile .= override_value_to_string_recursive2('app_list_strings', $key, $array);
             }
             $okey = $key;
             if ($key_changed) {
                 $key = str_replace(strtolower($this->key_name), strtolower($key_name), $key);
             }
             // if we aren't duplicating or the key has changed let's add it
             if (!$duplicate || $okey != $key) {
                 if ($rename && isset($this->appListStrings[$lang][$key])) {
                     $arr = $this->appListStrings[$lang][$key];
                 } else {
                     $arr = $array;
                 }
                 $appFile .= override_value_to_string_recursive2('app_list_strings', $key, $arr);
             }
         }
         sugar_file_put_contents_atomic($app_save_path . '/' . $lang, $appFile);
     }
 }
Exemplo n.º 8
0
 /**
  * getConnectorStrings
  * This method returns the language Strings for a given connector instance
  *
  * @param String $source_id String value of the connector id to retrive language strings for
  * @param String $language optional String value for the language to use (defaults to $GLOBALS['current_language'])
  */
 public static function getConnectorStrings($source_id, $language = '')
 {
     global $locale;
     $dir = str_replace('_', '/', $source_id);
     $strings = array();
     $defaultLanguage = $GLOBALS['sugar_config']['default_language'] . '.lang.php';
     $files = array("modules/Connectors/connectors/sources/{$dir}/language/{$defaultLanguage}");
     if ($language != $defaultLanguage) {
         $currentLanguage = (empty($language) ? $locale->getAuthenticatedUserLanguage() : $language) . '.lang.php';
         $files[] = "modules/Connectors/connectors/sources/{$dir}/language/{$currentLanguage}";
     }
     foreach (SugarAutoLoader::existingCustom($files) as $file) {
         require $file;
         if (isset($connector_strings) && is_array($connector_strings)) {
             $strings = sugarLangArrayMerge($strings, $connector_strings);
         }
     }
     if (empty($strings)) {
         $GLOBALS['log']->error("Unable to locate language strings for source {$source_id}");
     }
     return $strings;
 }
Exemplo n.º 9
0
 /**
  * Given a module, search all of the specified locations, and any others as specified
  * in order to refresh the cache file
  *
  * @param string $module the given module we want to load the vardefs for
  * @param string $lang the given language we wish to load
  * @param array $additional_search_paths an array which allows a consumer to pass in additional vardef locations to search
  */
 public static function refreshLanguage($module, $lang, $loaded_mod_strings = array(), $additional_search_paths = null)
 {
     // Some of the vardefs do not correctly define dictionary as global.  Declare it first.
     $lang_paths = self::getModuleLanguageFilePaths($module, $lang);
     $object = BeanFactory::getObjectName($module);
     if ($object && !empty($GLOBALS['dictionary'][$object]['templates'])) {
         $templates = $GLOBALS['dictionary'][$object]['templates'];
         $loaded_mod_strings = LanguageManager::loadTemplateLanguage($module, $templates, $lang, $loaded_mod_strings);
     }
     // Add in additional search paths if they were provided.
     if (!empty($additional_search_paths) && is_array($additional_search_paths)) {
         $lang_paths = array_merge($lang_paths, $additional_search_paths);
     }
     //search a predefined set of locations for the vardef files
     foreach (SugarAutoLoader::existing($lang_paths) as $path) {
         require $path;
         if (!empty($mod_strings)) {
             if (function_exists('sugarArrayMergeRecursive')) {
                 $loaded_mod_strings = sugarArrayMergeRecursive($loaded_mod_strings, $mod_strings);
             } else {
                 $loaded_mod_strings = sugarLangArrayMerge($loaded_mod_strings, $mod_strings);
             }
         }
     }
     //great! now that we have loaded all of our vardefs.
     //let's go save them to the cache file.
     if (!empty($loaded_mod_strings)) {
         LanguageManager::saveCache($module, $lang, $loaded_mod_strings);
     }
 }