ILIAS  release_8 Revision v8.24
ilMediaAliasItem Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilMediaAliasItem:

Public Member Functions

 __construct (php4DOMDocument $a_dom, string $a_hier_id, string $a_purpose, string $a_pc_id="", string $a_parent_node_name="MediaObject")
 
 getMAItemNode (string $a_hier_id, string $a_purpose, string $a_pc_id="", string $a_sub_element="")
 
 getParameterNodes (string $a_hier_id, string $a_purpose, string $a_pc_id="")
 
 getMapAreaNodes (string $a_hier_id, string $a_purpose, string $a_pc_id="")
 
 setPcId (string $a_pcid)
 
 getPcId ()
 
 exists ()
 check if item node exists More...
 
 insert ()
 inserts new node in dom More...
 
 setWidth (string $a_width)
 
 getWidth ()
 
 definesSize ()
 check if alias item defines own size or derives size from object More...
 
 deriveSize ()
 derive size from object (-> width and height attributes are removed from layout element) More...
 
 setHeight (string $a_height)
 
 getHeight ()
 
 setCaption (string $a_caption)
 
 getCaption ()
 
 definesCaption ()
 check if alias item defines own caption or derives caption from object More...
 
 deriveCaption ()
 derive caption from object (-> caption element is removed from media alias item) More...
 
 setTextRepresentation (string $a_text_representation)
 
 getTextRepresentation ()
 
 definesTextRepresentation ()
 check if alias item defines own TextRepresentation or derives TextRepresentation from object More...
 
 deriveTextRepresentation ()
 derive TextRepresentation from object (-> TextRepresentation element is removed from media alias item) More...
 
 setHorizontalAlign (string $a_halign)
 
 getHorizontalAlign ()
 
 setParameters (array $a_par_array)
 
 getParameterString ()
 Get all parameters as string. More...
 
 getParameters ()
 Get all parameters as array. More...
 
 definesParameters ()
 check if alias item defines own parameters or derives parameters from object More...
 
 deriveParameters ()
 derive parameters from object (-> all parameter elements are removed from media alias item) More...
 
 getMapAreas ()
 Get all map areas. More...
 
 setAreaTitle (int $a_nr, string $a_title)
 
 setAreaIntLink (int $a_nr, string $a_type, string $a_target, string $a_target_frame)
 Set link of area to an internal one. More...
 
 setAreaExtLink (int $a_nr, string $a_href)
 Set link of area to an external one. More...
 
 setShape (int $a_nr, string $a_shape_type, string $a_coords)
 Set shape and coords of single area. More...
 
 setAreaHighlightMode (int $a_nr, string $a_mode)
 Set highlight mode single area. More...
 
 setAreaHighlightClass (int $a_nr, string $a_class)
 Set highlight class single area. More...
 
 addMapArea (string $a_shape_type, string $a_coords, string $a_title, array $a_link, string $a_id="")
 Add a new area to the map. More...
 
 deleteMapArea (int $a_nr)
 Delete a sinlge map area. More...
 
 deleteMapAreaById (string $a_id)
 Delete map areas by id. More...
 
 deleteAllMapAreas ()
 Delete all map areas. More...
 
 getLinkTypeOfArea (int $a_nr)
 Get link type. More...
 
 getTypeOfArea (int $a_nr)
 Get type (only internal link) More...
 
 getTargetOfArea (int $a_nr)
 Get target (only internal link) More...
 
 getTargetFrameOfArea (int $a_nr)
 Get target frame (only internal link) More...
 
 getHrefOfArea (int $a_nr)
 Get href (only external link) More...
 
 getTitleOfArea (int $a_nr)
 Get title. More...
 
 delete ()
 delete full item node from dom More...
 
 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 More...
 
 hasAnyPropertiesSet ()
 Has the alias any properties set? More...
 

Data Fields

php4DOMDocument $dom
 
string $hier_id = ""
 
string $purpose = ""
 
php4DOMElement $item_node = null
 

Protected Attributes

