ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilTermsOfServiceUserHasCountryCriterionGUI.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 
20  protected $countryCodes = [];
21 
28  public function __construct(
31  array $countryCodes
32  ) {
33  $this->type = $type;
34  $this->lng = $lng;
35  $this->countryCodes = $countryCodes;
36  }
37 
42  {
43  $option = new ilRadioOption($this->getIdentPresentation(), $this->type->getTypeIdent());
44  $option->setInfo($this->lng->txt('tos_crit_type_usr_country_info'));
45 
46  $countrySelection = new ilSelectInputGUI(
47  $this->lng->txt('country'),
48  $this->type->getTypeIdent() . '_country'
49  );
50  $countrySelection->setRequired(true);
51 
52  $options = [];
53  foreach ($this->countryCodes as $country) {
54  $options[strtolower($country)] = $this->lng->txt('meta_c_' . strtoupper($country));
55  }
56  asort($options);
57 
58  $countrySelection->setOptions(['' => $this->lng->txt('please_choose')] + $options);
59  $countrySelection->setValue((string) ($config['country'] ?? ''));
60 
61  $option->addSubItem($countrySelection);
62 
63  $group->addOption($option);
64  }
65 
70  {
72  'country' => (string) $form->getInput($this->type->getTypeIdent() . '_country')
73  ]);
74 
75  return $config;
76  }
77 
81  public function getIdentPresentation() : string
82  {
83  return $this->lng->txt('tos_crit_type_usr_country');
84  }
85 
90  {
91  $country = $config['country'] ?? '';
92 
93  if (!is_string($country) || 2 !== strlen($country)) {
94  return $uiFactory->legacy('');
95  }
96 
97  return $uiFactory->legacy($this->lng->txt('meta_c_' . strtoupper((string) $country)));
98  }
99 }
This class represents an option in a radio group.
Interface ilTermsOfServiceCriterionTypeGUI.
This class represents a property form user interface.
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68
setInfo($a_info)
Set Info.
Class ilTermsOfServiceCriterionConfig.
This class represents a property in a property form.
addOption($a_option)
Add Option.
This is how the factory for UI elements looks.
Definition: Factory.php:17
getConfigByForm(ilPropertyFormGUI $form)
ilTermsOfServiceCriterionConfig
getValuePresentation(ilTermsOfServiceCriterionConfig $config, Factory $uiFactory)
Component
legacy($content)
description: purpose: > This component is used to wrap an existing ILIAS UI element into a UI compon...
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
appendOption(ilRadioGroupInputGUI $group, ilTermsOfServiceCriterionConfig $config)
__construct(ilTermsOfServiceUserHasCountryCriterion $type, ilLanguage $lng, array $countryCodes)
ilTermsOfServiceUserHasLanguageCriterionGUI constructor.