ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilCOPageEditGSToolProvider.php
Go to the documentation of this file.
1 <?php
2 
8 
15 {
16  const SHOW_EDITOR = 'copg_show_editor';
17  use Hasher;
18 
23  {
24  return $this->context_collection->main()->repository();
25  }
26 
27 
31  public function getToolsForContextStack(CalledContexts $called_contexts) : array
32  {
33  $tools = [];
34  $additional_data = $called_contexts->current()->getAdditionalData();
35  if ($additional_data->is(self::SHOW_EDITOR, true)) {
36  $title = $this->dic->language()->txt('editor');
37  $icon = $this->dic->ui()->factory()->symbol()->icon()->custom(\ilUtil::getImagePath("outlined/icon_edtr.svg"), $title);
38 
39  $iff = function ($id) {
40  return $this->identification_provider->contextAwareIdentifier($id);
41  };
42  $l = function (string $content) {
43  return $this->dic->ui()->factory()->legacy($content);
44  };
45  $identification = $iff("copg_editor");
46  $hashed = $this->hash($identification->serialize());
47  $tools[] = $this->factory->tool($identification)
48  ->addComponentDecorator(static function (ILIAS\UI\Component\Component $c) use ($hashed) : ILIAS\UI\Component\Component {
49  if ($c instanceof LegacySlate) {
50  $signal_id = $c->getToggleSignal()->getId();
51  return $c->withAdditionalOnLoadCode(static function ($id) use ($hashed) {
52  return "
53  $('body').on('il-copg-editor-slate', function(){
54  il.UI.maincontrols.mainbar.engageTool('$hashed');
55  });";
56  });
57  }
58  return $c;
59  })
60  ->withSymbol($icon)
61  ->withTitle($title)
62  ->withContent($l($this->getContent()));
63  }
64 
65  return $tools;
66  }
67 
68 
74  private function getContent() : string
75  {
76  return "<div id='copg-editor-slate-error'></div><div id='copg-editor-slate-content'></div>";
77  }
78 }
Class Factory.
$c
Definition: cli.php:37
Class ChatMainBarProvider .
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
getToolsForContextStack(CalledContexts $called_contexts)