ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 {
14  protected $multi_column = false;
15  protected $items = array();
16  protected $as_dropdown = false;
17  protected $dd_pullright = false;
18 
22  function __construct()
23  {
24  }
25 
31  function setAsDropDown($a_val, $a_pullright = false)
32  {
33  $this->as_dropdown = $a_val;
34  $this->dd_pullright = $a_pullright;
35  }
36 
42  function getAsDropDown()
43  {
44  return $this->as_dropdown;
45  }
46 
53  function addGroupHeader($a_content, $a_add_class = "")
54  {
55  $this->items[] = array("type" => "group_head", "content" => $a_content,
56  "add_class" => $a_add_class);
57  }
58 
62  function addSeparator()
63  {
64  $this->items[] = array("type" => "sep");
65  }
66 
70  function nextColumn()
71  {
72  $this->items[] = array("type" => "next_col");
73  $this->multi_column = true;
74  }
75 
82  function addEntry($a_content, $a_href="", $a_target="", $a_onclick="", $a_add_class = "",
83  $a_id = "", $a_ttip = "", $a_tt_my = "right center", $a_tt_at = "left center",
84  $a_tt_use_htmlspecialchars = true)
85  {
86  $this->items[] = array("type" => "entry", "content" => $a_content,
87  "href" => $a_href, "target" => $a_target, "onclick" => $a_onclick,
88  "add_class" => $a_add_class, "id" => $a_id, "ttip" => $a_ttip,
89  "tt_my" => $a_tt_my, "tt_at" => $a_tt_at,
90  "tt_use_htmlspecialchars" => $a_tt_use_htmlspecialchars);
91  }
92 
93 
100  function getHTML()
101  {
102  global $ilCtrl;
103 
104  $tpl = new ilTemplate("tpl.grouped_list.html", true, true, "Services/UIComponent/GroupedList");
105  $tt_calls = "";
106  foreach ($this->items as $i)
107  {
108  switch($i["type"])
109  {
110  case "sep":
111  $tpl->touchBlock("sep");
112  $tpl->touchBlock("item");
113  break;
114 
115  case "next_col":
116  $tpl->touchBlock("next_col");
117  $tpl->touchBlock("item");
118  break;
119 
120  case "group_head":
121  $tpl->setCurrentBlock("group_head");
122  if ($i["add_class"] != "")
123  {
124  $tpl->setVariable("ADD_CLASS", $i["add_class"]);
125  }
126  $tpl->setVariable("GROUP_HEAD", $i["content"]);
127  $tpl->parseCurrentBlock();
128  $tpl->touchBlock("item");
129  break;
130 
131  case "entry":
132  if ($i["href"] != "")
133  {
134  $tpl->setCurrentBlock("linked_entry");
135  if ($i["add_class"] != "")
136  {
137  $tpl->setVariable("ADD_CLASS", $i["add_class"]);
138  }
139  $tpl->setVariable("HREF", str_replace('&amp;', '&', ilUtil::secureUrl($i["href"])));
140  $tpl->setVariable("TXT_ENTRY", $i["content"]);
141  if ($i["target"] != "")
142  {
143  $tpl->setVariable("TARGET", 'target="'.$i["target"].'"');
144  }
145  else
146  {
147  $tpl->setVariable("TARGET", 'target="_top"');
148  }
149  if ($i["onclick"] != "")
150  {
151  $tpl->setVariable("ONCLICK", 'onclick="'.$i["onclick"].'"');
152  }
153  if ($i["id"] != "")
154  {
155  $tpl->setVariable("ID", 'id="'.$i["id"].'"');
156  }
157  $tpl->parseCurrentBlock();
158  $tpl->touchBlock("item");
159  if ($i["ttip"] != "" && $i["id"] != "")
160  {
161  include_once("./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
162  if ($ilCtrl->isAsynch())
163  {
164  $tt_calls.= " ".ilTooltipGUI::getTooltip($i["id"], $i["ttip"],
165  "", $i["tt_my"], $i["tt_at"], $i["tt_use_htmlspecialchars"]);
166  }
167  else
168  {
169  ilTooltipGUI::addTooltip($i["id"], $i["ttip"],
170  "", $i["tt_my"], $i["tt_at"], $i["tt_use_htmlspecialchars"]);
171  }
172  }
173 
174  }
175  else
176  {
177  $tpl->setCurrentBlock("unlinked_entry");
178  if ($i["add_class"] != "")
179  {
180  $tpl->setVariable("ADD_CLASS2", $i["add_class"]);
181  }
182  $tpl->setVariable("TXT_ENTRY2", $i["content"]);
183  $tpl->parseCurrentBlock();
184  }
185  break;
186  }
187  }
188 
189  if ($this->multi_column)
190  {
191  $tpl->touchBlock("multi_start");
192  $tpl->touchBlock("multi_end");
193  }
194 
195  if ($tt_calls != "")
196  {
197  $tpl->setCurrentBlock("script");
198  $tpl->setVariable("TT_CALLS", $tt_calls);
199  $tpl->parseCurrentBlock();
200  }
201 
202  if ($this->getAsDropDown())
203  {
204  if ($this->dd_pullright)
205  {
206  $tpl->setVariable("LIST_CLASS", "dropdown-menu pull-right");
207  }
208  else
209  {
210  $tpl->setVariable("LIST_CLASS", "dropdown-menu");
211  }
212  $tpl->setVariable("LIST_ROLE", "menu");
213  }
214  else
215  {
216  $tpl->setVariable("LIST_CLASS", "");
217  $tpl->setVariable("LIST_ROLE", "");
218  }
219 
220  return $tpl->get();
221  }
222 
223 }
224 
225 ?>
setAsDropDown($a_val, $a_pullright=false)
Set as drop down.
getAsDropDown()
Get as drop down.
addSeparator()
Add separator.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
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.
$a_content
Definition: workflow.php:94
Grouped list GUI class.
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.
special template class to simplify handling of ITX/PEAR
addGroupHeader($a_content, $a_add_class="")
Add group header.
Create styles array
The data for the language used.
static secureUrl($url)
Prepare secure href attribute.
nextColumn()
Add separator.
__construct()
Constructor.