4 include_once(
"./Services/Utilities/classes/class.ilDOMUtil.php");
23 function __construct(&$a_dom, $a_hier_id, $a_purpose, $a_pc_id =
"",
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");
152 $item_node = $obj_node->append_child($item_node);
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");
373 for($i=0; $i < count($par_nodes); $i++)
375 $par_node = $par_nodes[$i];
376 $par_node->unlink_node($par_node);
379 include_once(
"./Services/MediaObjects/classes/class.ilMediaItem.php");
380 if (is_array($a_par_array))
382 foreach($a_par_array as $par => $val)
386 $attributes =
array(
"Name" => $par,
"Value" => $val);
388 "Parameter",
array(
"MapArea"),
"", $attributes);
402 for($i=0; $i < count($par_nodes); $i++)
404 $par_node = $par_nodes[$i];
405 $par_arr[] = $par_node->get_attribute(
"Name").
"=\"".$par_node->get_attribute(
"Value").
"\"";
407 return implode($par_arr,
", ");
418 for($i=0; $i < count($par_nodes); $i++)
420 $par_node = $par_nodes[$i];
421 $par_arr[$par_node->get_attribute(
"Name")] =
422 $par_node->get_attribute(
"Value");
443 if (count($par_nodes) > 0)
457 if (count($par_nodes) > 0)
459 for($i=0; $i < count($par_nodes); $i++)
461 $par_node = $par_nodes[$i];
462 $par_node->unlink_node($par_node);
475 $maparea_arr =
array();
476 for($i=0; $i < count($ma_nodes); $i++)
478 $maparea_node = $ma_nodes[$i];
479 $childs = $maparea_node->child_nodes();
481 if ($childs[0]->node_name() ==
"ExtLink")
483 $link =
array(
"LinkType" =>
"ExtLink",
484 "Href" => $childs[0]->get_attribute(
"Href"),
485 "Title" => $childs[0]->get_content());
487 if ($childs[0]->node_name() ==
"IntLink")
489 $link =
array(
"LinkType" =>
"IntLink",
490 "Target" => $childs[0]->get_attribute(
"Target"),
491 "Type" => $childs[0]->get_attribute(
"Type"),
492 "TargetFrame" => $childs[0]->get_attribute(
"TargetFame"),
493 "Title" => $childs[0]->get_content());
495 $maparea_arr[] =
array(
497 "Shape" => $maparea_node->get_attribute(
"Shape"),
498 "Coords" => $maparea_node->get_attribute(
"Coords"),
499 "HighlightMode" => $maparea_node->get_attribute(
"HighlightMode"),
500 "HighlightClass" => $maparea_node->get_attribute(
"HighlightClass"),
501 "Id" => $maparea_node->get_attribute(
"Id"),
515 if (is_object($ma_nodes[$a_nr - 1]))
517 $childs = $ma_nodes[$a_nr - 1]->child_nodes();
518 if (is_object($childs[0]) &&
519 ($childs[0]->node_name() ==
"IntLink" || $childs[0]->node_name() ==
"ExtLink"))
521 $childs[0]->set_content($a_title);
533 if (is_object($ma_nodes[$a_nr - 1]))
537 $attributes =
array(
"Type" =>
$a_type,
"Target" => $a_target,
538 "TargetFrame" => $a_target_frame);
551 if (is_object($ma_nodes[$a_nr - 1]))
555 $attributes =
array(
"Href" => $a_href);
568 if (is_object($ma_nodes[$a_nr - 1]))
570 $ma_nodes[$a_nr - 1]->set_attribute(
"Shape", $a_shape_type);
571 $ma_nodes[$a_nr - 1]->set_attribute(
"Coords", $a_coords);
582 if (is_object($ma_nodes[$a_nr - 1]))
584 $ma_nodes[$a_nr - 1]->set_attribute(
"HighlightMode", $a_mode);
595 if (is_object($ma_nodes[$a_nr - 1]))
597 $ma_nodes[$a_nr - 1]->set_attribute(
"HighlightClass", $a_class);
607 $attributes =
array(
"Shape" => $a_shape_type,
608 "Coords" => $a_coords,
"Id" => $a_id);
611 "MapArea",
array(),
"", $attributes);
613 if ($a_link[
"LinkType"] ==
"int" || $a_link[
"LinkType"] ==
"IntLink")
615 $attributes =
array(
"Type" => $a_link[
"Type"],
616 "TargetFrame" => $a_link[
"TargetFrame"],
617 "Target" => $a_link[
"Target"]);
619 array(
""), $a_title, $attributes);
621 if ($a_link[
"LinkType"] ==
"ext" || $a_link[
"LinkType"] ==
"ExtLink")
623 $attributes =
array(
"Href" => $a_link[
"Href"]);
625 array(
""), $a_title, $attributes);
637 if (is_object($ma_nodes[$a_nr - 1]))
639 $ma_nodes[$a_nr - 1]->unlink_node($ma_nodes[$a_nr - 1]);
650 foreach ($ma_nodes as $node)
652 if ($node->get_attribute(
"Id") == $a_id)
654 $node->unlink_node($node);
665 $path =
"//PageContent[@HierId = '".$this->hier_id.
"']/".$this->parent_node_name.
"/MediaAliasItem[@Purpose='".$this->purpose.
"']/MapArea";
667 for ($i = 0; $i < count(
$res->nodeset); $i++)
669 $res->nodeset[$i]->unlink_node(
$res->nodeset[$i]);
680 if (is_object($ma_nodes[$a_nr - 1]))
682 $childs = $ma_nodes[$a_nr - 1]->child_nodes();
683 if ($childs[0]->node_name() ==
"IntLink")
687 if ($childs[0]->node_name() ==
"ExtLink")
701 if (is_object($ma_nodes[$a_nr - 1]))
703 $childs = $ma_nodes[$a_nr - 1]->child_nodes();
704 return $childs[0]->get_attribute(
"Type");
715 if (is_object($ma_nodes[$a_nr - 1]))
717 $childs = $ma_nodes[$a_nr - 1]->child_nodes();
718 return $childs[0]->get_attribute(
"Target");
729 if (is_object($ma_nodes[$a_nr - 1]))
731 $childs = $ma_nodes[$a_nr - 1]->child_nodes();
732 return $childs[0]->get_attribute(
"TargetFrame");
743 if (is_object($ma_nodes[$a_nr - 1]))
745 $childs = $ma_nodes[$a_nr - 1]->child_nodes();
746 return $childs[0]->get_attribute(
"Href");
757 if (is_object($ma_nodes[$a_nr - 1]))
759 $childs = $ma_nodes[$a_nr - 1]->child_nodes();
760 return $childs[0]->get_content();
769 if (is_object($this->item_node))
771 $this->item_node->unlink_node($this->item_node);
782 $a_output_new_area, $a_area_type, $a_coords)
786 if (!$a_st_item->copyOriginal())
790 $a_st_item->buildMapWorkImage();
797 if ($width == 0 && $height == 0)
799 $width = $a_st_item->getWidth();
800 $height = $a_st_item->getHeight();
802 $size = @getimagesize($a_st_item->getMapWorkCopyName());
804 if (
$size[0] > 0 && $width > 0)
806 $x_ratio = $width /
$size[0];
809 if (
$size[1] > 0 && $height > 0)
811 $y_ratio = $height /
$size[1];
816 for ($i=0; $i < count($areas); $i++)
818 if ( ((($i+1) == $a_area_nr) && !$a_exclude) ||
819 ((($i+1) != $a_area_nr) && $a_exclude) ||
824 $area->setShape($areas[$i][
"Shape"]);
825 $area->setCoords($areas[$i][
"Coords"]);
826 $area->draw($a_st_item->getMapWorkImage(), $a_st_item->color1, $a_st_item->color2,
true,
831 if ($a_output_new_area)
834 $area->setShape($a_area_type);
835 $area->setCoords($a_coords);
836 $area->draw($a_st_item->getMapWorkImage(), $a_st_item->color1, $a_st_item->color2,
false,
840 $a_st_item->saveMapWorkImage();
xpath_new_context($dom_document)
xpath_eval($xpath_context, $eval_str, $contextnode=null)
static deleteAllChildsByName($a_parent, $a_node_names)
delete all childs of a node by names in $a_node_names
static addElementToList($doc, $parent_node, $a_node_name, $a_successors, $a_content, $a_attributes)
Places a new node $a_node_name directly before nodes with names of $a_successors. ...
static setFirstOptionalElement($doc, $parent_node, $a_node_name, $a_successors, $a_content, $a_attributes, $a_remove_childs=true)
searches for an element $a_node_name within the childs of $parent_node if no node is found...
Create styles array
The data for the language used.