Пример #1
0
 public function run()
 {
     if (empty($this->upgrader->config['js_lang_version'])) {
         $this->upgrader->config['js_lang_version'] = 1;
     } else {
         $this->upgrader->config['js_lang_version'] += 1;
     }
     //remove lanugage cache files
     require_once 'include/SugarObjects/LanguageManager.php';
     LanguageManager::clearLanguageCache();
 }
Пример #2
0
 function removeCustomLabels()
 {
     $out = "";
     $languageDir = "custom/modules/{$this->module}/language";
     if (is_dir($languageDir)) {
         $files = scandir($languageDir);
         foreach ($files as $langFile) {
             if (substr($langFile, 0, 1) == '.') {
                 continue;
             }
             $language = substr($langFile, 0, strlen($langFile) - 9);
             unlink($languageDir . "/" . $langFile);
             LanguageManager::clearLanguageCache($this->module, $language);
             $out .= "Removed language file {$langFile}<br/>";
         }
     }
     return $out;
 }
 /**
  * Remove the language cache files from cache/modules/<module>/language
  */
 public function clearLanguageCache()
 {
     global $mod_strings;
     if ($this->show_output) {
         echo "<h3>{$mod_strings['LBL_QR_CLEARLANG']}</h3>";
     }
     //clear cache using the list $module_list_from_cache
     if (!empty($this->module_list) && is_array($this->module_list)) {
         if (in_array(translate('LBL_ALL_MODULES'), $this->module_list)) {
             LanguageManager::clearLanguageCache();
         } else {
             //use the modules selected thrut the select list.
             foreach ($this->module_list as $module_name) {
                 LanguageManager::clearLanguageCache($module_name);
             }
         }
     }
     // Clear app* cache values too
     if (!empty($GLOBALS['sugar_config']['languages'])) {
         $languages = $GLOBALS['sugar_config']['languages'];
     } else {
         $languages = array($GLOBALS['current_language'] => $GLOBALS['current_language']);
     }
     foreach (array_keys($languages) as $language) {
         sugar_cache_clear('app_strings.' . $language);
         sugar_cache_clear('app_list_strings.' . $language);
     }
 }
Пример #4
0
 private function deleteRelationship($lhs_module, $rhs_module = null, $rel_name = null)
 {
     $rhs_module = $rhs_module == null ? $lhs_module : $rhs_module;
     $this->relationships = new DeployedRelationships($lhs_module);
     $this->relationships->delete($rel_name !== null ? $rel_name : $this->relationship->getName());
     $this->relationships->save();
     SugarRelationshipFactory::deleteCache();
     LanguageManager::clearLanguageCache($lhs_module);
     if ($lhs_module != $rhs_module) {
         LanguageManager::clearLanguageCache($rhs_module);
     }
 }
Пример #5
0
 /**
  * Clear all related language cache files.
  *
  * @return void
  */
 private function clearLanguageCaches()
 {
     //remove the js language files
     LanguageManager::removeJSLanguageFiles();
     //remove lanugage cache files
     LanguageManager::clearLanguageCache();
 }
