ILIAS  release_8 Revision v8.24
class.ilTermsOfServiceUserHasCountryCriterionGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23
29{
31 protected ilLanguage $lng;
33 protected array $countryCodes = [];
34
41 public function __construct(
44 array $countryCodes
45 ) {
46 $this->type = $type;
47 $this->lng = $lng;
48 $this->countryCodes = $countryCodes;
49 }
50
52 {
53 $option = new ilRadioOption($this->getIdentPresentation(), $this->type->getTypeIdent());
54 $option->setInfo($this->lng->txt('tos_crit_type_usr_country_info'));
55
56 $countrySelection = new ilSelectInputGUI(
57 $this->lng->txt('country'),
58 $this->type->getTypeIdent() . '_country'
59 );
60 $countrySelection->setRequired(true);
61
62 $options = [];
63 foreach ($this->countryCodes as $country) {
64 $options[strtolower($country)] = $this->lng->txt('meta_c_' . strtoupper($country));
65 }
66 natcasesort($options);
67
68 $countrySelection->setOptions(['' => $this->lng->txt('please_choose')] + $options);
69 $countrySelection->setValue((string) ($config['country'] ?? ''));
70
71 $option->addSubItem($countrySelection);
72
73 $group->addOption($option);
74 }
75
77 {
79 'country' => (string) $form->getInput($this->type->getTypeIdent() . '_country')
80 ]);
81
82 return $config;
83 }
84
85 public function getIdentPresentation(): string
86 {
87 return $this->lng->txt('tos_crit_type_usr_country');
88 }
89
91 {
92 $country = $config['country'] ?? '';
93
94 if (!is_string($country) || 2 !== strlen($country)) {
95 return $uiFactory->legacy('');
96 }
97
98 return $uiFactory->legacy($this->lng->txt('meta_c_' . strtoupper($country)));
99 }
100}
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.
getValuePresentation(ilTermsOfServiceCriterionConfig $config, Factory $uiFactory)
appendOption(ilRadioGroupInputGUI $group, ilTermsOfServiceCriterionConfig $config)
__construct(ilTermsOfServiceUserHasCountryCriterion $type, ilLanguage $lng, array $countryCodes)
ilTermsOfServiceUserHasLanguageCriterionGUI constructor.
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...