18 require_once(
"./Services/Form/classes/class.ilFormPropertyGUI.php");
51 public function __construct(
string $a_title =
"",
string $a_postvar =
"")
61 if (isset($this->hooks[$key])) {
62 return $this->hooks[
$key];
70 $this->hooks[
$key] = $options;
75 if (isset($this->hooks[$key])) {
76 unset($this->hooks[$key]);
87 $this->input_options[$input->
getPostVar()] = $options;
120 public function setMulti(
bool $a_multi,
bool $a_sortable =
false,
bool $a_addremove =
true): void
122 $this->multi = $a_multi;
129 foreach ($this->inputs as
$key => $item) {
133 if (array_key_exists(
$key, $value)) {
134 $item->setValue($value[
$key]);
143 foreach ($this->inputs as
$key => $item) {
154 $this->line_values =
$data;
166 $internal_fields = array_keys($this->inputs);
170 foreach (
$post as $authority) {
172 array_key_exists(self::MULTI_FIELD_ID, $authority) &&
173 array_key_exists(self::MULTI_FIELD_OVER, $authority) &&
174 array_key_exists(self::MULTI_FIELD_SCOPE, $authority) &&
175 trim($authority[self::MULTI_FIELD_OVER]) !==
'' &&
176 trim($authority[self::MULTI_FIELD_SCOPE]) !==
'' 178 $this->
setAlert($this->
lng->txt(
"msg_input_is_required"));
188 if (isset($this->cust_attr[$key]) && !$override) {
210 public function render(
int $iterator_id = 0,
bool $clean_render =
false): string
214 $tpl =
new ilTemplate(
"tpl.prop_generic_multi_line.html",
true,
true,
'Modules/OrgUnit');
216 $class =
'multi_input_line';
219 $tpl->setCurrentBlock(
'cust_attr');
220 $tpl->setVariable(
'CUSTOM_ATTR_KEY',
$key);
221 $tpl->setVariable(
'CUSTOM_ATTR_VALUE',
$value);
222 $tpl->parseCurrentBlock();
225 foreach ($inputs as
$key => $input) {
226 $input = clone $input;
229 if (!method_exists($input,
'render')) {
238 throw new \ilException(
"Method " . get_class($input)
239 .
"::render() does not exists! You cannot use this input-type in ilMultiLineInputGUI");
243 $is_disabled_hook = $this->
getHook(self::HOOK_IS_INPUT_DISABLED);
244 if ($is_disabled_hook !==
false && !$clean_render) {
245 $input->setDisabled($is_disabled_hook($this->
getValue()));
248 $input->setDisabled(
true);
250 if ($iterator_id == 0 && !isset($this->post_var_cache[
$key])) {
251 $this->post_var_cache[
$key] = $input->getPostVar();
254 $input->setPostVar($this->post_var_cache[$key]);
257 $input->setPostVar($post_var);
258 $before_render_hook = $this->
getHook(self::HOOK_BEFORE_INPUT_RENDER);
259 if ($before_render_hook !==
false && !$clean_render) {
260 $input = $before_render_hook($this->
getValue(), $key, $input);
264 $tpl->setCurrentBlock(
'hidden');
265 $tpl->setVariable(
'NAME', $post_var);
270 $tpl->setCurrentBlock(
'input_label');
271 $tpl->setVariable(
'LABEL', $input->getTitle());
272 $tpl->setVariable(
'CONTENT', $input->getHTML());
273 $tpl->parseCurrentBlock();
274 $first_label =
false;
276 $tpl->setCurrentBlock(
'input');
277 $tpl->setVariable(
'CONTENT', $input->getHTML());
282 $tpl->setCurrentBlock(
'input_label');
283 $tpl->setVariable(
'LABEL', $input->getTitle());
284 $tpl->setVariable(
'CONTENT', $input->render());
285 $first_label =
false;
287 $tpl->setCurrentBlock(
'input');
288 $tpl->setVariable(
'CONTENT', $input->render());
294 $tpl->setCurrentBlock(
'input_info_label');
295 $tpl->setVariable(
'INFO_LABEL', $input->getInfo());
296 $tpl->parseCurrentBlock();
298 $tpl->setCurrentBlock(
'input_info');
299 $tpl->setVariable(
'INFO', $input->getInfo());
300 $tpl->parseCurrentBlock();
303 $tpl->parseCurrentBlock();
308 $is_removeable_hook = $this->
getHook(self::HOOK_IS_LINE_REMOVABLE);
309 if ($is_removeable_hook !==
false && !$clean_render) {
310 $show_remove = $is_removeable_hook($this->
getValue());
314 $tpl->setCurrentBlock(
'multi_icons');
315 $tpl->setVariable(
'IMAGE_PLUS', $image_plus);
316 $tpl->setVariable(
'IMAGE_MINUS', $image_minus);
317 $tpl->parseCurrentBlock();
319 $tpl->setCurrentBlock(
'multi_icons_move');
322 $tpl->parseCurrentBlock();
332 $tpl->addJavascript(
'Modules/OrgUnit/js/generic_multi_line_input.js');
343 $output .= $this->
render(0,
true);
344 if ($this->
getMulti() && is_array($this->line_values) && count($this->line_values) > 0) {
346 $tpl =
new ilTemplate(
"tpl.prop_generic_multi_line.html",
true,
true,
'Modules/OrgUnit');
348 $image_minus =
'<span class="glyphicon glyphicon-minus hide"></span>';
350 $tpl->setVariable(
'ADDITIONAL_ATTRS',
"id='multi_line_add_button' style='display:none'");
351 $tpl->setCurrentBlock(
'multi_icons');
352 $tpl->setVariable(
'IMAGE_PLUS', $image_plus);
353 $tpl->setVariable(
'IMAGE_MINUS', $image_minus);
354 $tpl->parseCurrentBlock();
355 $output .=
$tpl->get();
357 foreach ($this->line_values as $run =>
$data) {
359 $object->setValue(
$data);
360 $output .= $object->render($run);
363 if ($this->render_one_for_empty_value) {
364 $output .= $this->
render(0,
true);
366 $tpl =
new ilTemplate(
"tpl.prop_generic_multi_line.html",
true,
true,
'Modules/OrgUnit');
368 $image_minus =
'<span class="glyphicon glyphicon-minus hide"></span>';
370 $tpl->setVariable(
'ADDITIONAL_ATTRS',
"id='multi_line_add_button'");
371 $tpl->setCurrentBlock(
'multi_icons');
372 $tpl->setVariable(
'IMAGE_PLUS', $image_plus);
373 $tpl->setVariable(
'IMAGE_MINUS', $image_minus);
374 $tpl->parseCurrentBlock();
375 $output .=
$tpl->get();
379 $output =
"<div id='{$this->getFieldId()}' class='multi_line_input'>{$output}</div>";
382 $options = json_encode($this->input_options);
383 $tpl->addOnLoadCode(
"$('#{$this->getFieldId()}').multi_line_input({$this->getFieldId()}, '{$options}')");
404 return $this->
render(
"toolbar");
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
static get(string $a_glyph, string $a_text="")
setVariable($variable, $value='')
Sets a variable value.
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
__construct(Container $dic, ilPlugin $plugin)
This class represents a text area property in a property form.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl