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 }
getValuePresentation(\ilTermsOfServiceCriterionConfig $config, Factory $uiFactory)
Component
Interface ilTermsOfServiceCriterionTypeGUI.
appendOption(\ilRadioGroupInputGUI $group, \ilTermsOfServiceCriterionConfig $config)
$config
Definition: bootstrap.php:15
This class represents a property form user interface.
Class ilTermsOfServiceCriterionConfig.
__construct(\ilTermsOfServiceUserHasLanguageCriterion $type, \ilLanguage $lng)
ilTermsOfServiceUserHasLanguageCriterionGUI constructor.
This class represents a property in a property form.
addOption($a_option)
Add Option.
if(isset($_POST['submit'])) $form
This is how the factory for UI elements looks.
Definition: Factory.php:15
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.
language handling