ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
TabsCommandActionHandler.php
Go to the documentation of this file.
1<?php
2
20
23
27class TabsCommandActionHandler implements Server\CommandActionHandler
28{
29 protected \ILIAS\DI\UIServices $ui;
30 protected \ilLanguage $lng;
31 protected \ilPageObjectGUI $page_gui;
32 protected \ilObjUser $user;
33 protected Server\UIWrapper $ui_wrapper;
34
36 {
37 global $DIC;
38
39 $this->ui = $DIC->ui();
40 $this->lng = $DIC->language();
41 $this->page_gui = $page_gui;
42 $this->user = $DIC->user();
43
44 $this->ui_wrapper = new Server\UIWrapper($this->ui, $this->lng);
45 }
46
47 public function handle(array $query, array $body): Server\Response
48 {
49 switch ($body["action"]) {
50 case "insert":
51 return $this->insertCommand($body);
52
53 case "update":
54 return $this->updateCommand($body);
55
56 default:
57 throw new Exception("Unknown action " . $body["action"]);
58 }
59 }
60
61 protected function insertCommand(array $body): Server\Response
62 {
63 $page = $this->page_gui->getPageObject();
64
65 $hier_id = "pg";
66 $pc_id = "";
67 if (!in_array($body["after_pcid"], ["", "pg"])) {
68 $hier_ids = $page->getHierIdsForPCIds([$body["after_pcid"]]);
69 $hier_id = $hier_ids[$body["after_pcid"]];
70 $pc_id = $body["after_pcid"];
71 }
72
73 // if ($form->checkInput()) {
74 $tabs = new \ilPCTabs($page);
75 $tabs->create($page, $hier_id, $pc_id);
76
77 $type = $body["type"];
78 $tabs->setTabType($type);
79 $tabs->setTemplate("");
80 switch ($type) {
81 case \ilPCTabs::ACCORDION_VER:
82 $t = explode(":", $body["vaccord_templ"] ?? "");
83 $tabs->setTemplate($t[2] ?? "");
84 $tabs->setBehavior($body["vbehavior"]);
85 //$tabs->setHorizontalAlign($body["valign"]);
86 break;
87 case \ilPCTabs::CAROUSEL:
88 $autotime = ($body["auto_time"] != "")
89 ? (int) $body["auto_time"]
90 : null;
91 $t = explode(":", $body["carousel_templ"]);
92 $tabs->setTemplate($t[2] ?? "");
93 //$tabs->setHorizontalAlign($body["calign"]);
94 $tabs->setAutoTime($autotime);
95 $tabs->setRandomStart((bool) ($body["rand_start"] ?? false));
96 break;
97 }
98
99 for ($i = 0; $i < (int) $body["nr"]; $i++) {
100 $tabs->addTab($this->lng->txt("cont_new_tab"));
101 }
102 $updated = $page->update();
103
104 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
105 }
106
107 protected function updateCommand(array $body): Server\Response
108 {
109 $page = $this->page_gui->getPageObject();
110
112 $tabs = $page->getContentObjectForPcId($body["pcid"]);
113
114 $type = $body["type"];
115 $tabs->setTabType($type);
116 $tabs->setTemplate("");
117 switch ($type) {
118 case \ilPCTabs::ACCORDION_VER:
119 $t = explode(":", $body["vaccord_templ"] ?? "");
120 $tabs->setTemplate($t[2] ?? "");
121 $tabs->setBehavior($body["vbehavior"]);
122 //$tabs->setHorizontalAlign($body["valign"]);
123 break;
124 case \ilPCTabs::CAROUSEL:
125 $autotime = ($body["auto_time"] != "")
126 ? (int) $body["auto_time"]
127 : null;
128 $t = explode(":", $body["carousel_templ"]);
129 $tabs->setTemplate($t[2] ?? "");
130 //$tabs->setHorizontalAlign($body["calign"]);
131 $tabs->setAutoTime($autotime);
132 $tabs->setRandomStart((bool) ($body["rand_start"] ?? false));
133 break;
134 }
135
136 $updated = $page->update();
137
138 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
139 }
140
141}
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