ILIAS  release_8 Revision v8.24
ilImageMapEditorGUI Class Reference

User interface class for map editor. More...

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

Public Member Functions

 __construct (ilObjMediaObject $a_media_object)
 
 executeCommand ()
 
 editMapAreas ()
 
 getToolbar ()
 
 getEditorTitle ()
 
 getImageMapTableHTML ()
 
 handleMapParameters ()
 
 showImageMap ()
 
 updateAreas ()
 
 addNewArea ()
 
 linkWholePicture ()
 
 addRectangle ()
 
 addCircle ()
 
 addPolygon ()
 
 clearSessionVars ()
 
 addArea (bool $a_handle=true)
 
 editMapArea (bool $a_get_next_coordinate=false, bool $a_output_new_area=false, bool $a_save_form=false, string $a_edit_property="", int $a_area_nr=0)
 Edit a single map area. More...
 
 initAreaEditingForm (string $a_edit_property)
 
 makeMapWorkCopy (string $a_edit_property="", int $a_area_nr=0, bool $a_output_new_area=false, string $a_area_type="", string $a_coords="")
 Make work file for editing. More...
 
 getImageMapOutput (string $a_map_edit_mode="")
 Render the image map. More...
 
 getAdditionalPageXML ()
 Get additional page xml (to be overwritten) More...
 
 outputPostProcessing (string $a_output)
 
 getAliasXML ()
 
 getMapAreaLinkString (string $a_target, string $a_type, string $a_frame)
 Get text name of internal link. More...
 
 editImagemapForward ()
 Get image map coordinates. More...
 
 saveArea ()
 Save new or updated map area. More...
 
 setInternalLink ()
 
 setLink (bool $a_handle=true)
 
 getLinkTypeOfArea (int $a_nr)
 
 getTypeOfArea (int $a_nr)
 Get Type of Area (only internal link) More...
 
 getTargetOfArea (int $a_nr)
 Get Target of Area (only internal link) More...
 
 getTargetFrameOfArea (int $a_nr)
 Get TargetFrame of Area (only internal link) More...
 
 getHrefOfArea (int $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 (bool $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

ilObjMediaObject $media_object
 
ImageMapGUIRequest $request
 
ImageMapManager $map
 
ilTemplate $tpl
 
ilGlobalTemplateInterface $main_tpl
 
ilCtrl $ctrl
 
ilLanguage $lng
 
ilToolbarGUI $toolbar
 

Detailed Description

User interface class for map editor.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de @ilCtrl_Calls ilImageMapEditorGUI: ilInternalLinkGUI

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

Constructor & Destructor Documentation

◆ __construct()

ilImageMapEditorGUI::__construct ( ilObjMediaObject  $a_media_object)

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

40 {
41 global $DIC;
42
43 $this->ctrl = $DIC->ctrl();
44 $this->main_tpl = $DIC->ui()->mainTemplate();
45 $this->lng = $DIC->language();
46 $this->toolbar = $DIC->toolbar();
47 $this->media_object = $a_media_object;
48
49 $this->map = $DIC->mediaObjects()
50 ->internal()
51 ->domain()
52 ->imageMap();
53
54 $this->request = $DIC->mediaObjects()
55 ->internal()
56 ->gui()
57 ->imageMap()
58 ->request();
59 }
global $DIC
Definition: feed.php:28

References $DIC, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

+ Here is the call graph for this function:

Member Function Documentation

◆ _recoverParameters()

static ilImageMapEditorGUI::_recoverParameters ( )
static

Recover parameters from session variables (static)

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

683 : void
684 {
685 global $DIC;
686
687 $map = $DIC->mediaObjects()->internal()->domain()->imageMap();
688 /*
689 $_GET["ref_id"] = $map->getRefId();
690 $_GET["obj_id"] = $map->getObjId();
691 $_GET["hier_id"] = $map->getHierId();
692 $_GET["pc_id"] = $map->getPCId();*/
693 }

References $DIC.

Referenced by editImagemapForward().

+ Here is the caller graph for this function:

◆ addArea()

ilImageMapEditorGUI::addArea ( bool  $a_handle = true)

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

261 : string {
262
263 // handle map parameters
264 if ($a_handle) {
265 $this->handleMapParameters();
266 }
267
268 $area_type = $this->map->getAreaType();
269 $coords = $this->map->getCoords();
270 $cnt_coords = ilMapArea::countCoords($coords);
271
272 // decide what to do next
273 switch ($area_type) {
274 // Rectangle
275 case "Rect":
276 if ($cnt_coords < 2) {
277 $html = $this->editMapArea(true, false, false);
278 return $html;
279 } elseif ($cnt_coords == 2) {
280 return $this->editMapArea(false, true, true);
281 }
282 break;
283
284 // Circle
285 case "Circle":
286 if ($cnt_coords <= 1) {
287 return $this->editMapArea(true, false, false);
288 } else {
289 if ($cnt_coords == 2) {
290 $c = explode(",", $coords);
291 $coords = $c[0] . "," . $c[1] . ","; // determine radius
292 $coords .= round(sqrt(pow(abs($c[3] - $c[1]), 2) + pow(abs($c[2] - $c[0]), 2)));
293 }
294 $this->map->setCoords($coords);
295
296 return $this->editMapArea(false, true, true);
297 }
298
299 // Polygon
300 // no break
301 case "Poly":
302 if ($cnt_coords < 1) {
303 return $this->editMapArea(true, false, false);
304 } elseif ($cnt_coords < 3) {
305 return $this->editMapArea(true, true, false);
306 } else {
307 return $this->editMapArea(true, true, true);
308 }
309
310 // Whole picture
311 // no break
312 case "WholePicture":
313 return $this->editMapArea(false, false, true);
314 }
315 return "";
316 }
editMapArea(bool $a_get_next_coordinate=false, bool $a_output_new_area=false, bool $a_save_form=false, string $a_edit_property="", int $a_area_nr=0)
Edit a single map area.
static countCoords(string $c)
count the number of coordinates (x,y) in a coordinate string (format: "x1,y1,x2,y2,...
$c
Definition: cli.php:38

References handleMapParameters().

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

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

◆ addCircle()

ilImageMapEditorGUI::addCircle ( )

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

240 : string
241 {
242 $this->clearSessionVars();
243 $this->map->setAreaType("Circle");
244 return $this->addArea(false);
245 }
addArea(bool $a_handle=true)

References 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 ( )

Reimplemented in ilPCIIMTriggerEditorGUI.

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

214 : string
215 {
216 switch ($this->request->getAreaShape()) {
217 case "WholePicture": return $this->linkWholePicture();
218 case "Rect": return $this->addRectangle();
219 case "Circle": return $this->addCircle();
220 case "Poly": return $this->addPolygon();
221 }
222 return "";
223 }

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

+ Here is the call graph for this function:

◆ addPolygon()

ilImageMapEditorGUI::addPolygon ( )

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

247 : string
248 {
249 $this->clearSessionVars();
250 $this->map->setAreaType("Poly");
251 return $this->addArea(false);
252 }

References 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 ( )

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

233 : string
234 {
235 $this->clearSessionVars();
236 $this->map->setAreaType("Rect");
237 return $this->addArea(false);
238 }

References 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 ( )

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

254 : void
255 {
256 $this->map->clear();
257 }

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

+ Here is the caller graph for this function:

◆ deleteAreas()

ilImageMapEditorGUI::deleteAreas ( )

Delete map areas.

Reimplemented in ilPCImageMapEditorGUI.

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

905 : void
906 {
907 $ilCtrl = $this->ctrl;
909
910 $area = $this->request->getArea();
911 if (count($area) == 0) {
912 $this->main_tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
913 $ilCtrl->redirect($this, "editMapAreas");
914 }
915
916 $st_item = $this->media_object->getMediaItem("Standard");
917 $max = ilMapArea::_getMaxNr($st_item->getId());
918
919 if (count($area) > 0) {
920 $i = 0;
921
922 foreach ($area as $area_nr) {
923 $st_item->deleteMapArea($area_nr - $i);
924 $i++;
925 }
926
927 $this->media_object->update();
928 $this->main_tpl->setOnScreenMessage('success', $lng->txt("cont_areas_deleted"), true);
929 }
930
931 $ilCtrl->redirect($this, "editMapAreas");
932 }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _getMaxNr(int $a_item_id)
get maximum nr of media item (static)
$i
Definition: metadata.php:41

References $i, $lng, and ilMapArea\_getMaxNr().

+ Here is the call graph for this function:

◆ editImagemapForward()

ilImageMapEditorGUI::editImagemapForward ( )

Get image map coordinates.

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

664 : void
665 {
667
668 $coords = $this->map->getCoords();
669 if ($coords != "") {
670 $coords .= ",";
671 }
672
673 $this->map->setCoords($coords . $this->request->getX() . "," .
674 $this->request->getY());
675
676 // call editing script
677 ilUtil::redirect($this->map->getTargetScript());
678 }
static _recoverParameters()
Recover parameters from session variables (static)
static redirect(string $a_script)

References _recoverParameters(), and ilUtil\redirect().

+ Here is the call graph for this function:

◆ editLink()

ilImageMapEditorGUI::editLink ( )

Edit existing link.

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

937 : string
938 {
939 $this->map->clear();
940 return $this->setLink(false);
941 }
setLink(bool $a_handle=true)

◆ editMapArea()

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

Edit a single map area.

Parameters
bool$a_get_next_coordinateenable next coordinate input
bool$a_output_new_areaoutput the new area
bool$a_save_formoutput save form
string$a_edit_property"" | "link" | "shape"
int$a_area_nr
Returns
string

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

333 : string {
334 $ilCtrl = $this->ctrl;
336
337 $area_type = $this->map->getAreaType();
338 $coords = $this->map->getCoords();
339 $cnt_coords = ilMapArea::countCoords($coords);
340
341 $this->tpl = new ilTemplate("tpl.map_edit.html", true, true, "Services/MediaObjects");
342
343 $this->tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this));
344
345 if ($a_edit_property != "link") {
346 switch ($area_type) {
347 // rectangle
348 case "Rect":
349 if ($cnt_coords == 0) {
350 $this->main_tpl->setOnScreenMessage('info', $lng->txt("cont_click_tl_corner"));
351 }
352 if ($cnt_coords == 1) {
353 $this->main_tpl->setOnScreenMessage('info', $lng->txt("cont_click_br_corner"));
354 }
355 break;
356
357 // circle
358 case "Circle":
359 if ($cnt_coords == 0) {
360 $this->main_tpl->setOnScreenMessage('info', $lng->txt("cont_click_center"));
361 }
362 if ($cnt_coords == 1) {
363 $this->main_tpl->setOnScreenMessage('info', $lng->txt("cont_click_circle"));
364 }
365 break;
366
367 // polygon
368 case "Poly":
369 if ($cnt_coords == 0) {
370 $this->main_tpl->setOnScreenMessage('info', $lng->txt("cont_click_starting_point"));
371 } elseif ($cnt_coords < 3) {
372 $this->main_tpl->setOnScreenMessage('info', $lng->txt("cont_click_next_point"));
373 } else {
374 $this->main_tpl->setOnScreenMessage('info', $lng->txt("cont_click_next_or_save"));
375 }
376 break;
377 }
378 }
379
380
381 // map properties input fields (name and link)
382 if ($a_save_form) {
383 if ($a_edit_property != "shape") {
384 // prepare link gui
385 $ilCtrl->setParameter($this, "linkmode", "map");
386 $this->tpl->setCurrentBlock("int_link_prep");
387 $this->tpl->setVariable("INT_LINK_PREP", ilInternalLinkGUI::getInitHTML(
388 $ilCtrl->getLinkTargetByClass(
389 "ilinternallinkgui",
390 "",
391 false,
392 true,
393 false
394 )
395 ));
396 $this->tpl->parseCurrentBlock();
397 }
398 $form = $this->initAreaEditingForm($a_edit_property);
399 $this->tpl->setVariable("FORM", $form->getHTML());
400 }
401
402 $this->makeMapWorkCopy(
403 $a_edit_property,
404 $a_area_nr,
405 $a_output_new_area,
406 $area_type,
407 $coords
408 );
409
410 $edit_mode = ($a_get_next_coordinate)
411 ? "get_coords"
412 : (($a_output_new_area)
413 ? "new_area"
414 : "");
415 $output = $this->getImageMapOutput($edit_mode);
416 $this->tpl->setVariable("IMAGE_MAP", $output);
417
418 return $this->tpl->get();
419 }
initAreaEditingForm(string $a_edit_property)
getImageMapOutput(string $a_map_edit_mode="")
Render the image map.
makeMapWorkCopy(string $a_edit_property="", int $a_area_nr=0, bool $a_output_new_area=false, string $a_area_type="", string $a_coords="")
Make work file for editing.
static getInitHTML(string $a_url)
Get initialisation HTML to use internal link editing.
special template class to simplify handling of ITX/PEAR

Referenced by linkWholePicture().

+ Here is the caller graph for this function:

◆ editMapAreas()

ilImageMapEditorGUI::editMapAreas ( )

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

97 : string
98 {
99 $ilCtrl = $this->ctrl;
100
101 $this->map->setTargetScript(
102 $ilCtrl->getLinkTarget(
103 $this,
104 "addArea",
105 "",
106 false,
107 false
108 )
109 );
110 $this->handleMapParameters();
111
112 $this->tpl = new ilTemplate("tpl.map_edit.html", true, true, "Services/MediaObjects");
113 $this->tpl->setVariable("FORMACTION", $ilCtrl->getFormAction($this));
114
115 // create/update imagemap work copy
116 $this->makeMapWorkCopy();
117
118 $output = $this->getImageMapOutput();
119 $this->tpl->setVariable("IMAGE_MAP", $output);
120
121 $this->tpl->setVariable("TOOLBAR", $this->getToolbar()->getHTML());
122
123 // table
124 $this->tpl->setVariable("MAP_AREA_TABLE", $this->getImageMapTableHTML());
125
126 return $this->tpl->get();
127 }
setTargetScript(string $a_target_script)
@inheritDoc

References $ctrl, getImageMapOutput(), getImageMapTableHTML(), getToolbar(), handleMapParameters(), makeMapWorkCopy(), and ilCtrl\setTargetScript().

+ Here is the call graph for this function:

◆ editShapeCircle()

ilImageMapEditorGUI::editShapeCircle ( )

Edit an existing shape (make it a circle)

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

966 : string
967 {
968 $this->clearSessionVars();
969 $this->map->setAreaType("Circle");
970 return $this->setShape(false);
971 }
setShape(bool $a_handle=true)
edit shape of existing map area

◆ editShapePolygon()

ilImageMapEditorGUI::editShapePolygon ( )

Edit an existing shape (make it a polygon)

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

976 : string
977 {
978 $this->clearSessionVars();
979 $this->map->setAreaType("Poly");
980 return $this->setShape(false);
981 }

◆ editShapeRectangle()

ilImageMapEditorGUI::editShapeRectangle ( )

Edit an existing shape (make it a rectangle)

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

956 : string
957 {
958 $this->clearSessionVars();
959 $this->map->setAreaType("Rect");
960 return $this->setShape(false);
961 }

◆ editShapeWholePicture()

ilImageMapEditorGUI::editShapeWholePicture ( )

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

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

946 : string
947 {
948 $this->clearSessionVars();
949 $this->map->setAreaType("WholePicture");
950 return $this->setShape(false);
951 }

◆ executeCommand()

ilImageMapEditorGUI::executeCommand ( )
Returns
mixed
Exceptions
ilCtrlException

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

66 {
67 $ilCtrl = $this->ctrl;
68
69 $next_class = $ilCtrl->getNextClass($this);
70 $cmd = $ilCtrl->getCmd();
71
72 switch ($next_class) {
73 case "ilinternallinkgui":
74 $link_gui = new ilInternalLinkGUI("Media_Media", 0);
75 $link_gui->setSetLinkTargetScript(
76 $ilCtrl->getLinkTarget(
77 $this,
78 "setInternalLink"
79 )
80 );
81 $link_gui->filterLinkType("File");
82 $ret = $ilCtrl->forwardCommand($link_gui);
83 break;
84
85 default:
87 if ($this->request->getX() != "" &&
88 $this->request->getY() != "") {
89 $cmd = "editImagemapForward";
90 }
91 $ret = $this->$cmd();
92 break;
93 }
94 return $ret;
95 }
getNextClass($a_gui_class=null)
@inheritDoc
Internal link selector.
static includePresentationJS(ilGlobalTemplateInterface $a_tpl=null)
Include media object presentation JS.

References $ctrl, ilCtrl\getNextClass(), 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 578 of file class.ilImageMapEditorGUI.php.

578 : string
579 {
580 return "";
581 }

◆ getAliasXML()

ilImageMapEditorGUI::getAliasXML ( )

Reimplemented in ilPCImageMapEditorGUI.

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

589 : string
590 {
591 return $this->media_object->getXML(IL_MODE_ALIAS);
592 }
const IL_MODE_ALIAS

References IL_MODE_ALIAS.

◆ getEditorTitle()

ilImageMapEditorGUI::getEditorTitle ( )

Reimplemented in ilPCIIMTriggerEditorGUI.

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

151 : string
152 {
154 return $lng->txt("cont_imagemap");
155 }

References $lng, and ilLanguage\txt().

+ Here is the call graph for this function:

◆ getHrefOfArea()

ilImageMapEditorGUI::getHrefOfArea ( int  $a_nr)

Get Href of Area (only external link)

Reimplemented in ilPCImageMapEditorGUI.

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

896 : string {
897 $st_item = $this->media_object->getMediaItem("Standard");
898 $area = $st_item->getMapArea($a_nr);
899 return $area->getHref();
900 }

◆ getImageMapOutput()

ilImageMapEditorGUI::getImageMapOutput ( string  $a_map_edit_mode = "")

Render the image map.

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

534 : string {
535 $ilCtrl = $this->ctrl;
536
537 $st_item = $this->media_object->getMediaItem("Standard");
538
539 // output image map
540 $xml = "<dummy>";
541 $xml .= $this->getAliasXML();
542 $xml .= $this->media_object->getXML(IL_MODE_OUTPUT);
543 $xml .= $this->getAdditionalPageXML();
544 $xml .= "</dummy>";
545 $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
546 //echo htmlentities($xml); exit;
547 $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
548 $xh = xslt_create();
549 $wb_path = ilFileUtils::getWebspaceDir("output") . "/";
550 $mode = "media";
551 //echo htmlentities($ilCtrl->getLinkTarget($this, "showImageMap"));
552
553 $random = new \ilRandom();
554 $params = array('map_edit_mode' => $a_map_edit_mode,
555 'map_item' => $st_item->getId(),
556 'map_mob_id' => $this->media_object->getId(),
557 'mode' => $mode,
558 'media_mode' => 'enable',
559 'image_map_link' => $ilCtrl->getLinkTarget($this, "showImageMap", "", false, false),
560 'link_params' => "ref_id=" . $this->request->getRefId() . "&rand=" . $random->int(1, 999999),
561 'ref_id' => $this->request->getRefId(),
562 'pg_frame' => "",
563 'enlarge_path' => ilUtil::getImagePath("enlarge.svg"),
564 'webspace_path' => $wb_path);
565 $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", null, $args, $params);
566 xslt_error($xh);
567 xslt_free($xh);
568
569 $output = $this->outputPostProcessing($output);
570
571 return $output;
572 }
const IL_MODE_OUTPUT
static getWebspaceDir(string $mode="filesystem")
get webspace directory
getAdditionalPageXML()
Get additional page xml (to be overwritten)
outputPostProcessing(string $a_output)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
xslt_error(&$proc)
xslt_free(&$proc)
xslt_create()
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:33
$xml
Definition: metadata.php:351

Referenced by editMapAreas().

+ Here is the caller graph for this function:

◆ getImageMapTableHTML()

ilImageMapEditorGUI::getImageMapTableHTML ( )

Reimplemented in ilPCIIMTriggerEditorGUI, and ilPCImageMapEditorGUI.

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

158 : string
159 {
160 $image_map_table = new ilImageMapTableGUI($this, "editMapAreas", $this->media_object);
161 return $image_map_table->getHTML();
162 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Referenced by editMapAreas().

+ Here is the caller graph for this function:

◆ getLinkTypeOfArea()

ilImageMapEditorGUI::getLinkTypeOfArea ( int  $a_nr)

Reimplemented in ilPCImageMapEditorGUI.

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

852 : string {
853 $st_item = $this->media_object->getMediaItem("Standard");
854 $area = $st_item->getMapArea($a_nr);
855 return $area->getLinkType();
856 }

◆ getMapAreaLinkString()

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

Get text name of internal link.

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

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

604 : string {
606 $frame_str = "";
607 $link_str = "";
608 $t_arr = explode("_", $a_target);
609 if ($a_frame != "") {
610 $frame_str = " (" . $a_frame . " Frame)";
611 }
612 switch ($a_type) {
613 case "StructureObject":
614 $title = ilLMObject::_lookupTitle($t_arr[count($t_arr) - 1]);
615 $link_str = $lng->txt("chapter") .
616 ": " . $title . " [" . $t_arr[count($t_arr) - 1] . "]" . $frame_str;
617 break;
618
619 case "PageObject":
620 $title = ilLMObject::_lookupTitle($t_arr[count($t_arr) - 1]);
621 $link_str = $lng->txt("page") .
622 ": " . $title . " [" . $t_arr[count($t_arr) - 1] . "]" . $frame_str;
623 break;
624
625 case "GlossaryItem":
626 $term = new ilGlossaryTerm($t_arr[count($t_arr) - 1]);
627 $link_str = $lng->txt("term") .
628 ": " . $term->getTerm() . " [" . $t_arr[count($t_arr) - 1] . "]" . $frame_str;
629 break;
630
631 case "MediaObject":
632 $mob = new ilObjMediaObject($t_arr[count($t_arr) - 1]);
633 $link_str = $lng->txt("mob") .
634 ": " . $mob->getTitle() . " [" . $t_arr[count($t_arr) - 1] . "]" . $frame_str;
635 break;
636
637 case "RepositoryItem":
638 if (trim($a_target) !== "") {
639 $title = ilObject::_lookupTitle(
640 ilObject::_lookupObjId((int) $t_arr[count($t_arr) - 1])
641 );
642 $link_str = $lng->txt("obj_" . $t_arr[count($t_arr) - 2]) .
643 ": " . $title . " [" . $t_arr[count($t_arr) - 1] . "]" . $frame_str;
644 } else {
645 $title = "";
646 $link_str = "";
647 }
648 break;
649
650 case "WikiPage":
651 $wpg = new ilWikiPage($t_arr[count($t_arr) - 1]);
652 $link_str = $lng->txt("cont_wiki_page") .
653 ": " . $wpg->getTitle() . " [" . $t_arr[count($t_arr) - 1] . "]" . $frame_str;
654 break;
655
656 }
657
658 return $link_str;
659 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupTitle(int $a_obj_id)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getTargetFrameOfArea()

ilImageMapEditorGUI::getTargetFrameOfArea ( int  $a_nr)

Get TargetFrame of Area (only internal link)

Reimplemented in ilPCImageMapEditorGUI.

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

885 : string {
886 $st_item = $this->media_object->getMediaItem("Standard");
887 $area = $st_item->getMapArea($a_nr);
888 return $area->getTargetFrame();
889 }

◆ getTargetOfArea()

ilImageMapEditorGUI::getTargetOfArea ( int  $a_nr)

Get Target of Area (only internal link)

Reimplemented in ilPCImageMapEditorGUI.

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

874 : string {
875 $st_item = $this->media_object->getMediaItem("Standard");
876 $area = $st_item->getMapArea($a_nr);
877 return $area->getTarget();
878 }

◆ getToolbar()

ilImageMapEditorGUI::getToolbar ( )

Reimplemented in ilPCIIMTriggerEditorGUI.

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

130 {
131 $ilCtrl = $this->ctrl;
133
134 // toolbar
135 $tb = new ilToolbarGUI();
136 $tb->setFormAction($ilCtrl->getFormAction($this));
137 $options = array(
138 "WholePicture" => $lng->txt("cont_WholePicture"),
139 "Rect" => $lng->txt("cont_Rect"),
140 "Circle" => $lng->txt("cont_Circle"),
141 "Poly" => $lng->txt("cont_Poly"),
142 );
143 $si = new ilSelectInputGUI($lng->txt("cont_shape"), "shape");
144 $si->setOptions($options);
145 $tb->addInputItem($si, true);
146 $tb->addFormButton($lng->txt("cont_add_area"), "addNewArea");
147
148 return $tb;
149 }
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $ctrl, $lng, and ilLanguage\txt().

Referenced by editMapAreas().

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

◆ getTypeOfArea()

ilImageMapEditorGUI::getTypeOfArea ( int  $a_nr)

Get Type of Area (only internal link)

Reimplemented in ilPCImageMapEditorGUI.

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

863 : string {
864 $st_item = $this->media_object->getMediaItem("Standard");
865 $area = $st_item->getMapArea($a_nr);
866 return $area->getType();
867 }

◆ handleMapParameters()

ilImageMapEditorGUI::handleMapParameters ( )

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

164 : void
165 {
166 if ($this->request->getRefId() > 0) {
167 $this->map->setRefId($this->request->getRefId());
168 }
169
170 if ($this->request->getObjId() > 0) {
171 $this->map->setObjId($this->request->getObjId());
172 }
173
174 if ($this->request->getHierId() != "") {
175 $this->map->setHierId($this->request->getHierId());
176 }
177
178 if ($this->request->getPCId() != "") {
179 $this->map->setPCId($this->request->getPCId());
180 }
181 }

Referenced by addArea(), and editMapAreas().

+ Here is the caller graph for this function:

◆ initAreaEditingForm()

ilImageMapEditorGUI::initAreaEditingForm ( string  $a_edit_property)

Reimplemented in ilPCIIMTriggerEditorGUI.

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

425
426 $form = new ilPropertyFormGUI();
427 $form->setOpenTag(false);
428 $form->setCloseTag(false);
429
430 // link
431 if ($a_edit_property != "shape") {
432 //
433 $radg = new ilRadioGroupInputGUI($lng->txt("cont_link"), "area_link_type");
434 if ($this->map->getLinkType() != "int") {
435 if ($this->map->getExternalLink() == "") {
436 $radg->setValue("no");
437 } else {
438 $radg->setValue("ext");
439 }
440 } else {
441 $radg->setValue("int");
442 }
443
444 // external link
445 $ext = new ilRadioOption($lng->txt("cont_link_ext"), "ext");
446 $radg->addOption($ext);
447
448 $ti = new ilTextInputGUI("", "area_link_ext");
449 $ti->setMaxLength(800);
450 $ti->setSize(50);
451 if ($this->map->getExternalLink() != "") {
452 $ti->setValue($this->map->getExternalLink());
453 } else {
454 $ti->setValue("https://");
455 }
456 $ext->addSubItem($ti);
457
458 // internal link
459 $int = new ilRadioOption($lng->txt("cont_link_int"), "int");
460 $radg->addOption($int);
461
462 $ne = new ilNonEditableValueGUI("", "", true);
463 $link_str = "";
464 $int_link = $this->map->getInternalLink();
465 if ($int_link["target"] != "") {
466 $link_str = $this->getMapAreaLinkString(
467 $int_link["target"],
468 $int_link["type"],
469 $int_link["target_frame"]
470 );
471 }
472 $ne->setValue(
473 $link_str .
474 '&nbsp;<a id="iosEditInternalLinkTrigger" href="#">' .
475 "[" . $lng->txt("cont_get_link") . "]" .
476 '</a>'
477 );
478 $int->addSubItem($ne);
479
480 // no link
481 $no = new ilRadioOption($lng->txt("cont_link_no"), "no");
482 $radg->addOption($no);
483
484 $form->addItem($radg);
485 }
486
487
488 // name
489 if ($a_edit_property != "link" && $a_edit_property != "shape") {
490 $ti = new ilTextInputGUI($lng->txt("cont_name"), "area_name");
491 $ti->setMaxLength(200);
492 $ti->setSize(20);
493 $form->addItem($ti);
494 }
495
496 // save and cancel commands
497 $form->setTitle($lng->txt("cont_new_area"));
498 $form->addCommandButton("saveArea", $lng->txt("save"));
499
500 // $form->setFormAction($ilCtrl->getFormAction($this));
501
502 return $form;
503 }
getMapAreaLinkString(string $a_target, string $a_type, string $a_frame)
Get text name of internal link.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property form user interface.
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text property in a property form.

◆ linkWholePicture()

ilImageMapEditorGUI::linkWholePicture ( )

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

225 : string
226 {
227 $this->clearSessionVars();
228 $this->map->setAreaType("WholePicture");
229
230 return $this->editMapArea(false, false, true);
231 }

References 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 ( string  $a_edit_property = "",
int  $a_area_nr = 0,
bool  $a_output_new_area = false,
string  $a_area_type = "",
string  $a_coords = "" 
)

Make work file for editing.

Reimplemented in ilPCImageMapEditorGUI.

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

514 : void {
515 // create/update imagemap work copy
516 $st_item = $this->media_object->getMediaItem("Standard");
517
518 if ($a_edit_property == "shape") {
519 $st_item->makeMapWorkCopy($a_area_nr, true); // exclude area currently being edited
520 } else {
521 $st_item->makeMapWorkCopy($a_area_nr, false);
522 }
523
524 if ($a_output_new_area) {
525 $st_item->addAreaToMapWorkCopy($a_area_type, $a_coords);
526 }
527 }

Referenced by editMapAreas().

+ Here is the caller graph for this function:

◆ outputPostProcessing()

ilImageMapEditorGUI::outputPostProcessing ( string  $a_output)

Reimplemented in ilPCIIMTriggerEditorGUI.

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

585 : string {
586 return $a_output;
587 }

◆ saveArea()

ilImageMapEditorGUI::saveArea ( )

Save new or updated map area.

Reimplemented in ilPCIIMTriggerEditorGUI, and ilPCImageMapEditorGUI.

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

698 : string
699 {
701 $ilCtrl = $this->ctrl;
702
703 switch ($this->map->getMode()) {
704 // save edited link
705 case "edit_link":
706 $st_item = $this->media_object->getMediaItem("Standard");
707 $max = ilMapArea::_getMaxNr($st_item->getId());
708 $area = new ilMapArea($st_item->getId(), $this->map->getAreaNr());
709
710 if ($this->request->getAreaLinkType() == IL_INT_LINK) {
711 $area->setLinkType(IL_INT_LINK);
712 $int_link = $this->map->getInternalLink();
713 $area->setType($int_link["type"] ?? "");
714 $area->setTarget($int_link["target"] ?? "");
715 $area->setTargetFrame($int_link["target_frame"] ?? "");
716 } else {
717 $area->setLinkType(IL_EXT_LINK);
718 if ($this->request->getAreaLinkType() != IL_NO_LINK) {
719 $area->setHref(
720 $this->request->getExternalLink()
721 );
722 } else {
723 $area->setHref("");
724 }
725 }
726 $area->update();
727 break;
728
729 // save edited shape
730 case "edit_shape":
731 $st_item = $this->media_object->getMediaItem("Standard");
732 $max = ilMapArea::_getMaxNr($st_item->getId());
733 $area = new ilMapArea(
734 $st_item->getId(),
735 $this->map->getAreaNr()
736 );
737
738 $area->setShape($this->map->getAreaType());
739 $area->setCoords($this->map->getCoords());
740 $area->update();
741 break;
742
743 // save new area
744 default:
745 $area_type = $this->map->getAreaType();
746 $coords = $this->map->getCoords();
747
748 $st_item = $this->media_object->getMediaItem("Standard");
749 $max = ilMapArea::_getMaxNr($st_item->getId());
750
751 // make new area object
752 $area = new ilMapArea();
753 $area->setItemId($st_item->getId());
754 $area->setShape($area_type);
755 $area->setCoords($coords);
756 $area->setNr($max + 1);
757 $area->setTitle($this->request->getAreaName());
758 switch ($this->request->getAreaLinkType()) {
759 case "ext":
760 $area->setLinkType(IL_EXT_LINK);
761 $area->setHref($this->request->getExternalLink());
762 break;
763
764 case "int":
765 $area->setLinkType(IL_INT_LINK);
766 $int_link = $this->map->getInternalLink();
767 $area->setType($int_link["type"] ?? "");
768 $area->setTarget($int_link["target"] ?? "");
769 $area->setTargetFrame($int_link["type_frame"] ?? "");
770 break;
771 }
772
773 // put area into item and update media object
774 $st_item->addMapArea($area);
775 $this->media_object->update();
776 break;
777 }
778
779 //$this->initMapParameters();
780 $this->main_tpl->setOnScreenMessage('success', $lng->txt("cont_saved_map_area"), true);
781 $ilCtrl->redirect($this, "editMapAreas");
782 return "";
783 }
const IL_INT_LINK
const IL_EXT_LINK
const IL_NO_LINK
Class ilMapArea.

References $lng, ilMapArea\_getMaxNr(), IL_EXT_LINK, IL_INT_LINK, and IL_NO_LINK.

+ Here is the call graph for this function:

◆ setHighlight()

ilImageMapEditorGUI::setHighlight ( )

Set highlight settings.

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

1076 : void
1077 {
1078 $ilCtrl = $this->ctrl;
1079 $lng = $this->lng;
1080
1081 $st_item = $this->media_object->getMediaItem("Standard");
1082 // seems to be obsolete, methods don't exist
1083 //$st_item->setHighlightMode($this->request->getHighlightMode());
1084 //$st_item->setHighlightClass($this->request->getHighlightClass());
1085 $st_item->update();
1086
1087 $this->main_tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
1088 $ilCtrl->redirect($this, "editMapAreas");
1089 }

References $lng.

◆ setInternalLink()

ilImageMapEditorGUI::setInternalLink ( )

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

785 : string
786 {
787 $this->map->setLinkType("int");
788 $this->map->setInternalLink(
789 $this->request->getLinkType(),
790 $this->request->getLinkTarget(),
791 $this->request->getLinkTargetFrame(),
792 $this->request->getLinkAnchor()
793 );
794
795 switch ($this->map->getMode()) {
796 case "edit_link":
797 return $this->setLink();
798
799 default:
800 return $this->addArea();
801 }
802 }

◆ setLink()

ilImageMapEditorGUI::setLink ( bool  $a_handle = true)

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

806 : string {
808 $ilCtrl = $this->ctrl;
809 $area = null;
810 if ($a_handle) {
811 $this->handleMapParameters();
812 }
813 if ($this->map->getAreaNr() > 0) {
814 $area_nr = $this->map->getAreaNr();
815 } else {
816 $area = $this->request->getArea();
817 $area_nr = (int) ($area[0] ?? 0);
818 }
819 if ($area_nr === 0) {
820 $this->main_tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
821 $ilCtrl->redirect($this, "editMapAreas");
822 }
823
824 if (count($area ?? []) > 1) {
825 $this->main_tpl->setOnScreenMessage('failure', $lng->txt("cont_select_max_one_item"), true);
826 $ilCtrl->redirect($this, "editMapAreas");
827 }
828
829
830 if ($this->map->getMode() != "edit_link") {
831 $this->map->setAreaNr($area_nr);
832 $this->map->setLinkType($this->getLinkTypeOfArea($area_nr));
833 $this->map->setMode("edit_link");
834 $this->map->setTargetScript($ilCtrl->getLinkTarget($this, "setLink"));
835 if ($this->map->getLinkType() == IL_INT_LINK) {
836 $this->map->setInternalLink(
837 $this->getTypeOfArea($area_nr),
838 $this->getTargetOfArea($area_nr),
839 $this->getTargetFrameOfArea($area_nr),
840 ""
841 );
842 } else {
843 $this->map->setExternalLink($this->getHrefOfArea($area_nr));
844 }
845 }
846
847 return $this->editMapArea(false, false, true, "link", $area_nr);
848 }
getHrefOfArea(int $a_nr)
Get Href of Area (only external link)
getTargetFrameOfArea(int $a_nr)
Get TargetFrame of Area (only internal link)
getTargetOfArea(int $a_nr)
Get Target of Area (only internal link)
getTypeOfArea(int $a_nr)
Get Type of Area (only internal link)

◆ setShape()

ilImageMapEditorGUI::setShape ( bool  $a_handle = true)

edit shape of existing map area

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

988 : string {
990 $ilCtrl = $this->ctrl;
991
992 $area = [];
993 if ($a_handle) {
994 $this->handleMapParameters();
995 }
996 /* this seems to be obsolete
997 if ($_POST["areatype2"] != "") {
998 $this->map->setAreaType($_POST["areatype2"]);
999 }*/
1000 if ($this->map->getAreaNr() > 0) {
1001 $area_nr = $this->map->getAreaNr();
1002 } else {
1003 $area = $this->request->getArea();
1004 $area_nr = (int) ($area[0] ?? 0);
1005 }
1006 if ($area_nr === 0) {
1007 $this->main_tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
1008 $ilCtrl->redirect($this, "editMapAreas");
1009 }
1010
1011 if (count($area ?? []) > 1) {
1012 $this->main_tpl->setOnScreenMessage('failure', $lng->txt("cont_select_max_one_item"), true);
1013 $ilCtrl->redirect($this, "editMapAreas");
1014 }
1015
1016 if ($this->map->getMode() != "edit_shape") {
1017 $this->map->setAreaNr($area_nr);
1018 $this->map->setMode("edit_shape");
1019 $this->map->setTargetScript(
1020 $ilCtrl->getLinkTarget($this, "setShape", "", false, false)
1021 );
1022 }
1023
1024
1025 $area_type = $this->map->getAreaType();
1026 $coords = $this->map->getCoords();
1027 $cnt_coords = ilMapArea::countCoords($coords);
1028
1029 // decide what to do next
1030 switch ($area_type) {
1031 // Rectangle
1032 case "Rect":
1033 if ($cnt_coords < 2) {
1034 return $this->editMapArea(true, false, false, "shape", $area_nr);
1035 } elseif ($cnt_coords == 2) {
1036 return $this->saveArea();
1037 }
1038 break;
1039
1040 // Circle
1041 case "Circle":
1042 if ($cnt_coords <= 1) {
1043 return $this->editMapArea(true, false, false, "shape", $area_nr);
1044 } else {
1045 if ($cnt_coords == 2) {
1046 $c = explode(",", $coords);
1047 $coords = $c[0] . "," . $c[1] . ","; // determine radius
1048 $coords .= round(sqrt(pow(abs($c[3] - $c[1]), 2) + pow(abs($c[2] - $c[0]), 2)));
1049 }
1050 $this->map->setCoords($coords);
1051 return $this->saveArea();
1052 }
1053
1054 // Polygon
1055 // no break
1056 case "Poly":
1057 if ($cnt_coords < 1) {
1058 return $this->editMapArea(true, false, false, "shape", $area_nr);
1059 } elseif ($cnt_coords < 3) {
1060 return $this->editMapArea(true, true, false, "shape", $area_nr);
1061 } else {
1062 return $this->editMapArea(true, true, true, "shape", $area_nr);
1063 }
1064
1065 // Whole Picture
1066 // no break
1067 case "WholePicture":
1068 return $this->saveArea();
1069 }
1070 return "";
1071 }
saveArea()
Save new or updated map area.

◆ showImageMap()

ilImageMapEditorGUI::showImageMap ( )

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

183 : void
184 {
185 $item = new ilMediaItem($this->request->getItemId());
186 $item->outputMapWorkCopy();
187 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ updateAreas()

ilImageMapEditorGUI::updateAreas ( )

Reimplemented in ilPCImageMapEditorGUI.

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

189 : void
190 {
192 $ilCtrl = $this->ctrl;
193
194 $st_item = $this->media_object->getMediaItem("Standard");
195 $max = ilMapArea::_getMaxNr($st_item->getId());
196 for ($i = 1; $i <= $max; $i++) {
197 $area = new ilMapArea($st_item->getId(), $i);
198 $area->setTitle(
199 $this->request->getAreaTitle($i)
200 );
201 $area->setHighlightMode(
202 $this->request->getAreaHighlightMode($i)
203 );
204 $area->setHighlightClass(
205 $this->request->getAreaHighlightClass($i)
206 );
207 $area->update();
208 }
209
210 $this->main_tpl->setOnScreenMessage('success', $lng->txt("cont_saved_map_data"), true);
211 $ilCtrl->redirect($this, "editMapAreas");
212 }

References $ctrl, $i, $lng, ilMapArea\_getMaxNr(), and ilLanguage\txt().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

◆ $lng

◆ $main_tpl

ilGlobalTemplateInterface ilImageMapEditorGUI::$main_tpl
protected

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

◆ $map

ImageMapManager ilImageMapEditorGUI::$map
protected

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

◆ $media_object

ilObjMediaObject ilImageMapEditorGUI::$media_object
protected

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

◆ $request

ImageMapGUIRequest ilImageMapEditorGUI::$request
protected

◆ $toolbar

ilToolbarGUI ilImageMapEditorGUI::$toolbar
protected

◆ $tpl

ilTemplate ilImageMapEditorGUI::$tpl
protected

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


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