ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCheckboxListOverlayGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
11 {
12  private $items = array();
13 
14  const DOWN_ARROW_LIGHT = "mm_down_arrow.gif";
15  const DOWN_ARROW_DARK = "mm_down_arrow_dark.gif";
16  const NO_ICON = "";
17 
18 
23  public function __construct($a_id = "")
24  {
26  $this->setId($a_id);
27  }
28 
34  function setId($a_val)
35  {
36  $this->id = $a_val;
37  }
38 
44  function getId()
45  {
46  return $this->id;
47  }
48 
54  function setHeaderIcon($a_headericon)
55  {
56  $this->headericon = $a_headericon;
57  }
58 
64  function getHeaderIcon()
65  {
66  return $this->headericon;
67  }
68 
74  function setLinkTitle($a_val)
75  {
76  $this->link_title = $a_val;
77  }
78 
84  function getLinkTitle()
85  {
86  return $this->link_title;
87  }
88 
94  function setItems($a_val)
95  {
96  $this->items = $a_val;
97  }
98 
104  function getItems()
105  {
106  return $this->items;
107  }
108 
114  function setUrl($a_val)
115  {
116  $this->url = $a_val;
117  }
118 
124  function getUrl()
125  {
126  return $this->url;
127  }
128 
134  function setSelectionHeaderClass($a_selectionheaderclass)
135  {
136  $this->selectionheaderclass = $a_selectionheaderclass;
137  }
138 
145  {
146  return $this->selectionheaderclass;
147  }
148 
154  function setFormCmd($a_val)
155  {
156  $this->form_cmd = $a_val;
157  }
158 
164  function getFormCmd()
165  {
166  return $this->form_cmd;
167  }
168 
174  function setFieldVar($a_val)
175  {
176  $this->field_var = $a_val;
177  }
178 
184  function getFieldVar()
185  {
186  return $this->field_var;
187  }
188 
194  function setHiddenVar($a_val)
195  {
196  $this->hidden_var = $a_val;
197  }
198 
204  function getHiddenVar()
205  {
206  return $this->hidden_var;
207  }
211  public function getHTML()
212  {
213  global $lng;
214 
215  $items = $this->getItems();
216 
217  $GLOBALS["tpl"]->addJavascript("./Services/UIComponent/CheckboxListOverlay/js/ilCheckboxListOverlay.js");
218 
219  include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
220  $overlay = new ilOverlayGUI("ilChkboxListOverlay_".$this->getId());
221  $overlay->setAnchor("ilChkboxListAnchorEl_".$this->getId());
222  $overlay->setTrigger("ilChkboxListTrigger_".$this->getId());
223  //$overlay->setSize("300px", "300px");
224  $overlay->add();
225 
226  $tpl = new ilTemplate("tpl.checkbox_list_overlay.html", true, true,
227  "Services/UIComponent/CheckboxListOverlay", "DEFAULT", false, true);
228 
229  $tpl->setCurrentBlock("top_img");
230  switch ($this->getHeaderIcon())
231  {
233  $tpl->setVariable("IMG_DOWN",
235  break;
237  $tpl->setVariable("IMG_DOWN",
239  break;
240  default:
241  $tpl->setVariable("IMG_DOWN", $this->getHeaderIcon());
242  break;
243  }
244  // do not repeat title (accessibility) -> empty alt
245  $tpl->setVariable("TXT_SEL_TOP", $this->getLinkTitle());
246  $tpl->setVariable("ALT_SEL_TOP", "");
247  $tpl->setVariable("CLASS_SEL_TOP", $this->getSelectionHeaderClass());
248  $tpl->parseCurrentBlock();
249 
250  reset($items);
251  foreach ($items as $k => $v)
252  {
253  $tpl->setCurrentBlock("list_entry");
254  $tpl->setVariable("VAR", $this->getFieldVar());
255  $tpl->setVariable("VAL_ENTRY", $k);
256  $tpl->setVariable("TXT_ENTRY", $v["txt"]);
257  if ($v["selected"])
258  {
259  $tpl->setVariable("CHECKED", "checked='checked'");
260  }
261  $tpl->parseCurrentBlock();
262  }
263 
264  if ($this->getUrl() != "")
265  {
266  $tpl->setVariable("ONCLICK",
267  "onclick=\"return ilCheckboxListOverlay.save('".
268  $this->getUrl()."', '".$this->getFieldVar()."');\"");
269  }
270  $tpl->setVariable("ID", $this->getId());
271  $tpl->setVariable("HIDDEN_VAR", $this->getHiddenVar());
272  $tpl->setVariable("CMD_SUBMIT", $this->getFormCmd());
273  $tpl->setVariable("VAL_SUBMIT", $lng->txt("refresh"));
274  return $tpl->get();
275  }
276 }
277 ?>