select_language.php 957 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. require_once 'HTML/QuickForm/select.php';
  4. /**
  5. * A dropdownlist with all languages to use with QuickForm
  6. */
  7. class HTML_QuickForm_Select_Language extends HTML_QuickForm_select
  8. {
  9. /**
  10. * Class constructor
  11. */
  12. function HTML_QuickForm_Select_Language($elementName=null, $elementLabel=null, $options=null, $attributes=null){
  13. if (!isset($attributes['class'])) {
  14. $attributes['class'] = 'chzn-select';
  15. }
  16. parent::HTML_QuickForm_Select($elementName, $elementLabel, $options, $attributes);
  17. // Get all languages
  18. $languages = api_get_languages();
  19. $this->_options = array();
  20. $this->_values = array();
  21. foreach ($languages['name'] as $index => $name) {
  22. if($languages['folder'][$index] == api_get_setting('platformLanguage')) {
  23. $this->addOption($name,$languages['folder'][$index],array('selected'=>'selected'));
  24. } else {
  25. $this->addOption($name,$languages['folder'][$index]);
  26. }
  27. }
  28. }
  29. }