4 include_once(
"./Services/Utilities/classes/class.ilDOMUtil.php");
24 $a_parent_node_name =
"MediaObject")
27 $this->parent_node_name = $a_parent_node_name;
28 $this->hier_id = $a_hier_id;
29 $this->purpose = $a_purpose;
31 $this->item_node = $this->
getMAItemNode($this->hier_id, $this->purpose,
35 function getMAItemNode($a_hier_id, $a_purpose, $a_pc_id =
"", $a_sub_element =
"")
40 $path =
"//PageContent[@PCID = '".$a_pc_id.
"']/".$this->parent_node_name.
"/MediaAliasItem[@Purpose='$a_purpose']".$a_sub_element;
42 if (count(
$res->nodeset) == 1)
44 return $res->nodeset[0];
49 $path =
"//PageContent[@HierId = '".$a_hier_id.
"']/".$this->parent_node_name.
"/MediaAliasItem[@Purpose='$a_purpose']".$a_sub_element;
51 if (count(
$res->nodeset) > 0)
53 return $res->nodeset[0];
62 $path =
"//PageContent[@PCID = '".$a_pc_id.
"']/".$this->parent_node_name.
"/MediaAliasItem[@Purpose='$a_purpose']/Parameter";
64 if (count(
$res->nodeset) > 0)
72 $path =
"//PageContent[@HierId = '".$a_hier_id.
"']/".$this->parent_node_name.
"/MediaAliasItem[@Purpose='$a_purpose']/Parameter";
74 if (count(
$res->nodeset) > 0)
85 $path =
"//PageContent[@PCID = '".$a_pc_id.
"']/".$this->parent_node_name.
"/MediaAliasItem[@Purpose='$a_purpose']/MapArea";
87 if (count(
$res->nodeset) > 0)
95 $path =
"//PageContent[@HierId = '".$a_hier_id.
"']/".$this->parent_node_name.
"/MediaAliasItem[@Purpose='$a_purpose']/MapArea";
97 if (count(
$res->nodeset) > 0)
110 $this->pcid = $a_pcid;
130 if (is_object($this->item_node))
146 $path =
"//PageContent[@HierId = '".$this->hier_id.
"']/".$this->parent_node_name;
148 if (count(
$res->nodeset) > 0)
150 $obj_node =&
$res->nodeset[0];
151 $item_node =& $this->dom->create_element(
"MediaAliasItem");
153 $item_node->set_attribute(
"Purpose", $this->purpose);
164 array(
"Caption",
"TextRepresentation",
"Parameter",
"MapArea"),
165 "", array(
"Width" => $a_width),
false);
174 $layout_node = $this->
getMAItemNode($this->hier_id, $this->purpose,
176 if (is_object($layout_node))
178 return $layout_node->get_attribute(
"Width");
189 $layout_node = $this->
getMAItemNode($this->hier_id, $this->purpose,
191 if (is_object($layout_node))
193 return $layout_node->has_attribute(
"Width");
203 $layout_node = $this->
getMAItemNode($this->hier_id, $this->purpose,
205 if (is_object($layout_node))
207 if ($layout_node->has_attribute(
"Width"))
209 $layout_node->remove_attribute(
"Width");
211 if ($layout_node->has_attribute(
"Height"))
213 $layout_node->remove_attribute(
"Height");
224 array(
"Caption",
"TextRepresentation",
"Parameter",
"MapArea"),
225 "", array(
"Height" => $a_height),
false);
234 $layout_node = $this->
getMAItemNode($this->hier_id, $this->purpose,
236 if (is_object($layout_node))
238 return $layout_node->get_attribute(
"Height");
249 array(
"TextRepresentation",
"Parameter",
"MapArea"),
250 $a_caption, array(
"Align" =>
"bottom"));
259 $caption_node = $this->
getMAItemNode($this->hier_id, $this->purpose,
261 if (is_object($caption_node))
263 return $caption_node->get_content();
274 $caption_node = $this->
getMAItemNode($this->hier_id, $this->purpose,
276 if (is_object($caption_node))
288 $caption_node = $this->
getMAItemNode($this->hier_id, $this->purpose,
290 if (is_object($caption_node))
292 $caption_node->unlink_node($caption_node);
302 array(
"Parameter",
"MapArea"),
303 $a_text_representation, array());
311 $text_representation_node = $this->
getMAItemNode($this->hier_id, $this->purpose,
312 $this->
getPcId(),
"/TextRepresentation");
313 if (is_object($text_representation_node))
315 return $text_representation_node->get_content();
326 $text_representation_node = $this->
getMAItemNode($this->hier_id, $this->purpose,
327 $this->
getPcId(),
"/TextRepresentation");
328 if (is_object($text_representation_node))
340 $text_representation_node = $this->
getMAItemNode($this->hier_id, $this->purpose,
341 $this->
getPcId(),
"/TextRepresentation");
342 if (is_object($text_representation_node))
344 $text_representation_node->unlink_node($text_representation_node);
351 array(
"Caption",
"TextRepresentation",
"Parameter",
"MapArea"),
352 "", array(
"HorizontalAlign" => $a_halign),
false);
358 $layout_node = $this->
getMAItemNode($this->hier_id, $this->purpose,
360 if (is_object($layout_node))
362 return $layout_node->get_attribute(
"HorizontalAlign");
374 for($i=0; $i < count($par_nodes); $i++)
376 $par_node =& $par_nodes[$i];
377 $par_node->unlink_node($par_node);
380 if (is_array($a_par_array))
382 foreach($a_par_array as $par => $val)
384 $attributes = array (
"Name" => $par,
"Value" => $val);
386 "Parameter", array(
"MapArea"),
"", $attributes);
403 for($i=0; $i < count($par_nodes); $i++)
405 $par_node =& $par_nodes[$i];
406 $par_arr[] = $par_node->get_attribute(
"Name").
"=\"".$par_node->get_attribute(
"Value").
"\"";
408 return implode($par_arr,
", ");
419 for($i=0; $i < count($par_nodes); $i++)
421 $par_node =& $par_nodes[$i];
422 $par_arr[$par_node->get_attribute(
"Name")] =
423 $par_node->get_attribute(
"Value");
444 if (count($par_nodes) > 0)
458 if (count($par_nodes) > 0)
460 for($i=0; $i < count($par_nodes); $i++)
462 $par_node =& $par_nodes[$i];
463 $par_node->unlink_node($par_node);
476 $maparea_arr = array();
477 for($i=0; $i < count($ma_nodes); $i++)
479 $maparea_node = $ma_nodes[$i];
480 $childs = $maparea_node->child_nodes();
482 if ($childs[0]->node_name() ==
"ExtLink")
484 $link = array(
"LinkType" =>
"ExtLink",
485 "Href" => $childs[0]->get_attribute(
"Href"),
486 "Title" => $childs[0]->get_content());
488 if ($childs[0]->node_name() ==
"IntLink")
490 $link = array(
"LinkType" =>
"IntLink",
491 "Target" => $childs[0]->get_attribute(
"Target"),
492 "Type" => $childs[0]->get_attribute(
"Type"),
493 "TargetFrame" => $childs[0]->get_attribute(
"TargetFame"),
494 "Title" => $childs[0]->get_content());
496 $maparea_arr[] = array(
498 "Shape" => $maparea_node->get_attribute(
"Shape"),
499 "Coords" => $maparea_node->get_attribute(
"Coords"),
500 "HighlightMode" => $maparea_node->get_attribute(
"HighlightMode"),
501 "HighlightClass" => $maparea_node->get_attribute(
"HighlightClass"),
502 "Id" => $maparea_node->get_attribute(
"Id"),
516 if (is_object($ma_nodes[$a_nr - 1]))
518 $childs = $ma_nodes[$a_nr - 1]->child_nodes();
519 if (is_object($childs[0]) &&
520 ($childs[0]->node_name() ==
"IntLink" || $childs[0]->node_name() ==
"ExtLink"))
522 $childs[0]->set_content($a_title);
534 if (is_object($ma_nodes[$a_nr - 1]))
538 $attributes = array(
"Type" => $a_type,
"Target" => $a_target,
539 "TargetFrame" => $a_target_frame);
541 array(
""), $title, $attributes);
552 if (is_object($ma_nodes[$a_nr - 1]))
556 $attributes = array(
"Href" => $a_href);
558 array(
""), $title, $attributes);
569 if (is_object($ma_nodes[$a_nr - 1]))
571 $ma_nodes[$a_nr - 1]->set_attribute(
"Shape", $a_shape_type);
572 $ma_nodes[$a_nr - 1]->set_attribute(
"Coords", $a_coords);
583 if (is_object($ma_nodes[$a_nr - 1]))
585 $ma_nodes[$a_nr - 1]->set_attribute(
"HighlightMode", $a_mode);
596 if (is_object($ma_nodes[$a_nr - 1]))
598 $ma_nodes[$a_nr - 1]->set_attribute(
"HighlightClass", $a_class);
608 $attributes = array(
"Shape" => $a_shape_type,
609 "Coords" => $a_coords,
"Id" => $a_id);
612 "MapArea", array(),
"", $attributes);
614 if ($a_link[
"LinkType"] ==
"int" || $a_link[
"LinkType"] ==
"IntLink")
616 $attributes = array(
"Type" => $a_link[
"Type"],
617 "TargetFrame" => $a_link[
"TargetFrame"],
618 "Target" => $a_link[
"Target"]);
620 array(
""), $a_title, $attributes);
622 if ($a_link[
"LinkType"] ==
"ext" || $a_link[
"LinkType"] ==
"ExtLink")
624 $attributes = array(
"Href" => $a_link[
"Href"]);
626 array(
""), $a_title, $attributes);
638 if (is_object($ma_nodes[$a_nr - 1]))
640 $ma_nodes[$a_nr - 1]->unlink_node($ma_nodes[$a_nr - 1]);
651 foreach ($ma_nodes as $node)
653 if ($node->get_attribute(
"Id") == $a_id)
655 $node->unlink_node($node);
666 $path =
"//PageContent[@HierId = '".$this->hier_id.
"']/".$this->parent_node_name.
"/MediaAliasItem[@Purpose='".$this->purpose.
"']/MapArea";
668 for ($i = 0; $i < count(
$res->nodeset); $i++)
670 $res->nodeset[$i]->unlink_node(
$res->nodeset[$i]);
681 if (is_object($ma_nodes[$a_nr - 1]))
683 $childs = $ma_nodes[$a_nr - 1]->child_nodes();
684 if ($childs[0]->node_name() ==
"IntLink")
688 if ($childs[0]->node_name() ==
"ExtLink")
702 if (is_object($ma_nodes[$a_nr - 1]))
704 $childs = $ma_nodes[$a_nr - 1]->child_nodes();
705 return $childs[0]->get_attribute(
"Type");
716 if (is_object($ma_nodes[$a_nr - 1]))
718 $childs = $ma_nodes[$a_nr - 1]->child_nodes();
719 return $childs[0]->get_attribute(
"Target");
730 if (is_object($ma_nodes[$a_nr - 1]))
732 $childs = $ma_nodes[$a_nr - 1]->child_nodes();
733 return $childs[0]->get_attribute(
"TargetFrame");
744 if (is_object($ma_nodes[$a_nr - 1]))
746 $childs = $ma_nodes[$a_nr - 1]->child_nodes();
747 return $childs[0]->get_attribute(
"Href");
758 if (is_object($ma_nodes[$a_nr - 1]))
760 $childs = $ma_nodes[$a_nr - 1]->child_nodes();
761 return $childs[0]->get_content();
770 if (is_object($this->item_node))
772 $this->item_node->unlink_node($this->item_node);
783 $a_output_new_area, $a_area_type, $a_coords)
787 if (!$a_st_item->copyOriginal())
791 $a_st_item->buildMapWorkImage();
798 if ($width == 0 && $height == 0)
800 $width = $a_st_item->getWidth();
801 $height = $a_st_item->getHeight();
803 $size = @getimagesize($a_st_item->getMapWorkCopyName());
805 if (
$size[0] > 0 && $width > 0)
807 $x_ratio = $width /
$size[0];
810 if (
$size[1] > 0 && $height > 0)
812 $y_ratio = $height /
$size[1];
817 for ($i=0; $i < count($areas); $i++)
819 if ( ((($i+1) == $a_area_nr) && !$a_exclude) ||
820 ((($i+1) != $a_area_nr) && $a_exclude) ||
825 $area->setShape($areas[$i][
"Shape"]);
826 $area->setCoords($areas[$i][
"Coords"]);
827 $area->draw($a_st_item->getMapWorkImage(), $a_st_item->color1, $a_st_item->color2,
true,
832 if ($a_output_new_area)
835 $area->setShape($a_area_type);
836 $area->setCoords($a_coords);
837 $area->draw($a_st_item->getMapWorkImage(), $a_st_item->color1, $a_st_item->color2,
false,
841 $a_st_item->saveMapWorkImage();