ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPCImageMapEditorGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/MediaObjects/classes/class.ilImageMapEditorGUI.php");
5 
17 {
21  function __construct($a_pc_media_object, $a_page)
22  {
23  $this->pc_media_object = $a_pc_media_object;
24  $this->page = $a_page;
25  parent::__construct($a_pc_media_object->getMediaObject());
26  }
27 
28 
33  {
34  include_once("./Services/COPage/classes/class.ilPCImageMapTableGUI.php");
35  $image_map_table = new ilPCImageMapTableGUI($this, "editMapAreas", $this->pc_media_object);
36  return $image_map_table->getHTML();
37  }
38 
42  function saveArea()
43  {
44  global $lng, $ilCtrl;
45 
46  switch ($_SESSION["il_map_edit_mode"])
47  {
48  // save edited link
49  case "edit_link":
50  $std_alias_item = new ilMediaAliasItem($this->pc_media_object->dom,
51  $this->pc_media_object->hier_id, "Standard", $this->pc_media_object->getPcId());
52 
53  if ($_POST["area_link_type"] == IL_INT_LINK)
54  {
55  $std_alias_item->setAreaIntLink($_SESSION["il_map_area_nr"],
56  $_SESSION["il_map_il_type"], $_SESSION["il_map_il_target"],
57  $_SESSION["il_map_il_targetframe"]);
58  }
59  else
60  {
61  $std_alias_item->setAreaExtLink($_SESSION["il_map_area_nr"],
62  ilUtil::stripSlashes($_POST["area_link_ext"]));
63  }
64  $this->updated = $this->page->update();
65  break;
66 
67  // save edited shape
68  case "edit_shape":
69  $std_alias_item = new ilMediaAliasItem($this->pc_media_object->dom,
70  $this->pc_media_object->hier_id, "Standard", $this->pc_media_object->getPcId());
71  $std_alias_item->setShape($_SESSION["il_map_area_nr"],
72  $_SESSION["il_map_edit_area_type"], $_SESSION["il_map_edit_coords"]);
73  $this->updated = $this->page->update();
74  break;
75 
76  // save new area
77  default:
78  $area_type = $_SESSION["il_map_edit_area_type"];
79  $coords = $_SESSION["il_map_edit_coords"];
80 
81  switch($_POST["area_link_type"])
82  {
83  case "ext":
84  $link = array(
85  "LinkType" => IL_EXT_LINK,
86  "Href" => ilUtil::stripSlashes($_POST["area_link_ext"]));
87  break;
88 
89  case "int":
90  $link = array(
91  "LinkType" => IL_INT_LINK,
92  "Type" => $_SESSION["il_map_il_type"],
93  "Target" => $_SESSION["il_map_il_target"],
94  "TargetFrame" => $_SESSION["il_map_il_targetframe"]);
95  break;
96  }
97 
98  $std_alias_item = new ilMediaAliasItem($this->pc_media_object->dom,
99  $this->pc_media_object->hier_id, "Standard", $this->pc_media_object->getPcId());
100  $std_alias_item->addMapArea($area_type, $coords,
101  ilUtil::stripSlashes($_POST["area_name"]), $link);
102  $this->updated = $this->page->update();
103 
104  break;
105  }
106 
107  //$this->initMapParameters();
108  ilUtil::sendSuccess($lng->txt("cont_saved_map_area"), true);
109  $ilCtrl->redirect($this, "editMapAreas");
110  }
111 
115  function deleteAreas()
116  {
117  global $ilCtrl, $lng;
118 
119  if (!isset($_POST["area"]))
120  {
121  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
122  $ilCtrl->redirect($this, "editMapAreas");
123  }
124 
125  $std_alias_item = new ilMediaAliasItem($this->pc_media_object->dom,
126  $this->pc_media_object->hier_id, "Standard", $this->pc_media_object->getPcId());
127 
128  if (count($_POST["area"]) > 0)
129  {
130  $i = 0;
131 
132  foreach ($_POST["area"] as $area_nr)
133  {
134  $std_alias_item->deleteMapArea($area_nr - $i);
135  $i++;
136  }
137  $this->updated = $this->page->update();
138  ilUtil::sendSuccess($lng->txt("cont_areas_deleted"), true);
139  }
140 
141  $ilCtrl->redirect($this, "editMapAreas");
142  }
143 
147  function getLinkTypeOfArea($a_nr)
148  {
149  $std_alias_item = new ilMediaAliasItem($this->pc_media_object->dom,
150  $this->pc_media_object->hier_id, "Standard", $this->pc_media_object->getPcId());
151  return $std_alias_item->getLinkTypeOfArea($a_nr);
152  }
153 
157  function getTypeOfArea($a_nr)
158  {
159  $std_alias_item = new ilMediaAliasItem($this->pc_media_object->dom,
160  $this->pc_media_object->hier_id, "Standard", $this->pc_media_object->getPcId());
161  return $std_alias_item->getTypeOfArea($a_nr);
162  }
163 
167  function getTargetOfArea($a_nr)
168  {
169  $std_alias_item = new ilMediaAliasItem($this->pc_media_object->dom,
170  $this->pc_media_object->hier_id, "Standard", $this->pc_media_object->getPcId());
171  return $std_alias_item->getTargetOfArea($a_nr);
172  }
173 
177  function getTargetFrameOfArea($a_nr)
178  {
179  $std_alias_item = new ilMediaAliasItem($this->pc_media_object->dom,
180  $this->pc_media_object->hier_id, "Standard", $this->pc_media_object->getPcId());
181  return $std_alias_item->getTargetFrameOfArea($a_nr);
182  }
183 
187  function getHrefOfArea($a_nr)
188  {
189  $std_alias_item = new ilMediaAliasItem($this->pc_media_object->dom,
190  $this->pc_media_object->hier_id, "Standard", $this->pc_media_object->getPcId());
191  return $std_alias_item->getHrefOfArea($a_nr);
192  }
193 
197  function updateAreas()
198  {
199  global $lng, $ilCtrl;
200 
201  $std_alias_item = new ilMediaAliasItem($this->pc_media_object->dom,
202  $this->pc_media_object->hier_id, "Standard", $this->pc_media_object->getPcId());
203  $areas = $std_alias_item->getMapAreas();
204  foreach($areas as $area)
205  {
206  $std_alias_item->setAreaTitle($area["Nr"],
207  ilUtil::stripSlashes($_POST["name_".$area["Nr"]]));
208  }
209  $this->page->update();
210 
211  ilUtil::sendSuccess($lng->txt("cont_saved_map_data"), true);
212  $ilCtrl->redirect($this, "editMapAreas");
213  }
214 
218  function makeMapWorkCopy($a_edit_property = "", $a_area_nr = 0,
219  $a_output_new_area = false, $a_area_type = "", $a_coords = "")
220  {
221  // create/update imagemap work copy
222  $st_item = $this->media_object->getMediaItem("Standard");
223  $st_alias_item = new ilMediaAliasItem($this->pc_media_object->dom,
224  $this->pc_media_object->hier_id, "Standard", $this->pc_media_object->getPcId());
225 
226  if ($a_edit_property == "shape")
227  {
228  $st_alias_item->makeMapWorkCopy($st_item, $a_area_nr, true,
229  $a_output_new_area, $a_area_type, $a_coords); // exclude area currently being edited
230  }
231  else
232  {
233  $st_alias_item->makeMapWorkCopy($st_item, $a_area_nr, false,
234  $a_output_new_area, $a_area_type, $a_coords);
235  }
236  }
237 
238  function getAliasXML()
239  {
240  return $this->pc_media_object->dumpXML();
241  }
242 }
243 ?>