ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilNestedList Class Reference

Nested List. More...

+ Collaboration diagram for ilNestedList:

Public Member Functions

 __constructor ()
 Constructor. More...
 
 setItemClass ($a_val)
 Set li class. More...
 
 getItemClass ()
 Get li class. More...
 
 setListClass ($a_val, $a_depth=0)
 Set list class. More...
 
 getListClass ($a_depth=0)
 Get list class. More...
 
 addListNode ($a_content, $a_id, $a_parent=0)
 Add list node. More...
 
 setAutoNumbering ($a_val)
 Set auto numbering. More...
 
 getAutoNumbering ()
 Get auto numbering. More...
 
 getNumbers ()
 Get numbers. More...
 
 getHTML ()
 Get HTML. More...
 
 renderNode ($a_id, $tpl, $depth, &$nr)
 Render node. More...
 
 listItemStart ($tpl)
 List item start. More...
 
 listItemEnd ($tpl)
 List item end. More...
 
 listStart ($tpl, $depth)
 List start. More...
 
 listEnd ($tpl)
 List end. More...
 

Protected Attributes

 $item_class = "il_Explorer"
 
 $list_class = array()
 
 $auto_numbering = false
 
 $nr = array()
 

Detailed Description

Nested List.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Member Function Documentation

◆ __constructor()

ilNestedList::__constructor ( )

Constructor.

Parameters

return

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

25 {
26 $this->list_class[0] = "il_Explorer";
27 $this->childs[0] = array();
28 }

◆ addListNode()

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

Add list node.

Parameters

return

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

78 {
79 $this->nodes[$a_id] = $a_content;
80 $this->childs[$a_parent][] = $a_id;
81 }

◆ getAutoNumbering()

ilNestedList::getAutoNumbering ( )

Get auto numbering.

Returns
bool auto numbering

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

99 {
101 }

References $auto_numbering.

Referenced by renderNode().

+ Here is the caller graph for this function:

◆ getHTML()

ilNestedList::getHTML ( )

Get HTML.

Parameters

return

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

121 {
122 $tpl = new ilTemplate("tpl.nested_list.html", true, true, "Services/UIComponent/NestedList");
123
124 $nr = array();
125 $depth = 1;
126 if (is_array($this->childs[0]) && count($this->childs[0]) > 0)
127 {
128 $this->listStart($tpl, $depth);
129 foreach ($this->childs[0] as $child)
130 {
131 $this->renderNode($child, $tpl, $depth, $nr);
132 }
133 $this->listEnd($tpl);
134 }
135
136 return $tpl->get();
137 }
global $tpl
Definition: ilias.php:8
listEnd($tpl)
List end.
listStart($tpl, $depth)
List start.
renderNode($a_id, $tpl, $depth, &$nr)
Render node.
special template class to simplify handling of ITX/PEAR

References $nr, $tpl, listEnd(), listStart(), and renderNode().

+ Here is the call graph for this function:

◆ getItemClass()

ilNestedList::getItemClass ( )

Get li class.

Returns
string li class

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

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

References $item_class.

Referenced by listItemStart().

+ Here is the caller graph for this function:

◆ getListClass()

ilNestedList::getListClass (   $a_depth = 0)

Get list class.

Returns
string list class

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

67 {
68 return $this->list_class[$a_depth];
69 }

Referenced by listStart().

+ Here is the caller graph for this function:

◆ getNumbers()

ilNestedList::getNumbers ( )

Get numbers.

Returns
array number array

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

109 {
110 return $this->nr;
111 }

References $nr.

◆ listEnd()

ilNestedList::listEnd (   $tpl)

List end.

Parameters

return

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

255 {
256//echo "<br>listEnd";
257 $tpl->touchBlock("list_end");
258 $tpl->touchBlock("tag");
259 }

References $tpl.

Referenced by getHTML(), and renderNode().

+ Here is the caller graph for this function:

◆ listItemEnd()

ilNestedList::listItemEnd (   $tpl)

List item end.

Parameters

return

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

216 {
217 $tpl->touchBlock("list_item_end");
218 $tpl->touchBlock("tag");
219 }

References $tpl.

Referenced by renderNode().

+ Here is the caller graph for this function:

