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