ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 (OH_REF_ID > 0) {
37 $module_id = 0;
38 } else {
39 $module_id = (int) $ilSetting->get("help_module");
40 if ($module_id == 0) {
41 return "";
42 }
43 }
44
45 $set = $ilDB->query(
46 "SELECT tt_text FROM help_tooltip " .
47 " WHERE tt_id = " . $ilDB->quote($a_tt_id, "text") .
48 " AND module_id = " . $ilDB->quote($module_id, "integer")
49 );
50 $rec = $ilDB->fetchAssoc($set);
51 if ($rec["tt_text"] != "") {
52 $t = $rec["tt_text"];
53 if ($module_id == 0) {
54 $t.="<br/><i class='small'>" . $a_tt_id . "</i>";
55 }
56 return $t;
57 } else { // try to get general version
58 $fu = strpos($a_tt_id, "_");
59 $gen_tt_id = "*" . substr($a_tt_id, $fu);
60 $set = $ilDB->query(
61 "SELECT tt_text FROM help_tooltip " .
62 " WHERE tt_id = " . $ilDB->quote($gen_tt_id, "text") .
63 " AND module_id = " . $ilDB->quote($module_id, "integer")
64 );
65 $rec = $ilDB->fetchAssoc($set);
66 if ($rec["tt_text"] != "") {
67 $t = $rec["tt_text"];
68 if ($module_id == 0) {
69 $t.="<br/><i class='small'>" . $a_tt_id . "</i>";
70 }
71 return $t;
72 }
73 }
74 if ($module_id == 0) {
75 return "<i>" . $a_tt_id . "</i>";
76 }
77 return "";
78 }
79
86 public static function getObjCreationTooltipText($a_type)
87 {
88 return self::getTooltipPresentationText($a_type . "_create");
89 }
90
97 public static function getMainMenuTooltip($a_item_id)
98 {
99 return self::getTooltipPresentationText($a_item_id);
100 }
101
102
109 public static function getAllTooltips($a_comp = "", $a_module_id = 0)
110 {
111 global $DIC;
112
113 $ilDB = $DIC->database();
114
115 $q = "SELECT * FROM help_tooltip";
116 $q.= " WHERE module_id = " . $ilDB->quote($a_module_id, "integer");
117 if ($a_comp != "") {
118 $q.= " AND comp = " . $ilDB->quote($a_comp, "text");
119 }
120 $set = $ilDB->query($q);
121 $tts = array();
122 while ($rec = $ilDB->fetchAssoc($set)) {
123 $tts[$rec["id"]] = array("id" => $rec["id"], "text" => $rec["tt_text"],
124 "tt_id" => $rec["tt_id"]);
125 }
126 return $tts;
127 }
128
135 public static function addTooltip($a_tt_id, $a_text, $a_module_id = 0)
136 {
137 global $DIC;
138
139 $ilDB = $DIC->database();
140
141 $fu = strpos($a_tt_id, "_");
142 $comp = substr($a_tt_id, 0, $fu);
143
144 $nid = $ilDB->nextId("help_tooltip");
145 $ilDB->manipulate("INSERT INTO help_tooltip " .
146 "(id, tt_text, tt_id, comp,module_id) VALUES (" .
147 $ilDB->quote($nid, "integer") . "," .
148 $ilDB->quote($a_text, "text") . "," .
149 $ilDB->quote($a_tt_id, "text") . "," .
150 $ilDB->quote($comp, "text") . "," .
151 $ilDB->quote($a_module_id, "integer") .
152 ")");
153 }
154
161 public static function updateTooltip($a_id, $a_text, $a_tt_id)
162 {
163 global $DIC;
164
165 $ilDB = $DIC->database();
166
167 $fu = strpos($a_tt_id, "_");
168 $comp = substr($a_tt_id, 0, $fu);
169
170 $ilDB->manipulate(
171 "UPDATE help_tooltip SET " .
172 " tt_text = " . $ilDB->quote($a_text, "text") . ", " .
173 " tt_id = " . $ilDB->quote($a_tt_id, "text") . ", " .
174 " comp = " . $ilDB->quote($comp, "text") .
175 " WHERE id = " . $ilDB->quote($a_id, "integer")
176 );
177 }
178
179
186 public static function getTooltipComponents($a_module_id = 0)
187 {
188 global $DIC;
189
190 $ilDB = $DIC->database();
191 $lng = $DIC->language();
192
193 $set = $ilDB->query("SELECT DISTINCT comp FROM help_tooltip " .
194 " WHERE module_id = " . $ilDB->quote($a_module_id, "integer") .
195 " ORDER BY comp ");
196 $comps[""] = "- " . $lng->txt("help_all") . " -";
197 while ($rec = $ilDB->fetchAssoc($set)) {
198 $comps[$rec["comp"]] = $rec["comp"];
199 }
200 return $comps;
201 }
202
209 public static function deleteTooltip($a_id)
210 {
211 global $DIC;
212
213 $ilDB = $DIC->database();
214
215 $ilDB->manipulate(
216 "DELETE FROM help_tooltip WHERE " .
217 " id = " . $ilDB->quote($a_id, "integer")
218 );
219 }
220
227 public static function deleteTooltipsOfModule($a_id)
228 {
229 global $DIC;
230
231 $ilDB = $DIC->database();
232
233 $ilDB->manipulate(
234 "DELETE FROM help_tooltip WHERE " .
235 " module_id = " . $ilDB->quote($a_id, "integer")
236 );
237 }
238
244 public static function getHelpLMId()
245 {
246 global $DIC;
247
248 $ilSetting = $DIC->settings();
249
250 $lm_id = 0;
251
252 if (OH_REF_ID > 0) {
253 $lm_id = ilObject::_lookupObjId(OH_REF_ID);
254 } else {
255 $hm = (int) $ilSetting->get("help_module");
256 if ($hm > 0) {
257 include_once("./Services/Help/classes/class.ilObjHelpSettings.php");
259 }
260 }
261
262 return $lm_id;
263 }
264}
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 $lng
Definition: privfeed.php:17
global $ilSetting
Definition: privfeed.php:17
global $DIC
Definition: saml.php:7
global $ilDB
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92