ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.PlaceHolderCommandActionHandler.php
Go to the documentation of this file.
1<?php
2
20
23
24class PlaceHolderCommandActionHandler implements Server\CommandActionHandler
25{
26 protected \ILIAS\DI\UIServices $ui;
27 protected \ilLanguage $lng;
28 protected \ilPageObjectGUI $page_gui;
29 protected \ilObjUser $user;
30 protected Server\UIWrapper $ui_wrapper;
31
33 {
34 global $DIC;
35
36 $this->ui = $DIC->ui();
37 $this->lng = $DIC->language();
38 $this->page_gui = $page_gui;
39 $this->user = $DIC->user();
40
41 $this->ui_wrapper = new Server\UIWrapper($this->ui, $this->lng);
42 }
43
44 public function handle(array $query, array $body): Server\Response
45 {
46 switch ($body["action"]) {
47 case "insert":
48 return $this->insertCommand($body);
49
50 case "update":
51 return $this->updateCommand($body);
52
53 default:
54 throw new Exception("Unknown action " . $body["action"]);
55 }
56 }
57
58 protected function insertCommand(array $body): Server\Response
59 {
60 $page = $this->page_gui->getPageObject();
61
62 $hier_id = "pg";
63 $pc_id = "";
64 if (!in_array($body["after_pcid"], ["", "pg"])) {
65 $hier_ids = $page->getHierIdsForPCIds([$body["after_pcid"]]);
66 $hier_id = $hier_ids[$body["after_pcid"]];
67 $pc_id = $body["after_pcid"];
68 }
69
70 // if ($form->checkInput()) {
71 $ph = new \ilPCPlaceHolder($page);
72 $ph->create($page, $hier_id, $pc_id);
73 $ph->setHeight("300px");
74 $ph->setContentClass(
75 $body["plach_type"]
76 );
77 $updated = $page->update();
78
79 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
80 }
81
82 protected function updateCommand(array $body): Server\Response
83 {
84 $page = $this->page_gui->getPageObject();
85 $page->addHierIDs();
86 $hier_id = $page->getHierIdForPcId($body["pcid"]);
87 $ph = $page->getContentObjectForPcId($body["pcid"]);
88 $ph_gui = new \ilPCPlaceHolderGUI($page, $ph, $hier_id, $body["pcid"]);
89 $ph_gui->setPageConfig($page->getPageConfig());
90
91 $form = $ph_gui->initCreationForm();
92
93 // note: we have everyting in _POST here, form works the usual way
94 $updated = true;
95 if ($form->checkInput()) {
96 $ph->setContentClass(
97 $form->getInput("plach_type")
98 );
99 $updated = $page->update();
100 }
101
102 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
103 }
104
105}
Page editor json server.
Class ilPageObjectGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26