ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.GridCommandActionHandler.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25
29class GridCommandActionHandler implements Server\CommandActionHandler
30{
31 protected \ILIAS\DI\UIServices $ui;
32 protected \ilLanguage $lng;
33 protected \ilPageObjectGUI $page_gui;
34 protected \ilObjUser $user;
35 protected Server\UIWrapper $ui_wrapper;
36
38 {
39 global $DIC;
40
41 $this->ui = $DIC->ui();
42 $this->lng = $DIC->language();
43 $this->page_gui = $page_gui;
44 $this->user = $DIC->user();
45
46 $this->ui_wrapper = new Server\UIWrapper($this->ui, $this->lng);
47 }
48
49 public function handle(array $query, array $body): Server\Response
50 {
51 switch ($body["action"]) {
52 case "insert":
53 return $this->insertCommand($body);
54
55 default:
56 throw new Exception("Unknown action " . $body["action"]);
57 }
58 }
59
60 protected function insertCommand(array $body): Server\Response
61 {
62 $page = $this->page_gui->getPageObject();
63
64 $hier_id = "pg";
65 $pc_id = "";
66 if (!in_array($body["after_pcid"], ["", "pg"])) {
67 $hier_ids = $page->getHierIdsForPCIds([$body["after_pcid"]]);
68 $hier_id = $hier_ids[$body["after_pcid"]];
69 $pc_id = $body["after_pcid"];
70 }
71
72 // if ($form->checkInput()) {
73 $post_layout_template = (int) $body["layout_template"];
74 $grid = new \ilPCGrid($page);
75 $grid->create($page, $hier_id, $pc_id);
76 $grid->applyTemplate(
77 $post_layout_template,
78 (int) $body["number_of_cells"],
79 (int) $body["s"],
80 (int) $body["m"],
81 (int) $body["l"],
82 (int) $body["xl"]
83 );
84 $updated = $page->update();
85
86 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
87 }
88}
Page editor json server.
Class ilPageObjectGUI.
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