ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilCOPageEditGSToolProvider.php
Go to the documentation of this file.
1<?php
2
19use ILIAS\GlobalScreen\Scope\MainMenu\Collector\Renderer\Hasher;
24
31{
32 use Hasher;
33 public const SHOW_EDITOR = 'copg_show_editor';
34
36 {
37 return $this->context_collection->main()->repository();
38 }
39
40 public function getToolsForContextStack(CalledContexts $called_contexts): array
41 {
42 $tools = [];
43 $additional_data = $called_contexts->current()->getAdditionalData();
44 if ($additional_data->is(self::SHOW_EDITOR, true)) {
45 $title = $this->dic->language()->txt('editor');
46 $icon = $this->dic->ui()->factory()->symbol()->icon()->custom(\ilUtil::getImagePath("standard/icon_edtr.svg"), $title);
47
48 $iff = function ($id) {
49 return $this->identification_provider->contextAwareIdentifier($id);
50 };
51 $l = function (string $content) {
52 return $this->dic->ui()->factory()->legacy()->content($content);
53 };
54 $identification = $iff("copg_editor");
55 $hashed = $this->hash($identification->serialize());
56 $tools[] = $this->factory->tool($identification)
57 ->addComponentDecorator(static function (ILIAS\UI\Component\Component $c) use ($hashed): ILIAS\UI\Component\Component {
58 if ($c instanceof LegacySlate) {
59 $signal_id = $c->getToggleSignal()->getId();
60 return $c->withAdditionalOnLoadCode(static function ($id) use ($hashed) {
61 return "
62 $('body').on('il-copg-editor-slate', function(){
63 if (!il.UI.page.isSmallScreen()) {
64 il.UI.maincontrols.mainbar.engageTool('$hashed');
65 }
66 });";
67 });
68 }
69 return $c;
70 })
71 ->withSymbol($icon)
72 ->withTitle($title)
73 ->withContent($l($this->getContent()));
74 }
75
76 return $tools;
77 }
78
79 private function getContent(): string
80 {
81 return "<div id='copg-editor-slate-error'></div><div id='copg-editor-slate-content'></div>";
82 }
83}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
factory()
getToolsForContextStack(CalledContexts $called_contexts)
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
withSymbol(Symbol $symbol)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.