ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilAccessibilityUserHasLanguageCriterionGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
3
6
11{
13 protected $type;
14
16 protected $lng;
17
23 public function __construct(
26 ) {
27 $this->type = $type;
28 $this->lng = $lng;
29 }
30
35 {
36 $option = new ilRadioOption($this->getIdentPresentation(), $this->type->getTypeIdent());
37
38 $languageSelection = new ilSelectInputGUI(
39 $this->lng->txt('language'),
40 $this->type->getTypeIdent() . '_lng'
41 );
42 $languageSelection->setRequired(true);
43
44 $options = [];
45 foreach ($this->lng->getInstalledLanguages() as $lng) {
46 $options[$lng] = $this->lng->txt('meta_l_' . $lng);
47 }
48
49 asort($options);
50
51 $languageSelection->setOptions(['' => $this->lng->txt('please_choose')] + $options);
52 $languageSelection->setValue((string) ($config['lng'] ?? ''));
53
54 $option->addSubItem($languageSelection);
55
56 $group->addOption($option);
57 }
58
63 {
64 $languageSelection = new ilSelectInputGUI(
65 $this->lng->txt('language'),
66 $this->type->getTypeIdent() . '_lng'
67 );
68 $languageSelection->setRequired(true);
69
70 $options = [];
71 foreach ($this->lng->getInstalledLanguages() as $lng) {
72 $options[$lng] = $this->lng->txt('meta_l_' . $lng);
73 }
74
75 asort($options);
76
77 $languageSelection->setOptions(['' => $this->lng->txt('please_choose')] + $options);
78 $languageSelection->setValue((string) ($config['lng'] ?? ''));
79
80 return $languageSelection;
81 }
82
87 {
89 'lng' => (string) $form->getInput($this->type->getTypeIdent() . '_lng')
90 ]);
91
92 return $config;
93 }
94
98 public function getIdentPresentation() : string
99 {
100 return $this->lng->txt('acc_crit_type_usr_language');
101 }
102
107 {
108 $lng = $config['lng'] ?? '';
109
110 if (!is_string($lng) || 2 !== strlen($lng)) {
111 return $uiFactory->legacy('');
112 }
113
114 return $uiFactory->legacy($this->lng->txt('meta_l_' . (string) $lng));
115 }
116}
An exception for terminatinating execution or to throw for unit testing.
Class ilAccessibilityCriterionConfig.
getConfigByForm(ilPropertyFormGUI $form)
ilAccessibilityCriterionConfig
appendOption(ilRadioGroupInputGUI $group, ilAccessibilityCriterionConfig $config)
getSelection(ilAccessibilityCriterionConfig $config)
@inheritDoc
__construct(ilAccessibilityUserHasLanguageCriterion $type, ilLanguage $lng)
ilAccessibilityUserHasLanguageCriterionGUI constructor.
getValuePresentation(ilAccessibilityCriterionConfig $config, Factory $uiFactory)
Component
language handling
This class represents a property form user interface.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
This class represents a property in a property form.
addOption($a_option)
Add 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:14
This is how the factory for UI elements looks.
Definition: Factory.php:18
legacy($content)
Interface ilAccessibilityCriterionTypeGUI.
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68