ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\COPage\PC\Table\TableCommandActionHandler Class Reference
+ Inheritance diagram for ILIAS\COPage\PC\Table\TableCommandActionHandler:
+ Collaboration diagram for ILIAS\COPage\PC\Table\TableCommandActionHandler:

Public Member Functions

 __construct (\ilPageObjectGUI $page_gui)
 
 handle (array $query, array $body)
 
 sendUpdateResponse (\ilPageObjectGUI $page_gui, $updated, string $pcid)
 
 sendTable (\ilPageObjectGUI $page_gui, string $pcid)
 Send whole table as response. More...
 

Protected Member Functions

 insertCommand (array $body)
 
 setRowHeaderAndCharacteristic (\ilPCTable $tab, array $body)
 
 importSpreadsheet (array $body)
 
 updateDataCommand (array $body)
 
 updateData (string $pcid, array $content)
 

Protected Attributes

ILIAS DI UIServices $ui
 
ilLanguage $lng
 
ilPageObjectGUI $page_gui
 
ilObjUser $user
 
Server UIWrapper $ui_wrapper
 

Detailed Description

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 27 of file class.TableCommandActionHandler.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\COPage\PC\Table\TableCommandActionHandler::__construct ( \ilPageObjectGUI  $page_gui)

Definition at line 35 of file class.TableCommandActionHandler.php.

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 }
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\COPage\PC\Table\TableCommandActionHandler\$page_gui, ILIAS\Repository\lng(), ILIAS\Repository\ui(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ handle()

ILIAS\COPage\PC\Table\TableCommandActionHandler::handle ( array  $query,
array  $body 
)

Definition at line 47 of file class.TableCommandActionHandler.php.

47 : Server\Response
48 {
49 switch ($body["action"]) {
50 case "insert":
51 return $this->insertCommand($body);
52
53 case "update.data":
54 return $this->updateDataCommand($body);
55
56 case "modify.table":
57 return $this->modifyTableCommand($body);
58
59 case "update":
60 return $this->updateCommand($body);
61
62 case "set.properties":
63 return $this->setCellProperties($body);
64
65 case "toggle.merge":
66 return $this->toggleMerge($body);
67
68 default:
69 throw new Exception("Unknown action " . $body["action"]);
70 }
71 }

References ILIAS\COPage\PC\Table\TableCommandActionHandler\insertCommand(), and ILIAS\COPage\PC\Table\TableCommandActionHandler\updateDataCommand().

+ Here is the call graph for this function:

◆ importSpreadsheet()

ILIAS\COPage\PC\Table\TableCommandActionHandler::importSpreadsheet ( array  $body)
protected

Definition at line 133 of file class.TableCommandActionHandler.php.

133 : Server\Response
134 {
135 $page = $this->page_gui->getPageObject();
136
137 $hier_id = "pg";
138 $pc_id = "";
139 if (!in_array($body["after_pcid"], ["", "pg"])) {
140 $hier_ids = $page->getHierIdsForPCIds([$body["after_pcid"]]);
141 $hier_id = $hier_ids[$body["after_pcid"]];
142 $pc_id = $body["after_pcid"];
143 }
144
145 $tab = new \ilPCDataTable($page);
146 $tab->create($page, $hier_id, $pc_id);
147 $tab->setLanguage($this->user->getLanguage());
148
149 $this->setRowHeaderAndCharacteristic($tab, $body);
150
151 $table_data = $body["import_table"] ?? "";
152
153 $tab->importSpreadsheet($this->user->getLanguage(), trim($table_data));
154
155 $updated = $page->update();
156
157 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
158 }

References ILIAS\COPage\PC\Table\TableCommandActionHandler\setRowHeaderAndCharacteristic(), and ILIAS\Repository\user().

Referenced by ILIAS\COPage\PC\Table\TableCommandActionHandler\insertCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insertCommand()

ILIAS\COPage\PC\Table\TableCommandActionHandler::insertCommand ( array  $body)
protected

Definition at line 73 of file class.TableCommandActionHandler.php.

73 : Server\Response
74 {
75 if (($body["import"] ?? "") === "1") {
76 return $this->importSpreadsheet($body);
77 }
78
79 $page = $this->page_gui->getPageObject();
80
81 $hier_id = "pg";
82 $pc_id = "";
83 if (!in_array($body["after_pcid"], ["", "pg"])) {
84 $hier_ids = $page->getHierIdsForPCIds([$body["after_pcid"]]);
85 $hier_id = $hier_ids[$body["after_pcid"]];
86 $pc_id = $body["after_pcid"];
87 }
88
89 $tab = new \ilPCDataTable($page);
90 $tab->create($page, $hier_id, $pc_id);
91 $lang = $this->user->getLanguage();
92 if ($lang === "") {
93 $lang = "en";
94 }
95 $tab->setLanguage($lang);
96
97
98 $tab->addRows(
99 (int) ($body["nr_rows"] ?? 1),
100 (int) ($body["nr_cols"] ?? 1)
101 );
102
103
104 $this->setRowHeaderAndCharacteristic($tab, $body);
105
106 $updated = $page->update();
107
108 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
109 }
$lang
Definition: xapiexit.php:25

References $lang, ILIAS\COPage\PC\Table\TableCommandActionHandler\importSpreadsheet(), ILIAS\COPage\PC\Table\TableCommandActionHandler\setRowHeaderAndCharacteristic(), and ILIAS\Repository\user().

Referenced by ILIAS\COPage\PC\Table\TableCommandActionHandler\handle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendTable()

ILIAS\COPage\PC\Table\TableCommandActionHandler::sendTable ( \ilPageObjectGUI  $page_gui,
string  $pcid 
)

Send whole table as response.

Definition at line 319 of file class.TableCommandActionHandler.php.

322 : Server\Response {
323 $page = $page_gui->getPageObject();
324 $page->addHierIDs();
325 $table = $page->getContentObjectForPcId($pcid);
326 if ($table->getType() == "dtab") {
327 $table_gui = new \ilPCDataTableGUI(
329 $table,
330 $page->getHierIdForPcId($pcid),
331 $pcid
332 );
333 } else {
334 $table_gui = new \ilPCTableGUI(
336 $table,
337 $page->getHierIdForPcId($pcid),
338 $pcid
339 );
340 }
341 $table_gui->setStyleId($page_gui->getStyleId());
342 $data = new \stdClass();
343 $data->renderedContent = $table_gui->getEditDataTable();
344 $data->pcModel = $page_gui->getPageObject()->getPCModel();
345 return new Server\Response($data);
346 }

References ilPageObjectGUI\getPageObject().

+ Here is the call graph for this function:

◆ sendUpdateResponse()

ILIAS\COPage\PC\Table\TableCommandActionHandler::sendUpdateResponse ( \ilPageObjectGUI  $page_gui,
  $updated,
string  $pcid 
)
Parameters
string | bool | array$updated
Exceptions

ilDateTimeException

Definition at line 174 of file class.TableCommandActionHandler.php.

178 : Server\Response {
179 $error = null;
180
181 $last_change = null;
182 if ($updated !== true) {
183 if (is_array($updated)) {
184 $error = implode("<br />", $updated);
185 } elseif (is_string($updated)) {
186 $error = $updated;
187 } else {
188 $error = print_r($updated, true);
189 }
190 } else {
191 $last_change = $page_gui->getPageObject()->getLastChange();
192 }
193
194 $data = new \stdClass();
195 $data->error = $error;
196 if ($last_change) {
197 $lu = new \ilDateTime($last_change, IL_CAL_DATETIME);
199 $data->last_update = \ilDatePresentation::formatDate($lu, true);
200 }
201
202 return new Server\Response($data);
203 }
ilErrorHandling $error
Definition: class.ilias.php:69
const IL_CAL_DATETIME
static setUseRelativeDates(bool $a_status)
set use relative dates
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)

