ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPCImageMapEditorGUI.php
Go to the documentation of this file.
1<?php
2
21
29{
36 protected $content_obj;
38
42 public function __construct(
43 $a_content_obj,
44 ilPageObject $a_page,
46 ) {
47 global $DIC;
48
49 $this->content_obj = $a_content_obj;
50 $this->page = $a_page;
51 $this->edit_request = $request;
52 parent::__construct($a_content_obj->getMediaObject());
53
54 $this->std_alias_item = new ilMediaAliasItem(
55 $this->content_obj->getDomDoc(),
56 $this->content_obj->hier_id,
57 "Standard",
58 $this->content_obj->getPCId(),
59 $this->getParentNodeName()
60 );
61 $this->map_repo = $DIC
62 ->copage()
63 ->internal()
64 ->repo()
65 ->pc()
66 ->mediaMap();
67 }
68
69 public function getParentNodeName(): string
70 {
71 return "MediaObject";
72 }
73
74 public function getImageMapTableHTML(): string
75 {
76 $image_map_table = new ilPCImageMapTableGUI(
77 $this,
78 "editMapAreas",
79 $this->content_obj,
80 $this->getParentNodeName()
81 );
82 return $image_map_table->getHTML();
83 }
84
88 public function saveArea(): string
89 {
91 $ilCtrl = $this->ctrl;
92
93 switch ($this->map->getMode()) {
94 // save edited link
95 case "edit_link":
96 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
97 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
98
99 $area_link_type = $this->edit_request->getString("area_link_type");
100 if ($area_link_type == IL_INT_LINK) {
101 $int_link = $this->map->getInternalLink();
102 $this->std_alias_item->setAreaIntLink(
103 $this->map->getAreaNr(),
104 $int_link["type"],
105 $int_link["target"],
106 $int_link["target_frame"]
107 );
108 } elseif ($area_link_type == IL_NO_LINK) {
109 $this->std_alias_item->setAreaExtLink(
110 $this->map->getAreaNr(),
111 ""
112 );
113 } else {
114 $this->std_alias_item->setAreaExtLink(
115 $this->map->getAreaNr(),
116 $this->edit_request->getString("area_link_ext")
117 );
118 }
119 $this->page->update();
120 break;
121
122 // save edited shape
123 case "edit_shape":
124 $this->std_alias_item->setShape(
125 $this->map->getAreaNr(),
126 $this->map->getAreaType(),
127 $this->map->getCoords()
128 );
129 $this->page->update();
130 break;
131
132 // save new area
133 default:
134 $area_type = $this->map->getAreaType();
135 $coords = $this->map->getCoords();
136 $link = [];
137 $area_link_type = $this->edit_request->getString("area_link_type");
138 switch ($area_link_type) {
139 case IL_EXT_LINK:
140 $link = array(
141 "LinkType" => IL_EXT_LINK,
142 "Href" => $this->edit_request->getString("area_link_ext"));
143 break;
144
145 case IL_NO_LINK:
146 $link = array(
147 "LinkType" => IL_EXT_LINK,
148 "Href" => "");
149 break;
150
151 case IL_INT_LINK:
152 $int_link = $this->map->getInternalLink();
153 $link = array(
154 "LinkType" => IL_INT_LINK,
155 "Type" => $int_link["type"],
156 "Target" => $int_link["target"],
157 "TargetFrame" => $int_link["target_frame"]);
158 break;
159 }
160
161 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
162 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
163 $this->std_alias_item->addMapArea(
164 $area_type,
165 $coords,
166 $this->edit_request->getString("area_name"),
167 $link
168 );
169 $this->page->update();
170 break;
171 }
172
173 //$this->initMapParameters();
174 $this->main_tpl->setOnScreenMessage('success', $lng->txt("cont_saved_map_area"), true);
175 $ilCtrl->redirect($this, "editMapAreas");
176 return "";
177 }
178
182 public function deleteAreas(): void
183 {
184 $ilCtrl = $this->ctrl;
186
187 $areas = $this->edit_request->getStringArray("area");
188 if (count($areas) == 0) {
189 $this->main_tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
190 $ilCtrl->redirect($this, "editMapAreas");
191 }
192
193 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
194 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
195
196 $i = 0;
197 arsort($areas);
198 foreach ($areas as $area_nr) {
199 $this->std_alias_item->deleteMapArea($area_nr);
200 }
201 $this->page->update();
202 $this->main_tpl->setOnScreenMessage('success', $lng->txt("cont_areas_deleted"), true);
203
204 $ilCtrl->redirect($this, "editMapAreas");
205 }
206
210 public function getLinkTypeOfArea(int $a_nr): string
211 {
212 return $this->std_alias_item->getLinkTypeOfArea($a_nr);
213 }
214
218 public function getTypeOfArea(int $a_nr): string
219 {
220 return $this->std_alias_item->getTypeOfArea($a_nr);
221 }
222
226 public function getTargetOfArea(int $a_nr): string
227 {
228 return $this->std_alias_item->getTargetOfArea($a_nr);
229 }
230
234 public function getTargetFrameOfArea(int $a_nr): string
235 {
236 return $this->std_alias_item->getTargetFrameOfArea($a_nr);
237 }
238
242 public function getHrefOfArea(int $a_nr): string
243 {
244 return $this->std_alias_item->getHrefOfArea($a_nr);
245 }
246
250 public function updateAreas(): void
251 {
253 $ilCtrl = $this->ctrl;
254
255 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
256 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
257 $areas = $this->std_alias_item->getMapAreas();
258 foreach ($areas as $area) {
259 // fix #26032 empty values lead to "empty text node" errors on page update
260 $name = $this->edit_request->getString("name_" . $area["Nr"]);
261 $hl_mode = $this->edit_request->getString("hl_mode_" . $area["Nr"]);
262 $hl_class = $this->edit_request->getString("hl_class_" . $area["Nr"]);
263 if ($name == "") {
264 $name = " ";
265 }
266 $this->std_alias_item->setAreaTitle(
267 $area["Nr"],
268 $name
269 );
270 $this->std_alias_item->setAreaHighlightMode(
271 $area["Nr"],
272 $hl_mode
273 );
274 $this->std_alias_item->setAreaHighlightClass(
275 $area["Nr"],
276 $hl_class
277 );
278 }
279 $this->page->update();
280
281 $this->main_tpl->setOnScreenMessage('success', $lng->txt("cont_saved_map_data"), true);
282 $ilCtrl->redirect($this, "editMapAreas");
283 }
284
288 public function makeMapWorkCopy(
289 string $a_edit_property = "",
290 int $a_area_nr = 0,
291 bool $a_output_new_area = false,
292 string $a_area_type = "",
293 string $a_coords = ""
294 ): ilMediaItem {
295 // old for pc media object
296 // $media_object = $this->media_object->getMediaItem("Standard");
297 $media_object = $this->content_obj->getMediaObject();
298
299 // create/update imagemap work copy
300 $st_item = $media_object->getMediaItem("Standard");
301 $st_alias_item = new ilMediaAliasItem(
302 $this->content_obj->getDomDoc(),
303 $this->content_obj->hier_id,
304 "Standard",
305 $this->content_obj->getPCId(),
306 $this->getParentNodeName()
307 );
308
309 if ($a_edit_property == "shape") {
310 $st_alias_item->makeMapWorkCopy(
311 $st_item,
312 $a_area_nr,
313 true,
314 $a_output_new_area,
315 $a_area_type,
316 $a_coords
317 ); // exclude area currently being edited
318 } else {
319 $st_alias_item->makeMapWorkCopy(
320 $st_item,
321 $a_area_nr,
322 false,
323 $a_output_new_area,
324 $a_area_type,
325 $a_coords
326 );
327 }
328
329 return $st_item;
330 }
331
332 public function getAliasXML(): string
333 {
334 return $this->content_obj->dumpXML();
335 }
336}
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.
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...
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26