ILIAS  release_8 Revision v8.24
ilNestedList Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilNestedList:

Public Member Functions

 __construct ()
 
 setItemClass (string $a_val)
 
 getItemClass ()
 
 setListClass (string $a_val, int $a_depth=0)
 
 getListClass (int $a_depth=0)
 
 addListNode (string $a_content, string $a_id, $a_parent=0)
 
 setAutoNumbering (bool $a_val)
 
 getAutoNumbering ()
 
 getNumbers ()
 
 getHTML ()
 
 renderNode ( $a_id, ilTemplate $tpl, int $depth, array &$nr)
 
 listItemStart (ilTemplate $tpl)
 
 listItemEnd (ilTemplate $tpl)
 
 listStart (ilTemplate $tpl, int $depth)
 
 listEnd (ilTemplate $tpl)
 

Protected Attributes

string $item_class = "il_Explorer"
 
array $list_class = array()
 
bool $auto_numbering = false
 
array $nr = array()
 
array $nodes = []
 
array $childs = []
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Nested List

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 23 of file class.ilNestedList.php.

Constructor & Destructor Documentation

◆ __construct()

ilNestedList::__construct ( )

Definition at line 32 of file class.ilNestedList.php.

33 {
34 $this->list_class[0] = "il_Explorer";
35 $this->childs[0] = array();
36 }

Member Function Documentation

◆ addListNode()

ilNestedList::addListNode ( string  $a_content,
string  $a_id,
  $a_parent = 0 
)

Definition at line 60 of file class.ilNestedList.php.

64 : void {
65 $this->nodes[$a_id] = $a_content;
66 $this->childs[$a_parent][] = $a_id;
67 }

◆ getAutoNumbering()

ilNestedList::getAutoNumbering ( )

Definition at line 74 of file class.ilNestedList.php.

74 : bool
75 {
77 }

◆ getHTML()

ilNestedList::getHTML ( )

Definition at line 84 of file class.ilNestedList.php.

84 : string
85 {
86 $tpl = new ilTemplate("tpl.nested_list.html", true, true, "Services/UIComponent/NestedList");
87
88 $nr = array();
89 $depth = 1;
90 if (isset($this->childs[0]) && count($this->childs[0]) > 0) {
91 $this->listStart($tpl, $depth);
92 foreach ($this->childs[0] as $child) {
93 $this->renderNode($child, $tpl, $depth, $nr);
94 }
95 $this->listEnd($tpl);
96 }
97
98 return $tpl->get();
99 }
listStart(ilTemplate $tpl, int $depth)
listEnd(ilTemplate $tpl)
renderNode( $a_id, ilTemplate $tpl, int $depth, array &$nr)
special template class to simplify handling of ITX/PEAR
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41

References $tpl.

◆ getItemClass()

ilNestedList::getItemClass ( )

Definition at line 44 of file class.ilNestedList.php.

44 : string
45 {
46 return $this->item_class;
47 }

References $item_class.

◆ getListClass()

ilNestedList::getListClass ( int  $a_depth = 0)

Definition at line 55 of file class.ilNestedList.php.

55 : string
56 {
57 return $this->list_class[$a_depth] ?? "";
58 }

◆ getNumbers()

ilNestedList::getNumbers ( )

Definition at line 79 of file class.ilNestedList.php.

79 : array
80 {
81 return $this->nr;
82 }

◆ listEnd()

ilNestedList::listEnd ( ilTemplate  $tpl)

Definition at line 177 of file class.ilNestedList.php.

177 : void
178 {
179 //echo "<br>listEnd";
180 $tpl->touchBlock("list_end");
181 $tpl->touchBlock("tag");
182 }

References $tpl.

◆ listItemEnd()

ilNestedList::listItemEnd ( ilTemplate  $tpl)

Definition at line 153 of file class.ilNestedList.php.

153 : void
154 {
155 $tpl->touchBlock("list_item_end");
156 $tpl->touchBlock("tag");
157 }

References $tpl.

◆ listItemStart()

ilNestedList::listItemStart ( ilTemplate  $tpl)

Definition at line 141 of file class.ilNestedList.php.