References ILIAS\$error.

Referenced by ILIAS\COPage\PC\Table\TableCommandActionHandler\updateDataCommand().

+ Here is the caller graph for this function:

◆ setRowHeaderAndCharacteristic()

ILIAS\COPage\PC\Table\TableCommandActionHandler::setRowHeaderAndCharacteristic ( \ilPCTable  $tab,
array  $body 
)
protected

Definition at line 111 of file class.TableCommandActionHandler.php.

111 : void
112 {
113 if ($body["has_row_header"] ?? false) {
114 $tab->setHeaderRows(1);
115 }
116 $characteristic = ($body["characteristic"] ?? "");
117 if ($characteristic === "" && isset($body["import_characteristic"])) {
118 $characteristic = $body["import_characteristic"];
119 }
120 if ($characteristic === "") {
121 $characteristic = "StandardTable";
122 }
123 if (strpos($characteristic, ":") > 0) {
124 $t = explode(":", $characteristic);
125 $tab->setTemplate($t[2]);
126 $tab->setClass("");
127 } else {
128 $tab->setClass($characteristic);
129 $tab->setTemplate("");
130 }
131 }

References ilPCTable\setClass(), ilPCTable\setHeaderRows(), and ilPCTable\setTemplate().

Referenced by ILIAS\COPage\PC\Table\TableCommandActionHandler\importSpreadsheet(), and ILIAS\COPage\PC\Table\TableCommandActionHandler\insertCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateData()

ILIAS\COPage\PC\Table\TableCommandActionHandler::updateData ( string  $pcid,
array  $content 
)
protected
Returns
array|bool
Exceptions

ilDateTimeException

Definition at line 210 of file class.TableCommandActionHandler.php.

213 {
214 $page = $this->page_gui->getPageObject();
215 $table = $page->getContentObjectForPcId($pcid);
216
217 $data = [];
218 $updated = true;
219 foreach ($content as $i => $row) {
220 if (is_array($row)) {
221 foreach ($row as $j => $cell) {
222 $text = "<div>" . $cell . "</div>";
223 if ($updated) {
224 // determine cell content
226 $data[$i][$j] = $text;
227 $updated = (!is_null($text));
228 $text = $text["text"];
229 }
230 if ($updated) {
232 $text,
233 $table->getLanguage(),
234 true,
235 false
236 );
238
239 $data[$i][$j] = $text;
240 }
241 }
242 }
243 }
244
245 if ($updated) {
246 $table->setData($data);
247 $updated = $page->update();
248 }
249
250 return $updated;
251 }
static handleAjaxContentPost(string $text)
Post input2xml handling of ajax content.
static _input2xml(string $a_text, string $a_lang, bool $a_wysiwyg=false, bool $a_handle_lists=true)
Converts user input to xml User input comes as bb code information, e.g.
static handleAjaxContent(string $a_content)
Handle ajax content.

References $data, ilPCParagraph\_input2xml(), ilPCParagraph\handleAjaxContent(), and ilPCParagraph\handleAjaxContentPost().

Referenced by ILIAS\COPage\PC\Table\TableCommandActionHandler\updateDataCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateDataCommand()

ILIAS\COPage\PC\Table\TableCommandActionHandler::updateDataCommand ( array  $body)
protected

Definition at line 160 of file class.TableCommandActionHandler.php.

160 : Server\Response
161 {
162 $updated = $this->updateData($body["data"]["pcid"], $body["data"]["content"]);
163 if ($body["data"]["redirect"]) {
164 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
165 } else {
166 return $this->sendUpdateResponse($this->page_gui, $updated, $body["data"]["pcid"]);
167 }
168 }
sendUpdateResponse(\ilPageObjectGUI $page_gui, $updated, string $pcid)

References ILIAS\COPage\PC\Table\TableCommandActionHandler\sendUpdateResponse(), and ILIAS\COPage\PC\Table\TableCommandActionHandler\updateData().

Referenced by ILIAS\COPage\PC\Table\TableCommandActionHandler\handle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $lng

ilLanguage ILIAS\COPage\PC\Table\TableCommandActionHandler::$lng
protected

Definition at line 30 of file class.TableCommandActionHandler.php.

◆ $page_gui

ilPageObjectGUI ILIAS\COPage\PC\Table\TableCommandActionHandler::$page_gui
protected

◆ $ui

ILIAS DI UIServices ILIAS\COPage\PC\Table\TableCommandActionHandler::$ui
protected

Definition at line 29 of file class.TableCommandActionHandler.php.

◆ $ui_wrapper

Server UIWrapper ILIAS\COPage\PC\Table\TableCommandActionHandler::$ui_wrapper
protected

Definition at line 33 of file class.TableCommandActionHandler.php.

◆ $user

ilObjUser ILIAS\COPage\PC\Table\TableCommandActionHandler::$user
protected

Definition at line 32 of file class.TableCommandActionHandler.php.


The documentation for this class was generated from the following file: