ILIAS  release_7 Revision v7.30-3-g800a261c036
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 protected $id;
24
28 public function __construct($id = "")
29 {
30 global $DIC;
31
32 $this->id = $id;
33 $this->ctrl = $DIC->ctrl();
34 }
35
41 public function setAsDropDown($a_val, $a_pullright = false)
42 {
43 $this->as_dropdown = $a_val;
44 $this->dd_pullright = $a_pullright;
45 }
46
52 public function getAsDropDown()
53 {
54 return $this->as_dropdown;
55 }
56
63 public function addGroupHeader($a_content, $a_add_class = "")
64 {
65 $this->items[] = array("type" => "group_head", "content" => $a_content,
66 "add_class" => $a_add_class);
67 }
68
72 public function addSeparator()
73 {
74 $this->items[] = array("type" => "sep");
75 }
76
80 public function nextColumn()
81 {
82 $this->items[] = array("type" => "next_col");
83 $this->multi_column = true;
84 }
85
92 public function addEntry(
93 $a_content,
94 $a_href = "",
95 $a_target = "",
96 $a_onclick = "",
97 $a_add_class = "",
98 $a_id = "",
99 $a_ttip = "",
100 $a_tt_my = "right center",
101 $a_tt_at = "left center",
102 $a_tt_use_htmlspecialchars = true
103 ) {
104 $this->items[] = array("type" => "entry", "content" => $a_content,
105 "href" => $a_href, "target" => $a_target, "onclick" => $a_onclick,
106 "add_class" => $a_add_class, "id" => $a_id, "ttip" => $a_ttip,
107 "tt_my" => $a_tt_my, "tt_at" => $a_tt_at,
108 "tt_use_htmlspecialchars" => $a_tt_use_htmlspecialchars);
109 }
110
111
118 public function getHTML()
119 {
120 $ilCtrl = $this->ctrl;
121
122 $tpl = new ilTemplate("tpl.grouped_list.html", true, true, "Services/UIComponent/GroupedList");
123 $tt_calls = "";
124 foreach ($this->items as $i) {
125 switch ($i["type"]) {
126 case "sep":
127 $tpl->touchBlock("sep");
128 $tpl->touchBlock("item");
129 break;
130
131 case "next_col":
132 $tpl->touchBlock("next_col");
133 $tpl->touchBlock("item");
134 break;
135
136 case "group_head":
137 $tpl->setCurrentBlock("group_head");
138 if ($i["add_class"] != "") {
139 $tpl->setVariable("ADD_CLASS", $i["add_class"]);
140 }
141 $tpl->setVariable("GROUP_HEAD", $i["content"]);
142 $tpl->parseCurrentBlock();
143 $tpl->touchBlock("item");
144 break;
145
146 case "entry":
147 if ($i["href"] != "") {
148 $tpl->setCurrentBlock("linked_entry");
149 if ($i["add_class"] != "") {
150 $tpl->setVariable("ADD_CLASS", $i["add_class"]);
151 }
152 $tpl->setVariable("HREF", str_replace('&amp;', '&', ilUtil::secureUrl($i["href"])));
153 $tpl->setVariable("TXT_ENTRY", $i["content"]);
154 if ($i["target"] != "") {
155 $tpl->setVariable("TARGET", 'target="' . $i["target"] . '"');
156 } else {
157 $tpl->setVariable("TARGET", 'target="_top"');
158 }
159 if ($i["onclick"] != "") {
160 $tpl->setVariable("ONCLICK", 'onclick="' . $i["onclick"] . '"');
161 }
162 if ($i["id"] != "") {
163 $tpl->setVariable("ID", 'id="' . $i["id"] . '"');
164 }
165 $tpl->parseCurrentBlock();
166 $tpl->touchBlock("item");
167 if ($i["ttip"] != "" && $i["id"] != "") {
168 include_once("./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
169 if ($ilCtrl->isAsynch()) {
170 $tt_calls .= " " . ilTooltipGUI::getTooltip(
171 $i["id"],
172 $i["ttip"],
173 "",
174 $i["tt_my"],
175 $i["tt_at"],
176 $i["tt_use_htmlspecialchars"]
177 );
178 } else {
180 $i["id"],
181 $i["ttip"],
182 "",
183 $i["tt_my"],
184 $i["tt_at"],
185 $i["tt_use_htmlspecialchars"]
186 );
187 }
188 }
189 } else {
190 $tpl->setCurrentBlock("unlinked_entry");
191 if ($i["add_class"] != "") {
192 $tpl->setVariable("ADD_CLASS2", $i["add_class"]);
193 }
194 $tpl->setVariable("TXT_ENTRY2", $i["content"]);
195 $tpl->parseCurrentBlock();
196 }
197 break;
198 }
199 }
200
201 if ($this->multi_column) {
202 $tpl->touchBlock("multi_start");
203 $tpl->touchBlock("multi_end");
204 }
205
206 if ($tt_calls != "") {
207 $tpl->setCurrentBlock("script");
208 $tpl->setVariable("TT_CALLS", $tt_calls);
209 $tpl->parseCurrentBlock();
210 }
211
212 if ($this->id != "") {
213 $tpl->setCurrentBlock("id");
214 $tpl->setVariable("ID", $this->id);
215 $tpl->parseCurrentBlock();
216 }
217
218 if ($this->getAsDropDown()) {
219 if ($this->dd_pullright) {
220 $tpl->setVariable("LIST_CLASS", "dropdown-menu pull-right");
221 } else {
222 $tpl->setVariable("LIST_CLASS", "dropdown-menu");
223 }
224 $tpl->setVariable("LIST_ROLE", 'role="menu"');
225 } else {
226 $tpl->setVariable("LIST_CLASS", "");
227 $tpl->setVariable("LIST_ROLE", "");
228 }
229
230 return $tpl->get();
231 }
232}
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.
__construct($id="")
Constructor.
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.
global $DIC
Definition: goto.php:24
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$i
Definition: metadata.php:24