ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
MDEditorToolProvider.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use Generator;
31use ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
37
39{
40 use Hasher;
41
43
44 public function __construct(Container $dic)
45 {
47 $this->services = new InternalServices($dic);
48 }
49
51 {
52 return $this->context_collection->main()->repository()->desktop();
53 }
54
59 public function getToolsForContextStack(
60 CalledContexts $called_contexts
61 ): array {
62 $last_context = $called_contexts->getLast();
63
64 if ($last_context) {
65 $additional_data = $last_context->getAdditionalData();
66 if (
67 $additional_data->exists(\ilMDEditorGUI::SET_FOR_TREE) &&
68 $additional_data->exists(\ilMDEditorGUI::PATH_FOR_TREE)
69 ) {
70 return [$this->buildTreeAsTool(
71 $additional_data->get(\ilMDEditorGUI::SET_FOR_TREE),
72 $additional_data->get(\ilMDEditorGUI::PATH_FOR_TREE)
73 )];
74 }
75 }
76
77 return [];
78 }
79
81 {
82 $id_generator = function ($id) {
83 return $this->identification_provider->contextAwareIdentifier($id);
84 };
85 $identification = $id_generator('system_styles_tree');
86 $hashed = $this->hash($identification->serialize());
87
88 $lng = $this->services->presentation()->utilities();
89
90 return $this->factory
91 ->tool($identification)
92 ->withTitle(
93 $lng->txt('meta_lom_short')
94 )
95 ->withSymbol(
96 $this->services->dic()->ui()->factory()->symbol()->icon()->standard(
97 'mds',
98 $lng->txt('meta_lom_short')
99 )
100 )
101 ->withContent($this->services->dic()->ui()->factory()->legacy()->content(
102 $this->services->dic()->ui()->renderer()->render($this->getUITree(
103 $set,
104 $path
105 ))
106 ))
107 ->addComponentDecorator(static function (Component $c) use ($hashed): Component {
108 if ($c instanceof LegacySlate) {
109 $signal_id = $c->getToggleSignal()->getId();
110 return $c->withAdditionalOnLoadCode(static function ($id) use ($hashed) {
111 return "il.UI.maincontrols.mainbar.engageTool('$hashed');";
112 });
113 }
114 return $c;
115 });
116 }
117
118 protected function getUITree(SetInterface $set, PathInterface $path): Tree
119 {
120 $recursion = new Recursion(
121 $this->services->paths()->pathFactory(),
122 $this->services->editor()->internal()->presenter(),
123 $this->services->editor()->internal()->dictionary(),
124 $this->services->editor()->internal()->linkFactory(),
125 ...$this->getElements($set, $path)
126 );
127 $f = $this->services->dic()->ui()->factory();
128
129 return $f->tree()
130 ->expandable('MD Editor Tree', $recursion)
131 ->withData([$set->getRoot()])
132 ->withHighlightOnNodeClick(true);
133 }
134
138 protected function getElements(SetInterface $set, PathInterface $path): Generator
139 {
140 yield from $this->services->paths()->navigatorFactory()->navigator(
141 $path,
142 $set->getRoot()
143 )->elementsAtFinalStep();
144 }
145}
$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