ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
class.ilNestedListInputGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
27{
28 protected string $value = "1";
29 protected array $checked = [];
30 protected array $list_nodes = [];
32
33 public function __construct(
34 string $a_title = "",
35 string $a_postvar = ""
36 ) {
37 global $DIC;
38
39 $this->lng = $DIC->language();
40 parent::__construct($a_title, $a_postvar);
41 $this->setType("nested_list");
42
43 $this->list = new ilNestedList();
44 $this->list->setListClass("il_Explorer");
45 }
46
47 public function addListNode(
48 string $a_id,
49 string $a_text,
50 string $a_parent = "0",
51 bool $a_checked = false,
52 bool $a_disabled = false,
53 string $a_img_src = "",
54 string $a_img_alt = "",
55 string $a_post_var = ""
56 ) {
57 $this->list_nodes[$a_id] = array("text" => $a_text,
58 "parent" => $a_parent, "checked" => $a_checked, "disabled" => $a_disabled,
59 "img_src" => $a_img_src, "img_alt" => $a_img_alt, "post_var" => $a_post_var);
60 }
61
62 public function setValue(string $a_value): void
63 {
64 $this->value = $a_value;
65 }
66
67 public function getValue(): string
68 {
69 return $this->value;
70 }
71
72 public function setValueByArray(array $a_values): void
73 {
74 // $this->setChecked($a_values[$this->getPostVar()]);
75// foreach($this->getSubItems() as $item)
76// {
77// $item->setValueByArray($a_values);
78// }
79 }
80
81 public function checkInput(): bool
82 {
83 return true;
84 }
85
86 public function getInput(): array
87 {
88 return $this->strArray($this->getPostVar());
89 }
90
91 public function render(): string
92 {
93 foreach ($this->list_nodes as $id => $n) {
94 if ($n["post_var"] == "") {
95 $post_var = $this->getPostVar() . "[]";
96 } else {
97 $post_var = $n["post_var"];
98 }
99 $value = $id;
101 $n["checked"],
102 $post_var,
103 (string) $value,
104 $n["disabled"]
105 );
106 if ($n["img_src"] != "") {
107 $item_html .= ilUtil::img(
108 $n["img_src"],
109 $n["img_alt"],
110 "",
111 "",
112 0,
113 "",
114 "ilIcon"
115 ) . " ";
116 }
117 $item_html .= $n["text"];
118
119 $this->list->addListNode($item_html, (string) $id, $n["parent"]);
120 }
121
122 return $this->list->getHTML();
123 }
124
125 public function insert(ilTemplate $a_tpl): void
126 {
127 $html = $this->render();
128
129 $a_tpl->setCurrentBlock("prop_generic");
130 $a_tpl->setVariable("PROP_GENERIC", $html);
131 $a_tpl->parseCurrentBlock();
132 }
133}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
This class represents a property in a property form.
static formCheckbox(bool $checked, string $varname, string $value, bool $disabled=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(string $a_title="", string $a_postvar="")
addListNode(string $a_id, string $a_text, string $a_parent="0", bool $a_checked=false, bool $a_disabled=false, string $a_img_src="", string $a_img_alt="", string $a_post_var="")
checkInput()
Check input, strip slashes etc.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc