ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 $path, $res, ilPageContent\createPageContentNode(), 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  {
81  return $res->nodeset[0];
82  }
83  else // no node -> delete all childs and create paragraph
84  {
85  $xpc2 = xpath_new_context($this->dom);
86  $path2 = "//PageContent[@HierId='".$this->getHierId()."']".
87  "/Table/TableRow[".($i+1)."]/TableData[".($j+1)."]";
88  //$path2 = "//PageContent";
89 
90  $res2 = xpath_eval($xpc2, $path2);
91 
92  $td_node = $res2->nodeset[0];
93 
94  if (is_object($td_node))
95  {
96  // delete children of paragraph node
97  $children = $td_node->child_nodes();
98  for($i=0; $i<count($children); $i++)
99  {
100  $td_node->remove_child($children[$i]);
101  }
102 
103  // create page content and paragraph node here.
104  $pc_node = $this->createPageContentNode(false);
105  $pc_node = $td_node->append_child($pc_node);
106  $par_node = $this->dom->create_element("Paragraph");
107  $par_node = $pc_node->append_child($par_node);
108  $par_node->set_attribute("Characteristic", "TableContent");
109  $par_node->set_attribute("Language",
110  $this->getLanguage());
111 
112  return $par_node;
113  }
114  }
115 
116  return "";
117  }
$path
Definition: aliased.php:25
xpath_new_context($dom_document)
xpath_eval($xpath_context, $eval_str, $contextnode=null)
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
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 144 of file class.ilPCDataTable.php.

References getCellNode().

145  {
146  $cell_par = $this->getCellNode($i, $j);
147 
148  if (is_object($cell_par))
149  {
150  $content = "";
151  $childs = $cell_par->child_nodes();
152  for($i=0; $i<count($childs); $i++)
153  {
154  $content.= $this->dom->dump_node($childs[$i]);
155  }
156  return $content;
157  }
158  else
159  {
160  return "";
161  }
162  }
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 122 of file class.ilPCDataTable.php.

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

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

◆ setData()

ilPCDataTable::setData (   $a_data)

Set data of cells.

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

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

168  {
169  $ok = true;
170 //var_dump($a_data);
171  if (is_array($a_data))
172  {
173  foreach ($a_data as $i => $row)
174  {
175  if (is_array($row))
176  {
177  foreach ($row as $j => $cell)
178  {
179 //echo "<br><br>=".$cell."=";
180  $temp_dom = @domxml_open_mem('<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$cell.'</Paragraph>',
181  DOMXML_LOAD_PARSING, $error);
182 
183  $par_node = $this->getCellNode($i, $j);
184 //echo "<br>=".htmlentities($this->dom->dump_node($par_node))."=";
185 //echo "<br>-$i-$j-$cell-";
186  // remove all childs
187  if(empty($error) && is_object($par_node))
188  {
189  // delete children of paragraph node
190  $children = $par_node->child_nodes();
191  for($k=0; $k < count($children); $k++)
192  {
193  $par_node->remove_child($children[$k]);
194  }
195 
196  // copy new content children in paragraph node
197  $xpc = xpath_new_context($temp_dom);
198  $path = "//Paragraph";
199  $res = xpath_eval($xpc, $path);
200 
201  if (count($res->nodeset) == 1)
202  {
203  $new_par_node = $res->nodeset[0];
204  $new_childs = $new_par_node->child_nodes();
205  for ($l = 0; $l < count($new_childs); $l++)
206  {
207  $cloned_child = $new_childs[$l]->clone_node(true);
208  $par_node->append_child($cloned_child);
209 //echo "<br>=".htmlentities($this->dom->dump_node($cloned_child))."=";
210  }
211  }
212  }
213  else
214  {
215  if (!empty($error))
216  {
217  return $error;
218  }
219  }
220  }
221  }
222  }
223  }
224 //exit;
225  return true;
226  }
$error
Definition: Error.php:17
$path
Definition: aliased.php:25
xpath_new_context($dom_document)
xpath_eval($xpath_context, $eval_str, $contextnode=null)
global $l
Definition: afr.php:30
domxml_open_mem($str, $mode=0, &$error=NULL)
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: