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(
"Media");
44 $ret = $ilCtrl->forwardCommand($link_gui);
48 if (isset(
$_POST[
"editImagemapForward"]) ||
49 isset(
$_POST[
"editImagemapForward_x"]) ||
50 isset(
$_POST[
"editImagemapForward_y"]))
52 $cmd =
"editImagemapForward";
68 $_SESSION[
"il_map_edit_target_script"] = $ilCtrl->getLinkTarget($this,
"addArea",
72 $this->tpl =
new ilTemplate(
"tpl.map_edit.html",
true,
true,
"Services/MediaObjects");
73 $this->tpl->setVariable(
"FORMACTION", $ilCtrl->getFormAction($this));
75 $this->tpl->setVariable(
"TXT_IMAGEMAP", $lng->txt(
"cont_imagemap"));
81 $this->tpl->setVariable(
"IMAGE_MAP", $output);
85 return $this->tpl->get();
93 include_once(
"./Services/MediaObjects/classes/class.ilImageMapTableGUI.php");
95 return $image_map_table->getHTML();
103 if(
$_GET[
"ref_id"] !=
"")
108 if(
$_GET[
"obj_id"] !=
"")
113 if(
$_GET[
"hier_id"] !=
"")
118 if(
$_GET[
"pc_id"] !=
"")
130 $item->outputMapWorkCopy();
140 $st_item =& $this->media_object->getMediaItem(
"Standard");
142 for ($i=1; $i<=$max; $i++)
144 $area =&
new ilMapArea($st_item->getId(), $i);
150 $ilCtrl->redirect($this,
"editMapAreas");
159 $_SESSION[
"il_map_edit_area_type"] =
"WholePicture";
170 $_SESSION[
"il_map_edit_area_type"] =
"Rect";
180 $_SESSION[
"il_map_edit_area_type"] =
"Circle";
190 $_SESSION[
"il_map_edit_area_type"] =
"Poly";
222 $area_type =
$_SESSION[
"il_map_edit_area_type"];
223 $coords =
$_SESSION[
"il_map_edit_coords"];
224 include_once(
"./Services/MediaObjects/classes/class.ilMapArea.php");
237 else if ($cnt_coords == 2)
245 if ($cnt_coords <= 1)
251 if ($cnt_coords == 2)
253 $c = explode(
",",$coords);
254 $coords = $c[0].
",".$c[1].
",";
255 $coords .= round(sqrt(pow(abs($c[3]-$c[1]),2)+pow(abs($c[2]-$c[0]),2)));
257 $_SESSION[
"il_map_edit_coords"] = $coords;
269 else if ($cnt_coords < 3)
294 function editMapArea($a_get_next_coordinate =
false, $a_output_new_area =
false,
295 $a_save_form =
false, $a_edit_property =
"", $a_area_nr = 0)
299 $area_type =
$_SESSION[
"il_map_edit_area_type"];
300 $coords =
$_SESSION[
"il_map_edit_coords"];
301 include_once(
"./Services/MediaObjects/classes/class.ilMapArea.php");
304 $this->tpl =
new ilTemplate(
"tpl.map_edit.html",
true,
true,
"Services/MediaObjects");
306 $this->tpl->setVariable(
"FORMACTION", $ilCtrl->getFormAction($this));
308 $this->tpl->setVariable(
"TXT_IMAGEMAP", $lng->txt(
"cont_imagemap"));
310 $this->tpl->setCurrentBlock(
"instruction");
311 if ($a_edit_property !=
"link")
317 if ($cnt_coords == 0)
319 $this->tpl->setVariable(
"INSTRUCTION", $lng->txt(
"cont_click_tl_corner"));
321 if ($cnt_coords == 1)
323 $this->tpl->setVariable(
"INSTRUCTION", $lng->txt(
"cont_click_br_corner"));
329 if ($cnt_coords == 0)
331 $this->tpl->setVariable(
"INSTRUCTION", $lng->txt(
"cont_click_center"));
333 if ($cnt_coords == 1)
335 $this->tpl->setVariable(
"INSTRUCTION", $lng->txt(
"cont_click_circle"));
341 if ($cnt_coords == 0)
343 $this->tpl->setVariable(
"INSTRUCTION", $lng->txt(
"cont_click_starting_point"));
345 else if ($cnt_coords < 3)
347 $this->tpl->setVariable(
"INSTRUCTION", $lng->txt(
"cont_click_next_point"));
351 $this->tpl->setVariable(
"INSTRUCTION", $lng->txt(
"cont_click_next_or_save"));
356 $this->tpl->parseCurrentBlock();
364 if ($a_edit_property !=
"link" && $a_edit_property !=
"shape")
366 $this->tpl->setCurrentBlock(
"edit_name");
367 $this->tpl->setVariable(
"VAR_NAME2",
"area_name");
368 $this->tpl->setVariable(
"TXT_NAME2", $lng->txt(
"cont_name"));
369 $this->tpl->parseCurrentBlock();
372 if ($a_edit_property !=
"shape")
374 $this->tpl->setCurrentBlock(
"edit_link");
375 $this->tpl->setVariable(
"TXT_LINK_EXT", $lng->txt(
"cont_link_ext"));
376 $this->tpl->setVariable(
"TXT_LINK_INT", $lng->txt(
"cont_link_int"));
379 $this->tpl->setVariable(
"VAL_LINK_EXT",
$_SESSION[
"il_map_el_href"]);
383 $this->tpl->setVariable(
"VAL_LINK_EXT",
"http://");
385 $this->tpl->setVariable(
"VAR_LINK_EXT",
"area_link_ext");
386 $this->tpl->setVariable(
"VAR_LINK_TYPE",
"area_link_type");
387 if (
$_SESSION[
"il_map_il_ltype"] !=
"int")
389 $this->tpl->setVariable(
"EXT_CHECKED",
"checked=\"1\"");
393 $this->tpl->setVariable(
"INT_CHECKED",
"checked=\"1\"");
402 $this->tpl->setVariable(
"VAL_LINK_INT", $link_str);
406 $ilCtrl->setParameter($this,
"linkmode",
"map");
407 $this->tpl->setVariable(
"LINK_ILINK",
408 $ilCtrl->getLinkTargetByClass(
"ilInternalLinkGUI",
"showLinkHelp",
409 array(
"ilObjMediaObjectGUI"),
true));
410 $this->tpl->setVariable(
"TXT_ILINK",
"[".$lng->txt(
"cont_get_link").
"]");
412 $this->tpl->parseCurrentBlock();
415 $this->tpl->setCurrentBlock(
"new_area");
416 $this->tpl->setVariable(
"TXT_SAVE", $lng->txt(
"save"));
417 $this->tpl->setVariable(
"BTN_SAVE",
"saveArea");
418 if ($a_edit_property ==
"")
420 $this->tpl->setVariable(
"TXT_NEW_AREA", $lng->txt(
"cont_new_area"));
424 $this->tpl->setVariable(
"TXT_NEW_AREA", $lng->txt(
"cont_edit_area"));
426 $this->tpl->parseCurrentBlock();
430 $a_output_new_area, $area_type, $coords);
432 $edit_mode = ($a_get_next_coordinate)
436 $this->tpl->setVariable(
"IMAGE_MAP", $output);
438 return $this->tpl->get();
445 $a_output_new_area =
false, $a_area_type =
"", $a_coords =
"")
448 $st_item = $this->media_object->getMediaItem(
"Standard");
450 if ($a_edit_property ==
"shape")
452 $st_item->makeMapWorkCopy($a_area_nr,
true);
456 $st_item->makeMapWorkCopy($a_area_nr,
false);
459 if ($a_output_new_area)
461 $st_item->addAreaToMapWorkCopy($a_area_type, $a_coords);
472 $st_item = $this->media_object->getMediaItem(
"Standard");
479 $xsl = file_get_contents(
"./Services/COPage/xsl/page.xsl");
480 $args = array(
'/_xml' => $xml,
'/_xsl' => $xsl );
485 $params = array (
'map_edit_mode' => $a_map_edit_mode,
486 'map_item' => $st_item->getId(),
488 'image_map_link' => $ilCtrl->getLinkTarget($this,
"showImageMap",
"",
false,
false),
489 'link_params' =>
"ref_id=".$_GET[
"ref_id"].
"&rand=".rand(1,999999),
490 'ref_id' =>
$_GET[
"ref_id"],
492 'webspace_path' => $wb_path);
493 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl",NULL,$args, $params);
518 $t_arr = explode(
"_", $a_target);
521 $frame_str =
" (".$a_frame.
" Frame)";
525 case "StructureObject":
526 require_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
528 $link_str = $lng->txt(
"chapter").
529 ": ".$title.
" [".$t_arr[count($t_arr) - 1].
"]".$frame_str;
533 require_once(
"./Modules/LearningModule/classes/class.ilLMObject.php");
535 $link_str = $lng->txt(
"page").
536 ": ".$title.
" [".$t_arr[count($t_arr) - 1].
"]".$frame_str;
540 require_once(
"./Modules/Glossary/classes/class.ilGlossaryTerm.php");
542 $link_str = $lng->txt(
"term").
543 ": ".$term->getTerm().
" [".$t_arr[count($t_arr) - 1].
"]".$frame_str;
547 require_once(
"./Services/MediaObjects/classes/class.ilObjMediaObject.php");
549 $link_str = $lng->txt(
"mob").
550 ": ".$mob->getTitle().
" [".$t_arr[count($t_arr) - 1].
"]".$frame_str;
553 case "RepositoryItem":
556 $link_str = $lng->txt(
"obj_".$t_arr[count($t_arr) - 2]).
557 ": ".$title.
" [".$t_arr[count($t_arr) - 1].
"]".$frame_str;
571 if (
$_SESSION[
"il_map_edit_coords"] !=
"")
576 $_SESSION[
"il_map_edit_coords"] .=
$_POST[
"editImagemapForward_x"].
",".
577 $_POST[
"editImagemapForward_y"];
605 $st_item = $this->media_object->getMediaItem(
"Standard");
612 $area->setType(
$_SESSION[
"il_map_il_type"]);
613 $area->setTarget(
$_SESSION[
"il_map_il_target"]);
614 $area->setTargetFrame(
$_SESSION[
"il_map_il_targetframe"]);
626 $st_item = $this->media_object->getMediaItem(
"Standard");
631 $area->setCoords(
$_SESSION[
"il_map_edit_coords"]);
637 $area_type =
$_SESSION[
"il_map_edit_area_type"];
638 $coords =
$_SESSION[
"il_map_edit_coords"];
640 $st_item = $this->media_object->getMediaItem(
"Standard");
645 $area->setItemId($st_item->getId());
646 $area->setShape($area_type);
647 $area->setCoords($coords);
648 $area->setNr($max + 1);
650 switch(
$_POST[
"area_link_type"])
654 $area->setHref(
$_POST[
"area_link_ext"]);
659 $area->setType(
$_SESSION[
"il_map_il_type"]);
660 $area->setTarget(
$_SESSION[
"il_map_il_target"]);
661 $area->setTargetFrame(
$_SESSION[
"il_map_il_targetframe"]);
666 $st_item->addMapArea($area);
667 $this->media_object->update();
673 $ilCtrl->redirect($this,
"editMapAreas");
713 if (!isset(
$_POST[
"area"]))
716 $ilCtrl->redirect($this,
"editMapAreas");
719 if (count(
$_POST[
"area"]) > 1)
723 $ilCtrl->redirect($this,
"editMapAreas");
727 if (
$_SESSION[
"il_map_edit_mode"] !=
"edit_link")
731 $_SESSION[
"il_map_edit_mode"] =
"edit_link";
732 $_SESSION[
"il_map_edit_target_script"] = $ilCtrl->getLinkTarget($this,
"setLink");
753 $st_item = $this->media_object->getMediaItem(
"Standard");
754 $area = $st_item->getMapArea($a_nr);
755 return $area->getLinkType();
763 $st_item = $this->media_object->getMediaItem(
"Standard");
764 $area = $st_item->getMapArea($a_nr);
765 return $area->getType();
773 $st_item = $this->media_object->getMediaItem(
"Standard");
774 $area = $st_item->getMapArea($a_nr);
775 return $area->getTarget();
783 $st_item = $this->media_object->getMediaItem(
"Standard");
784 $area = $st_item->getMapArea($a_nr);
785 return $area->getTargetFrame();
793 $st_item = $this->media_object->getMediaItem(
"Standard");
794 $area = $st_item->getMapArea($a_nr);
795 return $area->getHref();
805 if (!isset(
$_POST[
"area"]))
808 $ilCtrl->redirect($this,
"editMapAreas");
811 $st_item = $this->media_object->getMediaItem(
"Standard");
814 if (count(
$_POST[
"area"]) > 0)
818 foreach (
$_POST[
"area"] as $area_nr)
820 $st_item->deleteMapArea($area_nr - $i);
824 $this->media_object->update();
828 $ilCtrl->redirect($this,
"editMapAreas");
853 $_SESSION[
"il_map_edit_area_type"] =
"WholePicture";
863 $_SESSION[
"il_map_edit_area_type"] =
"Rect";
873 $_SESSION[
"il_map_edit_area_type"] =
"Circle";
883 $_SESSION[
"il_map_edit_area_type"] =
"Poly";
898 if(
$_POST[
"areatype2"] !=
"")
906 if (!isset(
$_POST[
"area"]))
909 $ilCtrl->redirect($this,
"editMapAreas");
912 if (count(
$_POST[
"area"]) > 1)
915 $ilCtrl->redirect($this,
"editMapAreas");
918 if (
$_SESSION[
"il_map_edit_mode"] !=
"edit_shape")
921 $_SESSION[
"il_map_edit_mode"] =
"edit_shape";
922 $_SESSION[
"il_map_edit_target_script"] = $ilCtrl->getLinkTarget($this,
"setShape",
"",
false,
false);
926 $area_type =
$_SESSION[
"il_map_edit_area_type"];
927 $coords =
$_SESSION[
"il_map_edit_coords"];
939 else if ($cnt_coords == 2)
947 if ($cnt_coords <= 1)
953 if ($cnt_coords == 2)
955 $c = explode(
",",$coords);
956 $coords = $c[0].
",".$c[1].
",";
957 $coords .= round(sqrt(pow(abs($c[3]-$c[1]),2)+pow(abs($c[2]-$c[0]),2)));
959 $_SESSION[
"il_map_edit_coords"] = $coords;
971 else if ($cnt_coords < 3)