ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
MDEditorToolProvider.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
36 
38 {
39  use Hasher;
40 
42 
43  public function __construct(Container $dic)
44  {
45  parent::__construct($dic);
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 
138  {
139  yield from $this->services->paths()->navigatorFactory()->navigator(
140  $path,
141  $set->getRoot()
142  )->elementsAtFinalStep();
143  }
144 }
This describes the Legacy-Slate.
Definition: Legacy.php:26
const string SET_FOR_TREE
factory()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Tree Recursion, putting Entries into a Tree.
Definition: Recursion.php:42
getElements(SetInterface $set, PathInterface $path)
$c
Definition: deliver.php:25
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
$path
Definition: ltiservices.php:29
getRoot()
Returns the root element of the metadata set.
getToolsForContextStack(CalledContexts $called_contexts)
buildTreeAsTool(SetInterface $set, PathInterface $path)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes a Tree Control.
Definition: Tree.php:28
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(Container $dic, ilPlugin $plugin)
global $lng
Definition: privfeed.php:31
const string PATH_FOR_TREE
$dic
Definition: result.php:31
getUITree(SetInterface $set, PathInterface $path)