ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTooltipGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
9 {
10  static protected $initialized = false;
11 
19  static function addTooltip($a_el_id, $a_text, $a_container = "",
20  $a_my = "bottom center", $a_at = "top center", $a_use_htmlspecialchars = true)
21  {
22  global $tpl;
23 
24  if (!self::$initialized)
25  {
26 // include_once("./Services/YUI/classes/class.ilYuiUtil.php");
27 // ilYuiUtil::initTooltip();
28 $tpl->addCss("./Services/UIComponent/Tooltip/lib/qtip_2_0_nightly/jquery.qtip.min.css");
29 $tpl->addJavascript("./Services/UIComponent/Tooltip/lib/qtip_2_0_nightly/jquery.qtip.min.js");
30  $tpl->addJavascript("./Services/UIComponent/Tooltip/js/ilTooltip.js");
31  $tpl->addOnLoadCode('il.Tooltip.init();', 3);
32  self::$initialized = true;
33  }
34 
35  $code = self::getTooltip($a_el_id, $a_text, $a_container, $a_my, $a_at,
36  $a_use_htmlspecialchars);
37  $tpl->addOnLoadCode($code);
38  }
39 
47  static function getToolTip($a_el_id, $a_text, $a_container = "",
48  $a_my = "bottom center", $a_at = "top center", $a_use_htmlspecialchars = true)
49  {
50  $addstr = "";
51  if ($a_container != "")
52  {
53  $addstr.= ", container: '".$a_container."'";
54  }
55 
56  if ($a_use_htmlspecialchars)
57  {
58  $a_text = htmlspecialchars(str_replace(array("\n", "\r"), "", $a_text));
59  }
60  else
61  {
62  $a_text = str_replace(array("\n", "\r", "'", '"'), array("", "", "\'", '\"'), $a_text);
63  }
64  return 'il.Tooltip.add("'.$a_el_id.'", {'.
65  ' context:"'.$a_el_id.'",'.
66  ' my:"'.$a_my.'",'.
67  ' at:"'.$a_at.'",'.
68  ' text:"'.$a_text.'" '.$addstr.'} );';
69  }
70 
71 }
72 ?>