ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilHelpGSToolProvider.php
Go to the documentation of this file.
1<?php
2
19use ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
25
31{
32 use ilHelpDisplayed;
33 use Hasher;
34
35 public const SHOW_HELP_TOOL = 'show_help_tool';
36
38 {
39 return $this->context_collection->main();
40 }
41
42 public function getToolsForContextStack(CalledContexts $called_contexts): array
43 {
44 global $DIC;
45
47 $help_gui = $DIC["ilHelp"];
48
49 $lng = $DIC->language();
50 $lng->loadLanguageModule("help");
51 $f = $DIC->ui()->factory();
52
53 $tools = [];
54
55 $hidden = !$help_gui->isHelpPageActive();
56
57 $title = $lng->txt("help");
58 $icon = $f->symbol()->icon()->standard("hlps", $title);
59
60 if ($this->showHelpTool()) {
61 $iff = function ($id) {
62 return $this->identification_provider->contextAwareIdentifier($id, true);
63 };
64 $l = function (string $content) {
65 return $this->dic->ui()->factory()->legacy()->content($content);
66 };
67
68 $identification = $iff("help");
69 $hashed = $this->hash($identification->serialize());
70 $tools[] = $this->factory->tool($identification)
71 ->addComponentDecorator(static function (ILIAS\UI\Component\Component $c) use ($hashed, $hidden): ILIAS\UI\Component\Component {
72 if ($c instanceof LegacySlate) {
73 $signal_id = $c->getToggleSignal()->getId();
74 return $c->withAdditionalOnLoadCode(static function ($id) use ($hashed) {
75 return "
76 $('body').on('il-help-toggle-slate', function(){
77 if (!$('#$id').hasClass('disengaged')) {
78 il.Help.resetCurrentPage();
79 il.UI.maincontrols.mainbar.removeTool('$hashed');
80 } else {
81 il.UI.maincontrols.mainbar.engageTool('$hashed');
82 const panel = document.getElementById('ilHelpPanel');
83 const firstFocusElement = panel.querySelector('a,input,[role=\'button\'],button');
84 if (firstFocusElement) {
85 firstFocusElement.focus();
86 }
87 }
88 });";
89 });
90 }
91 return $c;
92 })
93 ->withInitiallyHidden($hidden)
94 ->withTitle($title)
95 ->withSymbol($icon)
96 ->withContentWrapper(function () use ($l) {
97 return $l($this->getHelpContent());
98 })
99 ->withPosition(90);
100 }
101
102 return $tools;
103 }
104
105 private function getHelpContent(): string
106 {
107 global $DIC;
108
109 $ctrl = $DIC->ctrl();
110 $main_tpl = $DIC->ui()->mainTemplate();
111
113 $help_gui = $DIC["ilHelp"];
114
115 $help_gui->initHelp($main_tpl, $ctrl->getLinkTargetByClass("ilhelpgui", "", "", true));
116
117 $html = "";
118 if ((defined("OH_REF_ID") && (int) OH_REF_ID > 0) || (defined('DEVMODE') && (int) DEVMODE === 1)) {
119 $html = "<div class='ilHighlighted small'>Screen ID: " . $help_gui->getScreenId() . "</div>";
120 }
121
122 $html .= "<div id='ilHelpPanel'>&nbsp;</div>";
123
124 return $html;
125 }
126}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
factory()
Class ilHelpGSToolProvider.
$c
Definition: deliver.php:25
getToolsForContextStack(CalledContexts $called_contexts)
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26