ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilAccessibilityUserHasLanguageCriterionGUI.php
Go to the documentation of this file.
1 <?php
2 
21 
26 {
28  protected ilLanguage $lng;
29 
30  public function __construct(
32  ilLanguage $lng
33  ) {
34  $this->type = $type;
35  $this->lng = $lng;
36  }
37 
39  {
40  $option = new ilRadioOption($this->getIdentPresentation(), $this->type->getTypeIdent());
41 
42  $languageSelection = new ilSelectInputGUI(
43  $this->lng->txt('language'),
44  $this->type->getTypeIdent() . '_lng'
45  );
46  $languageSelection->setRequired(true);
47 
48  $options = [];
49  foreach ($this->lng->getInstalledLanguages() as $lng) {
50  $options[$lng] = $this->lng->txt('meta_l_' . $lng);
51  }
52 
53  asort($options);
54 
55  $languageSelection->setOptions(['' => $this->lng->txt('please_choose')] + $options);
56  $languageSelection->setValue((string) ($config['lng'] ?? ''));
57 
58  $option->addSubItem($languageSelection);
59 
60  $group->addOption($option);
61  }
62 
64  {
65  $languageSelection = new ilSelectInputGUI(
66  $this->lng->txt('language'),
67  $this->type->getTypeIdent() . '_lng'
68  );
69  $languageSelection->setRequired(true);
70 
71  $options = [];
72  foreach ($this->lng->getInstalledLanguages() as $lng) {
73  $options[$lng] = $this->lng->txt('meta_l_' . $lng);
74  }
75 
76  asort($options);
77 
78  $languageSelection->setOptions(['' => $this->lng->txt('please_choose')] + $options);
79  $languageSelection->setValue((string) ($config['lng'] ?? ''));
80 
81  return $languageSelection;
82  }
83 
85  {
87  'lng' => (string) $form->getInput($this->type->getTypeIdent() . '_lng')
88  ]);
89 
90  return $config;
91  }
92 
93  public function getIdentPresentation(): string
94  {
95  return $this->lng->txt('acc_crit_type_usr_language');
96  }
97 
99  {
100  $lng = $config['lng'] ?? '';
101 
102  if (!is_string($lng) || 2 !== strlen($lng)) {
103  return $uiFactory->legacy('');
104  }
105 
106  return $uiFactory->legacy($this->lng->txt('meta_l_' . $lng));
107  }
108 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addOption(ilRadioOption $a_option)
legacy(string $content)
description: purpose: > This component is used to wrap an existing ILIAS UI element into a UI compon...
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
__construct(ilAccessibilityUserHasLanguageCriterion $type, ilLanguage $lng)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property in a property form.
setValue(string $a_value)
appendOption(ilRadioGroupInputGUI $group, ilAccessibilityCriterionConfig $config)
getValuePresentation(ilAccessibilityCriterionConfig $config, Factory $uiFactory)
Interface ilAccessibilityCriterionTypeGUI.