ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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="")
 
 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...
 
- 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...
 

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

76 {
77 for ($i = 1; $i <= $a_nr_rows; $i++) {
78 $aRow = $this->addRow();
79 for ($j = 1; $j <= $a_nr_cols; $j++) {
80 $this->addCell($aRow);
81 }
82 }
83 }
& 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 385 of file class.ilPCTable.php.

386 {
387 for ($i = 0; $i <= $x; $i++) {
388 for ($j = 0; $j <= $y; $j++) {
389 if ($i != $x || $j != $y) {
390 if ((($i + $colspans[$i][$j] > $x) &&
391 ($j + $rowspans[$i][$j] > $y))) {
392 return true;
393 }
394 }
395 }
396 }
397 return false;
398 }

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

687 {
688 $owner_document = $node->owner_document();
689 $children = $node->child_nodes();
690 $total_children = count($children);
691 for ($i = 0; $i < $total_children; $i++) {
692 $cur_child_node = $children[$i];
693 $output .= $owner_document->dump_node($cur_child_node);
694 }
695 return $output;
696 }

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

295 {
296
297 // first: get max x and y
298 $max_x = $max_y = 0;
299 $y = 0;
300 $rows = $this->tab_node->child_nodes();
301
302 foreach ($rows as $row) {
303 if ($row->node_name() == "TableRow") {
304 $x = 0;
305 $cells = $row->child_nodes();
306 foreach ($cells as $cell) {
307 if ($cell->node_name() == "TableData") {
308 $max_x = max($max_x, $x);
309 $max_y = max($max_y, $y);
310 }
311 $x++;
312 }
313 $y++;
314 }
315 }
316
317 // second: fix hidden/colspans for all cells
318 $y = 0;
319 $rows = $this->tab_node->child_nodes();
320 foreach ($rows as $row) {
321 if ($row->node_name() == "TableRow") {
322 $x = 0;
323 $cells = $row->child_nodes();
324 foreach ($cells as $cell) {
325 if ($cell->node_name() == "TableData") {
326 $cspan = max(1, (int) $cell->get_attribute("ColSpan"));
327 $rspan = max(1, (int) $cell->get_attribute("RowSpan"));
328
329 // if col or rowspan is to high: reduce it to the max
330 if ($cspan > $max_x - $x + 1) {
331 $cell->set_attribute("ColSpan", $max_x - $x + 1);
332 $cspan = $max_x - $x + 1;
333 }
334 if ($rspan > $max_y - $y + 1) {
335 $cell->set_attribute("RowSpan", $max_y - $y + 1);
336 $rspan = $max_y - $y + 1;
337 }
338
339 // check hidden status
340 if ($this->checkCellHidden($colspans, $rowspans, $x, $y)) {
341 // hidden: set hidden flag, remove col and rowspan
342 $cell->set_attribute("Hidden", "Y");
343 $cspan = 1;
344 $rspan = 1;
345 if ($cell->has_attribute("ColSpan")) {
346 $cell->remove_attribute("ColSpan");
347 }
348 if ($cell->has_attribute("RowSpan")) {
349 $cell->remove_attribute("RowSpan");
350 }
351 $this->makeEmptyCell($cell);
352 } else {
353 // not hidden: remove hidden flag if existing
354 if ($cell->has_attribute("Hidden")) {
355 $cell->remove_attribute("Hidden");
356 }
357 }
358
359 $colspans[$x][$y] = $cspan;
360 $rowspans[$x][$y] = $rspan;
361 }
362 $x++;
363 }
364 $y++;
365 }
366 }
367 }
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 429 of file class.ilPCTable.php.

430 {
431 $classes = array();
432 $rows = $this->tab_node->child_nodes();
433 foreach ($rows as $row) {
434 if ($row->node_name() == "TableRow") {
435 $cells = $row->child_nodes();
436 foreach ($cells as $cell) {
437 if ($cell->node_name() == "TableData") {
438 $classes[$cell->get_attribute("HierId") . ":" . $cell->get_attribute("PCID")]
439 = $cell->get_attribute("HorizontalAlign");
440 }
441 }
442 }
443 }
444
445 return $classes;
446 }

References $rows.

◆ getAllCellClasses()

ilPCTable::getAllCellClasses ( )

Get all cell classes.

Returns
array array of cell style classes

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

