ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilPCIIMTriggerEditorGUI.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/COPage/classes/class.ilPCImageMapEditorGUI.php");
6 
18 {
22  protected $tpl;
23 
27  protected $lng;
28 
32  protected $toolbar;
33 
37  protected $ctrl;
38 
42  public function __construct($a_content_obj, $a_page)
43  {
44  global $DIC;
45 
46  $this->tpl = $DIC["tpl"];
47  $this->lng = $DIC->language();
48  $this->toolbar = $DIC->toolbar();
49  $this->ctrl = $DIC->ctrl();
50  $tpl = $DIC["tpl"];
51 
52  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
54 
55  $tpl->addJavascript("./Services/COPage/js/ilCOPagePres.js");
56  $tpl->addJavascript("./Services/COPage/js/ilCOPagePCInteractiveImage.js");
57 
58  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
61 
62  parent::__construct($a_content_obj, $a_page);
63  }
64 
70  public function getParentNodeName()
71  {
72  return "InteractiveImage";
73  }
74 
80  public function getEditorTitle()
81  {
82  $lng = $this->lng;
83 
84  return $lng->txt("cont_pc_iim");
85  }
86 
90  public function getImageMapTableHTML()
91  {
92  $tpl = $this->tpl;
93  $ilToolbar = $this->toolbar;
94  $lng = $this->lng;
96 
97 
98  $ilToolbar->addText($lng->txt("cont_drag_element_click_save"));
99  $ilToolbar->setId("drag_toolbar");
100  $ilToolbar->setHidden(true);
101  $ilToolbar->addButton($lng->txt("save"), "#", "", "", "", "save_pos_button");
102 
103  $ilToolbar->addButton(
104  $lng->txt("cancel"),
105  $ilCtrl->getLinkTarget($this, "editMapAreas")
106  );
107 
108  include_once("./Services/COPage/classes/class.ilPCIIMTriggerTableGUI.php");
109  $image_map_table = new ilPCIIMTriggerTableGUI(
110  $this,
111  "editMapAreas",
112  $this->content_obj,
113  $this->getParentNodeName()
114  );
115  return $image_map_table->getHTML();
116  }
117 
123  public function getToolbar()
124  {
126  $lng = $this->lng;
127 
128  // toolbar
129  $tb = new ilToolbarGUI();
130  $tb->setFormAction($ilCtrl->getFormAction($this));
131  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
132  $options = array(
133  "Rect" => $lng->txt("cont_Rect"),
134  "Circle" => $lng->txt("cont_Circle"),
135  "Poly" => $lng->txt("cont_Poly"),
136  "Marker" => $lng->txt("cont_marker")
137  );
138  $si = new ilSelectInputGUI($lng->txt("cont_trigger_area"), "shape");
139  $si->setOptions($options);
140  $tb->addInputItem($si, true);
141  $tb->addFormButton($lng->txt("add"), "addNewArea");
142 
143  return $tb;
144  }
145 
152  public function addNewArea()
153  {
155  $lng = $this->lng;
156 
157  if ($_POST["shape"] == "Marker") {
158  $this->content_obj->addTriggerMarker();
159  $this->updated = $this->page->update();
160  ilUtil::sendSuccess($lng->txt("cont_saved_map_data"), true);
161  $ilCtrl->redirect($this, "editMapAreas");
162  } else {
163  return parent::addNewArea();
164  }
165  }
166 
172  public function initAreaEditingForm($a_edit_property)
173  {
174  $lng = $this->lng;
176 
177  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
178  $form = new ilPropertyFormGUI();
179  $form->setOpenTag(false);
180  $form->setCloseTag(false);
181 
182  // name
183  if ($a_edit_property != "link" && $a_edit_property != "shape") {
184  $ti = new ilTextInputGUI($lng->txt("cont_name"), "area_name");
185  $ti->setMaxLength(200);
186  $ti->setSize(20);
187  //$ti->setRequired(true);
188  $form->addItem($ti);
189  }
190 
191  // save and cancel commands
192  if ($a_edit_property == "") {
193  $form->setTitle($lng->txt("cont_new_trigger_area"));
194  $form->addCommandButton("saveArea", $lng->txt("save"));
195  } else {
196  $form->setTitle($lng->txt("cont_new_area"));
197  $form->addCommandButton("saveArea", $lng->txt("save"));
198  }
199 
200  return $form;
201  }
202 
206  public function saveArea()
207  {
208  $lng = $this->lng;
210 
211  switch ($_SESSION["il_map_edit_mode"]) {
212  // save edited shape
213  case "edit_shape":
214  $this->std_alias_item->setShape(
215  $_SESSION["il_map_area_nr"],
216  $_SESSION["il_map_edit_area_type"],
217  $_SESSION["il_map_edit_coords"]
218  );
219  $this->updated = $this->page->update();
220  break;
221 
222  // save new area
223  default:
224  $area_type = $_SESSION["il_map_edit_area_type"];
225  $coords = $_SESSION["il_map_edit_coords"];
226  $this->content_obj->addTriggerArea(
227  $this->std_alias_item,
228  $area_type,
229  $coords,
230  ilUtil::stripSlashes($_POST["area_name"]),
231  $link
232  );
233  $this->updated = $this->page->update();
234  break;
235  }
236 
237  //$this->initMapParameters();
238  ilUtil::sendSuccess($lng->txt("cont_saved_map_area"), true);
239  $ilCtrl->redirect($this, "editMapAreas");
240  }
241 
245  public function updateTrigger()
246  {
247  $lng = $this->lng;
249 
250  $this->content_obj->setTriggerOverlays($_POST["ov"]);
251  $this->content_obj->setTriggerPopups($_POST["pop"]);
252  $this->content_obj->setTriggerOverlayPositions($_POST["ovpos"]);
253  $this->content_obj->setTriggerMarkerPositions($_POST["markpos"]);
254  $this->content_obj->setTriggerPopupPositions($_POST["poppos"]);
255  $this->content_obj->setTriggerPopupSize($_POST["popsize"]);
256  $this->content_obj->setTriggerTitles($_POST["title"]);
257  $this->updated = $this->page->update();
258  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
259  $ilCtrl->redirect($this, "editMapAreas");
260  }
261 
265  public function confirmDeleteTrigger()
266  {
268  $tpl = $this->tpl;
269  $lng = $this->lng;
270 
271  if (!is_array($_POST["tr"]) || count($_POST["tr"]) == 0) {
272  ilUtil::sendFailure($lng->txt("no_checkbox"), true);
273  $ilCtrl->redirect($this, "editMapAreas");
274  } else {
275  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
276  $cgui = new ilConfirmationGUI();
277  $cgui->setFormAction($ilCtrl->getFormAction($this));
278  $cgui->setHeaderText($lng->txt("cont_really_delete_triggers"));
279  $cgui->setCancel($lng->txt("cancel"), "editMapAreas");
280  $cgui->setConfirm($lng->txt("delete"), "deleteTrigger");
281 
282  foreach ($_POST["tr"] as $i) {
283  $cgui->addItem("tr[]", $i, $_POST["title"][$i]);
284  }
285 
286  $tpl->setContent($cgui->getHTML());
287  }
288  }
289 
293  public function deleteTrigger()
294  {
296  $lng = $this->lng;
297 
298  if (is_array($_POST["tr"]) && count($_POST["tr"]) > 0) {
299  foreach ($_POST["tr"] as $tr_nr) {
300  $this->content_obj->deleteTrigger($this->std_alias_item, $tr_nr);
301  }
302  $this->updated = $this->page->update();
303  ilUtil::sendSuccess($lng->txt("cont_areas_deleted"), true);
304  }
305 
306  $ilCtrl->redirect($this, "editMapAreas");
307  }
308 
314  public function getAdditionalPageXML()
315  {
316  return $this->page->getMultimediaXML();
317  }
318 
325  public function outputPostProcessing($a_output)
326  {
327 
328  // for question html get the page gui object
329  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
330  $pg_gui = new ilPageObjectGUI($this->page->getParentType(), $this->page->getId());
331  $pg_gui->setOutputMode(IL_PAGE_PREVIEW);
332  $pg_gui->getPageConfig()->setEnableSelfAssessment(true);
333  // $pg_gui->initSelfAssessmentRendering(true); // todo: solve in other way
334  $qhtml = $pg_gui->getQuestionHTML();
335  if (is_array($qhtml)) {
336  foreach ($qhtml as $k => $h) {
337  $a_output = str_replace($pg_gui->pl_start . "Question;il__qst_$k" . $pg_gui->pl_end, " " . $h, $a_output);
338  }
339  }
340  // $a_output = $pg_gui->selfAssessmentRendering($a_output);
341 
342  return $a_output;
343  }
344 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
const IL_PAGE_PREVIEW
$_SESSION["AccountId"]
This class represents a selection list property in a property form.
confirmDeleteTrigger()
Confirm trigger deletion.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
$h
Class ilPageObjectGUI.
$coords
Definition: example_030.php:88
static addJavaScript(ilTemplate $main_tpl=null)
Add javascript files that are necessary to run accordion.
global $ilCtrl
Definition: ilias.php:18
outputPostProcessing($a_output)
Output post processing.
static addCss()
Add required css.
if(isset($_POST['submit'])) $form
TableGUI class for pc image map editor.
saveArea()
Save new or updated map area.
This class represents a text property in a property form.
setMaxLength($a_maxlength)
Set Max Length.
__construct($a_content_obj, $a_page)
Constructor.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
setOptions($a_options)
Set Options.
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.
static initjQueryUI($a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components.txt for included components)
$i
Definition: disco.tpl.php:19
initAreaEditingForm($a_edit_property)
Init area editing form.
User interface class for page content map editor.
$_POST["username"]
getParentNodeName()
Get parent node name.
getAdditionalPageXML()
Get additional page xml (to be overwritten)
setOutputMode($a_mode=IL_PAGE_PRESENTATION)
Set Output Mode.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
Confirmation screen class.