ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
10 class ilYuiUtil
11 {
12  const YUI_BASE = "./libs/bower/bower_components/yui2/build";
13 
14 
18  public static function initConnection(ilTemplate $a_main_tpl = null)
19  {
20  global $DIC;
21 
22  if ($a_main_tpl == null) {
23  $tpl = $DIC["tpl"];
24  } else {
25  $tpl = $a_main_tpl;
26  }
27  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
28  $tpl->addJavaScript(self::YUI_BASE . "/connection/connection-min.js");
29  }
30 
31 
35  public static function initEvent()
36  {
37  global $DIC;
38 
39  $tpl = $DIC["tpl"];
40 
41  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
42  }
43 
44 
48  public static function initDom()
49  {
50  global $DIC;
51 
52  $tpl = $DIC["tpl"];
53 
54  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
55  }
56 
57 
61  public static function initAnimation()
62  {
63  global $DIC;
64 
65  $tpl = $DIC["tpl"];
66 
67  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
68  $tpl->addJavaScript(self::YUI_BASE . "/animation/animation-min.js");
69  }
70 
71 
75  public static function initDragDrop()
76  {
77  global $DIC;
78 
79  $tpl = $DIC["tpl"];
80 
81  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
82  $tpl->addJavaScript(self::YUI_BASE . "/dragdrop/dragdrop-min.js");
83  $tpl->addJavaScript(self::YUI_BASE . "/element/element-min.js");
84  }
85 
86 
90  public static function initDomEvent()
91  {
92  global $DIC;
93 
94  $tpl = $DIC["tpl"];
95 
96  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
97  }
98 
99 
109  public static function initPanel($a_resize = false, ilTemplate $a_main_tpl = null)
110  {
111  global $DIC;
112 
113  if ($a_main_tpl != null) {
114  $tpl = $a_main_tpl;
115  } else {
116  $tpl = $DIC["tpl"];
117  }
118 
119  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
120  $tpl->addJavaScript(self::YUI_BASE . "/container/container-min.js");
121  self::addContainerCss($tpl);
122  $tpl->addCss("./Services/Calendar/css/panel_min.css");
123 
124  if ($a_resize) {
125  $tpl->addCss(self::YUI_BASE . "/resize/assets/skins/sam/resize.css");
126  $tpl->addJavaScript(self::YUI_BASE . "/utilities/utilities-min.js");
127  $tpl->addJavaScript(self::YUI_BASE . "/resize/resize-min.js");
128  }
129  }
130 
131 
135  public static function initConnectionWithAnimation()
136  {
137  global $DIC;
138 
139  $tpl = $DIC["tpl"];
140 
141  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
142  $tpl->addJavaScript(self::YUI_BASE . "/animation/animation-min.js");
143  $tpl->addJavaScript(self::YUI_BASE . "/connection/connection-min.js");
144  }
145 
146 
150  public static function initMenu()
151  {
152  global $DIC;
153 
154  $tpl = $DIC["tpl"];
155 
156  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
157  $tpl->addJavaScript(self::YUI_BASE . "/container/container_core.js");
158  $tpl->addJavaScript(self::YUI_BASE . "/menu/menu-min.js");
159  $tpl->addCss(self::YUI_BASE . "/menu/assets/menu.css");
160  }
161 
162 
166  public static function initOverlay(ilTemplate $a_main_tpl = null)
167  {
168  global $DIC;
169 
170  if ($a_main_tpl == null) {
171  $tpl = $DIC["tpl"];
172  } else {
173  $tpl = $a_main_tpl;
174  }
175 
176  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
177  $tpl->addJavaScript(self::YUI_BASE . "/container/container_core-min.js");
178  self::addContainerCss($tpl);
179  }
180 
181 
185  public static function initSimpleDialog()
186  {
187  global $DIC;
188 
189  $tpl = $DIC["tpl"];
190 
191  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
192  $tpl->addJavaScript(self::YUI_BASE . "/container/container-min.js");
193  $tpl->addJavaScript(self::YUI_BASE . "/dragdrop/dragdrop-min.js");
194  self::addContainerCss();
195  $tpl->addCss("./Services/YUI/templates/default/tpl.simpledialog.css");
196  }
197 
198 
202  public static function initAssessmentWizard()
203  {
204  global $DIC;
205 
206  $tpl = $DIC["tpl"];
207 
208  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
209  $tpl->addJavaScript(self::YUI_BASE . "/element/element-min.js");
210  $tpl->addJavaScript(self::YUI_BASE . "/button/button-min.js");
211  $tpl->addJavaScript(self::YUI_BASE . "/container/container-min.js");
212  $tpl->addCss(self::YUI_BASE . "/button/assets/skins/sam/button.css");
213  self::addContainerCss();
214  }
215 
216 
220  public static function initDragDropList()
221  {
222  global $DIC;
223 
224  $tpl = $DIC["tpl"];
225 
226  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
227  $tpl->addJavaScript(self::YUI_BASE . "/animation/animation-min.js");
228  $tpl->addJavaScript(self::YUI_BASE . "/dragdrop/dragdrop-min.js");
229  $tpl->addCss("./Services/YUI/templates/default/DragDropList.css");
230  }
231 
232 
236  public static function initDragDropAnimation()
237  {
238  global $DIC;
239 
240  $tpl = $DIC["tpl"];
241 
242  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
243  $tpl->addJavaScript(self::YUI_BASE . "/animation/animation-min.js");
244  $tpl->addJavaScript(self::YUI_BASE . "/dragdrop/dragdrop-min.js");
245  }
246 
247 
251  public static function initElementSelection()
252  {
253  global $DIC;
254 
255  $tpl = $DIC["tpl"];
256 
257  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
258  $tpl->addJavaScript(self::YUI_BASE . "/element/element-min.js");
259  }
260 
261 
265  public static function getDragDropList($id_source, $title_source, $source, $id_dest, $title_dest, $dest)
266  {
267  self::initDragDropList();
268 
269  $template = new ilTemplate("tpl.dragdroplist.html", true, true, "Services/YUI");
270  foreach ($source as $id => $name) {
271  $template->setCurrentBlock("source_element");
272  $template->setVariable("ELEMENT_ID", $id);
273  $template->setVariable("ELEMENT_NAME", $name);
274  $template->parseCurrentBlock();
275  $template->setCurrentBlock("element");
276  $template->setVariable("ELEMENT_ID", $id);
277  $template->parseCurrentBlock();
278  }
279  foreach ($dest as $id => $name) {
280  $template->setCurrentBlock("dest_element");
281  $template->setVariable("ELEMENT_ID", $id);
282  $template->setVariable("ELEMENT_NAME", $name);
283  $template->parseCurrentBlock();
284  $template->setCurrentBlock("element");
285  $template->setVariable("ELEMENT_ID", $id);
286  $template->parseCurrentBlock();
287  }
288  $template->setVariable("TITLE_LIST_1", $title_source);
289  $template->setVariable("TITLE_LIST_2", $title_dest);
290  $template->setVariable("LIST_1", $id_source);
291  $template->setVariable("LIST_2", $id_dest);
292 
293  return $template->get();
294  }
295 
296 
297  public static function addYesNoDialog($dialogname, $headertext, $message, $yesaction, $noaction, $defaultyes, $icon = "help")
298  {
299  global $DIC;
300 
301  $tpl = $DIC["tpl"];
302  $lng = $DIC->language();
303 
304  self::initSimpleDialog();
305 
306  $template = new ilTemplate("tpl.yes_no_dialog.js", true, true, "Services/YUI");
307  $template->setVariable("DIALOGNAME", $dialogname);
308  $template->setVariable("YES_ACTION", $yesaction);
309  $template->setVariable("NO_ACTION", $noaction);
310  $template->setVariable("DIALOG_HEADER", $headertext);
311  $template->setVariable("DIALOG_MESSAGE", $message);
312  $template->setVariable("TEXT_YES", $lng->txt("yes"));
313  $template->setVariable("TEXT_NO", $lng->txt("no"));
314  switch ($icon) {
315  case "warn":
316  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_WARN");
317  break;
318  case "tip":
319  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_TIP");
320  break;
321  case "info":
322  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_INFO");
323  break;
324  case "block":
325  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_BLOCK");
326  break;
327  case "alarm":
328  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_ALARM");
329  break;
330  case "help":
331  default:
332  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_HELP");
333  break;
334  }
335  if ($defaultyes) {
336  $template->touchBlock("isDefaultYes");
337  } else {
338  $template->touchBlock("isDefaultNo");
339  }
340  $tpl->setCurrentBlock("HeadContent");
341  $tpl->setVariable("CONTENT_BLOCK", $template->get());
342  $tpl->parseCurrentBlock();
343  }
344 
345 
353  public static function initCalendar()
354  {
355  global $DIC;
356 
357  $tpl = $DIC["tpl"];
358 
359  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
360  $tpl->addJavaScript(self::YUI_BASE . "/calendar/calendar-min.js");
361 
362  $tpl->addCss(self::YUI_BASE . "/calendar/assets/skins/sam/calendar.css");
363  $tpl->addCss("./Services/Calendar/css/calendar.css");
364  }
365 
366 
375  public static function initButtonControl()
376  {
377  global $DIC;
378 
379  $tpl = $DIC["tpl"];
380 
381  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
382  $tpl->addJavaScript(self::YUI_BASE . "/element/element-min.js");
383 
384  $tpl->addJavaScript(self::YUI_BASE . "/container/container_core-min.js");
385  $tpl->addJavaScript(self::YUI_BASE . "/menu/menu-min.js");
386 
387  $tpl->addJavaScript(self::YUI_BASE . "/button/button-min.js");
388 
389  $tpl->addCss(self::YUI_BASE . "/button/assets/skins/sam/button.css");
390  $tpl->addCss(self::YUI_BASE . "/menu/assets/skins/sam/menu.css");
391  }
392 
393 
401  public static function initColorPicker()
402  {
403  global $DIC;
404 
405  $tpl = $DIC["tpl"];
406 
407  self::initButtonControl();
408 
409  $tpl->addJavaScript(self::YUI_BASE . "/dragdrop/dragdrop-min.js");
410  $tpl->addJavaScript(self::YUI_BASE . "/slider/slider-min.js");
411  $tpl->addJavaScript(self::YUI_BASE . "/colorpicker/colorpicker-min.js");
412 
413  $tpl->addCss('./Services/Form/css/color_picker.css');
414  $tpl->addCss(self::YUI_BASE . "/colorpicker/assets/skins/sam/colorpicker.css");
415  }
416 
417 
421  public static function initTabView()
422  {
423  global $DIC;
424 
425  $tpl = $DIC["tpl"];
426 
427  $tpl->addCss(self::YUI_BASE . "/tabview/assets/skins/sam/tabview.css");
428  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
429  $tpl->addJavaScript(self::YUI_BASE . "/element/element-min.js");
430  $tpl->addJavaScript(self::YUI_BASE . "/tabview/tabview-min.js");
431  }
432 
433 
439  public static function initJson()
440  {
441  global $DIC;
442 
443  $tpl = $DIC["tpl"];
444  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
445  $tpl->addJavaScript(self::YUI_BASE . "/json/json-min.js");
446  }
447 
448 
452  public static function initLayout()
453  {
454  global $DIC;
455 
456  $tpl = $DIC["tpl"];
457 
458  $tpl->addCss(self::YUI_BASE . "/assets/skins/sam/resize.css");
459  $tpl->addCss(self::YUI_BASE . "/assets/skins/sam/layout.css");
460 
461  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
462  $tpl->addJavaScript(self::YUI_BASE . "/dragdrop/dragdrop-min.js");
463  $tpl->addJavaScript(self::YUI_BASE . "/element/element-min.js");
464  $tpl->addJavaScript(self::YUI_BASE . "/animation/animation-min.js");
465  $tpl->addJavaScript(self::YUI_BASE . "/resize/resize-min.js");
466  $tpl->addJavaScript(self::YUI_BASE . "/layout/layout-min.js");
467  }
468 
469 
473  public static function initTreeView()
474  {
475  global $DIC;
476 
477  $tpl = $DIC["tpl"];
478 
479  $tpl->addJavaScript(self::getLocalPath() . '/yahoo/yahoo-min.js');
480  $tpl->addJavaScript(self::getLocalPath() . '/event/event-min.js');
481  $tpl->addJavaScript(self::getLocalPath() . '/treeview/treeview.js');
482  }
483 
484 
488  public static function initTooltip()
489  {
490  global $DIC;
491 
492  $tpl = $DIC["tpl"];
493 
494  self::addContainerCss();
495  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
496  $tpl->addJavaScript(self::YUI_BASE . "/animation/animation-min.js");
497  $tpl->addJavaScript(self::YUI_BASE . "/container/container-min.js");
498  }
499 
500 
504  public static function initCookie()
505  {
509  global $DIC;
510 
511  $tpl = $DIC["tpl"];
512 
513  $tpl->addJavaScript(self::YUI_BASE . "/cookie/cookie.js");
514  }
515 
516 
520  public static function getLocalPath($a_name = "")
521  {
522  return self::YUI_BASE . "/" . $a_name;
523  }
524 
525 
529  protected static function addContainerCss(ilTemplate $a_main_tpl = null)
530  {
531  global $DIC;
532 
533  if ($a_main_tpl == null) {
534  $tpl = $DIC["tpl"];
535  } else {
536  $tpl = $a_main_tpl;
537  }
538 
539  $tpl->addCss(self::getLocalPath("container/assets/skins/sam/container.css"));
540  }
541 }
static initSimpleDialog()
Init YUI Simple Dialog.
static initTooltip()
Init YUI Event.
static initLayout()
Init layout (alpha!)
static initTreeView()
Init treeView.
$template
static initAnimation()
Init YUI Animation.
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
static initElementSelection()
init element selection
static initConnection(ilTemplate $a_main_tpl=null)
Init YUI Connection module.
static initJson()
Init YUI JSON component.
if(!array_key_exists('StateId', $_REQUEST)) $id
static getDragDropList($id_source, $title_source, $source, $id_dest, $title_dest, $dest)
get a drag & drop list
static initMenu()
Init YUI Menu module.
static initAssessmentWizard()
Init assessment wizard.
static initDom()
Init YUI Dom.
if($format !==null) $name
Definition: metadata.php:146
static initOverlay(ilTemplate $a_main_tpl=null)
Init YUI Overlay module.
catch(Exception $e) $message
Yahoo YUI Library Utility functions.
special template class to simplify handling of ITX/PEAR
static initColorPicker()
init color picker button
static initDomEvent()
Init YUI DomEvent.
static initEvent()
Init YUI Event.
static initDragDropAnimation()
init drag & drop and animation
static getLocalPath($a_name="")
Get local path of a YUI js file.
static initButtonControl()
init button control In the moment used for calendar color picker button
static initDragDrop()
Init YUI Drag and Drop.
static addContainerCss(ilTemplate $a_main_tpl=null)
Add container css.
global $lng
Definition: privfeed.php:17
$source
Definition: linkback.php:22
static initDragDropList()
init drag & drop list
static initPanel($a_resize=false, ilTemplate $a_main_tpl=null)
Init yui panel.
static addYesNoDialog($dialogname, $headertext, $message, $yesaction, $noaction, $defaultyes, $icon="help")
static initConnectionWithAnimation()
Init YUI Connection module.
static initTabView()
Init YUI TabView component.
static initCalendar()
init calendar