ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules 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 
10 class ilYuiUtil
11 {
12  const YUI_BASE = "./libs/bower/bower_components/yui2/build";
13 
14 
20  public static function initConnection(ilGlobalTemplateInterface $a_main_tpl = null)
21  {
22  global $DIC;
23 
24  if ($a_main_tpl == null) {
25  $tpl = $DIC["tpl"];
26  } else {
27  $tpl = $a_main_tpl;
28  }
29  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
30  $tpl->addJavaScript(self::YUI_BASE . "/connection/connection-min.js");
31  }
32 
33 
39  public static function initEvent(ilGlobalTemplateInterface $a_main_tpl = null)
40  {
41  global $DIC;
42 
43  if ($a_main_tpl == null) {
44  $tpl = $DIC["tpl"];
45  } else {
46  $tpl = $a_main_tpl;
47  }
48 
49  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
50  }
51 
52 
58  public static function initDom(ilGlobalTemplateInterface $a_main_tpl = null)
59  {
60  global $DIC;
61 
62  if ($a_main_tpl == null) {
63  $tpl = $DIC["tpl"];
64  } else {
65  $tpl = $a_main_tpl;
66  }
67 
68  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
69  }
70 
71 
77  public static function initAnimation(ilGlobalTemplateInterface $a_main_tpl = null)
78  {
79  global $DIC;
80 
81  if ($a_main_tpl == null) {
82  $tpl = $DIC["tpl"];
83  } else {
84  $tpl = $a_main_tpl;
85  }
86 
87  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
88  $tpl->addJavaScript(self::YUI_BASE . "/animation/animation-min.js");
89  }
90 
91 
97  public static function initDragDrop(ilGlobalTemplateInterface $a_main_tpl = null)
98  {
99  global $DIC;
100 
101  if ($a_main_tpl == null) {
102  $tpl = $DIC["tpl"];
103  } else {
104  $tpl = $a_main_tpl;
105  }
106 
107  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
108  $tpl->addJavaScript(self::YUI_BASE . "/dragdrop/dragdrop-min.js");
109  $tpl->addJavaScript(self::YUI_BASE . "/element/element-min.js");
110  }
111 
112 
118  public static function initDomEvent(ilGlobalTemplateInterface $a_main_tpl = null)
119  {
120  global $DIC;
121 
122  if ($a_main_tpl == null) {
123  $tpl = $DIC["tpl"];
124  } else {
125  $tpl = $a_main_tpl;
126  }
127 
128  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
129  }
130 
131 
142  public static function initPanel($a_resize = false, ilGlobalTemplateInterface $a_main_tpl = null)
143  {
144  global $DIC;
145 
146  if ($a_main_tpl == null) {
147  $tpl = $DIC["tpl"];
148  } else {
149  $tpl = $a_main_tpl;
150  }
151 
152  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
153  $tpl->addJavaScript(self::YUI_BASE . "/container/container-min.js");
154  self::addContainerCss($tpl);
155  $tpl->addCss("./Services/Calendar/css/panel_min.css");
156 
157  if ($a_resize) {
158  $tpl->addCss(self::YUI_BASE . "/resize/assets/skins/sam/resize.css");
159  $tpl->addJavaScript(self::YUI_BASE . "/utilities/utilities-min.js");
160  $tpl->addJavaScript(self::YUI_BASE . "/resize/resize-min.js");
161  }
162  }
163 
164 
168  public static function initConnectionWithAnimation()
169  {
170  global $DIC;
171 
172  $tpl = $DIC["tpl"];
173 
174  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
175  $tpl->addJavaScript(self::YUI_BASE . "/animation/animation-min.js");
176  $tpl->addJavaScript(self::YUI_BASE . "/connection/connection-min.js");
177  }
178 
179 
183  public static function initMenu()
184  {
185  global $DIC;
186 
187  $tpl = $DIC["tpl"];
188 
189  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
190  $tpl->addJavaScript(self::YUI_BASE . "/container/container_core.js");
191  $tpl->addJavaScript(self::YUI_BASE . "/menu/menu-min.js");
192  $tpl->addCss(self::YUI_BASE . "/menu/assets/menu.css");
193  }
194 
195 
199  public static function initOverlay(ilGlobalTemplateInterface $a_main_tpl = null)
200  {
201  global $DIC;
202 
203  if ($a_main_tpl == null) {
204  $tpl = $DIC["tpl"];
205  } else {
206  $tpl = $a_main_tpl;
207  }
208 
209  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
210  $tpl->addJavaScript(self::YUI_BASE . "/container/container_core-min.js");
211  self::addContainerCss($tpl);
212  }
213 
214 
218  public static function initSimpleDialog()
219  {
220  global $DIC;
221 
222  $tpl = $DIC["tpl"];
223 
224  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
225  $tpl->addJavaScript(self::YUI_BASE . "/container/container-min.js");
226  $tpl->addJavaScript(self::YUI_BASE . "/dragdrop/dragdrop-min.js");
227  self::addContainerCss();
228  $tpl->addCss("./Services/YUI/templates/default/tpl.simpledialog.css");
229  }
230 
231 
235  public static function initAssessmentWizard()
236  {
237  global $DIC;
238 
239  $tpl = $DIC["tpl"];
240 
241  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
242  $tpl->addJavaScript(self::YUI_BASE . "/element/element-min.js");
243  $tpl->addJavaScript(self::YUI_BASE . "/button/button-min.js");
244  $tpl->addJavaScript(self::YUI_BASE . "/container/container-min.js");
245  $tpl->addCss(self::YUI_BASE . "/button/assets/skins/sam/button.css");
246  self::addContainerCss();
247  }
248 
249 
253  public static function initDragDropList()
254  {
255  global $DIC;
256 
257  $tpl = $DIC["tpl"];
258 
259  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
260  $tpl->addJavaScript(self::YUI_BASE . "/animation/animation-min.js");
261  $tpl->addJavaScript(self::YUI_BASE . "/dragdrop/dragdrop-min.js");
262  $tpl->addCss("./Services/YUI/templates/default/DragDropList.css");
263  }
264 
265 
269  public static function initDragDropAnimation()
270  {
271  global $DIC;
272 
273  $tpl = $DIC["tpl"];
274 
275  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
276  $tpl->addJavaScript(self::YUI_BASE . "/animation/animation-min.js");
277  $tpl->addJavaScript(self::YUI_BASE . "/dragdrop/dragdrop-min.js");
278  }
279 
280 
284  public static function initElementSelection()
285  {
286  global $DIC;
287 
288  $tpl = $DIC["tpl"];
289 
290  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
291  $tpl->addJavaScript(self::YUI_BASE . "/element/element-min.js");
292  }
293 
294 
298  public static function getDragDropList($id_source, $title_source, $source, $id_dest, $title_dest, $dest)
299  {
300  self::initDragDropList();
301 
302  $template = new ilTemplate("tpl.dragdroplist.html", true, true, "Services/YUI");
303  foreach ($source as $id => $name) {
304  $template->setCurrentBlock("source_element");
305  $template->setVariable("ELEMENT_ID", $id);
306  $template->setVariable("ELEMENT_NAME", $name);
307  $template->parseCurrentBlock();
308  $template->setCurrentBlock("element");
309  $template->setVariable("ELEMENT_ID", $id);
310  $template->parseCurrentBlock();
311  }
312  foreach ($dest as $id => $name) {
313  $template->setCurrentBlock("dest_element");
314  $template->setVariable("ELEMENT_ID", $id);
315  $template->setVariable("ELEMENT_NAME", $name);
316  $template->parseCurrentBlock();
317  $template->setCurrentBlock("element");
318  $template->setVariable("ELEMENT_ID", $id);
319  $template->parseCurrentBlock();
320  }
321  $template->setVariable("TITLE_LIST_1", $title_source);
322  $template->setVariable("TITLE_LIST_2", $title_dest);
323  $template->setVariable("LIST_1", $id_source);
324  $template->setVariable("LIST_2", $id_dest);
325 
326  return $template->get();
327  }
328 
329 
330  public static function addYesNoDialog($dialogname, $headertext, $message, $yesaction, $noaction, $defaultyes, $icon = "help")
331  {
332  global $DIC;
333 
334  $tpl = $DIC["tpl"];
335  $lng = $DIC->language();
336 
337  self::initSimpleDialog();
338 
339  $template = new ilTemplate("tpl.yes_no_dialog.js", true, true, "Services/YUI");
340  $template->setVariable("DIALOGNAME", $dialogname);
341  $template->setVariable("YES_ACTION", $yesaction);
342  $template->setVariable("NO_ACTION", $noaction);
343  $template->setVariable("DIALOG_HEADER", $headertext);
344  $template->setVariable("DIALOG_MESSAGE", $message);
345  $template->setVariable("TEXT_YES", $lng->txt("yes"));
346  $template->setVariable("TEXT_NO", $lng->txt("no"));
347  switch ($icon) {
348  case "warn":
349  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_WARN");
350  break;
351  case "tip":
352  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_TIP");
353  break;
354  case "info":
355  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_INFO");
356  break;
357  case "block":
358  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_BLOCK");
359  break;
360  case "alarm":
361  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_ALARM");
362  break;
363  case "help":
364  default:
365  $template->setVariable("ICON", "YAHOO.widget.SimpleDialog.ICON_HELP");
366  break;
367  }
368  if ($defaultyes) {
369  $template->touchBlock("isDefaultYes");
370  } else {
371  $template->touchBlock("isDefaultNo");
372  }
373  $tpl->setCurrentBlock("HeadContent");
374  $tpl->setVariable("CONTENT_BLOCK", $template->get());
375  $tpl->parseCurrentBlock();
376  }
377 
378 
386  public static function initCalendar()
387  {
388  global $DIC;
389 
390  $tpl = $DIC["tpl"];
391 
392  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
393  $tpl->addJavaScript(self::YUI_BASE . "/calendar/calendar-min.js");
394 
395  $tpl->addCss(self::YUI_BASE . "/calendar/assets/skins/sam/calendar.css");
396  $tpl->addCss("./Services/Calendar/css/calendar.css");
397  }
398 
399 
408  public static function initButtonControl()
409  {
410  global $DIC;
411 
412  $tpl = $DIC["tpl"];
413 
414  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
415  $tpl->addJavaScript(self::YUI_BASE . "/element/element-min.js");
416 
417  $tpl->addJavaScript(self::YUI_BASE . "/container/container_core-min.js");
418  $tpl->addJavaScript(self::YUI_BASE . "/menu/menu-min.js");
419 
420  $tpl->addJavaScript(self::YUI_BASE . "/button/button-min.js");
421 
422  $tpl->addCss(self::YUI_BASE . "/button/assets/skins/sam/button.css");
423  $tpl->addCss(self::YUI_BASE . "/menu/assets/skins/sam/menu.css");
424  }
425 
426 
434  public static function initColorPicker()
435  {
436  global $DIC;
437 
438  $tpl = $DIC["tpl"];
439 
440  self::initButtonControl();
441 
442  $tpl->addJavaScript(self::YUI_BASE . "/dragdrop/dragdrop-min.js");
443  $tpl->addJavaScript(self::YUI_BASE . "/slider/slider-min.js");
444  $tpl->addJavaScript(self::YUI_BASE . "/colorpicker/colorpicker-min.js");
445 
446  $tpl->addCss('./Services/Form/css/color_picker.css');
447  $tpl->addCss(self::YUI_BASE . "/colorpicker/assets/skins/sam/colorpicker.css");
448  }
449 
450 
454  public static function initTabView()
455  {
456  global $DIC;
457 
458  $tpl = $DIC["tpl"];
459 
460  $tpl->addCss(self::YUI_BASE . "/tabview/assets/skins/sam/tabview.css");
461  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
462  $tpl->addJavaScript(self::YUI_BASE . "/element/element-min.js");
463  $tpl->addJavaScript(self::YUI_BASE . "/tabview/tabview-min.js");
464  }
465 
466 
472  public static function initJson()
473  {
474  global $DIC;
475 
476  $tpl = $DIC["tpl"];
477  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
478  $tpl->addJavaScript(self::YUI_BASE . "/json/json-min.js");
479  }
480 
481 
485  public static function initLayout()
486  {
487  global $DIC;
488 
489  $tpl = $DIC["tpl"];
490 
491  $tpl->addCss(self::YUI_BASE . "/assets/skins/sam/resize.css");
492  $tpl->addCss(self::YUI_BASE . "/assets/skins/sam/layout.css");
493 
494  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
495  $tpl->addJavaScript(self::YUI_BASE . "/dragdrop/dragdrop-min.js");
496  $tpl->addJavaScript(self::YUI_BASE . "/element/element-min.js");
497  $tpl->addJavaScript(self::YUI_BASE . "/animation/animation-min.js");
498  $tpl->addJavaScript(self::YUI_BASE . "/resize/resize-min.js");
499  $tpl->addJavaScript(self::YUI_BASE . "/layout/layout-min.js");
500  }
501 
502 
506  public static function initTreeView()
507  {
508  global $DIC;
509 
510  $tpl = $DIC["tpl"];
511 
512  $tpl->addJavaScript(self::getLocalPath() . '/yahoo/yahoo-min.js');
513  $tpl->addJavaScript(self::getLocalPath() . '/event/event-min.js');
514  $tpl->addJavaScript(self::getLocalPath() . '/treeview/treeview.js');
515  }
516 
517 
521  public static function initTooltip()
522  {
523  global $DIC;
524 
525  $tpl = $DIC["tpl"];
526 
527  self::addContainerCss();
528  $tpl->addJavaScript(self::YUI_BASE . "/yahoo-dom-event/yahoo-dom-event.js");
529  $tpl->addJavaScript(self::YUI_BASE . "/animation/animation-min.js");
530  $tpl->addJavaScript(self::YUI_BASE . "/container/container-min.js");
531  }
532 
533 
537  public static function initCookie()
538  {
542  global $DIC;
543 
544  $tpl = $DIC["tpl"];
545  $tpl->addJavaScript(self::YUI_BASE . "/yahoo/yahoo-min.js", 1);
546  $tpl->addJavaScript(self::YUI_BASE . "/cookie/cookie.js", 1);
547  }
548 
549 
553  public static function getLocalPath($a_name = "")
554  {
555  return self::YUI_BASE . "/" . $a_name;
556  }
557 
558 
562  protected static function addContainerCss(ilGlobalTemplateInterface $a_main_tpl = null)
563  {
564  global $DIC;
565 
566  if ($a_main_tpl == null) {
567  $tpl = $DIC["tpl"];
568  } else {
569  $tpl = $a_main_tpl;
570  }
571 
572  $tpl->addCss(self::getLocalPath("container/assets/skins/sam/container.css"));
573  }
574 }
static initSimpleDialog()
Init YUI Simple Dialog.
static initTooltip()
Init YUI Event.
static initLayout()
Init layout (alpha!)
static initTreeView()
Init treeView.
static initElementSelection()
init element selection
static initJson()
Init YUI JSON component.
static addContainerCss(ilGlobalTemplateInterface $a_main_tpl=null)
Add container css.
static getDragDropList($id_source, $title_source, $source, $id_dest, $title_dest, $dest)
get a drag & drop list
static initConnection(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
static initPanel($a_resize=false, ilGlobalTemplateInterface $a_main_tpl=null)
Init yui panel.
static initMenu()
Init YUI Menu module.
static initAssessmentWizard()
Init assessment wizard.
static initDom(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Dom.
if($format !==null) $name
Definition: metadata.php:230
static initEvent(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Event.
$lng
Yahoo YUI Library Utility functions.
global $DIC
Definition: goto.php:24
static initColorPicker()
init color picker button
static initDomEvent(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI DomEvent.
static initDragDrop(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Drag and Drop.
static initDragDropAnimation()
init drag & drop and animation
static getLocalPath($a_name="")
Get local path of a YUI js file.
static initOverlay(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Overlay module.
static initButtonControl()
init button control In the moment used for calendar color picker button
$message
Definition: xapiexit.php:14
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
static initDragDropList()
init drag & drop list
$source
Definition: metadata.php:76
static addYesNoDialog($dialogname, $headertext, $message, $yesaction, $noaction, $defaultyes, $icon="help")
static initConnectionWithAnimation()
Init YUI Connection module.
static initTabView()
Init YUI TabView component.
static initAnimation(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Animation.
static initCalendar()
init calendar