ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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{
21 protected $ctrl;
22
26 protected $settings;
27
31 protected $lng;
32
36 protected $user;
37
38 public $help_sections = array();
39 const ID_PART_SCREEN = "screen";
40 const ID_PART_SUB_SCREEN = "sub_screen";
41 const ID_PART_COMPONENT = "component";
42 public $def_screen_id = array();
43 public $screen_id = array();
44
48 public function __construct()
49 {
50 global $DIC;
51
52 $this->settings = $DIC->settings();
53 $this->lng = $DIC->language();
54 $this->user = $DIC->user();
55 $ilCtrl = $DIC->ctrl();
56
57 $this->ctrl = $ilCtrl;
58 }
59
66 public function setDefaultScreenId($a_part, $a_id)
67 {
68 $this->def_screen_id[$a_part] = $a_id;
69 }
70
76 public function setScreenId($a_id)
77 {
78 $this->screen_id[self::ID_PART_SCREEN] = $a_id;
79 }
80
86 public function setSubScreenId($a_id)
87 {
88 $this->screen_id[self::ID_PART_SUB_SCREEN] = $a_id;
89 }
90
97 public function setScreenIdComponent($a_comp)
98 {
99 $this->screen_id_component = $a_comp;
100 }
101
102
109 public function getScreenId()
110 {
111 $comp = ($this->screen_id_component != "")
112 ? $this->screen_id_component
113 : $this->def_screen_id[self::ID_PART_COMPONENT];
114
115 if ($comp == "") {
116 return "";
117 }
118
119 $scr_id = ($this->screen_id[self::ID_PART_SCREEN] != "")
120 ? $this->screen_id[self::ID_PART_SCREEN]
121 : $this->def_screen_id[self::ID_PART_SCREEN];
122
123 $sub_scr_id = ($this->screen_id[self::ID_PART_SUB_SCREEN] != "")
124 ? $this->screen_id[self::ID_PART_SUB_SCREEN]
125 : $this->def_screen_id[self::ID_PART_SUB_SCREEN];
126
127 $screen_id = $comp . "/" .
128 $scr_id . "/" .
129 $sub_scr_id;
130
131 return $screen_id;
132 }
133
134
141 public function addHelpSection($a_help_id, $a_level = 1)
142 {
143 $this->help_sections[] = array("help_id" => $a_help_id, $a_level);
144 }
145
152 public function hasSections()
153 {
155
156 include_once("./Services/Help/classes/class.ilHelpMapping.php");
158 }
159
166 public function getHelpSections()
167 {
168 include_once("./Services/Help/classes/class.ilHelpMapping.php");
169 return ilHelpMapping::getHelpSectionsForId($this->getScreenId(), (int) $_GET["ref_id"]);
170 }
171
178 public function setCtrlPar()
179 {
181
182 /*$h_ids = $sep = "";
183 foreach ($this->getHelpSections() as $hs)
184 {
185 $h_ids.= $sep.$hs;
186 $sep = ",";
187 }*/
188 $ilCtrl->setParameterByClass("ilhelpgui", "help_screen_id", $this->getScreenId() . "." . $_GET["ref_id"]);
189 }
190
191
195 public function executeCommand()
196 {
197 $cmd = $this->ctrl->getCmd("showHelp");
198 $next_class = $this->ctrl->getNextClass($this);
199
200 switch ($next_class) {
201 default:
202 return $this->$cmd();
203 break;
204 }
205 }
206
210 public function showHelp()
211 {
213
214 if ($_GET["help_screen_id"] != "") {
215 ilSession::set("help_screen_id", $_GET["help_screen_id"]);
216 $help_screen_id = $_GET["help_screen_id"];
217 } else {
218 $help_screen_id = ilSession::get("help_screen_id");
219 }
220
221 ilSession::set("help_search_term", "");
222
223 $this->resetCurrentPage();
224
225 $id_arr = explode(".", $help_screen_id);
226 include_once("./Services/Help/classes/class.ilHelpMapping.php");
227 include_once("./Services/Help/classes/class.ilHelp.php");
228
229 $help_arr = ilHelpMapping::getHelpSectionsForId($id_arr[0], $id_arr[1]);
230 $oh_lm_id = ilHelp::getHelpLMId();
231
232 if ($oh_lm_id > 0 && count($help_arr) > 0) {
233 include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
234 $acc = new ilAccordionGUI();
235 $acc->setId("oh_acc_" . $h_id);
236 $acc->setUseSessionStorage(true);
237 $acc->setBehaviour(ilAccordionGUI::FIRST_OPEN);
238
239 foreach ($help_arr as $h_id) {
240 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
241 $st_id = $h_id;
242
243 if (!ilLMObject::_exists($st_id)) {
244 continue;
245 }
246
247 $pages = ilLMObject::getPagesOfChapter($oh_lm_id, $st_id);
248 include_once("./Services/UIComponent/GroupedList/classes/class.ilGroupedListGUI.php");
249 $grp_list = new ilGroupedListGUI();
250 foreach ($pages as $pg) {
251 $grp_list->addEntry(
252 ilLMObject::_lookupTitle($pg["child"]),
253 "#",
254 "",
255 "return il.Help.showPage(" . $pg["child"] . ");"
256 );
257 }
258
259 $acc->addItem(ilLMObject::_lookupTitle($st_id), $grp_list->getHTML());
260 }
261 $h_tpl = new ilTemplate("tpl.help.html", true, true, "Services/Help");
262 $h_tpl->setVariable("HEAD", $lng->txt("help"));
263
264 $h_tpl->setCurrentBlock("search");
265 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
266 $h_tpl->setVariable("GL_SEARCH", ilGlyphGUI::get(ilGlyphGUI::SEARCH));
267 $h_tpl->parseCurrentBlock();
268
269 $h_tpl->setVariable("CONTENT", $acc->getHTML());
270 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
271 $h_tpl->setVariable("CLOSE_IMG", ilGlyphGUI::get(ilGlyphGUI::CLOSE));
272 echo $h_tpl->get();
273 }
274 exit;
275 }
276
283 public function showPage()
284 {
286
287 $page_id = (int) $_GET["help_page"];
288
289 $h_tpl = new ilTemplate("tpl.help.html", true, true, "Services/Help");
290 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
291
292
293 $h_tpl->setCurrentBlock("backlink");
294 $h_tpl->setVariable("TXT_BACK", $lng->txt("back"));
295 if (($t = ilSession::get("help_search_term")) != "") {
296 $h_tpl->setVariable(
297 "ONCLICK_BACK",
298 "return il.Help.search('" . ilUtil::prepareFormOutput($t) . "');"
299 );
300 } else {
301 $h_tpl->setVariable(
302 "ONCLICK_BACK",
303 "return il.Help.listHelp(event, true);"
304 );
305 }
306 $h_tpl->parseCurrentBlock();
307
308
309 $h_tpl->setVariable("HEAD", $lng->txt("help") . " - " .
310 ilLMObject::_lookupTitle($page_id));
311
312 include_once("./Services/COPage/classes/class.ilPageUtil.php");
313 if (!ilPageUtil::_existsAndNotEmpty("lm", $page_id)) {
314 exit;
315 }
316 include_once("./Services/COPage/classes/class.ilPageObject.php");
317 include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
318
319 // get page object
320 include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
321 include_once("./Modules/LearningModule/classes/class.ilLMPageGUI.php");
322 $page_gui = new ilLMPageGUI($page_id);
323 $cfg = $page_gui->getPageConfig();
324 $page_gui->setPresentationTitle("");
325 $page_gui->setTemplateOutput(false);
326 $page_gui->setHeader("");
327 $page_gui->setRawPageContent(true);
328 $cfg->setEnablePCType("Map", false);
329 $cfg->setEnablePCType("Tabs", false);
330 $cfg->setEnablePCType("FileList", false);
331
332 $page_gui->getPageObject()->buildDom();
333 $int_links = $page_gui->getPageObject()->getInternalLinks();
334 $link_xml = $this->getLinkXML($int_links);
335 $link_xml .= $this->getLinkTargetsXML();
336 //echo htmlentities($link_xml);
337 $page_gui->setLinkXML($link_xml);
338
339 $ret = $page_gui->showPage();
340
341 $h_tpl->setVariable("CONTENT", $ret);
342 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
343 $h_tpl->setVariable("CLOSE_IMG", ilGlyphGUI::get(ilGlyphGUI::CLOSE));
344
345 ilSession::set("help_pg", $page_id);
346
347 $page = $h_tpl->get();
348
349 // replace style classes
350 //$page = str_replace("ilc_text_inline_Strong", "ilHelpStrong", $page);
351
352 echo $page;
353 exit;
354 }
355
362 public function resetCurrentPage()
363 {
364 ilSession::clear("help_pg");
365 }
366
367
374 public function getTabTooltipText($a_tab_id)
375 {
377
378 include_once("./Services/Help/classes/class.ilHelp.php");
379 if ($this->screen_id_component != "") {
380 return ilHelp::getTooltipPresentationText($this->screen_id_component . "_" . $a_tab_id);
381 //return $lng->txt("help_tt_".$this->screen_id_component."_".$a_tab_id);
382 }
383 return "";
384 }
385
392 public static function initHelp($a_tpl)
393 {
394 global $DIC;
395
396 $ilUser = $DIC->user();
397 $ilSetting = $DIC->settings();
398
399 $module_id = (int) $ilSetting->get("help_module");
400
401 if ((OH_REF_ID > 0 || $module_id > 0) && $ilUser->getLanguage() == "de") {
402 if (ilSession::get("help_pg") > 0) {
403 $a_tpl->addOnLoadCode("il.Help.showCurrentPage(" . ilSession::get("help_pg") . ");", 3);
404 }
405 $a_tpl->addJavascript("./Services/Help/js/ilHelp.js");
406 if ($ilUser->getPref("hide_help_tt")) {
407 $a_tpl->addOnLoadCode("if (il && il.Help) {il.Help.switchTooltips();}", 3);
408 }
409 }
410 }
411
418 public function deactivateTooltips()
419 {
421
422 $ilUser->writePref("hide_help_tt", "1");
423 }
424
431 public function activateTooltips()
432 {
434
435 $ilUser->writePref("hide_help_tt", "0");
436 }
437
441 public function getLinkXML($a_int_links)
442 {
444
445 $link_info = "<IntLinkInfos>";
446 foreach ($a_int_links as $int_link) {
447 $target = $int_link["Target"];
448 if (substr($target, 0, 4) == "il__") {
449 $target_arr = explode("_", $target);
450 $target_id = $target_arr[count($target_arr) - 1];
451 $type = $int_link["Type"];
452 $targetframe = "None";
453
454 // anchor
455 $anc = $anc_add = "";
456 if ($int_link["Anchor"] != "") {
457 $anc = $int_link["Anchor"];
458 $anc_add = "_" . rawurlencode($int_link["Anchor"]);
459 }
460
461 switch ($type) {
462 case "PageObject":
463 case "StructureObject":
464 if ($type == "PageObject") {
465 $href = "#pg_" . $target_id;
466 } else {
467 $href = "#";
468 }
469 break;
470
471 }
472
473 $link_info .= "<IntLinkInfo Target=\"$target\" Type=\"$type\" " .
474 "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"\" Anchor=\"\"/>";
475 }
476 }
477 $link_info .= "</IntLinkInfos>";
478
479 return $link_info;
480 }
481
485 public function getLinkTargetsXML()
486 {
487 $link_info = "<LinkTargets>";
488 $link_info .= "<LinkTarget TargetFrame=\"None\" LinkTarget=\"\" OnClick=\"return il.Help.openLink(event);\" />";
489 $link_info .= "</LinkTargets>";
490 return $link_info;
491 }
492
499 public function search()
500 {
502
503 $term = $_GET["term"];
504
505 if ($term == "") {
506 $term = ilSession::get("help_search_term");
507 }
508
509 $this->resetCurrentPage();
510
511 $h_tpl = new ilTemplate("tpl.help.html", true, true, "Services/Help");
512 include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
513
514 $h_tpl->setCurrentBlock("backlink");
515 $h_tpl->setVariable("TXT_BACK", $lng->txt("back"));
516 $h_tpl->setVariable(
517 "ONCLICK_BACK",
518 "return il.Help.listHelp(event, true);"
519 );
520 $h_tpl->parseCurrentBlock();
521
522
523 $h_tpl->setVariable("HEAD", $lng->txt("help") . " - " .
524 $lng->txt("search_result"));
525
526 $h_tpl->setCurrentBlock("search");
527 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
528 $h_tpl->setVariable("GL_SEARCH", ilGlyphGUI::get(ilGlyphGUI::SEARCH));
529 $h_tpl->setVariable("VAL_SEARCH", ilUtil::prepareFormOutput($term));
530 $h_tpl->parseCurrentBlock();
531
532 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
533 $h_tpl->setVariable("CLOSE_IMG", ilGlyphGUI::get(ilGlyphGUI::CLOSE));
534
535 $lm_id = ilHelp::getHelpLMId();
536 include_once("./Services/Search/classes/class.ilRepositoryObjectDetailSearch.php");
538 $s->setQueryString($term);
539 $result = $s->performSearch();
540
541 include_once("./Services/UIComponent/GroupedList/classes/class.ilGroupedListGUI.php");
542 $grp_list = new ilGroupedListGUI();
543 foreach ($result->getResults() as $r) {
544 $grp_list->addEntry(
545 ilLMObject::_lookupTitle($r["item_id"]),
546 "#",
547 "",
548 "return il.Help.showPage(" . $r["item_id"] . ");"
549 );
550 }
551 $h_tpl->setVariable("CONTENT", $grp_list->getHTML());
552
553 ilSession::set("help_search_term", $term);
554
555 echo $h_tpl->get();
556 ;
557 exit;
558 }
559}
$result
user()
Definition: user.php:4
exit
Definition: backend.php:16
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
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.
__construct()
constructor
setCtrlPar()
Get help section url parameter.
deactivateTooltips()
Deactivate tooltips.
executeCommand()
execute command
const ID_PART_SCREEN
const ID_PART_SUB_SCREEN
getScreenId()
Get screen id.
showPage()
Show page.
search()
Search.
resetCurrentPage()
Hide help.
setSubScreenId($a_id)
Set sub screen id.
setScreenId($a_id)
Set screen id.
static initHelp($a_tpl)
Render current help page.
activateTooltips()
Activate tooltips.
setScreenIdComponent($a_comp)
Set screen id component.
static hasScreenIdSections($a_screen_id)
Has given screen Id any sections?
static getHelpSectionsForId($a_screen_id, $a_ref_id)
Get help sections for screen id.
static getTooltipPresentationText($a_tt_id)
Get tooltip for id.
static getHelpLMId()
Get help lm id.
static getPagesOfChapter($a_lm_id, $a_chap_id)
Get pages of chapter.
static _lookupTitle($a_obj_id)
Lookup title.
static _exists($a_id)
checks wether a lm content object with specified id exists or not
Extension of ilPageObjectGUI for learning modules.
static _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
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
$r
Definition: example_031.php:79
$target_id
Definition: goto.php:49
$target_arr
Definition: goto.php:47
global $ilCtrl
Definition: ilias.php:18
$target
Definition: test.php:19
$ret
Definition: parser.php:6
global $ilSetting
Definition: privfeed.php:17
$type
$s
Definition: pwgen.php:45
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2
$ilUser
Definition: imgupload.php:18
catch(Exception $e) if(isset( $_POST[ 'cancel'])) if(isset($_POST['continue'])) $cfg