ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilNestedListInputGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once 'Services/UIComponent/Toolbar/interfaces/interface.ilToolbarItem.php';
6 
15 {
16  protected $value = "1";
17  protected $checked;
18  protected $list_nodes = array();
19 
26  function __construct($a_title = "", $a_postvar = "")
27  {
28  parent::__construct($a_title, $a_postvar);
29  $this->setType("nested_list");
30 
31  include_once("./Services/UIComponent/NestedList/classes/class.ilNestedList.php");
32  $this->list = new ilNestedList();
33  }
34 
40  function addListNode($a_id, $a_text, $a_parent = 0, $a_checked = false, $a_disabled = false,
41  $a_img_src = "", $a_img_alt = "", $a_post_var = "")
42  {
43  $this->list_nodes[$a_id] = array("text" => $a_text,
44  "parent" => $a_parent, "checked" => $a_checked, "disabled" => $a_disabled,
45  "img_src" => $a_img_src, "img_alt" => $a_img_alt, "post_var" => $a_post_var);
46  }
47 
53  function setValue($a_value)
54  {
55  $this->value = $a_value;
56  }
57 
63  function getValue()
64  {
65  return $this->value;
66  }
67 
73  function setValueByArray($a_values)
74  {
75 // $this->setChecked($a_values[$this->getPostVar()]);
76 // foreach($this->getSubItems() as $item)
77 // {
78 // $item->setValueByArray($a_values);
79 // }
80  }
81 
87  function checkInput()
88  {
89  global $lng;
90 
91  return true;
92  }
93 
97  function render()
98  {
99  foreach ($this->list_nodes as $id => $n)
100  {
101  if ($n["post_var"] == "")
102  {
103  $post_var = $this->getPostVar()."[]";
104  $value = $id;
105  }
106  else
107  {
108  $post_var = $n["post_var"];
109  $value = $id;
110  }
111  $item_html = ilUtil::formCheckbox($n["checked"], $post_var, $value,
112  $n["disabled"]);
113  if ($n["img_src"] != "")
114  {
115  $item_html.= ilUtil::img($n["img_src"], $n["img_alt"])." ";
116  }
117  $item_html.= $n["text"];
118 
119  $this->list->addListNode($item_html, $id, $n["parent"]);
120  }
121 
122  return $this->list->getHTML();
123  }
124 
130  function insert(&$a_tpl)
131  {
132  $html = $this->render();
133 
134  $a_tpl->setCurrentBlock("prop_generic");
135  $a_tpl->setVariable("PROP_GENERIC", $html);
136  $a_tpl->parseCurrentBlock();
137  }
138 
139 }