ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilPCImageMapEditorGUI.php
Go to the documentation of this file.
1<?php
2
21
29{
35
39 public function __construct(
40 $a_content_obj,
41 ilPageObject $a_page,
43 ) {
44 global $DIC;
45
46 $this->content_obj = $a_content_obj;
47 $this->page = $a_page;
48 $this->edit_request = $request;
49 parent::__construct($a_content_obj->getMediaObject());
50
51 $this->std_alias_item = new ilMediaAliasItem(
52 $this->content_obj->getDomDoc(),
53 $this->content_obj->hier_id,
54 "Standard",
55 $this->content_obj->getPCId(),
56 $this->getParentNodeName()
57 );
58 $this->map_repo = $DIC
59 ->copage()
60 ->internal()
61 ->repo()
62 ->pc()
63 ->mediaMap();
64 }
65
66 public function getParentNodeName(): string
67 {
68 return "MediaObject";
69 }
70
71 public function getImageMapTableHTML(): string
72 {
73 $image_map_table = new ilPCImageMapTableGUI(
74 $this,
75 "editMapAreas",
76 $this->content_obj,
77 $this->getParentNodeName()
78 );
79 return $image_map_table->getHTML();
80 }
81
85 public function saveArea(): string
86 {
88 $ilCtrl = $this->ctrl;
89
90 switch ($this->map->getMode()) {
91 // save edited link
92 case "edit_link":
93 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
94 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
95
96 $area_link_type = $this->edit_request->getString("area_link_type");
97 if ($area_link_type == IL_INT_LINK) {
98 $int_link = $this->map->getInternalLink();
99 $this->std_alias_item->setAreaIntLink(
100 $this->map->getAreaNr(),
101 $int_link["type"],
102 $int_link["target"],
103 $int_link["target_frame"]
104 );
105 } elseif ($area_link_type == IL_NO_LINK) {
106 $this->std_alias_item->setAreaExtLink(
107 $this->map->getAreaNr(),
108 ""
109 );
110 } else {
111 $this->std_alias_item->setAreaExtLink(
112 $this->map->getAreaNr(),
113 $this->edit_request->getString("area_link_ext")
114 );
115 }
116 $this->page->update();
117 break;
118
119 // save edited shape
120 case "edit_shape":
121 $this->std_alias_item->setShape(
122 $this->map->getAreaNr(),
123 $this->map->getAreaType(),
124 $this->map->getCoords()
125 );
126 $this->page->update();
127 break;
128
129 // save new area
130 default:
131 $area_type = $this->map->getAreaType();
132 $coords = $this->map->getCoords();
133 $link = [];
134 $area_link_type = $this->edit_request->getString("area_link_type");
135 switch ($area_link_type) {
136 case IL_EXT_LINK:
137 $link = array(
138 "LinkType" => IL_EXT_LINK,
139 "Href" => $this->edit_request->getString("area_link_ext"));
140 break;
141
142 case IL_NO_LINK:
143 $link = array(
144 "LinkType" => IL_EXT_LINK,
145 "Href" => "");
146 break;
147
148 case IL_INT_LINK:
149 $int_link = $this->map->getInternalLink();
150 $link = array(
151 "LinkType" => IL_INT_LINK,
152 "Type" => $int_link["type"],
153 "Target" => $int_link["target"],
154 "TargetFrame" => $int_link["target_frame"]);
155 break;
156 }
157
158 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
159 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
160 $this->std_alias_item->addMapArea(
161 $area_type,
162 $coords,
163 $this->edit_request->getString("area_name"),
164 $link
165 );
166 $this->page->update();
167 break;
168 }
169
170 //$this->initMapParameters();
171 $this->main_tpl->setOnScreenMessage('success', $lng->txt("cont_saved_map_area"), true);
172 $ilCtrl->redirect($this, "editMapAreas");
173 return "";
174 }
175
179 public function deleteAreas(): void
180 {
181 $ilCtrl = $this->ctrl;
183
184 $areas = $this->edit_request->getStringArray("area");
185 if (count($areas) == 0) {
186 $this->main_tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
187 $ilCtrl->redirect($this, "editMapAreas");
188 }
189
190 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
191 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
192
193 $i = 0;
194 arsort($areas);
195 foreach ($areas as $area_nr) {
196 $this->std_alias_item->deleteMapArea($area_nr);
197 }
198 $this->page->update();
199 $this->main_tpl->setOnScreenMessage('success', $lng->txt("cont_areas_deleted"), true);
200
201 $ilCtrl->redirect($this, "editMapAreas");
202 }
203
207 public function getLinkTypeOfArea(int $a_nr): string
208 {
209 return $this->std_alias_item->getLinkTypeOfArea($a_nr);
210 }
211
215 public function getTypeOfArea(int $a_nr): string
216 {
217 return $this->std_alias_item->getTypeOfArea($a_nr);
218 }
219
223 public function getTargetOfArea(int $a_nr): string
224 {
225 return $this->std_alias_item->getTargetOfArea($a_nr);
226 }
227
231 public function getTargetFrameOfArea(int $a_nr): string
232 {
233 return $this->std_alias_item->getTargetFrameOfArea($a_nr);
234 }
235
239 public function getHrefOfArea(int $a_nr): string
240 {
241 return $this->std_alias_item->getHrefOfArea($a_nr);
242 }
243
247 public function updateAreas(): void
248 {
250 $ilCtrl = $this->ctrl;
251
252 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
253 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
254 $areas = $this->std_alias_item->getMapAreas();
255 foreach ($areas as $area) {
256 // fix #26032 empty values lead to "empty text node" errors on page update
257 $name = $this->edit_request->getString("name_" . $area["Nr"]);
258 $hl_mode = $this->edit_request->getString("hl_mode_" . $area["Nr"]);
259 $hl_class = $this->edit_request->getString("hl_class_" . $area["Nr"]);
260 if ($name == "") {
261 $name = " ";
262 }
263 $this->std_alias_item->setAreaTitle(
264 $area["Nr"],
265 $name
266 );
267 $this->std_alias_item->setAreaHighlightMode(
268 $area["Nr"],
269 $hl_mode
270 );
271 $this->std_alias_item->setAreaHighlightClass(
272 $area["Nr"],
273 $hl_class
274 );
275 }
276 $this->page->update();
277
278 $this->main_tpl->setOnScreenMessage('success', $lng->txt("cont_saved_map_data"), true);
279 $ilCtrl->redirect($this, "editMapAreas");
280 }
281
285 public function makeMapWorkCopy(
286 string $a_edit_property = "",
287 int $a_area_nr = 0,
288 bool $a_output_new_area = false,
289 string $a_area_type = "",
290 string $a_coords = ""
291 ): ilMediaItem {
292 // old for pc media object
293 // $media_object = $this->media_object->getMediaItem("Standard");
294 $media_object = $this->content_obj->getMediaObject();
295
296 // create/update imagemap work copy
297 $st_item = $media_object->getMediaItem("Standard");
298 $st_alias_item = new ilMediaAliasItem(
299 $this->content_obj->getDomDoc(),
300 $this->content_obj->hier_id,
301 "Standard",
302 $this->content_obj->getPCId(),
303 $this->getParentNodeName()
304 );
305
306 if ($a_edit_property == "shape") {
307 $st_alias_item->makeMapWorkCopy(
308 $st_item,
309 $a_area_nr,
310 true,
311 $a_output_new_area,
312 $a_area_type,
313 $a_coords
314 ); // exclude area currently being edited
315 } else {
316 $st_alias_item->makeMapWorkCopy(
317 $st_item,
318 $a_area_nr,
319 false,
320 $a_output_new_area,
321 $a_area_type,
322 $a_coords
323 );
324 }
325
326 return $st_item;
327 }
328
329 public function getAliasXML(): string
330 {
331 return $this->content_obj->dumpXML();
332 }
333}
Page component editing request.
const IL_INT_LINK
const IL_EXT_LINK
const IL_NO_LINK
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
@inheritDoc
User interface class for map editor.
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilMediaItem Media Item, component of a media object (file or reference)
getMediaItem(string $a_purpose)
get item for media purpose
User interface class for page content map editor.
saveArea()
Save new or updated map area.
MapEditorSessionRepository $map_repo
getHrefOfArea(int $a_nr)
Get Href of Area (only external link)
__construct( $a_content_obj, ilPageObject $a_page, EditGUIRequest $request)
getTargetFrameOfArea(int $a_nr)
Get TargetFrame of Area (only internal link)
getLinkTypeOfArea(int $a_nr)
Get Link Type of Area.
ilPCInteractiveImage ilPCMediaObject $content_obj
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.
getTypeOfArea(int $a_nr)
Get Type of Area (only internal link)
getTargetOfArea(int $a_nr)
Get Target of Area (only internal link)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilPCMediaObject Media content object (see ILIAS DTD)
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26