141 : void
142 {
143 if ($this->getItemClass() !== "") {
144 $tpl->setCurrentBlock("list_item_start");
145 $tpl->setVariable("LI_CLASS", ' class="' . $this->getItemClass() . '" ');
146 $tpl->parseCurrentBlock();
147 } else {
148 $tpl->touchBlock("list_item_start");
149 }
150 $tpl->touchBlock("tag");
151 }
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)

References $tpl.

◆ listStart()

ilNestedList::listStart ( ilTemplate  $tpl,
int  $depth 
)

Definition at line 159 of file class.ilNestedList.php.

159 : void
160 {
161 //echo "<br>listStart";
162
163 $class = ($this->getListClass($depth) !== "")
164 ? $this->getListClass($depth)
165 : $this->getListClass();
166 //echo "-$class-";
167 if ($class !== "") {
168 $tpl->setCurrentBlock("list_start");
169 $tpl->setVariable("UL_CLASS", ' class="' . $class . '" ');
170 $tpl->parseCurrentBlock();
171 } else {
172 $tpl->touchBlock("list_start");
173 }
174 $tpl->touchBlock("tag");
175 }
getListClass(int $a_depth=0)

References $tpl.

◆ renderNode()

ilNestedList::renderNode (   $a_id,
ilTemplate  $tpl,
int  $depth,
array &  $nr 
)

Definition at line 101 of file class.ilNestedList.php.

106 : void {
107 if (!isset($nr[$depth])) {
108 $nr[$depth] = 1;
109 } else {
110 $nr[$depth]++;
111 }
112
113 $nr_str = $sep = "";
114 if ($this->getAutoNumbering()) {
115 for ($i = 1; $i <= $depth; $i++) {
116 $nr_str .= $sep . $nr[$i];
117 $sep = ".";
118 }
119 }
120
121 $this->listItemStart($tpl);
122 $tpl->setCurrentBlock("content");
123 $tpl->setVariable("CONTENT", $nr_str . " " . $this->nodes[$a_id]);
124 $this->nr[$a_id] = $nr_str;
125 //echo "<br>".$this->nodes[$a_id];
126 $tpl->parseCurrentBlock();
127 $tpl->touchBlock("tag");
128
129 if (isset($this->childs[$a_id]) && count($this->childs[$a_id]) > 0) {
130 $this->listStart($tpl, $depth + 1);
131 foreach ($this->childs[$a_id] as $child) {
132 $this->renderNode($child, $tpl, $depth + 1, $nr);
133 }
134 $this->listEnd($tpl);
135 }
136 unset($nr[$depth + 1]);
137
138 $this->listItemEnd($tpl);
139 }
listItemStart(ilTemplate $tpl)
listItemEnd(ilTemplate $tpl)
$i
Definition: metadata.php:41

◆ setAutoNumbering()

ilNestedList::setAutoNumbering ( bool  $a_val)

Definition at line 69 of file class.ilNestedList.php.

69 : void
70 {
71 $this->auto_numbering = $a_val;
72 }

◆ setItemClass()

ilNestedList::setItemClass ( string  $a_val)

Definition at line 39 of file class.ilNestedList.php.

39 : void
40 {
41 $this->item_class = $a_val;
42 }

◆ setListClass()

ilNestedList::setListClass ( string  $a_val,
int  $a_depth = 0 
)

Definition at line 50 of file class.ilNestedList.php.

50 : void
51 {
52 $this->list_class[$a_depth] = $a_val;
53 }

Field Documentation

◆ $auto_numbering

bool ilNestedList::$auto_numbering = false
protected

Definition at line 27 of file class.ilNestedList.php.

◆ $childs

array ilNestedList::$childs = []
protected

Definition at line 30 of file class.ilNestedList.php.

◆ $item_class

string ilNestedList::$item_class = "il_Explorer"
protected

Definition at line 25 of file class.ilNestedList.php.

Referenced by getItemClass().

◆ $list_class

array ilNestedList::$list_class = array()
protected

Definition at line 26 of file class.ilNestedList.php.

◆ $nodes

array ilNestedList::$nodes = []
protected

Definition at line 29 of file class.ilNestedList.php.

◆ $nr

array ilNestedList::$nr = array()
protected

Definition at line 28 of file class.ilNestedList.php.


The documentation for this class was generated from the following file: