ILIAS  release_8 Revision v8.24
class.ilHelp.php
Go to the documentation of this file.
1<?php
2
24class ilHelp
25{
26 public static function getTooltipPresentationText(
27 string $a_tt_id
28 ): string {
29 global $DIC;
30
31 $ilDB = $DIC->database();
32 $ilSetting = $DIC->settings();
33 $ilUser = $DIC->user();
34
35
36 if ($ilUser->getLanguage() !== "de") {
37 return "";
38 }
39
40 if ($ilSetting->get("help_mode") === "1") {
41 return "";
42 }
43
44 if ($ilUser->getPref("hide_help_tt")) {
45 return "";
46 }
47
48 if (defined('OH_REF_ID') && (int) OH_REF_ID > 0) {
49 $module_id = 0;
50 } else {
51 $module_id = (int) $ilSetting->get("help_module");
52 if ($module_id === 0) {
53 return "";
54 }
55 }
56
57 $set = $ilDB->query(
58 "SELECT tt_text FROM help_tooltip " .
59 " WHERE tt_id = " . $ilDB->quote($a_tt_id, "text") .
60 " AND module_id = " . $ilDB->quote($module_id, "integer")
61 );
62 $rec = $ilDB->fetchAssoc($set);
63 if (is_array($rec) && $rec["tt_text"] != "") {
64 $t = $rec["tt_text"];
65 if ($module_id === 0) {
66 $t .= "<br/><i>(" . $a_tt_id . ")</i>";
67 }
68 return $t;
69 } else { // try to get general version
70 $fu = strpos($a_tt_id, "_");
71 $gen_tt_id = "*" . substr($a_tt_id, $fu);
72 $set = $ilDB->query(
73 "SELECT tt_text FROM help_tooltip " .
74 " WHERE tt_id = " . $ilDB->quote($gen_tt_id, "text") .
75 " AND module_id = " . $ilDB->quote($module_id, "integer")
76 );
77 $rec = $ilDB->fetchAssoc($set);
78 if (is_array($rec) && $rec["tt_text"] != "") {
79 $t = $rec["tt_text"];
80 if ($module_id === 0) {
81 $t .= "<br/><i>(" . $a_tt_id . ")</i>";
82 }
83 return $t;
84 }
85 }
86 if ($module_id === 0) {
87 return "<i>" . $a_tt_id . "</i>";
88 }
89 return "";
90 }
91
95 public static function getObjCreationTooltipText(
96 string $a_type
97 ): string {
98 return self::getTooltipPresentationText($a_type . "_create");
99 }
100
104 public static function getMainMenuTooltip(
105 string $a_item_id
106 ): string {
107 return self::getTooltipPresentationText($a_item_id);
108 }
109
110 public static function getAllTooltips(
111 string $a_comp = "",
112 int $a_module_id = 0
113 ): array {
114 global $DIC;
115
116 $ilDB = $DIC->database();
117
118 $q = "SELECT * FROM help_tooltip";
119 $q .= " WHERE module_id = " . $ilDB->quote($a_module_id, "integer");
120 if ($a_comp !== "") {
121 $q .= " AND comp = " . $ilDB->quote($a_comp, "text");
122 }
123 $set = $ilDB->query($q);
124 $tts = array();
125 while ($rec = $ilDB->fetchAssoc($set)) {
126 $tts[$rec["id"]] = array("id" => $rec["id"], "text" => $rec["tt_text"],
127 "tt_id" => $rec["tt_id"]);
128 }
129 return $tts;
130 }
131
132 public static function addTooltip(
133 string $a_tt_id,
134 string $a_text,
135 int $a_module_id = 0
136 ): void {
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
155 public static function updateTooltip(
156 int $a_id,
157 string $a_text,
158 string $a_tt_id
159 ): void {
160 global $DIC;
161
162 $ilDB = $DIC->database();
163
164 $fu = strpos($a_tt_id, "_");
165 $comp = substr($a_tt_id, 0, $fu);
166
167 $ilDB->manipulate(
168 "UPDATE help_tooltip SET " .
169 " tt_text = " . $ilDB->quote($a_text, "text") . ", " .
170 " tt_id = " . $ilDB->quote($a_tt_id, "text") . ", " .
171 " comp = " . $ilDB->quote($comp, "text") .
172 " WHERE id = " . $ilDB->quote($a_id, "integer")
173 );
174 }
175
176
180 public static function getTooltipComponents(
181 int $a_module_id = 0
182 ): array {
183 global $DIC;
184
185 $ilDB = $DIC->database();
186 $lng = $DIC->language();
187
188 $set = $ilDB->query("SELECT DISTINCT comp FROM help_tooltip " .
189 " WHERE module_id = " . $ilDB->quote($a_module_id, "integer") .
190 " ORDER BY comp ");
191 $comps[""] = "- " . $lng->txt("help_all") . " -";
192 while ($rec = $ilDB->fetchAssoc($set)) {
193 $comps[$rec["comp"]] = $rec["comp"];
194 }
195 return $comps;
196 }
197
198 public static function deleteTooltip(
199 int $a_id
200 ): void {
201 global $DIC;
202
203 $ilDB = $DIC->database();
204
205 $ilDB->manipulate(
206 "DELETE FROM help_tooltip WHERE " .
207 " id = " . $ilDB->quote($a_id, "integer")
208 );
209 }
210
211 public static function deleteTooltipsOfModule(
212 int $a_id
213 ): void {
214 global $DIC;
215
216 $ilDB = $DIC->database();
217
218 $ilDB->manipulate(
219 "DELETE FROM help_tooltip WHERE " .
220 " module_id = " . $ilDB->quote($a_id, "integer")
221 );
222 }
223
228 public static function getHelpLMId(): int
229 {
230 global $DIC;
231
232 $ilSetting = $DIC->settings();
233
234 $lm_id = 0;
235
236 if ((int) OH_REF_ID > 0) {
237 $lm_id = ilObject::_lookupObjId((int) OH_REF_ID);
238 } else {
239 $hm = (int) $ilSetting->get("help_module");
240 if ($hm > 0) {
242 }
243 }
244
245 return $lm_id;
246 }
247}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static updateTooltip(int $a_id, string $a_text, string $a_tt_id)
static getObjCreationTooltipText(string $a_type)
Get object_creation tooltip tab text.
static deleteTooltip(int $a_id)
static getMainMenuTooltip(string $a_item_id)
static deleteTooltipsOfModule(int $a_id)
static getAllTooltips(string $a_comp="", int $a_module_id=0)
static getTooltipPresentationText(string $a_tt_id)
static getHelpLMId()
Get help lm id.
static getTooltipComponents(int $a_module_id=0)
Get all tooltip components.
static addTooltip(string $a_tt_id, string $a_text, int $a_module_id=0)
static lookupModuleLmId(int $a_id)
static _lookupObjId(int $ref_id)
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
global $ilSetting
Definition: privfeed.php:17
$lng