19 declare(strict_types=1);
31 protected \ILIAS\DI\UIServices
$ui;
32 protected \ilLanguage
$lng;
41 $this->
ui = $DIC->ui();
42 $this->
lng = $DIC->language();
44 $this->
user = $DIC->user();
46 $this->ui_wrapper =
new Server\UIWrapper($this->
ui, $this->
lng);
51 switch ($body[
"action"]) {
55 case "save.trigger.properties":
56 return $this->saveTriggerProperties($query[
'pc_id'], $body);
58 case "save.trigger.overlay":
59 return $this->saveTriggerOverlay($query[
'pc_id'], $body);
61 case "save.trigger.popup":
62 return $this->saveTriggerPopup($query[
'pc_id'], $body);
64 case "upload.overlay":
65 return $this->uploadOverlay($query[
'pc_id'], $body);
67 case "delete.overlay":
71 return $this->
savePopup($query[
'pc_id'], $body);
76 case "delete.trigger":
80 return $this->saveSettings($query[
'pc_id'], $body);
83 throw new Exception(
"Unknown action " . $body[
"action"]);
89 $page = $this->page_gui->getPageObject();
93 if (!in_array($body[
"after_pcid"], [
"",
"pg"])) {
94 $hier_ids = $page->getHierIdsForPCIds([$body[
"after_pcid"]]);
95 $hier_id = $hier_ids[$body[
"after_pcid"]];
96 $pc_id = $body[
"after_pcid"];
99 $iim = new \ilPCInteractiveImage($page);
101 $iim_gui = new \ilPCInteractiveImageGUI($page, $iim,
"",
"");
102 $iim_gui->setPageConfig($page->getPageConfig());
103 $form = $iim_gui->getImportFormAdapter();
104 if ($form->isValid()) {
105 $iim->createFromMobId(
107 (
int) $form->getData(
"input_file"),
111 if (($body[
"pcid"] ??
"") !==
"") {
112 $iim->writePCId($body[
"pcid"]);
114 $updated = $page->update();
115 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
117 $html = $this->ui_wrapper->getRenderedAdapterForm(
119 [[
"Page",
"component.save", $this->
lng->txt(
"insert")],
120 [
"Page",
"component.cancel", $this->
lng->txt(
"cancel")]
123 return $this->ui_wrapper->sendFormError($html);
126 protected function saveTriggerProperties(
string $pc_id, array $body): Server\Response
128 $page = $this->page_gui->getPageObject();
130 $pc = $this->page_gui->getPageObject()->getContentObjectForPcId($pc_id);
131 $pc->setTriggerProperties((
string) $body[
"data"][
"trigger_nr"], $body[
"data"][
"title"], $body[
"data"][
"shape_type"], $body[
"data"][
"coords"], $body[
"data"][
"hl_mode"], $body[
"data"][
"hl_class"]);
132 $updated = $page->update();
137 protected function saveTriggerOverlay(
string $pc_id, array $body): Server\Response
139 $page = $this->page_gui->getPageObject();
141 $pc = $this->page_gui->getPageObject()->getContentObjectForPcId($pc_id);
142 $pc->setTriggerOverlay((
string) $body[
"data"][
"trigger_nr"], (
string) $body[
"data"][
"overlay"], (
string) $body[
"data"][
"coords"]);
143 $updated = $page->update();
148 protected function saveTriggerPopup(
string $pc_id, array $body): Server\Response
150 $page = $this->page_gui->getPageObject();
152 $pc = $this->page_gui->getPageObject()->getContentObjectForPcId($pc_id);
153 $pc->setTriggerPopup((
string) $body[
"data"][
"trigger_nr"], (
string) $body[
"data"][
"popup"], (
string) $body[
"data"][
"position"], (
string) $body[
"data"][
"size"]);
154 $updated = $page->update();
162 if ($updated !==
true) {
163 if (is_array($updated)) {
164 $error = implode(
"<br />", $updated);
165 } elseif (is_string($updated)) {
168 $error = print_r($updated,
true);
172 $data = new \stdClass();
176 return new Server\Response(
$data);
179 protected function uploadOverlay(
string $pc_id, array $body): Server\Response
181 $page = $this->page_gui->getPageObject();
183 $pc = $this->page_gui->getPageObject()->getContentObjectForPcId($pc_id);
185 $updated = $page->update();
192 $page = $this->page_gui->getPageObject();
194 $pc->deleteOverlay($body[
"data"][
"overlay"]);
195 $updated = $page->update();
202 $pg = $this->page_gui->getPageObject();
203 return $this->page_gui->getPageObject()->getContentObjectForPcId($pc_id);
208 $pg = $this->page_gui->getPageObject();
209 $iim = $this->page_gui->getPageObject()->getContentObjectForPcId($pc_id);
210 $iim_gui = new \ilPCInteractiveImageGUI($pg, $iim,
"", $pc_id);
211 $iim_gui->setPageConfig($pg->getPageConfig());
217 $page = $this->page_gui->getPageObject();
219 ->getPopupFormAdapter();
221 if ($form_adapter->isValid()) {
222 $title = $form_adapter->getData(
"title");
223 if ($body[
'nr'] ==
"") {
224 $pc->addContentPopup($title);
226 $pc->saveContentPopupTitle($body[
'nr'], $title);
229 $updated = $page->update();
236 $page = $this->page_gui->getPageObject();
238 $pc->deletePopupByNr($body[
"data"][
"nr"]);
239 $updated = $page->update();
246 $page = $this->page_gui->getPageObject();
248 $std_alias_item = $pc->getStandardAliasItem();
249 $pc->deleteTrigger($std_alias_item, (
int) $body[
"data"][
"nr"]);
250 $updated = $page->update();
254 protected function saveSettings(
string $pc_id, array $body): Server\Response
256 $page = $this->page_gui->getPageObject();
258 $pc = $this->page_gui->getPageObject()->getContentObjectForPcId($pc_id);
260 ->getBackgroundPropertiesFormAdapter();
262 if ($form_adapter->isValid()) {
263 $caption = $form_adapter->getData(
"caption");
264 $std_alias_item = $pc->getStandardAliasItem();
265 $std_alias_item->setCaption($caption);
268 $updated = $page->update();
getPCInteractiveImage(string $pc_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getPCInteractiveImageGUI(string $pc_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(\ilPageObjectGUI $page_gui)
getStandardResponse($updated, \ilPCInteractiveImage $pc)
handle(array $query, array $body)
insertCommand(array $body)
ilPageObjectGUI $page_gui
deletePopup(string $pc_id, array $body)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Server UIWrapper $ui_wrapper
savePopup(string $pc_id, array $body)
deleteTrigger(string $pc_id, array $body)
deleteOverlay(string $pc_id, array $body)
User interface class for interactive images.