コード例 #1
0
////require_once '../inc/global.inc.php';
require_once 'sub_language.class.php';
api_protect_admin_script();
$new_language = Security::remove_XSS($_REQUEST['new_language']);
$language_variable = Security::remove_XSS($_REQUEST['variable_language']);
$file_id = intval($_REQUEST['file_id']);
/**
 * Code
 */
if (isset($new_language) && isset($language_variable) && isset($file_id)) {
    $file_language = $language_files_to_load[$file_id] . '.inc.php';
    $id_language = intval($_REQUEST['id']);
    $sub_language_id = intval($_REQUEST['sub']);
    $all_data_of_language = SubLanguageManager::get_all_information_of_sub_language($id_language, $sub_language_id);
    $path_folder = api_get_path(SYS_LANG_PATH) . $all_data_of_language['dokeos_folder'] . '/' . $file_language;
    $all_file_of_directory = SubLanguageManager::get_all_language_variable_in_file($path_folder);
    $return_value = SubLanguageManager::add_file_in_language_directory($path_folder);
    //update variable language
    $new_language = str_replace('"', '\\"', $new_language);
    $all_file_of_directory[$language_variable] = "\"" . api_convert_encoding($new_language, api_get_system_encoding(), 'UTF-8') . "\";";
    $result_array = array();
    foreach ($all_file_of_directory as $key_value => $value_info) {
        $result_array[$key_value] = SubLanguageManager::write_data_in_file($path_folder, $value_info, $key_value);
    }
    $variables_with_problems = '';
    if (!empty($result_array)) {
        foreach ($result_array as $key => $result) {
            if ($result == false) {
                $variables_with_problems .= $key . ' <br />';
            }
        }
コード例 #2
0
 * Includes and declarations
 */
die;
require_once '../../inc/global.inc.php';
require_once api_get_path(SYS_CODE_PATH) . 'admin/sub_language.class.php';
$path = api_get_path(SYS_LANG_PATH) . 'english';
ini_set('memory_limit', '128M');
/**
 * Main code
 */
$terms = array();
$list = SubLanguageManager::get_lang_folder_files_list($path);
foreach ($list as $entry) {
    $file = $path . '/' . $entry;
    if (is_file($file)) {
        $terms = array_merge($terms, SubLanguageManager::get_all_language_variable_in_file($file, true));
    }
}
// get only the array keys (the language variables defined in language files)
$defined_terms = array_flip(array_keys($terms));
$terms = null;
echo count($defined_terms) . " terms were found in language files<br />";
// now get all terms found in all PHP files of Chamilo (this takes some
// time and memory)
$used_terms = array();
$l = strlen(api_get_path(SYS_PATH));
$files = get_all_php_files(api_get_path(SYS_PATH));
// Browse files
foreach ($files as $file) {
    //echo 'Analyzing '.$file."<br />";
    $shortfile = substr($file, $l);
コード例 #3
0
 /**
  * Returns an array of all the language variables with their corresponding
  * file of origin. This function tolerates a certain rate of error due to
  * the duplication of variables in language files.
  * @return array variable => origin file
  */
 public function get_variables_origin()
 {
     require_once '../../admin/sub_language.class.php';
     $path = api_get_path(SYS_LANG_PATH) . 'english/';
     $vars = array();
     $priority = array('trad4all', 'notification', 'accessibility');
     foreach ($priority as $file) {
         $list = SubLanguageManager::get_all_language_variable_in_file($path . $file . '.inc.php', true);
         foreach ($list as $var => $trad) {
             $vars[$var] = $file . '.inc.php';
         }
     }
     $files = scandir($path);
     foreach ($files as $file) {
         if (substr($file, 0, 1) == '.' or in_array($file, $priority)) {
             continue;
         }
         $list = SubLanguageManager::get_all_language_variable_in_file($path . $file, true);
         foreach ($list as $var => $trad) {
             $vars[$var] = $file;
         }
     }
     return $vars;
 }