ILIAS  release_7 Revision v7.30-3-g800a261c036
ilPCTable Class Reference

Class ilPCTable. More...

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

Public Member Functions

 init ()
 Init page content component. More...
 
 setNode ($a_node)
 Set xml node of page content. More...
 
 create (&$a_pg_obj, $a_hier_id, $a_pc_id="")
 
addRow ()
 
addCell (&$aRow, $a_data="", $a_lang="")
 
 getCellText ($i, $j)
 Get cell text of row $i and cell $j. More...
 
 getCellNode ($i, $j, $create_if_not_exists=false)
 Get cell paragraph node of row $i and cell $j. More...
 
 addRows ($a_nr_rows, $a_nr_cols)
 add rows to table More...
 
 importSpreadsheet ($a_lang, $a_data)
 import from table More...
 
 getLanguage ()
 get table language More...
 
 setLanguage ($a_lang)
 set table language More...
 
 getWidth ()
 get table width More...
 
 setWidth ($a_width)
 set table width More...
 
 getBorder ()
 get table border width More...
 
 setBorder ($a_border)
 set table border More...
 
 getCellSpacing ()
 get table cell spacing More...
 
 setCellSpacing ($a_spacing)
 set table cell spacing More...
 
 getCellPadding ()
 get table cell padding More...
 
 setCellPadding ($a_padding)
 set table cell padding More...
 
 setHorizontalAlign ($a_halign)
 set horizontal align More...
 
 getHorizontalAlign ()
 get table cell padding More...
 
 setTDWidth ($a_hier_id, $a_width, $a_pc_id="")
 set width of table data cell More...
 
 setTDSpans ($a_colspans, $a_rowspans)
 Set TDSpans. More...
 
 fixHideAndSpans ()
 Fix Hide and Spans. More...
 
 makeEmptyCell ($td_node)
 Make cell empty. More...
 
 checkCellHidden ($colspans, $rowspans, $x, $y)
 Check hidden status. More...
 
 getAllCellClasses ()
 Get all cell classes. More...
 
 getAllCellAlignments ()
 Get all cell alignments. More...
 
 getAllCellSpans ()
 Get all cell spans. More...
 
 getAllCellWidths ()
 Get all cell widhts. More...
 
 setTDClass ($a_hier_id, $a_class, $a_pc_id="")
 set class of table data cell More...
 
 setTDAlignment ($a_hier_id, $a_class, $a_pc_id="")
 set alignment of table data cell More...
 
 getCaption ()
 get caption More...
 
 getCaptionAlign ()
 get caption alignment (Top | Bottom) More...
 
 setCaption ($a_content, $a_align)
 set table caption More...
 
 importTableAttributes (&$node)
 
 importCellAttributes (&$node, &$par)
 
 importRow ($lng, &$node)
 
 importCell ($lng, &$cellNode, &$aRow)
 
 extractText (&$node)
 
 importHtml ($lng, $htmlTable)
 
 setFirstRowStyle ($a_class)
 Set first row td style. More...
 
 setClass ($a_class)
 Set Style Class of table. More...
 
 getClass ()
 Get characteristic of section. More...
 
 setTemplate ($a_template)
 Set template. More...
 
 getTemplate ()
 Get template. More...
 
 setHeaderRows ($a_nr)
 Set header rows. More...
 
 getHeaderRows ()
 Get header rows. More...
 
 setFooterRows ($a_nr)
 Set footer rows. More...
 
 getFooterRows ()
 Get footer rows. More...
 
 setHeaderCols ($a_nr)
 Set header cols. More...
 
 getHeaderCols ()
 Get header cols. More...
 
 setFooterCols ($a_nr)
 Set footer cols. More...
 
 getFooterCols ()
 Get footer cols. More...
 
 getTableAttribute ($a_attr)
 Get table tag attribute. More...
 
 getModel ()
 @inheritDoc More...
 
- Public Member Functions inherited from ilPageContent
 __construct ($a_pg_obj)
 Constructor. More...
 
 setPage ($a_val)
 Set page. More...
 
 getPage ()
 Get page. More...
 
 init ()
 Init object. More...
 
 getType ()
 Get type of page content. More...
 
 setNode ($a_node)
 Set xml node of page content. More...
 
getNode ()
 Get xml node of page content. More...
 
 getJavascriptFiles ($a_mode)
 Get Javascript files. More...
 
 getCssFiles ($a_mode)
 Get css files. More...
 
 getOnloadCode ($a_mode)
 Get on load code. More...
 
 setHierId ($a_hier_id)
 Set hierarchical ID in xml structure. More...
 
 getHierId ()
 Get hierarchical id. More...
 
 lookupHierId ()
 Get hierarchical id from dom. More...
 
 readHierId ()
 Read PC Id. More...
 
 setPcId ($a_pcid)
 Set PC Id. More...
 
 getPCId ()
 Get PC Id. More...
 
 setFileDownloadLink ($a_download_link)
 Set file download link. More...
 
 getFileDownloadLink ()
 Get file download link. More...
 
 setProfileBackUrl ($url)
 
 getProfileBackUrl ()
 
 setFullscreenLink ($a_fullscreen_link)
 Set fullscreen link. More...
 
 getFullscreenLink ()
 Get fullscreen link. More...
 
 setSourcecodeDownloadScript ($script_name)
 Set sourcecode download script. More...
 
 getSourcecodeDownloadScript ()
 Get sourcecode download script. More...
 
 readPCId ()
 Read PC Id. More...
 
 writePCId ($a_pc_id)
 Write pc id. More...
 
 setEnabled ($value)
 Set Enabled value for page content component. More...
 
 enable ()
 Enable page content. More...
 
 disable ()
 Disable page content. More...
 
 isEnabled ()
 Check whether page content is enabled. More...
 
 createPageContentNode ($a_set_this_node=true)
 Create page content node (always use this method first when adding a new element) More...
 
 modifyPageContentPostXsl ($a_output, $a_mode, $a_abstract_only=false)
 Modify page content after xsl. More...
 
 getModel ()
 Get model. More...
 

Static Public Member Functions

static getLangVars ()
 Get lang vars needed for editing. More...
 
static handleCopiedContent (DOMDocument $a_domdoc, $a_self_ass=true, $a_clone_mobs=false)
 Handle copied content. More...
 
- Static Public Member Functions inherited from ilPageContent
static incEdId ($ed_id)
 Increases an hierarchical editing id at lowest level (last number) More...
 
static decEdId ($ed_id)
 Decreases an hierarchical editing id at lowest level (last number) More...
 
static haveSameContainer ($ed_id1, $ed_id2)
 Check, if two ids are in same container. More...
 
static sortHierIds ($a_array)
 Sort an array of Hier IDS in ascending order. More...
 
static isGreaterHierId ($a, $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, $a_self_ass=true, $a_clone_mobs=false)
 Handle copied content. More...
 
static afterPageUpdate ($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
 After page has been updated (or created) More...
 
static beforePageDelete ($a_page)
 Before page is being deleted. More...
 
static afterPageHistoryEntry ($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
 After page history entry has been created. More...
 

Data Fields

 $dom
 
 $tab_node
 
- Data Fields inherited from ilPageContent
 $hier_id
 
 $node
 
 $dom
 
 $page_lang
 

Protected Member Functions

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

Additional Inherited Members

- Protected Attributes inherited from ilPageContent
 $profile_back_url
 
 $file_download_link
 
 $fullscreen_link
 
 $sourcecode_download_script
 
 $log
 

Detailed Description

Class ilPCTable.

Table content object (see ILIAS DTD)

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Member Function Documentation

◆ addCell()

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

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

54 {
55 $new_td = $this->dom->create_element("TableData");
56 $new_td = $aRow->append_child($new_td);
57
58 // insert data if given
59 if ($a_data != "") {
60 $new_pg = $this->createPageContentNode(false);
61 $new_par = $this->dom->create_element("Paragraph");
62 $new_par = $new_pg->append_child($new_par);
63 $new_par->set_attribute("Language", $a_lang);
64 $new_par->set_attribute("Characteristic", "TableContent");
65 $new_par->set_content($a_data);
66 $new_td->append_child($new_pg);
67 }
68
69 return $new_td;
70 }
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element)

References ilPageContent\createPageContentNode().

Referenced by addRows(), importCell(), and importSpreadsheet().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addRow()

& ilPCTable::addRow ( )

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

47 {
48 $new_tr = $this->dom->create_element("TableRow");
49 $new_tr = &$this->tab_node->append_child($new_tr);
50 return $new_tr;
51 }

Referenced by addRows(), importRow(), and importSpreadsheet().

+ Here is the caller graph for this function:

◆ addRows()

ilPCTable::addRows (   $a_nr_rows,
  $a_nr_cols 
)

add rows to table

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

147 {
148 for ($i = 1; $i <= $a_nr_rows; $i++) {
149 $aRow = $this->addRow();
150 for ($j = 1; $j <= $a_nr_cols; $j++) {
151 $this->addCell($aRow);
152 }
153 }
154 }
& addCell(&$aRow, $a_data="", $a_lang="")
$i
Definition: metadata.php:24

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

+ Here is the call graph for this function:

◆ checkCellHidden()

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

Check hidden status.

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

457 {
458 for ($i = 0; $i <= $x; $i++) {
459 for ($j = 0; $j <= $y; $j++) {
460 if ($i != $x || $j != $y) {
461 if ((($i + $colspans[$i][$j] > $x) &&
462 ($j + $rowspans[$i][$j] > $y))) {
463 return true;
464 }
465 }
466 }
467 }
468 return false;
469 }

References $i.

Referenced by fixHideAndSpans().

+ Here is the caller graph for this function:

◆ create()

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

Reimplemented in ilPCDataTable.

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

38 {
39 $this->node = $this->createPageContentNode();
40 $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
41 $this->tab_node = $this->dom->create_element("Table");
42 $this->tab_node = $this->node->append_child($this->tab_node);
43 $this->tab_node->set_attribute("Language", "");
44 }
const IL_INSERT_AFTER

References ilPageContent\createPageContentNode(), and IL_INSERT_AFTER.

+ Here is the call graph for this function:

◆ extractText()

ilPCTable::extractText ( $node)

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

758 {
759 $owner_document = $node->owner_document();
760 $children = $node->child_nodes();
761 $total_children = count($children);
762 for ($i = 0; $i < $total_children; $i++) {
763 $cur_child_node = $children[$i];
764 $output .= $owner_document->dump_node($cur_child_node);
765 }
766 return $output;
767 }

References $i, and ilPageContent\$node.

Referenced by importCellAttributes(), and importTableAttributes().

+ Here is the caller 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 365 of file class.ilPCTable.php.

366 {
367
368 // first: get max x and y
369 $max_x = $max_y = 0;
370 $y = 0;
371 $rows = $this->tab_node->child_nodes();
372
373 foreach ($rows as $row) {
374 if ($row->node_name() == "TableRow") {
375 $x = 0;
376 $cells = $row->child_nodes();
377 foreach ($cells as $cell) {
378 if ($cell->node_name() == "TableData") {
379 $max_x = max($max_x, $x);
380 $max_y = max($max_y, $y);
381 }
382 $x++;
383 }
384 $y++;
385 }
386 }
387
388 // second: fix hidden/colspans for all cells
389 $y = 0;
390 $rows = $this->tab_node->child_nodes();
391 foreach ($rows as $row) {
392 if ($row->node_name() == "TableRow") {
393 $x = 0;
394 $cells = $row->child_nodes();
395 foreach ($cells as $cell) {
396 if ($cell->node_name() == "TableData") {
397 $cspan = max(1, (int) $cell->get_attribute("ColSpan"));
398 $rspan = max(1, (int) $cell->get_attribute("RowSpan"));
399
400 // if col or rowspan is to high: reduce it to the max
401 if ($cspan > $max_x - $x + 1) {
402 $cell->set_attribute("ColSpan", $max_x - $x + 1);
403 $cspan = $max_x - $x + 1;
404 }
405 if ($rspan > $max_y - $y + 1) {
406 $cell->set_attribute("RowSpan", $max_y - $y + 1);
407 $rspan = $max_y - $y + 1;
408 }
409
410 // check hidden status
411 if ($this->checkCellHidden($colspans, $rowspans, $x, $y)) {
412 // hidden: set hidden flag, remove col and rowspan
413 $cell->set_attribute("Hidden", "Y");
414 $cspan = 1;
415 $rspan = 1;
416 if ($cell->has_attribute("ColSpan")) {
417 $cell->remove_attribute("ColSpan");
418 }
419 if ($cell->has_attribute("RowSpan")) {
420 $cell->remove_attribute("RowSpan");
421 }
422 $this->makeEmptyCell($cell);
423 } else {
424 // not hidden: remove hidden flag if existing
425 if ($cell->has_attribute("Hidden")) {
426 $cell->remove_attribute("Hidden");
427 }
428 }
429
430 $colspans[$x][$y] = $cspan;
431 $rowspans[$x][$y] = $rspan;
432 }
433 $x++;
434 }
435 $y++;
436 }
437 }
438 }
checkCellHidden($colspans, $rowspans, $x, $y)
Check hidden status.
makeEmptyCell($td_node)
Make cell empty.
$rows
Definition: xhr_table.php:10

References $rows, checkCellHidden(), and makeEmptyCell().

Referenced by setTDSpans().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllCellAlignments()

ilPCTable::getAllCellAlignments ( )

Get all cell alignments.

Returns
array array of cell alignments

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

501 {
502 $classes = array();
503 $rows = $this->tab_node->child_nodes();
504 foreach ($rows as $row) {
505 if ($row->node_name() == "TableRow") {
506 $cells = $row->child_nodes();
507 foreach ($cells as $cell) {
508 if ($cell->node_name() == "TableData") {
509 $classes[$cell->get_attribute("HierId") . ":" . $cell->get_attribute("PCID")]
510 = $cell->get_attribute("HorizontalAlign");
511 }
512 }
513 }
514 }
515
516 return $classes;
517 }

References $rows.

◆ getAllCellClasses()

ilPCTable::getAllCellClasses ( )

Get all cell classes.

Returns
array array of cell style classes

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

477 {
478 $classes = array();
479 $rows = $this->tab_node->child_nodes();
480 foreach ($rows as $row) {
481 if ($row->node_name() == "TableRow") {
482 $cells = $row->child_nodes();
483 foreach ($cells as $cell) {
484 if ($cell->node_name() == "TableData") {
485 $classes[$cell->get_attribute("HierId") . ":" . $cell->get_attribute("PCID")]
486 = $cell->get_attribute("Class");
487 }
488 }
489 }
490 }
491
492 return $classes;
493 }

References $rows.

◆ getAllCellSpans()

ilPCTable::getAllCellSpans ( )

Get all cell spans.

Returns
array array of cell style classes

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

525 {
526 $spans = array();
527 $rows = $this->tab_node->child_nodes();
528 $y = 0;
529 $max_x = 0;
530 $max_y = 0;
531 foreach ($rows as $row) {
532 if ($row->node_name() == "TableRow") {
533 $x = 0;
534 $cells = $row->child_nodes();
535 foreach ($cells as $cell) {
536 if ($cell->node_name() == "TableData") {
537 $spans[$cell->get_attribute("HierId") . ":" . $cell->get_attribute("PCID")]
538 = array("x" => $x, "y" => $y, "colspan" => $cell->get_attribute("ColSpan"),
539 "rowspan" => $cell->get_attribute("RowSpan"));
540 $max_x = max($max_x, $x);
541 $max_y = max($max_y, $y);
542 }
543 $x++;
544 }
545 $y++;
546 }
547 }
548 foreach ($spans as $k => $v) {
549 $spans[$k]["max_x"] = $max_x;
550 $spans[$k]["max_y"] = $max_y;
551 }
552
553 return $spans;
554 }

References $rows.

◆ getAllCellWidths()

ilPCTable::getAllCellWidths ( )

Get all cell widhts.

Returns
array array of cell style classes

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

562 {
563 $widths = array();
564 $rows = $this->tab_node->child_nodes();
565 foreach ($rows as $row) {
566 if ($row->node_name() == "TableRow") {
567 $cells = $row->child_nodes();
568 foreach ($cells as $cell) {
569 if ($cell->node_name() == "TableData") {
570 $widths[$cell->get_attribute("HierId") . ":" . $cell->get_attribute("PCID")]
571 = $cell->get_attribute("Width");
572 }
573 }
574 }
575 }
576
577 return $widths;
578 }

References $rows.

◆ getBorder()

ilPCTable::getBorder ( )

get table border width

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

232 {
233 return $this->getTableAttribute("Border");
234 }
getTableAttribute($a_attr)
Get table tag attribute.

References getTableAttribute().

+ Here is the call graph for this function:

◆ getCaption()

ilPCTable::getCaption ( )

get caption

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

630 {
631 $hier_id = $this->getHierId();
632 if (!empty($hier_id)) {
633 $xpc = xpath_new_context($this->dom);
634 $path = "//PageContent[@HierId = '" . $hier_id . "']/Table/Caption";
635 $res = xpath_eval($xpc, $path);
636
637 if (count($res->nodeset) == 1) {
638 return $res->nodeset[0]->get_content();
639 }
640 }
641 }
getHierId()
Get hierarchical id.
xpath_eval($xpath_context, $eval_str, $contextnode=null)
xpath_new_context($dom_document)
foreach($_POST as $key=> $value) $res

References ilPageContent\$hier_id, $res, ilPageContent\getHierId(), 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 646 of file class.ilPCTable.php.

647 {
648 $hier_id = $this->getHierId();
649 if (!empty($hier_id)) {
650 $xpc = xpath_new_context($this->dom);
651 $path = "//PageContent[@HierId = '" . $hier_id . "']/Table/Caption";
652 $res = xpath_eval($xpc, $path);
653 if (count($res->nodeset) == 1) {
654 return $res->nodeset[0]->get_attribute("Align");
655 }
656 }
657 }

References ilPageContent\$hier_id, $res, ilPageContent\getHierId(), xpath_eval(), and xpath_new_context().

+ Here is the call graph for this function:

◆ getCellNode()

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

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

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

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

References $i, $res, ilPageContent\createPageContentNode(), ilPageContent\getHierId(), getLanguage(), xpath_eval(), and xpath_new_context().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCellPadding()

ilPCTable::getCellPadding ( )

get table cell padding

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

268 {
269 return $this->getTableAttribute("CellPadding");
270 }

References getTableAttribute().

+ Here is the call graph for this function:

◆ getCellSpacing()

ilPCTable::getCellSpacing ( )

get table cell spacing

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

250 {
251 return $this->getTableAttribute("CellSpacing");
252 }

References getTableAttribute().

+ Here is the call graph for this function:

◆ getCellText()

ilPCTable::getCellText (   $i,
  $j 
)

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

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

76 {
77 $cell_par = $this->getCellNode($i, $j, false);
78
79 if (is_object($cell_par)) {
80 $content = "";
81 $childs = $cell_par->child_nodes();
82 for ($i = 0; $i < count($childs); $i++) {
83 $content .= $this->dom->dump_node($childs[$i]);
84 }
85 return $content;
86 } else {
87 return "";
88 }
89 }
getCellNode($i, $j, $create_if_not_exists=false)
Get cell paragraph node of row $i and cell $j.

References $i, and getCellNode().

Referenced by getModel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getClass()

ilPCTable::getClass ( )

Get characteristic of section.

Returns
string characteristic

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

855 {
856 return $this->getTableAttribute("Class");
857 }

References getTableAttribute().

+ Here is the call graph for this function:

◆ getFooterCols()

ilPCTable::getFooterCols ( )

Get footer cols.

Returns
string number of footer cols

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

955 {
956 return $this->getTableAttribute("FooterCols");
957 }

References getTableAttribute().

+ Here is the call graph for this function:

◆ getFooterRows()

ilPCTable::getFooterRows ( )

Get footer rows.

Returns
string number of footer rows

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

915 {
916 return $this->getTableAttribute("FooterRows");
917 }

References getTableAttribute().

+ Here is the call graph for this function:

◆ getHeaderCols()

ilPCTable::getHeaderCols ( )

Get header cols.

Returns
string number of header cols

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

935 {
936 return $this->getTableAttribute("HeaderCols");
937 }

References getTableAttribute().

+ Here is the call graph for this function:

◆ getHeaderRows()

ilPCTable::getHeaderRows ( )

Get header rows.

Returns
string number of header rows

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

895 {
896 return $this->getTableAttribute("HeaderRows");
897 }

References getTableAttribute().

+ Here is the call graph for this function:

◆ getHorizontalAlign()

ilPCTable::getHorizontalAlign ( )

get table cell padding

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

294 {
295 return $this->getTableAttribute("HorizontalAlign");
296 }

References getTableAttribute().

+ Here is the call graph for this function:

◆ getLanguage()

ilPCTable::getLanguage ( )

get table language

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

194 {
195 return $this->getTableAttribute("Language");
196 }

References getTableAttribute().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLangVars()

static ilPCTable::getLangVars ( )
static

Get lang vars needed for editing.

Returns
array array of lang var keys

Reimplemented from ilPageContent.

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

993 {
994 return array("ed_insert_dtable", "ed_insert_atable","ed_new_row_after", "ed_new_row_before",
995 "ed_new_col_after", "ed_new_col_before", "ed_delete_col",
996 "ed_delete_row", "ed_edit_data", "ed_row_up", "ed_row_down",
997 "ed_col_left", "ed_col_right");
998 }

◆ getModel()

ilPCTable::getModel ( )

@inheritDoc

Reimplemented from ilPageContent.

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

1020 {
1021 $model = new \stdClass();
1022
1023 $rows = $this->tab_node->child_nodes();
1024
1025 $y = 0;
1026 foreach ($rows as $row) {
1027 if ($row->node_name() == "TableRow") {
1028 $x = 0;
1029 $cells = $row->child_nodes();
1030 foreach ($cells as $cell) {
1031 if ($cell->node_name() == "TableData") {
1033 $this->getCellText($y, $x),
1034 true,
1035 false
1036 );
1037 $text = ilPCParagraphGUI::xml2outputJS($text);
1038 $model->content[$y][$x] = $text;
1039 }
1040 $x++;
1041 }
1042 $y++;
1043 }
1044 }
1045
1046 return $model;
1047 }
static xml2outputJS($s_text)
Prepare content for js output.
static xml2output($a_text, $a_wysiwyg=false, $a_replace_lists=true, $unmask=true)
Converts xml from DB to output in edit textarea.
getCellText($i, $j)
Get cell text of row $i and cell $j.

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

+ Here is the call graph for this function:

◆ getTableAttribute()

ilPCTable::getTableAttribute (   $a_attr)

Get table tag attribute.

Returns
string attribute name

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

982 {
983 if (is_object($this->tab_node)) {
984 return $this->tab_node->get_attribute($a_attr);
985 }
986 }

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

+ Here is the caller graph for this function:

◆ getTemplate()

ilPCTable::getTemplate ( )

Get template.

Returns
string template

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

875 {
876 return $this->getTableAttribute("Template");
877 }

References getTableAttribute().

+ Here is the call graph for this function:

◆ getWidth()

ilPCTable::getWidth ( )

get table width

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

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

References getTableAttribute().

+ Here is the call graph for this function:

◆ handleCopiedContent()

static ilPCTable::handleCopiedContent ( DOMDocument  $a_domdoc,
  $a_self_ass = true,
  $a_clone_mobs = false 
)
static

Handle copied content.

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

Parameters
DOMDocument$a_domdocdom document

Reimplemented from ilPageContent.

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

1008 {
1009 $xpath = new DOMXPath($a_domdoc);
1010 $nodes = $xpath->query("//Table");
1011 foreach ($nodes as $node) {
1012 $node->removeAttribute("Id");
1013 }
1014 }

References ilPageContent\$node.

