ILIAS  release_8 Revision v8.24
class.ilTermsOfServiceUserHasLanguageCriterionGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
29{
31 protected ilLanguage $lng;
32
33 public function __construct(
36 ) {
37 $this->type = $type;
38 $this->lng = $lng;
39 }
40
42 {
43 $option = new ilRadioOption($this->getIdentPresentation(), $this->type->getTypeIdent());
44 $option->setInfo($this->lng->txt('tos_crit_type_usr_language_info'));
45
46 $languageSelection = new ilSelectInputGUI(
47 $this->lng->txt('language'),
48 $this->type->getTypeIdent() . '_lng'
49 );
50 $languageSelection->setRequired(true);
51
52 $options = [];
53 foreach ($this->lng->getInstalledLanguages() as $lng) {
54 $options[$lng] = $this->lng->txt('meta_l_' . $lng);
55 }
56
57 natcasesort($options);
58
59 $languageSelection->setOptions(['' => $this->lng->txt('please_choose')] + $options);
60 $languageSelection->setValue((string) ($config['lng'] ?? ''));
61
62 $option->addSubItem($languageSelection);
63
64 $group->addOption($option);
65 }
66
68 {
70 'lng' => (string) $form->getInput($this->type->getTypeIdent() . '_lng')
71 ]);
72
73 return $config;
74 }
75
76 public function getIdentPresentation(): string
77 {
78 return $this->lng->txt('tos_crit_type_usr_language');
79 }
80
82 {
83 $lng = $config['lng'] ?? '';
84
85 if (!is_string($lng) || 2 !== strlen($lng)) {
86 return $uiFactory->legacy('');
87 }
88
89 return $uiFactory->legacy($this->lng->txt('meta_l_' . $lng));
90 }
91}
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 file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a selection list property in a property form.
Class ilTermsOfServiceCriterionConfig.
appendOption(ilRadioGroupInputGUI $group, ilTermsOfServiceCriterionConfig $config)
getValuePresentation(ilTermsOfServiceCriterionConfig $config, Factory $uiFactory)
__construct(ilTermsOfServiceUserHasLanguageCriterion $type, ilLanguage $lng)
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
legacy(string $content)
Interface ilTermsOfServiceCriterionTypeGUI.
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...