ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 public static function getTooltipPresentationText($a_tt_id)
20 {
21 global $DIC;
22
23 $ilDB = $DIC->database();
24 $ilSetting = $DIC->settings();
25 $ilUser = $DIC->user();
26
27
28 if ($ilUser->getLanguage() != "de") {
29 return "";
30 }
31
32 if ($ilSetting->get("help_mode") == "1") {
33 return "";
34 }
35
36 if ($ilUser->getPref("hide_help_tt")) {
37 return "";
38 }
39
40 if (OH_REF_ID > 0) {
41 $module_id = 0;
42 } else {
43 $module_id = (int) $ilSetting->get("help_module");
44 if ($module_id == 0) {
45 return "";
46 }
47 }
48
49 $set = $ilDB->query(
50 "SELECT tt_text FROM help_tooltip " .
51 " WHERE tt_id = " . $ilDB->quote($a_tt_id, "text") .
52 " AND module_id = " . $ilDB->quote($module_id, "integer")
53 );
54 $rec = $ilDB->fetchAssoc($set);
55 if ($rec["tt_text"] != "") {
56 $t = $rec["tt_text"];
57 if ($module_id == 0) {
58 $t .= "<br/><i>(" . $a_tt_id . ")</i>";
59 }
60 return $t;
61 } else { // try to get general version
62 $fu = strpos($a_tt_id, "_");
63 $gen_tt_id = "*" . substr($a_tt_id, $fu);
64 $set = $ilDB->query(
65 "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 $t = $rec["tt_text"];
72 if ($module_id == 0) {
73 $t .= "<br/><i>(" . $a_tt_id . ")</i>";
74 }
75 return $t;
76 }
77 }
78 if ($module_id == 0) {
79 return "<i>" . $a_tt_id . "</i>";
80 }
81 return "";
82 }
83
90 public static function getObjCreationTooltipText($a_type)
91 {
92 return self::getTooltipPresentationText($a_type . "_create");
93 }
94
101 public static function getMainMenuTooltip($a_item_id)
102 {
103 return self::getTooltipPresentationText($a_item_id);
104 }
105
106
113 public static function getAllTooltips($a_comp = "", $a_module_id = 0)
114 {
115 global $DIC;
116
117 $ilDB = $DIC->database();
118
119 $q = "SELECT * FROM help_tooltip";
120 $q .= " WHERE module_id = " . $ilDB->quote($a_module_id, "integer");
121 if ($a_comp != "") {
122 $q .= " AND comp = " . $ilDB->quote($a_comp, "text");
123 }
124 $set = $ilDB->query($q);
125 $tts = array();
126 while ($rec = $ilDB->fetchAssoc($set)) {
127 $tts[$rec["id"]] = array("id" => $rec["id"], "text" => $rec["tt_text"],
128 "tt_id" => $rec["tt_id"]);
129 }
130 return $tts;
131 }
132
139 public static function addTooltip($a_tt_id, $a_text, $a_module_id = 0)
140 {
141 global $DIC;
142
143 $ilDB = $DIC->database();
144
145 $fu = strpos($a_tt_id, "_");
146 $comp = substr($a_tt_id, 0, $fu);
147
148 $nid = $ilDB->nextId("help_tooltip");
149 $ilDB->manipulate("INSERT INTO help_tooltip " .
150 "(id, tt_text, tt_id, comp,module_id) VALUES (" .
151 $ilDB->quote($nid, "integer") . "," .
152 $ilDB->quote($a_text, "text") . "," .
153 $ilDB->quote($a_tt_id, "text") . "," .
154 $ilDB->quote($comp, "text") . "," .
155 $ilDB->quote($a_module_id, "integer") .
156 ")");
157 }
158
165 public static function updateTooltip($a_id, $a_text, $a_tt_id)
166 {
167 global $DIC;
168
169 $ilDB = $DIC->database();
170
171 $fu = strpos($a_tt_id, "_");
172 $comp = substr($a_tt_id, 0, $fu);
173
174 $ilDB->manipulate(
175 "UPDATE help_tooltip SET " .
176 " tt_text = " . $ilDB->quote($a_text, "text") . ", " .
177 " tt_id = " . $ilDB->quote($a_tt_id, "text") . ", " .
178 " comp = " . $ilDB->quote($comp, "text") .
179 " WHERE id = " . $ilDB->quote($a_id, "integer")
180 );
181 }
182
183
190 public static function getTooltipComponents($a_module_id = 0)
191 {
192 global $DIC;
193
194 $ilDB = $DIC->database();
195 $lng = $DIC->language();
196
197 $set = $ilDB->query("SELECT DISTINCT comp FROM help_tooltip " .
198 " WHERE module_id = " . $ilDB->quote($a_module_id, "integer") .
199 " ORDER BY comp ");
200 $comps[""] = "- " . $lng->txt("help_all") . " -";
201 while ($rec = $ilDB->fetchAssoc($set)) {
202 $comps[$rec["comp"]] = $rec["comp"];
203 }
204 return $comps;
205 }
206
213 public static function deleteTooltip($a_id)
214 {
215 global $DIC;
216
217 $ilDB = $DIC->database();
218
219 $ilDB->manipulate(
220 "DELETE FROM help_tooltip WHERE " .
221 " id = " . $ilDB->quote($a_id, "integer")
222 );
223 }
224
231 public static function deleteTooltipsOfModule($a_id)
232 {
233 global $DIC;
234
235 $ilDB = $DIC->database();
236
237 $ilDB->manipulate(
238 "DELETE FROM help_tooltip WHERE " .
239 " module_id = " . $ilDB->quote($a_id, "integer")
240 );
241 }
242
248 public static function getHelpLMId()
249 {
250 global $DIC;
251
252 $ilSetting = $DIC->settings();
253
254 $lm_id = 0;
255
256 if (OH_REF_ID > 0) {
257 $lm_id = ilObject::_lookupObjId(OH_REF_ID);
258 } else {
259 $hm = (int) $ilSetting->get("help_module");
260 if ($hm > 0) {
261 include_once("./Services/Help/classes/class.ilObjHelpSettings.php");
263 }
264 }
265
266 return $lm_id;
267 }
268}
An exception for terminatinating execution or to throw for unit testing.
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.
static lookupModuleLmId($a_id)
lookup module lm id
static _lookupObjId($a_id)
global $ilSetting
Definition: privfeed.php:17
$lng
global $ilDB
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92
$DIC
Definition: xapitoken.php:46