ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilPCInteractiveImage.php
Go to the documentation of this file.
1 <?php
2 
25 {
26  public const AREA = "Area";
27  public const MARKER = "Marker";
28  protected DOMNode $mal_node;
30  protected \ILIAS\DI\UIServices $ui;
31  protected \ILIAS\COPage\Html\TransformUtil $htmlTransform;
32  protected \ILIAS\COPage\PC\InteractiveImage\IIMManager $manager;
33 
36  protected ilLanguage $lng;
37  public ?DOMNode $iim_node;
38 
39  public function init(): void
40  {
41  global $DIC;
42 
43  $this->lng = $DIC->language();
44  $this->setType("iim");
45  $this->manager = $DIC->copage()->internal()->domain()->pc()->interactiveImage();
46  $this->htmlTransform = $DIC->copage()->internal()->domain()->htmlTransformUtil();
47  $this->ui = $DIC->copage()->internal()->gui()->ui();
48  }
49 
50  public function readMediaObject(int $a_mob_id = 0): void
51  {
52  if ($a_mob_id > 0) {
53  $mob = new ilObjMediaObject($a_mob_id);
54  $this->setMediaObject($mob);
55  }
56  }
57 
58  public function setDomNode(DOMNode $dom_node): void
59  {
60  parent::setDomNode($dom_node); // this is the PageContent node
61  $this->iim_node = $dom_node->firstChild;
62  if (isset($this->iim_node)) {
63  $this->med_alias_node = $this->iim_node->firstChild;
64  }
65  if (isset($this->med_alias_node)) {
66  $id = $this->med_alias_node->getAttribute("OriginId");
68  if ($this->object->getTypeForObjId($mob_id) == "mob") {
69  $this->setMediaObject(new ilObjMediaObject($mob_id));
70  }
71  }
72  $this->std_alias_item = new ilMediaAliasItem(
73  $this->getDomDoc(),
74  $this->readHierId(),
75  "Standard",
76  $this->readPCId(),
77  "InteractiveImage"
78  );
79  }
80 
81  public function setMediaObject(ilObjMediaObject $a_mediaobject): void
82  {
83  $this->mediaobject = $a_mediaobject;
84  }
85 
86  public function getMediaObject(): ilObjMediaObject
87  {
88  return $this->mediaobject;
89  }
90 
91  public function createMediaObject(): void
92  {
93  $this->setMediaObject(new ilObjMediaObject());
94  }
95 
96  public function create(): void
97  {
98  $this->createPageContentNode();
99  }
100 
102  {
103  return $this->getMediaObject()->getMediaItem("Standard");
104  }
105 
107  {
108  return $this->std_alias_item;
109  }
110 
111  public function getBaseThumbnailTarget(): string
112  {
113  return $this->getMediaObject()->getMediaItem("Standard")->getThumbnailTarget();
114  }
115 
116  public function createAlias(
117  ilPageObject $a_pg_obj,
118  string $a_hier_id,
119  string $a_pc_id = ""
120  ): void {
121  $this->setDomNode($this->dom_doc->createElement("PageContent"));
122  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
123  $this->iim_node = $this->dom_doc->createElement("InteractiveImage");
124  $this->iim_node = $this->getDomNode()->appendChild($this->iim_node);
125  $this->mal_node = $this->dom_doc->createElement("MediaAlias");
126  $this->mal_node = $this->iim_node->appendChild($this->mal_node);
127  $this->mal_node->setAttribute("OriginId", "il__mob_" . $this->getMediaObject()->getId());
128 
129  // standard view
130  $item_node = $this->dom_doc->createElement("MediaAliasItem");
131  $item_node = $this->iim_node->appendChild($item_node);
132  $item_node->setAttribute("Purpose", "Standard");
133  $media_item = $this->getMediaObject()->getMediaItem("Standard");
134 
135  $layout_node = $this->dom_doc->createElement("Layout");
136  $layout_node = $item_node->appendChild($layout_node);
137  $layout_node->setAttribute("HorizontalAlign", "Left");
138 
139  // caption
140  if ($media_item->getCaption() != "") {
141  $cap_node = $this->dom_doc->createElement("Caption");
142  $cap_node = $item_node->appendChild($cap_node);
143  $cap_node->setAttribute("Align", "bottom");
144  $this->dom_util->setContent($cap_node, $media_item->getCaption());
145  }
146 
147  // text representation
148  if ($media_item->getTextRepresentation() != "") {
149  $tr_node = $this->dom_doc->createElement("TextRepresentation");
150  $tr_node = $item_node->appendChild($tr_node);
151  $this->dom_util->setContent($tr_node, $media_item->getTextRepresentation());
152  }
153  }
154 
155  public function dumpXML(): string
156  {
157  $xml = $this->dom_util->dump($this->getDomNode());
158  return $xml;
159  }
160 
161 
165 
169  public function addContentPopup(?string $title = null): void
170  {
171  $lng = $this->lng;
172 
173  if ($title === null) {
174  $title = $lng->txt("cont_new_popup");
175  }
176  $max = 0;
177  $popups = $this->getPopups();
178  foreach ($popups as $p) {
179  $max = max($max, (int) $p["nr"]);
180  }
181 
182  $new_item = $this->dom_doc->createElement("ContentPopup");
183  $new_item->setAttribute("Title", $title);
184  $new_item->setAttribute("Nr", $max + 1);
185  $new_item = $this->iim_node->appendChild($new_item);
186  }
187 
191  public function getPopups(): array
192  {
193  $titles = array();
194  $k = 0;
195  foreach ($this->iim_node->childNodes as $c) {
196  if ($c->nodeName == "ContentPopup") {
197  $pc_id = $c->getAttribute("PCID");
198  $hier_id = $c->getAttribute("HierId");
199  $title = $c->getAttribute("Title");
200  $nr = $c->getAttribute("Nr");
201 
202  $titles[] = array("title" => $title,
203  "nr" => $nr,
204  "pc_id" => $pc_id,
205  "hier_id" => $hier_id
206  );
207  $k++;
208  }
209  }
210  return $titles;
211  }
212 
216  public function savePopups(array $a_popups): void
217  {
218  foreach ($this->iim_node->childNodes as $c) {
219  if ($c->nodeName == "ContentPopup") {
220  $pc_id = $c->getAttribute("PCID");
221  $hier_id = $c->getAttribute("HierId");
222  $k = $hier_id . ":" . $pc_id;
223  $c->setAttribute("Title", $a_popups[$k]);
224  }
225  }
226  }
227 
231  public function deletePopup(
232  string $a_hier_id,
233  string $a_pc_id
234  ): void {
235  foreach ($this->iim_node->childNodes as $c) {
236  if ($c->nodeName === "ContentPopup") {
237  if ($a_pc_id == $c->getAttribute("PCID") &&
238  $a_hier_id == $c->getAttribute("HierId")) {
239  $c->parentNode->removeChild($c);
240  }
241  }
242  }
243  }
244 
245  public function saveContentPopupTitle(string $nr, string $title): void
246  {
247  foreach ($this->iim_node->childNodes as $c) {
248  if ($c->nodeName === "ContentPopup") {
249  if ($nr === $c->getAttribute("Nr")) {
250  $c->setAttribute("Title", $title);
251  }
252  }
253  }
254  }
255 
256  public function deletePopupByNr(
257  string $nr
258  ): void {
259  foreach ($this->iim_node->childNodes as $c) {
260  if ($c->nodeName === "ContentPopup") {
261  if ($nr === $c->getAttribute("Nr")) {
262  $c->parentNode->removeChild($c);
263  }
264  }
265  }
266  $tr_nodes = $this->getTriggerNodes($this->hier_id, $this->getPCId());
267  foreach ($tr_nodes as $tr_node) {
268  if ($tr_node->getAttribute("PopupNr") === $nr) {
269  $tr_node->removeAttribute("PopupNr");
270  }
271  }
272  }
273 
277 
278  protected function setMapAreaProperties(
279  ilMediaAliasItem $a_alias_item,
280  string $a_shape_type,
281  string $a_coords,
282  string $a_title,
283  string $a_id,
284  string $hl_mode = "",
285  string $hl_class = ""
286  ): void {
287  $link = array(
288  "LinkType" => IL_EXT_LINK,
289  "Href" => ilUtil::stripSlashes("#")
290  );
291 
292  $a_alias_item->deleteMapAreaById($a_id);
293  $a_alias_item->addMapArea(
294  $a_shape_type,
295  $a_coords,
296  ilUtil::stripSlashes($a_title),
297  $link,
298  $a_id,
299  $hl_mode,
300  $hl_class
301  );
302  }
303 
307  public function addTriggerArea(
308  ilMediaAliasItem $a_alias_item,
309  string $a_shape_type,
310  string $a_coords,
311  string $a_title,
312  string $hl_mode = "",
313  string $hl_class = ""
314  ): void {
315  $max = 0;
316  $triggers = $this->getTriggers();
317  foreach ($triggers as $t) {
318  $max = max($max, (int) $t["Nr"]);
319  }
320 
321  $this->setMapAreaProperties(
322  $a_alias_item,
323  $a_shape_type,
324  $a_coords,
325  ilUtil::stripSlashes($a_title),
326  (string) ($max + 1),
327  $hl_mode,
328  $hl_class
329  );
330 
331  $attributes = array("Type" => self::AREA,
332  "Title" => ilUtil::stripSlashes($a_title),
333  "Nr" => $max + 1,
334  "OverlayX" => "0",
335  "OverlayY" => "0",
336  "Overlay" => "",
337  "PopupNr" => "",
338  "PopupX" => "0",
339  "PopupY" => "0",
340  "PopupWidth" => "150",
341  "PopupHeight" => "200"
342  );
343  $ma_node = $this->dom_util->addElementToList(
344  $this->iim_node,
345  "Trigger",
346  array("ContentPopup"),
347  "",
348  $attributes
349  );
350  }
351 
355  public function addTriggerMarker(
356  string $title = "",
357  string $coords = ""
358  ): void {
359  $lng = $this->lng;
360 
361  $max = 0;
362  $triggers = $this->getTriggers();
363  foreach ($triggers as $t) {
364  $max = max($max, (int) $t["Nr"]);
365  }
366 
367  if ($title === "") {
368  $title = $lng->txt("cont_new_marker");
369  }
370  $markerx = "0";
371  $markery = "0";
372  if ($coords !== "") {
373  $coord_parts = explode(",", $coords);
374  $markerx = ($coord_parts[0] ?? "0");
375  $markery = ($coord_parts[1] ?? "0");
376  }
377 
378  $attributes = array("Type" => self::MARKER,
379  "Title" => $title,
380  "Nr" => $max + 1,
381  "OverlayX" => "0",
382  "OverlayY" => "0",
383  "MarkerX" => $markerx,
384  "MarkerY" => $markery,
385  "PopupNr" => "",
386  "PopupX" => "0",
387  "PopupY" => "0",
388  "PopupWidth" => "150",
389  "PopupHeight" => "200"
390  );
391  $ma_node = $this->dom_util->addElementToList(
392  $this->iim_node,
393  "Trigger",
394  array("ContentPopup"),
395  "",
396  $attributes
397  );
398  }
399 
400  public function getTriggerNodes(
401  string $a_hier_id,
402  string $a_pc_id = ""
403  ): DOMNodeList {
404  if ($a_pc_id != "") {
405  $path = "//PageContent[@PCID = '" . $a_pc_id . "']/InteractiveImage/Trigger";
406  return $this->dom_util->path($this->dom_doc, $path);
407  }
408 
409  $path = "//PageContent[@HierId = '" . $a_hier_id . "']/InteractiveImage/Trigger";
410  return $this->dom_util->path($this->dom_doc, $path);
411  }
412 
413  public function getTriggers(): array
414  {
415  $tr_nodes = $this->getTriggerNodes($this->hier_id, $this->getPCId());
416  $trigger_arr = array();
417  foreach ($tr_nodes as $tr_node) {
418  $childs = $tr_node->childNodes;
419  $trigger_arr[] = array(
420  "Nr" => $tr_node->getAttribute("Nr"),
421  "Type" => $tr_node->getAttribute("Type"),
422  "Title" => $tr_node->getAttribute("Title"),
423  "OverlayX" => $tr_node->getAttribute("OverlayX"),
424  "OverlayY" => $tr_node->getAttribute("OverlayY"),
425  "MarkerX" => $tr_node->getAttribute("MarkerX"),
426  "MarkerY" => $tr_node->getAttribute("MarkerY"),
427  "Overlay" => $tr_node->getAttribute("Overlay"),
428  "PopupNr" => $tr_node->getAttribute("PopupNr"),
429  "PopupX" => $tr_node->getAttribute("PopupX"),
430  "PopupY" => $tr_node->getAttribute("PopupY"),
431  "PopupWidth" => $tr_node->getAttribute("PopupWidth"),
432  "PopupHeight" => $tr_node->getAttribute("PopupHeight"),
433  "PopupPosition" => $tr_node->getAttribute("PopupPosition"),
434  "PopupSize" => $tr_node->getAttribute("PopupSize")
435  );
436  }
437 
438  return $trigger_arr;
439  }
440 
444  public function deleteTrigger(
445  ilMediaAliasItem $a_alias_item,
446  int $a_nr
447  ): void {
448  foreach ($this->iim_node->childNodes as $c) {
449  if ($c->nodeName === "Trigger") {
450  if ($a_nr === (int) $c->getAttribute("Nr")) {
451  $c->parentNode->removeChild($c);
452  }
453  }
454  }
455  $a_alias_item->deleteMapAreaById($a_nr);
456  }
457 
462  public function setTriggerOverlays(
463  array $a_ovs
464  ): void {
465  $tr_nodes = $this->getTriggerNodes($this->hier_id, $this->getPCId());
466  foreach ($tr_nodes as $tr_node) {
467  if (isset($a_ovs["" . $tr_node->getAttribute("Nr")])) {
468  $tr_node->setAttribute(
469  "Overlay",
470  $a_ovs["" . $tr_node->getAttribute("Nr")]
471  );
472  }
473  }
474  }
475 
476  public function deleteOverlay(string $file): void
477  {
478  $file = str_replace("..", "", ilUtil::stripSlashes($file));
479  $this->getMediaObject()
480  ->removeAdditionalFile("overlays/" . $file);
481  $tr_nodes = $this->getTriggerNodes($this->hier_id, $this->getPCId());
482  foreach ($tr_nodes as $tr_node) {
483  if ($tr_node->getAttribute("Overlay") === $file) {
484  $tr_node->removeAttribute("Overlay");
485  }
486  }
487  }
488 
493  public function setTriggerOverlayPositions(
494  array $a_pos
495  ): void {
496  $tr_nodes = $this->getTriggerNodes($this->hier_id, $this->getPCId());
497  foreach ($tr_nodes as $tr_node) {
498  if (isset($a_pos["" . $tr_node->getAttribute("Nr")])) {
499  $pos = explode(",", $a_pos["" . $tr_node->getAttribute("Nr")]);
500  $tr_node->setAttribute("OverlayX", (int) $pos[0]);
501  $tr_node->setAttribute("OverlayY", (int) $pos[1]);
502  }
503  }
504  }
505 
510  public function setTriggerMarkerPositions(
511  array $a_pos
512  ): void {
513  $tr_nodes = $this->getTriggerNodes($this->hier_id, $this->getPCId());
514  foreach ($tr_nodes as $tr_node) {
515  if ($tr_node->getAttribute("Type") == self::MARKER) {
516  if (isset($a_pos["" . $tr_node->getAttribute("Nr")])) {
517  $pos = explode(",", $a_pos["" . $tr_node->getAttribute("Nr")]);
518  $tr_node->setAttribute("MarkerX", (int) $pos[0]);
519  $tr_node->setAttribute("MarkerY", (int) $pos[1]);
520  }
521  }
522  }
523  }
524 
529  public function setTriggerPopupPositions(
530  array $a_pos
531  ): void {
532  $tr_nodes = $this->getTriggerNodes($this->hier_id, $this->getPCId());
533  foreach ($tr_nodes as $tr_node) {
534  if (isset($a_pos["" . $tr_node->getAttribute("Nr")])) {
535  $pos = explode(",", $a_pos["" . $tr_node->getAttribute("Nr")]);
536  $tr_node->setAttribute("PopupX", (int) $pos[0]);
537  $tr_node->setAttribute("PopupY", (int) $pos[1]);
538  }
539  }
540  }
541 
546  public function setTriggerPopupSize(
547  array $a_size
548  ): void {
549  $tr_nodes = $this->getTriggerNodes($this->hier_id, $this->getPCId());
550  foreach ($tr_nodes as $tr_node) {
551  if (isset($a_size["" . $tr_node->getAttribute("Nr")])) {
552  $size = explode(",", $a_size["" . $tr_node->getAttribute("Nr")]);
553  $tr_node->setAttribute("PopupWidth", (int) $size[0]);
554  $tr_node->setAttribute("PopupHeight", (int) $size[1]);
555  }
556  }
557  }
558 
563  public function setTriggerPopups(
564  array $a_pops
565  ): void {
566  $tr_nodes = $this->getTriggerNodes($this->hier_id, $this->getPCId());
567  foreach ($tr_nodes as $tr_node) {
568  if (isset($a_pops[(string) $tr_node->getAttribute("Nr")])) {
569  $pop = $a_pops[(string) $tr_node->getAttribute("Nr")];
570  $tr_node->setAttribute("PopupNr", $pop);
571  }
572  }
573  }
574 
579  public function setTriggerTitles(
580  array $a_titles
581  ): void {
582  $tr_nodes = $this->getTriggerNodes($this->hier_id, $this->getPCId());
583  foreach ($tr_nodes as $tr_node) {
584  if (isset($a_titles[(string) $tr_node->getAttribute("Nr")])) {
585  $tr_node->setAttribute(
586  "Title",
587  $a_titles[(string) $tr_node->getAttribute("Nr")]
588  );
589  $this->setExtLinkTitle(
590  $tr_node->getAttribute("Nr"),
591  $a_titles[(string) $tr_node->getAttribute("Nr")]
592  );
593  }
594  }
595  }
596 
597  public function setExtLinkTitle(
598  int $a_nr,
599  string $a_title
600  ): void {
601  if ($this->getPCId() != "") {
602  $path = "//PageContent[@PCID = '" . $this->getPCId() . "']/InteractiveImage/MediaAliasItem/MapArea[@Id='" . $a_nr . "']/ExtLink";
603  $res = $this->dom_util->path($this->dom_doc, $path);
604  if (count($res) > 0) {
605  $this->dom_util->setContent($res->item(0), $a_title);
606  }
607  return;
608  }
609 
610  $path = "//PageContent[@HierId = '" . $this->hier_id . "']/InteractiveImage/MediaAliasItem/MapArea[@Id='" . $a_nr . "']/ExtLink";
611  $res = $this->dom_util->path($this->dom_doc, $path);
612  if (count($res) > 0) {
613  $this->dom_util->setContent($res->item(0), $a_title);
614  }
615  }
616 
617  public static function handleCopiedContent(
618  DOMDocument $a_domdoc,
619  bool $a_self_ass = true,
620  bool $a_clone_mobs = false,
621  int $new_parent_id = 0,
622  int $obj_copy_id = 0
623  ): void {
624  global $DIC;
625 
626  $dom_util = $DIC->copage()->internal()->domain()->domUtil();
627  $path = "//InteractiveImage/MediaAlias";
628  $nodes = $dom_util->path($a_domdoc, $path);
629  foreach ($nodes as $node) {
630  $or_id = $node->getAttribute("OriginId");
631  $inst_id = ilInternalLink::_extractInstOfTarget($or_id);
632  $mob_id = ilInternalLink::_extractObjIdOfTarget($or_id);
633  if (!($inst_id > 0)) {
634  if ($mob_id > 0) {
635  $media_object = new ilObjMediaObject($mob_id);
636  $new_mob = $media_object->duplicate();
637  $node->setAttribute("OriginId", "il__mob_" . $new_mob->getId());
638  }
639  }
640  }
641  }
642 
643  public function createFromMobId(
644  \ilPageObject $page,
645  int $mob_id,
646  string $hier_id,
647  string $pc_id
648  ): void {
649  $this->setMediaObject(new ilObjMediaObject($mob_id));
650  $this->createAlias($page, $hier_id, $pc_id);
651  }
652 
653  public function getIIMModel(): ?stdClass
654  {
655  $alias_item = $this->getStandardAliasItem();
656  $model = new \stdClass();
657  $model->triggers = $this->getTriggers();
658  $model->popups = $this->getPopups();
659  $model->media_item = $alias_item->getModel();
660  $model->overlays = $this->manager->getOverlays($this->getMediaObject());
661  return $model;
662  }
663 
664  protected function getTriggerNode(string $nr)
665  {
666  $tr_nodes = $this->getTriggerNodes($this->hier_id, $this->getPCId());
667  foreach ($tr_nodes as $tr_node) {
668  if ($tr_node->getAttribute("Nr") === $nr) {
669  return $tr_node;
670  }
671  }
672  return null;
673  }
674 
675  public function setTriggerProperties(string $nr, string $title, string $shape_type, string $coords, string $hl_mode = "", string $hl_class = ""): void
676  {
677  $tr_node = $this->getTriggerNode($nr);
678 
679  if ($shape_type === "Marker") {
680 
681  if (!$tr_node) {
682  $this->addTriggerMarker(
683  ilUtil::stripSlashes($title),
684  $coords
685  );
686  } else {
687  // set marker properties
688  $tr_node->setAttribute("Type", "Marker");
689  $tr_node->setAttribute(
690  "Title",
691  $title
692  );
693  $coord_parts = explode(",", $coords);
694  $tr_node->setAttribute("MarkerX", ($coord_parts[0] ?? "0"));
695  $tr_node->setAttribute("MarkerY", ($coord_parts[1] ?? "0"));
696 
697  // remove area
698  $path = "//PageContent[@HierId = '" . $this->hier_id . "']/InteractiveImage/MediaAliasItem/MapArea[@Id='" . $nr . "']";
699  $res = $this->dom_util->path($this->dom_doc, $path);
700  if ($child = $res->item(0)) {
701  $child->parentNode->removeChild($child);
702  }
703  }
704  return;
705  }
706 
707  if ($tr_node) {
708  $tr_node->setAttribute("Type", "Area");
709  $tr_node->removeAttribute("MarkerX");
710  $tr_node->removeAttribute("MarkerY");
711  $tr_node->setAttribute(
712  "Title",
713  ilUtil::stripSlashes($title),
714  );
715  $this->setMapAreaProperties(
716  $this->getStandardAliasItem(),
717  $shape_type,
718  $coords,
719  ilUtil::stripSlashes($title),
720  $nr,
721  $hl_mode,
722  $hl_class
723  );
724  } else {
725  $this->addTriggerArea(
726  $this->getStandardAliasItem(),
727  $shape_type,
728  $coords,
729  $title,
730  $hl_mode,
731  $hl_class
732  );
733  }
734  }
735 
736  public function setTriggerOverlay(string $nr, string $overlay, string $coords): void
737  {
738  $tr_node = $this->getTriggerNode($nr);
739  if ($tr_node) {
740  $c = explode(",", $coords);
741  $x = (int) ($c[0] ?? 0);
742  $y = (int) ($c[1] ?? 0);
743  $tr_node->setAttribute("Overlay", $overlay);
744  $tr_node->setAttribute("OverlayX", $x);
745  $tr_node->setAttribute("OverlayY", $y);
746  }
747  }
748 
749  public function setTriggerPopup(string $nr, string $popup, string $position, string $size): void
750  {
751  $tr_node = $this->getTriggerNode($nr);
752  if ($tr_node) {
753  $tr_node->setAttribute("PopupNr", $popup);
754  $tr_node->setAttribute("PopupPosition", $position);
755  $tr_node->setAttribute("PopupSize", $size);
756  }
757  }
758 
759  public function modifyPageContentPostXsl(
760  string $a_output,
761  string $a_mode,
762  bool $a_abstract_only = false
763  ): string {
764  $keep_original = false;
765  if (in_array($a_mode, [ilPageObjectGUI::EDIT], true)) {
766  $keep_original = true;
767  }
768  $trans = $this->htmlTransform;
769  while (!is_null($params = $trans->getPlaceholderParams($a_output, "InteractiveImage;PopupStart"))) {
770  $params = $trans->getPlaceholderParams($a_output, "InteractiveImage;PopupStart");
771  $par_page = $params[2] ?? 0;
772  $par_pop_nr = $params[4] ?? 0;
773  $inner = $trans->getInnerContentOfPlaceholders(
774  $a_output,
775  "InteractiveImage;PopupStart",
776  "InteractiveImage;PopupEnd"
777  );
778  if ($keep_original) {
779  $new_inner = $inner;
780  } else {
781  $pop = $this->ui->factory()->popover()->standard(
782  $this->ui->factory()->legacy("#####popovercontent#####")
783  );
784  $signal_id = $pop->getShowSignal()->getId();
785  //$new_inner = $this->ui->renderer()->render($pop);
786  $new_inner = "#####popovercontent#####";
787  // we need a position relative around the absolute inner div, to make 100% the current available space
788  $new_inner = str_replace(
789  "#####popovercontent#####",
790  "<div style='position:relative'><div class='copg-iim-popup copg-iim-popup-md' style='display:none;' data-copg-cont-type='iim-popup' data-signal-id='$signal_id' data-copg-page='$par_page' data-copg-popup-nr='$par_pop_nr'>" . $inner . "</div></div>",
791  $new_inner
792  );
793  }
794  $html = $trans->replaceInnerContentAndPlaceholders(
795  $a_output,
796  "InteractiveImage;PopupStart",
797  "InteractiveImage;PopupEnd",
798  $new_inner
799  );
800  if (is_null($html)) {
801  break;
802  } else {
803  $a_output = $html;
804  }
805  }
806  return $a_output .
807 '<script type="module" src="./Services/COPage/PC/InteractiveImage/js/presentation/src/presentation.js"></script>';
808  }
809 
810  public function getPopupDummy(): string
811  {
812  $content = <<<EOT
813 <div style='position:relative'><div class='copg-iim-popup copg-iim-popup-md' data-copg-cont-type='iim-popup'>
814 <div class="ilc_iim_ContentPopup" data-copg-iim-data-type="popup"><div class="ilc_Paragraph ilc_text_block_Standard">
815 ###content###
816 </div></div></div></div>
817 
818 EOT;
819  return $content;
820  }
821 
822  public function getBackgroundImage(): string
823  {
824  $mob = $this->getMediaObject();
825 
826  //$ilCtrl = $this->ctrl;
827 
828  $st_item = $mob->getMediaItem("Standard");
829 
830  // output image map
831  $xml = "<dummy>";
832  $xml .= $mob->getXML(IL_MODE_ALIAS);
833  $xml .= $mob->getXML(IL_MODE_OUTPUT);
834  $xml .= "</dummy>";
835  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
836  //echo htmlentities($xml); exit;
837  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
838  $xh = xslt_create();
839  $wb_path = \ilFileUtils::getWebspaceDir("output") . "/";
840  $mode = "media";
841  //echo htmlentities($ilCtrl->getLinkTarget($this, "showImageMap"));
842 
843  $random = new \ilRandom();
844  $params = array(
845  'media_mode' => 'enable',
846  'pg_frame' => "",
847  'enlarge_path' => \ilUtil::getImagePath("enlarge.svg"),
848  'webspace_path' => $wb_path);
849  $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", null, $args, $params);
850  xslt_error($xh);
851  xslt_free($xh);
852 
853  return $output;
854  }
855 
856 }
static getWebspaceDir(string $mode="filesystem")
get webspace directory
xslt_create()
setType(string $a_type)
Set Type.
$res
Definition: ltiservices.php:69
deletePopup(string $a_hier_id, string $a_pc_id)
Delete popup.
setTriggerPopupPositions(array $a_pos)
Set trigger popup position.
setMapAreaProperties(ilMediaAliasItem $a_alias_item, string $a_shape_type, string $a_coords, string $a_title, string $a_id, string $hl_mode="", string $hl_class="")
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
setTriggerOverlays(array $a_ovs)
Set trigger overlays.
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
xslt_free(&$proc)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
createAlias(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Content object of ilPageObject (see ILIAS DTD).
setTriggerProperties(string $nr, string $title, string $shape_type, string $coords, string $hl_mode="", string $hl_class="")
$path
Definition: ltiservices.php:32
ILIAS COPage Html TransformUtil $htmlTransform
setTriggerTitles(array $a_titles)
Set trigger titles.
addTriggerArea(ilMediaAliasItem $a_alias_item, string $a_shape_type, string $a_coords, string $a_title, string $hl_mode="", string $hl_class="")
Add a new trigger.
global $DIC
Definition: feed.php:28
setTriggerPopup(string $nr, string $popup, string $position, string $size)
xslt_error(&$proc)
setTriggerPopupSize(array $a_size)
Set trigger popup size.
deleteTrigger(ilMediaAliasItem $a_alias_item, int $a_nr)
Delete Trigger.
getPopups()
Get popup captions.
setMediaObject(ilObjMediaObject $a_mediaobject)
savePopups(array $a_popups)
Save popups.
insertContent(ilPageContent $a_cont_obj, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="", bool $remove_placeholder=true)
insert a content node before/after a sibling or as first child of a parent
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTriggerOverlay(string $nr, string $overlay, string $coords)
saveContentPopupTitle(string $nr, string $title)
const IL_INSERT_AFTER
createPageContentNode(bool $a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
const IL_MODE_ALIAS
static handleCopiedContent(DOMDocument $a_domdoc, bool $a_self_ass=true, bool $a_clone_mobs=false, int $new_parent_id=0, int $obj_copy_id=0)
const IL_EXT_LINK
createFromMobId(\ilPageObject $page, int $mob_id, string $hier_id, string $pc_id)
addMapArea(string $a_shape_type, string $a_coords, string $a_title, array $a_link, string $a_id="", string $hl_mode="", string $hl_class="",)
Add a new area to the map.
setExtLinkTitle(int $a_nr, string $a_title)
addContentPopup(?string $title=null)
Add a tab.
setTriggerPopups(array $a_pops)
Set trigger popups.
getTriggerNodes(string $a_hier_id, string $a_pc_id="")
setTriggerMarkerPositions(array $a_pos)
Set trigger marker position.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS COPage Dom DomUtil $dom_util
const IL_MODE_OUTPUT
setTriggerOverlayPositions(array $a_pos)
Set trigger overlay position.
ILIAS COPage PC InteractiveImage IIMManager $manager
deleteMapAreaById(string $a_id)
Delete map areas by id.
modifyPageContentPostXsl(string $a_output, string $a_mode, bool $a_abstract_only=false)
addTriggerMarker(string $title="", string $coords="")
Add a new trigger marker.