Пример #6
0
 /**
  * Doing the same things like setUp but for initialized list of modules
  *
  * @static
  * @return bool are caches refreshed or not
  */
 protected static function tearDown_relation()
 {
     SugarRelationshipFactory::deleteCache();
     $modules = array_unique(self::$cleanModules);
     foreach ($modules as $module) {
         LanguageManager::clearLanguageCache($module);
     }
     self::tearDown('dictionary');
     VardefManager::$linkFields = array();
     VardefManager::clearVardef();
     foreach ($modules as $module) {
         VardefManager::refreshVardefs($module, BeanFactory::getBeanName($module));
     }
     SugarRelationshipFactory::rebuildCache();
     self::$cleanModules = array();
     return true;
 }
 static function addLabels($language, $labels, $moduleName, $basepath = null)
 {
     $GLOBALS['log']->debug("ParserLabel->addLabels({$language}, \$labels, {$moduleName}, {$basepath} );");
     $GLOBALS['log']->debug("\$labels:" . print_r($labels, true));
     $deployedModule = false;
     if (is_null($basepath)) {
         $deployedModule = true;
         $basepath = "custom/modules/{$moduleName}/language";
         if (!is_dir($basepath)) {
             require_once 'modules/Administration/Common.php';
             create_module_lang_dir($moduleName);
         }
     }
     $filename = "{$basepath}/{$language}.lang.php";
     $dir_exists = is_dir($basepath);
     $mod_strings = array();
     if ($dir_exists) {
         if (file_exists($filename)) {
             // obtain $mod_strings
             include $filename;
         }
     } else {
         return false;
     }
     $changed = false;
     //$charset = (isset($app_strings['LBL_CHARSET'])) ? $app_strings['LBL_CHARSET'] : $GLOBALS['sugar_config']['default_charset'] ;
     foreach ($labels as $key => $value) {
         if (!isset($mod_strings[$key]) || strcmp($value, $mod_strings[$key]) != 0) {
             $mod_strings[$key] = html_entity_decode_utf8($value, ENT_QUOTES);
             // must match encoding used in view.labels.php
             $changed = true;
         }
     }
     if ($changed) {
         $GLOBALS['log']->debug("ParserLabel->addLabels: writing new mod_strings to {$filename}");
         $GLOBALS['log']->debug("ParserLabel->addLabels: mod_strings=" . print_r($mod_strings, true));
         if (!write_array_to_file("mod_strings", $mod_strings, $filename)) {
             $GLOBALS['log']->fatal("Could not write {$filename}");
         } else {
             // if we have a cache to worry about, then clear it now
             if ($deployedModule) {
                 $GLOBALS['log']->debug("PaserLabel->addLabels: clearing language cache");
                 $cache_key = "module_language." . $language . $moduleName;
                 sugar_cache_clear($cache_key);
                 LanguageManager::clearLanguageCache($moduleName, $language);
             }
         }
     }
     return true;
 }
Пример #8
0
foreach ($_SESSION['sugarMergeRunResults'] as $mergeModule => $mergeModuleFileList) {
    if (!empty($mergeModuleFileList)) {
        $skipLayouts = false;
    }
}
$stepNext = $skipLayouts ? $_REQUEST['step'] + 2 : $_REQUEST['step'] + 1;
$stepCancel = -1;
$stepRecheck = $_REQUEST['step'];
$_SESSION['step'][$steps['files'][$_REQUEST['step']]] = $stop ? 'failed' : 'success';
// clear out the theme cache
if (!class_exists('SugarThemeRegistry')) {
    require_once 'include/SugarTheme/SugarTheme.php';
}
$themeObject = SugarThemeRegistry::current();
$styleJSFilePath = $GLOBALS['sugar_config']['cache_dir'] . $themeObject->getJSPath() . DIRECTORY_SEPARATOR . 'style-min.js';
if (file_exists($styleJSFilePath)) {
    logThis("Rebuilding style js file: {$styleJSFilePath}");
    unlink($styleJSFilePath);
    SugarThemeRegistry::current()->clearJSCache();
    SugarThemeRegistry::current()->getJS();
}
SugarThemeRegistry::buildRegistry();
SugarThemeRegistry::clearAllCaches();
//Clean out the language files
logThis("Rebuilding language cache");
sugar_cache_reset_full();
LanguageManager::clearLanguageCache();
// re-minify the JS source files
$_REQUEST['root_directory'] = getcwd();
$_REQUEST['js_rebuild_concat'] = 'rebuild';
require_once 'jssource/minify.php';
Пример #9
0
 public function action_SaveRelationship()
 {
     if (!empty($GLOBALS['current_user']) && empty($GLOBALS['modListHeader'])) {
         $GLOBALS['modListHeader'] = query_module_access_list($GLOBALS['current_user']);
     }
     if (empty($_REQUEST['view_package'])) {
         $relationships = new DeployedRelationships($_REQUEST['view_module']);
     } else {
         $mb = new ModuleBuilder();
         $module =& $mb->getPackageModule($_REQUEST['view_package'], $_REQUEST['view_module']);
         $relationships = new UndeployedRelationships($module->getModuleDir());
     }
     $relationships->addFromPost();
     // Since the build() call below will call save() again, save the rebuild
     // of relationship metadata for now
     $relationships->save(false);
     $GLOBALS['log']->debug("\n\nSTART BUILD");
     if (empty($_REQUEST['view_package'])) {
         $relationships->build();
         LanguageManager::clearLanguageCache($_REQUEST['view_module']);
     }
     $GLOBALS['log']->debug("\n\nEND BUILD");
     $this->view = 'relationships';
 }
Пример #10
0
 static function addLabels($currLanguage, $labels, $moduleName, $basepath = null)
 {
     $GLOBALS['log']->debug("ParserLabel->addLabels({$currLanguage}, \$labels, {$moduleName}, {$basepath} );");
     $GLOBALS['log']->debug("\$labels:" . print_r($labels, true));
     $languages = get_languages();
     foreach ($languages as $language => $langlabel) {
         $currentLabels = self::getCustomLabels($language, $moduleName, $basepath);
         if ($currentLabels === false) {
             return false;
         }
         //Unable to create a custom folder.
         $mod_strings = $currentLabels['labels'];
         $changed = false;
         foreach ($labels as $key => $value) {
             if (!isset($mod_strings[$key]) || strcmp($value, $mod_strings[$key]) != 0 && $language == $currLanguage) {
                 $mod_strings[$key] = html_entity_decode_utf8($value, ENT_QUOTES);
                 // must match encoding used in view.labels.php
                 $changed = true;
             }
         }
         if ($changed) {
             $GLOBALS['log']->debug("ParserLabel->addLabels: writing new mod_strings to {$currentLabels['file']}");
             $GLOBALS['log']->debug("ParserLabel->addLabels: mod_strings=" . print_r($mod_strings, true));
             if (!write_array_to_file("mod_strings", $mod_strings, $currentLabels["file"])) {
                 $GLOBALS['log']->fatal("Could not write {$currentLabels['file']}");
             } else {
                 // if we have a cache to worry about, then clear it now
                 if ($currentLabels['deployed']) {
                     $GLOBALS['log']->debug("PaserLabel->addLabels: clearing language cache");
                     $cache_key = "module_language." . $language . $moduleName;
                     sugar_cache_clear($cache_key);
                     LanguageManager::clearLanguageCache($moduleName, $language);
                 }
             }
         }
     }
     return true;
 }
Пример #11
0
 /**
  * Add a set of labels to the language pack for a module, deployed or undeployed
  * 
  * @param string $language Language key, for example 'en_us'
  * @param array $labels The labels to add in the form of an array of System label => Display label pairs
  * @param string $moduleName Name of the module to which to add these labels
  * @param string $basepath Basepath to the file to be written to
  */
 public static function addLabels($language, $labels, $moduleName, $basepath = null)
 {
     $GLOBALS['log']->debug("ParserLabel->addLabels({$language}, \$labels, {$moduleName}, {$basepath});");
     $GLOBALS['log']->debug("\$labels:" . print_r($labels, true));
     $deployedModule = false;
     if (is_null($basepath)) {
         $deployedModule = true;
         $basepath = "custom/Extension/modules/{$moduleName}/Ext/Language";
         if (!SugarAutoLoader::fileExists($basepath)) {
             mkdir_recursive($basepath);
         }
     }
     $filename = "{$basepath}/{$language}.lang.php";
     $mod_strings = array();
     $changed = false;
     if (SugarAutoLoader::fileExists($basepath)) {
         if (SugarAutoLoader::fileExists($filename)) {
             // Get the current $mod_strings
             include $filename;
         }
         foreach ($labels as $key => $value) {
             if (!isset($mod_strings[$key]) || strcmp($value, $mod_strings[$key]) != 0) {
                 // Must match encoding used in view.labels.php
                 $mod_strings[$key] = to_html(strip_tags(from_html($value)));
                 $changed = true;
             }
         }
     } else {
         $changed = true;
     }
     if (!empty($mod_strings) && $changed) {
         $GLOBALS['log']->debug("ParserLabel->addLabels: writing new mod_strings to {$filename}");
         $GLOBALS['log']->debug("ParserLabel->addLabels: mod_strings=" . print_r($mod_strings, true));
         $write = "<?php\n// WARNING: The contents of this file are auto-generated.\n";
         // We can't use normal array writing here since multiple files can be
         // structured differently. This is dirty, yes, but necessary.
         foreach ($mod_strings as $k => $v) {
             $write .= "\$mod_strings['{$k}'] = " . var_export($v, 1) . ";\n";
         }
         if (!SugarAutoLoader::put($filename, $write, true)) {
             $GLOBALS['log']->fatal("Could not write {$filename}");
         } else {
             // if we have a cache to worry about, then clear it now
             if ($deployedModule) {
                 SugarCache::cleanOpcodes();
                 $GLOBALS['log']->debug("PaserLabel->addLabels: clearing language cache");
                 self::rebuildLanguageExtensions($language, $moduleName);
                 $cache_key = "module_language." . $language . $moduleName;
                 sugar_cache_clear($cache_key);
                 LanguageManager::clearLanguageCache($moduleName, $language);
                 MetaDataManager::refreshLanguagesCache($language);
             }
         }
     }
     return true;
 }
Пример #12
0
    static function addLabels ($language , $labels , $moduleName , $basepath = null, $forRelationshipLabel = false)
    {

        $GLOBALS [ 'log' ]->debug ( "ParserLabel->addLabels($language, \$labels, $moduleName, $basepath );" ) ;
        $GLOBALS [ 'log' ]->debug ( "\$labels:" . print_r ( $labels, true ) ) ;

        $deployedModule = false ;
        if (is_null ( $basepath ))
        {
            $deployedModule = true ;
            $basepath = "custom/modules/$moduleName/language" ;
            if($forRelationshipLabel){
            	$basepath = "custom/modules/$moduleName/Ext/Language" ;
            }
            if (! is_dir ( $basepath ))
            {
                mkdir_recursive($basepath);
            }
        }

        $filename = "$basepath/$language.lang.php" ;
        if($forRelationshipLabel){
        	$filename = "$basepath/$language.lang.ext.php" ;
     	}
        $dir_exists = is_dir ( $basepath ) ;

        $mod_strings = array ( ) ;

        if ($dir_exists)
        {
            if (file_exists ( $filename ))
            {
                // obtain $mod_strings
                include ($filename) ;
            }else if($forRelationshipLabel){
            	$fh = fopen ($filename, 'a');
            	fclose($fh);
            }
        } else
        {
            return false ;
        }

        	$changed = false ;

        //$charset = (isset($app_strings['LBL_CHARSET'])) ? $app_strings['LBL_CHARSET'] : $GLOBALS['sugar_config']['default_charset'] ;

	        foreach ( $labels as $key => $value )
	        {
            if (! isset ( $mod_strings [ $key ] ) || strcmp ( $value, $mod_strings [ $key ] ) != 0)
	            {
                    $mod_strings [$key] = to_html(strip_tags(from_html($value))); // must match encoding used in view.labels.php
	                $changed = true ;
	            }
	        }

	        if ($changed)
	        {
            $GLOBALS [ 'log' ]->debug ( "ParserLabel->addLabels: writing new mod_strings to $filename" ) ;
	            $GLOBALS [ 'log' ]->debug ( "ParserLabel->addLabels: mod_strings=".print_r($mod_strings,true) ) ;
            if (! write_array_to_file ( "mod_strings", $mod_strings, $filename ))
	            {
                $GLOBALS [ 'log' ]->fatal ( "Could not write $filename" ) ;
	            } else
	            {
	                // if we have a cache to worry about, then clear it now
                if ($deployedModule)
	                {
                            SugarCache::cleanOpcodes();
	                    $GLOBALS [ 'log' ]->debug ( "PaserLabel->addLabels: clearing language cache" ) ;
	                    $cache_key = "module_language." . $language . $moduleName ;
	                    sugar_cache_clear ( $cache_key ) ;
	                    LanguageManager::clearLanguageCache ( $moduleName, $language ) ;
	                }
	            }
	        }

        // Fix for bug #51
        // when the label is recreated it defaults back to the original value (In this case its "User").

        // Solution:
        // 1. Changes to the label names should go to custom/Extension/modules/{ModuleName}/Ext/Language
        // This is done in case different users edit the same Relationship concurrently.
        // The changes from custom/Extension/modules/{ModuleName}/Ext/Language
        // will overwrite stuff in custom/modules/{ModuleName}/Ext/Language/en_us.lang.ext.php after
        //  Quick Repair and Rebuild is applied.
        if($forRelationshipLabel) {
            if(!empty($_POST[view_module]) && !empty($_POST[relationship_name]) && !empty($_POST[rhs_label]) && !empty($_POST[lhs_module])) {
                // 1. Overwrite custom/Extension/modules/{ModuleName}/Ext/Language
                $extension_basepath = "custom/Extension/modules/" . $_POST[view_module] . "/Ext/Language";
                mkdir_recursive($extension_basepath);

                $headerString = "<?php\n//THIS FILE IS AUTO GENERATED, DO NOT MODIFY\n";
                $out = $headerString;

                $extension_filename = "$extension_basepath/$language.custom" . $_POST[relationship_name] . ".php";

                $mod_strings = array();
                if (file_exists($extension_filename)) {
                    // obtain $mod_strings
                    include($extension_filename);
                }

                $changed_mod_strings = false;
                foreach ($labels as $key => $value) {
                    foreach ($mod_strings as $key_mod_string => $value_mod_string) {
                        if (strpos($key_mod_string, strtoupper($_POST[relationship_name])) !== false) {
                            $mod_strings[$key_mod_string] = to_html(strip_tags(from_html($_POST[rhs_label]))); // must match encoding used in view.labels.php
                            $changed_mod_strings = true;
                        }
                    }
                }

                foreach ($mod_strings as $key => $val)
                    $out .= override_value_to_string_recursive2('mod_strings', $key, $val);

                $failed_to_write = false;
                try {
                    $file_contents = fopen($extension_filename, 'w');
                    fputs($file_contents, $out, strlen($out));
                    fclose($file_contents);
                } catch (Exception $e) {
                    $GLOBALS ['log']->fatal("Could not write $filename");
                    $GLOBALS ['log']->fatal("Exception " . $e->getMessage());
                    $failed_to_write = true;
                }

                //2. Overwrite custom/Extension/modules/relationships/language/{ModuleName}.php
                // Also need to overwrite custom/Extension/modules/relationships/language/{ModuleName}.php
                // because whenever new relationship is created this place is checked by the system to get
                // all the label names
                $relationships_basepath = "custom/Extension/modules/relationships/language";
                mkdir_recursive($relationships_basepath);

                $headerString = "<?php\n//THIS FILE IS AUTO GENERATED, DO NOT MODIFY\n";
                $out = $headerString;

                $relationships_filename = "$relationships_basepath/" . $_POST[lhs_module] . ".php";


                $mod_strings = array();
                if (file_exists($relationships_filename)) {
                    // obtain $mod_strings
                    include($relationships_filename);
                }

                $changed_mod_strings = false;
                foreach ($labels as $key => $value) {
                    foreach ($mod_strings as $key_mod_string => $value_mod_string) {
                        if (strpos($key_mod_string, strtoupper($_POST[relationship_name])) !== false) {
                            $mod_strings[$key_mod_string] = to_html(strip_tags(from_html($_POST[rhs_label]))); // must match encoding used in view.labels.php
                            $changed_mod_strings = true;
                        }
                    }
                }

                foreach ($mod_strings as $key => $val)
                    $out .= override_value_to_string_recursive2('mod_strings', $key, $val);

                $failed_to_write = false;
                try {
                    $file_contents = fopen($relationships_filename, 'w');
                    fputs($file_contents, $out, strlen($out));
                    fclose($file_contents);
                } catch (Exception $e) {
                    $GLOBALS ['log']->fatal("Could not write $filename");
                    $GLOBALS ['log']->fatal("Exception " . $e->getMessage());
                    $failed_to_write = true;
                }

                if ($changed_mod_strings) {
                    if (!$failed_to_write) {
                        // if we have a cache to worry about, then clear it now
                        if ($deployedModule) {
                            SugarCache::cleanOpcodes();
                            $GLOBALS ['log']->debug("PaserLabel->addLabels: clearing language cache");
                            $cache_key = "module_language." . $language . $moduleName;
                            sugar_cache_clear($cache_key);
                            LanguageManager::clearLanguageCache($moduleName, $language);
                        }
                    }
                }
            }
        }

        return true ;
    }
