ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilLMEditGSToolProvider.php
Go to the documentation of this file.
1 <?php
2 
8 
15 {
16  use Hasher;
17  public const SHOW_TREE = 'show_tree';
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_TREE, true)) {
36  $title = $this->dic->language()->txt('objs_st');
37  $icon = $this->dic->ui()->factory()->symbol()->icon()->custom(\ilUtil::getImagePath("icon_chp.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("tree");
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  console.log('trigger added');
54  $('body').on('il-lm-editor-tree', function(){
55  il.UI.maincontrols.mainbar.engageTool('$hashed');
56  console.log('trigger tree');
57  });";
58  });
59  }
60  return $c;
61  })
62  ->withTitle($title)
63  ->withSymbol($icon)
64  ->withContentWrapper(function () use ($l) {
65  return $l($this->getContent());
66  });
67  }
68 
69  return $tools;
70  }
71 
72 
77  private function getContent(): string
78  {
79  global $DIC;
80 
81  $request = $DIC->learningModule()
82  ->internal()
83  ->gui()
84  ->editing()
85  ->request();
86 
87  $lm = new ilObjLearningModule($request->getRefId());
88 
89  $exp = new ilLMEditorExplorerGUI("illmeditorgui", "showTree", $lm);
90 
91  return $exp->getHTML();
92  }
93 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
global $DIC
Definition: feed.php:28
Learning module editing GS tool provider.
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)