ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilPCDataTable Class Reference

Class ilPCDataTable. More...

+ Inheritance diagram for ilPCDataTable:
+ Collaboration diagram for ilPCDataTable:

Public Member Functions

 init ()
 Init page content component. More...
 
 setNode ($a_node)
 
 create (&$a_pg_obj, $a_hier_id, $a_pc_id="")
 
 getCellNode ($i, $j)
 Get cell paragraph node of row $i and cell $j. More...
 
 makeEmptyCell ($td_node)
 Make cell empty. More...
 
 getCellText ($i, $j)
 Get cell text of row $i and cell $j. More...
 
 setData ($a_data)
 Set data of cells. More...
 
- Public Member Functions inherited from ilPCTable
 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...
 

Data Fields

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

Additional Inherited Members

- Static Public Member Functions inherited from ilPCTable
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...
 
- Protected Member Functions inherited from ilPCTable
 setTableAttribute ($a_attr, $a_value)
 Set attribute of table tag. More...
 
- Protected Member Functions inherited from ilPageContent
 setType ($a_type)
 Set Type. More...
 
- Protected Attributes inherited from ilPageContent
 $file_download_link
 
 $fullscreen_link
 
 $sourcecode_download_script
 
 $log
 

Detailed Description

Class ilPCDataTable.

Data table content object (see ILIAS DTD). This type of table can only hold one paragraph content item per cell.

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

Definition at line 38 of file class.ilPCDataTable.php.

Member Function Documentation

◆ create()

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

Definition at line 57 of file class.ilPCDataTable.php.

References ilPageContent\createPageContentNode(), and IL_INSERT_AFTER.

58  {
59  $this->node = $this->createPageContentNode();
60  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
61  $this->tab_node = $this->dom->create_element("Table");
62  $this->tab_node = $this->node->append_child($this->tab_node);
63  $this->tab_node->set_attribute("Language", "");
64  $this->tab_node->set_attribute("DataTable", "y");
65  }
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:

◆ getCellNode()

ilPCDataTable::getCellNode (   $i,
  $j 
)

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

Definition at line 70 of file class.ilPCDataTable.php.

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

Referenced by getCellText(), and setData().

71  {
72  $xpc = xpath_new_context($this->dom);
73  $path = "//PageContent[@HierId='" . $this->getHierId() . "']" .
74  "/Table/TableRow[$i+1]/TableData[$j+1]/PageContent[1]/Paragraph[1]";
75  //echo "<br>++".$path;
76  //]--//PageContent[@HierId='3']/Table/TableRow[+1]/TableData[0 style=+1]/PageContent[1]/Paragraph[1]
77  $res = xpath_eval($xpc, $path);
78 
79  if (is_object($res->nodeset[0])) {
80  return $res->nodeset[0];
81  } else { // no node -> delete all childs and create paragraph
82  $xpc2 = xpath_new_context($this->dom);
83  $path2 = "//PageContent[@HierId='" . $this->getHierId() . "']" .
84  "/Table/TableRow[" . ($i + 1) . "]/TableData[" . ($j + 1) . "]";
85  //$path2 = "//PageContent";
86 
87  $res2 = xpath_eval($xpc2, $path2);
88 
89  $td_node = $res2->nodeset[0];
90 
91  if (is_object($td_node)) {
92  // delete children of paragraph node
93  $children = $td_node->child_nodes();
94  for ($i = 0; $i < count($children); $i++) {
95  $td_node->remove_child($children[$i]);
96  }
97 
98  // create page content and paragraph node here.
99  $pc_node = $this->createPageContentNode(false);
100  $pc_node = $td_node->append_child($pc_node);
101  $par_node = $this->dom->create_element("Paragraph");
102  $par_node = $pc_node->append_child($par_node);
103  $par_node->set_attribute("Characteristic", "TableContent");
104  $par_node->set_attribute(
105  "Language",
106  $this->getLanguage()
107  );
108 
109  return $par_node;
110  }
111  }
112 
113  return "";
114  }
$path
Definition: aliased.php:25
xpath_new_context($dom_document)
xpath_eval($xpath_context, $eval_str, $contextnode=null)
foreach($_POST as $key=> $value) $res
getHierId()
Get hierarchical id.
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
$i
Definition: disco.tpl.php:19
getLanguage()
get table language
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCellText()

ilPCDataTable::getCellText (   $i,
  $j 
)

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

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

References $i, and getCellNode().

143  {
144  $cell_par = $this->getCellNode($i, $j);
145 
146  if (is_object($cell_par)) {
147  $content = "";
148  $childs = $cell_par->child_nodes();
149  for ($i = 0; $i < count($childs); $i++) {
150  $content .= $this->dom->dump_node($childs[$i]);
151  }
152  return $content;
153  } else {
154  return "";
155  }
156  }
$i
Definition: disco.tpl.php:19
getCellNode($i, $j)
Get cell paragraph node of row $i and cell $j.
+ Here is the call graph for this function:

◆ init()

ilPCDataTable::init ( )

Init page content component.

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

References ilPageContent\setType().

47  {
48  $this->setType("dtab");
49  }
setType($a_type)
Set Type.
+ Here is the call graph for this function:

◆ makeEmptyCell()

ilPCDataTable::makeEmptyCell (   $td_node)

Make cell empty.

Definition at line 119 of file class.ilPCDataTable.php.

References $i, ilPageContent\createPageContentNode(), and ilPCTable\getLanguage().

120  {
121  // delete children of paragraph node
122  $children = $td_node->child_nodes();
123  for ($i = 0; $i < count($children); $i++) {
124  $td_node->remove_child($children[$i]);
125  }
126 
127  // create page content and paragraph node here.
128  $pc_node = $this->createPageContentNode(false);
129  $pc_node = $td_node->append_child($pc_node);
130  $par_node = $this->dom->create_element("Paragraph");
131  $par_node = $pc_node->append_child($par_node);
132  $par_node->set_attribute("Characteristic", "TableContent");
133  $par_node->set_attribute(
134  "Language",
135  $this->getLanguage()
136  );
137  }
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
$i
Definition: disco.tpl.php:19
getLanguage()
get table language
+ Here is the call graph for this function:

◆ setData()

ilPCDataTable::setData (   $a_data)

Set data of cells.

Definition at line 161 of file class.ilPCDataTable.php.

References $i, $l, $ok, $path, $res, $row, DOMXML_LOAD_PARSING, domxml_open_mem(), getCellNode(), xpath_eval(), and xpath_new_context().

162  {
163  $ok = true;
164  //var_dump($a_data);
165  if (is_array($a_data)) {
166  foreach ($a_data as $i => $row) {
167  if (is_array($row)) {
168  foreach ($row as $j => $cell) {
169  //echo "<br><br>=".$cell."=";
170  $temp_dom = @domxml_open_mem(
171  '<?xml version="1.0" encoding="UTF-8"?><Paragraph>' . $cell . '</Paragraph>',
173  $error
174  );
175 
176  $par_node = $this->getCellNode($i, $j);
177  //echo "<br>=".htmlentities($this->dom->dump_node($par_node))."=";
178  //echo "<br>-$i-$j-$cell-";
179  // remove all childs
180  if (empty($error) && is_object($par_node)) {
181  // delete children of paragraph node
182  $children = $par_node->child_nodes();
183  for ($k = 0; $k < count($children); $k++) {
184  $par_node->remove_child($children[$k]);
185  }
186 
187  // copy new content children in paragraph node
188  $xpc = xpath_new_context($temp_dom);
189  $path = "//Paragraph";
190  $res = xpath_eval($xpc, $path);
191 
192  if (count($res->nodeset) == 1) {
193  $new_par_node = $res->nodeset[0];
194  $new_childs = $new_par_node->child_nodes();
195  for ($l = 0; $l < count($new_childs); $l++) {
196  $cloned_child = $new_childs[$l]->clone_node(true);
197  $par_node->append_child($cloned_child);
198  //echo "<br>=".htmlentities($this->dom->dump_node($cloned_child))."=";
199  }
200  }
201  } else {
202  if (!empty($error)) {
203  return $error;
204  }
205  }
206  }
207  }
208  }
209  }
210  //exit;
211  return true;
212  }
$path
Definition: aliased.php:25
xpath_new_context($dom_document)
domxml_open_mem($str, $mode=0, &$error=null)
xpath_eval($xpath_context, $eval_str, $contextnode=null)
foreach($_POST as $key=> $value) $res
$row
global $l
Definition: afr.php:30
const DOMXML_LOAD_PARSING
$i
Definition: disco.tpl.php:19
getCellNode($i, $j)
Get cell paragraph node of row $i and cell $j.
+ Here is the call graph for this function:

◆ setNode()

ilPCDataTable::setNode (   $a_node)

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

52  {
53  parent::setNode($a_node); // this is the PageContent node
54  $this->tab_node = $a_node->first_child(); // this is the Table node
55  }

Field Documentation

◆ $dom

ilPCDataTable::$dom

Definition at line 40 of file class.ilPCDataTable.php.

◆ $tab_node

ilPCDataTable::$tab_node

Definition at line 41 of file class.ilPCDataTable.php.


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