function rebuild_js_lang()
{
    require_once 'include/utils/file_utils.php';
    global $sugar_config;
    $jsFiles = array();
    getFiles($jsFiles, $sugar_config['cache_dir'] . 'jsLanguage');
    foreach ($jsFiles as $file) {
        unlink($file);
    }
    if (empty($sugar_config['js_lang_version'])) {
        $sugar_config['js_lang_version'] = 1;
    } else {
        $sugar_config['js_lang_version'] += 1;
    }
    write_array_to_file("sugar_config", $sugar_config, "config.php");
    //remove lanugage cache files
    require_once 'include/SugarObjects/LanguageManager.php';
    LanguageManager::clearLanguageCache();
}
Пример #14
0
 function action_SaveRelationship()
 {
     if (!empty($GLOBALS['current_user']) && empty($GLOBALS['modListHeader'])) {
         $GLOBALS['modListHeader'] = query_module_access_list($GLOBALS['current_user']);
     }
     if (empty($_REQUEST['view_package'])) {
         require_once 'modules/ModuleBuilder/parsers/relationships/DeployedRelationships.php';
         $relationships = new DeployedRelationships($_REQUEST['view_module']);
     } else {
         $mb = new ModuleBuilder();
         $module =& $mb->getPackageModule($_REQUEST['view_package'], $_REQUEST['view_module']);
         require_once 'modules/ModuleBuilder/parsers/relationships/UndeployedRelationships.php';
         $relationships = new UndeployedRelationships($module->getModuleDir());
     }
     $relationships->addFromPost();
     $relationships->save();
     $GLOBALS['log']->debug("\n\nSTART BUILD");
     if (empty($_REQUEST['view_package'])) {
         $relationships->build();
         LanguageManager::clearLanguageCache($_REQUEST['view_module']);
     }
     $GLOBALS['log']->debug("\n\nEND BUILD");
     $this->view = 'relationships';
 }
