Chamilo is a learning management system focused on ease of use and accessibility
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.
 
 
 
 
 
 
chamilo-lms/public/main/inc/lib/formvalidator/Element/SelectLanguage.php

38 lines
1.1 KiB

<?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
{
/**
* Class constructor.
*/
public function __construct(
$elementName = null,
$elementLabel = null,
$options = [],
$attributes = []
) {
parent::__construct($elementName, $elementLabel, $options, $attributes);
$default = isset($attributes['set_custom_default']) ? $attributes['set_custom_default'] : false;
// Get all languages
$languages = api_get_languages();
foreach ($languages as $index => $name) {
if (!empty($default)) {
$defaultValue = $default;
} else {
$defaultValue = api_get_setting('platformLanguage');
}
if ($languages[$index] == $defaultValue) {
$this->addOption($name, $index, ['selected' => 'selected']);
} else {
$this->addOption($name, $index);
}
}
}
}