2 require_once(
"./Services/Form/classes/class.ilFormPropertyGUI.php");
84 parent::__construct($a_title, $a_postvar);
96 if (isset($this->hooks[
$key])) {
97 return $this->hooks[
$key];
120 if (isset($this->hooks[
$key])) {
121 unset($this->hooks[$key]);
192 public function setMulti($a_multi, $a_sortable =
false, $a_addremove =
true)
194 $this->multi = $a_multi;
205 foreach ($this->inputs as
$key => $item) {
206 if (method_exists($item,
'setValue')) {
207 $item->setValue($a_value[
$key]);
212 $this->value = $a_value;
224 foreach ($this->inputs as
$key => $item) {
241 $this->line_values =
$data;
258 $out_array = array();
261 foreach ($this->inputs as $input_key => $input) {
262 if (isset($item[$input_key])) {
263 $out_array[$item_num][$input_key] = (is_string($item[$input_key])) ? \
ilUtil::stripSlashes($item[$input_key]) : $item[$input_key];
274 foreach ($this->inputs as $input_key =>
$inputs) {
275 foreach ($out_array as $subitem) {
283 $this->
setAlert($lng->txt(
"msg_input_is_required"));
299 if (isset($this->cust_attr[
$key]) && !$override) {
340 public function render($iterator_id = 0, $clean_render =
false)
344 $tpl =
new ilTemplate(
"tpl.prop_generic_multi_line.html",
true,
true,
'Modules/OrgUnit');
346 $class =
'multi_input_line';
349 $tpl->setCurrentBlock(
'cust_attr');
350 $tpl->setVariable(
'CUSTOM_ATTR_KEY',
$key);
351 $tpl->setVariable(
'CUSTOM_ATTR_VALUE',
$value);
352 $tpl->parseCurrentBlock();
359 if (!method_exists($input,
'render')) {
368 throw new \ilException(
"Method " . get_class($input)
369 .
"::render() does not exists! You cannot use this input-type in ilMultiLineInputGUI");
373 $is_disabled_hook = $this->
getHook(self::HOOK_IS_INPUT_DISABLED);
374 if ($is_disabled_hook !==
false && !$clean_render) {
375 $input->setDisabled($is_disabled_hook($this->
getValue()));
378 $input->setDisabled(
true);
380 if ($iterator_id == 0 && !isset($this->post_var_cache[
$key])) {
381 $this->post_var_cache[
$key] = $input->getPostVar();
384 $input->setPostVar($this->post_var_cache[$key]);
387 $input->setPostVar($post_var);
388 $before_render_hook = $this->
getHook(self::HOOK_BEFORE_INPUT_RENDER);
389 if ($before_render_hook !==
false && !$clean_render) {
390 $input = $before_render_hook($this->
getValue(), $key, $input);
394 $tpl->setCurrentBlock(
'hidden');
395 $tpl->setVariable(
'NAME', $post_var);
400 $tpl->setCurrentBlock(
'input_label');
401 $tpl->setVariable(
'LABEL', $input->getTitle());
402 $tpl->setVariable(
'CONTENT', $input->getHTML());
403 $tpl->parseCurrentBlock();
404 $first_label =
false;
406 $tpl->setCurrentBlock(
'input');
407 $tpl->setVariable(
'CONTENT', $input->getHTML());
412 $tpl->setCurrentBlock(
'input_label');
413 $tpl->setVariable(
'LABEL', $input->getTitle());
414 $tpl->setVariable(
'CONTENT', $input->render());
415 $first_label =
false;
417 $tpl->setCurrentBlock(
'input');
418 $tpl->setVariable(
'CONTENT', $input->render());
424 $tpl->setCurrentBlock(
'input_info_label');
425 $tpl->setVariable(
'INFO_LABEL', $input->getInfo());
426 $tpl->parseCurrentBlock();
428 $tpl->setCurrentBlock(
'input_info');
429 $tpl->setVariable(
'INFO', $input->getInfo());
430 $tpl->parseCurrentBlock();
433 $tpl->parseCurrentBlock();
438 $is_removeable_hook = $this->
getHook(self::HOOK_IS_LINE_REMOVABLE);
439 if ($is_removeable_hook !==
false && !$clean_render) {
440 $show_remove = $is_removeable_hook($this->
getValue());
444 $tpl->setCurrentBlock(
'multi_icons');
445 $tpl->setVariable(
'IMAGE_PLUS', $image_plus);
446 $tpl->setVariable(
'IMAGE_MINUS', $image_minus);
447 $tpl->parseCurrentBlock();
449 $tpl->setCurrentBlock(
'multi_icons_move');
452 $tpl->parseCurrentBlock();
463 $tpl->addJavascript(
'Modules/OrgUnit/js/generic_multi_line_input.js');
477 if ($this->
getMulti() && is_array($this->line_values) && count($this->line_values) > 0) {
478 foreach ($this->line_values as $run =>
$data) {
480 $object->setValue(
$data);
481 $output .= $object->render($run);
484 if ($this->render_one_for_empty_value) {
487 $tpl =
new ilTemplate(
"tpl.prop_generic_multi_line.html",
true,
true,
'Modules/OrgUnit');
489 $image_minus =
'<span class="glyphicon glyphicon-minus hide"></span>';
491 $tpl->setVariable(
'ADDITIONAL_ATTRS',
"style='float:left';");
492 $tpl->setCurrentBlock(
'multi_icons');
493 $tpl->setVariable(
'IMAGE_PLUS', $image_plus);
494 $tpl->setVariable(
'IMAGE_MINUS', $image_minus);
495 $tpl->parseCurrentBlock();
500 $output =
"<div id='{$this->getFieldId()}' class='multi_line_input'>{$output}</div>";
503 $options = json_encode($this->input_options);
504 $tpl->addOnLoadCode(
"$('#{$this->getFieldId()}').multi_line_input({$this->getFieldId()}, '{$options}')");
507 $a_tpl->setCurrentBlock(
"prop_generic");
508 $a_tpl->setVariable(
"PROP_GENERIC",
$output);
509 $a_tpl->parseCurrentBlock();
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
static get($a_glyph, $a_text="")
Get glyph html.
special template class to simplify handling of ITX/PEAR
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
This class represents a text area property in a property form.