ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilTermsOfServiceUserHasLanguageCriterionGUI.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2/* Copyright (c) 1998-2018 ILIAS open source, Extended GPL, see docs/LICENSE */
3
6
12{
14 protected $type;
15
17 protected $lng;
18
24 public function __construct(
27 ) {
28 $this->type = $type;
29 $this->lng = $lng;
30 }
31
36 {
37 $option = new ilRadioOption($this->getIdentPresentation(), $this->type->getTypeIdent());
38 $option->setInfo($this->lng->txt('tos_crit_type_usr_language_info'));
39
40 $languageSelection = new ilSelectInputGUI(
41 $this->lng->txt('language'),
42 $this->type->getTypeIdent() . '_lng'
43 );
44 $languageSelection->setRequired(true);
45
46 $options = [];
47 foreach ($this->lng->getInstalledLanguages() as $lng) {
48 $options[$lng] = $this->lng->txt('meta_l_' . $lng);
49 }
50
51 asort($options);
52
53 $languageSelection->setOptions(['' => $this->lng->txt('please_choose')] + $options);
54 $languageSelection->setValue((string) ($config['lng'] ?? ''));
55
56 $option->addSubItem($languageSelection);
57
58 $group->addOption($option);
59 }
60
65 {
67 'lng' => (string) $form->getInput($this->type->getTypeIdent() . '_lng')
68 ]);
69
70 return $config;
71 }
72
76 public function getIdentPresentation() : string
77 {
78 return $this->lng->txt('tos_crit_type_usr_language');
79 }
80
85 {
86 $lng = $config['lng'] ?? '';
87
88 if (!is_string($lng) || 2 !== strlen($lng)) {
89 return $uiFactory->legacy('');
90 }
91
92 return $uiFactory->legacy($this->lng->txt('meta_l_' . (string) $lng));
93 }
94}
An exception for terminatinating execution or to throw for unit testing.
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.
Class ilTermsOfServiceCriterionConfig.
getConfigByForm(ilPropertyFormGUI $form)
ilTermsOfServiceCriterionConfig
appendOption(ilRadioGroupInputGUI $group, ilTermsOfServiceCriterionConfig $config)
getValuePresentation(ilTermsOfServiceCriterionConfig $config, Factory $uiFactory)
Component
__construct(ilTermsOfServiceUserHasLanguageCriterion $type, ilLanguage $lng)
ilTermsOfServiceUserHasLanguageCriterionGUI constructor.
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 ilTermsOfServiceCriterionTypeGUI.
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68