◆ listItemStart()

ilNestedList::listItemStart (   $tpl)

List item start.

Parameters

return

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

195 {
196 if ($this->getItemClass() != "")
197 {
198 $tpl->setCurrentBlock("list_item_start");
199 $tpl->setVariable("LI_CLASS", ' class="'.$this->getItemClass().'" ');
200 $tpl->parseCurrentBlock();
201 }
202 else
203 {
204 $tpl->touchBlock("list_item_start");
205 }
206 $tpl->touchBlock("tag");
207 }
getItemClass()
Get li class.

References $tpl, and getItemClass().

Referenced by renderNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listStart()

ilNestedList::listStart (   $tpl,
  $depth 
)

List start.

Parameters

return

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

228 {
229//echo "<br>listStart";
230
231 $class = ($this->getListClass($depth) != "")
232 ? $this->getListClass($depth)
233 : $this->getListClass();
234//echo "-$class-";
235 if ($class != "")
236 {
237 $tpl->setCurrentBlock("list_start");
238 $tpl->setVariable("UL_CLASS", ' class="'.$class.'" ');
239 $tpl->parseCurrentBlock();
240 }
241 else
242 {
243 $tpl->touchBlock("list_start");
244 }
245 $tpl->touchBlock("tag");
246 }
getListClass($a_depth=0)
Get list class.

References $tpl, and getListClass().

Referenced by getHTML(), and renderNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderNode()

ilNestedList::renderNode (   $a_id,
  $tpl,
  $depth,
$nr 
)

Render node.

Parameters

return

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

146 {
147 if (!isset($nr[$depth]))
148 {
149 $nr[$depth] = 1;
150 }
151 else
152 {
153 $nr[$depth]++;
154 }
155
156 $nr_str = $sep = "";
157 if ($this->getAutoNumbering())
158 {
159 for($i = 1; $i <= $depth; $i++)
160 {
161 $nr_str.= $sep.$nr[$i];
162 $sep = ".";
163 }
164 }
165
166 $this->listItemStart($tpl);
167 $tpl->setCurrentBlock("content");
168 $tpl->setVariable("CONTENT", $nr_str." ".$this->nodes[$a_id]);
169 $this->nr[$a_id] = $nr_str;
170//echo "<br>".$this->nodes[$a_id];
171 $tpl->parseCurrentBlock();
172 $tpl->touchBlock("tag");
173
174 if (is_array($this->childs[$a_id]) && count($this->childs[$a_id]) > 0)
175 {
176 $this->listStart($tpl, $depth + 1);
177 foreach ($this->childs[$a_id] as $child)
178 {
179 $this->renderNode($child, $tpl, $depth + 1, $nr);
180 }
181 $this->listEnd($tpl);
182 }
183 unset($nr[$depth + 1]);
184
185 $this->listItemEnd($tpl);
186 }
listItemEnd($tpl)
List item end.
listItemStart($tpl)
List item start.
getAutoNumbering()
Get auto numbering.

References $nr, $tpl, getAutoNumbering(), listEnd(), listItemEnd(), listItemStart(), listStart(), and renderNode().

Referenced by getHTML(), and renderNode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAutoNumbering()

ilNestedList::setAutoNumbering (   $a_val)

Set auto numbering.

Parameters
bool$a_valauto numbering

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

89 {
90 $this->auto_numbering = $a_val;
91 }

◆ setItemClass()

ilNestedList::setItemClass (   $a_val)

Set li class.

Parameters
stringli class

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

36 {
37 $this->item_class = $a_val;
38 }

◆ setListClass()

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

Set list class.

Parameters
stringlist class

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

56 {
57//var_dump($a_val);
58 $this->list_class[$a_depth] = $a_val;
59 }

Field Documentation

◆ $auto_numbering

ilNestedList::$auto_numbering = false
protected

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

Referenced by getAutoNumbering().

◆ $item_class

ilNestedList::$item_class = "il_Explorer"
protected

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

Referenced by getItemClass().

◆ $list_class

ilNestedList::$list_class = array()
protected

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

◆ $nr

ilNestedList::$nr = array()
protected

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

Referenced by getHTML(), getNumbers(), and renderNode().


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