ILIAS  release_8 Revision v8.24
class.ilOrgUnitAuthorityInputGUI.php
Go to the documentation of this file.
1<?php
24{
28 protected $value;
29
35 public function __construct($a_title, $a_postvar)
36 {
37 parent::__construct($a_title, $a_postvar);
42 $a = ilOrgUnitAuthority::find($id);
43 $data = array('id' => $id, 'over' => $a->getOver(), 'scope' => $a->getScope());
44
45 return json_encode($data);
46 });
47 }
48
52 public function insert(ilTemplate $a_tpl): void
53 {
54 $html = $this->render();
55
56 $a_tpl->setCurrentBlock("prop_generic");
57 $a_tpl->setVariable("PROP_GENERIC", $html);
58 $a_tpl->parseCurrentBlock();
59 }
60
64 public function setValueByArray(array $values): void
65 {
66 $authorities = $values[$this->getPostVar()];
67 if (!is_array($authorities)) {
68 $authorities = [];
69 }
70 foreach ($authorities as $authority) {
71 assert($authority instanceof ilOrgUnitAuthority);
72 }
73 $this->setValue($authorities);
74 }
75
79 public function setValue(array $a_value): void
80 {
81 $this->value = $a_value;
82 }
83
87 public function getValue(): array
88 {
89 return $this->value;
90 }
91
95 protected function render(): string
96 {
97 $tpl = new ilTemplate("tpl.authority_input.html", true, true, "Modules/OrgUnit");
98 // if (strlen($this->getValue())) {
99 // $tpl->setCurrentBlock("prop_text_propval");
100 // $tpl->setVariable("PROPERTY_VALUE", ilUtil::prepareFormOutput($this->getValue()));
101 // $tpl->parseCurrentBlock();
102 // }
103
104 //$tpl->setVariable("POSITION_ID", $this->getFieldId());
105
106 $postvar = $this->getPostVar();
107 // if ($this->getMulti() && substr($postvar, - 2) != "[]") {
108 // $postvar .= "[]";
109 // }
110
111 $tpl->setVariable("POST_VAR", $postvar);
112
113 // SCOPE
114 $scope_html = "";
116 $txt = $this->dic()->language()->txt('scope_' . $scope);
117 $scope_html .= "<option value='{$scope}'>{$txt}</option>";
118 }
119 $tpl->setVariable("SCOPE_OPTIONS", $scope_html);
120
121 // Over
122 $over_everyone = ilOrgUnitAuthority::OVER_EVERYONE;
123 $title = $this->lang()->txt('over_' . $over_everyone);
124 $over_html = "<option value='{$over_everyone}'>{$title}</option>";
125 foreach (ilOrgUnitPosition::getArray('id', 'title') as $id => $title) {
126 $over_html .= "<option value='{$id}'>{$title}</option>";
127 }
128 $tpl->setVariable("OVER_OPTIONS", $over_html);
132 if ($this->getMultiValues()) {
133 foreach ($this->getMultiValues() as $ilOrgUnitAuthority) {
134 // $tpl->setVariable("OVER_OPTIONS", $over_html);
135 }
136 }
137
138 if ($this->getRequired()) {
139 // $tpl->setVariable("REQUIRED", "required=\"required\"");
140 }
141
142 $tpl->touchBlock("inline_in_bl");
143 $tpl->setVariable("MULTI_ICONS", $this->getMultiIconsHTML());
144 $this->initJS();
145
146 return $tpl->get();
147 }
148
149 protected function dic(): \ILIAS\DI\Container
150 {
151 return $GLOBALS["DIC"];
152 }
153
154 protected function lang(): \ilLanguage
155 {
156 static $loaded;
157 $lang = $this->dic()->language();
158 if (!$loaded) {
159 $lang->loadLanguageModule('orgu');
160 $loaded = true;
161 }
162
163 return $lang;
164 }
165
166 public function getMulti(): bool
167 {
168 return false;
169 }
170
171 protected function initJS(): void
172 {
173 // Global JS
177 $globalTpl = $GLOBALS['DIC'] ? $GLOBALS['DIC']['tpl'] : $GLOBALS['tpl'];
178 $globalTpl->addJavascript("./Modules/OrgUnit/templates/default/authority.js");
179 $config = json_encode(array());
180 $data = json_encode($this->getValue());
181 $globalTpl->addOnLoadCode("ilOrgUnitAuthorityInput.init({$config}, {$data});");
182 }
183}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
static getArray(?string $key=null, $values=null)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
This class represents a property in a property form.
__construct(string $a_title="", string $a_postvar="")
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static replaceNameRenderer(Closure $closure)
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
$txt
Definition: error.php:13
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$scope
Definition: ltiregstart.php:53
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
Class HTTPServicesTest.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Class ChatMainBarProvider \MainMenu\Provider.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
$lang
Definition: xapiexit.php:26