ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilCOPageEditGSToolProvider.php
Go to the documentation of this file.
1 <?php
2 
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("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);
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 }
Class Factory.
$c
Definition: cli.php:38
Class ChatMainBarProvider .
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getToolsForContextStack(CalledContexts $called_contexts)