ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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
Deprecated:
with ILIAS 12

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

Constructor & Destructor Documentation

◆ __construct()

ilNestedList::__construct ( )

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

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

Member Function Documentation

◆ addListNode()

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

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

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

◆ getAutoNumbering()

ilNestedList::getAutoNumbering ( )

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

76 : bool
77 {
79 }

◆ getHTML()

ilNestedList::getHTML ( )

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

86 : string
87 {
88 $tpl = new ilTemplate("tpl.nested_list.html", true, true, "components/ILIAS/UIComponent/NestedList");
89
90 $nr = array();
91 $depth = 1;
92 if (isset($this->childs[0]) && count($this->childs[0]) > 0) {
93 $this->listStart($tpl, $depth);
94 foreach ($this->childs[0] as $child) {
95 $this->renderNode($child, $tpl, $depth, $nr);
96 }
97 $this->listEnd($tpl);
98 }
99
100 return $tpl->get();
101 }
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

◆ getItemClass()

ilNestedList::getItemClass ( )

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

46 : string
47 {
48 return $this->item_class;
49 }

References $item_class.

◆ getListClass()

ilNestedList::getListClass ( int  $a_depth = 0)

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

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

◆ getNumbers()

ilNestedList::getNumbers ( )

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

81 : array
82 {
83 return $this->nr;
84 }

◆ listEnd()

ilNestedList::listEnd ( ilTemplate  $tpl)

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

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

References ilTemplate\touchBlock().

+ Here is the call graph for this function:

◆ listItemEnd()

ilNestedList::listItemEnd ( ilTemplate  $tpl)

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

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

References ilTemplate\touchBlock().

+ Here is the call graph for this function:

◆ listItemStart()

ilNestedList::listItemStart ( ilTemplate  $tpl)

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

143 : void
144 {
145 if ($this->getItemClass() !== "") {
146 $tpl->setCurrentBlock("list_item_start");
147 $tpl->setVariable("LI_CLASS", ' class="' . $this->getItemClass() . '" ');
148 $tpl->parseCurrentBlock();
149 } else {
150 $tpl->touchBlock("list_item_start");
151 }
152 $tpl->touchBlock("tag");
153 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)

References ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), HTML_Template_IT\setVariable(), and ilTemplate\touchBlock().

+ Here is the call graph for this function:

◆ listStart()

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

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

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

References ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), HTML_Template_IT\setVariable(), and ilTemplate\touchBlock().

+ Here is the call graph for this function:

◆ renderNode()

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

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

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

◆ setAutoNumbering()

ilNestedList::setAutoNumbering ( bool  $a_val)

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

71 : void
72 {
73 $this->auto_numbering = $a_val;
74 }

◆ setItemClass()

ilNestedList::setItemClass ( string  $a_val)

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

41 : void
42 {
43 $this->item_class = $a_val;
44 }

◆ setListClass()

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

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

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

Field Documentation

◆ $auto_numbering

bool ilNestedList::$auto_numbering = false
protected

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

◆ $childs

array ilNestedList::$childs = []
protected

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

◆ $item_class

string ilNestedList::$item_class = "il_Explorer"
protected

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

Referenced by getItemClass().

◆ $list_class

array ilNestedList::$list_class = array()
protected

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

◆ $nodes

array ilNestedList::$nodes = []
protected

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

◆ $nr

array ilNestedList::$nr = array()
protected

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


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