string $parent_node_name
 
string $pcid
 
ilLanguage $lng
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilMediaAliasItem Media Alias Item, component of a media object (file or reference)

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 24 of file class.ilMediaAliasItem.php.

Constructor & Destructor Documentation

◆ __construct()

ilMediaAliasItem::__construct ( php4DOMDocument  $a_dom,
string  $a_hier_id,
string  $a_purpose,
string  $a_pc_id = "",
string  $a_parent_node_name = "MediaObject" 
)

Definition at line 34 of file class.ilMediaAliasItem.php.

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 }
getMAItemNode(string $a_hier_id, string $a_purpose, string $a_pc_id="", string $a_sub_element="")
global $DIC
Definition: feed.php:28

References $DIC, getMAItemNode(), getPcId(), ILIAS\Repository\lng(), and setPcId().

+ Here is the call graph for this function:

Member Function Documentation

◆ addMapArea()

ilMediaAliasItem::addMapArea ( string  $a_shape_type,
string  $a_coords,
string  $a_title,
array  $a_link,
string  $a_id = "" 
)

Add a new area to the map.

Definition at line 682 of file class.ilMediaAliasItem.php.

688 : void {
689 $attributes = array("Shape" => $a_shape_type,
690 "Coords" => $a_coords, "Id" => $a_id);
691
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 }
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.
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,...
$attributes
Definition: metadata.php:248

◆ definesCaption()

ilMediaAliasItem::definesCaption ( )

check if alias item defines own caption or derives caption from object

Returns
bool returns true if caption is not derived from object

Definition at line 290 of file class.ilMediaAliasItem.php.

290 : 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 }

◆ definesParameters()

ilMediaAliasItem::definesParameters ( )

check if alias item defines own parameters or derives parameters from object

Returns
bool returns true if parameters are not derived from object

Definition at line 479 of file class.ilMediaAliasItem.php.

479 : 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 }
getParameterNodes(string $a_hier_id, string $a_purpose, string $a_pc_id="")

◆ definesSize()

ilMediaAliasItem::definesSize ( )

check if alias item defines own size or derives size from object

Returns
bool returns true if size is not derived from object

Definition at line 197 of file class.ilMediaAliasItem.php.

197 : 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 }

◆ definesTextRepresentation()

ilMediaAliasItem::definesTextRepresentation ( )

check if alias item defines own TextRepresentation or derives TextRepresentation from object

Returns
bool returns true if TextRepresentation is not derived from object

Definition at line 351 of file class.ilMediaAliasItem.php.

351 : 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 }

◆ delete()

ilMediaAliasItem::delete ( )

delete full item node from dom

Definition at line 884 of file class.ilMediaAliasItem.php.

884 : void
885 {
886 if (is_object($this->item_node)) {
887 $this->item_node->unlink_node($this->item_node);
888 }
889 }

◆ deleteAllMapAreas()

ilMediaAliasItem::deleteAllMapAreas ( )

Delete all map areas.

Definition at line 764 of file class.ilMediaAliasItem.php.

764 : 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 }
xpath_new_context($dom_document)
xpath_eval(php4DOMXPath $xpath_context, string $eval_str, $contextnode=null)
$path
Definition: ltiservices.php:32
$res
Definition: ltiservices.php:69
$i
Definition: metadata.php:41

References $i, $path, $res, xpath_eval(), and xpath_new_context().

+ Here is the call graph for this function:

◆ deleteMapArea()

ilMediaAliasItem::deleteMapArea ( int  $a_nr)

Delete a sinlge map area.

Definition at line 730 of file class.ilMediaAliasItem.php.

730 : 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 }
getMapAreaNodes(string $a_hier_id, string $a_purpose, string $a_pc_id="")

◆ deleteMapAreaById()

ilMediaAliasItem::deleteMapAreaById ( string  $a_id)

Delete map areas by id.

Definition at line 746 of file class.ilMediaAliasItem.php.

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 }

◆ deriveCaption()