Пример #15
0
 /**
  * Remove the language cache files from cache/modules/<module>/language
  */
 public function clearLanguageCache()
 {
     global $mod_strings;
     if ($this->show_output) {
         echo "<h3>{$mod_strings['LBL_QR_CLEARLANG']}</h3>";
     }
     //clear cache using the list $module_list_from_cache
     if (!empty($this->module_list) && is_array($this->module_list)) {
         if (in_array(translate('LBL_ALL_MODULES'), $this->module_list)) {
             LanguageManager::clearLanguageCache();
         } else {
             //use the modules selected thrut the select list.
             foreach ($this->module_list as $module_name) {
                 LanguageManager::clearLanguageCache($module_name);
             }
         }
     }
 }
Пример #16
0
 function rebuild_languages($languages = array(), $modules = "")
 {
     foreach ($languages as $language => $value) {
         $this->log(translate('LBL_MI_REBUILDING') . " Language...{$language}");
         $this->merge_files('Ext/Language/', $language . '.lang.ext.php', $language);
         if ($modules != "") {
             foreach ($modules as $module) {
                 LanguageManager::clearLanguageCache($module, $language);
             }
         }
     }
     sugar_cache_reset();
 }
Пример #17
0
 function rebuild_languages($languages = array(), $modules = array())
 {
     global $current_language, $app_list_strings, $app_strings;
     foreach ($languages as $language => $value) {
         $this->log(translate('LBL_MI_REBUILDING') . " Language...{$language}");
         $this->merge_files('Ext/Language/', $language . '.lang.ext.php', $language, false, $modules);
         if (is_array($modules) && !empty($modules)) {
             foreach ($modules as $module) {
                 LanguageManager::clearLanguageCache($module, $language);
             }
         } else {
             LanguageManager::clearLanguageCache(null, $language);
         }
     }
     sugar_cache_reset();
     // since both were cleared out, we need to set the app_strings
     $app_strings = return_application_language($current_language);
     // put actual metadata into global variable as well
     $app_list_strings = return_app_list_strings_language($current_language);
 }
