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,
"components/ILIAS/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());
188 $this->request->getOutEditProperty(),
189 $this->request->getOutAreaNr(),
190 $this->request->getOutOutputNewArea(),
191 $this->request->getOutAreaType(),
192 $this->request->getOutCoords()
196 $item->outputMapWorkCopy();
204 $st_item = $this->media_object->getMediaItem(
"Standard");
206 for ($i = 1; $i <= $max; $i++) {
207 if (!$this->request->hasRow($i)) {
210 $area =
new ilMapArea($st_item->getId(), $i);
212 $this->request->getAreaTitle($i)
214 $area->setHighlightMode(
215 $this->request->getAreaHighlightMode($i)
217 $area->setHighlightClass(
218 $this->request->getAreaHighlightClass($i)
223 $this->main_tpl->setOnScreenMessage(
'success',
$lng->
txt(
"cont_saved_map_data"),
true);
224 $ilCtrl->redirect($this,
"editMapAreas");
229 switch ($this->request->getAreaShape()) {
232 case "Circle":
return $this->
addCircle();
241 $this->map->setAreaType(
"WholePicture");
249 $this->map->setAreaType(
"Rect");
256 $this->map->setAreaType(
"Circle");
263 $this->map->setAreaType(
"Poly");
273 bool $a_handle =
true
280 $area_type = $this->map->getAreaType();
281 $coords = $this->map->getCoords();
285 switch ($area_type) {
288 if ($cnt_coords < 2) {
291 } elseif ($cnt_coords == 2) {
298 if ($cnt_coords <= 1) {
301 if ($cnt_coords == 2) {
302 $c = explode(
",", $coords);
303 $coords =
$c[0] .
"," .
$c[1] .
",";
304 $coords .= round(sqrt(pow(abs(
$c[3] -
$c[1]), 2) + pow(abs(
$c[2] -
$c[0]), 2)));
306 $this->map->setCoords($coords);
314 if ($cnt_coords < 1) {
316 } elseif ($cnt_coords < 3) {
340 bool $a_get_next_coordinate =
false,
341 bool $a_output_new_area =
false,
342 bool $a_save_form =
false,
343 string $a_edit_property =
"",
346 $ilCtrl = $this->
ctrl;
349 $area_type = $this->map->getAreaType();
350 $coords = $this->map->getCoords();
353 $this->tpl =
new ilTemplate(
"tpl.map_edit.html",
true,
true,
"components/ILIAS/MediaObjects");
355 $this->tpl->setVariable(
"FORMACTION", $ilCtrl->getFormAction($this));
357 if ($a_edit_property !=
"link") {
358 switch ($area_type) {
361 if ($cnt_coords == 0) {
362 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"cont_click_tl_corner"));
364 if ($cnt_coords == 1) {
365 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"cont_click_br_corner"));
371 if ($cnt_coords == 0) {
372 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"cont_click_center"));
374 if ($cnt_coords == 1) {
375 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"cont_click_circle"));
381 if ($cnt_coords == 0) {
382 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"cont_click_starting_point"));
383 } elseif ($cnt_coords < 3) {
384 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"cont_click_next_point"));
386 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"cont_click_next_or_save"));
395 if ($a_edit_property !=
"shape") {
397 $ilCtrl->setParameter($this,
"linkmode",
"map");
398 $this->tpl->setCurrentBlock(
"int_link_prep");
400 $ilCtrl->getLinkTargetByClass(
408 $this->tpl->parseCurrentBlock();
410 $form = $this->initAreaEditingForm($a_edit_property);
411 $this->tpl->setVariable(
"FORM", $form->getHTML());
414 $ilCtrl->setParameter($this,
"out_edit_property", $a_edit_property);
415 $ilCtrl->setParameter($this,
"out_area_nr", $a_area_nr);
416 $ilCtrl->setParameter($this,
"out_output_new_area", (
int) $a_output_new_area);
417 $ilCtrl->setParameter($this,
"out_area_type", $area_type);
418 $ilCtrl->setParameter($this,
"out_coords", $coords);
420 $edit_mode = ($a_get_next_coordinate)
422 : (($a_output_new_area)
426 $output = $this->getImageMapOutput($edit_mode);
427 $this->tpl->setVariable(
"IMAGE_MAP", $output);
429 return $this->tpl->get();
433 string $a_edit_property
438 $form->setOpenTag(
false);
439 $form->setCloseTag(
false);
442 if ($a_edit_property !=
"shape") {
445 if ($this->map->getLinkType() !=
"int") {
446 if ($this->map->getExternalLink() ==
"") {
447 $radg->setValue(
"no");
449 $radg->setValue(
"ext");
452 $radg->setValue(
"int");
457 $radg->addOption($ext);
460 $ti->setMaxLength(800);
462 if ($this->map->getExternalLink() !=
"") {
463 $ti->setValue($this->map->getExternalLink());
465 $ti->setValue(
"https://");
467 $ext->addSubItem($ti);
471 $radg->addOption($int);
475 $int_link = $this->map->getInternalLink();
476 if ($int_link[
"target"] !=
"") {
477 $link_str = $this->getMapAreaLinkString(
480 $int_link[
"target_frame"]
485 ' <a id="iosEditInternalLinkTrigger" href="#">' .
486 "[" .
$lng->txt(
"cont_get_link") .
"]" .
489 $int->addSubItem($ne);
493 $radg->addOption($no);
495 $form->addItem($radg);
500 if ($a_edit_property !=
"link" && $a_edit_property !=
"shape") {
502 $ti->setMaxLength(200);
508 $form->setTitle(
$lng->txt(
"cont_new_area"));
509 $form->addCommandButton(
"saveArea",
$lng->txt(
"save"));
520 string $a_edit_property =
"",
522 bool $a_output_new_area =
false,
523 string $a_area_type =
"",
524 string $a_coords =
""
527 $st_item = $this->media_object->getMediaItem(
"Standard");
529 if ($a_edit_property ==
"shape") {
532 $st_item->makeMapWorkCopy($a_area_nr,
false);
535 if ($a_output_new_area) {
536 $st_item->addAreaToMapWorkCopy($a_area_type, $a_coords);
546 string $a_map_edit_mode =
""
548 $ilCtrl = $this->
ctrl;
550 $st_item = $this->media_object->getMediaItem(
"Standard");
554 $xml .= $this->getAliasXML();
556 $xml .= $this->getAdditionalPageXML();
563 $random = new \Random\Randomizer();
564 $params = array(
'map_edit_mode' => $a_map_edit_mode,
565 'map_item' => $st_item->getId(),
566 'map_mob_id' => $this->media_object->getId(),
568 'media_mode' =>
'enable',
569 'image_map_link' => $ilCtrl->getLinkTarget($this,
"showImageMap",
"",
false,
false),
570 'link_params' =>
"ref_id=" . $this->request->getRefId() .
"&rand=" . $random->getInt(1, 999999),
571 'ref_id' => $this->request->getRefId(),
574 'webspace_path' => $wb_path);
575 $output = $this->xsl->process($xml,
$params);
577 $output = $this->outputPostProcessing($output);
616 $t_arr = explode(
"_", $a_target);
617 if ($a_frame !=
"") {
618 $frame_str =
" (" . $a_frame .
" Frame)";
621 case "StructureObject":
622 $id = (
int) $t_arr[count($t_arr) - 1];
625 $link_str =
$lng->txt(
"chapter") .
626 ": " . $title .
" [" . $t_arr[count($t_arr) - 1] .
"]" . $frame_str;
631 $id = (
int) $t_arr[count($t_arr) - 1];
634 $link_str =
$lng->txt(
"page") .
635 ": " . $title .
" [" . $t_arr[count($t_arr) - 1] .
"]" . $frame_str;
640 $id = (
int) $t_arr[count($t_arr) - 1];
643 $link_str =
$lng->txt(
"term") .
644 ": " . $term->getTerm() .
" [" . $t_arr[count($t_arr) - 1] .
"]" . $frame_str;
649 $id = (
int) $t_arr[count($t_arr) - 1];
652 $link_str =
$lng->txt(
"mob") .
653 ": " . $mob->getTitle() .
" [" . $t_arr[count($t_arr) - 1] .
"]" . $frame_str;
657 case "RepositoryItem":
658 if (trim($a_target) !==
"") {
659 $id = (
int) $t_arr[count($t_arr) - 1];
665 $link_str =
$lng->txt(
"obj_" . $t_arr[count($t_arr) - 2]) .
666 ": " . $title .
" [" . $t_arr[count($t_arr) - 1] .
"]" . $frame_str;
675 $id = (
int) $t_arr[count($t_arr) - 1];
678 $link_str =
$lng->txt(
"cont_wiki_page") .
679 ": " . $wpg->getTitle() .
" [" . $t_arr[count($t_arr) - 1] .
"]" . $frame_str;
695 $coords = $this->map->getCoords();
700 $this->map->setCoords($coords . $this->request->getX() .
"," .
701 $this->request->getY());
714 $map =
$DIC->mediaObjects()->internal()->domain()->imageMap();
728 $ilCtrl = $this->ctrl;
730 switch ($this->map->getMode()) {
733 $st_item = $this->media_object->getMediaItem(
"Standard");
735 $area =
new ilMapArea($st_item->getId(), $this->map->getAreaNr());
737 if ($this->request->getAreaLinkType() ==
IL_INT_LINK) {
739 $int_link = $this->map->getInternalLink();
740 $area->setType($int_link[
"type"] ??
"");
741 $area->setTarget($int_link[
"target"] ??
"");
742 $area->setTargetFrame($int_link[
"target_frame"] ??
"");
745 if ($this->request->getAreaLinkType() !=
IL_NO_LINK) {
747 $this->request->getExternalLink()
758 $st_item = $this->media_object->getMediaItem(
"Standard");
762 $this->map->getAreaNr()
765 $area->setShape($this->map->getAreaType());
766 $area->setCoords($this->map->getCoords());
772 $area_type = $this->map->getAreaType();
773 $coords = $this->map->getCoords();
775 $st_item = $this->media_object->getMediaItem(
"Standard");
780 $area->setItemId($st_item->getId());
781 $area->setShape($area_type);
782 $area->setCoords($coords);
783 $area->setNr($max + 1);
784 $area->setTitle($this->request->getAreaName());
785 switch ($this->request->getAreaLinkType()) {
788 $area->setHref($this->request->getExternalLink());
793 $int_link = $this->map->getInternalLink();
794 $area->setType($int_link[
"type"] ??
"");
795 $area->setTarget($int_link[
"target"] ??
"");
796 $area->setTargetFrame($int_link[
"type_frame"] ??
"");
801 $st_item->addMapArea($area);
802 $this->media_object->update();
807 $this->main_tpl->setOnScreenMessage(
'success',
$lng->txt(
"cont_saved_map_area"),
true);
808 $ilCtrl->redirect($this,
"editMapAreas");
814 $this->map->setLinkType(
"int");
815 $this->map->setInternalLink(
816 $this->request->getLinkType(),
817 $this->request->getLinkTarget(),
818 $this->request->getLinkTargetFrame(),
819 $this->request->getLinkAnchor()
822 switch ($this->map->getMode()) {
824 return $this->setLink();
827 return $this->addArea();
832 bool $a_handle =
true
835 $ilCtrl = $this->ctrl;
838 $this->handleMapParameters();
840 if ($this->map->getAreaNr() > 0) {
841 $area_nr = $this->map->getAreaNr();
843 $area = $this->request->getArea();
844 $area_nr = (
int) ($area[0] ?? 0);
846 if ($area_nr === 0) {
847 $this->main_tpl->setOnScreenMessage(
'failure',
$lng->txt(
"no_checkbox"),
true);
848 $ilCtrl->redirect($this,
"editMapAreas");
851 if (count($area ?? []) > 1) {
852 $this->main_tpl->setOnScreenMessage(
'failure',
$lng->txt(
"cont_select_max_one_item"),
true);
853 $ilCtrl->redirect($this,
"editMapAreas");
857 if ($this->map->getMode() !=
"edit_link") {
858 $this->map->setAreaNr($area_nr);
859 $this->map->setLinkType($this->getLinkTypeOfArea($area_nr));
860 $this->map->setMode(
"edit_link");
861 $this->map->setTargetScript($ilCtrl->getLinkTarget($this,
"setLink"));
863 $this->map->setInternalLink(
864 $this->getTypeOfArea($area_nr),
865 $this->getTargetOfArea($area_nr),
866 $this->getTargetFrameOfArea($area_nr),
870 $this->map->setExternalLink($this->getHrefOfArea($area_nr));
874 return $this->editMapArea(
false,
false,
true,
"link", $area_nr);
880 $st_item = $this->media_object->getMediaItem(
"Standard");
881 $area = $st_item->getMapArea($a_nr);
882 return $area->getLinkType();
891 $st_item = $this->media_object->getMediaItem(
"Standard");
892 $area = $st_item->getMapArea($a_nr);
893 return $area->getType();
902 $st_item = $this->media_object->getMediaItem(
"Standard");
903 $area = $st_item->getMapArea($a_nr);
904 return $area->getTarget();
913 $st_item = $this->media_object->getMediaItem(
"Standard");
914 $area = $st_item->getMapArea($a_nr);
915 return $area->getTargetFrame();
924 $st_item = $this->media_object->getMediaItem(
"Standard");
925 $area = $st_item->getMapArea($a_nr);
926 return $area->getHref();
934 $ilCtrl = $this->ctrl;
937 $area = $this->request->getArea();
938 if (count($area) == 0) {
939 $this->main_tpl->setOnScreenMessage(
'failure',
$lng->txt(
"no_checkbox"),
true);
940 $ilCtrl->redirect($this,
"editMapAreas");
943 $st_item = $this->media_object->getMediaItem(
"Standard");
946 if (count($area) > 0) {
949 foreach ($area as $area_nr) {
950 $st_item->deleteMapArea($area_nr - $i);
954 $this->media_object->update();
955 $this->main_tpl->setOnScreenMessage(
'success',
$lng->txt(
"cont_areas_deleted"),
true);
958 $ilCtrl->redirect($this,
"editMapAreas");
967 return $this->setLink(
false);
975 $this->clearSessionVars();
976 $this->map->setAreaType(
"WholePicture");
977 return $this->setShape(
false);
985 $this->clearSessionVars();
986 $this->map->setAreaType(
"Rect");
987 return $this->setShape(
false);
995 $this->clearSessionVars();
996 $this->map->setAreaType(
"Circle");
997 return $this->setShape(
false);
1005 $this->clearSessionVars();
1006 $this->map->setAreaType(
"Poly");
1007 return $this->setShape(
false);
1014 bool $a_handle =
true
1017 $ilCtrl = $this->ctrl;
1021 $this->handleMapParameters();
1023 if ($this->map->getAreaNr() > 0) {
1024 $area_nr = $this->map->getAreaNr();
1026 $area = $this->request->getArea();
1027 $area_nr = (
int) ($area[0] ?? 0);
1029 if ($area_nr === 0) {
1030 $this->main_tpl->setOnScreenMessage(
'failure',
$lng->txt(
"no_checkbox"),
true);
1031 $ilCtrl->redirect($this,
"editMapAreas");
1034 if (count($area ?? []) > 1) {
1035 $this->main_tpl->setOnScreenMessage(
'failure',
$lng->txt(
"cont_select_max_one_item"),
true);
1036 $ilCtrl->redirect($this,
"editMapAreas");
1039 if ($this->map->getMode() !=
"edit_shape") {
1040 $this->map->setAreaNr($area_nr);
1041 $this->map->setMode(
"edit_shape");
1042 $this->map->setTargetScript(
1043 $ilCtrl->getLinkTarget($this,
"setShape",
"",
false,
false)
1048 $area_type = $this->map->getAreaType();
1049 $coords = $this->map->getCoords();
1053 switch ($area_type) {
1056 if ($cnt_coords < 2) {
1057 return $this->editMapArea(
true,
false,
false,
"shape", $area_nr);
1058 } elseif ($cnt_coords == 2) {
1059 return $this->saveArea();
1065 if ($cnt_coords <= 1) {
1066 return $this->editMapArea(
true,
false,
false,
"shape", $area_nr);
1068 if ($cnt_coords == 2) {
1069 $c = explode(
",", $coords);
1070 $coords =
$c[0] .
"," .
$c[1] .
",";
1071 $coords .= round(sqrt(pow(abs(
$c[3] -
$c[1]), 2) + pow(abs(
$c[2] -
$c[0]), 2)));
1073 $this->map->setCoords($coords);
1074 return $this->saveArea();
1080 if ($cnt_coords < 1) {
1081 return $this->editMapArea(
true,
false,
false,
"shape", $area_nr);
1082 } elseif ($cnt_coords < 3) {
1083 return $this->editMapArea(
true,
true,
false,
"shape", $area_nr);
1085 return $this->editMapArea(
true,
true,
true,
"shape", $area_nr);
1090 case "WholePicture":
1091 return $this->saveArea();
1101 $ilCtrl = $this->ctrl;
1104 $st_item = $this->media_object->getMediaItem(
"Standard");
1110 $this->main_tpl->setOnScreenMessage(
'success',
$lng->txt(
"msg_obj_modified"),
true);
1111 $ilCtrl->redirect($this,
"editMapAreas");
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Class ilCtrl provides processing control methods.
getNextClass($a_gui_class=null)
@inheritDoc
setTargetScript(string $a_target_script)
@inheritDoc
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...
static _exists(int $a_id)
checks whether a glossary term with specified id exists or not
User interface class for map editor.
__construct(ilObjMediaObject $a_media_object)
getHrefOfArea(int $a_nr)
Get Href of Area (only external link)
static _recoverParameters()
Recover parameters from session variables (static)
getTargetFrameOfArea(int $a_nr)
Get TargetFrame of Area (only internal link)
editImagemapForward()
Get image map coordinates.
getTargetOfArea(int $a_nr)
Get Target of Area (only internal link)
ilObjMediaObject $media_object
deleteAreas()
Delete map areas.
initAreaEditingForm(string $a_edit_property)
ilGlobalTemplateInterface $main_tpl
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.
editLink()
Edit existing link.
setLink(bool $a_handle=true)
ILIAS COPage Xsl XslManager $xsl
setShape(bool $a_handle=true)
edit shape of existing map area
getAdditionalPageXML()
Get additional page xml (to be overwritten)
addArea(bool $a_handle=true)
setHighlight()
Set highlight settings.
editShapeWholePicture()
Edit an existing shape (make it a whole picture link)
getMapAreaLinkString(string $a_target, string $a_type, string $a_frame)
Get text name of internal link.
getLinkTypeOfArea(int $a_nr)
getImageMapOutput(string $a_map_edit_mode="")
Render the image map.
editShapeRectangle()
Edit an existing shape (make it a rectangle)
ImageMapGUIRequest $request
saveArea()
Save new or updated map area.
getTypeOfArea(int $a_nr)
Get Type of Area (only internal link)
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.
editShapePolygon()
Edit an existing shape (make it a polygon)
editShapeCircle()
Edit an existing shape (make it a circle)
outputPostProcessing(string $a_output)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInitHTML(string $a_url)
Get initialisation HTML to use internal link editing.
static _exists(int $a_id)
checks wether a lm content object with specified id exists or not
static _lookupTitle(int $a_obj_id)
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)
static countCoords(string $c)
count the number of coordinates (x,y) in a coordinate string (format: "x1,y1,x2,y2,...
This class represents a non editable value in a property form.
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
This class represents an option in a radio group.
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static redirect(string $a_script)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
if(!file_exists('../ilias.ini.php'))