406 {
407 $classes = array();
408 $rows = $this->tab_node->child_nodes();
409 foreach ($rows as $row) {
410 if ($row->node_name() == "TableRow") {
411 $cells = $row->child_nodes();
412 foreach ($cells as $cell) {
413 if ($cell->node_name() == "TableData") {
414 $classes[$cell->get_attribute("HierId") . ":" . $cell->get_attribute("PCID")]
415 = $cell->get_attribute("Class");
416 }
417 }
418 }
419 }
420
421 return $classes;
422 }

References $rows.

◆ getAllCellSpans()

ilPCTable::getAllCellSpans ( )

Get all cell spans.

Returns
array array of cell style classes

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

454 {
455 $spans = array();
456 $rows = $this->tab_node->child_nodes();
457 $y = 0;
458 $max_x = 0;
459 $max_y = 0;
460 foreach ($rows as $row) {
461 if ($row->node_name() == "TableRow") {
462 $x = 0;
463 $cells = $row->child_nodes();
464 foreach ($cells as $cell) {
465 if ($cell->node_name() == "TableData") {
466 $spans[$cell->get_attribute("HierId") . ":" . $cell->get_attribute("PCID")]
467 = array("x" => $x, "y" => $y, "colspan" => $cell->get_attribute("ColSpan"),
468 "rowspan" => $cell->get_attribute("RowSpan"));
469 $max_x = max($max_x, $x);
470 $max_y = max($max_y, $y);
471 }
472 $x++;
473 }
474 $y++;
475 }
476 }
477 foreach ($spans as $k => $v) {
478 $spans[$k]["max_x"] = $max_x;
479 $spans[$k]["max_y"] = $max_y;
480 }
481
482 return $spans;
483 }

References $rows.

◆ getAllCellWidths()

ilPCTable::getAllCellWidths ( )

Get all cell widhts.

Returns
array array of cell style classes

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

491 {
492 $widths = array();
493 $rows = $this->tab_node->child_nodes();
494 foreach ($rows as $row) {
495 if ($row->node_name() == "TableRow") {
496 $cells = $row->child_nodes();
497 foreach ($cells as $cell) {
498 if ($cell->node_name() == "TableData") {
499 $widths[$cell->get_attribute("HierId") . ":" . $cell->get_attribute("PCID")]
500 = $cell->get_attribute("Width");
501 }
502 }
503 }
504 }
505
506 return $widths;
507 }

References $rows.

◆ getBorder()

ilPCTable::getBorder ( )

get table border width

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

161 {
162 return $this->getTableAttribute("Border");
163 }
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 558 of file class.ilPCTable.php.

559 {
560 $hier_id = $this->getHierId();
561 if (!empty($hier_id)) {
562 $xpc = xpath_new_context($this->dom);
563 $path = "//PageContent[@HierId = '" . $hier_id . "']/Table/Caption";
564 $res = xpath_eval($xpc, $path);
565
566 if (count($res->nodeset) == 1) {
567 return $res->nodeset[0]->get_content();
568 }
569 }
570 }
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 575 of file class.ilPCTable.php.

576 {
577 $hier_id = $this->getHierId();
578 if (!empty($hier_id)) {
579 $xpc = xpath_new_context($this->dom);
580 $path = "//PageContent[@HierId = '" . $hier_id . "']/Table/Caption";
581 $res = xpath_eval($xpc, $path);
582 if (count($res->nodeset) == 1) {
583 return $res->nodeset[0]->get_attribute("Align");
584 }
585 }
586 }

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

+ Here is the call graph for this function:

◆ getCellPadding()

ilPCTable::getCellPadding ( )

get table cell padding

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

197 {
198 return $this->getTableAttribute("CellPadding");
199 }

References getTableAttribute().

+ Here is the call graph for this function:

◆ getCellSpacing()

ilPCTable::getCellSpacing ( )

get table cell spacing

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

179 {
180 return $this->getTableAttribute("CellSpacing");
181 }

References getTableAttribute().

+ Here is the call graph for this function:

◆ getClass()

ilPCTable::getClass ( )

Get characteristic of section.

Returns
string characteristic

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

784 {
785 return $this->getTableAttribute("Class");
786 }

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

884 {
885 return $this->getTableAttribute("FooterCols");
886 }

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

844 {
845 return $this->getTableAttribute("FooterRows");
846 }

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

864 {
865 return $this->getTableAttribute("HeaderCols");
866 }

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

824 {
825 return $this->getTableAttribute("HeaderRows");
826 }

References getTableAttribute().

+ Here is the call graph for this function:

◆ getHorizontalAlign()

ilPCTable::getHorizontalAlign ( )

get table cell padding

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

223 {
224 return $this->getTableAttribute("HorizontalAlign");
225 }

References getTableAttribute().

+ Here is the call graph for this function:

◆ getLanguage()

ilPCTable::getLanguage ( )

get table language

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

123 {
124 return $this->getTableAttribute("Language");
125 }

References getTableAttribute().

Referenced by ilPCDataTable\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 921 of file class.ilPCTable.php.

922 {
923 return array("ed_insert_dtable", "ed_insert_atable","ed_new_row_after", "ed_new_row_before",
924 "ed_new_col_after", "ed_new_col_before", "ed_delete_col",
925 "ed_delete_row", "ed_edit_data", "ed_row_up", "ed_row_down",
926 "ed_col_left", "ed_col_right");
927 }

◆ getTableAttribute()

ilPCTable::getTableAttribute (   $a_attr)

Get table tag attribute.

Returns
string attribute name

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

911 {
912 if (is_object($this->tab_node)) {
913 return $this->tab_node->get_attribute($a_attr);
914 }
915 }

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

804 {
805 return $this->getTableAttribute("Template");
806 }

References getTableAttribute().

+ Here is the call graph for this function:

◆ getWidth()

ilPCTable::getWidth ( )

get table width

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

143 {
144 return $this->getTableAttribute("Width");
145 }

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

937 {
938 $xpath = new DOMXPath($a_domdoc);
939 $nodes = $xpath->query("//Table");
940 foreach ($nodes as $node) {
941 $node->removeAttribute("Id");
942 }
943 }

References ilPageContent\$node.

◆ importCell()

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

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

674 {
675 /*echo "add Cell";
676 var_dump($cellNode);*/
677 $aCell = $this->addCell($aRow);
678 $par = new ilPCParagraph($this->getPage());
679 $par->createAtNode($aCell);
680 $par->setText($par->input2xml($this->extractText($cellNode)));
681 $par->setCharacteristic("TableContent");
682 $par->setLanguage($lng);
683 $this->importCellAttributes($cellNode, $aCell);
684 }
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 637 of file class.ilPCTable.php.

638 {
639 /*echo "importing table attributes";
640 var_dump($tableNode);*/
641 if ($node->has_attributes()) {
642 foreach ($node->attributes() as $n) {
643 switch (strtolower($n->node_name())) {
644 case "class":
645 $par->set_attribute("Class", $this->extractText($n));
646 break;
647 case "width":
648 $par->set_attribute("Width", $this->extractText($n));
649 break;
650 }
651 }
652 }
653 }
$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 698 of file class.ilPCTable.php.

699 {
700 $dummy = ilUtil::stripSlashes($htmlTable, false);
701 //echo htmlentities($dummy);
702 $dom = @domxml_open_mem($dummy, DOMXML_LOAD_PARSING, $error);
703
704 if ($dom) {
705 $xpc = @xpath_new_context($dom);
706 // extract first table object
707 $path = "//table[1] | //Table[1]";
708 $res = @xpath_eval($xpc, $path);
709
710 if (count($res->nodeset) == 0) {
711 $error = "Could not find a table root node";
712 }
713
714 if (empty($error)) {
715 for ($i = 0; $i < count($res->nodeset); $i++) {
716 $node = $res->nodeset[$i];
717
719
720 if ($node->has_child_nodes()) {
721 foreach ($node->child_nodes() as $n) {
722 if ($n->node_type() == XML_ELEMENT_NODE &&
723 strcasecmp($n->node_name(), "tr") == 0) {
724 $this->importRow($lng, $n);
725 }
726 }
727 }
728 }
729 }
730 $dom->free();
731 }
732 if (is_array($error)) {
733 $errmsg = "";
734 foreach ($error as $errorline) { # Loop through all errors
735 $errmsg .= "[" . $errorline['line'] . ", " . $errorline['col'] . "]: " . $errorline['errormessage'] . " at Node '" . $errorline['nodename'] . "'<br />";
736 }
737 } else {
738 $errmsg = $error;
739 }
740
741 if (empty($errmsg)) {
742 return true;
743 }
744
745 $_SESSION["message"] = $errmsg;
746 return false;
747 }
$_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 656 of file class.ilPCTable.php.

