ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilMediaAliasItem.php
Go to the documentation of this file.
1<?php
2
25{
26 protected DOMDocument $dom_doc;
27 protected \ILIAS\COPage\Dom\DomUtil $dom_util;
28 protected string $parent_node_name;
29 protected string $pcid;
30 protected ilLanguage $lng;
31 public string $hier_id = "";
32 public string $purpose = "";
33 public ?DOMNode $item_node = null;
34
35 public function __construct(
36 DOMDocument $dom,
37 string $a_hier_id,
38 string $a_purpose,
39 string $a_pc_id = "",
40 string $a_parent_node_name = "MediaObject"
41 ) {
42 global $DIC;
43
44 $this->lng = $DIC->language();
45 $this->dom_doc = $dom;
46 $this->parent_node_name = $a_parent_node_name;
47 $this->hier_id = $a_hier_id;
48 $this->purpose = $a_purpose;
49 $this->setPcId($a_pc_id);
50 $this->dom_util = $DIC->copage()->internal()->domain()->domUtil();
51 $this->item_node = $this->getMAItemNode(
52 $this->hier_id,
53 $this->purpose,
54 $this->getPcId()
55 );
56 }
57
58 protected function getItemNode(): DOMNode
59 {
60 return $this->item_node;
61 }
62
63 public function getMAItemNode(
64 string $a_hier_id,
65 string $a_purpose,
66 string $a_pc_id = "",
67 string $a_sub_element = ""
68 ): ?DOMNode {
69 if ($a_pc_id != "") {
70 $path = "//PageContent[@PCID = '" . $a_pc_id . "']/" . $this->parent_node_name . "/MediaAliasItem[@Purpose='$a_purpose']" . $a_sub_element;
71 $nodes = $this->dom_util->path($this->dom_doc, $path);
72 if (count($nodes) == 1) {
73 return $nodes->item(0);
74 }
75 }
76
77 $path = "//PageContent[@HierId = '" . $a_hier_id . "']/" . $this->parent_node_name . "/MediaAliasItem[@Purpose='$a_purpose']" . $a_sub_element;
78 $nodes = $this->dom_util->path($this->dom_doc, $path);
79 if (count($nodes) > 0) {
80 return $nodes->item(0);
81 }
82 return null;
83 }
84
85 public function getParameterNodes(
86 string $a_hier_id,
87 string $a_purpose,
88 string $a_pc_id = ""
89 ): DOMNodeList {
90 if ($a_pc_id != "") {
91 $path = "//PageContent[@PCID = '" . $a_pc_id . "']/" . $this->parent_node_name . "/MediaAliasItem[@Purpose='$a_purpose']/Parameter";
92 return $this->dom_util->path($this->dom_doc, $path);
93 }
94
95 $path = "//PageContent[@HierId = '" . $a_hier_id . "']/" . $this->parent_node_name . "/MediaAliasItem[@Purpose='$a_purpose']/Parameter";
96 return $this->dom_util->path($this->dom_doc, $path);
97 }
98
99 public function getMapAreaNodes(
100 string $a_hier_id,
101 string $a_purpose,
102 string $a_pc_id = ""
103 ): DOMNodeList {
104 if ($a_pc_id != "") {
105 $path = "//PageContent[@PCID = '" . $a_pc_id . "']/" . $this->parent_node_name . "/MediaAliasItem[@Purpose='$a_purpose']/MapArea";
106 return $this->dom_util->path($this->dom_doc, $path);
107 }
108
109 $path = "//PageContent[@HierId = '" . $a_hier_id . "']/" . $this->parent_node_name . "/MediaAliasItem[@Purpose='$a_purpose']/MapArea";
110 return $this->dom_util->path($this->dom_doc, $path);
111 }
112
113 public function setPcId(string $a_pcid): void
114 {
115 $this->pcid = $a_pcid;
116 }
117
118 public function getPcId(): string
119 {
120 return $this->pcid;
121 }
122
126 public function exists(): bool
127 {
128 if (is_object($this->item_node)) {
129 return true;
130 } else {
131 return false;
132 }
133 }
134
138 public function insert(): void
139 {
140 $path = "//PageContent[@HierId = '" . $this->hier_id . "']/" . $this->parent_node_name;
141 $nodes = $this->dom_util->path($this->dom_doc, $path);
142 if (count($nodes) > 0) {
143 $obj_node = $nodes->item(0);
144 $item_node = $this->dom_doc->createElement("MediaAliasItem");
145 $item_node = $obj_node->appendChild($item_node);
146 $item_node->setAttribute("Purpose", $this->purpose);
147 $this->item_node = $item_node;
148 }
149 }
150
151 public function setWidth(string $a_width): void
152 {
153 $this->dom_util->setFirstOptionalElement(
154 $this->getItemNode(),
155 "Layout",
156 array("Caption", "TextRepresentation", "Parameter", "MapArea"),
157 "",
158 array("Width" => $a_width),
159 false
160 );
161 }
162
163
164 public function getWidth(): string
165 {
166 $layout_node = $this->getMAItemNode(
167 $this->hier_id,
168 $this->purpose,
169 $this->getPcId(),
170 "/Layout"
171 );
172 if (is_object($layout_node)) {
173 return $layout_node->getAttribute("Width");
174 }
175 return "";
176 }
177
182 public function definesSize(): bool
183 {
184 $layout_node = $this->getMAItemNode(
185 $this->hier_id,
186 $this->purpose,
187 $this->getPcId(),
188 "/Layout"
189 );
190 if (is_object($layout_node)) {
191 return $layout_node->hasAttribute("Width");
192 }
193 return false;
194 }
195
199 public function deriveSize(): void
200 {
201 $layout_node = $this->getMAItemNode(
202 $this->hier_id,
203 $this->purpose,
204 $this->getPcId(),
205 "/Layout"
206 );
207 if (is_object($layout_node)) {
208 if ($layout_node->hasAttribute("Width")) {
209 $layout_node->removeAttribute("Width");
210 }
211 if ($layout_node->hasAttribute("Height")) {
212 $layout_node->removeAttribute("Height");
213 }
214 }
215 }
216
217 public function setHeight(string $a_height): void
218 {
219 $this->dom_util->setFirstOptionalElement(
220 $this->getItemNode(),
221 "Layout",
222 array("Caption", "TextRepresentation", "Parameter", "MapArea"),
223 "",
224 array("Height" => $a_height),
225 false
226 );
227 }
228
229
230 public function getHeight(): string
231 {
232 $layout_node = $this->getMAItemNode(
233 $this->hier_id,
234 $this->purpose,
235 $this->getPcId(),
236 "/Layout"
237 );
238 if (is_object($layout_node)) {
239 return $layout_node->getAttribute("Height");
240 }
241 return "";
242 }
243
244 public function setCaption(string $a_caption): void
245 {
246 $this->dom_util->setFirstOptionalElement(
247 $this->getItemNode(),
248 "Caption",
249 array("TextRepresentation", "Parameter", "MapArea"),
250 $a_caption,
251 array("Align" => "bottom")
252 );
253 }
254
255 public function getCaption(): string
256 {
257 $caption_node = $this->getMAItemNode(
258 $this->hier_id,
259 $this->purpose,
260 $this->getPcId(),
261 "/Caption"
262 );
263 if (is_object($caption_node)) {
264 return $this->dom_util->getContent($caption_node);
265 }
266 return "";
267 }
268
273 public function definesCaption(): bool
274 {
275 $caption_node = $this->getMAItemNode(
276 $this->hier_id,
277 $this->purpose,
278 $this->getPcId(),
279 "/Caption"
280 );
281 if (is_object($caption_node)) {
282 return true;
283 }
284 return false;
285 }
286
290 public function deriveCaption(): void
291 {
292 $caption_node = $this->getMAItemNode(
293 $this->hier_id,
294 $this->purpose,
295 $this->getPcId(),
296 "/Caption"
297 );
298 if (is_object($caption_node)) {
299 $caption_node->parentNode->removeChild($caption_node);
300 }
301 }
302
303 public function setTextRepresentation(
304 string $a_text_representation
305 ): void {
306 $this->dom_util->setFirstOptionalElement(
307 $this->getItemNode(),
308 "TextRepresentation",
309 array("Parameter", "MapArea"),
310 $a_text_representation,
311 array()
312 );
313 }
314
315 public function getTextRepresentation(): string
316 {
317 $text_representation_node = $this->getMAItemNode(
318 $this->hier_id,
319 $this->purpose,
320 $this->getPcId(),
321 "/TextRepresentation"
322 );
323 if (is_object($text_representation_node)) {
324 return $this->dom_util->getContent($text_representation_node);
325 }
326 return "";
327 }
328
333 public function definesTextRepresentation(): bool
334 {
335 $text_representation_node = $this->getMAItemNode(
336 $this->hier_id,
337 $this->purpose,
338 $this->getPcId(),
339 "/TextRepresentation"
340 );
341 if (is_object($text_representation_node)) {
342 return true;
343 }
344 return false;
345 }
346
350 public function deriveTextRepresentation(): void
351 {
352 $text_representation_node = $this->getMAItemNode(
353 $this->hier_id,
354 $this->purpose,
355 $this->getPcId(),
356 "/TextRepresentation"
357 );
358 if (is_object($text_representation_node)) {
359 $text_representation_node->parentNode->removeChild($text_representation_node);
360 }
361 }
362
363 public function setHorizontalAlign(string $a_halign): void
364 {
365 $this->dom_util->setFirstOptionalElement(
366 $this->getItemNode(),
367 "Layout",
368 array("Caption", "TextRepresentation", "Parameter", "MapArea"),
369 "",
370 array("HorizontalAlign" => $a_halign),
371 false
372 );
373 }
374
375
376 public function getHorizontalAlign(): string
377 {
378 $layout_node = $this->getMAItemNode(
379 $this->hier_id,
380 $this->purpose,
381 $this->getPcId(),
382 "/Layout"
383 );
384 if (is_object($layout_node)) {
385 return $layout_node->getAttribute("HorizontalAlign");
386 }
387 return "";
388 }
389
390 public function setParameters(array $a_par_array): void
391 {
392 $par_nodes = $this->getParameterNodes(
393 $this->hier_id,
394 $this->purpose,
395 $this->getPcId()
396 );
397 for ($i = 0; $i < count($par_nodes); $i++) {
398 $par_node = $par_nodes[$i];
399 $par_node->unlink_node($par_node);
400 }
401
402 if (is_array($a_par_array)) {
403 foreach ($a_par_array as $par => $val) {
404 if (ilMediaItem::checkParameter($par, $val)) {
405 $attributes = array("Name" => $par, "Value" => $val);
406 $this->dom_util->addElementToList(
407 $this->getItemNode(),
408 "Parameter",
409 array("MapArea"),
410 "",
411 $attributes
412 );
413 }
414 }
415 }
416 }
417
421 public function getParameterString(): string
422 {
423 $par_nodes = $this->getParameterNodes(
424 $this->hier_id,
425 $this->purpose,
426 $this->getPcId()
427 );
428 $par_arr = array();
429 foreach ($par_nodes as $par_node) {
430 $par_arr[] = $par_node->getAttribute("Name") . "=\"" . $par_node->getAttribute("Value") . "\"";
431 }
432 return implode(", ", $par_arr);
433 }
434
438 public function getParameters(): array
439 {
440 $par_nodes = $this->getParameterNodes(
441 $this->hier_id,
442 $this->purpose,
443 $this->getPcId()
444 );
445 $par_arr = array();
446 for ($i = 0; $i < count($par_nodes); $i++) {
447 $par_node = $par_nodes[$i];
448 $par_arr[$par_node->getAttribute("Name")] =
449 $par_node->getAttribute("Value");
450 }
451 return $par_arr;
452 }
453
458 public function definesParameters(): bool
459 {
460 $par_nodes = $this->getParameterNodes(
461 $this->hier_id,
462 $this->purpose,
463 $this->getPcId()
464 );
465 if (count($par_nodes) > 0) {
466 return true;
467 }
468 return false;
469 }
470
474 public function deriveParameters(): void
475 {
476 $par_nodes = $this->getParameterNodes(
477 $this->hier_id,
478 $this->purpose,
479 $this->getPcId()
480 );
481 foreach ($par_nodes as $par_node) {
482 $par_node->parentNode->removeChild($par_node);
483 }
484 }
485
486
490 public function getMapAreas(): array
491 {
492 $ma_nodes = $this->getMapAreaNodes(
493 $this->hier_id,
494 $this->purpose,
495 $this->getPcId()
496 );
497 $maparea_arr = array();
498 $i = 0;
499 foreach ($ma_nodes as $maparea_node) {
500 $childs = $maparea_node->childNodes;
501 $link = array();
502 $first = $childs->item(0);
503 if ($first->nodeName == "ExtLink") {
504 $link = array("LinkType" => "ExtLink",
505 "Href" => $first->getAttribute("Href"),
506 "Title" => $this->dom_util->getContent($first));
507 }
508 if ($first->nodeName == "IntLink") {
509 $link = array("LinkType" => "IntLink",
510 "Target" => $first->getAttribute("Target"),
511 "Type" => $first->getAttribute("Type"),
512 "TargetFrame" => $first->getAttribute("TargetFame"),
513 "Title" => $this->dom_util->getContent($first));
514 }
515 $maparea_arr[] = array(
516 "Nr" => $i + 1,
517 "Shape" => $maparea_node->getAttribute("Shape"),
518 "Coords" => $maparea_node->getAttribute("Coords"),
519 "HighlightMode" => $maparea_node->getAttribute("HighlightMode"),
520 "HighlightClass" => $maparea_node->getAttribute("HighlightClass"),
521 "Id" => $maparea_node->getAttribute("Id"),
522 "Link" => $link);
523 $i++;
524 }
525
526 return $maparea_arr;
527 }
528
529 public function setAreaTitle(
530 int $a_nr,
531 string $a_title
532 ): void {
533 $ma_nodes = $this->getMapAreaNodes(
534 $this->hier_id,
535 $this->purpose,
536 $this->getPcId()
537 );
538 if (is_object($ma_nodes[$a_nr - 1])) {
539 $childs = $ma_nodes[$a_nr - 1]->childNodes;
540 if (is_object($childs[0]) &&
541 ($childs[0]->nodeName == "IntLink" || $childs[0]->nodeName == "ExtLink")) {
542 $childs[0]->nodeValue = $a_title;
543 }
544 }
545 }
546
550 public function setAreaIntLink(
551 int $a_nr,
552 string $a_type,
553 string $a_target,
554 string $a_target_frame
555 ): void {
556 $ma_nodes = $this->getMapAreaNodes(
557 $this->hier_id,
558 $this->purpose,
559 $this->getPcId()
560 );
561 if (is_object($ma_nodes[$a_nr - 1])) {
562 $title = $this->getTitleOfArea($a_nr);
563 $this->dom_util->deleteAllChildsByName($ma_nodes[$a_nr - 1], array("IntLink", "ExtLink"));
564 $attributes = array("Type" => $a_type, "Target" => $a_target,
565 "TargetFrame" => $a_target_frame);
566 $this->dom_util->setFirstOptionalElement(
567 $ma_nodes[$a_nr - 1],
568 "IntLink",
569 array(""),
570 $title,
571 $attributes
572 );
573 }
574 }
575
579 public function setAreaExtLink(
580 int $a_nr,
581 string $a_href
582 ): void {
583 $ma_nodes = $this->getMapAreaNodes(
584 $this->hier_id,
585 $this->purpose,
586 $this->getPcId()
587 );
588 if (is_object($ma_nodes[$a_nr - 1])) {
589 $title = $this->getTitleOfArea($a_nr);
590 $this->dom_util->deleteAllChildsByName($ma_nodes[$a_nr - 1], array("IntLink", "ExtLink"));
591 $attributes = array("Href" => $a_href);
592 $this->dom_util->setFirstOptionalElement(
593 $ma_nodes[$a_nr - 1],
594 "ExtLink",
595 array(""),
596 $title,
597 $attributes
598 );
599 }
600 }
601
605 public function setShape(
606 int $a_nr,
607 string $a_shape_type,
608 string $a_coords
609 ): void {
610 $ma_nodes = $this->getMapAreaNodes(
611 $this->hier_id,
612 $this->purpose,
613 $this->getPcId()
614 );
615 if (is_object($ma_nodes[$a_nr - 1])) {
616 $ma_nodes[$a_nr - 1]->setAttribute("Shape", $a_shape_type);
617 $ma_nodes[$a_nr - 1]->setAttribute("Coords", $a_coords);
618 }
619 }
620
624 public function setAreaHighlightMode(
625 int $a_nr,
626 string $a_mode
627 ): void {
628 $ma_nodes = $this->getMapAreaNodes(
629 $this->hier_id,
630 $this->purpose,
631 $this->getPcId()
632 );
633 if (is_object($ma_nodes[$a_nr - 1])) {
634 $ma_nodes[$a_nr - 1]->setAttribute("HighlightMode", $a_mode);
635 }
636 }
637
641 public function setAreaHighlightClass(
642 int $a_nr,
643 string $a_class
644 ): void {
645 $ma_nodes = $this->getMapAreaNodes(
646 $this->hier_id,
647 $this->purpose,
648 $this->getPcId()
649 );
650 if (is_object($ma_nodes[$a_nr - 1])) {
651 $ma_nodes[$a_nr - 1]->setAttribute("HighlightClass", $a_class);
652 }
653 }
654
658 public function addMapArea(
659 string $a_shape_type,
660 string $a_coords,
661 string $a_title,
662 array $a_link,
663 string $a_id = "",
664 string $hl_mode = "",
665 string $hl_class = "",
666 ): void {
667 $attributes = array("Shape" => $a_shape_type,
668 "Coords" => $a_coords, "Id" => $a_id,
669 "HighlightMode" => $hl_mode, "HighlightClass" => $hl_class);
670
671 $ma_node = $this->dom_util->addElementToList(
672 $this->getItemNode(),
673 "MapArea",
674 array(),
675 "",
676 $attributes
677 );
678
679 if ($a_link["LinkType"] == "int" || $a_link["LinkType"] == "IntLink") {
680 $attributes = array("Type" => $a_link["Type"],
681 "TargetFrame" => $a_link["TargetFrame"],
682 "Target" => $a_link["Target"]);
683 $this->dom_util->setFirstOptionalElement(
684 $ma_node,
685 "IntLink",
686 array(""),
687 $a_title,
688 $attributes
689 );
690 }
691 if ($a_link["LinkType"] == "ext" || $a_link["LinkType"] == "ExtLink") {
692 $attributes = array("Href" => $a_link["Href"]);
693 $this->dom_util->setFirstOptionalElement(
694 $ma_node,
695 "ExtLink",
696 array(""),
697 $a_title,
698 $attributes
699 );
700 }
701 }
702
706 public function deleteMapArea(int $a_nr): void
707 {
708 $ma_nodes = $this->getMapAreaNodes(
709 $this->hier_id,
710 $this->purpose,
711 $this->getPcId()
712 );
713
714 if (is_object($ma_nodes->item($a_nr - 1))) {
715 $node = $ma_nodes->item($a_nr - 1);
716 $node->parentNode->removeChild($node);
717 }
718 }
719
723 public function deleteMapAreaById(
724 string $a_id
725 ): void {
726 $ma_nodes = $this->getMapAreaNodes(
727 $this->hier_id,
728 $this->purpose,
729 $this->getPcId()
730 );
731 foreach ($ma_nodes as $node) {
732 if ($node->getAttribute("Id") == $a_id) {
733 $node->parentNode->removeChild($node);
734 }
735 }
736 }
737
741 public function deleteAllMapAreas(): void
742 {
743 $path = "//PageContent[@HierId = '" . $this->hier_id . "']/" . $this->parent_node_name . "/MediaAliasItem[@Purpose='" . $this->purpose . "']/MapArea";
744 $nodes = $this->dom_util->path($this->dom_doc, $path);
745 foreach ($nodes as $node) {
746 $node->parentNode->removeChild($node);
747 }
748 }
749
753 public function getLinkTypeOfArea(int $a_nr): string
754 {
755 $ma_nodes = $this->getMapAreaNodes(
756 $this->hier_id,
757 $this->purpose,
758 $this->getPcId()
759 );
760 if (is_object($ma_nodes->item($a_nr - 1))) {
761 $childs = $ma_nodes->item($a_nr - 1)->childNodes;
762 if ($childs->item(0)->nodeName == "IntLink") {
763 return "int";
764 }
765 if ($childs->item(0)->nodeName == "ExtLink") {
766 return "ext";
767 }
768 }
769 return "";
770 }
771
775 public function getTypeOfArea(int $a_nr): string
776 {
777 $ma_nodes = $this->getMapAreaNodes(
778 $this->hier_id,
779 $this->purpose,
780 $this->getPcId()
781 );
782 if (is_object($ma_nodes->item($a_nr - 1))) {
783 $childs = $ma_nodes->item($a_nr - 1)->childNodes;
784 return $childs->item(0)->getAttribute("Type");
785 }
786 return "";
787 }
788
792 public function getTargetOfArea(int $a_nr): string
793 {
794 $ma_nodes = $this->getMapAreaNodes(
795 $this->hier_id,
796 $this->purpose,
797 $this->getPcId()
798 );
799 if (is_object($ma_nodes->item($a_nr - 1))) {
800 $childs = $ma_nodes->item($a_nr - 1)->childNodes;
801 return $childs->item(0)->getAttribute("Target");
802 }
803 return "";
804 }
805
809 public function getTargetFrameOfArea(int $a_nr): string
810 {
811 $ma_nodes = $this->getMapAreaNodes(
812 $this->hier_id,
813 $this->purpose,
814 $this->getPcId()
815 );
816 if (is_object($ma_nodes->item($a_nr - 1))) {
817 $childs = $ma_nodes->item($a_nr - 1)->childNodes;
818 return $childs->item(0)->getAttribute("TargetFrame");
819 }
820 return "";
821 }
822
826 public function getHrefOfArea(int $a_nr): string
827 {
828 $ma_nodes = $this->getMapAreaNodes(
829 $this->hier_id,
830 $this->purpose,
831 $this->getPcId()
832 );
833 if (is_object($ma_nodes->item($a_nr - 1))) {
834 $childs = $ma_nodes->item($a_nr - 1)->childNodes;
835 return $childs->item(0)->getAttribute("Href");
836 }
837 return "";
838 }
839
843 public function getTitleOfArea(int $a_nr): string
844 {
845 $ma_nodes = $this->getMapAreaNodes(
846 $this->hier_id,
847 $this->purpose,
848 $this->getPcId()
849 );
850 if (is_object($ma_nodes->item($a_nr - 1))) {
851 $childs = $ma_nodes->item($a_nr - 1)->childNodes;
852 return $this->dom_util->getContent($childs->item(0));
853 }
854 return "";
855 }
856
860 public function delete(): void
861 {
862 if (is_object($this->item_node)) {
863 $this->item_node->parentNode->removeChild($this->item_node);
864 }
865 }
866
872 public function makeMapWorkCopy(
873 ilMediaItem $a_st_item,
874 int $a_area_nr,
875 bool $a_exclude,
876 bool $a_output_new_area,
877 string $a_area_type,
878 string $a_coords
879 ): bool {
880 $a_st_item->buildMapWorkImage();
881
882 // determine ratios (first see whether the instance has w/h defined)
883 $width = $this->getWidth();
884 $height = $this->getHeight();
885
886 // if instance has no size, use object w/h
887 if ($width == 0 && $height == 0) {
888 $width = $a_st_item->getWidth();
889 $height = $a_st_item->getHeight();
890 }
891 $size = getimagesize($a_st_item->getOriginalSource());
892 $x_ratio = 1;
893 if ($size[0] > 0 && $width > 0) {
894 $x_ratio = $width / $size[0];
895 }
896 $y_ratio = 1;
897 if ($size[1] > 0 && $height > 0) {
898 $y_ratio = $height / $size[1];
899 }
900
901 // draw map areas
902 $areas = $this->getMapAreas();
903 for ($i = 0; $i < count($areas); $i++) {
904 if (((($i + 1) == $a_area_nr) && !$a_exclude) ||
905 ((($i + 1) != $a_area_nr) && $a_exclude) ||
906 ($a_area_nr == 0)
907 ) {
908 $area = new ilMapArea();
909 $area->setShape($areas[$i]["Shape"]);
910 $area->setCoords($areas[$i]["Coords"]);
911 $area->draw(
912 $a_st_item->getMapWorkImage(),
913 $a_st_item->color1,
914 $a_st_item->color2,
915 true,
916 $x_ratio,
917 $y_ratio
918 );
919 }
920 }
921
922 if ($a_output_new_area) {
923 $area = new ilMapArea();
924 $area->setShape($a_area_type);
925 $area->setCoords($a_coords);
926 $area->draw(
927 $a_st_item->getMapWorkImage(),
928 $a_st_item->color1,
929 $a_st_item->color2,
930 false,
931 $x_ratio,
932 $y_ratio
933 );
934 }
935
936 return true;
937 }
938
942 public function hasAnyPropertiesSet(): bool
943 {
944 return ($this->definesSize() ||
945 $this->definesCaption() ||
946 $this->definesTextRepresentation() ||
947 $this->definesParameters());
948 }
949
950 public function getModel(): ?stdClass
951 {
952 $model = new \stdClass();
953 $model->areas = $this->getMapAreas();
954 $model->caption = $this->getCaption();
955 return $model;
956 }
957}
language handling
Class ilMapArea.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getHrefOfArea(int $a_nr)
Get href (only external link)
setParameters(array $a_par_array)
setHorizontalAlign(string $a_halign)
definesTextRepresentation()
check if alias item defines own TextRepresentation or derives TextRepresentation from object
setTextRepresentation(string $a_text_representation)
getTitleOfArea(int $a_nr)
Get title.
setAreaHighlightClass(int $a_nr, string $a_class)
Set highlight class single area.
setHeight(string $a_height)
setAreaExtLink(int $a_nr, string $a_href)
Set link of area to an external one.
exists()
check if item node exists
getTargetFrameOfArea(int $a_nr)
Get target frame (only internal link)
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.
hasAnyPropertiesSet()
Has the alias any properties set?
setAreaIntLink(int $a_nr, string $a_type, string $a_target, string $a_target_frame)
Set link of area to an internal one.
definesParameters()
check if alias item defines own parameters or derives parameters from object
getParameterString()
Get all parameters as string.
getMAItemNode(string $a_hier_id, string $a_purpose, string $a_pc_id="", string $a_sub_element="")
insert()
inserts new node in dom
setWidth(string $a_width)
getMapAreaNodes(string $a_hier_id, string $a_purpose, string $a_pc_id="")
definesSize()
check if alias item defines own size or derives size from object
getTypeOfArea(int $a_nr)
Get type (only internal link)
deleteMapArea(int $a_nr)
Delete a sinlge map area.
makeMapWorkCopy(ilMediaItem $a_st_item, int $a_area_nr, bool $a_exclude, bool $a_output_new_area, string $a_area_type, string $a_coords)
make map work copy of image
setAreaTitle(int $a_nr, string $a_title)
deriveSize()
derive size from object (-> width and height attributes are removed from layout element)
deriveParameters()
derive parameters from object (-> all parameter elements are removed from media alias item)
setShape(int $a_nr, string $a_shape_type, string $a_coords)
Set shape and coords of single area.
setAreaHighlightMode(int $a_nr, string $a_mode)
Set highlight mode single area.
ILIAS COPage Dom DomUtil $dom_util
deleteAllMapAreas()
Delete all map areas.
deriveTextRepresentation()
derive TextRepresentation from object (-> TextRepresentation element is removed from media alias item...
deriveCaption()
derive caption from object (-> caption element is removed from media alias item)
getParameters()
Get all parameters as array.
getTargetOfArea(int $a_nr)
Get target (only internal link)
__construct(DOMDocument $dom, string $a_hier_id, string $a_purpose, string $a_pc_id="", string $a_parent_node_name="MediaObject")
getParameterNodes(string $a_hier_id, string $a_purpose, string $a_pc_id="")
getMapAreas()
Get all map areas.
setCaption(string $a_caption)
getLinkTypeOfArea(int $a_nr)
Get link type.
deleteMapAreaById(string $a_id)
Delete map areas by id.
definesCaption()
check if alias item defines own caption or derives caption from object
Class ilMediaItem Media Item, component of a media object (file or reference)
static checkParameter(string $a_par, string $a_val)
Check parameter (filter javascript related and other unsafe parameters/values)
$path
Definition: ltiservices.php:30
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26