コード例 #1
0
ファイル: install.lib.php プロジェクト: KRCM13/chamilo-lms
/**
 * Displays a drop down box for selection the preferred language.
 */
function display_language_selection_box($name = 'language_list', $default_language = 'english')
{
    // Reading language list.
    $language_list = get_language_folder_list();
    /*
    // Reduction of the number of languages shown. Enable this fragment of code for customization purposes.
    // Modify the language list according to your preference. Don't exclude the 'english' item.
    $language_to_display = array('asturian', 'bulgarian', 'english', 'italian', 'french', 'slovenian', 'slovenian_unicode', 'spanish');
    foreach ($language_list as $key => & $value) {
        if (!in_array($key, $language_to_display)) {
            unset($language_list[$key]);
        }
    }
    */
    // Sanity checks due to the possibility for customizations.
    if (!is_array($language_list) || empty($language_list)) {
        $language_list = array('english' => 'English');
    }
    // Sorting again, if it is necessary.
    //asort($language_list);
    // More sanity checks.
    if (!array_key_exists($default_language, $language_list)) {
        if (array_key_exists('english', $language_list)) {
            $default_language = 'english';
        } else {
            $language_keys = array_keys($language_list);
            $default_language = $language_keys[0];
        }
    }
    // Displaying the box.
    $html = '';
    $html .= "\t\t<select class='form-control' name=\"{$name}\">\n";
    foreach ($language_list as $key => $value) {
        if ($key == $default_language) {
            $option_end = ' selected="selected">';
        } else {
            $option_end = '>';
        }
        $html .= "\t\t\t<option value=\"{$key}\"{$option_end}";
        $html .= $value;
        $html .= "</option>\n";
    }
    $html .= "\t\t</select>\n";
    return $html;
}
コード例 #2
0
/**
* Displays a select element (drop down menu) so the user can select
* the course language.
* @todo function does not belong here, move to (display?) library,
* @todo language display used apparently no longer existing array, converted to english for now.
* but we should switch to display the real language names.
*/
function display_language_select($element_name)
{
    global $platformLanguage;
    //get language list
    $dirname = api_get_path(SYS_PATH) . "main/lang/";
    $language_list = get_language_folder_list($dirname);
    sort($language_list);
    //build array with strings to display
    foreach ($language_list as $this_language) {
        $language_to_display[$this_language] = $this_language;
    }
    //sort alphabetically
    //warning: key,value association needs to be maintained --> asort instead of sort
    asort($language_to_display);
    $user_selected_language = $_SESSION["user_language_choice"];
    if (!isset($user_selected_language)) {
        $user_selected_language = $platformLanguage;
    }
    //display
    echo "<select name=\"{$element_name}\">";
    foreach ($language_to_display as $key => $value) {
        if ($key == $user_selected_language) {
            $option_end = "selected >";
        } else {
            $option_end = ">";
        }
        echo "<option value=\"{$key}\" {$option_end}";
        echo $value;
        echo "</option>\n";
    }
    echo "</select>";
}
コード例 #3
0
/**
 * Displays a drop down box for selection the preferred language.
 */
function display_language_selection_box($name = 'language_list', $default_language = 'english')
{
    // Reading language list.
    $language_list = get_language_folder_list();
    // Sanity checks due to the possibility for customizations.
    if (!is_array($language_list) || empty($language_list)) {
        $language_list = array('english' => 'English');
    }
    // Sorting again, if it is necessary.
    //asort($language_list);
    // More sanity checks.
    if (!array_key_exists($default_language, $language_list)) {
        if (array_key_exists('english', $language_list)) {
            $default_language = 'english';
        } else {
            $language_keys = array_keys($language_list);
            $default_language = $language_keys[0];
        }
    }
    // Displaying the box.
    echo "\t\t<select name=\"{$name}\">\n";
    foreach ($language_list as $key => $value) {
        if ($key == $default_language) {
            $option_end = ' selected="selected">';
        } else {
            $option_end = '>';
        }
        echo "\t\t\t<option value=\"{$key}\"{$option_end}";
        echo $value;
        echo "</option>\n";
    }
    echo "\t\t</select>\n";
}
コード例 #4
0
ファイル: index.php プロジェクト: secuencia24/chamilo-lms
// We need to provide some limited support for it through initialization of the
// global array-type variable $_setting.
$_setting = array('platform_charset' => 'UTF-8', 'server_type' => 'production', 'permissions_for_new_directories' => '0770', 'permissions_for_new_files' => '0660', 'stylesheets' => 'chamilo');
// Determination of the language during the installation procedure.
if (!empty($_POST['language_list'])) {
    $search = array('../', '\\0');
    $install_language = str_replace($search, '', urldecode($_POST['language_list']));
    Session::write('install_language', $install_language);
} elseif (isset($_SESSION['install_language']) && $_SESSION['install_language']) {
    $install_language = $_SESSION['install_language'];
} else {
    // Trying to switch to the browser's language, it is covenient for most of the cases.
    $install_language = detect_browser_language();
}
// Language validation.
if (!array_key_exists($install_language, get_language_folder_list())) {
    $install_language = 'english';
}
$installationGuideLink = '../../documentation/installation_guide.html';
// Loading language files.
require api_get_path(SYS_LANG_PATH) . 'english/trad4all.inc.php';
if ($install_language != 'english') {
    include_once api_get_path(SYS_LANG_PATH) . $install_language . '/trad4all.inc.php';
    switch ($install_language) {
        case 'french':
            $installationGuideLink = '../../documentation/installation_guide_fr_FR.html';
            break;
        case 'spanish':
            $installationGuideLink = '../../documentation/installation_guide_es_ES.html';
            break;
        case 'italian':