◆ importCell()

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

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

745 {
746 /*echo "add Cell";
747 var_dump($cellNode);*/
748 $aCell = $this->addCell($aRow);
749 $par = new ilPCParagraph($this->getPage());
750 $par->createAtNode($aCell);
751 $par->setText($par->input2xml($this->extractText($cellNode)));
752 $par->setCharacteristic("TableContent");
753 $par->setLanguage($lng);
754 $this->importCellAttributes($cellNode, $aCell);
755 }
Class ilPCParagraph.
importCellAttributes(&$node, &$par)
$lng

References $lng, addCell(), ilPageContent\getPage(), and importCellAttributes().

Referenced by importRow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importCellAttributes()

ilPCTable::importCellAttributes ( $node,
$par 
)

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

709 {
710 /*echo "importing table attributes";
711 var_dump($tableNode);*/
712 if ($node->has_attributes()) {
713 foreach ($node->attributes() as $n) {
714 switch (strtolower($n->node_name())) {
715 case "class":
716 $par->set_attribute("Class", $this->extractText($n));
717 break;
718 case "width":
719 $par->set_attribute("Width", $this->extractText($n));
720 break;
721 }
722 }
723 }
724 }
$n
Definition: RandomTest.php:85
extractText(&$node)

References $n, ilPageContent\$node, and extractText().

Referenced by importCell().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importHtml()

ilPCTable::importHtml (   $lng,
  $htmlTable 
)

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

770 {
771 $dummy = ilUtil::stripSlashes($htmlTable, false);
772 //echo htmlentities($dummy);
773 $dom = @domxml_open_mem($dummy, DOMXML_LOAD_PARSING, $error);
774
775 if ($dom) {
776 $xpc = @xpath_new_context($dom);
777 // extract first table object
778 $path = "//table[1] | //Table[1]";
779 $res = @xpath_eval($xpc, $path);
780
781 if (count($res->nodeset) == 0) {
782 $error = "Could not find a table root node";
783 }
784
785 if (empty($error)) {
786 for ($i = 0; $i < count($res->nodeset); $i++) {
787 $node = $res->nodeset[$i];
788
790
791 if ($node->has_child_nodes()) {
792 foreach ($node->child_nodes() as $n) {
793 if ($n->node_type() == XML_ELEMENT_NODE &&
794 strcasecmp($n->node_name(), "tr") == 0) {
795 $this->importRow($lng, $n);
796 }
797 }
798 }
799 }
800 }
801 $dom->free();
802 }
803 if (is_array($error)) {
804 $errmsg = "";
805 foreach ($error as $errorline) { # Loop through all errors
806 $errmsg .= "[" . $errorline['line'] . ", " . $errorline['col'] . "]: " . $errorline['errormessage'] . " at Node '" . $errorline['nodename'] . "'<br />";
807 }
808 } else {
809 $errmsg = $error;
810 }
811
812 if (empty($errmsg)) {
813 return true;
814 }
815
816 $_SESSION["message"] = $errmsg;
817 return false;
818 }
$_SESSION["AccountId"]
importRow($lng, &$node)
importTableAttributes(&$node)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
domxml_open_mem($str, $mode=0, &$error=null)
const DOMXML_LOAD_PARSING

References $_SESSION, $dom, $i, $lng, $n, ilPageContent\$node, $res, DOMXML_LOAD_PARSING, domxml_open_mem(), importRow(), importTableAttributes(), ilUtil\stripSlashes(), xpath_eval(), and xpath_new_context().

+ Here is the call graph for this function:

◆ importRow()

ilPCTable::importRow (   $lng,
$node 
)

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

728 {
729 /*echo "add Row";
730 var_dump($node);*/
731
732 $aRow = $this->addRow();
733
734 if ($node->has_child_nodes()) {
735 foreach ($node->child_nodes() as $n) {
736 if ($n->node_type() == XML_ELEMENT_NODE &&
737 strcasecmp($n->node_name(), "td") == 0) {
738 $this->importCell($lng, $n, $aRow);
739 }
740 }
741 }
742 }
importCell($lng, &$cellNode, &$aRow)

References $lng, $n, ilPageContent\$node, addRow(), and importCell().

Referenced by importHtml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importSpreadsheet()

ilPCTable::importSpreadsheet (   $a_lang,
  $a_data 
)

import from table

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

160 {
161 str_replace($a_data, "\r", "\n");
162 str_replace($a_data, "\n\n", "\n");
163 $target_rows = array();
164 $rows = explode("\n", $a_data);
165
166 // get maximum of cols in a row and
167 // put data in target_row arrays
168 foreach ($rows as $row) {
169 $cells = explode("\t", $row);
170 $max_cols = ($max_cols > count($cells))
171 ? $max_cols
172 : count($cells);
173 $target_rows[] = $cells;
174 }
175
176 // iterate target row arrays and insert data
177 foreach ($target_rows as $row) {
178 $aRow = $this->addRow();
179 for ($j = 0; $j < $max_cols; $j++) {
180 // mask html
181 $data = str_replace("&", "&amp;", $row[$j]);
182 $data = str_replace("<", "&lt;", $data);
183 $data = str_replace(">", "&gt;", $data);
184
185 $this->addCell($aRow, $data, $a_lang);
186 }
187 }
188 }
$data
Definition: storeScorm.php:23

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

+ Here is the call graph for this function:

◆ importTableAttributes()

ilPCTable::importTableAttributes ( $node)

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

680 {
681 /*echo "importing table attributes";
682 var_dump($tableNode);*/
683 if ($node->has_attributes()) {
684 foreach ($node->attributes() as $n) {
685 switch (strtolower($n->node_name())) {
686 case "border":
687 $this->setBorder($this->extractText($n));
688 break;
689 case "align":
690 $this->setHorizontalAlign(ucfirst(strtolower($this->extractText($n))));
691 break;
692 case "cellspacing":
693 $this->setCellSpacing($this->extractText($n));
694 break;
695 case "cellpadding":
696 $this->setCellPadding($this->extractText($n));
697 break;
698 case "width":
699 $this->setWidth($this->extractText($n));
700 break;
701
702 }
703 }
704 }
705 }
setCellPadding($a_padding)
set table cell padding
setHorizontalAlign($a_halign)
set horizontal align
setWidth($a_width)
set table width
setBorder($a_border)
set table border
setCellSpacing($a_spacing)
set table cell spacing

References $n, ilPageContent\$node, extractText(), setBorder(), setCellPadding(), setCellSpacing(), setHorizontalAlign(), and setWidth().

Referenced by importHtml().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

ilPCTable::init ( )

Init page content component.

Reimplemented from ilPageContent.

Reimplemented in ilPCDataTable.

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

27 {
28 $this->setType("tab");
29 }
setType($a_type)
Set Type.

References ilPageContent\setType().

+ Here is the call graph for this function:

◆ makeEmptyCell()

ilPCTable::makeEmptyCell (   $td_node)

Make cell empty.

Reimplemented in ilPCDataTable.

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

445 {
446 // delete children of paragraph node
447 $children = $td_node->child_nodes();
448 for ($i = 0; $i < count($children); $i++) {
449 $td_node->remove_child($children[$i]);
450 }
451 }

References $i.

Referenced by fixHideAndSpans().

+ Here is the caller graph for this function:

◆ setBorder()

ilPCTable::setBorder (   $a_border)

set table border

Parameters
string$a_bordertable border

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

242 {
243 $this->setTableAttribute("Border", $a_border);
244 }
setTableAttribute($a_attr, $a_value)
Set attribute of table tag.

References setTableAttribute().

Referenced by importTableAttributes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCaption()

ilPCTable::setCaption (   $a_content,
  $a_align 
)

set table caption

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

663 {
664 if ($a_content != "") {
666 $this->dom,
667 $this->tab_node,
668 "Caption",
669 array("Summary", "TableRow"),
670 $a_content,
671 array("Align" => $a_align)
672 );
673 } else {
674 ilDOMUtil::deleteAllChildsByName($this->tab_node, array("Caption"));
675 }
676 }
static setFirstOptionalElement( $doc, $parent_node, $a_node_name, $a_successors, $a_content, $a_attributes, $a_remove_childs=true)
searches for an element $a_node_name within the childs of $parent_node if no node is found,...
static deleteAllChildsByName($a_parent, $a_node_names)
delete all childs of a node by names in $a_node_names

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

+ Here is the call graph for this function:

◆ setCellPadding()

ilPCTable::setCellPadding (   $a_padding)

set table cell padding

Parameters
string$a_paddingtable cell padding

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

278 {
279 $this->setTableAttribute("CellPadding", $a_padding);
280 }

References setTableAttribute().

Referenced by importTableAttributes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCellSpacing()

ilPCTable::setCellSpacing (   $a_spacing)

set table cell spacing

Parameters
string$a_spacingtable cell spacing

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

260 {
261 $this->setTableAttribute("CellSpacing", $a_spacing);
262 }

References setTableAttribute().

Referenced by importTableAttributes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setClass()

ilPCTable::setClass (   $a_class)

Set Style Class of table.

Parameters
string$a_classclass

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

845 {
846 $this->setTableAttribute("Class", $a_class);
847 }

References setTableAttribute().

+ Here is the call graph for this function:

◆ setFirstRowStyle()

ilPCTable::setFirstRowStyle (   $a_class)

Set first row td style.

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

824 {
825 $childs = $this->tab_node->child_nodes();
826 foreach ($childs as $child) {
827 if ($child->node_name() == "TableRow") {
828 $gchilds = $child->child_nodes();
829 foreach ($gchilds as $gchild) {
830 if ($gchild->node_name() == "TableData") {
831 $gchild->set_attribute("Class", $a_class);
832 }
833 }
834 return;
835 }
836 }
837 }

◆ setFooterCols()

ilPCTable::setFooterCols (   $a_nr)

Set footer cols.

Parameters
stringnumber of footer cols

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

945 {
946 $this->setTableAttribute("FooterCols", $a_nr);
947 }

References setTableAttribute().

+ Here is the call graph for this function:

◆ setFooterRows()

ilPCTable::setFooterRows (   $a_nr)

Set footer rows.

Parameters
stringnumber of footer rows

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

905 {
906 $this->setTableAttribute("FooterRows", $a_nr);
907 }

References setTableAttribute().

+ Here is the call graph for this function:

◆ setHeaderCols()

ilPCTable::setHeaderCols (   $a_nr)

Set header cols.

Parameters
stringnumber of header cols

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

925 {
926 $this->setTableAttribute("HeaderCols", $a_nr);
927 }

References setTableAttribute().

+ Here is the call graph for this function:

◆ setHeaderRows()

ilPCTable::setHeaderRows (   $a_nr)

Set header rows.

Parameters
stringnumber of header rows

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

885 {
886 $this->setTableAttribute("HeaderRows", $a_nr);
887 }

References setTableAttribute().

+ Here is the call graph for this function:

◆ setHorizontalAlign()

ilPCTable::setHorizontalAlign (   $a_halign)

set horizontal align

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

286 {
287 $this->tab_node->set_attribute("HorizontalAlign", $a_halign);
288 }

Referenced by importTableAttributes().

+ Here is the caller graph for this function:

◆ setLanguage()

ilPCTable::setLanguage (   $a_lang)

set table language

Parameters
string$a_langlanguage code

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

204 {
205 if ($a_lang != "") {
206 $this->setTableAttribute("Language", $a_lang);
207 }
208 }

References setTableAttribute().

+ Here is the call graph for this function:

◆ setNode()

ilPCTable::setNode (   $a_node)

Set xml node of page content.

Parameters
object$a_nodenode object

Reimplemented from ilPageContent.

Reimplemented in ilPCDataTable.

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

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

◆ setTableAttribute()

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

Set attribute of table tag.

Parameters
stringattribute name
stringattribute value

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

966 {
967 if (!empty($a_value)) {
968 $this->tab_node->set_attribute($a_attr, $a_value);
969 } else {
970 if ($this->tab_node->has_attribute($a_attr)) {
971 $this->tab_node->remove_attribute($a_attr);
972 }
973 }
974 }

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

+ Here is the caller graph for this function:

◆ setTDAlignment()

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

set alignment of table data cell

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

607 {
608 $xpc = xpath_new_context($this->dom);
609 if ($a_pc_id == "") {
610 $path = "//TableData[@HierId = '" . $a_hier_id . "']";
611 } else {
612 $path = "//TableData[@PCID = '" . $a_pc_id . "']";
613 }
614 $res = xpath_eval($xpc, $path);
615 if (count($res->nodeset) == 1) {
616 if ($a_class != "") {
617 $res->nodeset[0]->set_attribute("HorizontalAlign", $a_class);
618 } else {
619 if ($res->nodeset[0]->has_attribute("HorizontalAlign")) {
620 $res->nodeset[0]->remove_attribute("HorizontalAlign");
621 }
622 }
623 }
624 }

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

+ Here is the call graph for this function:

◆ setTDClass()

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

set class of table data cell

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

584 {
585 $xpc = xpath_new_context($this->dom);
586 if ($a_pc_id == "") {
587 $path = "//TableData[@HierId = '" . $a_hier_id . "']";
588 } else {
589 $path = "//TableData[@PCID = '" . $a_pc_id . "']";
590 }
591 $res = xpath_eval($xpc, $path);
592 if (count($res->nodeset) == 1) {
593 if ($a_class != "") {
594 $res->nodeset[0]->set_attribute("Class", $a_class);
595 } else {
596 if ($res->nodeset[0]->has_attribute("Class")) {
597 $res->nodeset[0]->remove_attribute("Class");
598 }
599 }
600 }
601 }

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

+ Here is the call graph for this function:

◆ setTDSpans()

ilPCTable::setTDSpans (   $a_colspans,
  $a_rowspans 
)

Set TDSpans.

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

327 {
328 $y = 0;
329 $rows = $this->tab_node->child_nodes();
330 foreach ($rows as $row) {
331 if ($row->node_name() == "TableRow") {
332 $x = 0;
333 $cells = $row->child_nodes();
334 foreach ($cells as $cell) {
335 if ($cell->node_name() == "TableData") {
336 $ckey = $cell->get_attribute("HierId") . ":" . $cell->get_attribute("PCID");
337 if ((int) $a_colspans[$ckey] > 1) {
338 $cell->set_attribute("ColSpan", (int) $a_colspans[$ckey]);
339 } else {
340 if ($cell->has_attribute("ColSpan")) {
341 $cell->remove_attribute("ColSpan");
342 }
343 }
344 if ((int) $a_rowspans[$ckey] > 1) {
345 $cell->set_attribute("RowSpan", (int) $a_rowspans[$ckey]);
346 } else {
347 if ($cell->has_attribute("RowSpan")) {
348 $cell->remove_attribute("RowSpan");
349 }
350 }
351 }
352 $x++;
353 }
354 $y++;
355 }
356 }
357 $this->fixHideAndSpans();
358 }
fixHideAndSpans()
Fix Hide and Spans.

References $rows, and fixHideAndSpans().

+ Here is the call graph for this function:

◆ setTDWidth()

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

set width of table data cell

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

302 {
303 $xpc = xpath_new_context($this->dom);
304
305 if ($a_pc_id == "") {
306 $path = "//TableData[@HierId = '" . $a_hier_id . "']";
307 } else {
308 $path = "//TableData[@PCID = '" . $a_pc_id . "']";
309 }
310 $res = xpath_eval($xpc, $path);
311
312 if (count($res->nodeset) == 1) {
313 if ($a_width != "") {
314 $res->nodeset[0]->set_attribute("Width", $a_width);
315 } else {
316 if ($res->nodeset[0]->has_attribute("Width")) {
317 $res->nodeset[0]->remove_attribute("Width");
318 }
319 }
320 }
321 }

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

+ Here is the call graph for this function:

◆ setTemplate()

ilPCTable::setTemplate (   $a_template)

Set template.

Parameters
string$a_templatetemplate

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

865 {
866 $this->setTableAttribute("Template", $a_template);
867 }

References setTableAttribute().

+ Here is the call graph for this function:

◆ setWidth()

ilPCTable::setWidth (   $a_width)

set table width

Parameters
string$a_widthtable width

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

224 {
225 $this->setTableAttribute("Width", $a_width);
226 }

References setTableAttribute().

Referenced by importTableAttributes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $dom

ilPCTable::$dom

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

Referenced by importHtml().

◆ $tab_node

ilPCTable::$tab_node

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


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