29 protected \ILIAS\DI\UIServices
$ui;
30 protected \ilLanguage
$lng;
39 $this->
ui = $DIC->ui();
40 $this->
lng = $DIC->language();
42 $this->
user = $DIC->user();
44 $this->ui_wrapper =
new Server\UIWrapper($this->
ui, $this->
lng);
49 switch ($body[
"action"]) {
57 return $this->modifyTableCommand($body);
60 return $this->updateCommand($body);
62 case "set.properties":
63 return $this->setCellProperties($body);
66 return $this->toggleMerge($body);
69 throw new Exception(
"Unknown action " . $body[
"action"]);
75 if (($body[
"import"] ??
"") ===
"1") {
79 $page = $this->page_gui->getPageObject();
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"];
89 $tab = new \ilPCDataTable($page);
90 $tab->create($page, $hier_id, $pc_id);
95 $tab->setLanguage(
$lang);
99 (
int) ($body[
"nr_rows"] ?? 1),
100 (
int) ($body[
"nr_cols"] ?? 1)
106 $updated = $page->update();
108 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
113 if ($body[
"has_row_header"] ??
false) {
116 $characteristic = ($body[
"characteristic"] ??
"");
117 if ($characteristic ===
"" && isset($body[
"import_characteristic"])) {
118 $characteristic = $body[
"import_characteristic"];
120 if ($characteristic ===
"") {
121 $characteristic =
"StandardTable";
123 if (strpos($characteristic,
":") > 0) {
124 $t = explode(
":", $characteristic);
135 $page = $this->page_gui->getPageObject();
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"];
145 $tab = new \ilPCDataTable($page);
146 $tab->create($page, $hier_id, $pc_id);
147 $tab->setLanguage($this->
user->getLanguage());
151 $table_data = $body[
"import_table"] ??
"";
153 $tab->importSpreadsheet($this->
user->getLanguage(), trim($table_data));
155 $updated = $page->update();
157 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
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);
182 if ($updated !==
true) {
183 if (is_array($updated)) {
184 $error = implode(
"<br />", $updated);
185 } elseif (is_string($updated)) {
188 $error = print_r($updated,
true);
194 $data = new \stdClass();
202 return new Server\Response(
$data);
214 $page = $this->page_gui->getPageObject();
215 $table = $page->getContentObjectForPcId($pcid);
219 foreach ($content as $i => $row) {
220 if (is_array($row)) {
221 foreach ($row as $j => $cell) {
222 $text =
"<div>" . $cell .
"</div>";
226 $data[$i][$j] = $text;
227 $updated = (!is_null($text));
228 $text = $text[
"text"];
233 $table->getLanguage(),
239 $data[$i][$j] = $text;
246 $table->setData(
$data);
247 $updated = $page->update();
254 protected function modifyTableCommand(array $body): Server\Response
256 $page = $this->page_gui->getPageObject();
260 $table = $page->getContentObjectForPcId($body[
"data"][
"tablePcid"]);
263 if ($table->getType() ==
"dtab" && $body[
"data"][
"modification"] !==
"none") {
264 $this->
updateData($body[
"data"][
"tablePcid"], $body[
"data"][
"content"]);
271 if ($body[
"data"][
"modification"] !==
"none") {
272 $td = $page->getContentObjectForPcId($body[
"data"][
"cellPcid"]);
275 $cnt = $body[
"data"][
"cnt"] ?? 1;
276 switch ($body[
"data"][
"modification"]) {
278 $td->newColBefore($cnt);
281 $td->newColAfter($cnt);
293 $td->newRowBefore($cnt);
296 $td->newRowAfter($cnt);
313 return $this->
sendTable($this->page_gui, $body[
"data"][
"tablePcid"]);
325 $table = $page->getContentObjectForPcId($pcid);
326 if ($table->getType() ==
"dtab") {
327 $table_gui = new \ilPCDataTableGUI(
330 $page->getHierIdForPcId($pcid),
334 $table_gui = new \ilPCTableGUI(
337 $page->getHierIdForPcId($pcid),
341 $table_gui->setStyleId($page_gui->
getStyleId());
342 $data = new \stdClass();
343 $data->renderedContent = $table_gui->getEditDataTable();
345 return new Server\Response(
$data);
348 protected function updateCommand(array $body): Server\Response
350 $page = $this->page_gui->getPageObject();
353 $tab = $page->getContentObjectForPcId($body[
"pcid"]);
357 $header_row = (bool) ($body[
"has_row_header"] ??
false);
358 if ($tab->getHeaderRows() === 0 && $header_row) {
359 $tab->setHeaderRows(1);
361 if ($tab->getHeaderRows() > 0 && !$header_row) {
362 $tab->setHeaderRows(0);
365 $updated = $page->update();
366 return $this->ui_wrapper->sendPage($this->page_gui, $updated);
369 protected function setCellProperties(array $body): Server\Response
371 $page = $this->page_gui->getPageObject();
374 $tab = $page->getContentObjectForPcId($body[
"pcid"]);
375 $top = (
int) ($body[
"top"] ?? -1);
376 $bottom = (
int) ($body[
"bottom"] ?? -1);
377 $left = (
int) ($body[
"left"] ?? -1);
378 $right = (
int) ($body[
"right"] ?? -1);
379 if ($top !== -1 && $bottom !== -1 && $left !== -1 && $right !== -1) {
380 for ($i = $top; $i <= $bottom; $i++) {
381 for ($j = $left; $j <= $right; $j++) {
382 $td_node = $tab->getTableDataNode($i, $j);
385 if (isset($body[
"style_cb"])) {
386 $class = $body[
"style"] ??
"";
388 $td_node->removeAttribute(
"Class");
390 $td_node->setAttribute(
"Class", $class);
394 if (isset($body[
"width_cb"])) {
395 $width = $body[
"width"] ??
"";
397 $td_node->removeAttribute(
"Width");
399 $td_node->setAttribute(
"Width", $width);
403 if (isset($body[
"al_cb"])) {
404 $alignment = $body[
"alignment"] ??
"";
405 if ($alignment ===
"") {
406 $td_node->removeAttribute(
"HorizontalAlign");
408 $td_node->setAttribute(
"HorizontalAlign", $alignment);
416 $updated = $page->update();
417 return $this->
sendTable($this->page_gui, $body[
"pcid"]);
420 protected function toggleMerge(array $body): Server\Response
422 $page = $this->page_gui->getPageObject();
424 $data = $body[
"data"];
427 $tab = $page->getContentObjectForPcId(
$data[
"pcid"]);
429 $bottom = (
int) (
$data[
"bottom"] ?? -1);
430 $left = (
int) (
$data[
"left"] ?? -1);
431 $right = (
int) (
$data[
"right"] ?? -1);
433 $td_node = $tab->getTableDataNode($top, $left);
434 $td_node->setAttribute(
"ColSpan", $right - $left + 1);
435 $td_node->setAttribute(
"RowSpan", $bottom - $top + 1);
437 $tab->fixHideAndSpans();
439 $updated = $page->update();
importSpreadsheet(array $body)
static array static setUseRelativeDates(bool $a_status)
set use relative dates
static handleAjaxContent(string $a_content)
Handle ajax content.
setRowHeaderAndCharacteristic(\ilPCTable $tab, array $body)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
sendTable(\ilPageObjectGUI $page_gui, string $pcid)
Send whole table as response.
sendUpdateResponse(\ilPageObjectGUI $page_gui, $updated, string $pcid)
__construct(\ilPageObjectGUI $page_gui)
updateData(string $pcid, array $content)
updateDataCommand(array $body)
handle(array $query, array $body)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
insertCommand(array $body)
static handleAjaxContentPost(string $text)
Post input2xml handling of ajax content.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilPageObjectGUI $page_gui
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
setClass(string $a_class)
Set Style Class of table.
setTemplate(string $a_template)
Server UIWrapper $ui_wrapper