ILIAS  release_8 Revision v8.23
class.ilMediaAliasItem.php
Go to the documentation of this file.
1 <?php
2 
25 {
26  protected string $parent_node_name;
27  protected string $pcid;
28  protected ilLanguage $lng;
30  public string $hier_id = "";
31  public string $purpose = "";
32  public ?php4DOMElement $item_node = null;
33 
34  public function __construct(
35  php4DOMDocument $a_dom,
36  string $a_hier_id,
37  string $a_purpose,
38  string $a_pc_id = "",
39  string $a_parent_node_name = "MediaObject"
40  ) {
41  global $DIC;
42 
43  $this->lng = $DIC->language();
44  $this->dom = $a_dom;
45  $this->parent_node_name = $a_parent_node_name;
46  $this->hier_id = $a_hier_id;
47  $this->purpose = $a_purpose;
48  $this->setPcId($a_pc_id);
49  $this->item_node = $this->getMAItemNode(
50  $this->hier_id,
51  $this->purpose,
52  $this->getPcId()
53  );
54  }
55 
56  public function getMAItemNode(
57  string $a_hier_id,
58  string $a_purpose,
59  string $a_pc_id = "",
60  string $a_sub_element = ""
61  ): ?php4DOMElement {
62  if ($a_pc_id != "") {
63  $xpc = xpath_new_context($this->dom);
64  $path = "//PageContent[@PCID = '" . $a_pc_id . "']/" . $this->parent_node_name . "/MediaAliasItem[@Purpose='$a_purpose']" . $a_sub_element;
65  $res = xpath_eval($xpc, $path);
66  if (count($res->nodeset) == 1) {
67  return $res->nodeset[0];
68  }
69  }
70 
71  $xpc = xpath_new_context($this->dom);
72  $path = "//PageContent[@HierId = '" . $a_hier_id . "']/" . $this->parent_node_name . "/MediaAliasItem[@Purpose='$a_purpose']" . $a_sub_element;
73  $res = xpath_eval($xpc, $path);
74  if (count($res->nodeset) > 0) {
75  return $res->nodeset[0];
76  }
77  return null;
78  }
79 
80  public function getParameterNodes(
81  string $a_hier_id,
82  string $a_purpose,
83  string $a_pc_id = ""
84  ): array {
85  $xpc = xpath_new_context($this->dom);
86  if ($a_pc_id != "") {
87  $path = "//PageContent[@PCID = '" . $a_pc_id . "']/" . $this->parent_node_name . "/MediaAliasItem[@Purpose='$a_purpose']/Parameter";
88  $res = xpath_eval($xpc, $path);
89  if (count($res->nodeset) > 0) {
90  return $res->nodeset;
91  }
92  return array();
93  }
94 
95  $path = "//PageContent[@HierId = '" . $a_hier_id . "']/" . $this->parent_node_name . "/MediaAliasItem[@Purpose='$a_purpose']/Parameter";
96  $res = xpath_eval($xpc, $path);
97  if (count($res->nodeset) > 0) {
98  return $res->nodeset;
99  }
100  return [];
101  }
102 
103  public function getMapAreaNodes(
104  string $a_hier_id,
105  string $a_purpose,
106  string $a_pc_id = ""
107  ): array {
108  $xpc = xpath_new_context($this->dom);
109  if ($a_pc_id != "") {
110  $path = "//PageContent[@PCID = '" . $a_pc_id . "']/" . $this->parent_node_name . "/MediaAliasItem[@Purpose='$a_purpose']/MapArea";
111  $res = xpath_eval($xpc, $path);
112  if (count($res->nodeset) > 0) {
113  return $res->nodeset;
114  }
115  return array();
116  }
117 
118  $path = "//PageContent[@HierId = '" . $a_hier_id . "']/" . $this->parent_node_name . "/MediaAliasItem[@Purpose='$a_purpose']/MapArea";
119  $res = xpath_eval($xpc, $path);
120  if (count($res->nodeset) > 0) {
121  return $res->nodeset;
122  }
123  return array();
124  }
125 
126  public function setPcId(string $a_pcid): void
127  {
128  $this->pcid = $a_pcid;
129  }
130 
131  public function getPcId(): string
132  {
133  return $this->pcid;
134  }
135 
139  public function exists(): bool
140  {
141  if (is_object($this->item_node)) {
142  return true;
143  } else {
144  return false;
145  }
146  }
147 
151  public function insert(): void
152  {
153  $xpc = xpath_new_context($this->dom);
154  $path = "//PageContent[@HierId = '" . $this->hier_id . "']/" . $this->parent_node_name;
155  $res = xpath_eval($xpc, $path);
156  if (count($res->nodeset) > 0) {
157  $obj_node = $res->nodeset[0];
158  $item_node = $this->dom->create_element("MediaAliasItem");
159  $item_node = $obj_node->append_child($item_node);
160  $item_node->set_attribute("Purpose", $this->purpose);
161  $this->item_node = $item_node;
162  }
163  }
164 
165  public function setWidth(string $a_width): void
166  {
168  $this->dom,
169  $this->item_node,
170  "Layout",
171  array("Caption", "TextRepresentation", "Parameter", "MapArea"),
172  "",
173  array("Width" => $a_width),
174  false
175  );
176  }
177 
178 
179  public function getWidth(): string
180  {
181  $layout_node = $this->getMAItemNode(
182  $this->hier_id,
183  $this->purpose,
184  $this->getPcId(),
185  "/Layout"
186  );
187  if (is_object($layout_node)) {
188  return $layout_node->get_attribute("Width");
189  }
190  return "";
191  }
192 
197  public function definesSize(): bool
198  {
199  $layout_node = $this->getMAItemNode(
200  $this->hier_id,
201  $this->purpose,
202  $this->getPcId(),
203  "/Layout"
204  );
205  if (is_object($layout_node)) {
206  return $layout_node->has_attribute("Width");
207  }
208  return false;
209  }
210 
214  public function deriveSize(): void
215  {
216  $layout_node = $this->getMAItemNode(
217  $this->hier_id,
218  $this->purpose,
219  $this->getPcId(),
220  "/Layout"
221  );
222  if (is_object($layout_node)) {
223  if ($layout_node->has_attribute("Width")) {
224  $layout_node->remove_attribute("Width");
225  }
226  if ($layout_node->has_attribute("Height")) {
227  $layout_node->remove_attribute("Height");
228  }
229  }
230  }
231 
232  public function setHeight(string $a_height): void
233  {
235  $this->dom,
236  $this->item_node,
237  "Layout",
238  array("Caption", "TextRepresentation", "Parameter", "MapArea"),
239  "",
240  array("Height" => $a_height),
241  false
242  );
243  }
244 
245 
246  public function getHeight(): string
247  {
248  $layout_node = $this->getMAItemNode(
249  $this->hier_id,
250  $this->purpose,
251  $this->getPcId(),
252  "/Layout"
253  );
254  if (is_object($layout_node)) {
255  return $layout_node->get_attribute("Height");
256  }
257  return "";
258  }
259 
260  public function setCaption(string $a_caption): void
261  {
263  $this->dom,
264  $this->item_node,
265  "Caption",
266  array("TextRepresentation", "Parameter", "MapArea"),
267  $a_caption,
268  array("Align" => "bottom")
269  );
270  }
271 
272  public function getCaption(): string
273  {
274  $caption_node = $this->getMAItemNode(
275  $this->hier_id,
276  $this->purpose,
277  $this->getPcId(),
278  "/Caption"
279  );
280  if (is_object($caption_node)) {
281  return $caption_node->get_content();
282  }
283  return "";
284  }
285 
290  public function definesCaption(): bool
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  return true;
300  }
301  return false;
302  }
303 
307  public function deriveCaption(): void
308  {
309  $caption_node = $this->getMAItemNode(
310  $this->hier_id,
311  $this->purpose,
312  $this->getPcId(),
313  "/Caption"
314  );
315  if (is_object($caption_node)) {
316  $caption_node->unlink_node($caption_node);
317  }
318  }
319 
320  public function setTextRepresentation(
321  string $a_text_representation
322  ): void {
324  $this->dom,
325  $this->item_node,
326  "TextRepresentation",
327  array("Parameter", "MapArea"),
328  $a_text_representation,
329  array()
330  );
331  }
332 
333  public function getTextRepresentation(): string
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 $text_representation_node->get_content();
343  }
344  return "";
345  }
346 
351  public function definesTextRepresentation(): bool
352  {
353  $text_representation_node = $this->getMAItemNode(
354  $this->hier_id,
355  $this->purpose,
356  $this->getPcId(),
357  "/TextRepresentation"
358  );
359  if (is_object($text_representation_node)) {
360  return true;
361  }
362  return false;
363  }
364 
368  public function deriveTextRepresentation(): void
369  {
370  $text_representation_node = $this->getMAItemNode(
371  $this->hier_id,
372  $this->purpose,
373  $this->getPcId(),
374  "/TextRepresentation"
375  );
376  if (is_object($text_representation_node)) {
377  $text_representation_node->unlink_node($text_representation_node);
378  }
379  }
380 
381  public function setHorizontalAlign(string $a_halign): void
382  {
384  $this->dom,
385  $this->item_node,
386  "Layout",
387  array("Caption", "TextRepresentation", "Parameter", "MapArea"),
388  "",
389  array("HorizontalAlign" => $a_halign),
390  false
391  );
392  }
393 
394 
395  public function getHorizontalAlign(): string
396  {
397  $layout_node = $this->getMAItemNode(
398  $this->hier_id,
399  $this->purpose,
400  $this->getPcId(),
401  "/Layout"
402  );
403  if (is_object($layout_node)) {
404  return $layout_node->get_attribute("HorizontalAlign");
405  }
406  return "";
407  }
408 
409  public function setParameters(array $a_par_array): void
410  {
411  $par_nodes = $this->getParameterNodes(
412  $this->hier_id,
413  $this->purpose,
414  $this->getPcId()
415  );
416  for ($i = 0; $i < count($par_nodes); $i++) {
417  $par_node = $par_nodes[$i];
418  $par_node->unlink_node($par_node);
419  }
420 
421  if (is_array($a_par_array)) {
422  foreach ($a_par_array as $par => $val) {
423  if (ilMediaItem::checkParameter($par, $val)) {
424  $attributes = array("Name" => $par, "Value" => $val);
426  $this->dom,
427  $this->item_node,
428  "Parameter",
429  array("MapArea"),
430  "",
432  );
433  }
434  }
435  }
436  }
437 
441  public function getParameterString(): string
442  {
443  $par_nodes = $this->getParameterNodes(
444  $this->hier_id,
445  $this->purpose,
446  $this->getPcId()
447  );
448  $par_arr = array();
449  for ($i = 0; $i < count($par_nodes); $i++) {
450  $par_node = $par_nodes[$i];
451  $par_arr[] = $par_node->get_attribute("Name") . "=\"" . $par_node->get_attribute("Value") . "\"";
452  }
453  return implode(", ", $par_arr);
454  }
455 
459  public function getParameters(): array
460  {
461  $par_nodes = $this->getParameterNodes(
462  $this->hier_id,
463  $this->purpose,
464  $this->getPcId()
465  );
466  $par_arr = array();
467  for ($i = 0; $i < count($par_nodes); $i++) {
468  $par_node = $par_nodes[$i];
469  $par_arr[$par_node->get_attribute("Name")] =
470  $par_node->get_attribute("Value");
471  }
472  return $par_arr;
473  }
474 
479  public function definesParameters(): bool
480  {
481  $par_nodes = $this->getParameterNodes(
482  $this->hier_id,
483  $this->purpose,
484  $this->getPcId()
485  );
486  if (count($par_nodes) > 0) {
487  return true;
488  }
489  return false;
490  }
491 
495  public function deriveParameters(): void
496  {
497  $par_nodes = $this->getParameterNodes(
498  $this->hier_id,
499  $this->purpose,
500  $this->getPcId()
501  );
502  if (count($par_nodes) > 0) {
503  for ($i = 0; $i < count($par_nodes); $i++) {
504  $par_node = $par_nodes[$i];
505  $par_node->unlink_node($par_node);
506  }
507  }
508  }
509 
510 
514  public function getMapAreas(): array
515  {
516  $ma_nodes = $this->getMapAreaNodes(
517  $this->hier_id,
518  $this->purpose,
519  $this->getPcId()
520  );
521  $maparea_arr = array();
522  for ($i = 0; $i < count($ma_nodes); $i++) {
523  $maparea_node = $ma_nodes[$i];
524  $childs = $maparea_node->child_nodes();
525  $link = array();
526  if ($childs[0]->node_name() == "ExtLink") {
527  $link = array("LinkType" => "ExtLink",
528  "Href" => $childs[0]->get_attribute("Href"),
529  "Title" => $childs[0]->get_content());
530  }
531  if ($childs[0]->node_name() == "IntLink") {
532  $link = array("LinkType" => "IntLink",
533  "Target" => $childs[0]->get_attribute("Target"),
534  "Type" => $childs[0]->get_attribute("Type"),
535  "TargetFrame" => $childs[0]->get_attribute("TargetFame"),
536  "Title" => $childs[0]->get_content());
537  }
538  $maparea_arr[] = array(
539  "Nr" => $i + 1,
540  "Shape" => $maparea_node->get_attribute("Shape"),
541  "Coords" => $maparea_node->get_attribute("Coords"),
542  "HighlightMode" => $maparea_node->get_attribute("HighlightMode"),
543  "HighlightClass" => $maparea_node->get_attribute("HighlightClass"),
544  "Id" => $maparea_node->get_attribute("Id"),
545  "Link" => $link);
546  }
547 
548  return $maparea_arr;
549  }
550 
551  public function setAreaTitle(
552  int $a_nr,
553  string $a_title
554  ): void {
555  $ma_nodes = $this->getMapAreaNodes(
556  $this->hier_id,
557  $this->purpose,
558  $this->getPcId()
559  );
560  if (is_object($ma_nodes[$a_nr - 1])) {
561  $childs = $ma_nodes[$a_nr - 1]->child_nodes();
562  if (is_object($childs[0]) &&
563  ($childs[0]->node_name() == "IntLink" || $childs[0]->node_name() == "ExtLink")) {
564  $childs[0]->set_content($a_title);
565  }
566  }
567  }
568 
572  public function setAreaIntLink(
573  int $a_nr,
574  string $a_type,
575  string $a_target,
576  string $a_target_frame
577  ): void {
578  $ma_nodes = $this->getMapAreaNodes(
579  $this->hier_id,
580  $this->purpose,
581  $this->getPcId()
582  );
583  if (is_object($ma_nodes[$a_nr - 1])) {
584  $title = $this->getTitleOfArea($a_nr);
585  ilDOMUtil::deleteAllChildsByName($ma_nodes[$a_nr - 1], array("IntLink", "ExtLink"));
586  $attributes = array("Type" => $a_type, "Target" => $a_target,
587  "TargetFrame" => $a_target_frame);
589  $this->dom,
590  $ma_nodes[$a_nr - 1],
591  "IntLink",
592  array(""),
593  $title,
595  );
596  }
597  }
598 
602  public function setAreaExtLink(
603  int $a_nr,
604  string $a_href
605  ): void {
606  $ma_nodes = $this->getMapAreaNodes(
607  $this->hier_id,
608  $this->purpose,
609  $this->getPcId()
610  );
611  if (is_object($ma_nodes[$a_nr - 1])) {
612  $title = $this->getTitleOfArea($a_nr);
613  ilDOMUtil::deleteAllChildsByName($ma_nodes[$a_nr - 1], array("IntLink", "ExtLink"));
614  $attributes = array("Href" => $a_href);
616  $this->dom,
617  $ma_nodes[$a_nr - 1],
618  "ExtLink",
619  array(""),
620  $title,
622  );
623  }
624  }
625 
629  public function setShape(
630  int $a_nr,
631  string $a_shape_type,
632  string $a_coords
633  ): void {
634  $ma_nodes = $this->getMapAreaNodes(
635  $this->hier_id,
636  $this->purpose,
637  $this->getPcId()
638  );
639  if (is_object($ma_nodes[$a_nr - 1])) {
640  $ma_nodes[$a_nr - 1]->set_attribute("Shape", $a_shape_type);
641  $ma_nodes[$a_nr - 1]->set_attribute("Coords", $a_coords);
642  }
643  }
644 
648  public function setAreaHighlightMode(
649  int $a_nr,
650  string $a_mode
651  ): void {
652  $ma_nodes = $this->getMapAreaNodes(
653  $this->hier_id,
654  $this->purpose,
655  $this->getPcId()
656  );
657  if (is_object($ma_nodes[$a_nr - 1])) {
658  $ma_nodes[$a_nr - 1]->set_attribute("HighlightMode", $a_mode);
659  }
660  }
661 
665  public function setAreaHighlightClass(
666  int $a_nr,
667  string $a_class
668  ): void {
669  $ma_nodes = $this->getMapAreaNodes(
670  $this->hier_id,
671  $this->purpose,
672  $this->getPcId()
673  );
674  if (is_object($ma_nodes[$a_nr - 1])) {
675  $ma_nodes[$a_nr - 1]->set_attribute("HighlightClass", $a_class);
676  }
677  }
678 
682  public function addMapArea(
683  string $a_shape_type,
684  string $a_coords,
685  string $a_title,
686  array $a_link,
687  string $a_id = ""
688  ): void {
689  $attributes = array("Shape" => $a_shape_type,
690  "Coords" => $a_coords, "Id" => $a_id);
691 
692  $ma_node = ilDOMUtil::addElementToList(
693  $this->dom,
694  $this->item_node,
695  "MapArea",
696  array(),
697  "",
699  );
700 
701  if ($a_link["LinkType"] == "int" || $a_link["LinkType"] == "IntLink") {
702  $attributes = array("Type" => $a_link["Type"],
703  "TargetFrame" => $a_link["TargetFrame"],
704  "Target" => $a_link["Target"]);
706  $this->dom,
707  $ma_node,
708  "IntLink",
709  array(""),
710  $a_title,
712  );
713  }
714  if ($a_link["LinkType"] == "ext" || $a_link["LinkType"] == "ExtLink") {
715  $attributes = array("Href" => $a_link["Href"]);
717  $this->dom,
718  $ma_node,
719  "ExtLink",
720  array(""),
721  $a_title,
723  );
724  }
725  }
726 
730  public function deleteMapArea(int $a_nr): void
731  {
732  $ma_nodes = $this->getMapAreaNodes(
733  $this->hier_id,
734  $this->purpose,
735  $this->getPcId()
736  );
737 
738  if (is_object($ma_nodes[$a_nr - 1])) {
739  $ma_nodes[$a_nr - 1]->unlink_node($ma_nodes[$a_nr - 1]);
740  }
741  }
742 
746  public function deleteMapAreaById(
747  string $a_id
748  ): void {
749  $ma_nodes = $this->getMapAreaNodes(
750  $this->hier_id,
751  $this->purpose,
752  $this->getPcId()
753  );
754  foreach ($ma_nodes as $node) {
755  if ($node->get_attribute("Id") == $a_id) {
756  $node->unlink_node($node);
757  }
758  }
759  }
760 
764  public function deleteAllMapAreas(): void
765  {
766  $xpc = xpath_new_context($this->dom);
767  $path = "//PageContent[@HierId = '" . $this->hier_id . "']/" . $this->parent_node_name . "/MediaAliasItem[@Purpose='" . $this->purpose . "']/MapArea";
768  $res = xpath_eval($xpc, $path);
769  for ($i = 0; $i < count($res->nodeset); $i++) {
770  $res->nodeset[$i]->unlink_node($res->nodeset[$i]);
771  }
772  }
773 
777  public function getLinkTypeOfArea(int $a_nr): string
778  {
779  $ma_nodes = $this->getMapAreaNodes(
780  $this->hier_id,
781  $this->purpose,
782  $this->getPcId()
783  );
784  if (is_object($ma_nodes[$a_nr - 1])) {
785  $childs = $ma_nodes[$a_nr - 1]->child_nodes();
786  if ($childs[0]->node_name() == "IntLink") {
787  return "int";
788  }
789  if ($childs[0]->node_name() == "ExtLink") {
790  return "ext";
791  }
792  }
793  return "";
794  }
795 
799  public function getTypeOfArea(int $a_nr): string
800  {
801  $ma_nodes = $this->getMapAreaNodes(
802  $this->hier_id,
803  $this->purpose,
804  $this->getPcId()
805  );
806  if (is_object($ma_nodes[$a_nr - 1])) {
807  $childs = $ma_nodes[$a_nr - 1]->child_nodes();
808  return $childs[0]->get_attribute("Type");
809  }
810  return "";
811  }
812 
816  public function getTargetOfArea(int $a_nr): string
817  {
818  $ma_nodes = $this->getMapAreaNodes(
819  $this->hier_id,
820  $this->purpose,
821  $this->getPcId()
822  );
823  if (is_object($ma_nodes[$a_nr - 1])) {
824  $childs = $ma_nodes[$a_nr - 1]->child_nodes();
825  return $childs[0]->get_attribute("Target");
826  }
827  return "";
828  }
829 
833  public function getTargetFrameOfArea(int $a_nr): string
834  {
835  $ma_nodes = $this->getMapAreaNodes(
836  $this->hier_id,
837  $this->purpose,
838  $this->getPcId()
839  );
840  if (is_object($ma_nodes[$a_nr - 1])) {
841  $childs = $ma_nodes[$a_nr - 1]->child_nodes();
842  return $childs[0]->get_attribute("TargetFrame");
843  }
844  return "";
845  }
846 
850  public function getHrefOfArea(int $a_nr): string
851  {
852  $ma_nodes = $this->getMapAreaNodes(
853  $this->hier_id,
854  $this->purpose,
855  $this->getPcId()
856  );
857  if (is_object($ma_nodes[$a_nr - 1])) {
858  $childs = $ma_nodes[$a_nr - 1]->child_nodes();
859  return $childs[0]->get_attribute("Href");
860  }
861  return "";
862  }
863 
867  public function getTitleOfArea(int $a_nr): string
868  {
869  $ma_nodes = $this->getMapAreaNodes(
870  $this->hier_id,
871  $this->purpose,
872  $this->getPcId()
873  );
874  if (is_object($ma_nodes[$a_nr - 1])) {
875  $childs = $ma_nodes[$a_nr - 1]->child_nodes();
876  return $childs[0]->get_content();
877  }
878  return "";
879  }
880 
884  public function delete(): void
885  {
886  if (is_object($this->item_node)) {
887  $this->item_node->unlink_node($this->item_node);
888  }
889  }
890 
896  public function makeMapWorkCopy(
897  ilMediaItem $a_st_item,
898  int $a_area_nr,
899  bool $a_exclude,
900  bool $a_output_new_area,
901  string $a_area_type,
902  string $a_coords
903  ): bool {
904  $a_st_item->copyOriginal();
905  $a_st_item->buildMapWorkImage();
906 
907  // determine ratios (first see whether the instance has w/h defined)
908  $width = $this->getWidth();
909  $height = $this->getHeight();
910 
911  // if instance has no size, use object w/h
912  if ($width == 0 && $height == 0) {
913  $width = $a_st_item->getWidth();
914  $height = $a_st_item->getHeight();
915  }
916  $size = getimagesize($a_st_item->getMapWorkCopyName());
917  $x_ratio = 1;
918  if ($size[0] > 0 && $width > 0) {
919  $x_ratio = $width / $size[0];
920  }
921  $y_ratio = 1;
922  if ($size[1] > 0 && $height > 0) {
923  $y_ratio = $height / $size[1];
924  }
925 
926  // draw map areas
927  $areas = $this->getMapAreas();
928  for ($i = 0; $i < count($areas); $i++) {
929  if (((($i + 1) == $a_area_nr) && !$a_exclude) ||
930  ((($i + 1) != $a_area_nr) && $a_exclude) ||
931  ($a_area_nr == 0)
932  ) {
933  $area = new ilMapArea();
934  $area->setShape($areas[$i]["Shape"]);
935  $area->setCoords($areas[$i]["Coords"]);
936  $area->draw(
937  $a_st_item->getMapWorkImage(),
938  $a_st_item->color1,
939  $a_st_item->color2,
940  true,
941  $x_ratio,
942  $y_ratio
943  );
944  }
945  }
946 
947  if ($a_output_new_area) {
948  $area = new ilMapArea();
949  $area->setShape($a_area_type);
950  $area->setCoords($a_coords);
951  $area->draw(
952  $a_st_item->getMapWorkImage(),
953  $a_st_item->color1,
954  $a_st_item->color2,
955  false,
956  $x_ratio,
957  $y_ratio
958  );
959  }
960 
961  $a_st_item->saveMapWorkImage();
962  return true;
963  }
964 
968  public function hasAnyPropertiesSet(): bool
969  {
970  return ($this->definesSize() ||
971  $this->definesCaption() ||
972  $this->definesTextRepresentation() ||
973  $this->definesParameters());
974  }
975 }
xpath_eval(php4DOMXPath $xpath_context, string $eval_str, $contextnode=null)
hasAnyPropertiesSet()
Has the alias any properties set?
$attributes
Definition: metadata.php:248
$res
Definition: ltiservices.php:69
static setFirstOptionalElement(php4DOMDocument $doc, php4DOMElement $parent_node, string $a_node_name, array $a_successors, string $a_content, array $a_attributes, bool $a_remove_childs=true)
searches for an element $a_node_name within the childs of $parent_node if no node is found...
append_child($newnode)
static addElementToList(php4DOMDocument $doc, php4DOMElement $parent_node, string $a_node_name, array $a_successors, string $a_content, array $a_attributes)
Places a new node $a_node_name directly before nodes with names of $a_successors. ...
set_attribute($name, $value)
static deleteAllChildsByName(php4DOMElement $a_parent, array $a_node_names)
delete all childs of a node by names in $a_node_names
setCaption(string $a_caption)
insert()
inserts new node in dom
copyOriginal()
Copy the original file for map editing to the working directory.
static checkParameter(string $a_par, string $a_val)
Check parameter (filter javascript related and other unsafe parameters/values)
buildMapWorkImage()
build image map work image
definesTextRepresentation()
check if alias item defines own TextRepresentation or derives TextRepresentation from object ...
deleteAllMapAreas()
Delete all map areas.
setAreaTitle(int $a_nr, string $a_title)
getTitleOfArea(int $a_nr)
Get title.
deriveSize()
derive size from object (-> width and height attributes are removed from layout element) ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
deriveCaption()
derive caption from object (-> caption element is removed from media alias item)
setAreaHighlightClass(int $a_nr, string $a_class)
Set highlight class single area.
$path
Definition: ltiservices.php:32
deriveTextRepresentation()
derive TextRepresentation from object (-> TextRepresentation element is removed from media alias item...
deleteMapArea(int $a_nr)
Delete a sinlge map area.
global $DIC
Definition: feed.php:28
definesCaption()
check if alias item defines own caption or derives caption from object
definesSize()
check if alias item defines own size or derives size from object
xpath_new_context($dom_document)
setAreaIntLink(int $a_nr, string $a_type, string $a_target, string $a_target_frame)
Set link of area to an internal one.
getMapAreaNodes(string $a_hier_id, string $a_purpose, string $a_pc_id="")
php4DomElement
__construct(php4DOMDocument $a_dom, string $a_hier_id, string $a_purpose, string $a_pc_id="", string $a_parent_node_name="MediaObject")
getMapWorkCopyName(bool $a_reference_copy=false)
Get name of image map work copy file.
getTargetOfArea(int $a_nr)
Get target (only internal link)
getParameterString()
Get all parameters as string.
setTextRepresentation(string $a_text_representation)
addMapArea(string $a_shape_type, string $a_coords, string $a_title, array $a_link, string $a_id="")
Add a new area to the map.
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
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setHeight(string $a_height)
getParameters()
Get all parameters as array.
setParameters(array $a_par_array)
getTypeOfArea(int $a_nr)
Get type (only internal link)
getLinkTypeOfArea(int $a_nr)
Get link type.
setAreaExtLink(int $a_nr, string $a_href)
Set link of area to an external one.
setShape(int $a_nr, string $a_shape_type, string $a_coords)
Set shape and coords of single area.
saveMapWorkImage()
save image map work image as file
deriveParameters()
derive parameters from object (-> all parameter elements are removed from media alias item) ...
Class ilMapArea.
getTargetFrameOfArea(int $a_nr)
Get target frame (only internal link)
getMAItemNode(string $a_hier_id, string $a_purpose, string $a_pc_id="", string $a_sub_element="")
exists()
check if item node exists
setAreaHighlightMode(int $a_nr, string $a_mode)
Set highlight mode single area.
setWidth(string $a_width)
getParameterNodes(string $a_hier_id, string $a_purpose, string $a_pc_id="")
deleteMapAreaById(string $a_id)
Delete map areas by id.
setHorizontalAlign(string $a_halign)
getHrefOfArea(int $a_nr)
Get href (only external link)
getMapAreas()
Get all map areas.
$i
Definition: metadata.php:41
definesParameters()
check if alias item defines own parameters or derives parameters from object