26     public function init(): void
    46         $new_tr = $this->dom_doc->createElement(
"TableRow");
    56         $new_td = $this->dom_doc->createElement(
"TableData");
    57         $new_td = $aRow->appendChild($new_td);
    62             $new_par = $this->dom_doc->createElement(
"Paragraph");
    63             $new_par = $new_pg->appendChild($new_par);
    64             $new_par->setAttribute(
"Language", $a_lang);
    65             $new_par->setAttribute(
"Characteristic", 
"TableContent");
    66             $this->dom_util->setContent($new_par, $a_data);
    67             $new_td->appendChild($new_pg);
    79         if (!is_null($cell_par)) {
    81             foreach ($cell_par->childNodes as 
$c) {
    82                 $content .= $this->dom_util->dump($c);
    96             "/Table/TableRow[" . ($i + 1) . 
"]/TableData[" . ($j + 1) . 
"]/PageContent[1]/Paragraph[1]";
    97         $nodes = $this->dom_util->path($this->dom_doc, 
$path);
    98         if (!is_null($nodes->item(0))) {
    99             return $nodes->item(0);
   101             if (!$create_if_not_exists) {
   104             $path2 = 
"//PageContent[@HierId='" . $this->
getHierId() . 
"']" .
   105                 "/Table/TableRow[" . ($i + 1) . 
"]/TableData[" . ($j + 1) . 
"]";
   106             $nodes2 = $this->dom_util->path($this->dom_doc, $path2);
   108             $td_node = $nodes2->item(0);
   110             if (!is_null($td_node)) {
   112                 $this->dom_util->deleteAllChilds($td_node);
   116                 $pc_node = $td_node->appendChild($pc_node);
   117                 $par_node = $this->dom_doc->createElement(
"Paragraph");
   118                 $par_node = $pc_node->appendChild($par_node);
   119                 $par_node->setAttribute(
"Characteristic", 
"TableContent");
   120                 $par_node->setAttribute(
   138             "/Table/TableRow[$i+1]/TableData[$j+1]";
   139         $nodes = $this->dom_util->path($this->dom_doc, 
$path);
   141         if (count($nodes) > 0) {
   142             return $nodes->item(0);
   150     public function addRows(
int $a_nr_rows, 
int $a_nr_cols): void
   152         for ($i = 1; $i <= $a_nr_rows; $i++) {
   154             for ($j = 1; $j <= $a_nr_cols; $j++) {
   169         str_replace($a_data, 
"\r", 
"\n");
   170         str_replace($a_data, 
"\n\n", 
"\n");
   171         $target_rows = array();
   172         $rows = explode(
"\n", $a_data);
   176         foreach ($rows as $row) {
   177             $cells = explode(
"\t", $row);
   178             if (count($cells) === 1) {
   179                 $cells = explode(
";", $row);
   181             $max_cols = ($max_cols > count($cells))
   184             $target_rows[] = $cells;
   188         foreach ($target_rows as $row) {
   190             for ($j = 0; $j < $max_cols; $j++) {
   192                 $data = str_replace(
"&", 
"&", ($row[$j] ?? 
""));
   255         $this->
getChildNode()->setAttribute(
"HorizontalAlign", $a_halign);
   271         if ($a_pc_id == 
"") {
   272             $path = 
"//TableData[@HierId = '" . $a_hier_id . 
"']";
   274             $path = 
"//TableData[@PCID = '" . $a_pc_id . 
"']";
   276         $nodes = $this->dom_util->path($this->dom_doc, 
$path);
   278         if (count($nodes) == 1) {
   279             if ($a_width != 
"") {
   280                 $nodes->item(0)->setAttribute(
"Width", $a_width);
   282                 if ($nodes->item(0)->hasAttribute(
"Width")) {
   283                     $nodes->item(0)->removeAttribute(
"Width");
   295         foreach ($rows as $row) {
   296             if ($row->nodeName == 
"TableRow") {
   298                 $cells = $row->childNodes;
   299                 foreach ($cells as $cell) {
   300                     if ($cell->nodeName == 
"TableData") {
   301                         $ckey = $cell->getAttribute(
"HierId") . 
":" . $cell->getAttribute(
"PCID");
   302                         if ((
int) ($a_colspans[$ckey] ?? 0) > 1) {
   303                             $cell->setAttribute(
"ColSpan", (
int) $a_colspans[$ckey]);
   305                             if ($cell->hasAttribute(
"ColSpan")) {
   306                                 $cell->removeAttribute(
"ColSpan");
   309                         if ((
int) ($a_rowspans[$ckey] ?? 0) > 1) {
   310                             $cell->setAttribute(
"RowSpan", (
int) $a_rowspans[$ckey]);
   312                             if ($cell->hasAttribute(
"RowSpan")) {
   313                                 $cell->removeAttribute(
"RowSpan");
   337         foreach ($rows as $row) {
   338             if ($row->nodeName == 
"TableRow") {
   340                 $cells = $row->childNodes;
   341                 foreach ($cells as $cell) {
   342                     if ($cell->nodeName == 
"TableData") {
   343                         $max_x = max($max_x, $x);
   344                         $max_y = max($max_y, $y);
   357         foreach ($rows as $row) {
   358             if ($row->nodeName == 
"TableRow") {
   360                 $cells = $row->childNodes;
   361                 foreach ($cells as $cell) {
   362                     if ($cell->nodeName == 
"TableData") {
   363                         $cspan = max(1, (
int) $cell->getAttribute(
"ColSpan"));
   364                         $rspan = max(1, (
int) $cell->getAttribute(
"RowSpan"));
   367                         if ($cspan > $max_x - $x + 1) {
   368                             $cell->setAttribute(
"ColSpan", $max_x - $x + 1);
   369                             $cspan = $max_x - $x + 1;
   371                         if ($rspan > $max_y - $y + 1) {
   372                             $cell->setAttribute(
"RowSpan", $max_y - $y + 1);
   373                             $rspan = $max_y - $y + 1;
   379                             $cell->setAttribute(
"Hidden", 
"Y");
   382                             if ($cell->hasAttribute(
"ColSpan")) {
   383                                 $cell->removeAttribute(
"ColSpan");
   385                             if ($cell->hasAttribute(
"RowSpan")) {
   386                                 $cell->removeAttribute(
"RowSpan");
   391                             if ($cell->hasAttribute(
"Hidden")) {
   392                                 $cell->removeAttribute(
"Hidden");
   396                         $colspans[$x][$y] = $cspan;
   397                         $rowspans[$x][$y] = $rspan;
   410         $this->dom_util->deleteAllChilds($td_node);
   416     public function checkCellHidden(array $colspans, array $rowspans, 
int $x, 
int $y): bool
   418         for ($i = 0; $i <= $x; $i++) {
   419             for ($j = 0; $j <= $y; $j++) {
   420                 if ($i != $x || $j != $y) {
   421                     if ((($i + $colspans[$i][$j] > $x) &&
   422                         ($j + $rowspans[$i][$j] > $y))) {
   438         foreach ($rows as $row) {
   439             if ($row->nodeName == 
"TableRow") {
   440                 $cells = $row->childNodes;
   441                 foreach ($cells as $cell) {
   442                     if ($cell->nodeName == 
"TableData") {
   443                         $classes[$cell->getAttribute(
"HierId") . 
":" . $cell->getAttribute(
"PCID")]
   444                             = $cell->getAttribute(
"Class");
   457         foreach ($rows as $row) {
   458             if ($row->nodeName == 
"TableRow") {
   459                 $cells = $row->childNodes;
   460                 foreach ($cells as $cell) {
   461                     if ($cell->nodeName == 
"TableData") {
   462                         $classes[$cell->getAttribute(
"HierId") . 
":" . $cell->getAttribute(
"PCID")]
   463                             = $cell->getAttribute(
"HorizontalAlign");
   482         foreach ($rows as $row) {
   483             if ($row->nodeName == 
"TableRow") {
   485                 $cells = $row->childNodes;
   486                 foreach ($cells as $cell) {
   487                     if ($cell->nodeName == 
"TableData") {
   488                         $spans[$cell->getAttribute(
"HierId") . 
":" . $cell->getAttribute(
"PCID")]
   489                             = array(
"x" => $x, 
"y" => $y, 
"colspan" => $cell->getAttribute(
"ColSpan"),
   490                                 "rowspan" => $cell->getAttribute(
"RowSpan"));
   491                         $max_x = max($max_x, $x);
   492                         $max_y = max($max_y, $y);
   499         foreach ($spans as $k => $v) {
   500             $spans[$k][
"max_x"] = $max_x;
   501             $spans[$k][
"max_y"] = $max_y;
   515         foreach ($rows as $row) {
   516             if ($row->nodeName == 
"TableRow") {
   517                 $cells = $row->childNodes;
   518                 foreach ($cells as $cell) {
   519                     if ($cell->nodeName == 
"TableData") {
   520                         $widths[$cell->getAttribute(
"HierId") . 
":" . $cell->getAttribute(
"PCID")]
   521                             = $cell->getAttribute(
"Width");
   538         if ($a_pc_id == 
"") {
   539             $path = 
"//TableData[@HierId = '" . $a_hier_id . 
"']";
   541             $path = 
"//TableData[@PCID = '" . $a_pc_id . 
"']";
   543         $nodes = $this->dom_util->path($this->dom_doc, 
$path);
   544         if (count($nodes) == 1) {
   545             if ($a_class != 
"") {
   546                 $nodes->item(0)->setAttribute(
"Class", $a_class);
   548                 if ($nodes->item(0)->hasAttribute(
"Class")) {
   549                     $nodes->item(0)->removeAttribute(
"Class");
   563         if ($a_pc_id == 
"") {
   564             $path = 
"//TableData[@HierId = '" . $a_hier_id . 
"']";
   566             $path = 
"//TableData[@PCID = '" . $a_pc_id . 
"']";
   568         $nodes = $this->dom_util->path($this->dom_doc, 
$path);
   569         if (count($nodes) == 1) {
   570             if ($a_class != 
"") {
   571                 $nodes->item(0)->setAttribute(
"HorizontalAlign", $a_class);
   573                 if ($nodes->item(0)->hasAttribute(
"HorizontalAlign")) {
   574                     $nodes->item(0)->removeAttribute(
"HorizontalAlign");
   584             $path = 
"//PageContent[@HierId = '" . 
$hier_id . 
"']/Table/Caption";
   585             $nodes = $this->dom_util->path($this->dom_doc, 
$path);
   586             if (count($nodes) == 1) {
   587                 return $this->dom_util->getContent($nodes->item(0));
   600             $path = 
"//PageContent[@HierId = '" . 
$hier_id . 
"']/Table/Caption";
   601             $nodes = $this->dom_util->path($this->dom_doc, 
$path);
   602             if (count($nodes) == 1) {
   603                 return $nodes->item(0)->getAttribute(
"Align");
   609     public function setCaption(
string $a_content, 
string $a_align): void
   611         if ($a_content != 
"") {
   612             $this->dom_util->setFirstOptionalElement(
   615                 array(
"Summary", 
"TableRow"),
   617                 array(
"Align" => $a_align)
   620             $this->dom_util->deleteAllChildsByName(
   631             if ($child->nodeName == 
"TableRow") {
   632                 foreach ($child->childNodes as $gchild) {
   633                     if ($gchild->nodeName == 
"TableData") {
   634                         $gchild->setAttribute(
"Class", $a_class);
   712         if (!empty($a_value)) {
   731         return array(
"ed_insert_dtable", 
"ed_insert_atable",
"ed_new_row_after", 
"ed_new_row_before",
   732             "ed_new_col_after", 
"ed_new_col_before", 
"ed_delete_col",
   733             "ed_delete_row", 
"ed_edit_data", 
"ed_row_up", 
"ed_row_down",
   734             "ed_col_left", 
"ed_col_right");
   740         bool $a_self_ass = 
true,
   741         bool $a_clone_mobs = 
false,
   742         int $new_parent_id = 0,
   746         $nodes = $xpath->query(
"//Table");
   747         foreach ($nodes as $node) {
   748             $node->removeAttribute(
"Id");
   754         $this->log->debug(
"Get table model start");
   755         $model = new \stdClass();
   759             if ($row->nodeName == 
"TableRow") {
   761                 foreach ($row->childNodes as $cell) {
   762                     if ($cell->nodeName == 
"TableData") {
   769                         $model->content[$y][$x] = $text;
   779             $model->characteristic = 
"";
   781             $model->characteristic = $this->
getClass();
   782             $model->template = 
"";
   786         $this->log->debug(
"...end");
 importSpreadsheet(string $a_lang, string $a_data)
import from table 
 
setType(string $a_type)
Set Type. 
 
setCellPadding(string $a_padding)
 
addRows(int $a_nr_rows, int $a_nr_cols)
add rows to table 
 
static xml2outputJS(string $s_text)
Prepare content for js output. 
 
checkCellHidden(array $colspans, array $rowspans, int $x, int $y)
Check hidden status. 
 
setCellSpacing(string $a_spacing)
 
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
setTDAlignment(string $a_hier_id, string $a_class, string $a_pc_id="")
set alignment of table data cell 
 
getCellNode(int $i, int $j, bool $create_if_not_exists=false)
Get cell paragraph node of row $i and cell $j. 
 
setTDWidth(string $a_hier_id, string $a_width, string $a_pc_id="")
set width of table data cell 
 
static xml2output(string $a_text, bool $a_wysiwyg=false, bool $a_replace_lists=true, bool $unmask=true)
Converts xml from DB to output in edit textarea. 
 
setCaption(string $a_content, string $a_align)
 
getTableDataNode(int $i, int $j)
Get cell paragraph node of row $i and cell $j. 
 
Content object of ilPageObject (see ILIAS DTD). 
 
addCell(DOMNode $aRow, string $a_data="", string $a_lang="")
 
setTableAttribute(string $a_attr, string $a_value)
Set attribute of table tag. 
 
makeEmptyCell(DomNode $td_node)
 
setHorizontalAlign(string $a_halign)
 
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD) 
 
static handleCopiedContent(DOMDocument $a_domdoc, bool $a_self_ass=true, bool $a_clone_mobs=false, int $new_parent_id=0, int $obj_copy_id=0)
 
getCellText(int $i, int $j)
Get cell text of row $i and cell $j. 
 
getAllCellWidths()
Get all cell widths. 
 
setFirstRowStyle(string $a_class)
 
getCaptionAlign()
get caption alignment (Top | Bottom) 
 
setBorder(string $a_border)
 
getAllCellSpans()
Get all cell spans. 
 
setWidth(string $a_width)
 
setTDSpans(array $a_colspans, array $a_rowspans)
 
setClass(string $a_class)
Set Style Class of table. 
 
getTableAttribute(string $a_attr)
 
setTDClass(string $a_hier_id, string $a_class, string $a_pc_id="")
set class of table data cell 
 
setTemplate(string $a_template)
 
getAllCellClasses()
Get all cell classes. 
 
setLanguage(string $a_lang)
 
createInitialChildNode(string $hier_id, string $pc_id, string $child, array $child_attributes=[])
 
fixHideAndSpans()
Fix Hide and Spans.