19 declare(strict_types=1);
52 public function __construct(
string $a_title =
"",
string $a_postvar =
"")
62 if (isset($this->hooks[$key])) {
63 return $this->hooks[
$key];
71 $this->hooks[
$key] = $options;
76 if (isset($this->hooks[$key])) {
77 unset($this->hooks[$key]);
84 $this->input_options[$input->
getPostVar()] = $options;
113 public function setMulti(
bool $a_multi,
bool $a_sortable =
false,
bool $a_addremove =
true): void
115 $this->multi = $a_multi;
120 foreach ($this->inputs as
$key => $item) {
121 if (method_exists($item,
'setValue')) {
122 $item->setValue($a_value[
$key]);
127 $this->value = $a_value;
133 foreach ($this->inputs as
$key => $item) {
148 $this->line_values =
$data;
163 $out_array = array();
164 foreach ($_POST[$this->
getPostVar()] as $item_num => $item) {
165 foreach ($this->inputs as $input_key => $input) {
166 if (isset($item[$input_key])) {
167 $out_array[$item_num][$input_key] = (is_string($item[$input_key])) ? \
ilUtil::stripSlashes($item[$input_key]) : $item[$input_key];
176 foreach ($this->inputs as $input_key => $inputs) {
177 if (!$inputs->checkInput()) {
182 $this->
setAlert($lng->txt(
"msg_input_is_required"));
192 if (isset($this->cust_attr[$key]) && !$override) {
217 public function render(
int $iterator_id = 0,
bool $clean_render =
false): string
220 $tpl = new \ilTemplate(
221 "tpl.multi_line_input.html",
224 'Customizing/global/plugins/Services/Repository/RepositoryObject/LiveVoting' 226 $class =
'multi_input_line';
229 $tpl->setCurrentBlock(
'cust_attr');
230 $tpl->setVariable(
'CUSTOM_ATTR_KEY',
$key);
231 $tpl->setVariable(
'CUSTOM_ATTR_VALUE',
$value);
232 $tpl->parseCurrentBlock();
235 foreach ($inputs as
$key => $input) {
236 $input = clone $input;
239 if (!method_exists($input,
'render')) {
248 throw new \ilException(
"Method " . get_class($input)
249 .
"::render() does not exists! You cannot use this input-type in ilMultiLineInputGUI");
253 $is_disabled_hook = $this->
getHook(self::HOOK_IS_INPUT_DISABLED);
254 if ($is_disabled_hook !==
false && !$clean_render) {
255 $input->setDisabled($is_disabled_hook($this->
getValue()));
258 $input->setDisabled(
true);
260 if ($iterator_id == 0 && !isset($this->post_var_cache[
$key])) {
261 $this->post_var_cache[
$key] = $input->getPostVar();
264 $input->setPostVar($this->post_var_cache[$key]);
267 $input->setPostVar($post_var);
268 $before_render_hook = $this->
getHook(self::HOOK_BEFORE_INPUT_RENDER);
269 if ($before_render_hook !==
false && !$clean_render) {
270 $input = $before_render_hook($this->
getValue(), $key, $input);
274 $tpl->setCurrentBlock(
'hidden');
275 $tpl->setVariable(
'NAME', $post_var);
280 $tpl->setCurrentBlock(
'input_label');
281 $tpl->setVariable(
'LABEL', $input->getTitle());
282 $tpl->setVariable(
'CONTENT', $input->getHTML());
283 $tpl->parseCurrentBlock();
284 $first_label =
false;
286 $tpl->setCurrentBlock(
'input');
287 $tpl->setVariable(
'CONTENT', $input->getHTML());
292 $tpl->setCurrentBlock(
'input_label');
293 $tpl->setVariable(
'LABEL', $input->getTitle());
294 $tpl->setVariable(
'CONTENT', $input->render());
295 $first_label =
false;
297 $tpl->setCurrentBlock(
'input');
298 $tpl->setVariable(
'CONTENT', $input->render());
304 $tpl->setCurrentBlock(
'input_info_label');
305 $tpl->setVariable(
'INFO_LABEL', $input->getInfo());
306 $tpl->parseCurrentBlock();
308 $tpl->setCurrentBlock(
'input_info');
309 $tpl->setVariable(
'INFO', $input->getInfo());
310 $tpl->parseCurrentBlock();
313 $tpl->parseCurrentBlock();
318 $is_removeable_hook = $this->
getHook(self::HOOK_IS_LINE_REMOVABLE);
319 if ($is_removeable_hook !==
false && !$clean_render) {
320 $show_remove = $is_removeable_hook($this->
getValue());
323 $image_minus = ($show_remove) ?
xlvoGlyphGUI::get(
'minus') :
'<span class="glyphicon glyphicon-minus hide"></span>';
324 $tpl->setCurrentBlock(
'multi_icons');
325 $tpl->setVariable(
'IMAGE_PLUS', $image_plus);
326 $tpl->setVariable(
'IMAGE_MINUS', $image_minus);
327 $tpl->parseCurrentBlock();
329 $tpl->setCurrentBlock(
'multi_icons_move');
332 $tpl->parseCurrentBlock();
342 $tpl->addJavascript(
'./Modules/OrgUnit/templates/default/multi_line_input.js');
349 $output .= $this->
render(0,
true);
350 if ($this->
getMulti() && is_array($this->line_values) && count($this->line_values) > 0) {
351 foreach ($this->line_values as $run =>
$data) {
353 $object->setValue(
$data);
354 $output .= $object->render($run);
357 $output .= $this->
render(0,
true);
360 $output =
'<div id="' . $this->
getFieldId() .
'" class="multi_line_input">' . $output
362 $output .=
'<script type="text/javascript">$("#' . $this->
getFieldId()
363 .
'").multi_line_input(' . json_encode($this->input_options) .
')</script>';
383 return $this->
render(
"toolbar");
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
setVariable($variable, $value='')
Sets a variable value.
get(string $key, Refinery\Transformation $t)
Get passed parameter, if not data passed, get key from http request.
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
This class represents a text area property in a property form.