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 $area =
new ilMapArea($st_item->getId(), $i);
209 $this->request->getAreaTitle($i)
211 $area->setHighlightMode(
212 $this->request->getAreaHighlightMode($i)
214 $area->setHighlightClass(
215 $this->request->getAreaHighlightClass($i)
220 $this->main_tpl->setOnScreenMessage(
'success',
$lng->
txt(
"cont_saved_map_data"),
true);
221 $ilCtrl->redirect($this,
"editMapAreas");
226 switch ($this->request->getAreaShape()) {
229 case "Circle":
return $this->
addCircle();
238 $this->map->setAreaType(
"WholePicture");
246 $this->map->setAreaType(
"Rect");
253 $this->map->setAreaType(
"Circle");
260 $this->map->setAreaType(
"Poly");
270 bool $a_handle =
true
277 $area_type = $this->map->getAreaType();
278 $coords = $this->map->getCoords();
282 switch ($area_type) {
285 if ($cnt_coords < 2) {
288 } elseif ($cnt_coords == 2) {
295 if ($cnt_coords <= 1) {
298 if ($cnt_coords == 2) {
299 $c = explode(
",", $coords);
300 $coords =
$c[0] .
"," .
$c[1] .
",";
301 $coords .= round(sqrt(pow(abs(
$c[3] -
$c[1]), 2) + pow(abs(
$c[2] -
$c[0]), 2)));
303 $this->map->setCoords($coords);
311 if ($cnt_coords < 1) {
313 } elseif ($cnt_coords < 3) {
337 bool $a_get_next_coordinate =
false,
338 bool $a_output_new_area =
false,
339 bool $a_save_form =
false,
340 string $a_edit_property =
"",
343 $ilCtrl = $this->
ctrl;
346 $area_type = $this->map->getAreaType();
347 $coords = $this->map->getCoords();
350 $this->tpl =
new ilTemplate(
"tpl.map_edit.html",
true,
true,
"components/ILIAS/MediaObjects");
352 $this->tpl->setVariable(
"FORMACTION", $ilCtrl->getFormAction($this));
354 if ($a_edit_property !=
"link") {
355 switch ($area_type) {
358 if ($cnt_coords == 0) {
359 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"cont_click_tl_corner"));
361 if ($cnt_coords == 1) {
362 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"cont_click_br_corner"));
368 if ($cnt_coords == 0) {
369 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"cont_click_center"));
371 if ($cnt_coords == 1) {
372 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"cont_click_circle"));
378 if ($cnt_coords == 0) {
379 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"cont_click_starting_point"));
380 } elseif ($cnt_coords < 3) {
381 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"cont_click_next_point"));
383 $this->main_tpl->setOnScreenMessage(
'info',
$lng->txt(
"cont_click_next_or_save"));
392 if ($a_edit_property !=
"shape") {
394 $ilCtrl->setParameter($this,
"linkmode",
"map");
395 $this->tpl->setCurrentBlock(
"int_link_prep");
397 $ilCtrl->getLinkTargetByClass(
405 $this->tpl->parseCurrentBlock();
407 $form = $this->initAreaEditingForm($a_edit_property);
408 $this->tpl->setVariable(
"FORM", $form->getHTML());
411 $ilCtrl->setParameter($this,
"out_edit_property", $a_edit_property);
412 $ilCtrl->setParameter($this,
"out_area_nr", $a_area_nr);
413 $ilCtrl->setParameter($this,
"out_output_new_area", (
int) $a_output_new_area);
414 $ilCtrl->setParameter($this,
"out_area_type", $area_type);
415 $ilCtrl->setParameter($this,
"out_coords", $coords);
417 $edit_mode = ($a_get_next_coordinate)
419 : (($a_output_new_area)
423 $output = $this->getImageMapOutput($edit_mode);
424 $this->tpl->setVariable(
"IMAGE_MAP", $output);
426 return $this->tpl->get();
430 string $a_edit_property
435 $form->setOpenTag(
false);
436 $form->setCloseTag(
false);
439 if ($a_edit_property !=
"shape") {
442 if ($this->map->getLinkType() !=
"int") {
443 if ($this->map->getExternalLink() ==
"") {
444 $radg->setValue(
"no");
446 $radg->setValue(
"ext");
449 $radg->setValue(
"int");
454 $radg->addOption($ext);
457 $ti->setMaxLength(800);
459 if ($this->map->getExternalLink() !=
"") {
460 $ti->setValue($this->map->getExternalLink());
462 $ti->setValue(
"https://");
464 $ext->addSubItem($ti);
468 $radg->addOption($int);
472 $int_link = $this->map->getInternalLink();
473 if ($int_link[
"target"] !=
"") {
474 $link_str = $this->getMapAreaLinkString(
477 $int_link[
"target_frame"]
482 ' <a id="iosEditInternalLinkTrigger" href="#">' .
483 "[" .
$lng->txt(
"cont_get_link") .
"]" .
486 $int->addSubItem($ne);
490 $radg->addOption($no);
492 $form->addItem($radg);
497 if ($a_edit_property !=
"link" && $a_edit_property !=
"shape") {
499 $ti->setMaxLength(200);
505 $form->setTitle(
$lng->txt(
"cont_new_area"));
506 $form->addCommandButton(
"saveArea",
$lng->txt(
"save"));
517 string $a_edit_property =
"",
519 bool $a_output_new_area =
false,
520 string $a_area_type =
"",
521 string $a_coords =
""
524 $st_item = $this->media_object->getMediaItem(
"Standard");
526 if ($a_edit_property ==
"shape") {
529 $st_item->makeMapWorkCopy($a_area_nr,
false);
532 if ($a_output_new_area) {
533 $st_item->addAreaToMapWorkCopy($a_area_type, $a_coords);
543 string $a_map_edit_mode =
""
545 $ilCtrl = $this->
ctrl;
547 $st_item = $this->media_object->getMediaItem(
"Standard");
551 $xml .= $this->getAliasXML();
553 $xml .= $this->getAdditionalPageXML();
560 $random = new \Random\Randomizer();
561 $params = array(
'map_edit_mode' => $a_map_edit_mode,
562 'map_item' => $st_item->getId(),
563 'map_mob_id' => $this->media_object->getId(),
565 'media_mode' =>
'enable',
566 'image_map_link' => $ilCtrl->getLinkTarget($this,
"showImageMap",
"",
false,
false),
567 'link_params' =>
"ref_id=" . $this->request->getRefId() .
"&rand=" . $random->getInt(1, 999999),
568 'ref_id' => $this->request->getRefId(),
571 'webspace_path' => $wb_path);
572 $output = $this->xsl->process($xml,
$params);
574 $output = $this->outputPostProcessing($output);
613 $t_arr = explode(
"_", $a_target);
614 if ($a_frame !=
"") {
615 $frame_str =
" (" . $a_frame .
" Frame)";
618 case "StructureObject":
619 $id = (
int) $t_arr[count($t_arr) - 1];
622 $link_str =
$lng->txt(
"chapter") .
623 ": " . $title .
" [" . $t_arr[count($t_arr) - 1] .
"]" . $frame_str;
628 $id = (
int) $t_arr[count($t_arr) - 1];
631 $link_str =
$lng->txt(
"page") .
632 ": " . $title .
" [" . $t_arr[count($t_arr) - 1] .
"]" . $frame_str;
637 $id = (
int) $t_arr[count($t_arr) - 1];
640 $link_str =
$lng->txt(
"term") .
641 ": " . $term->getTerm() .
" [" . $t_arr[count($t_arr) - 1] .
"]" . $frame_str;
646 $id = (
int) $t_arr[count($t_arr) - 1];
649 $link_str =
$lng->txt(
"mob") .
650 ": " . $mob->getTitle() .
" [" . $t_arr[count($t_arr) - 1] .
"]" . $frame_str;
654 case "RepositoryItem":
655 if (trim($a_target) !==
"") {
656 $id = (
int) $t_arr[count($t_arr) - 1];
662 $link_str =
$lng->txt(
"obj_" . $t_arr[count($t_arr) - 2]) .
663 ": " . $title .
" [" . $t_arr[count($t_arr) - 1] .
"]" . $frame_str;
672 $id = (
int) $t_arr[count($t_arr) - 1];
675 $link_str =
$lng->txt(
"cont_wiki_page") .
676 ": " . $wpg->getTitle() .
" [" . $t_arr[count($t_arr) - 1] .
"]" . $frame_str;
692 $coords = $this->map->getCoords();
697 $this->map->setCoords($coords . $this->request->getX() .
"," .
698 $this->request->getY());
711 $map =
$DIC->mediaObjects()->internal()->domain()->imageMap();
725 $ilCtrl = $this->ctrl;
727 switch ($this->map->getMode()) {
730 $st_item = $this->media_object->getMediaItem(
"Standard");
732 $area =
new ilMapArea($st_item->getId(), $this->map->getAreaNr());
734 if ($this->request->getAreaLinkType() ==
IL_INT_LINK) {
736 $int_link = $this->map->getInternalLink();
737 $area->setType($int_link[
"type"] ??
"");
738 $area->setTarget($int_link[
"target"] ??
"");
739 $area->setTargetFrame($int_link[
"target_frame"] ??
"");
742 if ($this->request->getAreaLinkType() !=
IL_NO_LINK) {
744 $this->request->getExternalLink()
755 $st_item = $this->media_object->getMediaItem(
"Standard");
759 $this->map->getAreaNr()
762 $area->setShape($this->map->getAreaType());
763 $area->setCoords($this->map->getCoords());
769 $area_type = $this->map->getAreaType();
770 $coords = $this->map->getCoords();
772 $st_item = $this->media_object->getMediaItem(
"Standard");
777 $area->setItemId($st_item->getId());
778 $area->setShape($area_type);
779 $area->setCoords($coords);
780 $area->setNr($max + 1);
781 $area->setTitle($this->request->getAreaName());
782 switch ($this->request->getAreaLinkType()) {
785 $area->setHref($this->request->getExternalLink());
790 $int_link = $this->map->getInternalLink();
791 $area->setType($int_link[
"type"] ??
"");
792 $area->setTarget($int_link[
"target"] ??
"");
793 $area->setTargetFrame($int_link[
"type_frame"] ??
"");
798 $st_item->addMapArea($area);
799 $this->media_object->update();
804 $this->main_tpl->setOnScreenMessage(
'success',
$lng->txt(
"cont_saved_map_area"),
true);
805 $ilCtrl->redirect($this,
"editMapAreas");
811 $this->map->setLinkType(
"int");
812 $this->map->setInternalLink(
813 $this->request->getLinkType(),
814 $this->request->getLinkTarget(),
815 $this->request->getLinkTargetFrame(),
816 $this->request->getLinkAnchor()
819 switch ($this->map->getMode()) {
821 return $this->setLink();
824 return $this->addArea();
829 bool $a_handle =
true
832 $ilCtrl = $this->ctrl;
835 $this->handleMapParameters();
837 if ($this->map->getAreaNr() > 0) {
838 $area_nr = $this->map->getAreaNr();
840 $area = $this->request->getArea();
841 $area_nr = (
int) ($area[0] ?? 0);
843 if ($area_nr === 0) {
844 $this->main_tpl->setOnScreenMessage(
'failure',
$lng->txt(
"no_checkbox"),
true);
845 $ilCtrl->redirect($this,
"editMapAreas");
848 if (count($area ?? []) > 1) {
849 $this->main_tpl->setOnScreenMessage(
'failure',
$lng->txt(
"cont_select_max_one_item"),
true);
850 $ilCtrl->redirect($this,
"editMapAreas");
854 if ($this->map->getMode() !=
"edit_link") {
855 $this->map->setAreaNr($area_nr);
856 $this->map->setLinkType($this->getLinkTypeOfArea($area_nr));
857 $this->map->setMode(
"edit_link");
858 $this->map->setTargetScript($ilCtrl->getLinkTarget($this,
"setLink"));
860 $this->map->setInternalLink(
861 $this->getTypeOfArea($area_nr),
862 $this->getTargetOfArea($area_nr),
863 $this->getTargetFrameOfArea($area_nr),
867 $this->map->setExternalLink($this->getHrefOfArea($area_nr));
871 return $this->editMapArea(
false,
false,
true,
"link", $area_nr);
877 $st_item = $this->media_object->getMediaItem(
"Standard");
878 $area = $st_item->getMapArea($a_nr);
879 return $area->getLinkType();
888 $st_item = $this->media_object->getMediaItem(
"Standard");
889 $area = $st_item->getMapArea($a_nr);
890 return $area->getType();
899 $st_item = $this->media_object->getMediaItem(
"Standard");
900 $area = $st_item->getMapArea($a_nr);
901 return $area->getTarget();
910 $st_item = $this->media_object->getMediaItem(
"Standard");
911 $area = $st_item->getMapArea($a_nr);
912 return $area->getTargetFrame();
921 $st_item = $this->media_object->getMediaItem(
"Standard");
922 $area = $st_item->getMapArea($a_nr);
923 return $area->getHref();
931 $ilCtrl = $this->ctrl;
934 $area = $this->request->getArea();
935 if (count($area) == 0) {
936 $this->main_tpl->setOnScreenMessage(
'failure',
$lng->txt(
"no_checkbox"),
true);
937 $ilCtrl->redirect($this,
"editMapAreas");
940 $st_item = $this->media_object->getMediaItem(
"Standard");
943 if (count($area) > 0) {
946 foreach ($area as $area_nr) {
947 $st_item->deleteMapArea($area_nr - $i);
951 $this->media_object->update();
952 $this->main_tpl->setOnScreenMessage(
'success',
$lng->txt(
"cont_areas_deleted"),
true);
955 $ilCtrl->redirect($this,
"editMapAreas");
964 return $this->setLink(
false);
972 $this->clearSessionVars();
973 $this->map->setAreaType(
"WholePicture");
974 return $this->setShape(
false);
982 $this->clearSessionVars();
983 $this->map->setAreaType(
"Rect");
984 return $this->setShape(
false);
992 $this->clearSessionVars();
993 $this->map->setAreaType(
"Circle");
994 return $this->setShape(
false);
1002 $this->clearSessionVars();
1003 $this->map->setAreaType(
"Poly");
1004 return $this->setShape(
false);
1011 bool $a_handle =
true
1014 $ilCtrl = $this->ctrl;
1018 $this->handleMapParameters();
1020 if ($this->map->getAreaNr() > 0) {
1021 $area_nr = $this->map->getAreaNr();
1023 $area = $this->request->getArea();
1024 $area_nr = (
int) ($area[0] ?? 0);
1026 if ($area_nr === 0) {
1027 $this->main_tpl->setOnScreenMessage(
'failure',
$lng->txt(
"no_checkbox"),
true);
1028 $ilCtrl->redirect($this,
"editMapAreas");
1031 if (count($area ?? []) > 1) {
1032 $this->main_tpl->setOnScreenMessage(
'failure',
$lng->txt(
"cont_select_max_one_item"),
true);
1033 $ilCtrl->redirect($this,
"editMapAreas");
1036 if ($this->map->getMode() !=
"edit_shape") {
1037 $this->map->setAreaNr($area_nr);
1038 $this->map->setMode(
"edit_shape");
1039 $this->map->setTargetScript(
1040 $ilCtrl->getLinkTarget($this,
"setShape",
"",
false,
false)
1045 $area_type = $this->map->getAreaType();
1046 $coords = $this->map->getCoords();
1050 switch ($area_type) {
1053 if ($cnt_coords < 2) {
1054 return $this->editMapArea(
true,
false,
false,
"shape", $area_nr);
1055 } elseif ($cnt_coords == 2) {
1056 return $this->saveArea();
1062 if ($cnt_coords <= 1) {
1063 return $this->editMapArea(
true,
false,
false,
"shape", $area_nr);
1065 if ($cnt_coords == 2) {
1066 $c = explode(
",", $coords);
1067 $coords =
$c[0] .
"," .
$c[1] .
",";
1068 $coords .= round(sqrt(pow(abs(
$c[3] -
$c[1]), 2) + pow(abs(
$c[2] -
$c[0]), 2)));
1070 $this->map->setCoords($coords);
1071 return $this->saveArea();
1077 if ($cnt_coords < 1) {
1078 return $this->editMapArea(
true,
false,
false,
"shape", $area_nr);
1079 } elseif ($cnt_coords < 3) {
1080 return $this->editMapArea(
true,
true,
false,
"shape", $area_nr);
1082 return $this->editMapArea(
true,
true,
true,
"shape", $area_nr);
1087 case "WholePicture":
1088 return $this->saveArea();
1098 $ilCtrl = $this->ctrl;
1101 $st_item = $this->media_object->getMediaItem(
"Standard");
1107 $this->main_tpl->setOnScreenMessage(
'success',
$lng->txt(
"msg_obj_modified"),
true);
1108 $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'))