Пример #18
0
 static function addLabels($language, $labels, $moduleName, $basepath = null, $forRelationshipLabel = false)
 {
     $GLOBALS['log']->debug("ParserLabel->addLabels({$language}, \$labels, {$moduleName}, {$basepath} );");
     $GLOBALS['log']->debug("\$labels:" . print_r($labels, true));
     $deployedModule = false;
     if (is_null($basepath)) {
         $deployedModule = true;
         $basepath = "custom/modules/{$moduleName}/language";
         if ($forRelationshipLabel) {
             $basepath = "custom/modules/{$moduleName}/Ext/Language";
         }
         if (!is_dir($basepath)) {
             mkdir_recursive($basepath);
         }
     }
     $filename = "{$basepath}/{$language}.lang.php";
     if ($forRelationshipLabel) {
         $filename = "{$basepath}/{$language}.lang.ext.php";
     }
     $dir_exists = is_dir($basepath);
     $mod_strings = array();
     if ($dir_exists) {
         if (file_exists($filename)) {
             // obtain $mod_strings
             include $filename;
         } else {
             if ($forRelationshipLabel) {
                 $fh = fopen($filename, 'a');
                 fclose($fh);
             }
         }
     } else {
         return false;
     }
     $changed = false;
     //$charset = (isset($app_strings['LBL_CHARSET'])) ? $app_strings['LBL_CHARSET'] : $GLOBALS['sugar_config']['default_charset'] ;
     foreach ($labels as $key => $value) {
         if (!isset($mod_strings[$key]) || strcmp($value, $mod_strings[$key]) != 0) {
             $mod_strings[$key] = to_html(strip_tags(from_html($value)));
             // must match encoding used in view.labels.php
             $changed = true;
         }
     }
     if ($changed) {
         $GLOBALS['log']->debug("ParserLabel->addLabels: writing new mod_strings to {$filename}");
         $GLOBALS['log']->debug("ParserLabel->addLabels: mod_strings=" . print_r($mod_strings, true));
         if (!write_array_to_file("mod_strings", $mod_strings, $filename)) {
             $GLOBALS['log']->fatal("Could not write {$filename}");
         } else {
             // if we have a cache to worry about, then clear it now
             if ($deployedModule) {
                 SugarCache::cleanOpcodes();
                 $GLOBALS['log']->debug("PaserLabel->addLabels: clearing language cache");
                 $cache_key = "module_language." . $language . $moduleName;
                 sugar_cache_clear($cache_key);
                 LanguageManager::clearLanguageCache($moduleName, $language);
             }
         }
     }
     return true;
 }
 /**
  * Remove all created relationships
  *
  * @static
  */
 public static function removeAllCreatedRelationships()
 {
     foreach (self::$_relsAdded as $rel) {
         $relationships = new DeployedRelationships($rel['lhs_module']);
         $relationships->delete($rel['relationship_name']);
         $relationships->save();
         $relationships->build();
         LanguageManager::clearLanguageCache($rel['lhs_module']);
         require_once "data/Relationships/RelationshipFactory.php";
         SugarRelationshipFactory::deleteCache();
         SugarRelationshipFactory::rebuildCache();
     }
     // since we are creating a relationship we need to unset this global var
     if (isset($GLOBALS['reload_vardefs'])) {
         unset($GLOBALS['reload_vardefs']);
     }
 }