ilMediaAliasItem::deriveCaption ( )

derive caption from object (-> caption element is removed from media alias item)

Definition at line 307 of file class.ilMediaAliasItem.php.

307 : 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 }

◆ deriveParameters()

ilMediaAliasItem::deriveParameters ( )

derive parameters from object (-> all parameter elements are removed from media alias item)

Definition at line 495 of file class.ilMediaAliasItem.php.

495 : 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 }

References $i.

◆ deriveSize()

ilMediaAliasItem::deriveSize ( )

derive size from object (-> width and height attributes are removed from layout element)

Definition at line 214 of file class.ilMediaAliasItem.php.

214 : 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 }

◆ deriveTextRepresentation()

ilMediaAliasItem::deriveTextRepresentation ( )

derive TextRepresentation from object (-> TextRepresentation element is removed from media alias item)

Definition at line 368 of file class.ilMediaAliasItem.php.

368 : 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 }

◆ exists()

ilMediaAliasItem::exists ( )

check if item node exists

Definition at line 139 of file class.ilMediaAliasItem.php.

139 : bool
140 {
141 if (is_object($this->item_node)) {
142 return true;
143 } else {
144 return false;
145 }
146 }

◆ getCaption()

ilMediaAliasItem::getCaption ( )

Definition at line 272 of file class.ilMediaAliasItem.php.

272 : 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 }

◆ getHeight()

ilMediaAliasItem::getHeight ( )

Definition at line 246 of file class.ilMediaAliasItem.php.

246 : 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 }

◆ getHorizontalAlign()

ilMediaAliasItem::getHorizontalAlign ( )

Definition at line 395 of file class.ilMediaAliasItem.php.

395 : 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 }

◆ getHrefOfArea()

ilMediaAliasItem::getHrefOfArea ( int  $a_nr)

Get href (only external link)

Definition at line 850 of file class.ilMediaAliasItem.php.

850 : 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 }

◆ getLinkTypeOfArea()

ilMediaAliasItem::getLinkTypeOfArea ( int  $a_nr)

Get link type.

Definition at line 777 of file class.ilMediaAliasItem.php.

777 : 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 }

◆ getMAItemNode()

ilMediaAliasItem::getMAItemNode ( string  $a_hier_id,
string  $a_purpose,
string  $a_pc_id = "",
string  $a_sub_element = "" 
)

Definition at line 56 of file class.ilMediaAliasItem.php.

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 }

References $path, $res, xpath_eval(), and xpath_new_context().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMapAreaNodes()

ilMediaAliasItem::getMapAreaNodes ( string  $a_hier_id,
string  $a_purpose,
string  $a_pc_id = "" 
)

Definition at line 103 of file class.ilMediaAliasItem.php.

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 }

References $path, $res, and xpath_eval().

+ Here is the call graph for this function:

◆ getMapAreas()

ilMediaAliasItem::getMapAreas ( )

Get all map areas.

Definition at line 514 of file class.ilMediaAliasItem.php.

514 : 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 }

References $i.

◆ getParameterNodes()

ilMediaAliasItem::getParameterNodes ( string  $a_hier_id,
string  $a_purpose,
string  $a_pc_id = "" 
)

Definition at line 80 of file class.ilMediaAliasItem.php.

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 }

References $path, $res, and xpath_eval().

+ Here is the call graph for this function:

◆ getParameters()

ilMediaAliasItem::getParameters ( )

Get all parameters as array.

Definition at line 459 of file class.ilMediaAliasItem.php.

459 : 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 }

References $i.

◆ getParameterString()

ilMediaAliasItem::getParameterString ( )

Get all parameters as string.

Definition at line 441 of file class.ilMediaAliasItem.php.

441 : 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 }

References $i.

◆ getPcId()

ilMediaAliasItem::getPcId ( )

Definition at line 131 of file class.ilMediaAliasItem.php.

