ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilPCImageMapEditorGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 include_once("./Services/MediaObjects/classes/class.ilImageMapEditorGUI.php");
6 
18 {
22  protected $lng;
23 
27  protected $ctrl;
28 
32  public function __construct($a_content_obj, $a_page)
33  {
34  global $DIC;
35 
36  $this->lng = $DIC->language();
37  $this->ctrl = $DIC->ctrl();
38  $this->content_obj = $a_content_obj;
39  $this->page = $a_page;
40  parent::__construct($a_content_obj->getMediaObject());
41 
42  $this->std_alias_item = new ilMediaAliasItem(
43  $this->content_obj->dom,
44  $this->content_obj->hier_id,
45  "Standard",
46  $this->content_obj->getPcId(),
47  $this->getParentNodeName()
48  );
49  }
50 
56  public function getParentNodeName()
57  {
58  return "MediaObject";
59  }
60 
64  public function getImageMapTableHTML()
65  {
66  include_once("./Services/COPage/classes/class.ilPCImageMapTableGUI.php");
67  $image_map_table = new ilPCImageMapTableGUI(
68  $this,
69  "editMapAreas",
70  $this->content_obj,
71  $this->getParentNodeName()
72  );
73  return $image_map_table->getHTML();
74  }
75 
79  public function saveArea()
80  {
81  $lng = $this->lng;
83 
84  switch ($_SESSION["il_map_edit_mode"]) {
85  // save edited link
86  case "edit_link":
87 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
88 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
89 
90  if ($_POST["area_link_type"] == IL_INT_LINK) {
91  $this->std_alias_item->setAreaIntLink(
92  $_SESSION["il_map_area_nr"],
93  $_SESSION["il_map_il_type"],
94  $_SESSION["il_map_il_target"],
95  $_SESSION["il_map_il_targetframe"]
96  );
97  } elseif ($_POST["area_link_type"] == IL_NO_LINK) {
98  $this->std_alias_item->setAreaExtLink(
99  $_SESSION["il_map_area_nr"],
100  ""
101  );
102  } else {
103  $this->std_alias_item->setAreaExtLink(
104  $_SESSION["il_map_area_nr"],
105  ilUtil::stripSlashes($_POST["area_link_ext"])
106  );
107  }
108  $this->updated = $this->page->update();
109  break;
110 
111  // save edited shape
112  case "edit_shape":
113 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
114 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
115  $this->std_alias_item->setShape(
116  $_SESSION["il_map_area_nr"],
117  $_SESSION["il_map_edit_area_type"],
118  $_SESSION["il_map_edit_coords"]
119  );
120  $this->updated = $this->page->update();
121  break;
122 
123  // save new area
124  default:
125  $area_type = $_SESSION["il_map_edit_area_type"];
126  $coords = $_SESSION["il_map_edit_coords"];
127 
128  switch ($_POST["area_link_type"]) {
129  case IL_EXT_LINK:
130  $link = array(
131  "LinkType" => IL_EXT_LINK,
132  "Href" => ilUtil::stripSlashes($_POST["area_link_ext"]));
133  break;
134 
135  case IL_NO_LINK:
136  $link = array(
137  "LinkType" => IL_EXT_LINK,
138  "Href" => "");
139  break;
140 
141  case IL_INT_LINK:
142  $link = array(
143  "LinkType" => IL_INT_LINK,
144  "Type" => $_SESSION["il_map_il_type"],
145  "Target" => $_SESSION["il_map_il_target"],
146  "TargetFrame" => $_SESSION["il_map_il_targetframe"]);
147  break;
148  }
149 
150 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
151 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
152  $this->std_alias_item->addMapArea(
153  $area_type,
154  $coords,
155  ilUtil::stripSlashes($_POST["area_name"]),
156  $link
157  );
158  $this->updated = $this->page->update();
159 
160  break;
161  }
162 
163  //$this->initMapParameters();
164  ilUtil::sendSuccess($lng->txt("cont_saved_map_area"), true);
165  $ilCtrl->redirect($this, "editMapAreas");
166  }
167 
171  public function deleteAreas()
172  {
174  $lng = $this->lng;
175 
176  if (!isset($_POST["area"])) {
177  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
178  $ilCtrl->redirect($this, "editMapAreas");
179  }
180 
181  // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
182  // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
183 
184  if (count($_POST["area"]) > 0) {
185  $i = 0;
186  arsort($_POST["area"]);
187  foreach ($_POST["area"] as $area_nr) {
188  $this->std_alias_item->deleteMapArea($area_nr);
189  }
190  $this->updated = $this->page->update();
191  ilUtil::sendSuccess($lng->txt("cont_areas_deleted"), true);
192  }
193 
194  $ilCtrl->redirect($this, "editMapAreas");
195  }
196 
200  public function getLinkTypeOfArea($a_nr)
201  {
202  // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
203  // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
204  return $this->std_alias_item->getLinkTypeOfArea($a_nr);
205  }
206 
210  public function getTypeOfArea($a_nr)
211  {
212  // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
213  // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
214  return $this->std_alias_item->getTypeOfArea($a_nr);
215  }
216 
220  public function getTargetOfArea($a_nr)
221  {
222  // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
223  // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
224  return $this->std_alias_item->getTargetOfArea($a_nr);
225  }
226 
230  public function getTargetFrameOfArea($a_nr)
231  {
232  // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
233  // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
234  return $this->std_alias_item->getTargetFrameOfArea($a_nr);
235  }
236 
240  public function getHrefOfArea($a_nr)
241  {
242  // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
243  // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
244  return $this->std_alias_item->getHrefOfArea($a_nr);
245  }
246 
250  public function updateAreas()
251  {
252  $lng = $this->lng;
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 = ilUtil::stripSlashes($_POST["name_" . $area["Nr"]]);
261  if ($name == "") {
262  $name = " ";
263  }
264  $this->std_alias_item->setAreaTitle(
265  $area["Nr"],
266  $name
267  );
268  $this->std_alias_item->setAreaHighlightMode(
269  $area["Nr"],
270  ilUtil::stripSlashes($_POST["hl_mode_" . $area["Nr"]])
271  );
272  $this->std_alias_item->setAreaHighlightClass(
273  $area["Nr"],
274  ilUtil::stripSlashes($_POST["hl_class_" . $area["Nr"]])
275  );
276  }
277  $this->page->update();
278 
279  ilUtil::sendSuccess($lng->txt("cont_saved_map_data"), true);
280  $ilCtrl->redirect($this, "editMapAreas");
281  }
282 
286  public function makeMapWorkCopy(
287  $a_edit_property = "",
288  $a_area_nr = 0,
289  $a_output_new_area = false,
290  $a_area_type = "",
291  $a_coords = ""
292  ) {
293  // old for pc media object
294  // $media_object = $this->media_object->getMediaItem("Standard");
295  $media_object = $this->content_obj->getMediaObject();
296 
297  // create/update imagemap work copy
298  $st_item = $media_object->getMediaItem("Standard");
299  $st_alias_item = new ilMediaAliasItem(
300  $this->content_obj->dom,
301  $this->content_obj->hier_id,
302  "Standard",
303  $this->content_obj->getPcId(),
304  $this->getParentNodeName()
305  );
306 
307  if ($a_edit_property == "shape") {
308  $st_alias_item->makeMapWorkCopy(
309  $st_item,
310  $a_area_nr,
311  true,
312  $a_output_new_area,
313  $a_area_type,
314  $a_coords
315  ); // exclude area currently being edited
316  } else {
317  $st_alias_item->makeMapWorkCopy(
318  $st_item,
319  $a_area_nr,
320  false,
321  $a_output_new_area,
322  $a_area_type,
323  $a_coords
324  );
325  }
326  }
327 
328  public function getAliasXML()
329  {
330  return $this->content_obj->dumpXML();
331  }
332 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
getHrefOfArea($a_nr)
Get Href of Area (only external link)
makeMapWorkCopy( $a_st_item, $a_area_nr=0, $a_exclude=false, $a_output_new_area, $a_area_type, $a_coords)
make map work copy of image
$_SESSION["AccountId"]
global $DIC
Definition: saml.php:7
getLinkTypeOfArea($a_nr)
Get Link Type of Area.
Class ilMediaAliasItem.
getParentNodeName()
Get parent node name.
$coords
Definition: example_030.php:88
getTargetFrameOfArea($a_nr)
Get TargetFrame of Area (only internal link)
const IL_NO_LINK
global $ilCtrl
Definition: ilias.php:18
if($format !==null) $name
Definition: metadata.php:146
getTypeOfArea($a_nr)
Get Type of Area (only internal link)
const IL_INT_LINK
makeMapWorkCopy( $a_edit_property="", $a_area_nr=0, $a_output_new_area=false, $a_area_type="", $a_coords="")
Make work file for editing.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
User interface class for page content map editor.
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const IL_EXT_LINK
User interface class for map editor.
__construct($a_content_obj, $a_page)
Constructor.
TableGUI class for pc image map editor.
$i
Definition: disco.tpl.php:19
getTargetOfArea($a_nr)
Get Target of Area (only internal link)
saveArea()
Save new or updated map area.
$_POST["username"]