ILIAS  Release_4_2_x_branch Revision 61807
 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 
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  static function initPanel($a_resize = false)
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");
95  $tpl->addCss("./Services/Calendar/css/panel_min.css");
96 
97  if ($a_resize)
98  {
99  $tpl->addCss("./Services/YUI/js/".self::$ver."/resize/assets/skins/sam/resize.css");
100  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/utilities/utilities-min.js");
101  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/resize/resize-min.js");
102  }
103 
104  }
105 
109  static function initConnectionWithAnimation()
110  {
111  global $tpl;
112 
113  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
114  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
115  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/connection/connection-min.js");
116  }
117 
121  static function initMenu()
122  {
123  global $tpl;
124 
125  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
126  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container_core.js");
127  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/menu/menu-min.js");
128  $tpl->addCss("./Services/YUI/js/".self::$ver."/menu/assets/menu.css");
129  }
130 
134  static function initOverlay()
135  {
136  global $tpl;
137 
138  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
139  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container_core-min.js");
141  }
142 
146  static function initSimpleDialog()
147  {
148  global $tpl;
149 
150  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
151  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container-min.js");
152  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
154  $tpl->addCss("./Services/YUI/templates/default/tpl.simpledialog.css");
155  }
156 
160  static function initAssessmentWizard()
161  {
162  global $tpl;
163 
164  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
165  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
166  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/button/button-min.js");
167  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container-min.js");
168  $tpl->addCss("./Services/YUI/js/".self::$ver."/button/assets/skins/sam/button.css");
170  }
171 
175  static function initDragDropList()
176  {
177  global $tpl;
178 
179  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
180  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
181  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
182  $tpl->addCss("./Services/YUI/templates/default/DragDropList.css");
183  }
184 
188  static function initDragDropAnimation()
189  {
190  global $tpl;
191 
192  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
193  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
194  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
195  }
196 
200  static function initElementSelection()
201  {
202  global $tpl;
203 
204  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
205  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
206  }
207 
211  static function getDragDropList($id_source, $title_source, $source, $id_dest, $title_dest, $dest)
212  {
214 
215  $template = new ilTemplate("tpl.dragdroplist.html", TRUE, TRUE, "Services/YUI");
216  foreach ($source as $id => $name)
217  {
218  $template->setCurrentBlock("source_element");
219  $template->setVariable("ELEMENT_ID", $id);
220  $template->setVariable("ELEMENT_NAME", $name);
221  $template->parseCurrentBlock();
222  $template->setCurrentBlock("element");
223  $template->setVariable("ELEMENT_ID", $id);
224  $template->parseCurrentBlock();
225  }
226  foreach ($dest as $id => $name)
227  {
228  $template->setCurrentBlock("dest_element");
229  $template->setVariable("ELEMENT_ID", $id);
230  $template->setVariable("ELEMENT_NAME", $name);
231  $template->parseCurrentBlock();
232  $template->setCurrentBlock("element");
233  $template->setVariable("ELEMENT_ID", $id);
234  $template->parseCurrentBlock();
235  }
236  $template->setVariable("TITLE_LIST_1", $title_source);
237  $template->setVariable("TITLE_LIST_2", $title_dest);
238  $template->setVariable("LIST_1", $id_source);
239  $template->setVariable("LIST_2", $id_dest);
240  return $template->get();
241  }
242 
243  static function addYesNoDialog($dialogname, $headertext, $message, $yesaction, $noaction, $defaultyes, $icon = "help")
244  {
245  global $tpl, $lng;
246 
248 
249  $template = new ilTemplate("tpl.yes_no_dialog.js", TRUE, TRUE, "Services/YUI");
250  $template->setVariable("DIALOGNAME", $dialogname);
251  $template->setVariable("YES_ACTION", $yesaction);
252  $template->setVariable("NO_ACTION", $noaction);
253  $template->setVariable("DIALOG_HEADER", $headertext);
254  $template->setVariable("DIALOG_MESSAGE", $message);
255  $template->setVariable("TEXT_YES", $lng->txt("yes"));
256  $template->setVariable("TEXT_NO", $lng->txt("no"));
257  switch ($icon)
258  {
259  case "warn":
260  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_WARN");
261  break;
262  case "tip":
263  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_TIP");
264  break;
265  case "info":
266  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_INFO");
267  break;
268  case "block":
269  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_BLOCK");
270  break;
271  case "alarm":
272  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_ALARM");
273  break;
274  case "help":
275  default:
276  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_HELP");
277  break;
278  }
279  if ($defaultyes)
280  {
281  $template->touchBlock("isDefaultYes");
282  }
283  else
284  {
285  $template->touchBlock("isDefaultNo");
286  }
287  $tpl->setCurrentBlock("HeadContent");
288  $tpl->setVariable("CONTENT_BLOCK", $template->get());
289  $tpl->parseCurrentBlock();
290  }
291 
299  static function initCalendar()
300  {
301  global $tpl;
302 
303  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
304  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/calendar/calendar-min.js");
305 
306  $tpl->addCss("./Services/YUI/js/".self::$ver."/calendar/assets/skins/sam/calendar.css");
307  $tpl->addCss("./Services/Calendar/css/calendar.css");
308  }
309 
318  static function initButtonControl()
319  {
320  global $tpl;
321 
322  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
323  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
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  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  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  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
365  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/tabview/tabview-min.js");
366  }
367 
372  static function initAutoComplete()
373  {
374  global $tpl;
375 
376  self::initJson();
377 
378  $tpl->addCss("./Services/YUI/js/".self::$ver."/autocomplete/assets/skins/sam/autocomplete.css");
379 
380  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
381  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/datasource/datasource-min.js");
382  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/connection/connection-min.js");
383  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/autocomplete/autocomplete-min.js");
384  }
385 
390  static function initJson()
391  {
392  global $tpl;
393  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
394  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/json/json-min.js");
395  }
396 
400  static function initLayout()
401  {
402  global $tpl;
403 
404  $tpl->addCss("./Services/YUI/js/".self::$ver."/assets/skins/sam/resize.css");
405  $tpl->addCss("./Services/YUI/js/".self::$ver."/assets/skins/sam/layout.css");
406 
407  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
408  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/dragdrop/dragdrop-min.js");
409  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/element/element-min.js");
410  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
411  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/resize/resize-min.js");
412  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/layout/layout-min.js");
413  }
414 
418  static function initTreeView()
419  {
420  global $tpl;
421 
422  $tpl->addJavaScript(self::getLocalPath().'/yahoo/yahoo-min.js');
423  $tpl->addJavaScript(self::getLocalPath().'/event/event-min.js');
424  $tpl->addJavaScript(self::getLocalPath().'/treeview/treeview.js');
425  }
426 
430  static function initTooltip()
431  {
432  global $tpl;
433 
435  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/yahoo-dom-event/yahoo-dom-event.js");
436  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/animation/animation-min.js");
437  $tpl->addJavaScript("./Services/YUI/js/".self::$ver."/container/container-min.js");
438  }
439 
443  static function getLocalPath($a_name = "")
444  {
445  return "./Services/YUI/js/".self::$ver."/".$a_name;
446  }
447 
451  protected static function addContainerCss()
452  {
453  global $tpl;
454 
455  $tpl->addCss(self::getLocalPath("container/assets/skins/sam/container.css"));
456  }
457 
458 
459 } // END class.ilUtil
460 ?>