ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  function __construct($a_content_obj, $a_page)
23  {
24  $this->content_obj = $a_content_obj;
25  $this->page = $a_page;
26  parent::__construct($a_content_obj->getMediaObject());
27 
28  $this->std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
29  $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId(),
30  $this->getParentNodeName());
31  }
32 
38  function getParentNodeName()
39  {
40  return "MediaObject";
41  }
42 
47  {
48  include_once("./Services/COPage/classes/class.ilPCImageMapTableGUI.php");
49  $image_map_table = new ilPCImageMapTableGUI($this, "editMapAreas", $this->content_obj,
50  $this->getParentNodeName());
51  return $image_map_table->getHTML();
52  }
53 
57  function saveArea()
58  {
59  global $lng, $ilCtrl;
60 
61  switch ($_SESSION["il_map_edit_mode"])
62  {
63  // save edited link
64  case "edit_link":
65 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
66 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
67 
68  if ($_POST["area_link_type"] == IL_INT_LINK)
69  {
70  $this->std_alias_item->setAreaIntLink($_SESSION["il_map_area_nr"],
71  $_SESSION["il_map_il_type"], $_SESSION["il_map_il_target"],
72  $_SESSION["il_map_il_targetframe"]);
73  }
74  else if ($_POST["area_link_type"] == IL_NO_LINK)
75  {
76  $this->std_alias_item->setAreaExtLink($_SESSION["il_map_area_nr"],
77  "");
78  }
79  else
80  {
81  $this->std_alias_item->setAreaExtLink($_SESSION["il_map_area_nr"],
82  ilUtil::stripSlashes($_POST["area_link_ext"]));
83  }
84  $this->updated = $this->page->update();
85  break;
86 
87  // save edited shape
88  case "edit_shape":
89 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
90 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
91  $this->std_alias_item->setShape($_SESSION["il_map_area_nr"],
92  $_SESSION["il_map_edit_area_type"], $_SESSION["il_map_edit_coords"]);
93  $this->updated = $this->page->update();
94  break;
95 
96  // save new area
97  default:
98  $area_type = $_SESSION["il_map_edit_area_type"];
99  $coords = $_SESSION["il_map_edit_coords"];
100 
101  switch($_POST["area_link_type"])
102  {
103  case IL_EXT_LINK:
104  $link = array(
105  "LinkType" => IL_EXT_LINK,
106  "Href" => ilUtil::stripSlashes($_POST["area_link_ext"]));
107  break;
108 
109  case IL_NO_LINK:
110  $link = array(
111  "LinkType" => IL_EXT_LINK,
112  "Href" => "");
113  break;
114 
115  case IL_INT_LINK:
116  $link = array(
117  "LinkType" => IL_INT_LINK,
118  "Type" => $_SESSION["il_map_il_type"],
119  "Target" => $_SESSION["il_map_il_target"],
120  "TargetFrame" => $_SESSION["il_map_il_targetframe"]);
121  break;
122  }
123 
124 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
125 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
126  $this->std_alias_item->addMapArea($area_type, $coords,
127  ilUtil::stripSlashes($_POST["area_name"]), $link);
128  $this->updated = $this->page->update();
129 
130  break;
131  }
132 
133  //$this->initMapParameters();
134  ilUtil::sendSuccess($lng->txt("cont_saved_map_area"), true);
135  $ilCtrl->redirect($this, "editMapAreas");
136  }
137 
141  function deleteAreas()
142  {
143  global $ilCtrl, $lng;
144 
145  if (!isset($_POST["area"]))
146  {
147  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
148  $ilCtrl->redirect($this, "editMapAreas");
149  }
150 
151 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
152 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
153 
154  if (count($_POST["area"]) > 0)
155  {
156  $i = 0;
157  arsort($_POST["area"]);
158  foreach ($_POST["area"] as $area_nr)
159  {
160  $this->std_alias_item->deleteMapArea($area_nr);
161  }
162  $this->updated = $this->page->update();
163  ilUtil::sendSuccess($lng->txt("cont_areas_deleted"), true);
164  }
165 
166  $ilCtrl->redirect($this, "editMapAreas");
167  }
168 
172  function getLinkTypeOfArea($a_nr)
173  {
174 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
175 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
176  return $this->std_alias_item->getLinkTypeOfArea($a_nr);
177  }
178 
182  function getTypeOfArea($a_nr)
183  {
184 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
185 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
186  return $this->std_alias_item->getTypeOfArea($a_nr);
187  }
188 
192  function getTargetOfArea($a_nr)
193  {
194 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
195 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
196  return $this->std_alias_item->getTargetOfArea($a_nr);
197  }
198 
202  function getTargetFrameOfArea($a_nr)
203  {
204 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
205 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
206  return $this->std_alias_item->getTargetFrameOfArea($a_nr);
207  }
208 
212  function getHrefOfArea($a_nr)
213  {
214 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
215 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
216  return $this->std_alias_item->getHrefOfArea($a_nr);
217  }
218 
222  function updateAreas()
223  {
224  global $lng, $ilCtrl;
225 
226 // $std_alias_item = new ilMediaAliasItem($this->content_obj->dom,
227 // $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId());
228  $areas = $this->std_alias_item->getMapAreas();
229  foreach($areas as $area)
230  {
231  $this->std_alias_item->setAreaTitle($area["Nr"],
232  ilUtil::stripSlashes($_POST["name_".$area["Nr"]]));
233  $this->std_alias_item->setAreaHighlightMode($area["Nr"],
234  ilUtil::stripSlashes($_POST["hl_mode_".$area["Nr"]]));
235  $this->std_alias_item->setAreaHighlightClass($area["Nr"],
236  ilUtil::stripSlashes($_POST["hl_class_".$area["Nr"]]));
237  }
238  $this->page->update();
239 
240  ilUtil::sendSuccess($lng->txt("cont_saved_map_data"), true);
241  $ilCtrl->redirect($this, "editMapAreas");
242  }
243 
247  function makeMapWorkCopy($a_edit_property = "", $a_area_nr = 0,
248  $a_output_new_area = false, $a_area_type = "", $a_coords = "")
249  {
250 // old for pc media object
251 // $media_object = $this->media_object->getMediaItem("Standard");
252  $media_object = $this->content_obj->getMediaObject();
253 
254  // create/update imagemap work copy
255  $st_item = $media_object->getMediaItem("Standard");
256  $st_alias_item = new ilMediaAliasItem($this->content_obj->dom,
257  $this->content_obj->hier_id, "Standard", $this->content_obj->getPcId(),
258  $this->getParentNodeName());
259 
260  if ($a_edit_property == "shape")
261  {
262  $st_alias_item->makeMapWorkCopy($st_item, $a_area_nr, true,
263  $a_output_new_area, $a_area_type, $a_coords); // exclude area currently being edited
264  }
265  else
266  {
267  $st_alias_item->makeMapWorkCopy($st_item, $a_area_nr, false,
268  $a_output_new_area, $a_area_type, $a_coords);
269  }
270  }
271 
272  function getAliasXML()
273  {
274  return $this->content_obj->dumpXML();
275  }
276 }
277 ?>