ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAccessibilityUserHasLanguageCriterionGUI.php
Go to the documentation of this file.
1<?php
2
21
26{
28 protected ilLanguage $lng;
29
30 public function __construct(
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 {
86 $config = new ilAccessibilityCriterionConfig([
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()->content('');
104 }
105
106 return $uiFactory->legacy()->content($this->lng->txt('meta_l_' . $lng));
107 }
108}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
appendOption(ilRadioGroupInputGUI $group, ilAccessibilityCriterionConfig $config)
__construct(ilAccessibilityUserHasLanguageCriterion $type, ilLanguage $lng)
getValuePresentation(ilAccessibilityCriterionConfig $config, Factory $uiFactory)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
language handling
This class represents a property form user interface.
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-...
This class represents a property in a property form.
addOption(ilRadioOption $a_option)
This class represents an option in a radio group.
This class represents a selection list property in a property form.
A component is the most general form of an entity in the UI.
Definition: Component.php:28
This is how the factory for UI elements looks.
Definition: Factory.php:38
Interface ilAccessibilityCriterionTypeGUI.