ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLMEditGSToolProvider.php
Go to the documentation of this file.
1<?php
2
22use ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
24
31{
32 use Hasher;
33 public const SHOW_TREE = 'show_tree';
34
39 {
40 return $this->context_collection->main()->repository();
41 }
42
43
47 public function getToolsForContextStack(CalledContexts $called_contexts): array
48 {
49 $tools = [];
50 $additional_data = $called_contexts->current()->getAdditionalData();
51 if ($additional_data->is(self::SHOW_TREE, true)) {
52 $title = $this->dic->language()->txt('objs_st');
53 $icon = $this->dic->ui()->factory()->symbol()->icon()->custom(\ilUtil::getImagePath("standard/icon_chp.svg"), $title);
54
55 $iff = function ($id) {
56 return $this->identification_provider->contextAwareIdentifier($id);
57 };
58 $l = function (string $content) {
59 return $this->dic->ui()->factory()->legacy()->content($content);
60 };
61 $identification = $iff("tree");
62 $hashed = $this->hash($identification->serialize());
63 $tools[] = $this->factory->tool($identification)
64 ->addComponentDecorator(static function (ILIAS\UI\Component\Component $c) use ($hashed): ILIAS\UI\Component\Component {
65 if ($c instanceof LegacySlate) {
66 $signal_id = $c->getToggleSignal()->getId();
67 return $c->withAdditionalOnLoadCode(static function ($id) use ($hashed) {
68 return "document.addEventListener('il-lm-editor-tree', () => {
69 il.UI.maincontrols.mainbar.engageTool('$hashed');
70 });";
71 });
72 }
73 return $c;
74 })
75 ->withTitle($title)
76 ->withSymbol($icon)
77 ->withContentWrapper(function () use ($l) {
78 return $l($this->getContent());
79 });
80 }
81
82 return $tools;
83 }
84
85
90 private function getContent(): string
91 {
92 global $DIC;
93 $request = $DIC->learningModule()
94 ->internal()
95 ->gui()
96 ->editing()
97 ->request();
98
99 $lm = new ilObjLearningModule($request->getRefId());
100
101 $exp = new ilLMEditorExplorerGUI("illmeditorgui", "showTree", $lm);
102
103 return $exp->getHTML(true);
104 }
105}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
factory()
Learning module editing GS tool provider.
getToolsForContextStack(CalledContexts $called_contexts)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
$c
Definition: deliver.php:25
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:26