21 $this->media_object = $a_media_object;
31 $next_class = $ilCtrl->getNextClass($this);
32 $cmd = $ilCtrl->getCmd();
36 case "ilinternallinkgui":
37 require_once(
"./Modules/LearningModule/classes/class.ilInternalLinkGUI.php");
39 $link_gui->setMode(
"link");
40 $link_gui->setSetLinkTargetScript(
41 $ilCtrl->getLinkTarget($this,
43 $link_gui->filterLinkType(
"File");
44 $link_gui->setMode(
"asynch");
45 $ret = $ilCtrl->forwardCommand($link_gui);
49 require_once(
"./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
51 if (isset(
$_POST[
"editImagemapForward"]) ||
52 isset(
$_POST[
"editImagemapForward_x"]) ||
53 isset(
$_POST[
"editImagemapForward_y"]))
55 $cmd =
"editImagemapForward";
71 $_SESSION[
"il_map_edit_target_script"] = $ilCtrl->getLinkTarget($this,
"addArea",
75 $this->tpl =
new ilTemplate(
"tpl.map_edit.html",
true,
true,
"Services/MediaObjects");
76 $this->tpl->setVariable(
"FORMACTION", $ilCtrl->getFormAction($this));
82 $this->tpl->setVariable(
"IMAGE_MAP", $output);
84 $this->tpl->setVariable(
"TOOLBAR", $this->
getToolbar()->getHTML());
89 return $this->tpl->get();
103 $tb->setFormAction($ilCtrl->getFormAction($this));
104 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
106 "WholePicture" => $lng->txt(
"cont_WholePicture"),
107 "Rect" => $lng->txt(
"cont_Rect"),
108 "Circle" => $lng->txt(
"cont_Circle"),
109 "Poly" => $lng->txt(
"cont_Poly"),
113 $tb->addInputItem($si,
true);
114 $tb->addFormButton($lng->txt(
"cont_add_area"),
"addNewArea");
148 return $lng->txt(
"cont_imagemap");
157 include_once(
"./Services/MediaObjects/classes/class.ilImageMapTableGUI.php");
158 $image_map_table =
new ilImageMapTableGUI($this,
"editMapAreas", $this->media_object);
159 return $image_map_table->getHTML();
167 if(
$_GET[
"ref_id"] !=
"")
172 if(
$_GET[
"obj_id"] !=
"")
177 if(
$_GET[
"hier_id"] !=
"")
182 if(
$_GET[
"pc_id"] !=
"")
194 $item->outputMapWorkCopy();
204 $st_item =& $this->media_object->getMediaItem(
"Standard");
206 for ($i=1; $i<=$max; $i++)
208 $area =&
new ilMapArea($st_item->getId(), $i);
216 $ilCtrl->redirect($this,
"editMapAreas");
228 case "Circle":
return $this->
addCircle();
240 $_SESSION[
"il_map_edit_area_type"] =
"WholePicture";
251 $_SESSION[
"il_map_edit_area_type"] =
"Rect";
261 $_SESSION[
"il_map_edit_area_type"] =
"Circle";
271 $_SESSION[
"il_map_edit_area_type"] =
"Poly";
303 $area_type =
$_SESSION[
"il_map_edit_area_type"];
304 $coords =
$_SESSION[
"il_map_edit_coords"];
305 include_once(
"./Services/MediaObjects/classes/class.ilMapArea.php");
318 else if ($cnt_coords == 2)
326 if ($cnt_coords <= 1)
332 if ($cnt_coords == 2)
334 $c = explode(
",",$coords);
335 $coords = $c[0].
",".$c[1].
",";
336 $coords .= round(sqrt(pow(abs($c[3]-$c[1]),2)+pow(abs($c[2]-$c[0]),2)));
338 $_SESSION[
"il_map_edit_coords"] = $coords;
350 else if ($cnt_coords < 3)
375 function editMapArea($a_get_next_coordinate =
false, $a_output_new_area =
false,
376 $a_save_form =
false, $a_edit_property =
"", $a_area_nr = 0)
380 $area_type =
$_SESSION[
"il_map_edit_area_type"];
381 $coords =
$_SESSION[
"il_map_edit_coords"];
382 include_once(
"./Services/MediaObjects/classes/class.ilMapArea.php");
385 $this->tpl =
new ilTemplate(
"tpl.map_edit.html",
true,
true,
"Services/MediaObjects");
387 $this->tpl->setVariable(
"FORMACTION", $ilCtrl->getFormAction($this));
389 if ($a_edit_property !=
"link")
395 if ($cnt_coords == 0)
399 if ($cnt_coords == 1)
407 if ($cnt_coords == 0)
411 if ($cnt_coords == 1)
419 if ($cnt_coords == 0)
423 else if ($cnt_coords < 3)
439 if ($a_edit_property !=
"shape")
442 $ilCtrl->setParameter($this,
"linkmode",
"map");
443 include_once(
"./Modules/LearningModule/classes/class.ilInternalLinkGUI.php");
444 $this->tpl->setCurrentBlock(
"int_link_prep");
446 $ilCtrl->getLinkTargetByClass(
"ilinternallinkgui",
447 "",
false,
true,
false)));
448 $this->tpl->parseCurrentBlock();
451 $this->tpl->setVariable(
"FORM", $form->getHTML());
455 $a_output_new_area, $area_type, $coords);
457 $edit_mode = ($a_get_next_coordinate)
459 : (($a_output_new_area)
463 $this->tpl->setVariable(
"IMAGE_MAP", $output);
465 return $this->tpl->get();
477 include_once(
"Services/Form/classes/class.ilPropertyFormGUI.php");
479 $form->setOpenTag(
false);
480 $form->setCloseTag(
false);
483 if ($a_edit_property !=
"shape")
487 if (
$_SESSION[
"il_map_il_ltype"] !=
"int")
495 $radg->setValue(
"ext");
500 $radg->setValue(
"int");
505 $radg->addOption($ext);
508 $ti->setMaxLength(200);
512 $ti->setValue(
$_SESSION[
"il_map_el_href"]);
516 $ti->setValue(
"http://");
518 $ext->addSubItem($ti);
522 $radg->addOption($int);
531 $ne->setValue($link_str.
532 ' <a id="iosEditInternalLinkTrigger" href="#">'.
533 "[".$lng->txt(
"cont_get_link").
"]".
536 $int->addSubItem($ne);
540 $radg->addOption($no);
542 $form->addItem($radg);
547 if ($a_edit_property !=
"link" && $a_edit_property !=
"shape")
556 if ($a_edit_property ==
"")
558 $form->setTitle($lng->txt(
"cont_new_area"));
559 $form->addCommandButton(
"saveArea", $lng->txt(
"save"));
563 $form->setTitle($lng->txt(
"cont_new_area"));
564 $form->addCommandButton(
"saveArea", $lng->txt(
"save"));
576 $a_output_new_area =
false, $a_area_type =
"", $a_coords =
"")
579 $st_item = $this->media_object->getMediaItem(
"Standard");
581 if ($a_edit_property ==
"shape")
583 $st_item->makeMapWorkCopy($a_area_nr,
true);
587 $st_item->makeMapWorkCopy($a_area_nr,
false);
590 if ($a_output_new_area)
592 $st_item->addAreaToMapWorkCopy($a_area_type, $a_coords);
603 $st_item = $this->media_object->getMediaItem(
"Standard");
611 $xsl = file_get_contents(
"./Services/COPage/xsl/page.xsl");
613 $args = array(
'/_xml' => $xml,
'/_xsl' => $xsl );
618 $params = array (
'map_edit_mode' => $a_map_edit_mode,
619 'map_item' => $st_item->getId(),
620 'map_mob_id' => $this->media_object->getId(),
622 'media_mode' =>
'enable',
623 'image_map_link' => $ilCtrl->getLinkTarget($this,
"showImageMap",
"",
false,
false),
624 'link_params' =>
"ref_id=".$_GET[
"ref_id"].
"&rand=".rand(1,999999),
625 'ref_id' =>
$_GET[
"ref_id"],
627 'webspace_path' => $wb_path);
628 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args, $params);
676 $t_arr = explode(
"_", $a_target);
679 $frame_str =
" (".$a_frame.
" Frame)";
683 case "StructureObject":
684 require_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
686 $link_str = $lng->txt(
"chapter").
687 ": ".$title.
" [".$t_arr[count($t_arr) - 1].
"]".$frame_str;
691 require_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
693 $link_str = $lng->txt(
"page").
694 ": ".$title.
" [".$t_arr[count($t_arr) - 1].
"]".$frame_str;
698 require_once(
"./Modules/Glossary/classes/class.ilGlossaryTerm.php");
700 $link_str = $lng->txt(
"term").
701 ": ".$term->getTerm().
" [".$t_arr[count($t_arr) - 1].
"]".$frame_str;
705 require_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
707 $link_str = $lng->txt(
"mob").
708 ": ".$mob->getTitle().
" [".$t_arr[count($t_arr) - 1].
"]".$frame_str;
711 case "RepositoryItem":
714 $link_str = $lng->txt(
"obj_".$t_arr[count($t_arr) - 2]).
715 ": ".$title.
" [".$t_arr[count($t_arr) - 1].
"]".$frame_str;
729 if (
$_SESSION[
"il_map_edit_coords"] !=
"")
734 $_SESSION[
"il_map_edit_coords"] .=
$_POST[
"editImagemapForward_x"].
",".
735 $_POST[
"editImagemapForward_y"];
763 $st_item = $this->media_object->getMediaItem(
"Standard");
770 $area->setType(
$_SESSION[
"il_map_il_type"]);
771 $area->setTarget(
$_SESSION[
"il_map_il_target"]);
772 $area->setTargetFrame(
$_SESSION[
"il_map_il_targetframe"]);
791 $st_item = $this->media_object->getMediaItem(
"Standard");
796 $area->setCoords(
$_SESSION[
"il_map_edit_coords"]);
802 $area_type =
$_SESSION[
"il_map_edit_area_type"];
803 $coords =
$_SESSION[
"il_map_edit_coords"];
805 $st_item = $this->media_object->getMediaItem(
"Standard");
810 $area->setItemId($st_item->getId());
811 $area->setShape($area_type);
812 $area->setCoords($coords);
813 $area->setNr($max + 1);
815 switch(
$_POST[
"area_link_type"])
819 $area->setHref(
$_POST[
"area_link_ext"]);
824 $area->setType(
$_SESSION[
"il_map_il_type"]);
825 $area->setTarget(
$_SESSION[
"il_map_il_target"]);
826 $area->setTargetFrame(
$_SESSION[
"il_map_il_targetframe"]);
831 $st_item->addMapArea($area);
832 $this->media_object->update();
838 $ilCtrl->redirect($this,
"editMapAreas");
878 if (!isset(
$_POST[
"area"]))
881 $ilCtrl->redirect($this,
"editMapAreas");
884 if (count(
$_POST[
"area"]) > 1)
888 $ilCtrl->redirect($this,
"editMapAreas");
892 if (
$_SESSION[
"il_map_edit_mode"] !=
"edit_link")
896 $_SESSION[
"il_map_edit_mode"] =
"edit_link";
897 $_SESSION[
"il_map_edit_target_script"] = $ilCtrl->getLinkTarget($this,
"setLink");
918 $st_item = $this->media_object->getMediaItem(
"Standard");
919 $area = $st_item->getMapArea($a_nr);
920 return $area->getLinkType();
928 $st_item = $this->media_object->getMediaItem(
"Standard");
929 $area = $st_item->getMapArea($a_nr);
930 return $area->getType();
938 $st_item = $this->media_object->getMediaItem(
"Standard");
939 $area = $st_item->getMapArea($a_nr);
940 return $area->getTarget();
948 $st_item = $this->media_object->getMediaItem(
"Standard");
949 $area = $st_item->getMapArea($a_nr);
950 return $area->getTargetFrame();
958 $st_item = $this->media_object->getMediaItem(
"Standard");
959 $area = $st_item->getMapArea($a_nr);
960 return $area->getHref();
970 if (!isset(
$_POST[
"area"]))
973 $ilCtrl->redirect($this,
"editMapAreas");
976 $st_item = $this->media_object->getMediaItem(
"Standard");
979 if (count(
$_POST[
"area"]) > 0)
983 foreach (
$_POST[
"area"] as $area_nr)
985 $st_item->deleteMapArea($area_nr - $i);
989 $this->media_object->update();
993 $ilCtrl->redirect($this,
"editMapAreas");
1007 $_SESSION[
"il_map_il_targetframe"] =
"";
1018 $_SESSION[
"il_map_edit_area_type"] =
"WholePicture";
1028 $_SESSION[
"il_map_edit_area_type"] =
"Rect";
1038 $_SESSION[
"il_map_edit_area_type"] =
"Circle";
1048 $_SESSION[
"il_map_edit_area_type"] =
"Poly";
1063 if(
$_POST[
"areatype2"] !=
"")
1071 if (!isset(
$_POST[
"area"]))
1074 $ilCtrl->redirect($this,
"editMapAreas");
1077 if (count(
$_POST[
"area"]) > 1)
1080 $ilCtrl->redirect($this,
"editMapAreas");
1083 if (
$_SESSION[
"il_map_edit_mode"] !=
"edit_shape")
1086 $_SESSION[
"il_map_edit_mode"] =
"edit_shape";
1087 $_SESSION[
"il_map_edit_target_script"] = $ilCtrl->getLinkTarget($this,
"setShape",
"",
false,
false);
1091 $area_type =
$_SESSION[
"il_map_edit_area_type"];
1092 $coords =
$_SESSION[
"il_map_edit_coords"];
1100 if ($cnt_coords < 2)
1104 else if ($cnt_coords == 2)
1112 if ($cnt_coords <= 1)
1118 if ($cnt_coords == 2)
1120 $c = explode(
",",$coords);
1121 $coords = $c[0].
",".$c[1].
",";
1122 $coords .= round(sqrt(pow(abs($c[3]-$c[1]),2)+pow(abs($c[2]-$c[0]),2)));
1124 $_SESSION[
"il_map_edit_coords"] = $coords;
1132 if ($cnt_coords < 1)
1136 else if ($cnt_coords < 3)
1147 case "WholePicture":
1163 $st_item = $this->media_object->getMediaItem(
"Standard");
1169 $ilCtrl->redirect($this,
"editMapAreas");