131 : string
132 {
133 return $this->pcid;
134 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ getTargetFrameOfArea()

ilMediaAliasItem::getTargetFrameOfArea ( int  $a_nr)

Get target frame (only internal link)

Definition at line 833 of file class.ilMediaAliasItem.php.

833 : 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 }

◆ getTargetOfArea()

ilMediaAliasItem::getTargetOfArea ( int  $a_nr)

Get target (only internal link)

Definition at line 816 of file class.ilMediaAliasItem.php.

816 : 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 }

◆ getTextRepresentation()

ilMediaAliasItem::getTextRepresentation ( )

Definition at line 333 of file class.ilMediaAliasItem.php.

333 : 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 }

◆ getTitleOfArea()

ilMediaAliasItem::getTitleOfArea ( int  $a_nr)

Get title.

Definition at line 867 of file class.ilMediaAliasItem.php.

867 : 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 }

◆ getTypeOfArea()

ilMediaAliasItem::getTypeOfArea ( int  $a_nr)

Get type (only internal link)

Definition at line 799 of file class.ilMediaAliasItem.php.

799 : 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 }

◆ getWidth()

ilMediaAliasItem::getWidth ( )

Definition at line 179 of file class.ilMediaAliasItem.php.

179 : 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 }

◆ hasAnyPropertiesSet()

ilMediaAliasItem::hasAnyPropertiesSet ( )

Has the alias any properties set?

Definition at line 968 of file class.ilMediaAliasItem.php.

968 : bool
969 {
970 return ($this->definesSize() ||
971 $this->definesCaption() ||
972 $this->definesTextRepresentation() ||
973 $this->definesParameters());
974 }
definesTextRepresentation()
check if alias item defines own TextRepresentation or derives TextRepresentation from object
definesParameters()
check if alias item defines own parameters or derives parameters from object
definesSize()
check if alias item defines own size or derives size from object
definesCaption()
check if alias item defines own caption or derives caption from object

◆ insert()

ilMediaAliasItem::insert ( )

inserts new node in dom

Definition at line 151 of file class.ilMediaAliasItem.php.

151 : 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 }
set_attribute($name, $value)
append_child($newnode)

References $path, $res, php4DOMNode\append_child(), php4DOMElement\set_attribute(), xpath_eval(), and xpath_new_context().

+ Here is the call graph for this function:

◆ makeMapWorkCopy()

ilMediaAliasItem::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

Parameters
int$a_area_nrdraw area $a_area_nr only
bool$a_excludetrue: draw all areas but area $a_area_nr

Definition at line 896 of file class.ilMediaAliasItem.php.

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 }
Class ilMapArea.
getMapAreas()
Get all map areas.
saveMapWorkImage()
save image map work image as file
getMapWorkCopyName(bool $a_reference_copy=false)
Get name of image map work copy file.
buildMapWorkImage()
build image map work image
copyOriginal()
Copy the original file for map editing to the working directory.

◆ setAreaExtLink()

ilMediaAliasItem::setAreaExtLink ( int  $a_nr,
string  $a_href 
)

Set link of area to an external one.

Definition at line 602 of file class.ilMediaAliasItem.php.

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 }
static deleteAllChildsByName(php4DOMElement $a_parent, array $a_node_names)
delete all childs of a node by names in $a_node_names
getTitleOfArea(int $a_nr)
Get title.

References $attributes, ilDOMUtil\deleteAllChildsByName(), and ilDOMUtil\setFirstOptionalElement().

+ Here is the call graph for this function:

◆ setAreaHighlightClass()

ilMediaAliasItem::setAreaHighlightClass ( int  $a_nr,
string  $a_class 
)

Set highlight class single area.

Definition at line 665 of file class.ilMediaAliasItem.php.

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 }

◆ setAreaHighlightMode()

ilMediaAliasItem::setAreaHighlightMode ( int  $a_nr,
string  $a_mode 
)

Set highlight mode single area.

Definition at line 648 of file class.ilMediaAliasItem.php.

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 }

◆ setAreaIntLink()

