You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
990 B
35 lines
990 B
<?php
|
|
|
|
/* For licensing terms, see /license.txt */
|
|
|
|
/**
|
|
* Class SelectLanguage
|
|
* A dropdown list with all languages to use with QuickForm.
|
|
*/
|
|
class SelectLanguage extends HTML_QuickForm_select
|
|
{
|
|
public function __construct(
|
|
$elementName = null,
|
|
$elementLabel = null,
|
|
$options = [],
|
|
$attributes = []
|
|
) {
|
|
parent::__construct($elementName, $elementLabel, $options, $attributes);
|
|
|
|
$default = $attributes['set_custom_default'] ?? false;
|
|
if (!empty($default)) {
|
|
$defaultValue = $default;
|
|
} else {
|
|
$defaultValue = api_get_setting('platformLanguage');
|
|
}
|
|
// Get all languages
|
|
$languages = api_get_languages();
|
|
foreach ($languages as $iso => $name) {
|
|
$attributes = [];
|
|
if ($iso === $defaultValue) {
|
|
$attributes = ['selected' => 'selected'];
|
|
}
|
|
$this->addOption($name, $iso, $attributes);
|
|
}
|
|
}
|
|
}
|
|
|