ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilTermsOfServiceUserHasLanguageCriterionGUI.php
Go to the documentation of this file.
1<?php
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 {
66 $config = new \ilTermsOfServiceCriterionConfig([
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.
This class represents a property in a property form.
addOption($a_option)
Add Option.
Class ilTermsOfServiceCriterionConfig.
__construct(\ilTermsOfServiceUserHasLanguageCriterion $type, \ilLanguage $lng)
ilTermsOfServiceUserHasLanguageCriterionGUI constructor.
appendOption(\ilRadioGroupInputGUI $group, \ilTermsOfServiceCriterionConfig $config)
getConfigByForm(\ilPropertyFormGUI $form)
\ilTermsOfServiceCriterionConfig
getValuePresentation(\ilTermsOfServiceCriterionConfig $config, Factory $uiFactory)
Component
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:16
legacy($content)
Interface ilTermsOfServiceCriterionTypeGUI.
$config
Definition: bootstrap.php:15
if(isset($_POST['submit'])) $form