ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilPCDataTable.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
30{
31 public function init(): void
32 {
33 $this->setType("dtab");
34 }
35
36 public function create(
37 ilPageObject $a_pg_obj,
38 string $a_hier_id,
39 string $a_pc_id = ""
40 ): void {
42 $a_hier_id,
43 $a_pc_id,
44 "Table",
45 ["Language" => "", "DataTable" => "y"]
46 );
47 }
48
49
50 public function makeEmptyCell(DomNode $td_node): void
51 {
52 // delete children of paragraph node
53 $this->dom_util->deleteAllChilds($td_node);
54
55 // create page content and paragraph node here.
56 $pc_node = $this->getNewPageContentNode();
57 $pc_node = $td_node->appendChild($pc_node);
58 $par_node = $this->dom_doc->createElement("Paragraph");
59 $par_node = $pc_node->appendChild($par_node);
60 $par_node->setAttribute("Characteristic", "TableContent");
61 $par_node->setAttribute(
62 "Language",
63 $this->getLanguage()
64 );
65 }
66
67
71 public function setData(array $a_data): bool|string|null
72 {
73 $error = "";
74 if (is_array($a_data)) {
75 foreach ($a_data as $i => $row) {
76 if (is_array($row)) {
77 foreach ($row as $j => $cell) {
78 $temp_dom = $this->dom_util->docFromString(
79 '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $cell . '</Paragraph>',
80 $error
81 );
82 $par_node = $this->getCellNode($i, $j, true);
83 // remove all childs
84 if (empty($error) && !is_null($par_node)) {
85 // delete children of paragraph node
86 $this->dom_util->deleteAllChilds($par_node);
87
88 // copy new content children in paragraph node
89 $nodes = $this->dom_util->path(
90 $temp_dom,
91 "//Paragraph"
92 );
93
94 if (count($nodes) == 1) {
95 $new_par_node = $nodes->item(0);
96 foreach ($new_par_node->childNodes as $c) {
97 $cloned_child = $c->cloneNode(true);
98 $cloned_child = $this->dom_doc->importNode($cloned_child, true);
99 $par_node->appendChild($cloned_child);
100 }
101 }
102 } else {
103 if (!empty($error)) {
104 return $error;
105 }
106 }
107 }
108 }
109 }
110 }
111 return true;
112 }
113}
Class ilPCDataTable.
init()
Init object.
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
setData(array $a_data)
Set data of cells.
makeEmptyCell(DomNode $td_node)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
createInitialChildNode(string $hier_id, string $pc_id, string $child, array $child_attributes=[])
setType(string $a_type)
Set Type.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
$c
Definition: deliver.php:25
getLanguage()