ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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)
 
 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...
 
 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)
 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
 $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 52 of file class.ilPCTable.php.

References ilPageContent\createPageContentNode().

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

53  {
54  $new_td = $this->dom->create_element("TableData");
55  $new_td = $aRow->append_child($new_td);
56 
57  // insert data if given
58  if ($a_data != "")
59  {
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) ...
+ 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.

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

46  {
47  $new_tr = $this->dom->create_element("TableRow");
48  $new_tr = &$this->tab_node->append_child($new_tr);
49  return $new_tr;
50  }
+ 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.

References addCell(), and addRow().

76  {
77  for ($i=1; $i<=$a_nr_rows; $i++)
78  {
79  $aRow = $this->addRow();
80  for ($j=1; $j<=$a_nr_cols; $j++)
81  {
82  $this->addCell($aRow);
83  }
84  }
85  }
& addCell(&$aRow, $a_data="", $a_lang="")
+ Here is the call graph for this function:

◆ checkCellHidden()

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

Check hidden status.

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

References $x, and $y.

Referenced by fixHideAndSpans().

430  {
431  for ($i = 0; $i<=$x; $i++)
432  {
433  for ($j = 0; $j<=$y; $j++)
434  {
435  if ($i != $x || $j != $y)
436  {
437  if ((($i + $colspans[$i][$j] > $x) &&
438  ($j + $rowspans[$i][$j] > $y)))
439  {
440  return true;
441  }
442  }
443  }
444  }
445  return false;
446  }
$x
Definition: example_009.php:98
$y
Definition: example_007.php:83
+ Here is the caller graph for this function:

◆ create()

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

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

References ilPageContent\createPageContentNode(), and IL_INSERT_AFTER.

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
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
+ Here is the call graph for this function:

◆ extractText()

ilPCTable::extractText ( $node)

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

References ilPageContent\$node, and $output.

Referenced by importCellAttributes(), and importTableAttributes().

776  {
777  $owner_document = $node->owner_document ();
778  $children = $node->child_nodes();
779  $total_children = count($children);
780  for ($i = 0; $i < $total_children; $i++){
781  $cur_child_node = $children[$i];
782  $output .= $owner_document->dump_node($cur_child_node);
783  }
784  return $output;
785  }
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
+ 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 320 of file class.ilPCTable.php.

References $row, $x, $y, checkCellHidden(), and makeEmptyCell().

Referenced by setTDSpans().

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

References $row, and array.

482  {
483  $classes = array();
484  $rows = $this->tab_node->child_nodes();
485  foreach($rows as $row)
486  {
487  if ($row->node_name() == "TableRow")
488  {
489  $cells = $row->child_nodes();
490  foreach($cells as $cell)
491  {
492  if ($cell->node_name() == "TableData")
493  {
494  $classes[$cell->get_attribute("HierId").":".$cell->get_attribute("PCID")]
495  = $cell->get_attribute("HorizontalAlign");
496  }
497  }
498  }
499  }
500 
501  return $classes;
502  }
Create styles array
The data for the language used.

◆ getAllCellClasses()

ilPCTable::getAllCellClasses ( )

Get all cell classes.

Returns
array array of cell style classes

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

References $row, and array.

454  {
455  $classes = array();
456  $rows = $this->tab_node->child_nodes();
457  foreach($rows as $row)
458  {
459  if ($row->node_name() == "TableRow")
460  {
461  $cells = $row->child_nodes();
462  foreach($cells as $cell)
463  {
464  if ($cell->node_name() == "TableData")
465  {
466  $classes[$cell->get_attribute("HierId").":".$cell->get_attribute("PCID")]
467  = $cell->get_attribute("Class");
468  }
469  }
470  }
471  }
472 
473  return $classes;
474  }
Create styles array
The data for the language used.

◆ getAllCellSpans()

ilPCTable::getAllCellSpans ( )

Get all cell spans.

Returns
array array of cell style classes

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

References $row, $x, $y, and array.

510  {
511  $spans = array();
512  $rows = $this->tab_node->child_nodes();
513  $y = 0;
514  $max_x = 0;
515  $max_y = 0;
516  foreach($rows as $row)
517  {
518  if ($row->node_name() == "TableRow")
519  {
520  $x = 0;
521  $cells = $row->child_nodes();
522  foreach($cells as $cell)
523  {
524  if ($cell->node_name() == "TableData")
525  {
526  $spans[$cell->get_attribute("HierId").":".$cell->get_attribute("PCID")]
527  = array("x" => $x, "y" => $y, "colspan" => $cell->get_attribute("ColSpan"),
528  "rowspan" => $cell->get_attribute("RowSpan"));
529  $max_x = max($max_x, $x);
530  $max_y = max($max_y, $y);
531  }
532  $x++;
533  }
534  $y++;
535  }
536  }
537  foreach ($spans as $k => $v)
538  {
539  $spans[$k]["max_x"] = $max_x;
540  $spans[$k]["max_y"] = $max_y;
541  }
542 
543  return $spans;
544  }
$x
Definition: example_009.php:98
$y
Definition: example_007.php:83
Create styles array
The data for the language used.

◆ getAllCellWidths()

ilPCTable::getAllCellWidths ( )

Get all cell widhts.

Returns
array array of cell style classes

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

References $row, and array.

552  {
553  $widths = array();
554  $rows = $this->tab_node->child_nodes();
555  foreach($rows as $row)
556  {
557  if ($row->node_name() == "TableRow")
558  {
559  $cells = $row->child_nodes();
560  foreach($cells as $cell)
561  {
562  if ($cell->node_name() == "TableData")
563  {
564  $widths[$cell->get_attribute("HierId").":".$cell->get_attribute("PCID")]
565  = $cell->get_attribute("Width");
566  }
567  }
568  }
569  }
570 
571  return $widths;
572  }
Create styles array
The data for the language used.

◆ getBorder()

ilPCTable::getBorder ( )

get table border width

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

References getTableAttribute().

167  {
168  return $this->getTableAttribute("Border");
169  }
getTableAttribute($a_attr)
Get table tag attribute.
+ Here is the call graph for this function:

◆ getCaption()

ilPCTable::getCaption ( )

get caption

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

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

640  {
641  $hier_id = $this->getHierId();
642  if(!empty($hier_id))
643  {
644  $xpc = xpath_new_context($this->dom);
645  $path = "//PageContent[@HierId = '".$hier_id."']/Table/Caption";
646  $res = xpath_eval($xpc, $path);
647 
648  if (count($res->nodeset) == 1)
649  {
650  return $res->nodeset[0]->get_content();
651  }
652  }
653  }
$path
Definition: aliased.php:25
xpath_new_context($dom_document)
xpath_eval($xpath_context, $eval_str, $contextnode=null)
getHierId()
Get hierarchical id.
+ Here is the call graph for this function:

◆ getCaptionAlign()

ilPCTable::getCaptionAlign ( )

get caption alignment (Top | Bottom)

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

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

659  {
660  $hier_id = $this->getHierId();
661  if(!empty($hier_id))
662  {
663  $xpc = xpath_new_context($this->dom);
664  $path = "//PageContent[@HierId = '".$hier_id."']/Table/Caption";
665  $res = xpath_eval($xpc, $path);
666  if (count($res->nodeset) == 1)
667  {
668  return $res->nodeset[0]->get_attribute("Align");
669  }
670  }
671  }
$path
Definition: aliased.php:25
xpath_new_context($dom_document)
xpath_eval($xpath_context, $eval_str, $contextnode=null)
getHierId()
Get hierarchical id.
+ Here is the call graph for this function:

◆ getCellPadding()

ilPCTable::getCellPadding ( )

get table cell padding

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

References getTableAttribute().

203  {
204  return $this->getTableAttribute("CellPadding");
205  }
getTableAttribute($a_attr)
Get table tag attribute.
+ Here is the call graph for this function:

◆ getCellSpacing()

ilPCTable::getCellSpacing ( )

get table cell spacing

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

References getTableAttribute().

185  {
186  return $this->getTableAttribute("CellSpacing");
187  }
getTableAttribute($a_attr)
Get table tag attribute.
+ Here is the call graph for this function:

◆ getClass()

ilPCTable::getClass ( )

Get characteristic of section.

Returns
string characteristic

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

References getTableAttribute().

885  {
886  return $this->getTableAttribute("Class");
887  }
getTableAttribute($a_attr)
Get table tag attribute.
+ Here is the call graph for this function:

◆ getFooterCols()

ilPCTable::getFooterCols ( )

Get footer cols.

Returns
string number of footer cols

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

References getTableAttribute().

985  {
986  return $this->getTableAttribute("FooterCols");
987  }
getTableAttribute($a_attr)
Get table tag attribute.
+ Here is the call graph for this function:

◆ getFooterRows()

ilPCTable::getFooterRows ( )

Get footer rows.

Returns
string number of footer rows

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

References getTableAttribute().

945  {
946  return $this->getTableAttribute("FooterRows");
947  }
getTableAttribute($a_attr)
Get table tag attribute.
+ Here is the call graph for this function:

◆ getHeaderCols()

ilPCTable::getHeaderCols ( )

Get header cols.

Returns
string number of header cols

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

References getTableAttribute().

965  {
966  return $this->getTableAttribute("HeaderCols");
967  }
getTableAttribute($a_attr)
Get table tag attribute.
+ Here is the call graph for this function:

◆ getHeaderRows()

ilPCTable::getHeaderRows ( )

Get header rows.

Returns
string number of header rows

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

References getTableAttribute().

925  {
926  return $this->getTableAttribute("HeaderRows");
927  }
getTableAttribute($a_attr)
Get table tag attribute.
+ Here is the call graph for this function:

◆ getHorizontalAlign()

ilPCTable::getHorizontalAlign ( )

get table cell padding

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

References getTableAttribute().

229  {
230  return $this->getTableAttribute("HorizontalAlign");
231  }
getTableAttribute($a_attr)
Get table tag attribute.
+ Here is the call graph for this function:

◆ getLanguage()

ilPCTable::getLanguage ( )

get table language

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

References getTableAttribute().

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

128  {
129  return $this->getTableAttribute("Language");
130  }
getTableAttribute($a_attr)
Get table tag attribute.
+ 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

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

References array.

1028  {
1029  return array("ed_insert_dtable", "ed_insert_atable","ed_new_row_after", "ed_new_row_before",
1030  "ed_new_col_after", "ed_new_col_before", "ed_delete_col",
1031  "ed_delete_row", "ed_edit_data", "ed_row_up", "ed_row_down",
1032  "ed_col_left", "ed_col_right");
1033  }
Create styles array
The data for the language used.

◆ getTableAttribute()

ilPCTable::getTableAttribute (   $a_attr)

Get table tag attribute.

Returns
string attribute name

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

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

1016  {
1017  if (is_object($this->tab_node))
1018  {
1019  return $this->tab_node->get_attribute($a_attr);
1020  }
1021  }
+ Here is the caller graph for this function:

◆ getTemplate()

ilPCTable::getTemplate ( )

Get template.

Returns
string template

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

References getTableAttribute().

905  {
906  return $this->getTableAttribute("Template");
907  }
getTableAttribute($a_attr)
Get table tag attribute.
+ Here is the call graph for this function:

◆ getWidth()

ilPCTable::getWidth ( )

get table width

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

References getTableAttribute().

149  {
150  return $this->getTableAttribute("Width");
151  }
getTableAttribute($a_attr)
Get table tag attribute.
+ 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

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

References ilPageContent\$node.

1043  {
1044  $xpath = new DOMXPath($a_domdoc);
1045  $nodes = $xpath->query("//Table");
1046  foreach($nodes as $node)
1047  {
1048  $node->removeAttribute("Id");
1049  }
1050  }

◆ importCell()

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

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

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

Referenced by importRow().

764  {
765  /*echo "add Cell";
766  var_dump($cellNode);*/
767  $aCell = $this->addCell($aRow);
768  $par = new ilPCParagraph($this->getPage());
769  $par->createAtNode($aCell);
770  $par->setText($par->input2xml($this->extractText($cellNode)));
771  $par->setCharacteristic("TableContent");
772  $par->setLanguage($lng);
773  $this->importCellAttributes($cellNode, $aCell);
774  }
Class ilPCParagraph.
importCellAttributes(&$node, &$par)
& addCell(&$aRow, $a_data="", $a_lang="")
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importCellAttributes()

ilPCTable::importCellAttributes ( $node,
$par 
)

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

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

Referenced by importCell().

723  {
724  /*echo "importing table attributes";
725  var_dump($tableNode);*/
726  if ($node->has_attributes ())
727  {
728  foreach($node->attributes() as $n)
729  {
730 
731  switch (strtolower($n->node_name ())) {
732  case "class":
733  $par->set_attribute("Class", $this->extractText($n));
734  break;
735  case "width":
736  $par->set_attribute("Width", $this->extractText($n));
737  break;
738  }
739 
740  }
741  }
742  }
extractText(&$node)
$n
Definition: RandomTest.php:80
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importHtml()

ilPCTable::importHtml (   $lng,
  $htmlTable 
)

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

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

787  {
788  $dummy = ilUtil::stripSlashes($htmlTable, false);
789  //echo htmlentities($dummy);
790  $dom = @domxml_open_mem($dummy,DOMXML_LOAD_PARSING, $error);
791 
792  if ($dom)
793  {
794  $xpc = @xpath_new_context($dom);
795  // extract first table object
796  $path = "//table[1] | //Table[1]";
797  $res = @xpath_eval($xpc, $path);
798 
799  if (count($res->nodeset) == 0)
800  {
801  $error = "Could not find a table root node";
802  }
803 
804  if (empty ($error))
805  {
806  for($i = 0; $i < count($res->nodeset); $i++)
807  {
808  $node = $res->nodeset[$i];
809 
810  $this->importTableAttributes ($node);
811 
812  if ($node->has_child_nodes())
813  {
814  foreach($node->child_nodes() as $n)
815  {
816  if ($n->node_type() == XML_ELEMENT_NODE &&
817  strcasecmp($n->node_name (), "tr") == 0)
818  {
819 
820  $this->importRow ($lng, $n);
821  }
822  }
823  }
824  }
825  }
826  $dom->free ();
827  }
828  if (is_array($error)) {
829  $errmsg = "";
830  foreach ($error as $errorline) { # Loop through all errors
831  $errmsg .= "[" . $errorline['line'] . ", " . $errorline['col'] . "]: ".$errorline['errormessage']." at Node '". $errorline['nodename'] . "'<br />";
832  }
833  }else
834  {
835  $errmsg = $error;
836  }
837 
838  if (empty ($errmsg)) {
839  return true;
840  }
841 
842  $_SESSION["message"] = $errmsg;
843  return false;
844  }
$error
Definition: Error.php:17
$path
Definition: aliased.php:25
$_SESSION["AccountId"]
xpath_new_context($dom_document)
xpath_eval($xpath_context, $eval_str, $contextnode=null)
importRow($lng, &$node)
$n
Definition: RandomTest.php:80
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
importTableAttributes(&$node)
global $lng
Definition: privfeed.php:17
domxml_open_mem($str, $mode=0, &$error=NULL)
+ Here is the call graph for this function:

◆ importRow()

ilPCTable::importRow (   $lng,
$node 
)

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

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

Referenced by importHtml().

745  {
746  /*echo "add Row";
747  var_dump($node);*/
748 
749  $aRow = $this->addRow();
750 
751  if ($node->has_child_nodes())
752  {
753  foreach($node->child_nodes() as $n)
754  {
755  if ($n->node_type() == XML_ELEMENT_NODE &&
756  strcasecmp($n->node_name (), "td") == 0)
757  {
758  $this->importCell ($lng, $n, $aRow);
759  }
760  }
761  }
762  }
importCell($lng, &$cellNode, &$aRow)
$n
Definition: RandomTest.php:80
global $lng
Definition: privfeed.php:17
+ 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 90 of file class.ilPCTable.php.

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

91  {
92  str_replace($a_data, "\r", "\n");
93  str_replace($a_data, "\n\n", "\n");
94  $target_rows = array();
95  $rows = explode("\n", $a_data);
96 
97  // get maximum of cols in a row and
98  // put data in target_row arrays
99  foreach($rows as $row)
100  {
101  $cells = explode("\t", $row);
102  $max_cols = ($max_cols > count($cells))
103  ? $max_cols
104  : count($cells);
105  $target_rows[] = $cells;
106  }
107 
108  // iterate target row arrays and insert data
109  foreach($target_rows as $row)
110  {
111  $aRow = $this->addRow();
112  for ($j=0; $j<$max_cols; $j++)
113  {
114  // mask html
115  $data = str_replace("&","&amp;", $row[$j]);
116  $data = str_replace("<","&lt;", $data);
117  $data = str_replace(">","&gt;", $data);
118 
119  $this->addCell($aRow, $data, $a_lang);
120  }
121  }
122  }
& addCell(&$aRow, $a_data="", $a_lang="")
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ importTableAttributes()

ilPCTable::importTableAttributes ( $node)

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

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

Referenced by importHtml().

691  {
692  /*echo "importing table attributes";
693  var_dump($tableNode);*/
694  if ($node->has_attributes ())
695  {
696  foreach($node->attributes() as $n)
697  {
698 
699  switch (strtolower($n->node_name ())) {
700  case "border":
701  $this->setBorder ($this->extractText($n));
702  break;
703  case "align":
704  $this->setHorizontalAlign(ucfirst(strtolower($this->extractText($n))));
705  break;
706  case "cellspacing":
707  $this->setCellSpacing($this->extractText($n));
708  break;
709  case "cellpadding":
710  $this->setCellPadding($this->extractText($n));
711  break;
712  case "width":
713  $this->setWidth($this->extractText($n));
714  break;
715 
716  }
717 
718  }
719  }
720  }
extractText(&$node)
setHorizontalAlign($a_halign)
set horizontal align
setCellSpacing($a_spacing)
set table cell spacing
setWidth($a_width)
set table width
$n
Definition: RandomTest.php:80
setBorder($a_border)
set table border
setCellPadding($a_padding)
set table cell padding
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

ilPCTable::init ( )

Init page content component.

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

References ilPageContent\setType().

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

◆ makeEmptyCell()

ilPCTable::makeEmptyCell (   $td_node)

Make cell empty.

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

Referenced by fixHideAndSpans().

417  {
418  // delete children of paragraph node
419  $children = $td_node->child_nodes();
420  for($i=0; $i<count($children); $i++)
421  {
422  $td_node->remove_child($children[$i]);
423  }
424  }
+ Here is the caller graph for this function:

◆ setBorder()

ilPCTable::setBorder (   $a_border)

set table border

Parameters
string$a_bordertable border

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

References setTableAttribute().

Referenced by importTableAttributes().

177  {
178  $this->setTableAttribute("Border", $a_border);
179  }
setTableAttribute($a_attr, $a_value)
Set attribute of table tag.
+ 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 676 of file class.ilPCTable.php.

References $a_content, array, ilDOMUtil\deleteAllChildsByName(), and ilDOMUtil\setFirstOptionalElement().

677  {
678  if ($a_content != "")
679  {
680  ilDOMUtil::setFirstOptionalElement($this->dom, $this->tab_node, "Caption",
681  array("Summary", "TableRow"), $a_content,
682  array("Align" => $a_align));
683  }
684  else
685  {
686  ilDOMUtil::deleteAllChildsByName($this->tab_node, array("Caption"));
687  }
688  }
static deleteAllChildsByName($a_parent, $a_node_names)
delete all childs of a node by names in $a_node_names
$a_content
Definition: workflow.php:94
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...
Create styles array
The data for the language used.
+ 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 212 of file class.ilPCTable.php.

References setTableAttribute().

Referenced by importTableAttributes().

213  {
214  $this->setTableAttribute("CellPadding", $a_padding);
215  }
setTableAttribute($a_attr, $a_value)
Set attribute of table tag.
+ 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 194 of file class.ilPCTable.php.

References setTableAttribute().

Referenced by importTableAttributes().

195  {
196  $this->setTableAttribute("CellSpacing", $a_spacing);
197  }
setTableAttribute($a_attr, $a_value)
Set attribute of table tag.
+ 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 874 of file class.ilPCTable.php.

References setTableAttribute().

875  {
876  $this->setTableAttribute("Class", $a_class);
877  }
setTableAttribute($a_attr, $a_value)
Set attribute of table tag.
+ Here is the call graph for this function:

◆ setFirstRowStyle()

ilPCTable::setFirstRowStyle (   $a_class)

Set first row td style.

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

850  {
851  $childs = $this->tab_node->child_nodes();
852  foreach($childs as $child)
853  {
854  if ($child->node_name() == "TableRow")
855  {
856  $gchilds = $child->child_nodes();
857  foreach($gchilds as $gchild)
858  {
859  if ($gchild->node_name() == "TableData")
860  {
861  $gchild->set_attribute("Class", $a_class);
862  }
863  }
864  return;
865  }
866  }
867  }

◆ setFooterCols()

ilPCTable::setFooterCols (   $a_nr)

Set footer cols.

Parameters
stringnumber of footer cols

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

References setTableAttribute().

975  {
976  $this->setTableAttribute("FooterCols", $a_nr);
977  }
setTableAttribute($a_attr, $a_value)
Set attribute of table tag.
+ Here is the call graph for this function:

◆ setFooterRows()

ilPCTable::setFooterRows (   $a_nr)

Set footer rows.

Parameters
stringnumber of footer rows

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

References setTableAttribute().

935  {
936  $this->setTableAttribute("FooterRows", $a_nr);
937  }
setTableAttribute($a_attr, $a_value)
Set attribute of table tag.
+ Here is the call graph for this function:

◆ setHeaderCols()

ilPCTable::setHeaderCols (   $a_nr)

Set header cols.

Parameters
stringnumber of header cols

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

References setTableAttribute().

955  {
956  $this->setTableAttribute("HeaderCols", $a_nr);
957  }
setTableAttribute($a_attr, $a_value)
Set attribute of table tag.
+ Here is the call graph for this function:

◆ setHeaderRows()

ilPCTable::setHeaderRows (   $a_nr)

Set header rows.

Parameters
stringnumber of header rows

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

References setTableAttribute().

915  {
916  $this->setTableAttribute("HeaderRows", $a_nr);
917  }
setTableAttribute($a_attr, $a_value)
Set attribute of table tag.
+ Here is the call graph for this function:

◆ setHorizontalAlign()

ilPCTable::setHorizontalAlign (   $a_halign)

set horizontal align

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

Referenced by importTableAttributes().

221  {
222  $this->tab_node->set_attribute("HorizontalAlign", $a_halign);
223  }
+ Here is the caller graph for this function:

◆ setLanguage()

ilPCTable::setLanguage (   $a_lang)

set table language

Parameters
string$a_langlanguage code

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

References setTableAttribute().

138  {
139  if($a_lang != "")
140  {
141  $this->setTableAttribute("Language", $a_lang);
142  }
143  }
setTableAttribute($a_attr, $a_value)
Set attribute of table tag.
+ Here is the call graph for this function:

◆ setNode()

ilPCTable::setNode (   $a_node)

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

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

996  {
997  if (!empty($a_value))
998  {
999  $this->tab_node->set_attribute($a_attr, $a_value);
1000  }
1001  else
1002  {
1003  if ($this->tab_node->has_attribute($a_attr))
1004  {
1005  $this->tab_node->remove_attribute($a_attr);
1006  }
1007  }
1008  }
+ 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 608 of file class.ilPCTable.php.

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

609  {
610  $xpc = xpath_new_context($this->dom);
611  if ($a_pc_id == "")
612  {
613  $path = "//TableData[@HierId = '".$a_hier_id."']";
614  }
615  else
616  {
617  $path = "//TableData[@PCID = '".$a_pc_id."']";
618  }
619  $res = xpath_eval($xpc, $path);
620  if (count($res->nodeset) == 1)
621  {
622  if($a_class != "")
623  {
624  $res->nodeset[0]->set_attribute("HorizontalAlign", $a_class);
625  }
626  else
627  {
628  if ($res->nodeset[0]->has_attribute("HorizontalAlign"))
629  {
630  $res->nodeset[0]->remove_attribute("HorizontalAlign");
631  }
632  }
633  }
634  }
$path
Definition: aliased.php:25
xpath_new_context($dom_document)
xpath_eval($xpath_context, $eval_str, $contextnode=null)
+ 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 577 of file class.ilPCTable.php.

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

578  {
579  $xpc = xpath_new_context($this->dom);
580  if ($a_pc_id == "")
581  {
582  $path = "//TableData[@HierId = '".$a_hier_id."']";
583  }
584  else
585  {
586  $path = "//TableData[@PCID = '".$a_pc_id."']";
587  }
588  $res = xpath_eval($xpc, $path);
589  if (count($res->nodeset) == 1)
590  {
591  if($a_class != "")
592  {
593  $res->nodeset[0]->set_attribute("Class", $a_class);
594  }
595  else
596  {
597  if ($res->nodeset[0]->has_attribute("Class"))
598  {
599  $res->nodeset[0]->remove_attribute("Class");
600  }
601  }
602  }
603  }
$path
Definition: aliased.php:25
xpath_new_context($dom_document)
xpath_eval($xpath_context, $eval_str, $contextnode=null)
+ Here is the call graph for this function:

◆ setTDSpans()

ilPCTable::setTDSpans (   $a_colspans,
  $a_rowspans 
)

Set TDSpans.

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

References $row, $x, $y, and fixHideAndSpans().

270  {
271  $y = 0;
272  $rows = $this->tab_node->child_nodes();
273  foreach($rows as $row)
274  {
275  if ($row->node_name() == "TableRow")
276  {
277  $x = 0;
278  $cells = $row->child_nodes();
279  foreach($cells as $cell)
280  {
281  if ($cell->node_name() == "TableData")
282  {
283  $ckey = $cell->get_attribute("HierId").":".$cell->get_attribute("PCID");
284  if((int) $a_colspans[$ckey] > 1)
285  {
286  $cell->set_attribute("ColSpan", (int) $a_colspans[$ckey]);
287  }
288  else
289  {
290  if ($cell->has_attribute("ColSpan"))
291  {
292  $cell->remove_attribute("ColSpan");
293  }
294  }
295  if((int) $a_rowspans[$ckey] > 1)
296  {
297  $cell->set_attribute("RowSpan", (int) $a_rowspans[$ckey]);
298  }
299  else
300  {
301  if ($cell->has_attribute("RowSpan"))
302  {
303  $cell->remove_attribute("RowSpan");
304  }
305  }
306  }
307  $x++;
308  }
309  $y++;
310  }
311  }
312  $this->fixHideAndSpans();
313  }
$x
Definition: example_009.php:98
$y
Definition: example_007.php:83
fixHideAndSpans()
Fix Hide and Spans.
+ 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 236 of file class.ilPCTable.php.

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

237  {
238  $xpc = xpath_new_context($this->dom);
239 
240  if ($a_pc_id == "")
241  {
242  $path = "//TableData[@HierId = '".$a_hier_id."']";
243  }
244  else
245  {
246  $path = "//TableData[@PCID = '".$a_pc_id."']";
247  }
248  $res = xpath_eval($xpc, $path);
249 
250  if (count($res->nodeset) == 1)
251  {
252  if($a_width != "")
253  {
254  $res->nodeset[0]->set_attribute("Width", $a_width);
255  }
256  else
257  {
258  if ($res->nodeset[0]->has_attribute("Width"))
259  {
260  $res->nodeset[0]->remove_attribute("Width");
261  }
262  }
263  }
264  }
$path
Definition: aliased.php:25
xpath_new_context($dom_document)
xpath_eval($xpath_context, $eval_str, $contextnode=null)
+ Here is the call graph for this function:

◆ setTemplate()

ilPCTable::setTemplate (   $a_template)

Set template.

Parameters
string$a_templatetemplate

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

References setTableAttribute().

895  {
896  $this->setTableAttribute("Template", $a_template);
897  }
setTableAttribute($a_attr, $a_value)
Set attribute of table tag.
+ Here is the call graph for this function:

◆ setWidth()

ilPCTable::setWidth (   $a_width)

set table width

Parameters
string$a_widthtable width

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

References setTableAttribute().

Referenced by importTableAttributes().

159  {
160  $this->setTableAttribute("Width", $a_width);
161  }
setTableAttribute($a_attr, $a_value)
Set attribute of table tag.
+ 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.

◆ $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: