ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilHelpGUI.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
5include_once ("Services/Help/classes/class.ilHelp.php");
6
17{
18 var $help_sections = array();
19 const ID_PART_SCREEN = "screen";
20 const ID_PART_SUB_SCREEN = "sub_screen";
21 const ID_PART_COMPONENT = "component";
22 var $def_screen_id = array();
23 var $screen_id = array();
24
28 function ilHelpGUI()
29 {
30 global $ilCtrl;
31
32 $this->ctrl =& $ilCtrl;
33 }
34
41 function setDefaultScreenId($a_part, $a_id)
42 {
43 $this->def_screen_id[$a_part] = $a_id;
44 }
45
51 function setScreenId($a_id)
52 {
53 $this->screen_id[self::ID_PART_SCREEN] = $a_id;
54 }
55
61 function setSubScreenId($a_id)
62 {
63 $this->screen_id[self::ID_PART_SUB_SCREEN] = $a_id;
64 }
65
72 function setScreenIdComponent($a_comp)
73 {
74 $this->screen_id_component = $a_comp;
75 }
76
77
84 function getScreenId()
85 {
86 $comp = ($this->screen_id_component != "")
87 ? $this->screen_id_component
88 : $this->def_screen_id[self::ID_PART_COMPONENT];
89
90 if ($comp == "")
91 {
92 return "";
93 }
94
95 $scr_id = ($this->screen_id[self::ID_PART_SCREEN] != "")
96 ? $this->screen_id[self::ID_PART_SCREEN]
97 : $this->def_screen_id[self::ID_PART_SCREEN];
98
99 $sub_scr_id = ($this->screen_id[self::ID_PART_SUB_SCREEN] != "")
100 ? $this->screen_id[self::ID_PART_SUB_SCREEN]
101 : $this->def_screen_id[self::ID_PART_SUB_SCREEN];
102
103 $screen_id = $comp."/".
104 $scr_id."/".
105 $sub_scr_id;
106
107 return $screen_id;
108 }
109
110
117 function addHelpSection($a_help_id, $a_level = 1)
118 {
119 $this->help_sections[] = array("help_id" => $a_help_id, $a_level);
120 }
121
128 function hasSections()
129 {
130 global $ilSetting;
131
132 include_once("./Services/Help/classes/class.ilHelpMapping.php");
134 }
135
143 {
144 include_once("./Services/Help/classes/class.ilHelpMapping.php");
145 return ilHelpMapping::getHelpSectionsForId($this->getScreenId(), (int) $_GET["ref_id"]);
146 }
147
154 function setCtrlPar()
155 {
156 global $ilCtrl;
157
158 /*$h_ids = $sep = "";
159 foreach ($this->getHelpSections() as $hs)
160 {
161 $h_ids.= $sep.$hs;
162 $sep = ",";
163 }*/
164 $ilCtrl->setParameterByClass("ilhelpgui", "help_screen_id", $this->getScreenId().".".$_GET["ref_id"]);
165 }
166
167
171 function executeCommand()
172 {
173 $cmd = $this->ctrl->getCmd("showHelp");
174 $next_class = $this->ctrl->getNextClass($this);
175
176 switch($next_class)
177 {
178 default:
179 return $this->$cmd();
180 break;
181 }
182 }
183
187 function showHelp()
188 {
189 global $ilHelp, $lng, $ilSetting;
190
191 if ($_GET["help_screen_id"] != "")
192 {
193 ilSession::set("help_screen_id", $_GET["help_screen_id"]);
194 $help_screen_id = $_GET["help_screen_id"];
195 }
196 else
197 {
198 $help_screen_id = ilSession::get("help_screen_id");
199 }
200
201 $this->resetCurrentPage();
202
203 $id_arr = explode(".", $help_screen_id);
204 include_once("./Services/Help/classes/class.ilHelpMapping.php");
205 $help_arr = ilHelpMapping::getHelpSectionsForId($id_arr[0], $id_arr[1]);
206
207 $hm = (int) $ilSetting->get("help_module");
208
209 if ((OH_REF_ID > 0 || $hm > 0) && count($help_arr) > 0)
210 {
211 if (OH_REF_ID > 0)
212 {
213 $oh_lm_id = ilObject::_lookupObjId(OH_REF_ID);
214 }
215 else
216 {
217 include_once("./Services/Help/classes/class.ilObjHelpSettings.php");
219 }
220
221 include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
222 $acc = new ilAccordionGUI();
223 $acc->setId("oh_acc_".$h_id);
224 $acc->setUseSessionStorage(true);
225 $acc->setBehaviour(ilAccordionGUI::FIRST_OPEN);
226
227 foreach ($help_arr as $h_id)
228 {
229 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
230 $st_id = $h_id;
231
232 if (!ilLMObject::_exists($st_id))
233 {
234 continue;
235 }
236
237 $pages = ilLMObject::getPagesOfChapter($oh_lm_id, $st_id);
238 include_once("./Services/UIComponent/GroupedList/classes/class.ilGroupedListGUI.php");
239 $grp_list = new ilGroupedListGUI();
240 foreach ($pages as $pg)
241 {
242 $grp_list->addEntry(ilLMObject::_lookupTitle($pg["child"]), "#", "",
243 "return il.Help.showPage(".$pg["child"].");");
244 }
245
246 $acc->addItem(ilLMObject::_lookupTitle($st_id), $grp_list->getHTML());
247 }
248 $h_tpl = new ilTemplate("tpl.help.html", true, true, "Services/Help");
249 $h_tpl->setVariable("HEAD", $lng->txt("help"));
250 $h_tpl->setVariable("CONTENT", $acc->getHTML());
251 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
252 $h_tpl->setVariable("CLOSE_IMG", ilGlyphGUI::get(ilGlyphGUI::CLOSE));
253 echo $h_tpl->get();
254 }
255 exit;
256 }
257
264 function showPage()
265 {
266 global $lng;
267
268 $page_id = (int) $_GET["help_page"];
269
270 $h_tpl = new ilTemplate("tpl.help.html", true, true, "Services/Help");
271 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
272
273 $h_tpl->setCurrentBlock("backlink");
274 $h_tpl->setVariable("TXT_BACK", $lng->txt("back"));
275 $h_tpl->setVariable("ONCLICK_BACK",
276 "return il.Help.listHelp(event, true);");
277 $h_tpl->parseCurrentBlock();
278
279
280 $h_tpl->setVariable("HEAD", $lng->txt("help")." - ".
281 ilLMObject::_lookupTitle($page_id));
282
283 include_once("./Services/COPage/classes/class.ilPageUtil.php");
284 if (!ilPageUtil::_existsAndNotEmpty("lm", $page_id))
285 {
286 exit;
287 }
288 include_once("./Services/COPage/classes/class.ilPageObject.php");
289 include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
290
291 // get page object
292 include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
293 include_once("./Modules/LearningModule/classes/class.ilLMPageGUI.php");
294 $page_gui = new ilLMPageGUI($page_id);
295 $cfg = $page_gui->getPageConfig();
296 $page_gui->setPresentationTitle("");
297 $page_gui->setTemplateOutput(false);
298 $page_gui->setHeader("");
299 $page_gui->setRawPageContent(true);
300 $cfg->setEnablePCType("Map", false);
301 $cfg->setEnablePCType("Tabs", false);
302 $cfg->setEnablePCType("FileList", false);
303
304 $page_gui->getPageObject()->buildDom();
305 $int_links = $page_gui->getPageObject()->getInternalLinks();
306 $link_xml = $this->getLinkXML($int_links);
307 $link_xml.= $this->getLinkTargetsXML();
308//echo htmlentities($link_xml);
309 $page_gui->setLinkXML($link_xml);
310
311 $ret = $page_gui->showPage();
312
313 $h_tpl->setVariable("CONTENT", $ret);
314 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
315 $h_tpl->setVariable("CLOSE_IMG", ilGlyphGUI::get(ilGlyphGUI::CLOSE));
316
317 ilSession::set("help_pg", $page_id);
318
319 $page = $h_tpl->get();
320
321 // replace style classes
322 //$page = str_replace("ilc_text_inline_Strong", "ilHelpStrong", $page);
323
324 echo $page;
325 exit;
326 }
327
335 {
336 ilSession::clear("help_pg");
337 }
338
339
346 function getTabTooltipText($a_tab_id)
347 {
348 global $lng;
349
350 include_once("./Services/Help/classes/class.ilHelp.php");
351 if ($this->screen_id_component != "")
352 {
353 return ilHelp::getTooltipPresentationText($this->screen_id_component."_".$a_tab_id);
354 //return $lng->txt("help_tt_".$this->screen_id_component."_".$a_tab_id);
355 }
356 return "";
357 }
358
365 function initHelp($a_tpl)
366 {
367 global $ilUser, $ilSetting;
368
369 $module_id = (int) $ilSetting->get("help_module");
370
371 if ((OH_REF_ID > 0 || $module_id > 0) && $ilUser->getLanguage() == "de")
372 {
373 if (ilSession::get("help_pg") > 0)
374 {
375 $a_tpl->addOnLoadCode("il.Help.showCurrentPage(".ilSession::get("help_pg").");", 3);
376 }
377 if ($ilUser->getPref("hide_help_tt"))
378 {
379 $a_tpl->addOnLoadCode("if (il && il.Help) il.Help.switchTooltips();", 3);
380 }
381 }
382 }
383
391 {
392 global $ilUser;
393
394 $ilUser->writePref("hide_help_tt", "1");
395 }
396
404 {
405 global $ilUser;
406
407 $ilUser->writePref("hide_help_tt", "0");
408 }
409
413 function getLinkXML($a_int_links)
414 {
415 global $ilCtrl;
416
417 $link_info = "<IntLinkInfos>";
418 foreach ($a_int_links as $int_link)
419 {
420 $target = $int_link["Target"];
421 if (substr($target, 0, 4) == "il__")
422 {
423 $target_arr = explode("_", $target);
424 $target_id = $target_arr[count($target_arr) - 1];
425 $type = $int_link["Type"];
426 $targetframe = "None";
427
428 // anchor
429 $anc = $anc_add = "";
430 if ($int_link["Anchor"] != "")
431 {
432 $anc = $int_link["Anchor"];
433 $anc_add = "_".rawurlencode($int_link["Anchor"]);
434 }
435
436 switch($type)
437 {
438 case "PageObject":
439 case "StructureObject":
440 if ($type == "PageObject")
441 {
442 $href = "#pg_".$target_id;
443 }
444 else
445 {
446 $href = "#";
447 }
448 break;
449
450 }
451
452 $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
453 "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"\" Anchor=\"\"/>";
454 }
455 }
456 $link_info.= "</IntLinkInfos>";
457
458 return $link_info;
459 }
460
465 {
466 $link_info = "<LinkTargets>";
467 $link_info.="<LinkTarget TargetFrame=\"None\" LinkTarget=\"\" OnClick=\"return il.Help.openLink(event);\" />";
468 $link_info.= "</LinkTargets>";
469 return $link_info;
470 }
471
472}
473?>
$_GET["client_id"]
Accordion user interface class.
static get($a_glyph, $a_text="")
Get glyph html.
Grouped list GUI class.
Help GUI class.
hasSections()
Has sections?
addHelpSection($a_help_id, $a_level=1)
Add help section.
getLinkXML($a_int_links)
get xml for links
showHelp()
Show online help.
const ID_PART_COMPONENT
getHelpSections()
Get help sections.
getTabTooltipText($a_tab_id)
Get tab tooltip text.
getLinkTargetsXML()
Get XMl for Link Targets.
setDefaultScreenId($a_part, $a_id)
Set default screen id.
initHelp($a_tpl)
Render current help page.
setCtrlPar()
Get help section url parameter.
deactivateTooltips()
Deactivate tooltips.
executeCommand()
execute command
const ID_PART_SCREEN
ilHelpGUI()
constructor
const ID_PART_SUB_SCREEN
getScreenId()
Get screen id.
showPage()
Show page.
resetCurrentPage()
Hide help.
setSubScreenId($a_id)
Set sub screen id.
setScreenId($a_id)
Set screen id.
activateTooltips()
Activate tooltips.
setScreenIdComponent($a_comp)
Set screen id component.
static getHelpSectionsForId($a_screen_id, $a_ref_id)
Get help sections for screen id.
hasScreenIdSections($a_screen_id)
Has given screen Id any sections?
static getTooltipPresentationText($a_tt_id)
Get tooltip for id.
_exists($a_id)
checks wether a lm content object with specified id exists or not
static getPagesOfChapter($a_lm_id, $a_chap_id)
Get pages of chapter.
static _lookupTitle($a_obj_id)
Lookup title.
Extension of ilPageObjectGUI for learning modules.
lookupModuleLmId($a_id)
lookup module lm id
static _lookupObjId($a_id)
_existsAndNotEmpty($a_parent_type, $a_id, $a_lang="-")
checks whether page exists and is not empty (may return true on some empty pages)
static set($a_var, $a_val)
Set a value.
static clear($a_var)
Unset a value.
static get($a_var)
Get a value.
special template class to simplify handling of ITX/PEAR
$target_id
Definition: goto.php:88
$target_arr
Definition: goto.php:86
global $ilCtrl
Definition: ilias.php:18
exit
Definition: login.php:54
global $lng
Definition: privfeed.php:40
global $ilSetting
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
global $ilUser
Definition: imgupload.php:15