ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilHelp.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4
11class ilHelp
12{
19 static function getTooltipPresentationText($a_tt_id)
20 {
21 global $ilDB, $ilSetting, $ilUser;
22
23
24 if ($ilUser->getLanguage() != "de")
25 {
26 return "";
27 }
28
29 if ($ilSetting->get("help_mode") == "1")
30 {
31 return "";
32 }
33
34 if (OH_REF_ID > 0)
35 {
36 $module_id = 0;
37 }
38 else
39 {
40 $module_id = (int) $ilSetting->get("help_module");
41 if ($module_id == 0)
42 {
43 return "";
44 }
45 }
46
47 $set = $ilDB->query("SELECT tt_text FROM help_tooltip ".
48 " WHERE tt_id = ".$ilDB->quote($a_tt_id, "text").
49 " AND module_id = ".$ilDB->quote($module_id, "integer")
50 );
51 $rec = $ilDB->fetchAssoc($set);
52 if ($rec["tt_text"] != "")
53 {
54 $t = $rec["tt_text"];
55 if ($module_id == 0)
56 {
57 $t.="<br/><i class='small'>".$a_tt_id."</i>";
58 }
59 return $t;
60 }
61 else // try to get general version
62 {
63 $fu = strpos($a_tt_id, "_");
64 $gen_tt_id = "*".substr($a_tt_id, $fu);
65 $set = $ilDB->query("SELECT tt_text FROM help_tooltip ".
66 " WHERE tt_id = ".$ilDB->quote($gen_tt_id, "text").
67 " AND module_id = ".$ilDB->quote($module_id, "integer")
68 );
69 $rec = $ilDB->fetchAssoc($set);
70 if ($rec["tt_text"] != "")
71 {
72 $t = $rec["tt_text"];
73 if ($module_id == 0)
74 {
75 $t.="<br/><i class='small'>".$a_tt_id."</i>";
76 }
77 return $t;
78 }
79 }
80 if ($module_id == 0)
81 {
82 return "<i>".$a_tt_id."</i>";
83 }
84 return "";
85 }
86
93 static function getObjCreationTooltipText($a_type)
94 {
95 return self::getTooltipPresentationText($a_type."_create");
96 }
97
104 static function getMainMenuTooltip($a_item_id)
105 {
106 return self::getTooltipPresentationText($a_item_id);
107 }
108
109
116 static function getAllTooltips($a_comp = "", $a_module_id = 0)
117 {
118 global $ilDB;
119
120 $q = "SELECT * FROM help_tooltip";
121 $q.= " WHERE module_id = ".$ilDB->quote($a_module_id, "integer");
122 if ($a_comp != "")
123 {
124 $q.= " AND comp = ".$ilDB->quote($a_comp, "text");
125 }
126 $set = $ilDB->query($q);
127 $tts = array();
128 while ($rec = $ilDB->fetchAssoc($set))
129 {
130 $tts[$rec["id"]] = array("id" => $rec["id"], "text" => $rec["tt_text"],
131 "tt_id" => $rec["tt_id"]);
132 }
133 return $tts;
134 }
135
142 static function addTooltip($a_tt_id, $a_text, $a_module_id = 0)
143 {
144 global $ilDB;
145
146 $fu = strpos($a_tt_id, "_");
147 $comp = substr($a_tt_id, 0, $fu);
148
149 $nid = $ilDB->nextId("help_tooltip");
150 $ilDB->manipulate("INSERT INTO help_tooltip ".
151 "(id, tt_text, tt_id, comp,module_id) VALUES (".
152 $ilDB->quote($nid, "integer").",".
153 $ilDB->quote($a_text, "text").",".
154 $ilDB->quote($a_tt_id, "text").",".
155 $ilDB->quote($comp, "text").",".
156 $ilDB->quote($a_module_id, "integer").
157 ")");
158 }
159
166 static function updateTooltip($a_id, $a_text, $a_tt_id)
167 {
168 global $ilDB;
169
170 $fu = strpos($a_tt_id, "_");
171 $comp = substr($a_tt_id, 0, $fu);
172
173 $ilDB->manipulate("UPDATE help_tooltip SET ".
174 " tt_text = ".$ilDB->quote($a_text, "text").", ".
175 " tt_id = ".$ilDB->quote($a_tt_id, "text").", ".
176 " comp = ".$ilDB->quote($comp, "text").
177 " WHERE id = ".$ilDB->quote($a_id, "integer")
178 );
179 }
180
181
188 static function getTooltipComponents($a_module_id = 0)
189 {
190 global $ilDB, $lng;
191
192 $set = $ilDB->query("SELECT DISTINCT comp FROM help_tooltip ".
193 " WHERE module_id = ".$ilDB->quote($a_module_id, "integer").
194 " ORDER BY comp ");
195 $comps[""] = "- ".$lng->txt("help_all")." -";
196 while ($rec = $ilDB->fetchAssoc($set))
197 {
198 $comps[$rec["comp"]] = $rec["comp"];
199 }
200 return $comps;
201 }
202
209 static function deleteTooltip($a_id)
210 {
211 global $ilDB;
212
213 $ilDB->manipulate("DELETE FROM help_tooltip WHERE ".
214 " id = ".$ilDB->quote($a_id, "integer")
215 );
216 }
217
224 static function deleteTooltipsOfModule($a_id)
225 {
226 global $ilDB;
227
228 $ilDB->manipulate("DELETE FROM help_tooltip WHERE ".
229 " module_id = ".$ilDB->quote($a_id, "integer")
230 );
231
232 }
233
239 static function getHelpLMId()
240 {
241 global $ilSetting;
242
243 $lm_id = 0;
244
245 if (OH_REF_ID > 0)
246 {
247 $lm_id = ilObject::_lookupObjId(OH_REF_ID);
248 }
249 else
250 {
251 $hm = (int) $ilSetting->get("help_module");
252 if ($hm > 0)
253 {
254 include_once("./Services/Help/classes/class.ilObjHelpSettings.php");
256 }
257 }
258
259 return $lm_id;
260 }
261
262}
263?>
Online help application class.
static addTooltip($a_tt_id, $a_text, $a_module_id=0)
Add tooltip.
static getAllTooltips($a_comp="", $a_module_id=0)
Get all tooltips.
static getTooltipPresentationText($a_tt_id)
Get tooltip for id.
static updateTooltip($a_id, $a_text, $a_tt_id)
Update tooltip.
static getMainMenuTooltip($a_item_id)
Get main menu tooltip.
static getObjCreationTooltipText($a_type)
Get object_creation tooltip tab text.
static getTooltipComponents($a_module_id=0)
Get all tooltip components.
static deleteTooltip($a_id)
Delete tooltip.
static getHelpLMId()
Get help lm id.
static deleteTooltipsOfModule($a_id)
Delete tooltips of module.
lookupModuleLmId($a_id)
lookup module lm id
static _lookupObjId($a_id)
global $lng
Definition: privfeed.php:40
global $ilSetting
Definition: privfeed.php:40
global $ilDB
global $ilUser
Definition: imgupload.php:15