ILIAS  release_8 Revision v8.24
ilPCTable Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilPCTable:
+ Collaboration diagram for ilPCTable:

Public Member Functions

 init ()
 Init object. More...
 
 setNode (php4DOMElement $a_node)
 Set xml node of page content. More...
 
 create (ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
 
 addRow ()
 
 addCell (php4DOMElement $aRow, string $a_data="", string $a_lang="")
 
 getCellText (int $i, int $j)
 Get cell text of row $i and cell $j. More...
 
 getCellNode (int $i, int $j, bool $create_if_not_exists=false)
 Get cell paragraph node of row $i and cell $j. More...
 
 addRows (int $a_nr_rows, int $a_nr_cols)
 add rows to table More...
 
 importSpreadsheet (string $a_lang, string $a_data)
 import from table More...
 
 getLanguage ()
 
 setLanguage (string $a_lang)
 
 getWidth ()
 
 setWidth (string $a_width)
 
 getBorder ()
 
 setBorder (string $a_border)
 
 getCellSpacing ()
 
 setCellSpacing (string $a_spacing)
 
 getCellPadding ()
 
 setCellPadding (string $a_padding)
 
 setHorizontalAlign (string $a_halign)
 
 getHorizontalAlign ()
 
 setTDWidth (string $a_hier_id, string $a_width, string $a_pc_id="")
 set width of table data cell More...
 
 setTDSpans (array $a_colspans, array $a_rowspans)
 
 fixHideAndSpans ()
 Fix Hide and Spans. More...
 
 makeEmptyCell (php4DOMElement $td_node)
 Make cell empty. More...
 
 checkCellHidden (array $colspans, array $rowspans, int $x, int $y)
 Check hidden status. More...
 
 getAllCellClasses ()
 Get all cell classes. More...
 
 getAllCellAlignments ()
 
 getAllCellSpans ()
 Get all cell spans. More...
 
 getAllCellWidths ()
 Get all cell widths. More...
 
 setTDClass (string $a_hier_id, string $a_class, string $a_pc_id="")
 set class of table data cell More...
 
 setTDAlignment (string $a_hier_id, string $a_class, string $a_pc_id="")
 set alignment of table data cell More...
 
 getCaption ()
 
 getCaptionAlign ()
 get caption alignment (Top | Bottom) More...
 
 setCaption (string $a_content, string $a_align)
 
 importTableAttributes (php4DOMElement $node)
 
 importCellAttributes (php4DOMElement $node, php4DOMElement $par)
 
 importRow (string $lng, php4DOMElement $node)
 
 importCell (string $lng, php4DOMElement $cellNode, php4DOMElement $aRow)
 
 extractText (php4DOMElement $node)
 
 importHtml (string $lng, string $htmlTable)
 
 setFirstRowStyle (string $a_class)
 
 setClass (string $a_class)
 Set Style Class of table. More...
 
 getClass ()
 
 setTemplate (string $a_template)
 
 getTemplate ()
 
 setHeaderRows (int $a_nr)
 
 getHeaderRows ()
 
 setFooterRows (int $a_nr)
 
 getFooterRows ()
 
 setHeaderCols (int $a_nr)
 
 getHeaderCols ()
 
 setFooterCols (int $a_nr)
 
 getFooterCols ()
 
 getTableAttribute (string $a_attr)
 
 getModel ()
 Get model as needed for the front-end editor. More...
 
- Public Member Functions inherited from ilPageContent
 __construct (ilPageObject $a_pg_obj)
 
 setPage (ilPageObject $a_val)
 
 getPage ()
 
 init ()
 Init object. More...
 
 getType ()
 
 setNode (php4DOMElement $a_node)
 Set xml node of page content. More...
 
 getNode ()
 
 getJavascriptFiles (string $a_mode)
 
 getCssFiles (string $a_mode)
 
 getOnloadCode (string $a_mode)
 
 setHierId (string $a_hier_id)
 
 getHierId ()
 
 lookupHierId ()
 
 readHierId ()
 
 setPcId (string $a_pcid)
 
 getPCId ()
 
 setFileDownloadLink (string $a_download_link)
 
 getFileDownloadLink ()
 
 setProfileBackUrl (string $url)
 
 getProfileBackUrl ()
 
 setFullscreenLink (string $a_fullscreen_link)
 
 getFullscreenLink ()
 
 setSourcecodeDownloadScript (string $script_name)
 
 getSourcecodeDownloadScript ()
 
 readPCId ()
 
 writePCId (string $a_pc_id)
 
 setEnabled (string $value)
 Set Enabled value for page content component. More...
 
 enable ()
 
 disable ()
 
 isEnabled ()
 
 createPageContentNode (bool $a_set_this_node=true)
 Create page content node (always use this method first when adding a new element) More...
 
 modifyPageContentPostXsl (string $a_output, string $a_mode, bool $a_abstract_only=false)
 Modify page content after xsl. More...
 
 getModel ()
 Get model as needed for the front-end editor. More...
 

Static Public Member Functions

static getLangVars ()
 Get lang vars needed for editing. More...
 
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)
 Handle copied content. More...
 
- Static Public Member Functions inherited from ilPageContent
static incEdId (string $ed_id)
 Increases an hierarchical editing id at lowest level (last number) More...
 
static decEdId (string $ed_id)
 Decreases an hierarchical editing id at lowest level (last number) More...
 
static sortHierIds (array $a_array)
 Sort an array of Hier IDS in ascending order. More...
 
static isGreaterHierId (string $a, string $b)
 Check whether Hier ID $a is greater than Hier ID $b. More...
 
static getLangVars ()
 Get lang vars needed for editing. More...
 
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)
 Handle copied content. More...
 
