ILIAS  release_7 Revision v7.30-3-g800a261c036
class.GridCommandActionHandler.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2020 ILIAS open source, Extended GPL, see docs/LICENSE */
4
6
9
14{
18 protected $ui;
19
23 protected $lng;
24
28 protected $page_gui;
29
33 protected $user;
34
38 protected $ui_wrapper;
39
41 {
42 global $DIC;
43
44 $this->ui = $DIC->ui();
45 $this->lng = $DIC->language();
46 $this->page_gui = $page_gui;
47 $this->user = $DIC->user();
48
49 $this->ui_wrapper = new Server\UIWrapper($this->ui, $this->lng);
50 }
51
57 public function handle($query, $body) : Server\Response
58 {
59 switch ($body["action"]) {
60 case "insert":
61 return $this->insertCommand($body);
62 break;
63
64 default:
65 throw new Exception("Unknown action " . $body["action"]);
66 break;
67 }
68 }
69
75 protected function insertCommand($body) : Server\Response
76 {
77 $page = $this->page_gui->getPageObject();
78
79 $hier_id = "pg";
80 $pc_id = "";
81 if (!in_array($body["after_pcid"], ["", "pg"])) {
82 $hier_ids = $page->getHierIdsForPCIds([$body["after_pcid"]]);
83 $hier_id = $hier_ids[$body["after_pcid"]];
84 $pc_id = $body["after_pcid"];
85 }
86
87 // if ($form->checkInput()) {
88 $post_layout_template = (int) $body["layout_template"];
89 $grid = new \ilPCGrid($page);
90 $grid->create($page, $hier_id, $pc_id);
91 $grid->applyTemplate(
92 $post_layout_template,
93 (int) $body["number_of_cells"],
94 $body["s"],
95 $body["m"],
96 $body["l"],
97 $body["xl"]
98 );
99 $updated = $page->update();
100
101 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
102 }
103}
user()
Definition: user.php:4
An exception for terminatinating execution or to throw for unit testing.
Page editor json server.
Class ilPageObjectGUI.
global $DIC
Definition: goto.php:24
$query
ui()
Definition: ui.php:5