ILIAS  trunk Revision v11.0_alpha-1731-gff9cd7e2bd3
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilLMEditGSToolProvider.php
Go to the documentation of this file.
1 <?php
2 
24 
31 {
32  use Hasher;
33  public const SHOW_TREE = 'show_tree';
34 
39  {
40  return $this->context_collection->main()->repository();
41  }
42 
43 
47  public function getToolsForContextStack(CalledContexts $called_contexts): array
48  {
49  $tools = [];
50  $additional_data = $called_contexts->current()->getAdditionalData();
51  if ($additional_data->is(self::SHOW_TREE, true)) {
52  $title = $this->dic->language()->txt('objs_st');
53  $icon = $this->dic->ui()->factory()->symbol()->icon()->custom(\ilUtil::getImagePath("standard/icon_chp.svg"), $title);
54 
55  $iff = function ($id) {
56  return $this->identification_provider->contextAwareIdentifier($id);
57  };
58  $l = function (string $content) {
59  return $this->dic->ui()->factory()->legacy()->content($content);
60  };
61  $identification = $iff("tree");
62  $hashed = $this->hash($identification->serialize());
63  $tools[] = $this->factory->tool($identification)
64  ->addComponentDecorator(static function (ILIAS\UI\Component\Component $c) use ($hashed): ILIAS\UI\Component\Component {
65  if ($c instanceof LegacySlate) {
66  $signal_id = $c->getToggleSignal()->getId();
67  return $c->withAdditionalOnLoadCode(static function ($id) use ($hashed) {
68  return "document.addEventListener('il-lm-editor-tree', () => {
69  il.UI.maincontrols.mainbar.engageTool('$hashed');
70  });";
71  });
72  }
73  return $c;
74  })
75  ->withTitle($title)
76  ->withSymbol($icon)
77  ->withContentWrapper(function () use ($l) {
78  return $l($this->getContent());
79  });
80  }
81 
82  return $tools;
83  }
84 
85 
90  private function getContent(): string
91  {
92  global $DIC;
93  $request = $DIC->learningModule()
94  ->internal()
95  ->gui()
96  ->editing()
97  ->request();
98 
99  $lm = new ilObjLearningModule($request->getRefId());
100 
101  $exp = new ilLMEditorExplorerGUI("illmeditorgui", "showTree", $lm);
102 
103  return $exp->getHTML(true);
104  }
105 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface Observer Contains several chained tasks and infos about them.
factory()
$c
Definition: deliver.php:25
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Learning module editing GS tool provider.
global $DIC
Definition: shib_login.php:22
static getImagePath(string $image_name, 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...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
getToolsForContextStack(CalledContexts $called_contexts)