Exemplo n.º 1
0
 /**
  * Remove directory for sub-language
  * @param String The sub-language path directory ( e.g. 'spanish_corporate'' )
  * @return boolean  True on success, false on failure
  */
 public static function remove_language_directory($sub_language_dir)
 {
     if (empty($sub_language_dir)) {
         return false;
     }
     $dir = api_get_path(SYS_LANG_PATH) . $sub_language_dir;
     if (!is_dir($dir)) {
         return true;
     }
     //even if the dir does not exist, we reach the objective of not having the directory there
     $content = SubLanguageManager::get_lang_folder_files_list($dir);
     if (count($content) > 0) {
         foreach ($content as $value_content) {
             $path_file = $dir . '/' . $value_content;
             unlink($path_file);
         }
         return @rmdir($dir);
     } else {
         return @rmdir($dir);
     }
 }
Exemplo n.º 2
0
/**
 * Cron script to list unused, but defined, language variables
 * @package chamilo.cron.lang
 */
/**
 * Includes and declarations
 */
//die();
require_once '../../inc/global.inc.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);
$langs = scandir(api_get_path(SYS_LANG_PATH));
foreach ($langs as $lang) {
    $dir = api_get_path(SYS_LANG_PATH) . $lang;
    if (is_dir($dir) && substr($lang, 0, 1) != '.' && !empty($lang)) {
        echo "{$lang}...";
        $ok = true;
        foreach ($list as $entry) {
            $file = $dir . '/' . $entry;
            $out = array();
            if (is_file($file)) {
                //$terms = array_merge($terms,SubLanguageManager::get_all_language_variable_in_file($file,true));
                @exec('php5 -l ' . $file, $out);
                if (substr($out[0], 0, 2) != 'No') {
                    echo $out[0] . "\n";
                    $ok = false;
Exemplo n.º 3
0
}
if (!empty($_POST['language_list'])) {
    $user_language = str_replace('index.php?language=', '', $_POST['language_list']);
}
if (empty($user_language) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !isset($_SESSION['_user'])) {
    $l = SubLanguageManager::getLanguageFromBrowserPreference($_SERVER['HTTP_ACCEPT_LANGUAGE']);
    if (!empty($l)) {
        $user_language = $browser_language = $l;
    }
}
// Include all files (first english and then current interface language)
$langpath = api_get_path(SYS_LANG_PATH);
/* This will only work if we are in the page to edit a sub_language */
if (isset($this_script) && $this_script == 'sub_language') {
    // getting the arrays of files i.e notification, trad4all, etc
    $language_files_to_load = SubLanguageManager::get_lang_folder_files_list(api_get_path(SYS_LANG_PATH) . 'english', true);
    //getting parent info
    $parent_language = SubLanguageManager::get_all_information_of_language($_REQUEST['id']);
    //getting sub language info
    $sub_language = SubLanguageManager::get_all_information_of_language($_REQUEST['sub_language_id']);
    $english_language_array = $parent_language_array = $sub_language_array = array();
    foreach ($language_files_to_load as $language_file_item) {
        $lang_list_pre = array_keys($GLOBALS);
        //loading english
        $path = $langpath . 'english/' . $language_file_item . '.inc.php';
        if (file_exists($path)) {
            include $path;
        }
        $lang_list_post = array_keys($GLOBALS);
        $lang_list_result = array_diff($lang_list_post, $lang_list_pre);
        unset($lang_list_pre);