ilMediaAliasItem::setAreaIntLink ( int  $a_nr,
string  $a_type,
string  $a_target,
string  $a_target_frame 
)

Set link of area to an internal one.

Definition at line 572 of file class.ilMediaAliasItem.php.

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 }

References $attributes, ilDOMUtil\deleteAllChildsByName(), and ilDOMUtil\setFirstOptionalElement().

+ Here is the call graph for this function:

◆ setAreaTitle()

ilMediaAliasItem::setAreaTitle ( int  $a_nr,
string  $a_title 
)

Definition at line 551 of file class.ilMediaAliasItem.php.

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 }

◆ setCaption()

ilMediaAliasItem::setCaption ( string  $a_caption)

Definition at line 260 of file class.ilMediaAliasItem.php.

260 : 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 }

References ilDOMUtil\setFirstOptionalElement().

+ Here is the call graph for this function:

◆ setHeight()

ilMediaAliasItem::setHeight ( string  $a_height)

Definition at line 232 of file class.ilMediaAliasItem.php.

232 : 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 }

References ilDOMUtil\setFirstOptionalElement().

+ Here is the call graph for this function:

◆ setHorizontalAlign()

ilMediaAliasItem::setHorizontalAlign ( string  $a_halign)

Definition at line 381 of file class.ilMediaAliasItem.php.

381 : 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 }

References ilDOMUtil\setFirstOptionalElement().

+ Here is the call graph for this function:

◆ setParameters()

ilMediaAliasItem::setParameters ( array  $a_par_array)

Definition at line 409 of file class.ilMediaAliasItem.php.

409 : 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 }
static checkParameter(string $a_par, string $a_val)
Check parameter (filter javascript related and other unsafe parameters/values)

References $attributes, $i, ilDOMUtil\addElementToList(), and ilMediaItem\checkParameter().

+ Here is the call graph for this function:

◆ setPcId()

ilMediaAliasItem::setPcId ( string  $a_pcid)

Definition at line 126 of file class.ilMediaAliasItem.php.

126 : void
127 {
128 $this->pcid = $a_pcid;
129 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setShape()

ilMediaAliasItem::setShape ( int  $a_nr,
string  $a_shape_type,
string  $a_coords 
)

Set shape and coords of single area.

Definition at line 629 of file class.ilMediaAliasItem.php.

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 }

◆ setTextRepresentation()

ilMediaAliasItem::setTextRepresentation ( string  $a_text_representation)

Definition at line 320 of file class.ilMediaAliasItem.php.

322 : void {
324 $this->dom,
325 $this->item_node,
326 "TextRepresentation",
327 array("Parameter", "MapArea"),
328 $a_text_representation,
329 array()
330 );
331 }

◆ setWidth()

ilMediaAliasItem::setWidth ( string  $a_width)

Definition at line 165 of file class.ilMediaAliasItem.php.

165 : 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 }

References ilDOMUtil\setFirstOptionalElement().

+ Here is the call graph for this function:

Field Documentation

◆ $dom

php4DOMDocument ilMediaAliasItem::$dom

Definition at line 29 of file class.ilMediaAliasItem.php.

◆ $hier_id

string ilMediaAliasItem::$hier_id = ""

Definition at line 30 of file class.ilMediaAliasItem.php.

◆ $item_node

php4DOMElement ilMediaAliasItem::$item_node = null

Definition at line 32 of file class.ilMediaAliasItem.php.

◆ $lng

ilLanguage ilMediaAliasItem::$lng
protected

Definition at line 28 of file class.ilMediaAliasItem.php.

◆ $parent_node_name

string ilMediaAliasItem::$parent_node_name
protected

Definition at line 26 of file class.ilMediaAliasItem.php.

◆ $pcid

string ilMediaAliasItem::$pcid
protected

Definition at line 27 of file class.ilMediaAliasItem.php.

◆ $purpose

string ilMediaAliasItem::$purpose = ""

Definition at line 31 of file class.ilMediaAliasItem.php.


The documentation for this class was generated from the following file: