ILIAS  release_7 Revision v7.30-3-g800a261c036
ilImageMapEditorGUI Class Reference

User interface class for map editor. More...

+ Inheritance diagram for ilImageMapEditorGUI:
+ Collaboration diagram for ilImageMapEditorGUI:

Public Member Functions

 __construct ($a_media_object)
 Constructor. More...
 
 executeCommand ()
 Execute current command. More...
 
 editMapAreas ()
 Show map areas. More...
 
 getToolbar ()
 Get toolbar. More...
 
 getEditorTitle ()
 Get editor title. More...
 
 getImageMapTableHTML ()
 Get table HTML. More...
 
 handleMapParameters ()
 handle parameter during map area editing (storing to session) More...
 
 showImageMap ()
 show image map More...
 
 updateAreas ()
 Update map areas. More...
 
 addNewArea ()
 Add area. More...
 
 linkWholePicture ()
 Link the whole picture. More...
 
 addRectangle ()
 Add a new rectangle. More...
 
 addCircle ()
 Add a new circle. More...
 
 addPolygon ()
 Add a new polygon. More...
 
 clearSessionVars ()
 Clear Session Vars. More...
 
 addArea ($a_handle=true)
 Handle adding new area process. More...
 
 editMapArea ( $a_get_next_coordinate=false, $a_output_new_area=false, $a_save_form=false, $a_edit_property="", $a_area_nr=0)
 Edit a single map area. More...
 
 initAreaEditingForm ($a_edit_property)
 Init area editing form. More...
 
 makeMapWorkCopy ( $a_edit_property="", $a_area_nr=0, $a_output_new_area=false, $a_area_type="", $a_coords="")
 Make work file for editing. More...
 
 getImageMapOutput ($a_map_edit_mode="")
 Render the image map. More...
 
 getAdditionalPageXML ()
 Get additional page xml (to be overwritten) More...
 
 outputPostProcessing ($a_output)
 Output post processing. More...
 
 getAliasXML ()
 
 getMapAreaLinkString ($a_target, $a_type, $a_frame)
 Get text name of internal link. More...
 
 editImagemapForward ()
 Get image map coordinates. More...
 
 saveArea ()
 Save new or updated map area. More...
 
 setInternalLink ()
 Set internal link. More...
 
 setLink ($a_handle=true)
 Set link. More...
 
 getLinkTypeOfArea ($a_nr)
 Get Link Type of Area. More...
 
 getTypeOfArea ($a_nr)
 Get Type of Area (only internal link) More...
 
 getTargetOfArea ($a_nr)
 Get Target of Area (only internal link) More...
 
 getTargetFrameOfArea ($a_nr)
 Get TargetFrame of Area (only internal link) More...
 
 getHrefOfArea ($a_nr)
 Get Href of Area (only external link) More...
 
 deleteAreas ()
 Delete map areas. More...
 
 editLink ()
 Edit existing link. More...
 
 editShapeWholePicture ()
 Edit an existing shape (make it a whole picture link) More...
 
 editShapeRectangle ()
 Edit an existing shape (make it a rectangle) More...
 
 editShapeCircle ()
 Edit an existing shape (make it a circle) More...
 
 editShapePolygon ()
 Edit an existing shape (make it a polygon) More...
 
 setShape ($a_handle=true)
 edit shape of existing map area More...
 
 setHighlight ()
 Set highlight settings. More...
 

Static Public Member Functions

static _recoverParameters ()
 Recover parameters from session variables (static) More...
 

Protected Attributes

 $ctrl
 
 $tpl
 
 $lng
 
 $toolbar
 

Detailed Description

User interface class for map editor.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

@ilCtrl_Calls ilImageMapEditorGUI: ilInternalLinkGUI

Definition at line 14 of file class.ilImageMapEditorGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilImageMapEditorGUI::__construct (   $a_media_object)

Constructor.

Definition at line 39 of file class.ilImageMapEditorGUI.php.

40 {
41 global $DIC;
42
43 $this->ctrl = $DIC->ctrl();
44 $this->tpl = $DIC["tpl"];
45 $this->lng = $DIC->language();
46 $this->toolbar = $DIC->toolbar();
47 $this->media_object = $a_media_object;
48 }
global $DIC
Definition: goto.php:24

References $DIC.

Member Function Documentation

◆ _recoverParameters()

static ilImageMapEditorGUI::_recoverParameters ( )
static

Recover parameters from session variables (static)

Definition at line 754 of file class.ilImageMapEditorGUI.php.

755 {
756 $_GET["ref_id"] = $_SESSION["il_map_edit_ref_id"];
757 $_GET["obj_id"] = $_SESSION["il_map_edit_obj_id"];
758 $_GET["hier_id"] = $_SESSION["il_map_edit_hier_id"];
759 $_GET["pc_id"] = $_SESSION["il_map_edit_pc_id"];
760 }
$_GET["client_id"]
$_SESSION["AccountId"]

References $_GET, and $_SESSION.

Referenced by editImagemapForward(), and ilInternalLinkGUI\renderLink().

+ Here is the caller graph for this function:

◆ addArea()

ilImageMapEditorGUI::addArea (   $a_handle = true)

Handle adding new area process.

Definition at line 324 of file class.ilImageMapEditorGUI.php.

325 {
326
327 // handle map parameters
328 if ($a_handle) {
329 $this->handleMapParameters();
330 }
331
332 $area_type = $_SESSION["il_map_edit_area_type"];
333 $coords = $_SESSION["il_map_edit_coords"];
334 include_once("./Services/MediaObjects/classes/class.ilMapArea.php");
335 $cnt_coords = ilMapArea::countCoords($coords);
336
337 // decide what to do next
338 switch ($area_type) {
339 // Rectangle
340 case "Rect":
341 if ($cnt_coords < 2) {
342 $html = $this->editMapArea(true, false, false);
343 return $html;
344 } elseif ($cnt_coords == 2) {
345 return $this->editMapArea(false, true, true);
346 }
347 break;
348
349 // Circle
350 case "Circle":
351 if ($cnt_coords <= 1) {
352 return $this->editMapArea(true, false, false);
353 } else {
354 if ($cnt_coords == 2) {
355 $c = explode(",", $coords);
356 $coords = $c[0] . "," . $c[1] . ","; // determine radius
357 $coords .= round(sqrt(pow(abs($c[3] - $c[1]), 2) + pow(abs($c[2] - $c[0]), 2)));
358 }
359 $_SESSION["il_map_edit_coords"] = $coords;
360
361 return $this->editMapArea(false, true, true);
362 }
363 break;
364
365 // Polygon
366 case "Poly":
367 if ($cnt_coords < 1) {
368 return $this->editMapArea(true, false, false);
369 } elseif ($cnt_coords < 3) {
370 return $this->editMapArea(true, true, false);
371 } else {
372 return $this->editMapArea(true, true, true);
373 }
374 break;
375
376 // Whole picture
377 case "WholePicture":
378 return $this->editMapArea(false, false, true);
379 break;
380 }
381 }
editMapArea( $a_get_next_coordinate=false, $a_output_new_area=false, $a_save_form=false, $a_edit_property="", $a_area_nr=0)
Edit a single map area.
handleMapParameters()
handle parameter during map area editing (storing to session)
static countCoords($c)
count the number of coordinates (x,y) in a coordinate string (format: "x1,y1,x2,y2,...
$c
Definition: cli.php:37

References $_SESSION, $c, ilMapArea\countCoords(), editMapArea(), and handleMapParameters().

Referenced by addCircle(), addPolygon(), addRectangle(), and setInternalLink().

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

◆ addCircle()

ilImageMapEditorGUI::addCircle ( )

Add a new circle.

Definition at line 288 of file class.ilImageMapEditorGUI.php.

289 {
290 $this->clearSessionVars();
291 $_SESSION["il_map_edit_area_type"] = "Circle";
292 return $this->addArea(false);
293 }
clearSessionVars()
Clear Session Vars.
addArea($a_handle=true)
Handle adding new area process.

References $_SESSION, addArea(), and clearSessionVars().

Referenced by addNewArea().

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

◆ addNewArea()

ilImageMapEditorGUI::addNewArea ( )

Add area.

Reimplemented in ilPCIIMTriggerEditorGUI.

Definition at line 253 of file class.ilImageMapEditorGUI.php.

254 {
255 switch ($_POST["shape"]) {
256 case "WholePicture": return $this->linkWholePicture();
257 case "Rect": return $this->addRectangle();
258 case "Circle": return $this->addCircle();
259 case "Poly": return $this->addPolygon();
260 }
261 }
$_POST["username"]
linkWholePicture()
Link the whole picture.
addPolygon()
Add a new polygon.
addRectangle()
Add a new rectangle.

References $_POST, addCircle(), addPolygon(), addRectangle(), and linkWholePicture().

+ Here is the call graph for this function:

◆ addPolygon()

ilImageMapEditorGUI::addPolygon ( )

Add a new polygon.

Definition at line 298 of file class.ilImageMapEditorGUI.php.

299 {
300 $this->clearSessionVars();
301 $_SESSION["il_map_edit_area_type"] = "Poly";
302 return $this->addArea(false);
303 }

References $_SESSION, addArea(), and clearSessionVars().

Referenced by addNewArea().

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

◆ addRectangle()

ilImageMapEditorGUI::addRectangle ( )

Add a new rectangle.

Definition at line 278 of file class.ilImageMapEditorGUI.php.

279 {
280 $this->clearSessionVars();
281 $_SESSION["il_map_edit_area_type"] = "Rect";
282 return $this->addArea(false);
283 }

References $_SESSION, addArea(), and clearSessionVars().

Referenced by addNewArea().

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

◆ clearSessionVars()

ilImageMapEditorGUI::clearSessionVars ( )

Clear Session Vars.

Definition at line 308 of file class.ilImageMapEditorGUI.php.

309 {
310 $_SESSION["il_map_area_nr"] = "";
311 $_SESSION["il_map_edit_coords"] = "";
312 $_SESSION["il_map_edit_mode"] = "";
313 $_SESSION["il_map_el_href"] = "";
314 $_SESSION["il_map_il_type"] = "";
315 $_SESSION["il_map_il_ltype"] = "";
316 $_SESSION["il_map_il_target"] = "";
317 $_SESSION["il_map_il_targetframe"] = "";
318 $_SESSION["il_map_edit_area_type"] = "";
319 }

References $_SESSION.

Referenced by addCircle(), addPolygon(), addRectangle(), editShapeCircle(), editShapePolygon(), editShapeRectangle(), editShapeWholePicture(), and linkWholePicture().

+ Here is the caller graph for this function:

◆ deleteAreas()

ilImageMapEditorGUI::deleteAreas ( )

Delete map areas.

Reimplemented in ilPCImageMapEditorGUI.

Definition at line 962 of file class.ilImageMapEditorGUI.php.

963 {
964 $ilCtrl = $this->ctrl;
966
967 if (!isset($_POST["area"])) {
968 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
969 $ilCtrl->redirect($this, "editMapAreas");
970 }
971
972 $st_item = $this->media_object->getMediaItem("Standard");
973 $max = ilMapArea::_getMaxNr($st_item->getId());
974
975 if (count($_POST["area"]) > 0) {
976 $i = 0;
977
978 foreach ($_POST["area"] as $area_nr) {
979 $st_item->deleteMapArea($area_nr - $i);
980 $i++;
981 }
982
983 $this->media_object->update();
984 ilUtil::sendSuccess($lng->txt("cont_areas_deleted"), true);
985 }
986
987 $ilCtrl->redirect($this, "editMapAreas");
988 }
static _getMaxNr($a_item_id)
get maximum nr of media item (static)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$i
Definition: metadata.php:24

References $_POST, $ctrl, $i, $lng, ilMapArea\_getMaxNr(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ editImagemapForward()

ilImageMapEditorGUI::editImagemapForward ( )

Get image map coordinates.

Definition at line 736 of file class.ilImageMapEditorGUI.php.

737 {
739
740 if ($_SESSION["il_map_edit_coords"] != "") {
741 $_SESSION["il_map_edit_coords"] .= ",";
742 }
743
744 $_SESSION["il_map_edit_coords"] .= $_POST["editImagemapForward_x"] . "," .
745 $_POST["editImagemapForward_y"];
746
747 // call editing script
748 ilUtil::redirect($_SESSION["il_map_edit_target_script"]);
749 }
static _recoverParameters()
Recover parameters from session variables (static)
static redirect($a_script)

References $_POST, $_SESSION, _recoverParameters(), and ilUtil\redirect().

+ Here is the call graph for this function:

◆ editLink()

ilImageMapEditorGUI::editLink ( )

Edit existing link.

Definition at line 993 of file class.ilImageMapEditorGUI.php.

994 {
995 $_SESSION["il_map_edit_coords"] = "";
996 $_SESSION["il_map_edit_mode"] = "";
997 $_SESSION["il_map_el_href"] = "";
998 $_SESSION["il_map_il_type"] = "";
999 $_SESSION["il_map_il_ltype"] = "";
1000 $_SESSION["il_map_il_target"] = "";
1001 $_SESSION["il_map_il_targetframe"] = "";
1002 $_SESSION["il_map_area_nr"] = "";
1003 return $this->setLink(false);
1004 }
setLink($a_handle=true)
Set link.

References $_SESSION, and setLink().

+ Here is the call graph for this function:

◆ editMapArea()

ilImageMapEditorGUI::editMapArea (   $a_get_next_coordinate = false,
  $a_output_new_area = false,
  $a_save_form = false,
  $a_edit_property = "",
  $a_area_nr = 0 
)

Edit a single map area.

Parameters
boolean$a_get_next_coordinateenable next coordinate input
boolean$a_output_new_areaoutput the new area
boolean$a_save_fromoutput save form
string$a_edit_property"" | "link" | "shape"

Definition at line 391 of file class.ilImageMapEditorGUI.php.

397 {
398 $ilCtrl = $this->ctrl;
401
402 $area_type = $_SESSION["il_map_edit_area_type"];
403 $coords = $_SESSION["il_map_edit_coords"];
404 include_once("./Services/MediaObjects/classes/class.ilMapArea.php");
405 $cnt_coords = ilMapArea::countCoords($coords);
406
407 $this->tpl = new ilTemplate("tpl.map_edit.html", true, true, "Services/MediaObjects");
408
409 $this->tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this));
410
411 if ($a_edit_property != "link") {
412 switch ($area_type) {
413 // rectangle
414 case "Rect":
415 if ($cnt_coords == 0) {
416 ilUtil::sendInfo($lng->txt("cont_click_tl_corner"));
417 }
418 if ($cnt_coords == 1) {
419 ilUtil::sendInfo($lng->txt("cont_click_br_corner"));
420 }
421 break;
422
423 // circle
424 case "Circle":
425 if ($cnt_coords == 0) {
426 ilUtil::sendInfo($lng->txt("cont_click_center"));
427 }
428 if ($cnt_coords == 1) {
429 ilUtil::sendInfo($lng->txt("cont_click_circle"));
430 }
431 break;
432
433 // polygon
434 case "Poly":
435 if ($cnt_coords == 0) {
436 ilUtil::sendInfo($lng->txt("cont_click_starting_point"));
437 } elseif ($cnt_coords < 3) {
438 ilUtil::sendInfo($lng->txt("cont_click_next_point"));
439 } else {
440 ilUtil::sendInfo($lng->txt("cont_click_next_or_save"));
441 }
442 break;
443 }
444 }
445
446
447 // map properties input fields (name and link)
448 if ($a_save_form) {
449 if ($a_edit_property != "shape") {
450 // prepare link gui
451 $ilCtrl->setParameter($this, "linkmode", "map");
452 include_once("./Services/Link/classes/class.ilInternalLinkGUI.php");
453 $this->tpl->setCurrentBlock("int_link_prep");
454 $this->tpl->setVariable("INT_LINK_PREP", ilInternalLinkGUI::getInitHTML(
455 $ilCtrl->getLinkTargetByClass(
456 "ilinternallinkgui",
457 "",
458 false,
459 true,
460 false
461 )
462 ));
463 $this->tpl->parseCurrentBlock();
464 }
465 $form = $this->initAreaEditingForm($a_edit_property);
466 $this->tpl->setVariable("FORM", $form->getHTML());
467 }
468
469 $this->makeMapWorkCopy(
470 $a_edit_property,
471 $a_area_nr,
472 $a_output_new_area,
473 $area_type,
474 $coords
475 );
476
477 $edit_mode = ($a_get_next_coordinate)
478 ? "get_coords"
479 : (($a_output_new_area)
480 ? "new_area"
481 :"");
482 $output = $this->getImageMapOutput($edit_mode);
483 $this->tpl->setVariable("IMAGE_MAP", $output);
484
485 return $this->tpl->get();
486 }
makeMapWorkCopy( $a_edit_property="", $a_area_nr=0, $a_output_new_area=false, $a_area_type="", $a_coords="")
Make work file for editing.
getImageMapOutput($a_map_edit_mode="")
Render the image map.
initAreaEditingForm($a_edit_property)
Init area editing form.
static getInitHTML($a_url)
Get initialisation HTML to use interna link editing.
special template class to simplify handling of ITX/PEAR
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References $_SESSION, $ctrl, $lng, $tpl, ilMapArea\countCoords(), getImageMapOutput(), ilInternalLinkGUI\getInitHTML(), initAreaEditingForm(), makeMapWorkCopy(), and ilUtil\sendInfo().

Referenced by addArea(), linkWholePicture(), setLink(), and setShape().

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

◆ editMapAreas()

ilImageMapEditorGUI::editMapAreas ( )

Show map areas.

Definition at line 93 of file class.ilImageMapEditorGUI.php.

94 {
95 $ilCtrl = $this->ctrl;
97 $ilToolbar = $this->toolbar;
98
99 $_SESSION["il_map_edit_target_script"] = $ilCtrl->getLinkTarget(
100 $this,
101 "addArea",
102 "",
103 false,
104 false
105 );
106 $this->handleMapParameters();
107
108 $this->tpl = new ilTemplate("tpl.map_edit.html", true, true, "Services/MediaObjects");
109 $this->tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this));
110
111 // create/update imagemap work copy
112 $this->makeMapWorkCopy();
113
114 $output = $this->getImageMapOutput();
115 $this->tpl->setVariable("IMAGE_MAP", $output);
116
117 $this->tpl->setVariable("TOOLBAR", $this->getToolbar()->getHTML());
118
119 // table
120 $this->tpl->setVariable("MAP_AREA_TABLE", $this->getImageMapTableHTML());
121
122 return $this->tpl->get();
123 }
getImageMapTableHTML()
Get table HTML.

References $_SESSION, $ctrl, $lng, $toolbar, getImageMapOutput(), getImageMapTableHTML(), getToolbar(), handleMapParameters(), and makeMapWorkCopy().

+ Here is the call graph for this function:

◆ editShapeCircle()

ilImageMapEditorGUI::editShapeCircle ( )

Edit an existing shape (make it a circle)

Definition at line 1029 of file class.ilImageMapEditorGUI.php.

1030 {
1031 $this->clearSessionVars();
1032 $_SESSION["il_map_edit_area_type"] = "Circle";
1033 return $this->setShape(false);
1034 }
setShape($a_handle=true)
edit shape of existing map area

References $_SESSION, clearSessionVars(), and setShape().

+ Here is the call graph for this function:

◆ editShapePolygon()

ilImageMapEditorGUI::editShapePolygon ( )

Edit an existing shape (make it a polygon)

Definition at line 1039 of file class.ilImageMapEditorGUI.php.

1040 {
1041 $this->clearSessionVars();
1042 $_SESSION["il_map_edit_area_type"] = "Poly";
1043 return $this->setShape(false);
1044 }

References $_SESSION, clearSessionVars(), and setShape().

+ Here is the call graph for this function:

◆ editShapeRectangle()

ilImageMapEditorGUI::editShapeRectangle ( )

Edit an existing shape (make it a rectangle)

Definition at line 1019 of file class.ilImageMapEditorGUI.php.

1020 {
1021 $this->clearSessionVars();
1022 $_SESSION["il_map_edit_area_type"] = "Rect";
1023 return $this->setShape(false);
1024 }

References $_SESSION, clearSessionVars(), and setShape().

+ Here is the call graph for this function:

◆ editShapeWholePicture()

ilImageMapEditorGUI::editShapeWholePicture ( )

Edit an existing shape (make it a whole picture link)

Definition at line 1009 of file class.ilImageMapEditorGUI.php.

1010 {
1011 $this->clearSessionVars();
1012 $_SESSION["il_map_edit_area_type"] = "WholePicture";
1013 return $this->setShape(false);
1014 }

References $_SESSION, clearSessionVars(), and setShape().

+ Here is the call graph for this function:

◆ executeCommand()

ilImageMapEditorGUI::executeCommand ( )

Execute current command.

Definition at line 53 of file class.ilImageMapEditorGUI.php.

54 {
55 $ilCtrl = $this->ctrl;
57
58 $next_class = $ilCtrl->getNextClass($this);
59 $cmd = $ilCtrl->getCmd();
60
61 switch ($next_class) {
62 case "ilinternallinkgui":
63 require_once("./Services/Link/classes/class.ilInternalLinkGUI.php");
64 $link_gui = new ilInternalLinkGUI("Media_Media", 0);
65 $link_gui->setSetLinkTargetScript(
66 $ilCtrl->getLinkTarget(
67 $this,
68 "setInternalLink"
69 )
70 );
71 $link_gui->filterLinkType("File");
72 $ret = $ilCtrl->forwardCommand($link_gui);
73 break;
74
75 default:
76 require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
78 if (isset($_POST["editImagemapForward"]) ||
79 isset($_POST["editImagemapForward_x"]) ||
80 isset($_POST["editImagemapForward_y"])) {
81 $cmd = "editImagemapForward";
82 }
83 $ret = $this->$cmd();
84 break;
85 }
86
87 return $ret;
88 }
Class ilInternalLinkGUI.
static includePresentationJS($a_tpl=null)
Include media object presentation JS.
$ret
Definition: parser.php:6

References $_POST, $ctrl, $ret, $tpl, and ilObjMediaObjectGUI\includePresentationJS().

+ Here is the call graph for this function:

◆ getAdditionalPageXML()

ilImageMapEditorGUI::getAdditionalPageXML ( )

Get additional page xml (to be overwritten)

Returns
string additional page xml

Reimplemented in ilPCIIMTriggerEditorGUI.

Definition at line 655 of file class.ilImageMapEditorGUI.php.

656 {
657 return "";
658 }

Referenced by getImageMapOutput().

+ Here is the caller graph for this function:

◆ getAliasXML()

ilImageMapEditorGUI::getAliasXML ( )

Reimplemented in ilPCImageMapEditorGUI.

Definition at line 671 of file class.ilImageMapEditorGUI.php.

672 {
673 return $this->media_object->getXML(IL_MODE_ALIAS);
674 }
const IL_MODE_ALIAS

References IL_MODE_ALIAS.

Referenced by getImageMapOutput().

+ Here is the caller graph for this function:

◆ getEditorTitle()

ilImageMapEditorGUI::getEditorTitle ( )

Get editor title.

Returns
string editor title

Reimplemented in ilPCIIMTriggerEditorGUI.

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

180 {
182
183 return $lng->txt("cont_imagemap");
184 }

References $lng.

◆ getHrefOfArea()

ilImageMapEditorGUI::getHrefOfArea (   $a_nr)

Get Href of Area (only external link)

Reimplemented in ilPCImageMapEditorGUI.

Definition at line 952 of file class.ilImageMapEditorGUI.php.

953 {
954 $st_item = $this->media_object->getMediaItem("Standard");
955 $area = $st_item->getMapArea($a_nr);
956 return $area->getHref();
957 }

Referenced by setLink().

+ Here is the caller graph for this function:

◆ getImageMapOutput()

ilImageMapEditorGUI::getImageMapOutput (   $a_map_edit_mode = "")

Render the image map.

Definition at line 609 of file class.ilImageMapEditorGUI.php.

610 {
611 $ilCtrl = $this->ctrl;
612
613 $st_item = $this->media_object->getMediaItem("Standard");
614
615 // output image map
616 $xml = "<dummy>";
617 $xml .= $this->getAliasXML();
618 $xml .= $this->media_object->getXML(IL_MODE_OUTPUT);
619 $xml .= $this->getAdditionalPageXML();
620 $xml .= "</dummy>";
621 $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
622 //echo htmlentities($xml); exit;
623 $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
624 $xh = xslt_create();
625 $wb_path = ilUtil::getWebspaceDir("output") . "/";
626 $mode = "media";
627 //echo htmlentities($ilCtrl->getLinkTarget($this, "showImageMap"));
628
629 $random = new \ilRandom();
630 $params = array('map_edit_mode' => $a_map_edit_mode,
631 'map_item' => $st_item->getId(),
632 'map_mob_id' => $this->media_object->getId(),
633 'mode' => $mode,
634 'media_mode' => 'enable',
635 'image_map_link' => $ilCtrl->getLinkTarget($this, "showImageMap", "", false, false),
636 'link_params' => "ref_id=" . $_GET["ref_id"] . "&rand=" . $random->int(1, 999999),
637 'ref_id' => $_GET["ref_id"],
638 'pg_frame' => "",
639 'enlarge_path' => ilUtil::getImagePath("enlarge.svg"),
640 'webspace_path' => $wb_path);
641 $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", null, $args, $params);
642 echo xslt_error($xh);
643 xslt_free($xh);
644
645 $output = $this->outputPostProcessing($output);
646
647 return $output;
648 }
const IL_MODE_OUTPUT
getAdditionalPageXML()
Get additional page xml (to be overwritten)
outputPostProcessing($a_output)
Output post processing.
static getWebspaceDir($mode="filesystem")
get webspace directory
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
xslt_error(&$proc)
xslt_free(&$proc)
xslt_create()
$xml
Definition: metadata.php:332

References $_GET, $ctrl, $xml, getAdditionalPageXML(), getAliasXML(), ilUtil\getImagePath(), ilUtil\getWebspaceDir(), IL_MODE_OUTPUT, outputPostProcessing(), xslt_create(), xslt_error(), and xslt_free().

Referenced by editMapArea(), and editMapAreas().

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

◆ getImageMapTableHTML()

ilImageMapEditorGUI::getImageMapTableHTML ( )

Get table HTML.

Reimplemented in ilPCIIMTriggerEditorGUI, and ilPCImageMapEditorGUI.

Definition at line 190 of file class.ilImageMapEditorGUI.php.

191 {
192 include_once("./Services/MediaObjects/classes/class.ilImageMapTableGUI.php");
193 $image_map_table = new ilImageMapTableGUI($this, "editMapAreas", $this->media_object);
194 return $image_map_table->getHTML();
195 }
TableGUI class for image map editor.

Referenced by editMapAreas().

+ Here is the caller graph for this function:

◆ getLinkTypeOfArea()

ilImageMapEditorGUI::getLinkTypeOfArea (   $a_nr)

Get Link Type of Area.

Reimplemented in ilPCImageMapEditorGUI.

Definition at line 912 of file class.ilImageMapEditorGUI.php.

913 {
914 $st_item = $this->media_object->getMediaItem("Standard");
915 $area = $st_item->getMapArea($a_nr);
916 return $area->getLinkType();
917 }

Referenced by setLink().

+ Here is the caller graph for this function:

◆ getMapAreaLinkString()

ilImageMapEditorGUI::getMapAreaLinkString (   $a_target,
  $a_type,
  $a_frame 
)

Get text name of internal link.

Parameters
string$a_targettarget object link id
string$a_typetype
string$a_frametarget frame

@access private

Definition at line 685 of file class.ilImageMapEditorGUI.php.

686 {
688
689 $t_arr = explode("_", $a_target);
690 if ($a_frame != "") {
691 $frame_str = " (" . $a_frame . " Frame)";
692 }
693 switch ($a_type) {
694 case "StructureObject":
695 require_once("./Modules/LearningModule/classes/class.ilLMObject.php");
696 $title = ilLMObject::_lookupTitle($t_arr[count($t_arr) - 1]);
697 $link_str = $lng->txt("chapter") .
698 ": " . $title . " [" . $t_arr[count($t_arr) - 1] . "]" . $frame_str;
699 break;
700
701 case "PageObject":
702 require_once("./Modules/LearningModule/classes/class.ilLMObject.php");
703 $title = ilLMObject::_lookupTitle($t_arr[count($t_arr) - 1]);
704 $link_str = $lng->txt("page") .
705 ": " . $title . " [" . $t_arr[count($t_arr) - 1] . "]" . $frame_str;
706 break;
707
708 case "GlossaryItem":
709 $term = new ilGlossaryTerm($t_arr[count($t_arr) - 1]);
710 $link_str = $lng->txt("term") .
711 ": " . $term->getTerm() . " [" . $t_arr[count($t_arr) - 1] . "]" . $frame_str;
712 break;
713
714 case "MediaObject":
715 require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
716 $mob = new ilObjMediaObject($t_arr[count($t_arr) - 1]);
717 $link_str = $lng->txt("mob") .
718 ": " . $mob->getTitle() . " [" . $t_arr[count($t_arr) - 1] . "]" . $frame_str;
719 break;
720
721 case "RepositoryItem":
722 $title = ilObject::_lookupTitle(
723 ilObject::_lookupObjId($t_arr[count($t_arr) - 1])
724 );
725 $link_str = $lng->txt("obj_" . $t_arr[count($t_arr) - 2]) .
726 ": " . $title . " [" . $t_arr[count($t_arr) - 1] . "]" . $frame_str;
727 break;
728 }
729
730 return $link_str;
731 }
static _lookupTitle($a_obj_id)
Lookup title.
Class ilObjMediaObject.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title

References $lng, ilObject\_lookupObjId(), ilObject\_lookupTitle(), and ilLMObject\_lookupTitle().

Referenced by initAreaEditingForm().

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

◆ getTargetFrameOfArea()

ilImageMapEditorGUI::getTargetFrameOfArea (   $a_nr)

Get TargetFrame of Area (only internal link)

Reimplemented in ilPCImageMapEditorGUI.

Definition at line 942 of file class.ilImageMapEditorGUI.php.

943 {
944 $st_item = $this->media_object->getMediaItem("Standard");
945 $area = $st_item->getMapArea($a_nr);
946 return $area->getTargetFrame();
947 }

Referenced by setLink().

+ Here is the caller graph for this function:

◆ getTargetOfArea()

ilImageMapEditorGUI::getTargetOfArea (   $a_nr)

Get Target of Area (only internal link)

Reimplemented in ilPCImageMapEditorGUI.

Definition at line 932 of file class.ilImageMapEditorGUI.php.

933 {
934 $st_item = $this->media_object->getMediaItem("Standard");
935 $area = $st_item->getMapArea($a_nr);
936 return $area->getTarget();
937 }

Referenced by setLink().

+ Here is the caller graph for this function:

◆ getToolbar()

ilImageMapEditorGUI::getToolbar ( )

Get toolbar.

Returns
object toolbar

Reimplemented in ilPCIIMTriggerEditorGUI.

Definition at line 130 of file class.ilImageMapEditorGUI.php.

131 {
132 $ilCtrl = $this->ctrl;
135
136 // toolbar
137 $tb = new ilToolbarGUI();
138 $tb->setFormAction($ilCtrl->getFormAction($this));
139 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
140 $options = array(
141 "WholePicture" => $lng->txt("cont_WholePicture"),
142 "Rect" => $lng->txt("cont_Rect"),
143 "Circle" => $lng->txt("cont_Circle"),
144 "Poly" => $lng->txt("cont_Poly"),
145 );
146 $si = new ilSelectInputGUI($lng->txt("cont_shape"), "shape");
147 $si->setOptions($options);
148 $tb->addInputItem($si, true);
149 $tb->addFormButton($lng->txt("cont_add_area"), "addNewArea");
150
151
152 // highlight mode
153 /* if (strtolower(get_class($this)) == "ilimagemapeditorgui")
154 {
155 $st_item = $this->media_object->getMediaItem("Standard");
156 $tb->addSeparator();
157 $options = ilMapArea::getAllHighlightModes();
158 $hl = new ilSelectInputGUI($lng->txt("cont_highlight_mode"), "highlight_mode");
159 $hl->setOptions($options);
160 // $hl->setValue($st_item->getHighlightMode());
161 $tb->addInputItem($hl, true);
162 $options = ilMapArea::getAllHighlightClasses();
163 $hc = new ilSelectInputGUI($lng->txt("cont_highlight_class"), "highlight_class");
164 $hc->setOptions($options);
165 // $hc->setValue($st_item->getHighlightClass());
166 $tb->addInputItem($hc, false);
167 $tb->addFormButton($lng->txt("cont_set"), "setHighlight");
168 }*/
169
170 return $tb;
171 }
This class represents a selection list property in a property form.

References $ctrl, $lng, $si, and $tpl.

Referenced by editMapAreas().

+ Here is the caller graph for this function:

◆ getTypeOfArea()

ilImageMapEditorGUI::getTypeOfArea (   $a_nr)

Get Type of Area (only internal link)

Reimplemented in ilPCImageMapEditorGUI.

Definition at line 922 of file class.ilImageMapEditorGUI.php.

923 {
924 $st_item = $this->media_object->getMediaItem("Standard");
925 $area = $st_item->getMapArea($a_nr);
926 return $area->getType();
927 }

Referenced by setLink().

+ Here is the caller graph for this function:

◆ handleMapParameters()

ilImageMapEditorGUI::handleMapParameters ( )

handle parameter during map area editing (storing to session)

Definition at line 200 of file class.ilImageMapEditorGUI.php.

201 {
202 if ($_GET["ref_id"] != "") {
203 $_SESSION["il_map_edit_ref_id"] = $_GET["ref_id"];
204 }
205
206 if ($_GET["obj_id"] != "") {
207 $_SESSION["il_map_edit_obj_id"] = $_GET["obj_id"];
208 }
209
210 if ($_GET["hier_id"] != "") {
211 $_SESSION["il_map_edit_hier_id"] = $_GET["hier_id"];
212 }
213
214 if ($_GET["pc_id"] != "") {
215 $_SESSION["il_map_edit_pc_id"] = $_GET["pc_id"];
216 }
217 }

References $_GET, and $_SESSION.

Referenced by addArea(), editMapAreas(), setLink(), and setShape().

+ Here is the caller graph for this function:

◆ initAreaEditingForm()

ilImageMapEditorGUI::initAreaEditingForm (   $a_edit_property)

Init area editing form.

Parameters
int$a_modeEdit Mode

Reimplemented in ilPCIIMTriggerEditorGUI.

Definition at line 493 of file class.ilImageMapEditorGUI.php.

494 {
496 $ilCtrl = $this->ctrl;
497
498 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
499 $form = new ilPropertyFormGUI();
500 $form->setOpenTag(false);
501 $form->setCloseTag(false);
502
503 // link
504 if ($a_edit_property != "shape") {
505 //
506 $radg = new ilRadioGroupInputGUI($lng->txt("cont_link"), "area_link_type");
507 if ($_SESSION["il_map_il_ltype"] != "int") {
508 if ($_SESSION["il_map_el_href"] == "") {
509 $radg->setValue("no");
510 } else {
511 $radg->setValue("ext");
512 }
513 } else {
514 $radg->setValue("int");
515 }
516
517 // external link
518 $ext = new ilRadioOption($lng->txt("cont_link_ext"), "ext");
519 $radg->addOption($ext);
520
521 $ti = new ilTextInputGUI("", "area_link_ext");
522 $ti->setMaxLength(800);
523 $ti->setSize(50);
524 if ($_SESSION["il_map_el_href"] != "") {
525 $ti->setValue($_SESSION["il_map_el_href"]);
526 } else {
527 $ti->setValue("http://");
528 }
529 $ext->addSubItem($ti);
530
531 // internal link
532 $int = new ilRadioOption($lng->txt("cont_link_int"), "int");
533 $radg->addOption($int);
534
535 $ne = new ilNonEditableValueGUI("", "", true);
536 $link_str = "";
537 if ($_SESSION["il_map_il_target"] != "") {
538 $link_str = $this->getMapAreaLinkString(
539 $_SESSION["il_map_il_target"],
540 $_SESSION["il_map_il_type"],
541 $_SESSION["il_map_il_targetframe"]
542 );
543 }
544 $ne->setValue(
545 $link_str .
546 '&nbsp;<a id="iosEditInternalLinkTrigger" href="#">' .
547 "[" . $lng->txt("cont_get_link") . "]" .
548 '</a>'
549 );
550 $int->addSubItem($ne);
551
552 // no link
553 $no = new ilRadioOption($lng->txt("cont_link_no"), "no");
554 $radg->addOption($no);
555
556 $form->addItem($radg);
557 }
558
559
560 // name
561 if ($a_edit_property != "link" && $a_edit_property != "shape") {
562 $ti = new ilTextInputGUI($lng->txt("cont_name"), "area_name");
563 $ti->setMaxLength(200);
564 $ti->setSize(20);
565 $form->addItem($ti);
566 }
567
568 // save and cancel commands
569 if ($a_edit_property == "") {
570 $form->setTitle($lng->txt("cont_new_area"));
571 $form->addCommandButton("saveArea", $lng->txt("save"));
572 } else {
573 $form->setTitle($lng->txt("cont_new_area"));
574 $form->addCommandButton("saveArea", $lng->txt("save"));
575 }
576
577 // $form->setFormAction($ilCtrl->getFormAction($this));
578
579 return $form;
580 }
getMapAreaLinkString($a_target, $a_type, $a_frame)
Get text name of internal link.
This class represents a non editable value in a property form.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a text property in a property form.

References $_SESSION, $ctrl, $lng, and getMapAreaLinkString().

Referenced by editMapArea().

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

◆ linkWholePicture()

ilImageMapEditorGUI::linkWholePicture ( )

Link the whole picture.

Definition at line 267 of file class.ilImageMapEditorGUI.php.

268 {
269 $this->clearSessionVars();
270 $_SESSION["il_map_edit_area_type"] = "WholePicture";
271
272 return $this->editMapArea(false, false, true);
273 }

References $_SESSION, clearSessionVars(), and editMapArea().

Referenced by addNewArea().

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

◆ makeMapWorkCopy()

ilImageMapEditorGUI::makeMapWorkCopy (   $a_edit_property = "",
  $a_area_nr = 0,
  $a_output_new_area = false,
  $a_area_type = "",
  $a_coords = "" 
)

Make work file for editing.

Reimplemented in ilPCImageMapEditorGUI.

Definition at line 585 of file class.ilImageMapEditorGUI.php.

591 {
592 // create/update imagemap work copy
593 $st_item = $this->media_object->getMediaItem("Standard");
594
595 if ($a_edit_property == "shape") {
596 $st_item->makeMapWorkCopy($a_area_nr, true); // exclude area currently being edited
597 } else {
598 $st_item->makeMapWorkCopy($a_area_nr, false);
599 }
600
601 if ($a_output_new_area) {
602 $st_item->addAreaToMapWorkCopy($a_area_type, $a_coords);
603 }
604 }

Referenced by editMapArea(), and editMapAreas().

+ Here is the caller graph for this function:

◆ outputPostProcessing()

ilImageMapEditorGUI::outputPostProcessing (   $a_output)

Output post processing.

Parameters

return

Reimplemented in ilPCIIMTriggerEditorGUI.

Definition at line 666 of file class.ilImageMapEditorGUI.php.

667 {
668 return $a_output;
669 }

Referenced by getImageMapOutput().

+ Here is the caller graph for this function:

◆ saveArea()

ilImageMapEditorGUI::saveArea ( )

Save new or updated map area.

Reimplemented in ilPCIIMTriggerEditorGUI, and ilPCImageMapEditorGUI.

Definition at line 765 of file class.ilImageMapEditorGUI.php.

766 {
768 $ilCtrl = $this->ctrl;
769
770 switch ($_SESSION["il_map_edit_mode"]) {
771 // save edited link
772 case "edit_link":
773 $st_item = $this->media_object->getMediaItem("Standard");
774 $max = ilMapArea::_getMaxNr($st_item->getId());
775 $area = new ilMapArea($st_item->getId(), $_SESSION["il_map_area_nr"]);
776
777 if ($_POST["area_link_type"] == IL_INT_LINK) {
778 $area->setLinkType(IL_INT_LINK);
779 $area->setType($_SESSION["il_map_il_type"]);
780 $area->setTarget($_SESSION["il_map_il_target"]);
781 $area->setTargetFrame($_SESSION["il_map_il_targetframe"]);
782 } else {
783 $area->setLinkType(IL_EXT_LINK);
784 if ($_POST["area_link_type"] != IL_NO_LINK) {
785 $area->setHref(ilUtil::stripSlashes($_POST["area_link_ext"]));
786 } else {
787 $area->setHref("");
788 }
789 }
790 $area->update();
791 break;
792
793 // save edited shape
794 case "edit_shape":
795 $st_item = $this->media_object->getMediaItem("Standard");
796 $max = ilMapArea::_getMaxNr($st_item->getId());
797 $area = new ilMapArea($st_item->getId(), $_SESSION["il_map_area_nr"]);
798
799 $area->setShape($_SESSION["il_map_edit_area_type"]);
800 $area->setCoords($_SESSION["il_map_edit_coords"]);
801 $area->update();
802 break;
803
804 // save new area
805 default:
806 $area_type = $_SESSION["il_map_edit_area_type"];
807 $coords = $_SESSION["il_map_edit_coords"];
808
809 $st_item = $this->media_object->getMediaItem("Standard");
810 $max = ilMapArea::_getMaxNr($st_item->getId());
811
812 // make new area object
813 $area = new ilMapArea();
814 $area->setItemId($st_item->getId());
815 $area->setShape($area_type);
816 $area->setCoords($coords);
817 $area->setNr($max + 1);
818 $area->setTitle(ilUtil::stripSlashes($_POST["area_name"]));
819 switch ($_POST["area_link_type"]) {
820 case "ext":
821 $area->setLinkType(IL_EXT_LINK);
822 $area->setHref($_POST["area_link_ext"]);
823 break;
824
825 case "int":
826 $area->setLinkType(IL_INT_LINK);
827 $area->setType($_SESSION["il_map_il_type"]);
828 $area->setTarget($_SESSION["il_map_il_target"]);
829 $area->setTargetFrame($_SESSION["il_map_il_targetframe"]);
830 break;
831 }
832
833 // put area into item and update media object
834 $st_item->addMapArea($area);
835 $this->media_object->update();
836 break;
837 }
838
839 //$this->initMapParameters();
840 ilUtil::sendSuccess($lng->txt("cont_saved_map_area"), true);
841 $ilCtrl->redirect($this, "editMapAreas");
842 }
const IL_INT_LINK
const IL_EXT_LINK
const IL_NO_LINK
Class ilMapArea.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

References $_POST, $_SESSION, $ctrl, $lng, ilMapArea\_getMaxNr(), IL_EXT_LINK, IL_INT_LINK, IL_NO_LINK, and ilUtil\stripSlashes().

Referenced by setShape().

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

◆ setHighlight()

ilImageMapEditorGUI::setHighlight ( )

Set highlight settings.

Parameters

return

Definition at line 1134 of file class.ilImageMapEditorGUI.php.

1135 {
1136 $ilCtrl = $this->ctrl;
1137 $lng = $this->lng;
1138
1139 $st_item = $this->media_object->getMediaItem("Standard");
1140 $st_item->setHighlightMode(ilUtil::stripSlashes($_POST["highlight_mode"]));
1141 $st_item->setHighlightClass(ilUtil::stripSlashes($_POST["highlight_class"]));
1142 $st_item->update();
1143
1144 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1145 $ilCtrl->redirect($this, "editMapAreas");
1146 }

References $_POST, $ctrl, $lng, and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ setInternalLink()

ilImageMapEditorGUI::setInternalLink ( )

Set internal link.

Definition at line 847 of file class.ilImageMapEditorGUI.php.

848 {
849 $_SESSION["il_map_il_type"] = $_GET["linktype"];
850 $_SESSION["il_map_il_ltype"] = "int";
851
852 $_SESSION["il_map_il_target"] = $_GET["linktarget"];
853 $_SESSION["il_map_il_targetframe"] = $_GET["linktargetframe"];
854 $_SESSION["il_map_il_anchor"] = $_GET["linkanchor"];
855 switch ($_SESSION["il_map_edit_mode"]) {
856 case "edit_link":
857 return $this->setLink();
858 break;
859
860 default:
861 return $this->addArea();
862 break;
863 }
864 }

References $_GET, $_SESSION, addArea(), and setLink().

+ Here is the call graph for this function:

◆ setLink()

ilImageMapEditorGUI::setLink (   $a_handle = true)

Set link.

Definition at line 869 of file class.ilImageMapEditorGUI.php.

870 {
872 $ilCtrl = $this->ctrl;
873
874 if ($a_handle) {
875 $this->handleMapParameters();
876 }
877 if ($_SESSION["il_map_area_nr"] != "") {
878 $_POST["area"][0] = $_SESSION["il_map_area_nr"];
879 }
880 if (!isset($_POST["area"])) {
881 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
882 $ilCtrl->redirect($this, "editMapAreas");
883 }
884
885 if (count($_POST["area"]) > 1) {
886 //$this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
887 ilUtil::sendFailure($lng->txt("cont_select_max_one_item"), true);
888 $ilCtrl->redirect($this, "editMapAreas");
889 }
890
891
892 if ($_SESSION["il_map_edit_mode"] != "edit_link") {
893 $_SESSION["il_map_area_nr"] = $_POST["area"][0];
894 $_SESSION["il_map_il_ltype"] = $this->getLinkTypeOfArea($_POST["area"][0]);
895 $_SESSION["il_map_edit_mode"] = "edit_link";
896 $_SESSION["il_map_edit_target_script"] = $ilCtrl->getLinkTarget($this, "setLink");
897 if ($_SESSION["il_map_il_ltype"] == IL_INT_LINK) {
898 $_SESSION["il_map_il_type"] = $this->getTypeOfArea($_POST["area"][0]);
899 $_SESSION["il_map_il_target"] = $this->getTargetOfArea($_POST["area"][0]);
900 $_SESSION["il_map_il_targetframe"] = $this->getTargetFrameOfArea($_POST["area"][0]);
901 } else {
902 $_SESSION["il_map_el_href"] = $this->getHrefOfArea($_POST["area"][0]);
903 }
904 }
905
906 return $this->editMapArea(false, false, true, "link", $_POST["area"][0]);
907 }
getTargetOfArea($a_nr)
Get Target of Area (only internal link)
getTypeOfArea($a_nr)
Get Type of Area (only internal link)
getTargetFrameOfArea($a_nr)
Get TargetFrame of Area (only internal link)
getHrefOfArea($a_nr)
Get Href of Area (only external link)
getLinkTypeOfArea($a_nr)
Get Link Type of Area.

References $_POST, $_SESSION, $ctrl, $lng, editMapArea(), getHrefOfArea(), getLinkTypeOfArea(), getTargetFrameOfArea(), getTargetOfArea(), getTypeOfArea(), handleMapParameters(), IL_INT_LINK, and ilUtil\sendFailure().

Referenced by editLink(), and setInternalLink().

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

◆ setShape()

ilImageMapEditorGUI::setShape (   $a_handle = true)

edit shape of existing map area

Definition at line 1049 of file class.ilImageMapEditorGUI.php.

1050 {
1051 $lng = $this->lng;
1052 $ilCtrl = $this->ctrl;
1053
1054 if ($a_handle) {
1055 $this->handleMapParameters();
1056 }
1057 if ($_POST["areatype2"] != "") {
1058 $_SESSION["il_map_edit_area_type"] = $_POST["areatype2"];
1059 }
1060 if ($_SESSION["il_map_area_nr"] != "") {
1061 $_POST["area"][0] = $_SESSION["il_map_area_nr"];
1062 }
1063 if (!isset($_POST["area"])) {
1064 ilUtil::sendFailure($lng->txt("no_checkbox"), true);
1065 $ilCtrl->redirect($this, "editMapAreas");
1066 }
1067
1068 if (count($_POST["area"]) > 1) {
1069 ilUtil::sendFailure($lng->txt("cont_select_max_one_item"), true);
1070 $ilCtrl->redirect($this, "editMapAreas");
1071 }
1072
1073 if ($_SESSION["il_map_edit_mode"] != "edit_shape") {
1074 $_SESSION["il_map_area_nr"] = $_POST["area"][0];
1075 $_SESSION["il_map_edit_mode"] = "edit_shape";
1076 $_SESSION["il_map_edit_target_script"] = $ilCtrl->getLinkTarget($this, "setShape", "", false, false);
1077 }
1078
1079
1080 $area_type = $_SESSION["il_map_edit_area_type"];
1081 $coords = $_SESSION["il_map_edit_coords"];
1082 $cnt_coords = ilMapArea::countCoords($coords);
1083
1084 // decide what to do next
1085 switch ($area_type) {
1086 // Rectangle
1087 case "Rect":
1088 if ($cnt_coords < 2) {
1089 return $this->editMapArea(true, false, false, "shape", $_POST["area"][0]);
1090 } elseif ($cnt_coords == 2) {
1091 return $this->saveArea();
1092 }
1093 break;
1094
1095 // Circle
1096 case "Circle":
1097 if ($cnt_coords <= 1) {
1098 return $this->editMapArea(true, false, false, "shape", $_POST["area"][0]);
1099 } else {
1100 if ($cnt_coords == 2) {
1101 $c = explode(",", $coords);
1102 $coords = $c[0] . "," . $c[1] . ","; // determine radius
1103 $coords .= round(sqrt(pow(abs($c[3] - $c[1]), 2) + pow(abs($c[2] - $c[0]), 2)));
1104 }
1105 $_SESSION["il_map_edit_coords"] = $coords;
1106
1107 return $this->saveArea();
1108 }
1109 break;
1110
1111 // Polygon
1112 case "Poly":
1113 if ($cnt_coords < 1) {
1114 return $this->editMapArea(true, false, false, "shape", $_POST["area"][0]);
1115 } elseif ($cnt_coords < 3) {
1116 return $this->editMapArea(true, true, false, "shape", $_POST["area"][0]);
1117 } else {
1118 return $this->editMapArea(true, true, true, "shape", $_POST["area"][0]);
1119 }
1120 break;
1121
1122 // Whole Picture
1123 case "WholePicture":
1124 return $this->saveArea();
1125 }
1126 }
saveArea()
Save new or updated map area.

References $_POST, $_SESSION, $c, $ctrl, $lng, ilMapArea\countCoords(), editMapArea(), handleMapParameters(), saveArea(), and ilUtil\sendFailure().

Referenced by editShapeCircle(), editShapePolygon(), editShapeRectangle(), and editShapeWholePicture().

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

◆ showImageMap()

ilImageMapEditorGUI::showImageMap ( )

show image map

Definition at line 222 of file class.ilImageMapEditorGUI.php.

223 {
224 $item = new ilMediaItem($_GET["item_id"]);
225 $item->outputMapWorkCopy();
226 }
Class ilMediaItem Media Item, component of a media object (file or reference)

References $_GET.

◆ updateAreas()

ilImageMapEditorGUI::updateAreas ( )

Update map areas.

Reimplemented in ilPCImageMapEditorGUI.

Definition at line 231 of file class.ilImageMapEditorGUI.php.

232 {
234 $ilCtrl = $this->ctrl;
235
236 $st_item = $this->media_object->getMediaItem("Standard");
237 $max = ilMapArea::_getMaxNr($st_item->getId());
238 for ($i = 1; $i <= $max; $i++) {
239 $area = new ilMapArea($st_item->getId(), $i);
240 $area->setTitle(ilUtil::stripSlashes($_POST["name_" . $i]));
241 $area->setHighlightMode(ilUtil::stripSlashes($_POST["hl_mode_" . $i]));
242 $area->setHighlightClass(ilUtil::stripSlashes($_POST["hl_class_" . $i]));
243 $area->update();
244 }
245
246 ilUtil::sendSuccess($lng->txt("cont_saved_map_data"), true);
247 $ilCtrl->redirect($this, "editMapAreas");
248 }

References $_POST, $ctrl, $i, $lng, ilMapArea\_getMaxNr(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

◆ $lng

◆ $toolbar

ilImageMapEditorGUI::$toolbar
protected

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

Referenced by editMapAreas().

◆ $tpl

ilImageMapEditorGUI::$tpl
protected

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

Referenced by editMapArea(), executeCommand(), and getToolbar().


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