ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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  static protected $library_initialized = false;
12 
20  static function addTooltip($a_el_id, $a_text, $a_container = "",
21  $a_my = "bottom center", $a_at = "top center", $a_use_htmlspecialchars = true)
22  {
23  global $tpl;
24 
25  self::initLibrary();
26  if (!self::$initialized)
27  {
28  $tpl->addJavascript("./Services/UIComponent/Tooltip/js/ilTooltip.js");
29  $tpl->addOnLoadCode('il.Tooltip.init();', 3);
30  self::$initialized = true;
31  }
32 
33  $code = self::getTooltip($a_el_id, $a_text, $a_container, $a_my, $a_at,
34  $a_use_htmlspecialchars);
35  $tpl->addOnLoadCode($code);
36  }
37 
45  static function getToolTip($a_el_id, $a_text, $a_container = "",
46  $a_my = "bottom center", $a_at = "top center", $a_use_htmlspecialchars = true)
47  {
48  $addstr = "";
49 
50  // not needed, just make sure the position plugin is included
51 // $addstr.= ", position: {viewport: $('#fixed_content')}";
52 
53  if ($a_container != "")
54  {
55  $addstr.= ", container: '".$a_container."'";
56  }
57 
58  if ($a_use_htmlspecialchars)
59  {
60  $a_text = htmlspecialchars(str_replace(array("\n", "\r"), "", $a_text));
61  }
62  else
63  {
64  $a_text = str_replace(array("\n", "\r", "'", '"'), array("", "", "\'", '\"'), $a_text);
65  }
66  return 'il.Tooltip.add("'.$a_el_id.'", {'.
67  ' context:"'.$a_el_id.'",'.
68  ' my:"'.$a_my.'",'.
69  ' at:"'.$a_at.'",'.
70  ' text:"'.$a_text.'" '.$addstr.'} );';
71  }
72 
76  static function initLibrary()
77  {
78  global $tpl;
79 
80  if (self::$library_initialized)
81  return;
82 
83  $tpl->addCss("./Services/UIComponent/Tooltip/lib/qtip_3_0_3/jquery.qtip.min.css");
84  $tpl->addJavascript("./Services/UIComponent/Tooltip/lib/qtip_3_0_3/jquery.qtip.min.js");
85 
86  self::$library_initialized = true;
87  }
88 }
89 ?>
$code
Definition: example_050.php:99
static getToolTip($a_el_id, $a_text, $a_container="", $a_my="bottom center", $a_at="top center", $a_use_htmlspecialchars=true)
Get tooltip js code.
static $library_initialized
global $tpl
Definition: ilias.php:8
static initLibrary()
Initializes the needed tooltip libraries.
static addTooltip($a_el_id, $a_text, $a_container="", $a_my="bottom center", $a_at="top center", $a_use_htmlspecialchars=true)
Adds a tooltip to an HTML element.
Create styles array
The data for the language used.
This is a utility class for the yui tooltips.