SelectLanguage.php 801 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Class SelectLanguage
  5. * A dropdownlist with all languages to use with QuickForm
  6. */
  7. class SelectLanguage extends HTML_QuickForm_select
  8. {
  9. /**
  10. * Class constructor
  11. */
  12. public function __construct(
  13. $elementName = null,
  14. $elementLabel = null,
  15. $options = null,
  16. $attributes = null
  17. ) {
  18. parent::__construct($elementName, $elementLabel, $options, $attributes);
  19. // Get all languages
  20. $languages = api_get_languages();
  21. $this->_options = array();
  22. $this->_values = array();
  23. foreach ($languages as $iso => $name) {
  24. if ($iso == api_get_setting('language.platform_language')) {
  25. $this->addOption($name, $iso, array('selected'=>'selected'));
  26. } else {
  27. $this->addOption($name, $iso);
  28. }
  29. }
  30. }
  31. }