ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilHelpGSToolProvider.php
Go to the documentation of this file.
1<?php
2
3use ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
9
15{
16 const SHOW_HELP_TOOL = 'show_help_tool';
17 use ilHelpDisplayed;
18 use Hasher;
19
24 {
25 return $this->context_collection->main();
26 }
27
31 public function getToolsForContextStack(CalledContexts $called_contexts) : array
32 {
33 global $DIC;
34
36 $help_gui = $DIC["ilHelp"];
37
38 $lng = $DIC->language();
39 $lng->loadLanguageModule("help");
40 $f = $DIC->ui()->factory();
41
42 $tools = [];
43
44 $hidden = !$help_gui->isHelpPageActive();
45
46 $title = $lng->txt("help");
47 $icon = $f->symbol()->icon()->standard("hlps", $title)->withIsOutlined(true);
48
49 if ($this->showHelpTool()) {
50 $iff = function ($id) {
51 return $this->identification_provider->contextAwareIdentifier($id, true);
52 };
53 $l = function (string $content) {
54 return $this->dic->ui()->factory()->legacy($content);
55 };
56
57 $identification = $iff("help");
58 $hashed = $this->hash($identification->serialize());
59 $tools[] = $this->factory->tool($identification)
60 ->addComponentDecorator(static function (ILIAS\UI\Component\Component $c) use ($hashed, $hidden) : ILIAS\UI\Component\Component {
61 if ($c instanceof LegacySlate) {
62 $signal_id = $c->getToggleSignal()->getId();
63 return $c->withAdditionalOnLoadCode(static function ($id) use ($hashed, $hidden) {
64 return "
65 $('body').on('il-help-toggle-slate', function(){
66 if (!$('#$id').hasClass('disengaged')) {
67 il.Help.resetCurrentPage();
68 il.UI.maincontrols.mainbar.removeTool('$hashed');
69 } else {
70 il.UI.maincontrols.mainbar.engageTool('$hashed');
71 }
72 });";
73 });
74 }
75 return $c;
76 })
77 ->withInitiallyHidden($hidden)
78 ->withTitle($title)
79 ->withSymbol($icon)
80 ->withContentWrapper(function () use ($l) {
81 return $l($this->getHelpContent());
82 })
83 ->withPosition(90);
84 }
85
86 return $tools;
87 }
88
94 private function getHelpContent() : string
95 {
96 global $DIC;
97
98 $ctrl = $DIC->ctrl();
99 $main_tpl = $DIC->ui()->mainTemplate();
100
102 $help_gui = $DIC["ilHelp"];
103
104 $help_gui->initHelp($main_tpl, $ctrl->getLinkTargetByClass("ilhelpgui", "", "", true));
105
106 $html = "";
107 if ((defined("OH_REF_ID") && OH_REF_ID > 0) || DEVMODE == 1) {
108 $html = "<div class='ilHighlighted small'>Screen ID: " . $help_gui->getScreenId() . "</div>";
109 }
110
111 $html .= "<div id='ilHelpPanel'>&nbsp;</div>";
112
113 return $html;
114 }
115}
An exception for terminatinating execution or to throw for unit testing.
Class ilHelpGSToolProvider.
getToolsForContextStack(CalledContexts $called_contexts)
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.
$lng
$DIC
Definition: xapitoken.php:46