657 {
658 /*echo "add Row";
659 var_dump($node);*/
660
661 $aRow = $this->addRow();
662
663 if ($node->has_child_nodes()) {
664 foreach ($node->child_nodes() as $n) {
665 if ($n->node_type() == XML_ELEMENT_NODE &&
666 strcasecmp($n->node_name(), "td") == 0) {
667 $this->importCell($lng, $n, $aRow);
668 }
669 }
670 }
671 }
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 88 of file class.ilPCTable.php.

89 {
90 str_replace($a_data, "\r", "\n");
91 str_replace($a_data, "\n\n", "\n");
92 $target_rows = array();
93 $rows = explode("\n", $a_data);
94
95 // get maximum of cols in a row and
96 // put data in target_row arrays
97 foreach ($rows as $row) {
98 $cells = explode("\t", $row);
99 $max_cols = ($max_cols > count($cells))
100 ? $max_cols
101 : count($cells);
102 $target_rows[] = $cells;
103 }
104
105 // iterate target row arrays and insert data
106 foreach ($target_rows as $row) {
107 $aRow = $this->addRow();
108 for ($j = 0; $j < $max_cols; $j++) {
109 // mask html
110 $data = str_replace("&", "&amp;", $row[$j]);
111 $data = str_replace("<", "&lt;", $data);
112 $data = str_replace(">", "&gt;", $data);
113
114 $this->addCell($aRow, $data, $a_lang);
115 }
116 }
117 }
$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 608 of file class.ilPCTable.php.

609 {
610 /*echo "importing table attributes";
611 var_dump($tableNode);*/
612 if ($node->has_attributes()) {
613 foreach ($node->attributes() as $n) {
614 switch (strtolower($n->node_name())) {
615 case "border":
616 $this->setBorder($this->extractText($n));
617 break;
618 case "align":
619 $this->setHorizontalAlign(ucfirst(strtolower($this->extractText($n))));
620 break;
621 case "cellspacing":
622 $this->setCellSpacing($this->extractText($n));
623 break;
624 case "cellpadding":
625 $this->setCellPadding($this->extractText($n));
626 break;
627 case "width":
628 $this->setWidth($this->extractText($n));
629 break;
630
631 }
632 }
633 }
634 }
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 373 of file class.ilPCTable.php.

374 {
375 // delete children of paragraph node
376 $children = $td_node->child_nodes();
377 for ($i = 0; $i < count($children); $i++) {
378 $td_node->remove_child($children[$i]);
379 }
380 }

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

171 {
172 $this->setTableAttribute("Border", $a_border);
173 }
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 591 of file class.ilPCTable.php.

592 {
593 if ($a_content != "") {
595 $this->dom,
596 $this->tab_node,
597 "Caption",
598 array("Summary", "TableRow"),
600 array("Align" => $a_align)
601 );
602 } else {
603 ilDOMUtil::deleteAllChildsByName($this->tab_node, array("Caption"));
604 }
605 }
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
$a_content
Definition: workflow.php:93

References $a_content, 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 206 of file class.ilPCTable.php.

207 {
208 $this->setTableAttribute("CellPadding", $a_padding);
209 }

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

189 {
190 $this->setTableAttribute("CellSpacing", $a_spacing);
191 }

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

774 {
775 $this->setTableAttribute("Class", $a_class);
776 }

References setTableAttribute().

+ Here is the call graph for this function:

◆ setFirstRowStyle()

ilPCTable::setFirstRowStyle (   $a_class)

Set first row td style.

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

753 {
754 $childs = $this->tab_node->child_nodes();
755 foreach ($childs as $child) {
756 if ($child->node_name() == "TableRow") {
757 $gchilds = $child->child_nodes();
758 foreach ($gchilds as $gchild) {
759 if ($gchild->node_name() == "TableData") {
760 $gchild->set_attribute("Class", $a_class);
761 }
762 }
763 return;
764 }
765 }
766 }

◆ setFooterCols()

ilPCTable::setFooterCols (   $a_nr)

Set footer cols.

Parameters
stringnumber of footer cols

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

874 {
875 $this->setTableAttribute("FooterCols", $a_nr);
876 }

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

834 {
835 $this->setTableAttribute("FooterRows", $a_nr);
836 }

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

854 {
855 $this->setTableAttribute("HeaderCols", $a_nr);
856 }

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

814 {
815 $this->setTableAttribute("HeaderRows", $a_nr);
816 }

References setTableAttribute().

+ Here is the call graph for this function:

◆ setHorizontalAlign()

ilPCTable::setHorizontalAlign (   $a_halign)

set horizontal align

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

215 {
216 $this->tab_node->set_attribute("HorizontalAlign", $a_halign);
217 }

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

133 {
134 if ($a_lang != "") {
135 $this->setTableAttribute("Language", $a_lang);
136 }
137 }

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

895 {
896 if (!empty($a_value)) {
897 $this->tab_node->set_attribute($a_attr, $a_value);
898 } else {
899 if ($this->tab_node->has_attribute($a_attr)) {
900 $this->tab_node->remove_attribute($a_attr);
901 }
902 }
903 }

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

536 {
537 $xpc = xpath_new_context($this->dom);
538 if ($a_pc_id == "") {
539 $path = "//TableData[@HierId = '" . $a_hier_id . "']";
540 } else {
541 $path = "//TableData[@PCID = '" . $a_pc_id . "']";
542 }
543 $res = xpath_eval($xpc, $path);
544 if (count($res->nodeset) == 1) {
545 if ($a_class != "") {
546 $res->nodeset[0]->set_attribute("HorizontalAlign", $a_class);
547 } else {
548 if ($res->nodeset[0]->has_attribute("HorizontalAlign")) {
549 $res->nodeset[0]->remove_attribute("HorizontalAlign");
550 }
551 }
552 }
553 }

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

513 {
514 $xpc = xpath_new_context($this->dom);
515 if ($a_pc_id == "") {
516 $path = "//TableData[@HierId = '" . $a_hier_id . "']";
517 } else {
518 $path = "//TableData[@PCID = '" . $a_pc_id . "']";
519 }
520 $res = xpath_eval($xpc, $path);
521 if (count($res->nodeset) == 1) {
522 if ($a_class != "") {
523 $res->nodeset[0]->set_attribute("Class", $a_class);
524 } else {
525 if ($res->nodeset[0]->has_attribute("Class")) {
526 $res->nodeset[0]->remove_attribute("Class");
527 }
528 }
529 }
530 }

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

256 {
257 $y = 0;
258 $rows = $this->tab_node->child_nodes();
259 foreach ($rows as $row) {
260 if ($row->node_name() == "TableRow") {
261 $x = 0;
262 $cells = $row->child_nodes();
263 foreach ($cells as $cell) {
264 if ($cell->node_name() == "TableData") {
265 $ckey = $cell->get_attribute("HierId") . ":" . $cell->get_attribute("PCID");
266 if ((int) $a_colspans[$ckey] > 1) {
267 $cell->set_attribute("ColSpan", (int) $a_colspans[$ckey]);
268 } else {
269 if ($cell->has_attribute("ColSpan")) {
270 $cell->remove_attribute("ColSpan");
271 }
272 }
273 if ((int) $a_rowspans[$ckey] > 1) {
274 $cell->set_attribute("RowSpan", (int) $a_rowspans[$ckey]);
275 } else {
276 if ($cell->has_attribute("RowSpan")) {
277 $cell->remove_attribute("RowSpan");
278 }
279 }
280 }
281 $x++;
282 }
283 $y++;
284 }
285 }
286 $this->fixHideAndSpans();
287 }
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 230 of file class.ilPCTable.php.

231 {
232 $xpc = xpath_new_context($this->dom);
233
234 if ($a_pc_id == "") {
235 $path = "//TableData[@HierId = '" . $a_hier_id . "']";
236 } else {
237 $path = "//TableData[@PCID = '" . $a_pc_id . "']";
238 }
239 $res = xpath_eval($xpc, $path);
240
241 if (count($res->nodeset) == 1) {
242 if ($a_width != "") {
243 $res->nodeset[0]->set_attribute("Width", $a_width);
244 } else {
245 if ($res->nodeset[0]->has_attribute("Width")) {
246 $res->nodeset[0]->remove_attribute("Width");
247 }
248 }
249 }
250 }

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

794 {
795 $this->setTableAttribute("Template", $a_template);
796 }

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

153 {
154 $this->setTableAttribute("Width", $a_width);
155 }

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: