1<?php declare(strict_types=1);
2
3use ILIAS\GlobalScreen\Scope\Tool\Provider\AbstractDynamicToolProvider;
4
5require_once("Services/Style/System/classes/Documentation/class.ilSystemStyleDocumentationGUI.php");
6require_once("Services/Style/System/classes/Documentation/class.ilKSDocumentationExplorerGUI.php");
7
8/**
9 * Class SystemStylesGlobalScreenToolProvider
10 * @author Timon Amstutz
11 */
12class SystemStylesGlobalScreenToolProvider extends AbstractDynamicToolProvider
13{
14    const SHOW_MAIL_FOLDERS_TOOL = 'show_mail_folders_tool';
15
16    /**
17     * @inheritDoc
18     */
19    public function isInterestedInContexts() : \ILIAS\GlobalScreen\ScreenContext\Stack\ContextCollection
20    {
21        return $this->context_collection->administration();
22    }
23
24    /**
25     * @inheritDoc
26     */
27    public function getToolsForContextStack(\ILIAS\GlobalScreen\ScreenContext\Stack\CalledContexts $called_contexts) : array
28    {
29        $identification = function ($id) {
30            return $this->identification_provider->contextAwareIdentifier($id);
31        };
32
33        $tools = [];
34
35        $additional_data = $called_contexts->getLast()->getAdditionalData();
36        if ($additional_data->is(ilSystemStyleDocumentationGUI::SHOW_TREE, true)) {
37            $exp = new ilKSDocumentationExplorerGUI();
38
39            $title = $this->dic->language()->txt('documentation');
40            $icon = $this->dic->ui()->factory()->symbol()->icon()->standard('stys', $title)->withIsOutlined(true);
41
42            $tools[] = $this->factory
43                ->tool($identification('system_styles_tree'))
44                ->withTitle($title)
45                ->withSymbol($icon)
46                ->withContent($this->dic->ui()->factory()->legacy($exp->getHTML(true)));
47        }
48
49        return $tools;
50    }
51}
52