SelectLanguage.php 876 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * A dropdownlist with all languages to use with QuickForm
  5. */
  6. class SelectLanguage extends HTML_QuickForm_select
  7. {
  8. /**
  9. * Class constructor
  10. */
  11. function SelectLanguage($elementName=null, $elementLabel=null, $options=null, $attributes=null)
  12. {
  13. if (!isset($attributes['class'])) {
  14. $attributes['class'] = 'chzn-select';
  15. }
  16. parent::__construct($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. }