SelectLanguage.php 808 B

123456789101112131415161718192021222324252627
  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. public function __construct($elementName = null, $elementLabel = null, $options = null, $attributes = null)
  12. {
  13. parent::__construct($elementName, $elementLabel, $options, $attributes);
  14. // Get all languages
  15. $languages = api_get_languages();
  16. $this->_options = array();
  17. $this->_values = array();
  18. foreach ($languages['name'] as $index => $name) {
  19. if($languages['folder'][$index] == api_get_setting('platformLanguage')) {
  20. $this->addOption($name,$languages['folder'][$index],array('selected'=>'selected'));
  21. } else {
  22. $this->addOption($name,$languages['folder'][$index]);
  23. }
  24. }
  25. }
  26. }