static afterPageUpdate (ilPageObject $a_page, DOMDocument $a_domdoc, string $a_xml, bool $a_creation)
 After page has been updated (or created) More...
 
static beforePageDelete (ilPageObject $a_page)
 Before page is being deleted. More...
 
static afterRepositoryCopy (ilPageObject $page, array $mapping, int $source_ref_id)
 After repository (container) copy action. More...
 
static afterPageHistoryEntry (ilPageObject $a_page, DOMDocument $a_old_domdoc, string $a_old_xml, int $a_old_nr)
 After page history entry has been created. More...
 
static deleteHistoryLowerEqualThan (string $parent_type, int $page_id, string $lang, int $delete_lower_than_nr)
 Overwrite in derived classes, if old history entries are being deleted. More...
 

Data Fields

php4DOMElement $tab_node
 
- Data Fields inherited from ilPageContent
string $hier_id = ""
 
php4DOMElement $node = null
 
php4DOMDocument $dom = null
 
string $page_lang = ""
 

Protected Member Functions

 setTableAttribute (string $a_attr, string $a_value)
 Set attribute of table tag. More...
 
- Protected Member Functions inherited from ilPageContent
 setType (string $a_type)
 Set Type. More...
 

Additional Inherited Members

- Protected Attributes inherited from ilPageContent
string $pcid
 
string $type = ""
 
ilPageObject $pg_obj
 
string $file_download_link
 
string $fullscreen_link
 
string $sourcecode_download_script
 
ilLogger $log
 
string $profile_back_url = ""
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilPCTable Table content object (see ILIAS DTD)

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

Definition at line 24 of file class.ilPCTable.php.

Member Function Documentation

◆ addCell()

ilPCTable::addCell ( php4DOMElement  $aRow,
string  $a_data = "",
string  $a_lang = "" 
)

Definition at line 58 of file class.ilPCTable.php.

63 $new_td = $this->dom->create_element("TableData");
64 $new_td = $aRow->append_child($new_td);
65
66 // insert data if given
67 if ($a_data != "") {
68 $new_pg = $this->createPageContentNode(false);
69 $new_par = $this->dom->create_element("Paragraph");
70 $new_par = $new_pg->append_child($new_par);
71 $new_par->set_attribute("Language", $a_lang);
72 $new_par->set_attribute("Characteristic", "TableContent");
73 $new_par->set_content($a_data);
74 $new_td->append_child($new_pg);
75 }
76
77 return $new_td;
78 }
createPageContentNode(bool $a_set_this_node=true)
Create page content node (always use this method first when adding a new element)
append_child($newnode)

◆ addRow()

ilPCTable::addRow ( )

Definition at line 51 of file class.ilPCTable.php.

52 {
53 $new_tr = $this->dom->create_element("TableRow");
54 $new_tr = $this->tab_node->append_child($new_tr);
55 return $new_tr;
56 }

References php4DOMNode\append_child().

+ Here is the call graph for this function:

◆ addRows()

ilPCTable::addRows ( int  $a_nr_rows,
int  $a_nr_cols 
)

add rows to table

Definition at line 154 of file class.ilPCTable.php.

154 : void
155 {
156 for ($i = 1; $i <= $a_nr_rows; $i++) {
157 $aRow = $this->addRow();
158 for ($j = 1; $j <= $a_nr_cols; $j++) {
159 $this->addCell($aRow);
160 }
161 }
162 }
addCell(php4DOMElement $aRow, string $a_data="", string $a_lang="")
$i
Definition: metadata.php:41

References $i.

◆ checkCellHidden()

ilPCTable::checkCellHidden ( array  $colspans,
array  $rowspans,
int  $x,
int  $y 
)

Check hidden status.

Definition at line 426 of file class.ilPCTable.php.

426 : bool
427 {
428 for ($i = 0; $i <= $x; $i++) {
429 for ($j = 0; $j <= $y; $j++) {
430 if ($i != $x || $j != $y) {
431 if ((($i + $colspans[$i][$j] > $x) &&
432 ($j + $rowspans[$i][$j] > $y))) {
433 return true;
434 }
435 }
436 }
437 }
438 return false;
439 }

References $i.

◆ create()

ilPCTable::create ( ilPageObject  $a_pg_obj,
string  $a_hier_id,
string  $a_pc_id = "" 
)

Reimplemented in ilPCDataTable.

Definition at line 39 of file class.ilPCTable.php.

43 : void {
44 $this->node = $this->createPageContentNode();
45 $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
46 $this->tab_node = $this->dom->create_element("Table");
47 $this->tab_node = $this->node->append_child($this->tab_node);
48 $this->tab_node->set_attribute("Language", "");
49 }
const IL_INSERT_AFTER
insertContent(ilPageContent $a_cont_obj, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="", bool $remove_placeholder=true)
insert a content node before/after a sibling or as first child of a parent

◆ extractText()

ilPCTable::extractText ( php4DOMElement  $node)

Definition at line 723 of file class.ilPCTable.php.

725 : string {
726 $output = "";
727
728 $owner_document = $node->owner_document();
729 $children = $node->child_nodes();
730 $total_children = count($children);
731 for ($i = 0; $i < $total_children; $i++) {
732 $cur_child_node = $children[$i];
733 $output .= $owner_document->dump_node($cur_child_node);
734 }
735 return $output;
736 }
php4DOMElement $node

◆ fixHideAndSpans()

ilPCTable::fixHideAndSpans ( )

Fix Hide and Spans.

Reduces col and rowspans that are to high. Sets Hide attribute for all cells that are hidden due to other span attributes. Sets hidden cells to empty.

Definition at line 333 of file class.ilPCTable.php.

333 : void
334 {
335
336 // first: get max x and y
337 $max_x = $max_y = 0;
338 $y = 0;
339 $rows = $this->tab_node->child_nodes();
340
341 foreach ($rows as $row) {
342 if ($row->node_name() == "TableRow") {
343 $x = 0;
344 $cells = $row->child_nodes();
345 foreach ($cells as $cell) {
346 if ($cell->node_name() == "TableData") {
347 $max_x = max($max_x, $x);
348 $max_y = max($max_y, $y);
349 }
350 $x++;
351 }
352 $y++;
353 }
354 }
355
356 // second: fix hidden/colspans for all cells
357 $y = 0;
358 $colspans = [];
359 $rowspans = [];
360 $rows = $this->tab_node->child_nodes();
361 foreach ($rows as $row) {
362 if ($row->node_name() == "TableRow") {
363 $x = 0;
364 $cells = $row->child_nodes();
365 foreach ($cells as $cell) {
366 if ($cell->node_name() == "TableData") {
367 $cspan = max(1, (int) $cell->get_attribute("ColSpan"));
368 $rspan = max(1, (int) $cell->get_attribute("RowSpan"));
369
370 // if col or rowspan is to high: reduce it to the max
371 if ($cspan > $max_x - $x + 1) {
372 $cell->set_attribute("ColSpan", $max_x - $x + 1);
373 $cspan = $max_x - $x + 1;
374 }
375 if ($rspan > $max_y - $y + 1) {
376 $cell->set_attribute("RowSpan", $max_y - $y + 1);
377 $rspan = $max_y - $y + 1;
378 }
379
380 // check hidden status
381 if ($this->checkCellHidden($colspans, $rowspans, $x, $y)) {
382 // hidden: set hidden flag, remove col and rowspan
383 $cell->set_attribute("Hidden", "Y");
384 $cspan = 1;
385 $rspan = 1;
386 if ($cell->has_attribute("ColSpan")) {
387 $cell->remove_attribute("ColSpan");
388 }
389 if ($cell->has_attribute("RowSpan")) {
390 $cell->remove_attribute("RowSpan");
391 }
392 $this->makeEmptyCell($cell);
393 } else {
394 // not hidden: remove hidden flag if existing
395 if ($cell->has_attribute("Hidden")) {
396 $cell->remove_attribute("Hidden");
397 }
398 }
399
400 $colspans[$x][$y] = $cspan;
401 $rowspans[$x][$y] = $rspan;
402 }
403 $x++;
404 }
405 $y++;
406 }
407 }
408 }
checkCellHidden(array $colspans, array $rowspans, int $x, int $y)
Check hidden status.
makeEmptyCell(php4DOMElement $td_node)
Make cell empty.
$rows
Definition: xhr_table.php:10

References $rows.

◆ getAllCellAlignments()

ilPCTable::getAllCellAlignments ( )

Definition at line 463 of file class.ilPCTable.php.

463 : array
464 {
465 $classes = array();
466 $rows = $this->tab_node->child_nodes();
467 foreach ($rows as $row) {
468 if ($row->node_name() == "TableRow") {
469 $cells = $row->child_nodes();
470 foreach ($cells as $cell) {
471 if ($cell->node_name() == "TableData") {
472 $classes[$cell->get_attribute("HierId") . ":" . $cell->get_attribute("PCID")]
473 = $cell->get_attribute("HorizontalAlign");
474 }
475 }
476 }
477 }
478
479 return $classes;
480 }

References $rows.

◆ getAllCellClasses()

ilPCTable::getAllCellClasses ( )

Get all cell classes.

Definition at line 444 of file class.ilPCTable.php.

444 : array
445 {
446 $classes = array();
447 $rows = $this->tab_node->child_nodes();
448 foreach ($rows as $row) {
449 if ($row->node_name() == "TableRow") {
450 $cells = $row->child_nodes();
451 foreach ($cells as $cell) {
452 if ($cell->node_name() == "TableData") {
453 $classes[$cell->get_attribute("HierId") . ":" . $cell->get_attribute("PCID")]
454 = $cell->get_attribute("Class");
455 }
456 }
457 }
458 }
459
460 return $classes;
461 }

References $rows.

◆ getAllCellSpans()

ilPCTable::getAllCellSpans ( )

Get all cell spans.

Definition at line 485 of file class.ilPCTable.php.

485 : array
486 {
487 $spans = array();
488 $rows = $this->tab_node->child_nodes();
489 $y = 0;
490 $max_x = 0;
491 $max_y = 0;
492 foreach ($rows as $row) {
493 if ($row->node_name() == "TableRow") {
494 $x = 0;
495 $cells = $row->child_nodes();
496 foreach ($cells as $cell) {
497 if ($cell->node_name() == "TableData") {
498 $spans[$cell->get_attribute("HierId") . ":" . $cell->get_attribute("PCID")]
499 = array("x" => $x, "y" => $y, "colspan" => $cell->get_attribute("ColSpan"),
500 "rowspan" => $cell->get_attribute("RowSpan"));
501 $max_x = max($max_x, $x);
502 $max_y = max($max_y, $y);
503 }
504 $x++;
505 }
506 $y++;
507 }
508 }
509 foreach ($spans as $k => $v) {
510 $spans[$k]["max_x"] = $max_x;
511 $spans[$k]["max_y"] = $max_y;
512 }
513
514 return $spans;
515 }

References $rows.

◆ getAllCellWidths()

ilPCTable::getAllCellWidths ( )

Get all cell widths.

Returns
array array of cell style classes

Definition at line 521 of file class.ilPCTable.php.

521 : array
522 {
523 $widths = array();
524 $rows = $this->tab_node->child_nodes();
525 foreach ($rows as $row) {
526 if ($row->node_name() == "TableRow") {
527 $cells = $row->child_nodes();
528 foreach ($cells as $cell) {
529 if ($cell->node_name() == "TableData") {
530 $widths[$cell->get_attribute("HierId") . ":" . $cell->get_attribute("PCID")]
531 = $cell->get_attribute("Width");
532 }
533 }
534 }
535 }
536
537 return $widths;
538 }

References $rows.

◆ getBorder()

ilPCTable::getBorder ( )

Definition at line 224 of file class.ilPCTable.php.

224 : string
225 {
226 return $this->getTableAttribute("Border");
227 }
getTableAttribute(string $a_attr)

◆ getCaption()

ilPCTable::getCaption ( )

Definition at line 592 of file class.ilPCTable.php.

592 : string
593 {
594 $hier_id = $this->getHierId();
595 if (!empty($hier_id)) {
596 $xpc = xpath_new_context($this->dom);
597 $path = "//PageContent[@HierId = '" . $hier_id . "']/Table/Caption";
598 $res = xpath_eval($xpc, $path);
599
600 if (count($res->nodeset) == 1) {
601 return $res->nodeset[0]->get_content();
602 }
603 }
604 return "";
605 }
xpath_new_context($dom_document)
xpath_eval(php4DOMXPath $xpath_context, string $eval_str, $contextnode=null)
$path
Definition: ltiservices.php:32
$res
Definition: ltiservices.php:69

References $path, $res, xpath_eval(), and xpath_new_context().

+ Here is the call graph for this function:

◆ getCaptionAlign()

ilPCTable::getCaptionAlign ( )

get caption alignment (Top | Bottom)

Definition at line 610 of file class.ilPCTable.php.

610 : string
611 {
612 $hier_id = $this->getHierId();
613 if (!empty($hier_id)) {
614 $xpc = xpath_new_context($this->dom);
615 $path = "//PageContent[@HierId = '" . $hier_id . "']/Table/Caption";
616 $res = xpath_eval($xpc, $path);
617 if (count($res->nodeset) == 1) {
618 return $res->nodeset[0]->get_attribute("Align");
619 }
620 }
621 return "";
622 }

References $path, $res, xpath_eval(), and xpath_new_context().

+ Here is the call graph for this function:

◆ getCellNode()

ilPCTable::getCellNode ( int  $i,
int  $j,
bool  $create_if_not_exists = false 
)

Get cell paragraph node of row $i and cell $j.

Definition at line 102 of file class.ilPCTable.php.

103 {
104 $xpc = xpath_new_context($this->dom);
105 $path = "//PageContent[@HierId='" . $this->getHierId() . "']" .
106 "/Table/TableRow[$i+1]/TableData[$j+1]/PageContent[1]/Paragraph[1]";
107 //echo "<br>++".$path;
108 //]--//PageContent[@HierId='3']/Table/TableRow[+1]/TableData[0 style=+1]/PageContent[1]/Paragraph[1]
109 $res = xpath_eval($xpc, $path);
110
111 if (isset($res->nodeset[0])) {
112 return $res->nodeset[0];
113 } else { // no node -> delete all childs and create paragraph
114 if (!$create_if_not_exists) {
115 return null;
116 }
117 $xpc2 = xpath_new_context($this->dom);
118 $path2 = "//PageContent[@HierId='" . $this->getHierId() . "']" .
119 "/Table/TableRow[" . ($i + 1) . "]/TableData[" . ($j + 1) . "]";
120 //$path2 = "//PageContent";
121
122 $res2 = xpath_eval($xpc2, $path2);
123
124 $td_node = $res2->nodeset[0];
125
126 if (is_object($td_node)) {
127 // delete children of paragraph node
128 $children = $td_node->child_nodes();
129 for ($i = 0; $i < count($children); $i++) {
130 $td_node->remove_child($children[$i]);
131 }
132
133 // create page content and paragraph node here.
134 $pc_node = $this->createPageContentNode(false);
135 $pc_node = $td_node->append_child($pc_node);
136 $par_node = $this->dom->create_element("Paragraph");
137 $par_node = $pc_node->append_child($par_node);
138 $par_node->set_attribute("Characteristic", "TableContent");
139 $par_node->set_attribute(
140 "Language",
141 $this->getLanguage()
142 );
143
144 return $par_node;
145 }
146 }
147
148 return null;
149 }

References $i, $path, $res, ILIAS\UI\Implementation\Component\Input\getLanguage(), xpath_eval(), and xpath_new_context().

+ Here is the call graph for this function:

◆ getCellPadding()

ilPCTable::getCellPadding ( )

Definition at line 244 of file class.ilPCTable.php.

244 : string
245 {
246 return $this->getTableAttribute("CellPadding");
247 }

◆ getCellSpacing()

ilPCTable::getCellSpacing ( )

Definition at line 234 of file class.ilPCTable.php.

234 : string
235 {
236 return $this->getTableAttribute("CellSpacing");
237 }

◆ getCellText()

ilPCTable::getCellText ( int  $i,
int  $j 
)

Get cell text of row $i and cell $j.

Definition at line 83 of file class.ilPCTable.php.

83 : string
84 {
85 $cell_par = $this->getCellNode($i, $j, false);
86
87 if (is_object($cell_par)) {
88 $content = "";
89 $childs = $cell_par->child_nodes();
90 for ($i = 0; $i < count($childs); $i++) {
91 $content .= $this->dom->dump_node($childs[$i]);
92 }
93 return $content;
94 } else {
95 return "";
96 }
97 }
getCellNode(int $i, int $j, bool $create_if_not_exists=false)
Get cell paragraph node of row $i and cell $j.

References $i.

◆ getClass()

ilPCTable::getClass ( )

Definition at line 817 of file class.ilPCTable.php.

817 : string
818 {
819 return $this->getTableAttribute("Class");
820 }

◆ getFooterCols()

ilPCTable::getFooterCols ( )

Definition at line 867 of file class.ilPCTable.php.

867 : int
868 {
869 return (int) $this->getTableAttribute("FooterCols");
870 }

◆ getFooterRows()

ilPCTable::getFooterRows ( )

Definition at line 847 of file class.ilPCTable.php.

847 : int
848 {
849 return (int) $this->getTableAttribute("FooterRows");
850 }

◆ getHeaderCols()

ilPCTable::getHeaderCols ( )

Definition at line 857 of file class.ilPCTable.php.

857 : int
858 {
859 return (int) $this->getTableAttribute("HeaderCols");
860 }

◆ getHeaderRows()

ilPCTable::getHeaderRows ( )

Definition at line 837 of file class.ilPCTable.php.

837 : int
838 {
839 return (int) $this->getTableAttribute("HeaderRows");
840 }

◆ getHorizontalAlign()

ilPCTable::getHorizontalAlign ( )

Definition at line 259 of file class.ilPCTable.php.

259 : string
260 {
261 return $this->getTableAttribute("HorizontalAlign");
262 }

◆ getLanguage()

ilPCTable::getLanguage ( )

Definition at line 202 of file class.ilPCTable.php.

202 : string
203 {
204 return $this->getTableAttribute("Language");
205 }

◆ getLangVars()

static ilPCTable::getLangVars ( )
static

Get lang vars needed for editing.

Returns
string[] array of lang var keys

Reimplemented from ilPageContent.

Definition at line 896 of file class.ilPCTable.php.

896 : array
897 {
898 return array("ed_insert_dtable", "ed_insert_atable","ed_new_row_after", "ed_new_row_before",
899 "ed_new_col_after", "ed_new_col_before", "ed_delete_col",
900 "ed_delete_row", "ed_edit_data", "ed_row_up", "ed_row_down",
901 "ed_col_left", "ed_col_right");
902 }

◆ getModel()

ilPCTable::getModel ( )

Get model as needed for the front-end editor.

Reimplemented from ilPageContent.

Definition at line 919 of file class.ilPCTable.php.

919 : ?stdClass
920 {
921 $model = new \stdClass();
922
923 $rows = $this->tab_node->child_nodes();
924
925 $y = 0;
926 foreach ($rows as $row) {
927 if ($row->node_name() == "TableRow") {
928 $x = 0;
929 $cells = $row->child_nodes();
930 foreach ($cells as $cell) {
931 if ($cell->node_name() == "TableData") {
933 $this->getCellText($y, $x),
934 true,
935 false
936 );
937 $text = ilPCParagraphGUI::xml2outputJS($text);
938 $model->content[$y][$x] = $text;
939 }
940 $x++;
941 }
942 $y++;
943 }
944 }
945
946 return $model;
947 }
static xml2outputJS(string $s_text)
Prepare content for js output.
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.
getCellText(int $i, int $j)
Get cell text of row $i and cell $j.

References $rows, ilPCParagraph\xml2output(), and ilPCParagraphGUI\xml2outputJS().

+ Here is the call graph for this function:

◆ getTableAttribute()

ilPCTable::getTableAttribute ( string  $a_attr)

Definition at line 888 of file class.ilPCTable.php.

888 : string
889 {
890 if (is_object($this->tab_node)) {
891 return $this->tab_node->get_attribute($a_attr);
892 }
893 return "";
894 }

◆ getTemplate()

ilPCTable::getTemplate ( )

Definition at line 827 of file class.ilPCTable.php.

827 : string
828 {
829 return $this->getTableAttribute("Template");
830 }

◆ getWidth()

ilPCTable::getWidth ( )

Definition at line 214 of file class.ilPCTable.php.

214 : string
215 {
216 return $this->getTableAttribute("Width");
217 }

◆ handleCopiedContent()

static ilPCTable::handleCopiedContent ( DOMDocument  $a_domdoc,
bool  $a_self_ass = true,
bool  $a_clone_mobs = false,
int  $new_parent_id = 0,
int  $obj_copy_id = 0 
)
static

Handle copied content.

This function must, e.g. create copies of objects referenced within the content (e.g. question objects)

Parameters
DOMDocument$a_domdoc
bool$a_self_ass
bool$a_clone_mobs
int$new_parent_id
int$obj_copy_id

Reimplemented from ilPageContent.

Definition at line 905 of file class.ilPCTable.php.

911 : void {
912 $xpath = new DOMXPath($a_domdoc);
913 $nodes = $xpath->query("//Table");
914 foreach ($nodes as $node) {
915 $node->removeAttribute("Id");
916 }
917 }

◆ importCell()

ilPCTable::importCell ( string  $lng,
php4DOMElement  $cellNode,
php4DOMElement  $aRow 
)

Definition at line 707 of file class.ilPCTable.php.

711 : void {
712 /*echo "add Cell";
713 var_dump($cellNode);*/
714 $aCell = $this->addCell($aRow);
715 $par = new ilPCParagraph($this->getPage());
716 $par->createAtNode($aCell);
717 $par->setText($par->input2xml($this->extractText($cellNode)));
718 $par->setCharacteristic("TableContent");
719 $par->setLanguage($lng);
720 $this->importCellAttributes($cellNode, $aCell);
721 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
importCellAttributes(php4DOMElement $node, php4DOMElement $par)
$lng

◆ importCellAttributes()

ilPCTable::importCellAttributes ( php4DOMElement  $node,
php4DOMElement  $par 
)

Definition at line 670 of file class.ilPCTable.php.

673 : void {
674 /*echo "importing table attributes";
675 var_dump($tableNode);*/
676 if ($node->has_attributes()) {
677 foreach ($node->attributes() as $n) {
678 switch (strtolower($n->node_name())) {
679 case "class":
680 $par->set_attribute("Class", $this->extractText($n));
681 break;
682 case "width":
683 $par->set_attribute("Width", $this->extractText($n));
684 break;
685 }
686 }
687 }
688 }
extractText(php4DOMElement $node)
set_attribute($name, $value)

References php4DOMNode\attributes(), and php4DOMElement\set_attribute().

+ Here is the call graph for this function:

◆ importHtml()

ilPCTable::importHtml ( string  $lng,
string  $htmlTable 
)
Returns
bool|string

Definition at line 741 of file class.ilPCTable.php.

744 {
745 $dummy = ilUtil::stripSlashes($htmlTable, false);
746 $dom = domxml_open_mem($dummy, DOMXML_LOAD_PARSING, $error);
747
748 if ($dom) {
749 $xpc = xpath_new_context($dom);
750 // extract first table object
751 $path = "//table[1] | //Table[1]";
752 $res = xpath_eval($xpc, $path);
753
754 if (count($res->nodeset) == 0) {
755 $error = "Could not find a table root node";
756 }
757
758 if (empty($error)) {
759 for ($i = 0; $i < count($res->nodeset); $i++) {
760 $node = $res->nodeset[$i];
761
763
764 if ($node->has_child_nodes()) {
765 foreach ($node->child_nodes() as $n) {
766 if ($n->node_type() == XML_ELEMENT_NODE &&
767 strcasecmp($n->node_name(), "tr") == 0) {
768 $this->importRow($lng, $n);
769 }
770 }
771 }
772 }
773 }
774 $dom->free();
775 }
776 if (is_array($error)) {
777 $errmsg = "";
778 foreach ($error as $errorline) { # Loop through all errors
779 $errmsg .= "[" . $errorline['line'] . ", " . $errorline['col'] . "]: " . $errorline['errormessage'] . " at Node '" . $errorline['nodename'] . "'<br />";
780 }
781 } else {
782 $errmsg = $error;
783 }
784
785 if (empty($errmsg)) {
786 return true;
787 }
788
789 return $errmsg;
790 }
importRow(string $lng, php4DOMElement $node)
importTableAttributes(php4DOMElement $node)
php4DOMDocument $dom
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
domxml_open_mem($str, $mode=0, &$error=null)
const DOMXML_LOAD_PARSING

References $i, $lng, $path, $res, php4DOMNode\child_nodes(), DOMXML_LOAD_PARSING, domxml_open_mem(), php4DOMNode\has_child_nodes(), ilUtil\stripSlashes(), xpath_eval(), and xpath_new_context().

+ Here is the call graph for this function:

◆ importRow()

ilPCTable::importRow ( string  $lng,
php4DOMElement  $node 
)

Definition at line 691 of file class.ilPCTable.php.

694 : void {
695 $aRow = $this->addRow();
696
697 if ($node->has_child_nodes()) {
698 foreach ($node->child_nodes() as $n) {
699 if ($n->node_type() == XML_ELEMENT_NODE &&
700 strcasecmp($n->node_name(), "td") == 0) {
701 $this->importCell($lng, $n, $aRow);
702 }
703 }
704 }
705 }
importCell(string $lng, php4DOMElement $cellNode, php4DOMElement $aRow)

References $lng, and php4DOMNode\child_nodes().

+ Here is the call graph for this function:

◆ importSpreadsheet()

ilPCTable::importSpreadsheet ( string  $a_lang,
string  $a_data 
)

import from table

Definition at line 167 of file class.ilPCTable.php.

170 : void {
171 $max_cols = 0;
172
173 str_replace($a_data, "\r", "\n");
174 str_replace($a_data, "\n\n", "\n");
175 $target_rows = array();
176 $rows = explode("\n", $a_data);
177
178 // get maximum of cols in a row and
179 // put data in target_row arrays
180 foreach ($rows as $row) {
181 $cells = explode("\t", $row);
182 $max_cols = ($max_cols > count($cells))
183 ? $max_cols
184 : count($cells);
185 $target_rows[] = $cells;
186 }
187
188 // iterate target row arrays and insert data
189 foreach ($target_rows as $row) {
190 $aRow = $this->addRow();
191 for ($j = 0; $j < $max_cols; $j++) {
192 // mask html
193 $data = str_replace("&", "&amp;", ($row[$j] ?? ""));
194 $data = str_replace("<", "&lt;", $data);
195 $data = str_replace(">", "&gt;", $data);
196
197 $this->addCell($aRow, $data, $a_lang);
198 }
199 }
200 }

◆ importTableAttributes()

ilPCTable::importTableAttributes ( php4DOMElement  $node)

Definition at line 641 of file class.ilPCTable.php.

643 : void {
644 /*echo "importing table attributes";
645 var_dump($tableNode);*/
646 if ($node->has_attributes()) {
647 foreach ($node->attributes() as $n) {
648 switch (strtolower($n->node_name())) {
649 case "border":
650 $this->setBorder($this->extractText($n));
651 break;
652 case "align":
653 $this->setHorizontalAlign(ucfirst(strtolower($this->extractText($n))));
654 break;
655 case "cellspacing":
656 $this->setCellSpacing($this->extractText($n));
657 break;
658 case "cellpadding":
659 $this->setCellPadding($this->extractText($n));
660 break;
661 case "width":
662 $this->setWidth($this->extractText($n));
663 break;
664 }
665 }
666 }
667 }
setBorder(string $a_border)
setCellSpacing(string $a_spacing)
setCellPadding(string $a_padding)
setWidth(string $a_width)
setHorizontalAlign(string $a_halign)

References php4DOMNode\attributes().

+ Here is the call graph for this function:

◆ init()

ilPCTable::init ( )

Init object.

This function must be overwritten and at least set the content type.

Reimplemented from ilPageContent.

Reimplemented in ilPCDataTable.

Definition at line 28 of file class.ilPCTable.php.

28 : void
29 {
30 $this->setType("tab");
31 }
setType(string $a_type)
Set Type.

References ilPageContent\setType().

+ Here is the call graph for this function:

◆ makeEmptyCell()

ilPCTable::makeEmptyCell ( php4DOMElement  $td_node)

Make cell empty.

Reimplemented in ilPCDataTable.

Definition at line 414 of file class.ilPCTable.php.

414 : void
415 {
416 // delete children of paragraph node
417 $children = $td_node->child_nodes();
418 for ($i = 0; $i < count($children); $i++) {
419 $td_node->remove_child($children[$i]);
420 }
421 }
remove_child($oldchild)

References $i, php4DOMNode\child_nodes(), and php4DOMNode\remove_child().

+ Here is the call graph for this function:

◆ setBorder()

ilPCTable::setBorder ( string  $a_border)

Definition at line 229 of file class.ilPCTable.php.

229 : void
230 {
231 $this->setTableAttribute("Border", $a_border);
232 }
setTableAttribute(string $a_attr, string $a_value)
Set attribute of table tag.

◆ setCaption()

ilPCTable::setCaption ( string  $a_content,
string  $a_align 
)

Definition at line 624 of file class.ilPCTable.php.

624 : void
625 {
626 if ($a_content != "") {
628 $this->dom,
629 $this->tab_node,
630 "Caption",
631 array("Summary", "TableRow"),
632 $a_content,
633 array("Align" => $a_align)
634 );
635 } else {
636 ilDOMUtil::deleteAllChildsByName($this->tab_node, array("Caption"));
637 }
638 }
static deleteAllChildsByName(php4DOMElement $a_parent, array $a_node_names)
delete all childs of a node by names in $a_node_names
static setFirstOptionalElement(php4DOMDocument $doc, php4DOMElement $parent_node, string $a_node_name, array $a_successors, string $a_content, array $a_attributes, bool $a_remove_childs=true)
searches for an element $a_node_name within the childs of $parent_node if no node is found,...

References ilDOMUtil\deleteAllChildsByName(), and ilDOMUtil\setFirstOptionalElement().

+ Here is the call graph for this function:

◆ setCellPadding()

ilPCTable::setCellPadding ( string  $a_padding)

Definition at line 249 of file class.ilPCTable.php.

249 : void
250 {
251 $this->setTableAttribute("CellPadding", $a_padding);
252 }

◆ setCellSpacing()

ilPCTable::setCellSpacing ( string  $a_spacing)

Definition at line 239 of file class.ilPCTable.php.

239 : void
240 {
241 $this->setTableAttribute("CellSpacing", $a_spacing);
242 }

◆ setClass()

ilPCTable::setClass ( string  $a_class)

Set Style Class of table.

Definition at line 812 of file class.ilPCTable.php.

812 : void
813 {
814 $this->setTableAttribute("Class", $a_class);
815 }

◆ setFirstRowStyle()

ilPCTable::setFirstRowStyle ( string  $a_class)

Definition at line 792 of file class.ilPCTable.php.

794 : void {
795 $childs = $this->tab_node->child_nodes();
796 foreach ($childs as $child) {
797 if ($child->node_name() == "TableRow") {
798 $gchilds = $child->child_nodes();
799 foreach ($gchilds as $gchild) {
800 if ($gchild->node_name() == "TableData") {
801 $gchild->set_attribute("Class", $a_class);
802 }
803 }
804 return;
805 }
806 }
807 }

◆ setFooterCols()

ilPCTable::setFooterCols ( int  $a_nr)

Definition at line 862 of file class.ilPCTable.php.

862 : void
863 {
864 $this->setTableAttribute("FooterCols", $a_nr);
865 }

◆ setFooterRows()

ilPCTable::setFooterRows ( int  $a_nr)

Definition at line 842 of file class.ilPCTable.php.

842 : void
843 {
844 $this->setTableAttribute("FooterRows", $a_nr);
845 }

◆ setHeaderCols()

ilPCTable::setHeaderCols ( int  $a_nr)

Definition at line 852 of file class.ilPCTable.php.

852 : void
853 {
854 $this->setTableAttribute("HeaderCols", $a_nr);
855 }

◆ setHeaderRows()

ilPCTable::setHeaderRows ( int  $a_nr)

Definition at line 832 of file class.ilPCTable.php.

832 : void
833 {
834 $this->setTableAttribute("HeaderRows", $a_nr);
835 }

◆ setHorizontalAlign()

ilPCTable::setHorizontalAlign ( string  $a_halign)

Definition at line 254 of file class.ilPCTable.php.

254 : void
255 {
256 $this->tab_node->set_attribute("HorizontalAlign", $a_halign);
257 }

◆ setLanguage()

ilPCTable::setLanguage ( string  $a_lang)

Definition at line 207 of file class.ilPCTable.php.

207 : void
208 {
209 if ($a_lang != "") {
210 $this->setTableAttribute("Language", $a_lang);
211 }
212 }

◆ setNode()

ilPCTable::setNode ( php4DOMElement  $a_node)

Set xml node of page content.

Parameters
php4DOMElement$a_nodenode object

Reimplemented from ilPageContent.

Reimplemented in ilPCDataTable.

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

33 : void
34 {
35 parent::setNode($a_node); // this is the PageContent node
36 $this->tab_node = $a_node->first_child(); // this is the Table node
37 }

References php4DOMNode\first_child().

+ Here is the call graph for this function:

◆ setTableAttribute()

ilPCTable::setTableAttribute ( string  $a_attr,
string  $a_value 
)
protected

Set attribute of table tag.

Definition at line 875 of file class.ilPCTable.php.

878 : void {
879 if (!empty($a_value)) {
880 $this->tab_node->set_attribute($a_attr, $a_value);
881 } else {
882 if ($this->tab_node->has_attribute($a_attr)) {
883 $this->tab_node->remove_attribute($a_attr);
884 }
885 }
886 }

◆ setTDAlignment()

ilPCTable::setTDAlignment ( string  $a_hier_id,
string  $a_class,
string  $a_pc_id = "" 
)

set alignment of table data cell

Definition at line 569 of file class.ilPCTable.php.

573 : void {
574 $xpc = xpath_new_context($this->dom);
575 if ($a_pc_id == "") {
576 $path = "//TableData[@HierId = '" . $a_hier_id . "']";
577 } else {
578 $path = "//TableData[@PCID = '" . $a_pc_id . "']";
579 }
580 $res = xpath_eval($xpc, $path);
581 if (count($res->nodeset) == 1) {
582 if ($a_class != "") {
583 $res->nodeset[0]->set_attribute("HorizontalAlign", $a_class);
584 } else {
585 if ($res->nodeset[0]->has_attribute("HorizontalAlign")) {
586 $res->nodeset[0]->remove_attribute("HorizontalAlign");
587 }
588 }
589 }
590 }

References $path.

◆ setTDClass()

ilPCTable::setTDClass ( string  $a_hier_id,
string  $a_class,
string  $a_pc_id = "" 
)

set class of table data cell

Definition at line 543 of file class.ilPCTable.php.

547 : void {
548 $xpc = xpath_new_context($this->dom);
549 if ($a_pc_id == "") {
550 $path = "//TableData[@HierId = '" . $a_hier_id . "']";
551 } else {
552 $path = "//TableData[@PCID = '" . $a_pc_id . "']";
553 }
554 $res = xpath_eval($xpc, $path);
555 if (count($res->nodeset) == 1) {
556 if ($a_class != "") {
557 $res->nodeset[0]->set_attribute("Class", $a_class);
558 } else {
559 if ($res->nodeset[0]->has_attribute("Class")) {
560 $res->nodeset[0]->remove_attribute("Class");
561 }
562 }
563 }
564 }

References $path.

◆ setTDSpans()

ilPCTable::setTDSpans ( array  $a_colspans,
array  $a_rowspans 
)

Definition at line 292 of file class.ilPCTable.php.

295 : void {
296 $y = 0;
297 $rows = $this->tab_node->child_nodes();
298 foreach ($rows as $row) {
299 if ($row->node_name() == "TableRow") {
300 $x = 0;
301 $cells = $row->child_nodes();
302 foreach ($cells as $cell) {
303 if ($cell->node_name() == "TableData") {
304 $ckey = $cell->get_attribute("HierId") . ":" . $cell->get_attribute("PCID");
305 if ((int) ($a_colspans[$ckey] ?? 0) > 1) {
306 $cell->set_attribute("ColSpan", (int) $a_colspans[$ckey]);
307 } else {
308 if ($cell->has_attribute("ColSpan")) {
309 $cell->remove_attribute("ColSpan");
310 }
311 }
312 if ((int) ($a_rowspans[$ckey] ?? 0) > 1) {
313 $cell->set_attribute("RowSpan", (int) $a_rowspans[$ckey]);
314 } else {
315 if ($cell->has_attribute("RowSpan")) {
316 $cell->remove_attribute("RowSpan");
317 }
318 }
319 }
320 $x++;
321 }
322 $y++;
323 }
324 }
325 $this->fixHideAndSpans();
326 }
fixHideAndSpans()
Fix Hide and Spans.

◆ setTDWidth()

ilPCTable::setTDWidth ( string  $a_hier_id,
string  $a_width,
string  $a_pc_id = "" 
)

set width of table data cell

Definition at line 267 of file class.ilPCTable.php.

271 : void {
272 $xpc = xpath_new_context($this->dom);
273
274 if ($a_pc_id == "") {
275 $path = "//TableData[@HierId = '" . $a_hier_id . "']";
276 } else {
277 $path = "//TableData[@PCID = '" . $a_pc_id . "']";
278 }
279 $res = xpath_eval($xpc, $path);
280
281 if (count($res->nodeset) == 1) {
282 if ($a_width != "") {
283 $res->nodeset[0]->set_attribute("Width", $a_width);
284 } else {
285 if ($res->nodeset[0]->has_attribute("Width")) {
286 $res->nodeset[0]->remove_attribute("Width");
287 }
288 }
289 }
290 }

References $path.

◆ setTemplate()

ilPCTable::setTemplate ( string  $a_template)

Definition at line 822 of file class.ilPCTable.php.

822 : void
823 {
824 $this->setTableAttribute("Template", $a_template);
825 }

◆ setWidth()

ilPCTable::setWidth ( string  $a_width)

Definition at line 219 of file class.ilPCTable.php.

219 : void
220 {
221 $this->setTableAttribute("Width", $a_width);
222 }

Field Documentation

◆ $tab_node

php4DOMElement ilPCTable::$tab_node

Definition at line 26 of file class.ilPCTable.php.


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