29 protected \ILIAS\COPage\Xsl\XslManager
$xsl;
44 $this->
ctrl = $DIC->ctrl();
45 $this->main_tpl = $DIC->ui()->mainTemplate();
46 $this->
lng = $DIC->language();
47 $this->
toolbar = $DIC->toolbar();
48 $this->media_object = $a_media_object;
50 $this->map = $DIC->mediaObjects()
55 $this->request = $DIC->mediaObjects()
60 $this->xsl = $DIC->copage()->internal()->domain()->xsl();
72 $cmd = $ilCtrl->getCmd();
74 switch ($next_class) {
75 case "ilinternallinkgui":
77 $link_gui->setSetLinkTargetScript(
78 $ilCtrl->getLinkTarget(
83 $link_gui->filterLinkType(
"File");
84 $ret = $ilCtrl->forwardCommand($link_gui);
89 if ($this->request->getX() !=
"" &&
90 $this->request->getY() !=
"") {
91 $cmd =
"editImagemapForward";
104 $ilCtrl->getLinkTarget(
114 $this->tpl =
new ilTemplate(
"tpl.map_edit.html",
true,
true,
"Services/MediaObjects");
115 $this->tpl->setVariable(
"FORMACTION", $ilCtrl->getFormAction($this));
121 $this->tpl->setVariable(
"IMAGE_MAP", $output);
123 $this->tpl->setVariable(
"TOOLBAR", $this->
getToolbar()->getHTML());
128 return $this->tpl->get();
138 $tb->setFormAction($ilCtrl->getFormAction($this));
140 "WholePicture" => $lng->
txt(
"cont_WholePicture"),
141 "Rect" => $lng->
txt(
"cont_Rect"),
142 "Circle" => $lng->
txt(
"cont_Circle"),
143 "Poly" => $lng->
txt(
"cont_Poly"),
147 $tb->addInputItem($si,
true);
148 $tb->addFormButton($lng->
txt(
"cont_add_area"),
"addNewArea");
156 return $lng->
txt(
"cont_imagemap");
162 $image_map_table =
new ilImageMapTableGUI($this,
"editMapAreas", $this->media_object);
163 return $image_map_table->getHTML();
168 if ($this->request->getRefId() > 0) {
169 $this->map->setRefId($this->request->getRefId());
172 if ($this->request->getObjId() > 0) {
173 $this->map->setObjId($this->request->getObjId());
176 if ($this->request->getHierId() !=
"") {
177 $this->map->setHierId($this->request->getHierId());
180 if ($this->request->getPCId() !=
"") {
181 $this->map->setPCId($this->request->getPCId());
187 $item =
new ilMediaItem($this->request->getItemId());
196 $st_item = $this->media_object->getMediaItem(
"Standard");
198 for ($i = 1; $i <= $max; $i++) {
199 $area =
new ilMapArea($st_item->getId(), $i);
201 $this->request->getAreaTitle($i)
203 $area->setHighlightMode(
204 $this->request->getAreaHighlightMode($i)
206 $area->setHighlightClass(
207 $this->request->getAreaHighlightClass($i)
212 $this->main_tpl->setOnScreenMessage(
'success', $lng->
txt(
"cont_saved_map_data"),
true);
213 $ilCtrl->redirect($this,
"editMapAreas");
218 switch ($this->request->getAreaShape()) {
221 case "Circle":
return $this->
addCircle();
230 $this->map->setAreaType(
"WholePicture");
238 $this->map->setAreaType(
"Rect");
245 $this->map->setAreaType(
"Circle");
252 $this->map->setAreaType(
"Poly");
262 bool $a_handle =
true 269 $area_type = $this->map->getAreaType();
270 $coords = $this->map->getCoords();
274 switch ($area_type) {
277 if ($cnt_coords < 2) {
280 } elseif ($cnt_coords == 2) {
287 if ($cnt_coords <= 1) {
290 if ($cnt_coords == 2) {
291 $c = explode(
",", $coords);
292 $coords =
$c[0] .
"," .
$c[1] .
",";
293 $coords .= round(sqrt(pow(abs(
$c[3] -
$c[1]), 2) + pow(abs(
$c[2] -
$c[0]), 2)));
295 $this->map->setCoords($coords);
303 if ($cnt_coords < 1) {
305 } elseif ($cnt_coords < 3) {
329 bool $a_get_next_coordinate =
false,
330 bool $a_output_new_area =
false,
331 bool $a_save_form =
false,
332 string $a_edit_property =
"",
338 $area_type = $this->map->getAreaType();
339 $coords = $this->map->getCoords();
342 $this->tpl =
new ilTemplate(
"tpl.map_edit.html",
true,
true,
"Services/MediaObjects");
344 $this->tpl->setVariable(
"FORMACTION", $ilCtrl->getFormAction($this));
346 if ($a_edit_property !=
"link") {
347 switch ($area_type) {
350 if ($cnt_coords == 0) {
351 $this->main_tpl->setOnScreenMessage(
'info', $lng->
txt(
"cont_click_tl_corner"));
353 if ($cnt_coords == 1) {
354 $this->main_tpl->setOnScreenMessage(
'info', $lng->
txt(
"cont_click_br_corner"));
360 if ($cnt_coords == 0) {
361 $this->main_tpl->setOnScreenMessage(
'info', $lng->
txt(
"cont_click_center"));
363 if ($cnt_coords == 1) {
364 $this->main_tpl->setOnScreenMessage(
'info', $lng->
txt(
"cont_click_circle"));
370 if ($cnt_coords == 0) {
371 $this->main_tpl->setOnScreenMessage(
'info', $lng->
txt(
"cont_click_starting_point"));
372 } elseif ($cnt_coords < 3) {
373 $this->main_tpl->setOnScreenMessage(
'info', $lng->
txt(
"cont_click_next_point"));
375 $this->main_tpl->setOnScreenMessage(
'info', $lng->
txt(
"cont_click_next_or_save"));
384 if ($a_edit_property !=
"shape") {
386 $ilCtrl->setParameter($this,
"linkmode",
"map");
387 $this->tpl->setCurrentBlock(
"int_link_prep");
389 $ilCtrl->getLinkTargetByClass(
397 $this->tpl->parseCurrentBlock();
400 $this->tpl->setVariable(
"FORM", $form->getHTML());
411 $edit_mode = ($a_get_next_coordinate)
413 : (($a_output_new_area)
417 $this->tpl->setVariable(
"IMAGE_MAP", $output);
419 return $this->tpl->get();
423 string $a_edit_property
428 $form->setOpenTag(
false);
429 $form->setCloseTag(
false);
432 if ($a_edit_property !=
"shape") {
435 if ($this->map->getLinkType() !=
"int") {
436 if ($this->map->getExternalLink() ==
"") {
439 $radg->setValue(
"ext");
442 $radg->setValue(
"int");
447 $radg->addOption($ext);
450 $ti->setMaxLength(800);
452 if ($this->map->getExternalLink() !=
"") {
453 $ti->setValue($this->map->getExternalLink());
455 $ti->setValue(
"https://");
457 $ext->addSubItem($ti);
461 $radg->addOption($int);
465 $int_link = $this->map->getInternalLink();
466 if ($int_link[
"target"] !=
"") {
470 $int_link[
"target_frame"]
475 ' <a id="iosEditInternalLinkTrigger" href="#">' .
476 "[" . $lng->
txt(
"cont_get_link") .
"]" .
479 $int->addSubItem($ne);
483 $radg->addOption($no);
485 $form->addItem($radg);
490 if ($a_edit_property !=
"link" && $a_edit_property !=
"shape") {
492 $ti->setMaxLength(200);
498 $form->setTitle($lng->
txt(
"cont_new_area"));
499 $form->addCommandButton(
"saveArea", $lng->
txt(
"save"));
510 string $a_edit_property =
"",
512 bool $a_output_new_area =
false,
513 string $a_area_type =
"",
514 string $a_coords =
"" 517 $st_item = $this->media_object->getMediaItem(
"Standard");
519 if ($a_edit_property ==
"shape") {
520 $st_item->makeMapWorkCopy($a_area_nr,
true);
522 $st_item->makeMapWorkCopy($a_area_nr,
false);
525 if ($a_output_new_area) {
526 $st_item->addAreaToMapWorkCopy($a_area_type, $a_coords);
534 string $a_map_edit_mode =
"" 538 $st_item = $this->media_object->getMediaItem(
"Standard");
551 $random = new \ilRandom();
552 $params = array(
'map_edit_mode' => $a_map_edit_mode,
553 'map_item' => $st_item->getId(),
554 'map_mob_id' => $this->media_object->getId(),
556 'media_mode' =>
'enable',
557 'image_map_link' => $ilCtrl->getLinkTarget($this,
"showImageMap",
"",
false,
false),
558 'link_params' =>
"ref_id=" . $this->request->getRefId() .
"&rand=" . $random->int(1, 999999),
559 'ref_id' => $this->request->getRefId(),
562 'webspace_path' => $wb_path);
563 $output = $this->xsl->process($xml,
$params);
604 $t_arr = explode(
"_", $a_target);
605 if ($a_frame !=
"") {
606 $frame_str =
" (" . $a_frame .
" Frame)";
609 case "StructureObject":
611 $link_str = $lng->
txt(
"chapter") .
612 ": " . $title .
" [" . $t_arr[count($t_arr) - 1] .
"]" . $frame_str;
617 $link_str = $lng->
txt(
"page") .
618 ": " . $title .
" [" . $t_arr[count($t_arr) - 1] .
"]" . $frame_str;
623 $link_str = $lng->
txt(
"term") .
624 ": " . $term->getTerm() .
" [" . $t_arr[count($t_arr) - 1] .
"]" . $frame_str;
629 $link_str = $lng->
txt(
"mob") .
630 ": " . $mob->getTitle() .
" [" . $t_arr[count($t_arr) - 1] .
"]" . $frame_str;
633 case "RepositoryItem":
634 if (trim($a_target) !==
"") {
638 $link_str = $lng->
txt(
"obj_" . $t_arr[count($t_arr) - 2]) .
639 ": " . $title .
" [" . $t_arr[count($t_arr) - 1] .
"]" . $frame_str;
647 $wpg =
new ilWikiPage($t_arr[count($t_arr) - 1]);
648 $link_str = $lng->
txt(
"cont_wiki_page") .
649 ": " . $wpg->getTitle() .
" [" . $t_arr[count($t_arr) - 1] .
"]" . $frame_str;
664 $coords = $this->map->getCoords();
669 $this->map->setCoords($coords . $this->request->getX() .
"," .
670 $this->request->getY());
683 $map = $DIC->mediaObjects()->internal()->domain()->imageMap();
699 switch ($this->map->getMode()) {
702 $st_item = $this->media_object->getMediaItem(
"Standard");
704 $area =
new ilMapArea($st_item->getId(), $this->map->getAreaNr());
706 if ($this->request->getAreaLinkType() ==
IL_INT_LINK) {
708 $int_link = $this->map->getInternalLink();
709 $area->setType($int_link[
"type"] ??
"");
710 $area->setTarget($int_link[
"target"] ??
"");
711 $area->setTargetFrame($int_link[
"target_frame"] ??
"");
714 if ($this->request->getAreaLinkType() !=
IL_NO_LINK) {
716 $this->request->getExternalLink()
727 $st_item = $this->media_object->getMediaItem(
"Standard");
731 $this->map->getAreaNr()
734 $area->
setShape($this->map->getAreaType());
735 $area->setCoords($this->map->getCoords());
741 $area_type = $this->map->getAreaType();
742 $coords = $this->map->getCoords();
744 $st_item = $this->media_object->getMediaItem(
"Standard");
749 $area->setItemId($st_item->getId());
750 $area->setShape($area_type);
751 $area->setCoords($coords);
752 $area->setNr($max + 1);
753 $area->setTitle($this->request->getAreaName());
754 switch ($this->request->getAreaLinkType()) {
757 $area->setHref($this->request->getExternalLink());
762 $int_link = $this->map->getInternalLink();
763 $area->setType($int_link[
"type"] ??
"");
764 $area->setTarget($int_link[
"target"] ??
"");
765 $area->setTargetFrame($int_link[
"type_frame"] ??
"");
770 $st_item->addMapArea($area);
771 $this->media_object->update();
776 $this->main_tpl->setOnScreenMessage(
'success', $lng->
txt(
"cont_saved_map_area"),
true);
777 $ilCtrl->redirect($this,
"editMapAreas");
783 $this->map->setLinkType(
"int");
784 $this->map->setInternalLink(
785 $this->request->getLinkType(),
786 $this->request->getLinkTarget(),
787 $this->request->getLinkTargetFrame(),
788 $this->request->getLinkAnchor()
791 switch ($this->map->getMode()) {
801 bool $a_handle =
true 809 if ($this->map->getAreaNr() > 0) {
810 $area_nr = $this->map->getAreaNr();
812 $area = $this->request->getArea();
813 $area_nr = (
int) ($area[0] ?? 0);
815 if ($area_nr === 0) {
816 $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
"no_checkbox"),
true);
817 $ilCtrl->redirect($this,
"editMapAreas");
820 if (count($area ?? []) > 1) {
821 $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
"cont_select_max_one_item"),
true);
822 $ilCtrl->redirect($this,
"editMapAreas");
826 if ($this->map->getMode() !=
"edit_link") {
827 $this->map->setAreaNr($area_nr);
829 $this->map->setMode(
"edit_link");
830 $this->map->setTargetScript($ilCtrl->getLinkTarget($this,
"setLink"));
832 $this->map->setInternalLink(
843 return $this->
editMapArea(
false,
false,
true,
"link", $area_nr);
849 $st_item = $this->media_object->getMediaItem(
"Standard");
850 $area = $st_item->getMapArea($a_nr);
851 return $area->getLinkType();
860 $st_item = $this->media_object->getMediaItem(
"Standard");
861 $area = $st_item->getMapArea($a_nr);
862 return $area->getType();
871 $st_item = $this->media_object->getMediaItem(
"Standard");
872 $area = $st_item->getMapArea($a_nr);
873 return $area->getTarget();
882 $st_item = $this->media_object->getMediaItem(
"Standard");
883 $area = $st_item->getMapArea($a_nr);
884 return $area->getTargetFrame();
893 $st_item = $this->media_object->getMediaItem(
"Standard");
894 $area = $st_item->getMapArea($a_nr);
895 return $area->getHref();
906 $area = $this->request->getArea();
907 if (count($area) == 0) {
908 $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
"no_checkbox"),
true);
909 $ilCtrl->redirect($this,
"editMapAreas");
912 $st_item = $this->media_object->getMediaItem(
"Standard");
915 if (count($area) > 0) {
918 foreach ($area as $area_nr) {
919 $st_item->deleteMapArea($area_nr - $i);
923 $this->media_object->update();
924 $this->main_tpl->setOnScreenMessage(
'success', $lng->
txt(
"cont_areas_deleted"),
true);
927 $ilCtrl->redirect($this,
"editMapAreas");
945 $this->map->setAreaType(
"WholePicture");
955 $this->map->setAreaType(
"Rect");
965 $this->map->setAreaType(
"Circle");
975 $this->map->setAreaType(
"Poly");
983 bool $a_handle =
true 996 if ($this->map->getAreaNr() > 0) {
997 $area_nr = $this->map->getAreaNr();
999 $area = $this->request->getArea();
1000 $area_nr = (
int) ($area[0] ?? 0);
1002 if ($area_nr === 0) {
1003 $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
"no_checkbox"),
true);
1004 $ilCtrl->redirect($this,
"editMapAreas");
1007 if (count($area ?? []) > 1) {
1008 $this->main_tpl->setOnScreenMessage(
'failure', $lng->
txt(
"cont_select_max_one_item"),
true);
1009 $ilCtrl->redirect($this,
"editMapAreas");
1012 if ($this->map->getMode() !=
"edit_shape") {
1013 $this->map->setAreaNr($area_nr);
1014 $this->map->setMode(
"edit_shape");
1015 $this->map->setTargetScript(
1016 $ilCtrl->getLinkTarget($this,
"setShape",
"",
false,
false)
1021 $area_type = $this->map->getAreaType();
1022 $coords = $this->map->getCoords();
1026 switch ($area_type) {
1029 if ($cnt_coords < 2) {
1030 return $this->
editMapArea(
true,
false,
false,
"shape", $area_nr);
1031 } elseif ($cnt_coords == 2) {
1038 if ($cnt_coords <= 1) {
1039 return $this->
editMapArea(
true,
false,
false,
"shape", $area_nr);
1041 if ($cnt_coords == 2) {
1042 $c = explode(
",", $coords);
1043 $coords =
$c[0] .
"," .
$c[1] .
",";
1044 $coords .= round(sqrt(pow(abs(
$c[3] -
$c[1]), 2) + pow(abs(
$c[2] -
$c[0]), 2)));
1046 $this->map->setCoords($coords);
1053 if ($cnt_coords < 1) {
1054 return $this->
editMapArea(
true,
false,
false,
"shape", $area_nr);
1055 } elseif ($cnt_coords < 3) {
1056 return $this->
editMapArea(
true,
true,
false,
"shape", $area_nr);
1058 return $this->
editMapArea(
true,
true,
true,
"shape", $area_nr);
1063 case "WholePicture":
1077 $st_item = $this->media_object->getMediaItem(
"Standard");
1083 $this->main_tpl->setOnScreenMessage(
'success', $lng->
txt(
"msg_obj_modified"),
true);
1084 $ilCtrl->redirect($this,
"editMapAreas");
static getWebspaceDir(string $mode="filesystem")
get webspace directory
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
getImageMapOutput(string $a_map_edit_mode="")
Render the image map.
ImageMapGUIRequest $request
setTitle(string $a_title)
set (tooltip)title of area
editShapeWholePicture()
Edit an existing shape (make it a whole picture link)
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...
setLink(bool $a_handle=true)
saveArea()
Save new or updated map area.
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilObjMediaObject $a_media_object)
getTargetOfArea(int $a_nr)
Get Target of Area (only internal link)
getLinkTypeOfArea(int $a_nr)
static _getMaxNr(int $a_item_id)
get maximum nr of media item (static)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
getMapAreaLinkString(string $a_target, string $a_type, string $a_frame)
Get text name of internal link.
ILIAS COPage Xsl XslManager $xsl
setShape(string $a_shape)
set shape (IL_AREA_RECT, IL_AREA_CIRCLE, IL_AREA_POLY, IL_AREA_WHOLE_PICTURE)
initAreaEditingForm(string $a_edit_property)
getHrefOfArea(int $a_nr)
Get Href of Area (only external link)
static _lookupObjId(int $ref_id)
static _lookupTitle(int $a_obj_id)
getTargetFrameOfArea(int $a_nr)
Get TargetFrame of Area (only internal link)
editShapeCircle()
Edit an existing shape (make it a circle)
setHighlight()
Set highlight settings.
getNextClass($a_gui_class=null)
static _lookupTitle(int $obj_id)
outputPostProcessing(string $a_output)
static countCoords(string $c)
count the number of coordinates (x,y) in a coordinate string (format: "x1,y1,x2,y2,x3,y3,...")
setLinkType(string $a_link_type)
set link type
editLink()
Edit existing link.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
deleteAreas()
Delete map areas.
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.
ilObjMediaObject $media_object
static redirect(string $a_script)
User interface class for map editor.
setShape(bool $a_handle=true)
edit shape of existing map area
static _recoverParameters()
Recover parameters from session variables (static)
editShapePolygon()
Edit an existing shape (make it a polygon)
editImagemapForward()
Get image map coordinates.
setTargetScript(string $a_target_script)
getTypeOfArea(int $a_nr)
Get Type of Area (only internal link)
getAdditionalPageXML()
Get additional page xml (to be overwritten)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addArea(bool $a_handle=true)
ilGlobalTemplateInterface $main_tpl
editShapeRectangle()
Edit an existing shape (make it a rectangle)