ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
IIMEditorInit.php
Go to the documentation of this file.
1 <?php
2 
20 
25 {
26  protected \ILIAS\DI\UIServices $ui;
27  protected \ilCtrl $ctrl;
28  protected \ilLanguage $lng;
29 
30  public function __construct()
31  {
32  global $DIC;
33 
34  $this->ctrl = $DIC->ctrl();
35  $this->lng = $DIC->language();
36  $this->ui = $DIC->ui();
37  }
38 
39  public function initUI(
40  \ilGlobalTemplateInterface $main_tpl
41  ): void {
42  $ctrl = $this->ctrl;
43  $lng = $this->lng;
44 
45  \ILIAS\Repository\Form\FormAdapterGUI::initJavascript();
46 
47  $lang_vars = ["delete", "rename", "save", "cont_add_popup", "add", "cont_iim_add_overlay"];
48  foreach ($lang_vars as $l) {
49  $lng->toJS($l);
50  }
51 
52  // ensure that form.js is loaded which is needed for file input (js that shows file names)
53  $dummy = new \ilPropertyFormGUI();
54  $dummy->getHTML();
55  // ensure modal.js from ui framework is loaded
56  $this->ui->renderer()->render(
57  $this->ui->factory()->modal()->roundtrip("", $this->ui->factory()->legacy()->content(""))
58  );
59  }
60 
61  protected function sanitizeAttribute(string $attr): string
62  {
63  return str_replace(["<", ">", "'", "\""], "", $attr);
64  }
65 
66  public function getInitHtml(): string
67  {
68  $ctrl = $this->ctrl;
69 
70  $p1 = $this->sanitizeAttribute(
71  ILIAS_HTTP_PATH . "/" . $ctrl->getLinkTargetByClass(["ilPageEditorGUI", "ilPageEditorServerAdapterGUI"], "invokeServer")
72  );
73  $p2 = $this->sanitizeAttribute($ctrl->getFormActionByClass("ilPCInteractiveImageGUI"));
74 
75  $init_span = <<<EOT
76 <span id='il-copg-iim-init'
77  data-endpoint='$p1'
78  data-formaction='$p2'
79 ></span><div id='il-copg-iim-main'></div>
80 EOT;
81  $debug = "";
82  //$debug = ".";
83  $module_tag = <<<EOT
84 <script type="module" src="$debug./components/ILIAS/COPage/PC/InteractiveImage/js/editor/src/editor.js"></script>
85 EOT;
86  return $init_span . $module_tag;
87  }
88 
89 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26
initUI(\ilGlobalTemplateInterface $main_tpl)