ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilYuiUtil.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 
11 class ilYuiUtil
12 {
13  private static $ver = "2_7_0b";
14 
18  static function initConnection()
19  {
20  global $tpl;
21 
22  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
23  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/connection/connection-min.js");
24  }
25 
29  static function initEvent()
30  {
31  global $tpl;
32 
33  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
34  }
35 
39  static function initDom()
40  {
41  global $tpl;
42 
43  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
44 
45  }
46 
50  static function initAnimation()
51  {
52  global $tpl;
53 
54  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
55  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
56  }
57 
61  static function initDragDrop()
62  {
63  global $tpl;
64 
65  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
66  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
67  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
68  }
69 
73  static function initDomEvent()
74  {
75  global $tpl;
76 
77  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
78  }
79 
87  public function initPanel()
88  {
89  global $tpl;
90 
91  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
92  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container-min.js");
93  $tpl->addCss("./Services/YUI/js/".self::$ver."/container/assets/skins/sam/container.css");
94  $tpl->addCss("./Services/Calendar/css/panel_min.css");
95 
96  }
97 
101  static function initConnectionWithAnimation()
102  {
103  global $tpl;
104 
105  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
106  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
107  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/connection/connection-min.js");
108  }
109 
113  static function initMenu()
114  {
115  global $tpl;
116 
117  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
118  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container_core.js");
119  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/menu/menu-min.js");
120  $tpl->addCss("./Services/YUI/js/".self::$ver."/menu/assets/menu.css");
121  }
122 
126  static function initOverlay()
127  {
128  global $tpl;
129 
130  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
131  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container_core-min.js");
132  }
133 
137  static function initSimpleDialog()
138  {
139  global $tpl;
140 
141  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
142  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container-min.js");
143  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
144  $tpl->addCss("./Services/YUI/js/".self::$ver."/container/assets/container.css");
145  $tpl->addCss("./Services/YUI/templates/default/tpl.simpledialog.css");
146  }
147 
151  static function initAssessmentWizard()
152  {
153  global $tpl;
154 
155  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
156  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
157  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/button/button-min.js");
158  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container-min.js");
159  $tpl->addCss("./Services/YUI/js/".self::$ver."/button/assets/skins/sam/button.css");
160  $tpl->addCss("./Services/YUI/js/".self::$ver."/container/assets/skins/sam/container.css");
161  }
162 
166  static function initDragDropList()
167  {
168  global $tpl;
169 
170  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
171  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
172  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
173  $tpl->addCss("./Services/YUI/templates/default/DragDropList.css");
174  }
175 
179  static function initDragDropAnimation()
180  {
181  global $tpl;
182 
183  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
184  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
185  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
186  }
187 
191  static function initElementSelection()
192  {
193  global $tpl;
194 
195  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
196  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
197  }
198 
202  static function getDragDropList($id_source, $title_source, $source, $id_dest, $title_dest, $dest)
203  {
205 
206  $template = new ilTemplate("tpl.dragdroplist.html", TRUE, TRUE, "Services/YUI");
207  foreach ($source as $id => $name)
208  {
209  $template->setCurrentBlock("source_element");
210  $template->setVariable("ELEMENT_ID", $id);
211  $template->setVariable("ELEMENT_NAME", $name);
212  $template->parseCurrentBlock();
213  $template->setCurrentBlock("element");
214  $template->setVariable("ELEMENT_ID", $id);
215  $template->parseCurrentBlock();
216  }
217  foreach ($dest as $id => $name)
218  {
219  $template->setCurrentBlock("dest_element");
220  $template->setVariable("ELEMENT_ID", $id);
221  $template->setVariable("ELEMENT_NAME", $name);
222  $template->parseCurrentBlock();
223  $template->setCurrentBlock("element");
224  $template->setVariable("ELEMENT_ID", $id);
225  $template->parseCurrentBlock();
226  }
227  $template->setVariable("TITLE_LIST_1", $title_source);
228  $template->setVariable("TITLE_LIST_2", $title_dest);
229  $template->setVariable("LIST_1", $id_source);
230  $template->setVariable("LIST_2", $id_dest);
231  return $template->get();
232  }
233 
234  static function addYesNoDialog($dialogname, $headertext, $message, $yesaction, $noaction, $defaultyes, $icon = "help")
235  {
236  global $tpl, $lng;
237 
239 
240  $template = new ilTemplate("tpl.yes_no_dialog.js", TRUE, TRUE, "Services/YUI");
241  $template->setVariable("DIALOGNAME", $dialogname);
242  $template->setVariable("YES_ACTION", $yesaction);
243  $template->setVariable("NO_ACTION", $noaction);
244  $template->setVariable("DIALOG_HEADER", $headertext);
245  $template->setVariable("DIALOG_MESSAGE", $message);
246  $template->setVariable("TEXT_YES", $lng->txt("yes"));
247  $template->setVariable("TEXT_NO", $lng->txt("no"));
248  switch ($icon)
249  {
250  case "warn":
251  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_WARN");
252  break;
253  case "tip":
254  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_TIP");
255  break;
256  case "info":
257  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_INFO");
258  break;
259  case "block":
260  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_BLOCK");
261  break;
262  case "alarm":
263  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_ALARM");
264  break;
265  case "help":
266  default:
267  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_HELP");
268  break;
269  }
270  if ($defaultyes)
271  {
272  $template->touchBlock("isDefaultYes");
273  }
274  else
275  {
276  $template->touchBlock("isDefaultNo");
277  }
278  $tpl->setCurrentBlock("HeadContent");
279  $tpl->setVariable("CONTENT_BLOCK", $template->get());
280  $tpl->parseCurrentBlock();
281  }
282 
290  public static function initCalendar()
291  {
292  global $tpl;
293 
294  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
295  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/calendar/calendar-min.js");
296 
297  $tpl->addCss("./Services/YUI/js/".self::$ver."/calendar/assets/skins/sam/calendar.css");
298  $tpl->addCss("./Services/Calendar/css/calendar.css");
299  }
300 
309  public static function initButtonControl()
310  {
311  global $tpl;
312 
313  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
314  if (self::$ver == "2_5_0")
315  {
316  $tpl->addJavaScript("./Services/YUI/js/2_5_0/element/element-beta-min.js");
317  }
318  else
319  {
320  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
321  }
322 
323  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container_core-min.js");
324  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/menu/menu-min.js");
325 
326  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/button/button-min.js");
327 
328  $tpl->addCss("./Services/YUI/js/".self::$ver."/button/assets/skins/sam/button.css");
329  $tpl->addCss("./Services/YUI/js/".self::$ver."/menu/assets/skins/sam/menu.css");
330  }
331 
339  public static function initColorPicker()
340  {
341  global $tpl;
342 
344 
345  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
346  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/slider/slider-min.js");
347  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/colorpicker/colorpicker-min.js");
348 
349  $tpl->addCss('./Services/Form/css/color_picker.css');
350  $tpl->addCss("./Services/YUI/js/".self::$ver."/colorpicker/assets/skins/sam/colorpicker.css");
351  }
352 
356  public static function initTabView()
357  {
358  global $tpl;
359 
360  $tpl->addCss("./Services/YUI/js/".self::$ver."/tabview/assets/skins/sam/tabview.css");
361  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
362  if (self::$ver == "2_5_0")
363  {
364  $tpl->addJavaScript("./Services/YUI/js/2_5_0/element/element-beta-min.js");
365  }
366  else
367  {
368  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
369  }
370  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/tabview/tabview-min.js");
371  }
372 
377  public static function initAutoComplete()
378  {
379  global $tpl;
380 
381  self::initJson();
382 
383  $tpl->addCss("./Services/YUI/js/".self::$ver."/autocomplete/assets/skins/sam/autocomplete.css");
384 
385  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
386  if (self::$ver == "2_5_0")
387  {
388  $tpl->addJavaScript('./Services/YUI/js/2_5_0/datasource/datasource-beta-min.js');
389  }
390  else
391  {
392  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/datasource/datasource-min.js");
393  }
394  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/connection/connection-min.js");
395  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/autocomplete/autocomplete-min.js");
396  }
397 
402  public static function initJson()
403  {
404  global $tpl;
405  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
406  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/json/json-min.js");
407  }
408 
412  public static function initLayout()
413  {
414  global $tpl;
415 
416 // $tpl->addCss("./Services/YUI/js/2_5_0/reset-fonts-grids/reset-fonts-grids.css");
417  $tpl->addCss("./Services/YUI/js/".self::$ver."/assets/skins/sam/resize.css");
418  $tpl->addCss("./Services/YUI/js/".self::$ver."/assets/skins/sam/layout.css");
419 
420  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
421  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
422  if (self::$ver == "2_5_0")
423  {
424  $tpl->addJavaScript("./Services/YUI/js/2_5_0/element/element-beta-min.js");
425  }
426  else
427  {
428  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
429  }
430  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
431  if (self::$ver == "2_5_0")
432  {
433  $tpl->addJavaScript("./Services/YUI/js/2_5_0/resize/resize-beta-min.js");
434  $tpl->addJavaScript("./Services/YUI/js/2_5_0/layout/layout-beta-min.js");
435  }
436  else
437  {
438  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/resize/resize-min.js");
439  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/layout/layout-min.js");
440  }
441  }
442 
446  function getLocalPath($a_name = "")
447  {
448  return "./Services/YUI/js/".self::$ver."/".$a_name;
449  }
450 
451 } // END class.ilUtil
452 ?>