1<?php
2
3use ILIAS\GlobalScreen\Scope\Layout\Factory\MainBarModification;
4use ILIAS\GlobalScreen\Scope\Layout\Provider\AbstractModificationProvider;
5use ILIAS\GlobalScreen\Scope\Layout\Provider\ModificationProvider;
6use ILIAS\GlobalScreen\Scope\MainMenu\Factory\hasSymbol;
7use ILIAS\GlobalScreen\ScreenContext\Stack\CalledContexts;
8use ILIAS\GlobalScreen\ScreenContext\Stack\ContextCollection;
9use ILIAS\UI\Component\JavaScriptBindable;
10use ILIAS\UI\Component\Symbol\Symbol;
11
12/**
13 * HTML export view layout provider, hides main and meta bar
14 * @author <killing@leifos.de>
15 */
16class ilHelpViewLayoutProvider extends AbstractModificationProvider implements ModificationProvider
17{
18    use \ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
19    use ilHelpDisplayed;
20
21    /**
22     * @inheritDoc
23     */
24    public function isInterestedInContexts() : ContextCollection
25    {
26        return $this->context_collection->main();
27    }
28
29    /**
30     * No main bar in HTML exports
31     */
32    public function getMainBarModification(CalledContexts $called_contexts) : ?MainBarModification
33    {
34        if (!$this->showHelpTool()) {
35            return null;
36        }
37        $this->globalScreen()->collector()->mainmenu()->collectOnce();
38        foreach ($this->globalScreen()->collector()->mainmenu()->getRawItems() as $item) {
39            $p = $item->getProviderIdentification();
40
41            $tt_text = ilHelp::getMainMenuTooltip($p->getInternalIdentifier());
42            $tt_text = addslashes(str_replace(array("\n", "\r"), '', $tt_text));
43
44            if ($tt_text != "") {
45                if ($item instanceof hasSymbol && $item->hasSymbol()) {
46                    $item->addSymbolDecorator(static function (Symbol $symbol) use ($tt_text) : Symbol {
47                        if ($symbol instanceof JavaScriptBindable) {
48                            return $symbol->withAdditionalOnLoadCode(static function ($id) use ($tt_text) : string {
49                                return "il.Tooltip.addToNearest('$id', 'button,a', { context:'', my:'bottom center', at:'top center', text:'$tt_text' });";
50                            });
51                        }
52                        return $symbol;
53                    });
54                }
55            }
56        }
57
58        ilTooltipGUI::init();
59
60        return null;
61    }
62}
63