ILIAS  release_7 Revision v7.30-3-g800a261c036
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
5include_once 'Services/UIComponent/Toolbar/interfaces/interface.ilToolbarItem.php';
6
15{
16 protected $value = "1";
17 protected $checked;
18 protected $list_nodes = array();
19
26 public function __construct($a_title = "", $a_postvar = "")
27 {
28 global $DIC;
29
30 $this->lng = $DIC->language();
31 parent::__construct($a_title, $a_postvar);
32 $this->setType("nested_list");
33
34 include_once("./Services/UIComponent/NestedList/classes/class.ilNestedList.php");
35 $this->list = new ilNestedList();
36 $this->list->setListClass("il_Explorer");
37 }
38
44 public function addListNode(
45 $a_id,
46 $a_text,
47 $a_parent = 0,
48 $a_checked = false,
49 $a_disabled = false,
50 $a_img_src = "",
51 $a_img_alt = "",
52 $a_post_var = ""
53 ) {
54 $this->list_nodes[$a_id] = array("text" => $a_text,
55 "parent" => $a_parent, "checked" => $a_checked, "disabled" => $a_disabled,
56 "img_src" => $a_img_src, "img_alt" => $a_img_alt, "post_var" => $a_post_var);
57 }
58
64 public function setValue($a_value)
65 {
66 $this->value = $a_value;
67 }
68
74 public function getValue()
75 {
76 return $this->value;
77 }
78
84 public function setValueByArray($a_values)
85 {
86 // $this->setChecked($a_values[$this->getPostVar()]);
87// foreach($this->getSubItems() as $item)
88// {
89// $item->setValueByArray($a_values);
90// }
91 }
92
98 public function checkInput()
99 {
101
102 return true;
103 }
104
108 public function render()
109 {
110 foreach ($this->list_nodes as $id => $n) {
111 if ($n["post_var"] == "") {
112 $post_var = $this->getPostVar() . "[]";
113 $value = $id;
114 } else {
115 $post_var = $n["post_var"];
116 $value = $id;
117 }
118 $item_html = ilUtil::formCheckbox(
119 $n["checked"],
120 $post_var,
121 $value,
122 $n["disabled"]
123 );
124 if ($n["img_src"] != "") {
125 $item_html .= ilUtil::img($n["img_src"], $n["img_alt"]) . " ";
126 }
127 $item_html .= $n["text"];
128
129 $this->list->addListNode($item_html, $id, $n["parent"]);
130 }
131
132 return $this->list->getHTML();
133 }
134
140 public function insert($a_tpl)
141 {
142 $html = $this->render();
143
144 $a_tpl->setCurrentBlock("prop_generic");
145 $a_tpl->setVariable("PROP_GENERIC", $html);
146 $a_tpl->parseCurrentBlock();
147 }
148}
$n
Definition: RandomTest.php:85
An exception for terminatinating execution or to throw for unit testing.
This class represents a property in a property form.
setType($a_type)
Set Type.
getPostVar()
Get Post Variable.
This class represents a (nested) list of checkboxes (could be extended for radio items,...
__construct($a_title="", $a_postvar="")
Constructor.
insert($a_tpl)
Insert property html.
setValueByArray($a_values)
Set value by array.
addListNode( $a_id, $a_text, $a_parent=0, $a_checked=false, $a_disabled=false, $a_img_src="", $a_img_alt="", $a_post_var="")
Add list node.
checkInput()
Check input, strip slashes etc.
static formCheckbox($checked, $varname, $value, $disabled=false)
??? @access public
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc