ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilPCIIMTriggerEditorGUI.php
Go to the documentation of this file.
1 <?php
2 
20 
28 {
29  public function __construct(
30  ilPCInteractiveImage $a_content_obj,
31  ilPageObject $a_page,
33  ) {
35  parent::__construct($a_content_obj, $a_page, $request);
36 
37  $this->main_tpl->addJavaScript("./Services/COPage/js/ilCOPagePres.js");
38  $this->main_tpl->addJavaScript("./Services/COPage/js/ilCOPagePCInteractiveImage.js");
39 
42  }
43 
44  public function getParentNodeName(): string
45  {
46  return "InteractiveImage";
47  }
48 
49  public function getEditorTitle(): string
50  {
51  $lng = $this->lng;
52 
53  return $lng->txt("cont_pc_iim");
54  }
55 
59  public function getImageMapTableHTML(): string
60  {
61  $ilToolbar = $this->toolbar;
62  $lng = $this->lng;
63  $ilCtrl = $this->ctrl;
64 
65 
66  $ilToolbar->addText($lng->txt("cont_drag_element_click_save"));
67  $ilToolbar->setId("drag_toolbar");
68  $ilToolbar->setHidden(true);
69  $ilToolbar->addButton($lng->txt("save"), "#", "", null, "", "save_pos_button");
70 
71  $ilToolbar->addButton(
72  $lng->txt("cancel"),
73  $ilCtrl->getLinkTarget($this, "editMapAreas")
74  );
75 
76  $image_map_table = new ilPCIIMTriggerTableGUI(
77  $this,
78  "editMapAreas",
79  $this->content_obj,
80  $this->getParentNodeName()
81  );
82  return $image_map_table->getHTML();
83  }
84 
85  public function getToolbar(): ilToolbarGUI
86  {
87  $ilCtrl = $this->ctrl;
88  $lng = $this->lng;
89 
90  // toolbar
91  $tb = new ilToolbarGUI();
92  $tb->setFormAction($ilCtrl->getFormAction($this));
93  $options = array(
94  "Rect" => $lng->txt("cont_Rect"),
95  "Circle" => $lng->txt("cont_Circle"),
96  "Poly" => $lng->txt("cont_Poly"),
97  "Marker" => $lng->txt("cont_marker")
98  );
99  $si = new ilSelectInputGUI($lng->txt("cont_trigger_area"), "shape");
100  $si->setOptions($options);
101  $tb->addInputItem($si, true);
102  $tb->addFormButton($lng->txt("add"), "addNewArea");
103 
104  return $tb;
105  }
106 
107  public function addNewArea(): string
108  {
109  $ilCtrl = $this->ctrl;
110  $lng = $this->lng;
111 
112  if ($this->edit_request->getString("shape") == "Marker") {
113  $this->content_obj->addTriggerMarker();
114  $this->page->update();
115  $this->main_tpl->setOnScreenMessage('success', $lng->txt("cont_saved_map_data"), true);
116  $ilCtrl->redirect($this, "editMapAreas");
117  } else {
118  return parent::addNewArea();
119  }
120  return "";
121  }
122 
126  public function initAreaEditingForm(
127  string $a_edit_property
128  ): ilPropertyFormGUI {
129  $lng = $this->lng;
130  $form = new ilPropertyFormGUI();
131  $form->setOpenTag(false);
132  $form->setCloseTag(false);
133 
134  // name
135  if ($a_edit_property != "link" && $a_edit_property != "shape") {
136  $ti = new ilTextInputGUI($lng->txt("cont_name"), "area_name");
137  $ti->setMaxLength(200);
138  $ti->setSize(20);
139  //$ti->setRequired(true);
140  $form->addItem($ti);
141  }
142 
143  // save and cancel commands
144  if ($a_edit_property == "") {
145  $form->setTitle($lng->txt("cont_new_trigger_area"));
146  } else {
147  $form->setTitle($lng->txt("cont_new_area"));
148  }
149  $form->addCommandButton("saveArea", $lng->txt("save"));
150 
151  return $form;
152  }
153 
157  public function saveArea(): string
158  {
159  $lng = $this->lng;
160  $ilCtrl = $this->ctrl;
161 
162  switch ($this->map_repo->getMode()) {
163  // save edited shape
164  case "edit_shape":
165  $this->std_alias_item->setShape(
166  $this->map->getAreaNr(),
167  $this->map->getAreaType(),
168  $this->map->getCoords()
169  );
170  $this->page->update();
171  break;
172 
173  // save new area
174  default:
175  $area_type = $this->map->getAreaType();
176  $coords = $this->map->getCoords();
177  $this->content_obj->addTriggerArea(
178  $this->std_alias_item,
179  $area_type,
180  $coords,
181  $this->edit_request->getString("area_name")
182  );
183  $this->page->update();
184  break;
185  }
186 
187  //$this->initMapParameters();
188  $this->main_tpl->setOnScreenMessage('success', $lng->txt("cont_saved_map_area"), true);
189  $ilCtrl->redirect($this, "editMapAreas");
190  return "";
191  }
192 
196  public function updateTrigger(): void
197  {
198  $lng = $this->lng;
199  $ilCtrl = $this->ctrl;
200 
201  $this->content_obj->setTriggerOverlays(
202  $this->edit_request->getStringArray("ov")
203  );
204  $this->content_obj->setTriggerPopups(
205  $this->edit_request->getStringArray("pop")
206  );
207  $this->content_obj->setTriggerOverlayPositions(
208  $this->edit_request->getStringArray("ovpos")
209  );
210  $this->content_obj->setTriggerMarkerPositions(
211  $this->edit_request->getStringArray("markpos")
212  );
213  $this->content_obj->setTriggerPopupPositions(
214  $this->edit_request->getStringArray("poppos")
215  );
216  $this->content_obj->setTriggerPopupSize(
217  $this->edit_request->getStringArray("popsize")
218  );
219  $this->content_obj->setTriggerTitles(
220  $this->edit_request->getStringArray("title")
221  );
222  $this->page->update();
223  $this->main_tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
224  $ilCtrl->redirect($this, "editMapAreas");
225  }
226 
230  public function confirmDeleteTrigger(): void
231  {
232  $ilCtrl = $this->ctrl;
234  $lng = $this->lng;
235 
236  $trigger = $this->edit_request->getStringArray("tr");
237  $titles = $this->edit_request->getStringArray("title");
238 
239  if (count($trigger) == 0) {
240  $this->main_tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
241  $ilCtrl->redirect($this, "editMapAreas");
242  } else {
243  $cgui = new ilConfirmationGUI();
244  $cgui->setFormAction($ilCtrl->getFormAction($this));
245  $cgui->setHeaderText($lng->txt("cont_really_delete_triggers"));
246  $cgui->setCancel($lng->txt("cancel"), "editMapAreas");
247  $cgui->setConfirm($lng->txt("delete"), "deleteTrigger");
248 
249  foreach ($trigger as $i) {
250  $cgui->addItem("tr[]", $i, $titles[$i]);
251  }
252  $main_tpl->setContent($cgui->getHTML());
253  }
254  }
255 
260  public function deleteTrigger(): void
261  {
262  $ilCtrl = $this->ctrl;
263  $lng = $this->lng;
264 
265  $trigger = $this->edit_request->getStringArray("tr");
266 
267  if (count($trigger) > 0) {
268  foreach ($trigger as $tr_nr) {
269  $this->content_obj->deleteTrigger($this->std_alias_item, $tr_nr);
270  }
271  $this->page->update();
272  $this->main_tpl->setOnScreenMessage('success', $lng->txt("cont_areas_deleted"), true);
273  }
274 
275  $ilCtrl->redirect($this, "editMapAreas");
276  }
277 
281  public function getAdditionalPageXML(): string
282  {
283  return $this->page->getMultimediaXML();
284  }
285 
286  public function outputPostProcessing(string $a_output): string
287  {
288 
289  // for question html get the page gui object
290  $pg_gui = new ilPageObjectGUI($this->page->getParentType(), $this->page->getId());
292  $pg_gui->getPageConfig()->setEnableSelfAssessment(true);
293  // $pg_gui->initSelfAssessmentRendering(true); // todo: solve in other way
294  $qhtml = $pg_gui->getQuestionHTML();
295  if (is_array($qhtml)) {
296  foreach ($qhtml as $k => $h) {
297  $a_output = str_replace($pg_gui->pl_start . "Question;il__qst_$k" . $pg_gui->pl_end, " " . $h, $a_output);
298  }
299  }
300 
301  return $a_output;
302  }
303 }
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...
confirmDeleteTrigger()
Confirm trigger deletion.
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
setOutputMode(string $a_mode=self::PRESENTATION)
__construct(ilPCInteractiveImage $a_content_obj, ilPageObject $a_page, EditGUIRequest $request)
Class ilPageObjectGUI.
static addJavaScript(ilGlobalTemplate $main_tpl=null)
Add javascript files that are necessary to run accordion.
static addCss()
Add required css.
setContent(string $a_html)
Sets content for standard template.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
saveArea()
Save new or updated map area.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
Page component editing request.
static initjQueryUI(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components.txt for included components)
User interface class for page content map editor.
__construct(Container $dic, ilPlugin $plugin)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
initAreaEditingForm(string $a_edit_property)
Init area editing form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
User interface class for page content map editor.
ilGlobalTemplateInterface $main_tpl
getAdditionalPageXML()
Get additional page xml (to be overwritten)
$i
Definition: metadata.php:41
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...