ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilGroupedListGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
17 protected $ctrl;
18
19 protected $multi_column = false;
20 protected $items = array();
21 protected $as_dropdown = false;
22 protected $dd_pullright = false;
23
27 public function __construct()
28 {
29 global $DIC;
30
31 $this->ctrl = $DIC->ctrl();
32 }
33
39 public function setAsDropDown($a_val, $a_pullright = false)
40 {
41 $this->as_dropdown = $a_val;
42 $this->dd_pullright = $a_pullright;
43 }
44
50 public function getAsDropDown()
51 {
52 return $this->as_dropdown;
53 }
54
61 public function addGroupHeader($a_content, $a_add_class = "")
62 {
63 $this->items[] = array("type" => "group_head", "content" => $a_content,
64 "add_class" => $a_add_class);
65 }
66
70 public function addSeparator()
71 {
72 $this->items[] = array("type" => "sep");
73 }
74
78 public function nextColumn()
79 {
80 $this->items[] = array("type" => "next_col");
81 $this->multi_column = true;
82 }
83
90 public function addEntry(
92 $a_href="",
93 $a_target="",
94 $a_onclick="",
95 $a_add_class = "",
96 $a_id = "",
97 $a_ttip = "",
98 $a_tt_my = "right center",
99 $a_tt_at = "left center",
100 $a_tt_use_htmlspecialchars = true
101 ) {
102 $this->items[] = array("type" => "entry", "content" => $a_content,
103 "href" => $a_href, "target" => $a_target, "onclick" => $a_onclick,
104 "add_class" => $a_add_class, "id" => $a_id, "ttip" => $a_ttip,
105 "tt_my" => $a_tt_my, "tt_at" => $a_tt_at,
106 "tt_use_htmlspecialchars" => $a_tt_use_htmlspecialchars);
107 }
108
109
116 public function getHTML()
117 {
119
120 $tpl = new ilTemplate("tpl.grouped_list.html", true, true, "Services/UIComponent/GroupedList");
121 $tt_calls = "";
122 foreach ($this->items as $i) {
123 switch ($i["type"]) {
124 case "sep":
125 $tpl->touchBlock("sep");
126 $tpl->touchBlock("item");
127 break;
128
129 case "next_col":
130 $tpl->touchBlock("next_col");
131 $tpl->touchBlock("item");
132 break;
133
134 case "group_head":
135 $tpl->setCurrentBlock("group_head");
136 if ($i["add_class"] != "") {
137 $tpl->setVariable("ADD_CLASS", $i["add_class"]);
138 }
139 $tpl->setVariable("GROUP_HEAD", $i["content"]);
140 $tpl->parseCurrentBlock();
141 $tpl->touchBlock("item");
142 break;
143
144 case "entry":
145 if ($i["href"] != "") {
146 $tpl->setCurrentBlock("linked_entry");
147 if ($i["add_class"] != "") {
148 $tpl->setVariable("ADD_CLASS", $i["add_class"]);
149 }
150 $tpl->setVariable("HREF", str_replace('&amp;', '&', ilUtil::secureUrl($i["href"])));
151 $tpl->setVariable("TXT_ENTRY", $i["content"]);
152 if ($i["target"] != "") {
153 $tpl->setVariable("TARGET", 'target="' . $i["target"] . '"');
154 } else {
155 $tpl->setVariable("TARGET", 'target="_top"');
156 }
157 if ($i["onclick"] != "") {
158 $tpl->setVariable("ONCLICK", 'onclick="' . $i["onclick"] . '"');
159 }
160 if ($i["id"] != "") {
161 $tpl->setVariable("ID", 'id="' . $i["id"] . '"');
162 }
163 $tpl->parseCurrentBlock();
164 $tpl->touchBlock("item");
165 if ($i["ttip"] != "" && $i["id"] != "") {
166 include_once("./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
167 if ($ilCtrl->isAsynch()) {
168 $tt_calls.= " " . ilTooltipGUI::getTooltip(
169 $i["id"],
170 $i["ttip"],
171 "",
172 $i["tt_my"],
173 $i["tt_at"],
174 $i["tt_use_htmlspecialchars"]
175 );
176 } else {
178 $i["id"],
179 $i["ttip"],
180 "",
181 $i["tt_my"],
182 $i["tt_at"],
183 $i["tt_use_htmlspecialchars"]
184 );
185 }
186 }
187 } else {
188 $tpl->setCurrentBlock("unlinked_entry");
189 if ($i["add_class"] != "") {
190 $tpl->setVariable("ADD_CLASS2", $i["add_class"]);
191 }
192 $tpl->setVariable("TXT_ENTRY2", $i["content"]);
193 $tpl->parseCurrentBlock();
194 }
195 break;
196 }
197 }
198
199 if ($this->multi_column) {
200 $tpl->touchBlock("multi_start");
201 $tpl->touchBlock("multi_end");
202 }
203
204 if ($tt_calls != "") {
205 $tpl->setCurrentBlock("script");
206 $tpl->setVariable("TT_CALLS", $tt_calls);
207 $tpl->parseCurrentBlock();
208 }
209
210 if ($this->getAsDropDown()) {
211 if ($this->dd_pullright) {
212 $tpl->setVariable("LIST_CLASS", "dropdown-menu pull-right");
213 } else {
214 $tpl->setVariable("LIST_CLASS", "dropdown-menu");
215 }
216 $tpl->setVariable("LIST_ROLE", "menu");
217 } else {
218 $tpl->setVariable("LIST_CLASS", "");
219 $tpl->setVariable("LIST_ROLE", "");
220 }
221
222 return $tpl->get();
223 }
224}
$tpl
Definition: ilias.php:10
An exception for terminatinating execution or to throw for unit testing.
Grouped list GUI class.
addSeparator()
Add separator.
setAsDropDown($a_val, $a_pullright=false)
Set as drop down.
nextColumn()
Add separator.
getAsDropDown()
Get as drop down.
addEntry( $a_content, $a_href="", $a_target="", $a_onclick="", $a_add_class="", $a_id="", $a_ttip="", $a_tt_my="right center", $a_tt_at="left center", $a_tt_use_htmlspecialchars=true)
Add entry.
addGroupHeader($a_content, $a_add_class="")
Add group header.
special template class to simplify handling of ITX/PEAR
static addTooltip( $a_el_id, $a_text, $a_container="", $a_my="bottom center", $a_at="top center", $a_use_htmlspecialchars=true)
Adds a tooltip to an HTML element.
static secureUrl($url)
Prepare secure href attribute.
$i
Definition: disco.tpl.php:19
global $ilCtrl
Definition: ilias.php:18
global $DIC
Definition: saml.php:7
$a_content
Definition: workflow.php:93