ILIAS  Release_4_1_x_branch Revision 61804
 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  private static $ver = "2_8_1";
15 
19  static function initConnection()
20  {
21  global $tpl;
22 
23  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
24  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/connection/connection-min.js");
25  }
26 
30  static function initEvent()
31  {
32  global $tpl;
33 
34  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
35  }
36 
40  static function initDom()
41  {
42  global $tpl;
43 
44  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
45 
46  }
47 
51  static function initAnimation()
52  {
53  global $tpl;
54 
55  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
56  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
57  }
58 
62  static function initDragDrop()
63  {
64  global $tpl;
65 
66  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
67  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
68  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
69  }
70 
74  static function initDomEvent()
75  {
76  global $tpl;
77 
78  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
79  }
80 
88  public function initPanel()
89  {
90  global $tpl;
91 
92  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
93  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container-min.js");
94  $tpl->addCss("./Services/YUI/js/".self::$ver."/container/assets/skins/sam/container.css");
95  $tpl->addCss("./Services/Calendar/css/panel_min.css");
96 
97  }
98 
102  static function initConnectionWithAnimation()
103  {
104  global $tpl;
105 
106  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
107  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
108  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/connection/connection-min.js");
109  }
110 
114  static function initMenu()
115  {
116  global $tpl;
117 
118  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
119  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container_core.js");
120  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/menu/menu-min.js");
121  $tpl->addCss("./Services/YUI/js/".self::$ver."/menu/assets/menu.css");
122  }
123 
127  static function initOverlay()
128  {
129  global $tpl;
130 
131  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
132  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container_core-min.js");
133  $tpl->addCss("./Services/YUI/js/".self::$ver."/container/assets/skins/sam/container.css");
134  }
135 
139  static function initSimpleDialog()
140  {
141  global $tpl;
142 
143  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
144  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container-min.js");
145  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
146  $tpl->addCss("./Services/YUI/js/".self::$ver."/container/assets/container.css");
147  $tpl->addCss("./Services/YUI/templates/default/tpl.simpledialog.css");
148  }
149 
153  static function initAssessmentWizard()
154  {
155  global $tpl;
156 
157  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
158  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
159  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/button/button-min.js");
160  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container-min.js");
161  $tpl->addCss("./Services/YUI/js/".self::$ver."/button/assets/skins/sam/button.css");
162  $tpl->addCss("./Services/YUI/js/".self::$ver."/container/assets/skins/sam/container.css");
163  }
164 
168  static function initDragDropList()
169  {
170  global $tpl;
171 
172  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
173  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
174  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
175  $tpl->addCss("./Services/YUI/templates/default/DragDropList.css");
176  }
177 
181  static function initDragDropAnimation()
182  {
183  global $tpl;
184 
185  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
186  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
187  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
188  }
189 
193  static function initElementSelection()
194  {
195  global $tpl;
196 
197  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
198  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
199  }
200 
204  static function getDragDropList($id_source, $title_source, $source, $id_dest, $title_dest, $dest)
205  {
207 
208  $template = new ilTemplate("tpl.dragdroplist.html", TRUE, TRUE, "Services/YUI");
209  foreach ($source as $id => $name)
210  {
211  $template->setCurrentBlock("source_element");
212  $template->setVariable("ELEMENT_ID", $id);
213  $template->setVariable("ELEMENT_NAME", $name);
214  $template->parseCurrentBlock();
215  $template->setCurrentBlock("element");
216  $template->setVariable("ELEMENT_ID", $id);
217  $template->parseCurrentBlock();
218  }
219  foreach ($dest as $id => $name)
220  {
221  $template->setCurrentBlock("dest_element");
222  $template->setVariable("ELEMENT_ID", $id);
223  $template->setVariable("ELEMENT_NAME", $name);
224  $template->parseCurrentBlock();
225  $template->setCurrentBlock("element");
226  $template->setVariable("ELEMENT_ID", $id);
227  $template->parseCurrentBlock();
228  }
229  $template->setVariable("TITLE_LIST_1", $title_source);
230  $template->setVariable("TITLE_LIST_2", $title_dest);
231  $template->setVariable("LIST_1", $id_source);
232  $template->setVariable("LIST_2", $id_dest);
233  return $template->get();
234  }
235 
236  static function addYesNoDialog($dialogname, $headertext, $message, $yesaction, $noaction, $defaultyes, $icon = "help")
237  {
238  global $tpl, $lng;
239 
241 
242  $template = new ilTemplate("tpl.yes_no_dialog.js", TRUE, TRUE, "Services/YUI");
243  $template->setVariable("DIALOGNAME", $dialogname);
244  $template->setVariable("YES_ACTION", $yesaction);
245  $template->setVariable("NO_ACTION", $noaction);
246  $template->setVariable("DIALOG_HEADER", $headertext);
247  $template->setVariable("DIALOG_MESSAGE", $message);
248  $template->setVariable("TEXT_YES", $lng->txt("yes"));
249  $template->setVariable("TEXT_NO", $lng->txt("no"));
250  switch ($icon)
251  {
252  case "warn":
253  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_WARN");
254  break;
255  case "tip":
256  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_TIP");
257  break;
258  case "info":
259  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_INFO");
260  break;
261  case "block":
262  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_BLOCK");
263  break;
264  case "alarm":
265  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_ALARM");
266  break;
267  case "help":
268  default:
269  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_HELP");
270  break;
271  }
272  if ($defaultyes)
273  {
274  $template->touchBlock("isDefaultYes");
275  }
276  else
277  {
278  $template->touchBlock("isDefaultNo");
279  }
280  $tpl->setCurrentBlock("HeadContent");
281  $tpl->setVariable("CONTENT_BLOCK", $template->get());
282  $tpl->parseCurrentBlock();
283  }
284 
292  public static function initCalendar()
293  {
294  global $tpl;
295 
296  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
297  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/calendar/calendar-min.js");
298 
299  $tpl->addCss("./Services/YUI/js/".self::$ver."/calendar/assets/skins/sam/calendar.css");
300  $tpl->addCss("./Services/Calendar/css/calendar.css");
301  }
302 
311  public static function initButtonControl()
312  {
313  global $tpl;
314 
315  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
316  if (self::$ver == "2_5_0")
317  {
318  $tpl->addJavaScript("./Services/YUI/js/2_5_0/element/element-beta-min.js");
319  }
320  else
321  {
322  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
323  }
324 
325  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container_core-min.js");
326  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/menu/menu-min.js");
327 
328  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/button/button-min.js");
329 
330  $tpl->addCss("./Services/YUI/js/".self::$ver."/button/assets/skins/sam/button.css");
331  $tpl->addCss("./Services/YUI/js/".self::$ver."/menu/assets/skins/sam/menu.css");
332  }
333 
341  public static function initColorPicker()
342  {
343  global $tpl;
344 
346 
347  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
348  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/slider/slider-min.js");
349  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/colorpicker/colorpicker-min.js");
350 
351  $tpl->addCss('./Services/Form/css/color_picker.css');
352  $tpl->addCss("./Services/YUI/js/".self::$ver."/colorpicker/assets/skins/sam/colorpicker.css");
353  }
354 
358  public static function initTabView()
359  {
360  global $tpl;
361 
362  $tpl->addCss("./Services/YUI/js/".self::$ver."/tabview/assets/skins/sam/tabview.css");
363  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
364  if (self::$ver == "2_5_0")
365  {
366  $tpl->addJavaScript("./Services/YUI/js/2_5_0/element/element-beta-min.js");
367  }
368  else
369  {
370  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
371  }
372  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/tabview/tabview-min.js");
373  }
374 
379  public static function initAutoComplete()
380  {
381  global $tpl;
382 
383  self::initJson();
384 
385  $tpl->addCss("./Services/YUI/js/".self::$ver."/autocomplete/assets/skins/sam/autocomplete.css");
386 
387  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
388  if (self::$ver == "2_5_0")
389  {
390  $tpl->addJavaScript('./Services/YUI/js/2_5_0/datasource/datasource-beta-min.js');
391  }
392  else
393  {
394  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/datasource/datasource-min.js");
395  }
396  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/connection/connection-min.js");
397  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/autocomplete/autocomplete-min.js");
398  }
399 
404  public static function initJson()
405  {
406  global $tpl;
407  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
408  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/json/json-min.js");
409  }
410 
414  public static function initLayout()
415  {
416  global $tpl;
417 
418 // $tpl->addCss("./Services/YUI/js/2_5_0/reset-fonts-grids/reset-fonts-grids.css");
419  $tpl->addCss("./Services/YUI/js/".self::$ver."/assets/skins/sam/resize.css");
420  $tpl->addCss("./Services/YUI/js/".self::$ver."/assets/skins/sam/layout.css");
421 
422  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
423  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
424  if (self::$ver == "2_5_0")
425  {
426  $tpl->addJavaScript("./Services/YUI/js/2_5_0/element/element-beta-min.js");
427  }
428  else
429  {
430  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
431  }
432  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
433  if (self::$ver == "2_5_0")
434  {
435  $tpl->addJavaScript("./Services/YUI/js/2_5_0/resize/resize-beta-min.js");
436  $tpl->addJavaScript("./Services/YUI/js/2_5_0/layout/layout-beta-min.js");
437  }
438  else
439  {
440  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/resize/resize-min.js");
441  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/layout/layout-min.js");
442  }
443  }
444 
448  public static function initTreeView()
449  {
450  global $tpl;
451 
452  $tpl->addJavaScript(ilYuiUtil::getLocalPath().'/yahoo/yahoo-min.js');
453  $tpl->addJavaScript(ilYuiUtil::getLocalPath().'/event/event-min.js');
454  $tpl->addJavaScript(ilYuiUtil::getLocalPath().'/treeview/treeview.js');
455  }
456 
460  static function initTooltip()
461  {
462  global $tpl;
463 
464  $tpl->addCss("./Services/YUI/js/".self::$ver."/container/assets/container.css");
465  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
466  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
467  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container-min.js");
468  }
469 
473  function getLocalPath($a_name = "")
474  {
475  return "./Services/YUI/js/".self::$ver."/".$a_name;
476  }
477 
478 } // END class.ilUtil
479 ?>