ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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

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

References array.

25  {
26  $this->list_class[0] = "il_Explorer";
27  $this->childs[0] = array();
28  }
Create styles array
The data for the language used.

◆ addListNode()

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

Add list node.

Parameters

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

References $a_content.

78  {
79  $this->nodes[$a_id] = $a_content;
80  $this->childs[$a_parent][] = $a_id;
81  }
$a_content
Definition: workflow.php:93

◆ getAutoNumbering()

ilNestedList::getAutoNumbering ( )

Get auto numbering.

Returns
bool auto numbering

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

References $auto_numbering.

Referenced by renderNode().

99  {
100  return $this->auto_numbering;
101  }
+ Here is the caller graph for this function:

◆ getHTML()

ilNestedList::getHTML ( )

Get HTML.

Parameters

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

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

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  $this->listStart($tpl, $depth);
128  foreach ($this->childs[0] as $child) {
129  $this->renderNode($child, $tpl, $depth, $nr);
130  }
131  $this->listEnd($tpl);
132  }
133 
134  return $tpl->get();
135  }
$tpl
Definition: ilias.php:10
renderNode($a_id, $tpl, $depth, &$nr)
Render node.
special template class to simplify handling of ITX/PEAR
listEnd($tpl)
List end.
Create styles array
The data for the language used.
listStart($tpl, $depth)
List start.
+ 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.

References $item_class.

Referenced by listItemStart().

46  {
47  return $this->item_class;
48  }
+ 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.

Referenced by listStart().

67  {
68  return $this->list_class[$a_depth];
69  }
+ 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.

References $nr.

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

◆ listEnd()

ilNestedList::listEnd (   $tpl)

List end.

Parameters

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

References $tpl.

Referenced by getHTML(), and renderNode().

240  {
241  //echo "<br>listEnd";
242  $tpl->touchBlock("list_end");
243  $tpl->touchBlock("tag");
244  }
$tpl
Definition: ilias.php:10
+ Here is the caller graph for this function:

◆ listItemEnd()

ilNestedList::listItemEnd (   $tpl)

List item end.

Parameters

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

References $tpl.

Referenced by renderNode().

204  {
205  $tpl->touchBlock("list_item_end");
206  $tpl->touchBlock("tag");
207  }
$tpl
Definition: ilias.php:10
+ Here is the caller graph for this function:

◆ listItemStart()

ilNestedList::listItemStart (   $tpl)

List item start.

Parameters

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

References $tpl, and getItemClass().

Referenced by renderNode().

186  {
187  if ($this->getItemClass() != "") {
188  $tpl->setCurrentBlock("list_item_start");
189  $tpl->setVariable("LI_CLASS", ' class="' . $this->getItemClass() . '" ');
190  $tpl->parseCurrentBlock();
191  } else {
192  $tpl->touchBlock("list_item_start");
193  }
194  $tpl->touchBlock("tag");
195  }
getItemClass()
Get li class.
$tpl
Definition: ilias.php:10
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ listStart()

ilNestedList::listStart (   $tpl,
  $depth 
)

List start.

Parameters

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

References $tpl, and getListClass().

Referenced by getHTML(), and renderNode().

216  {
217  //echo "<br>listStart";
218 
219  $class = ($this->getListClass($depth) != "")
220  ? $this->getListClass($depth)
221  : $this->getListClass();
222  //echo "-$class-";
223  if ($class != "") {
224  $tpl->setCurrentBlock("list_start");
225  $tpl->setVariable("UL_CLASS", ' class="' . $class . '" ');
226  $tpl->parseCurrentBlock();
227  } else {
228  $tpl->touchBlock("list_start");
229  }
230  $tpl->touchBlock("tag");
231  }
$tpl
Definition: ilias.php:10
getListClass($a_depth=0)
Get list class.
+ 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

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

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

Referenced by getHTML().

144  {
145  if (!isset($nr[$depth])) {
146  $nr[$depth] = 1;
147  } else {
148  $nr[$depth]++;
149  }
150 
151  $nr_str = $sep = "";
152  if ($this->getAutoNumbering()) {
153  for ($i = 1; $i <= $depth; $i++) {
154  $nr_str.= $sep . $nr[$i];
155  $sep = ".";
156  }
157  }
158 
159  $this->listItemStart($tpl);
160  $tpl->setCurrentBlock("content");
161  $tpl->setVariable("CONTENT", $nr_str . " " . $this->nodes[$a_id]);
162  $this->nr[$a_id] = $nr_str;
163  //echo "<br>".$this->nodes[$a_id];
164  $tpl->parseCurrentBlock();
165  $tpl->touchBlock("tag");
166 
167  if (is_array($this->childs[$a_id]) && count($this->childs[$a_id]) > 0) {
168  $this->listStart($tpl, $depth + 1);
169  foreach ($this->childs[$a_id] as $child) {
170  $this->renderNode($child, $tpl, $depth + 1, $nr);
171  }
172  $this->listEnd($tpl);
173  }
174  unset($nr[$depth + 1]);
175 
176  $this->listItemEnd($tpl);
177  }
listItemStart($tpl)
List item start.
$tpl
Definition: ilias.php:10
renderNode($a_id, $tpl, $depth, &$nr)
Render node.
listEnd($tpl)
List end.
listItemEnd($tpl)
List item end.
getAutoNumbering()
Get auto numbering.
$i
Definition: disco.tpl.php:19
listStart($tpl, $depth)
List start.
+ 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: