ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 ()
 
 create (ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
 
 addRow ()
 
 addCell (DOMNode $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...
 
 getTableDataNode (int $i, int $j)
 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 (DomNode $td_node)
 
 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)
 
 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 ()
 
- Public Member Functions inherited from ilPageContent
 __construct (ilPageObject $a_pg_obj, ?PageManagerInterface $page_manager=null, ?ObjectAdapterInterface $object_adapter=null)
 
 setPage (ilPageObject $a_val)
 
 getPage ()
 
 init ()
 Init object. More...
 
 getType ()
 
 getDomNode ()
 
 getDomDoc ()
 
 setDomNode (DOMNode $node)
 
 getChildNode ()
 
 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...
 
 getNewPageContentNode ()
 
 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 ()
 
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)
 
- Static Public Member Functions inherited from ilPageContent
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...
 

Protected Member Functions

 setTableAttribute (string $a_attr, string $a_value)
 Set attribute of table tag. More...
 
- Protected Member Functions inherited from ilPageContent
 getPageManager ()
 
 setType (string $a_type)
 Set Type. More...
 
 hasNode ()
 
 createInitialChildNode (string $hier_id, string $pc_id, string $child, array $child_attributes=[])
 

Additional Inherited Members

- Data Fields inherited from ilPageContent
string $hier_id = ""
 
DOMNode $dom_node = null
 
string $page_lang = ""
 
- Protected Attributes inherited from ilPageContent
DOMDocument $dom_doc
 
ILIAS COPage InternalDomainService $domain
 
string $pcid
 
string $type = ""
 
ilPageObject $pg_obj
 
string $file_download_link
 
string $fullscreen_link
 
string $sourcecode_download_script
 
ilLogger $log
 
string $profile_back_url = ""
 
ILIAS COPage Dom DomUtil $dom_util
 
PageManagerInterface $page_manager = null
 
ObjectAdapterInterface $object = null
 

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 ( DOMNode  $aRow,
string  $a_data = "",
string  $a_lang = "" 
)

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

References ilPageContent\getNewPageContentNode().

Referenced by addRows(), and importSpreadsheet().

55  : DOMNode {
56  $new_td = $this->dom_doc->createElement("TableData");
57  $new_td = $aRow->appendChild($new_td);
58 
59  // insert data if given
60  if ($a_data != "") {
61  $new_pg = $this->getNewPageContentNode();
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);
68  }
69 
70  return $new_td;
71  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addRow()

ilPCTable::addRow ( )

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

References ilPageContent\getChildNode().

Referenced by addRows(), and importSpreadsheet().

44  : DOMNode
45  {
46  $new_tr = $this->dom_doc->createElement("TableRow");
47  $new_tr = $this->getChildNode()->appendChild($new_tr);
48  return $new_tr;
49  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addRows()

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

add rows to table

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

References addCell(), and addRow().

150  : void
151  {
152  for ($i = 1; $i <= $a_nr_rows; $i++) {
153  $aRow = $this->addRow();
154  for ($j = 1; $j <= $a_nr_cols; $j++) {
155  $this->addCell($aRow);
156  }
157  }
158  }
addCell(DOMNode $aRow, string $a_data="", string $a_lang="")
+ Here is the call graph for this function:

◆ checkCellHidden()

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

Check hidden status.

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

Referenced by fixHideAndSpans().

416  : bool
417  {
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))) {
423  return true;
424  }
425  }
426  }
427  }
428  return false;
429  }
+ Here is the caller graph for this function:

◆ create()

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

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

References ilPageContent\createInitialChildNode().

35  : void {
37  $a_hier_id,
38  $a_pc_id,
39  "Table",
40  ["Language" => ""]
41  );
42  }
createInitialChildNode(string $hier_id, string $pc_id, string $child, array $child_attributes=[])
+ Here is the call graph for this function:

◆ 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 330 of file class.ilPCTable.php.

References checkCellHidden(), ilPageContent\getChildNode(), and makeEmptyCell().

Referenced by setTDSpans().

330  : void
331  {
332  // first: get max x and y
333  $max_x = $max_y = 0;
334  $y = 0;
335  $rows = $this->getChildNode()->childNodes;
336 
337  foreach ($rows as $row) {
338  if ($row->nodeName == "TableRow") {
339  $x = 0;
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);
345  }
346  $x++;
347  }
348  $y++;
349  }
350  }
351 
352  // second: fix hidden/colspans for all cells
353  $y = 0;
354  $colspans = [];
355  $rowspans = [];
356  $rows = $this->getChildNode()->childNodes;
357  foreach ($rows as $row) {
358  if ($row->nodeName == "TableRow") {
359  $x = 0;
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"));
365 
366  // if col or rowspan is to high: reduce it to the max
367  if ($cspan > $max_x - $x + 1) {
368  $cell->setAttribute("ColSpan", $max_x - $x + 1);
369  $cspan = $max_x - $x + 1;
370  }
371  if ($rspan > $max_y - $y + 1) {
372  $cell->setAttribute("RowSpan", $max_y - $y + 1);
373  $rspan = $max_y - $y + 1;
374  }
375 
376  // check hidden status
377  if ($this->checkCellHidden($colspans, $rowspans, $x, $y)) {
378  // hidden: set hidden flag, remove col and rowspan
379  $cell->setAttribute("Hidden", "Y");
380  $cspan = 1;
381  $rspan = 1;
382  if ($cell->hasAttribute("ColSpan")) {
383  $cell->removeAttribute("ColSpan");
384  }
385  if ($cell->hasAttribute("RowSpan")) {
386  $cell->removeAttribute("RowSpan");
387  }
388  $this->makeEmptyCell($cell);
389  } else {
390  // not hidden: remove hidden flag if existing
391  if ($cell->hasAttribute("Hidden")) {
392  $cell->removeAttribute("Hidden");
393  }
394  }
395 
396  $colspans[$x][$y] = $cspan;
397  $rowspans[$x][$y] = $rspan;
398  }
399  $x++;
400  }
401  $y++;
402  }
403  }
404  }
checkCellHidden(array $colspans, array $rowspans, int $x, int $y)
Check hidden status.
makeEmptyCell(DomNode $td_node)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllCellAlignments()

ilPCTable::getAllCellAlignments ( )

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

References ilPageContent\getChildNode().

Referenced by ilPCTableGUI\_addAlignmentCheckboxes().

453  : array
454  {
455  $classes = array();
456  $rows = $this->getChildNode()->childNodes;
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");
464  }
465  }
466  }
467  }
468 
469  return $classes;
470  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllCellClasses()

ilPCTable::getAllCellClasses ( )

Get all cell classes.

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

References ilPageContent\getChildNode().

Referenced by ilPCTableGUI\_addStyleCheckboxes().

434  : array
435  {
436  $classes = array();
437  $rows = $this->getChildNode()->childNodes;
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");
445  }
446  }
447  }
448  }
449 
450  return $classes;
451  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllCellSpans()

ilPCTable::getAllCellSpans ( )

Get all cell spans.

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

References ilPageContent\getChildNode().

Referenced by ilPCTableGUI\_addSpanInputs().

475  : array
476  {
477  $spans = array();
478  $rows = $this->getChildNode()->childNodes;
479  $y = 0;
480  $max_x = 0;
481  $max_y = 0;
482  foreach ($rows as $row) {
483  if ($row->nodeName == "TableRow") {
484  $x = 0;
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);
493  }
494  $x++;
495  }
496  $y++;
497  }
498  }
499  foreach ($spans as $k => $v) {
500  $spans[$k]["max_x"] = $max_x;
501  $spans[$k]["max_y"] = $max_y;
502  }
503 
504  return $spans;
505  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllCellWidths()

ilPCTable::getAllCellWidths ( )

Get all cell widths.

Returns
array array of cell style classes

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

References ilPageContent\getChildNode().

Referenced by ilPCTableGUI\_addWidthInputs().

511  : array
512  {
513  $widths = array();
514  $rows = $this->getChildNode()->childNodes;
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");
522  }
523  }
524  }
525  }
526 
527  return $widths;
528  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBorder()

ilPCTable::getBorder ( )

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

References getTableAttribute().

223  : string
224  {
225  return $this->getTableAttribute("Border");
226  }
getTableAttribute(string $a_attr)
+ Here is the call graph for this function:

◆ getCaption()

ilPCTable::getCaption ( )

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

References ilPageContent\$hier_id, $path, and ilPageContent\getHierId().

580  : string
581  {
582  $hier_id = $this->getHierId();
583  if (!empty($hier_id)) {
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));
588  }
589  }
590  return "";
591  }
$path
Definition: ltiservices.php:29
+ Here is the call graph for this function:

◆ getCaptionAlign()

ilPCTable::getCaptionAlign ( )

get caption alignment (Top | Bottom)

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

References ilPageContent\$hier_id, $path, and ilPageContent\getHierId().

596  : string
597  {
598  $hier_id = $this->getHierId();
599  if (!empty($hier_id)) {
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");
604  }
605  }
606  return "";
607  }
$path
Definition: ltiservices.php:29
+ 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 93 of file class.ilPCTable.php.

References $path, ilPageContent\getHierId(), getLanguage(), ilPageContent\getNewPageContentNode(), and null.

Referenced by getCellText(), and ilPCDataTable\setData().

93  : ?DOMNode
94  {
95  $path = "//PageContent[@HierId='" . $this->getHierId() . "']" .
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);
100  } else { // no node -> delete all childs and create paragraph
101  if (!$create_if_not_exists) {
102  return null;
103  }
104  $path2 = "//PageContent[@HierId='" . $this->getHierId() . "']" .
105  "/Table/TableRow[" . ($i + 1) . "]/TableData[" . ($j + 1) . "]";
106  $nodes2 = $this->dom_util->path($this->dom_doc, $path2);
107 
108  $td_node = $nodes2->item(0);
109 
110  if (!is_null($td_node)) {
111  // delete children of paragraph node
112  $this->dom_util->deleteAllChilds($td_node);
113 
114  // create page content and paragraph node here.
115  $pc_node = $this->getNewPageContentNode();
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(
121  "Language",
122  $this->getLanguage()
123  );
124 
125  return $par_node;
126  }
127  }
128 
129  return null;
130  }
$path
Definition: ltiservices.php:29
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCellPadding()

ilPCTable::getCellPadding ( )

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

References getTableAttribute().

243  : string
244  {
245  return $this->getTableAttribute("CellPadding");
246  }
getTableAttribute(string $a_attr)
+ Here is the call graph for this function:

◆ getCellSpacing()

ilPCTable::getCellSpacing ( )

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

References getTableAttribute().

233  : string
234  {
235  return $this->getTableAttribute("CellSpacing");
236  }
getTableAttribute(string $a_attr)
+ Here is the call graph for this function:

◆ getCellText()

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

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

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

References $c, and getCellNode().

Referenced by getModel().

76  : string
77  {
78  $cell_par = $this->getCellNode($i, $j, false);
79  if (!is_null($cell_par)) {
80  $content = "";
81  foreach ($cell_par->childNodes as $c) {
82  $content .= $this->dom_util->dump($c);
83  }
84  return $content;
85  } else {
86  return "";
87  }
88  }
getCellNode(int $i, int $j, bool $create_if_not_exists=false)
Get cell paragraph node of row $i and cell $j.
$c
Definition: deliver.php:25
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getClass()

ilPCTable::getClass ( )

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

References getTableAttribute().

Referenced by getModel().

650  : string
651  {
652  return $this->getTableAttribute("Class");
653  }
getTableAttribute(string $a_attr)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFooterCols()

ilPCTable::getFooterCols ( )

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

References getTableAttribute().

700  : int
701  {
702  return (int) $this->getTableAttribute("FooterCols");
703  }
getTableAttribute(string $a_attr)
+ Here is the call graph for this function:

◆ getFooterRows()

ilPCTable::getFooterRows ( )

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

References getTableAttribute().

680  : int
681  {
682  return (int) $this->getTableAttribute("FooterRows");
683  }
getTableAttribute(string $a_attr)
+ Here is the call graph for this function:

◆ getHeaderCols()

ilPCTable::getHeaderCols ( )

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

References getTableAttribute().

690  : int
691  {
692  return (int) $this->getTableAttribute("HeaderCols");
693  }
getTableAttribute(string $a_attr)
+ Here is the call graph for this function:

◆ getHeaderRows()

ilPCTable::getHeaderRows ( )

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

References getTableAttribute().

Referenced by getModel().

670  : int
671  {
672  return (int) $this->getTableAttribute("HeaderRows");
673  }
getTableAttribute(string $a_attr)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getHorizontalAlign()

ilPCTable::getHorizontalAlign ( )

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

References getTableAttribute().

258  : string
259  {
260  return $this->getTableAttribute("HorizontalAlign");
261  }
getTableAttribute(string $a_attr)
+ Here is the call graph for this function:

◆ getLanguage()

ilPCTable::getLanguage ( )

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

References getTableAttribute().

Referenced by getCellNode(), and ilPCDataTable\makeEmptyCell().

201  : string
202  {
203  return $this->getTableAttribute("Language");
204  }
getTableAttribute(string $a_attr)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLangVars()

static ilPCTable::getLangVars ( )
static

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

729  : array
730  {
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");
735  }

◆ getModel()

ilPCTable::getModel ( )

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

References getCellText(), ilPageContent\getChildNode(), getClass(), getHeaderRows(), getTemplate(), ilPCParagraph\xml2output(), and ilPCParagraphGUI\xml2outputJS().

752  : ?stdClass
753  {
754  $this->log->debug("Get table model start");
755  $model = new \stdClass();
756 
757  $y = 0;
758  foreach ($this->getChildNode()->childNodes as $row) {
759  if ($row->nodeName == "TableRow") {
760  $x = 0;
761  foreach ($row->childNodes as $cell) {
762  if ($cell->nodeName == "TableData") {
764  $this->getCellText($y, $x),
765  true,
766  false
767  );
768  $text = ilPCParagraphGUI::xml2outputJS($text);
769  $model->content[$y][$x] = $text;
770  }
771  $x++;
772  }
773  $y++;
774  }
775  }
776 
777  if ($this->getTemplate() != "") {
778  $model->template = $this->getTemplate();
779  $model->characteristic = "";
780  } else {
781  $model->characteristic = $this->getClass();
782  $model->template = "";
783  }
784 
785  $model->hasHeaderRows = ($this->getHeaderRows() > 0);
786  $this->log->debug("...end");
787  return $model;
788  }
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.
+ Here is the call graph for this function:

◆ getTableAttribute()

ilPCTable::getTableAttribute ( string  $a_attr)

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

References ilPageContent\getChildNode().

Referenced by getBorder(), getCellPadding(), getCellSpacing(), getClass(), getFooterCols(), getFooterRows(), getHeaderCols(), getHeaderRows(), getHorizontalAlign(), getLanguage(), getTemplate(), and getWidth().

721  : string
722  {
723  if (!is_null($this->getChildNode())) {
724  return $this->getChildNode()->getAttribute($a_attr);
725  }
726  return "";
727  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTableDataNode()

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

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

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

References $path, ilPageContent\getHierId(), and null.

135  : ?DOMElement
136  {
137  $path = "//PageContent[@HierId='" . $this->getHierId() . "']" .
138  "/Table/TableRow[$i+1]/TableData[$j+1]";
139  $nodes = $this->dom_util->path($this->dom_doc, $path);
140 
141  if (count($nodes) > 0) {
142  return $nodes->item(0);
143  }
144  return null;
145  }
$path
Definition: ltiservices.php:29
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ getTemplate()

ilPCTable::getTemplate ( )

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

References getTableAttribute().

Referenced by getModel().

660  : string
661  {
662  return $this->getTableAttribute("Template");
663  }
getTableAttribute(string $a_attr)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getWidth()

ilPCTable::getWidth ( )

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

References getTableAttribute().

213  : string
214  {
215  return $this->getTableAttribute("Width");
216  }
getTableAttribute(string $a_attr)
+ Here is the call graph for this function:

◆ 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

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

744  : void {
745  $xpath = new DOMXPath($a_domdoc);
746  $nodes = $xpath->query("//Table");
747  foreach ($nodes as $node) {
748  $node->removeAttribute("Id");
749  }
750  }

◆ importSpreadsheet()

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

import from table

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

References $data, addCell(), and addRow().

166  : void {
167  $max_cols = 0;
168 
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);
173 
174  // get maximum of cols in a row and
175  // put data in target_row arrays
176  foreach ($rows as $row) {
177  $cells = explode("\t", $row);
178  if (count($cells) === 1) {
179  $cells = explode(";", $row);
180  }
181  $max_cols = ($max_cols > count($cells))
182  ? $max_cols
183  : count($cells);
184  $target_rows[] = $cells;
185  }
186 
187  // iterate target row arrays and insert data
188  foreach ($target_rows as $row) {
189  $aRow = $this->addRow();
190  for ($j = 0; $j < $max_cols; $j++) {
191  // mask html
192  $data = str_replace("&", "&amp;", ($row[$j] ?? ""));
193  $data = str_replace("<", "&lt;", $data);
194  $data = str_replace(">", "&gt;", $data);
195 
196  $this->addCell($aRow, $data, $a_lang);
197  }
198  }
199  }
addCell(DOMNode $aRow, string $a_data="", string $a_lang="")
+ Here is the call graph for this function:

◆ init()

ilPCTable::init ( )

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

References ilPageContent\setType().

26  : void
27  {
28  $this->setType("tab");
29  }
setType(string $a_type)
Set Type.
+ Here is the call graph for this function:

◆ makeEmptyCell()

ilPCTable::makeEmptyCell ( DomNode  $td_node)

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

Referenced by fixHideAndSpans().

407  : void
408  {
409  // delete children of paragraph node
410  $this->dom_util->deleteAllChilds($td_node);
411  }
+ Here is the caller graph for this function:

◆ setBorder()

ilPCTable::setBorder ( string  $a_border)

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

References setTableAttribute().

228  : void
229  {
230  $this->setTableAttribute("Border", $a_border);
231  }
setTableAttribute(string $a_attr, string $a_value)
Set attribute of table tag.
+ Here is the call graph for this function:

◆ setCaption()

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

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

References ilPageContent\getChildNode().

609  : void
610  {
611  if ($a_content != "") {
612  $this->dom_util->setFirstOptionalElement(
613  $this->getChildNode(),
614  "Caption",
615  array("Summary", "TableRow"),
616  $a_content,
617  array("Align" => $a_align)
618  );
619  } else {
620  $this->dom_util->deleteAllChildsByName(
621  $this->getChildNode(),
622  array("Caption")
623  );
624  }
625  }
+ Here is the call graph for this function:

◆ setCellPadding()

ilPCTable::setCellPadding ( string  $a_padding)

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

References setTableAttribute().

248  : void
249  {
250  $this->setTableAttribute("CellPadding", $a_padding);
251  }
setTableAttribute(string $a_attr, string $a_value)
Set attribute of table tag.
+ Here is the call graph for this function:

◆ setCellSpacing()

ilPCTable::setCellSpacing ( string  $a_spacing)

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

References setTableAttribute().

238  : void
239  {
240  $this->setTableAttribute("CellSpacing", $a_spacing);
241  }
setTableAttribute(string $a_attr, string $a_value)
Set attribute of table tag.
+ Here is the call graph for this function:

◆ setClass()

ilPCTable::setClass ( string  $a_class)

Set Style Class of table.

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

References setTableAttribute().

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

645  : void
646  {
647  $this->setTableAttribute("Class", $a_class);
648  }
setTableAttribute(string $a_attr, string $a_value)
Set attribute of table tag.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setFirstRowStyle()

ilPCTable::setFirstRowStyle ( string  $a_class)

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

References ilPageContent\getChildNode().

629  : void {
630  foreach ($this->getChildNode()->childNodes as $child) {
631  if ($child->nodeName == "TableRow") {
632  foreach ($child->childNodes as $gchild) {
633  if ($gchild->nodeName == "TableData") {
634  $gchild->setAttribute("Class", $a_class);
635  }
636  }
637  return;
638  }
639  }
640  }
+ Here is the call graph for this function:

◆ setFooterCols()

ilPCTable::setFooterCols ( int  $a_nr)

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

References setTableAttribute().

695  : void
696  {
697  $this->setTableAttribute("FooterCols", $a_nr);
698  }
setTableAttribute(string $a_attr, string $a_value)
Set attribute of table tag.
+ Here is the call graph for this function:

◆ setFooterRows()

ilPCTable::setFooterRows ( int  $a_nr)

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

References setTableAttribute().

675  : void
676  {
677  $this->setTableAttribute("FooterRows", $a_nr);
678  }
setTableAttribute(string $a_attr, string $a_value)
Set attribute of table tag.
+ Here is the call graph for this function:

◆ setHeaderCols()

ilPCTable::setHeaderCols ( int  $a_nr)

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

References setTableAttribute().

685  : void
686  {
687  $this->setTableAttribute("HeaderCols", $a_nr);
688  }
setTableAttribute(string $a_attr, string $a_value)
Set attribute of table tag.
+ Here is the call graph for this function:

◆ setHeaderRows()

ilPCTable::setHeaderRows ( int  $a_nr)

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

References setTableAttribute().

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

665  : void
666  {
667  $this->setTableAttribute("HeaderRows", $a_nr);
668  }
setTableAttribute(string $a_attr, string $a_value)
Set attribute of table tag.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHorizontalAlign()

ilPCTable::setHorizontalAlign ( string  $a_halign)

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

References ilPageContent\getChildNode().

253  : void
254  {
255  $this->getChildNode()->setAttribute("HorizontalAlign", $a_halign);
256  }
+ Here is the call graph for this function:

◆ setLanguage()

ilPCTable::setLanguage ( string  $a_lang)

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

References setTableAttribute().

206  : void
207  {
208  if ($a_lang != "") {
209  $this->setTableAttribute("Language", $a_lang);
210  }
211  }
setTableAttribute(string $a_attr, string $a_value)
Set attribute of table tag.
+ 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 708 of file class.ilPCTable.php.

References ilPageContent\getChildNode().

Referenced by setBorder(), setCellPadding(), setCellSpacing(), setClass(), setFooterCols(), setFooterRows(), setHeaderCols(), setHeaderRows(), setLanguage(), setTemplate(), and setWidth().

711  : void {
712  if (!empty($a_value)) {
713  $this->getChildNode()->setAttribute($a_attr, $a_value);
714  } else {
715  if ($this->getChildNode()->hasAttribute($a_attr)) {
716  $this->getChildNode()->removeAttribute($a_attr);
717  }
718  }
719  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTDAlignment()

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

set alignment of table data cell

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

References $path.

562  : void {
563  if ($a_pc_id == "") {
564  $path = "//TableData[@HierId = '" . $a_hier_id . "']";
565  } else {
566  $path = "//TableData[@PCID = '" . $a_pc_id . "']";
567  }
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);
572  } else {
573  if ($nodes->item(0)->hasAttribute("HorizontalAlign")) {
574  $nodes->item(0)->removeAttribute("HorizontalAlign");
575  }
576  }
577  }
578  }
$path
Definition: ltiservices.php:29

◆ setTDClass()

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

set class of table data cell

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

References $path.

537  : void {
538  if ($a_pc_id == "") {
539  $path = "//TableData[@HierId = '" . $a_hier_id . "']";
540  } else {
541  $path = "//TableData[@PCID = '" . $a_pc_id . "']";
542  }
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);
547  } else {
548  if ($nodes->item(0)->hasAttribute("Class")) {
549  $nodes->item(0)->removeAttribute("Class");
550  }
551  }
552  }
553  }
$path
Definition: ltiservices.php:29

◆ setTDSpans()

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

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

References fixHideAndSpans(), and ilPageContent\getChildNode().

292  : void {
293  $y = 0;
294  $rows = $this->getChildNode()->childNodes;
295  foreach ($rows as $row) {
296  if ($row->nodeName == "TableRow") {
297  $x = 0;
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]);
304  } else {
305  if ($cell->hasAttribute("ColSpan")) {
306  $cell->removeAttribute("ColSpan");
307  }
308  }
309  if ((int) ($a_rowspans[$ckey] ?? 0) > 1) {
310  $cell->setAttribute("RowSpan", (int) $a_rowspans[$ckey]);
311  } else {
312  if ($cell->hasAttribute("RowSpan")) {
313  $cell->removeAttribute("RowSpan");
314  }
315  }
316  }
317  $x++;
318  }
319  $y++;
320  }
321  }
322  $this->fixHideAndSpans();
323  }
fixHideAndSpans()
Fix Hide and Spans.
+ Here is the call graph for this function:

◆ setTDWidth()

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

set width of table data cell

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

References $path.

270  : void {
271  if ($a_pc_id == "") {
272  $path = "//TableData[@HierId = '" . $a_hier_id . "']";
273  } else {
274  $path = "//TableData[@PCID = '" . $a_pc_id . "']";
275  }
276  $nodes = $this->dom_util->path($this->dom_doc, $path);
277 
278  if (count($nodes) == 1) {
279  if ($a_width != "") {
280  $nodes->item(0)->setAttribute("Width", $a_width);
281  } else {
282  if ($nodes->item(0)->hasAttribute("Width")) {
283  $nodes->item(0)->removeAttribute("Width");
284  }
285  }
286  }
287  }
$path
Definition: ltiservices.php:29

◆ setTemplate()

ilPCTable::setTemplate ( string  $a_template)

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

References setTableAttribute().

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

655  : void
656  {
657  $this->setTableAttribute("Template", $a_template);
658  }
setTableAttribute(string $a_attr, string $a_value)
Set attribute of table tag.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setWidth()

ilPCTable::setWidth ( string  $a_width)

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

References setTableAttribute().

218  : void
219  {
220  $this->setTableAttribute("Width", $a_width);
221  }
setTableAttribute(string $a_attr, string $a_value)
Set attribute of table tag.
+ Here is the call graph for this function:

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