ILIAS  Release_4_4_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_8_1";
14  private static $ver = "2_9_0";
15 
19  static function initConnection()
20  {
21  global $tpl;
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  static function initPanel($a_resize = false)
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");
94  $tpl->addCss("./Services/Calendar/css/panel_min.css");
95 
96  if ($a_resize)
97  {
98  $tpl->addCss("./Services/YUI/js/".self::$ver."/resize/assets/skins/sam/resize.css");
99  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/utilities/utilities-min.js");
100  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/resize/resize-min.js");
101  }
102 
103  }
104 
108  static function initConnectionWithAnimation()
109  {
110  global $tpl;
111 
112  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
113  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
114  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/connection/connection-min.js");
115  }
116 
120  static function initMenu()
121  {
122  global $tpl;
123 
124  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
125  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container_core.js");
126  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/menu/menu-min.js");
127  $tpl->addCss("./Services/YUI/js/".self::$ver."/menu/assets/menu.css");
128  }
129 
133  static function initOverlay()
134  {
135  global $tpl;
136 
137  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
138  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container_core-min.js");
140  }
141 
145  static function initSimpleDialog()
146  {
147  global $tpl;
148 
149  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
150  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container-min.js");
151  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
153  $tpl->addCss("./Services/YUI/templates/default/tpl.simpledialog.css");
154  }
155 
159  static function initAssessmentWizard()
160  {
161  global $tpl;
162 
163  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
164  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
165  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/button/button-min.js");
166  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container-min.js");
167  $tpl->addCss("./Services/YUI/js/".self::$ver."/button/assets/skins/sam/button.css");
169  }
170 
174  static function initDragDropList()
175  {
176  global $tpl;
177 
178  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
179  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
180  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
181  $tpl->addCss("./Services/YUI/templates/default/DragDropList.css");
182  }
183 
187  static function initDragDropAnimation()
188  {
189  global $tpl;
190 
191  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
192  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
193  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
194  }
195 
199  static function initElementSelection()
200  {
201  global $tpl;
202 
203  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
204  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
205  }
206 
210  static function getDragDropList($id_source, $title_source, $source, $id_dest, $title_dest, $dest)
211  {
213 
214  $template = new ilTemplate("tpl.dragdroplist.html", TRUE, TRUE, "Services/YUI");
215  foreach ($source as $id => $name)
216  {
217  $template->setCurrentBlock("source_element");
218  $template->setVariable("ELEMENT_ID", $id);
219  $template->setVariable("ELEMENT_NAME", $name);
220  $template->parseCurrentBlock();
221  $template->setCurrentBlock("element");
222  $template->setVariable("ELEMENT_ID", $id);
223  $template->parseCurrentBlock();
224  }
225  foreach ($dest as $id => $name)
226  {
227  $template->setCurrentBlock("dest_element");
228  $template->setVariable("ELEMENT_ID", $id);
229  $template->setVariable("ELEMENT_NAME", $name);
230  $template->parseCurrentBlock();
231  $template->setCurrentBlock("element");
232  $template->setVariable("ELEMENT_ID", $id);
233  $template->parseCurrentBlock();
234  }
235  $template->setVariable("TITLE_LIST_1", $title_source);
236  $template->setVariable("TITLE_LIST_2", $title_dest);
237  $template->setVariable("LIST_1", $id_source);
238  $template->setVariable("LIST_2", $id_dest);
239  return $template->get();
240  }
241 
242  static function addYesNoDialog($dialogname, $headertext, $message, $yesaction, $noaction, $defaultyes, $icon = "help")
243  {
244  global $tpl, $lng;
245 
247 
248  $template = new ilTemplate("tpl.yes_no_dialog.js", TRUE, TRUE, "Services/YUI");
249  $template->setVariable("DIALOGNAME", $dialogname);
250  $template->setVariable("YES_ACTION", $yesaction);
251  $template->setVariable("NO_ACTION", $noaction);
252  $template->setVariable("DIALOG_HEADER", $headertext);
253  $template->setVariable("DIALOG_MESSAGE", $message);
254  $template->setVariable("TEXT_YES", $lng->txt("yes"));
255  $template->setVariable("TEXT_NO", $lng->txt("no"));
256  switch ($icon)
257  {
258  case "warn":
259  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_WARN");
260  break;
261  case "tip":
262  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_TIP");
263  break;
264  case "info":
265  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_INFO");
266  break;
267  case "block":
268  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_BLOCK");
269  break;
270  case "alarm":
271  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_ALARM");
272  break;
273  case "help":
274  default:
275  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_HELP");
276  break;
277  }
278  if ($defaultyes)
279  {
280  $template->touchBlock("isDefaultYes");
281  }
282  else
283  {
284  $template->touchBlock("isDefaultNo");
285  }
286  $tpl->setCurrentBlock("HeadContent");
287  $tpl->setVariable("CONTENT_BLOCK", $template->get());
288  $tpl->parseCurrentBlock();
289  }
290 
298  static function initCalendar()
299  {
300  global $tpl;
301 
302  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
303  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/calendar/calendar-min.js");
304 
305  $tpl->addCss("./Services/YUI/js/".self::$ver."/calendar/assets/skins/sam/calendar.css");
306  $tpl->addCss("./Services/Calendar/css/calendar.css");
307  }
308 
317  static function initButtonControl()
318  {
319  global $tpl;
320 
321  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
322  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
323 
324  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container_core-min.js");
325  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/menu/menu-min.js");
326 
327  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/button/button-min.js");
328 
329  $tpl->addCss("./Services/YUI/js/".self::$ver."/button/assets/skins/sam/button.css");
330  $tpl->addCss("./Services/YUI/js/".self::$ver."/menu/assets/skins/sam/menu.css");
331  }
332 
340  static function initColorPicker()
341  {
342  global $tpl;
343 
345 
346  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
347  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/slider/slider-min.js");
348  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/colorpicker/colorpicker-min.js");
349 
350  $tpl->addCss('./Services/Form/css/color_picker.css');
351  $tpl->addCss("./Services/YUI/js/".self::$ver."/colorpicker/assets/skins/sam/colorpicker.css");
352  }
353 
357  static function initTabView()
358  {
359  global $tpl;
360 
361  $tpl->addCss("./Services/YUI/js/".self::$ver."/tabview/assets/skins/sam/tabview.css");
362  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
363  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
364  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/tabview/tabview-min.js");
365  }
366 
371  static function initJson()
372  {
373  global $tpl;
374  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
375  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/json/json-min.js");
376  }
377 
381  static function initLayout()
382  {
383  global $tpl;
384 
385  $tpl->addCss("./Services/YUI/js/".self::$ver."/assets/skins/sam/resize.css");
386  $tpl->addCss("./Services/YUI/js/".self::$ver."/assets/skins/sam/layout.css");
387 
388  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
389  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
390  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
391  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
392  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/resize/resize-min.js");
393  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/layout/layout-min.js");
394  }
395 
399  static function initTreeView()
400  {
401  global $tpl;
402 
403  $tpl->addJavaScript(self::getLocalPath().'/yahoo/yahoo-min.js');
404  $tpl->addJavaScript(self::getLocalPath().'/event/event-min.js');
405  $tpl->addJavaScript(self::getLocalPath().'/treeview/treeview.js');
406  }
407 
411  static function initTooltip()
412  {
413  global $tpl;
414 
416  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
417  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
418  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container-min.js");
419  }
420 
424  public static function initCookie()
425  {
429  global $tpl;
430 
431  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/cookie/cookie.js");
432  }
433 
437  static function getLocalPath($a_name = "")
438  {
439  return "./Services/YUI/js/".self::$ver."/".$a_name;
440  }
441 
445  protected static function addContainerCss()
446  {
447  global $tpl;
448 
449  $tpl->addCss(self::getLocalPath("container/assets/skins/sam/container.css"));
450  }
451 
452 
453 } // END class.ilUtil
454 ?>