ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
MDEditorToolProvider.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
30use ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
36
38{
39 use Hasher;
40
42
43 public function __construct(Container $dic)
44 {
46 $this->services = new InternalServices($dic);
47 }
48
50 {
51 return $this->context_collection->main()->repository()->desktop();
52 }
53
58 public function getToolsForContextStack(
59 CalledContexts $called_contexts
60 ): array {
61 $last_context = $called_contexts->getLast();
62
63 if ($last_context) {
64 $additional_data = $last_context->getAdditionalData();
65 if (
66 $additional_data->exists(\ilMDEditorGUI::SET_FOR_TREE) &&
67 $additional_data->exists(\ilMDEditorGUI::PATH_FOR_TREE)
68 ) {
69 return [$this->buildTreeAsTool(
70 $additional_data->get(\ilMDEditorGUI::SET_FOR_TREE),
71 $additional_data->get(\ilMDEditorGUI::PATH_FOR_TREE)
72 )];
73 }
74 }
75
76 return [];
77 }
78
80 {
81 $id_generator = function ($id) {
82 return $this->identification_provider->contextAwareIdentifier($id);
83 };
84 $identification = $id_generator('system_styles_tree');
85 $hashed = $this->hash($identification->serialize());
86
87 $lng = $this->services->presentation()->utilities();
88
89 return $this->factory
90 ->tool($identification)
91 ->withTitle(
92 $lng->txt('meta_lom_short')
93 )
94 ->withSymbol(
95 $this->services->dic()->ui()->factory()->symbol()->icon()->standard(
96 'mds',
97 $lng->txt('meta_lom_short')
98 )
99 )
100 ->withContent($this->services->dic()->ui()->factory()->legacy()->content(
101 $this->services->dic()->ui()->renderer()->render($this->getUITree(
102 $set,
103 $path
104 ))
105 ))
106 ->addComponentDecorator(static function (Component $c) use ($hashed): Component {
107 if ($c instanceof LegacySlate) {
108 $signal_id = $c->getToggleSignal()->getId();
109 return $c->withAdditionalOnLoadCode(static function ($id) use ($hashed) {
110 return "il.UI.maincontrols.mainbar.engageTool('$hashed');";
111 });
112 }
113 return $c;
114 });
115 }
116
117 protected function getUITree(SetInterface $set, PathInterface $path): Tree
118 {
119 $recursion = new Recursion(
120 $this->services->paths()->pathFactory(),
121 $this->services->editor()->presenter(),
122 $this->services->editor()->dictionary(),
123 $this->services->editor()->linkFactory(),
124 ...$this->getElements($set, $path)
125 );
126 $f = $this->services->dic()->ui()->factory();
127
128 return $f->tree()
129 ->expandable('MD Editor Tree', $recursion)
130 ->withData([$set->getRoot()])
131 ->withHighlightOnNodeClick(true);
132 }
133
137 protected function getElements(SetInterface $set, PathInterface $path): \Generator
138 {
139 yield from $this->services->paths()->navigatorFactory()->navigator(
140 $path,
141 $set->getRoot()
142 )->elementsAtFinalStep();
143 }
144}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
factory()
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
buildTreeAsTool(SetInterface $set, PathInterface $path)
getUITree(SetInterface $set, PathInterface $path)
getToolsForContextStack(CalledContexts $called_contexts)
getElements(SetInterface $set, PathInterface $path)
Tree Recursion, putting Entries into a Tree.
Definition: Recursion.php:43
const string PATH_FOR_TREE
const string SET_FOR_TREE
$c
Definition: deliver.php:25
getRoot()
Returns the root element of the metadata set.
A component is the most general form of an entity in the UI.
Definition: Component.php:28
This describes the Legacy-Slate.
Definition: Legacy.php:27
This describes a Tree Control.
Definition: Tree.php:29
$dic
Definition: ltiresult.php:33
$path
Definition: ltiservices.php:30
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $lng
Definition: privfeed.php:31