Dropdown::showLanguages PHP Method

showLanguages() static public method

Dropdown available languages
static public showLanguages ( $myname, $options = [] )
$myname select name
$options array of additionnal options: - display_emptychoice : allow selection of no language - emptylabel : specific string to empty label if display_emptychoice is true
    static function showLanguages($myname, $options = array())
    {
        global $CFG_GLPI;
        $values = array();
        if (isset($options['display_emptychoice']) && $options['display_emptychoice']) {
            if (isset($options['emptylabel'])) {
                $values[''] = $options['emptylabel'];
            } else {
                $values[''] = self::EMPTY_VALUE;
            }
            unset($options['display_emptychoice']);
        }
        foreach ($CFG_GLPI["languages"] as $key => $val) {
            if (isset($val[1]) && is_file(GLPI_ROOT . "/locales/" . $val[1])) {
                $values[$key] = $val[0];
            }
        }
        return self::showFromArray($myname, $values, $options);
    }

Usage Example

function choose_language()
{
    echo "<form action='install.php' method='post'>";
    echo "<p class='center'>";
    Dropdown::showLanguages("language", array('value' => "en_GB"));
    echo "</p>";
    echo "";
    echo "<p class='submit'><input type='hidden' name='install' value='lang_select'>";
    echo "<input type='submit' name='submit' class='submit' value='OK'></p>";
    Html::closeForm();
}
All Usage Examples Of Dropdown::showLanguages