ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilPCDataTable Class Reference

Class ilPCDataTable. More...

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

Public Member Functions

 init ()
 Init page content component.
 setNode (&$a_node)
 Set xml node of page content.
 create (&$a_pg_obj, $a_hier_id, $a_pc_id="")
 getCellNode ($i, $j)
 Get cell paragraph node of row $i and cell $j.
 getCellText ($i, $j)
 Get cell text of row $i and cell $j.
 setData ($a_data)
 Set data of cells.
- Public Member Functions inherited from ilPCTable
addRow ()
addCell (&$aRow, $a_data="", $a_lang="")
 addRows ($a_nr_rows, $a_nr_cols)
 add rows to table
 importSpreadsheet ($a_lang, $a_data)
 import from table
 getLanguage ()
 get table language
 setLanguage ($a_lang)
 set table language
 getWidth ()
 get table width
 setWidth ($a_width)
 set table width
 getBorder ()
 get table border width
 setBorder ($a_border)
 set table border
 getCellSpacing ()
 get table cell spacing
 setCellSpacing ($a_spacing)
 set table cell spacing
 getCellPadding ()
 get table cell padding
 setCellPadding ($a_padding)
 set table cell padding
 setHorizontalAlign ($a_halign)
 set horizontal align
 getHorizontalAlign ()
 get table cell padding
 setTDWidth ($a_hier_id, $a_width, $a_pc_id="")
 set width of table data cell
 setTDClass ($a_hier_id, $a_class, $a_pc_id="")
 set class of table data cell
 getCaption ()
 get caption
 getCaptionAlign ()
 get caption alignment (Top | Bottom)
 setCaption ($a_content, $a_align)
 set table caption
 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.
- Public Member Functions inherited from ilPageContent
 __construct ($a_dom)
 Constructor.
 getType ()
 Get type of page content.
getNode ()
 Get xml node of page content.
 setHierId ($a_hier_id)
 Set hierarchical ID in xml structure.
 getHierId ()
 Get hierarchical id.
 readHierId ()
 Read PC Id.
 setPcId ($a_pcid)
 Set PC Id.
 getPCId ()
 Get PC Id.
 readPCId ()
 Read PC Id.
 setEnabled ($value)
 Set Enabled value for page content component.
 enable ()
 Enable page content.
 disable ()
 Disable page content.
 isEnabled ()
 Check whether page content is enabled.
 createPageContentNode ($a_set_this_node=true)
 Create page content node (always use this method first when adding a new element)

Data Fields

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

Additional Inherited Members

- Static Public Member Functions inherited from ilPageContent
static incEdId ($ed_id)
 Increases an hierarchical editing id at lowest level (last number)
static decEdId ($ed_id)
 Decreases an hierarchical editing id at lowest level (last number)
static haveSameContainer ($ed_id1, $ed_id2)
 Check, if two ids are in same container.
- Protected Member Functions inherited from ilPageContent
 setType ($a_type)
 Set Type.

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

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

Reimplemented from ilPCTable.

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

References ilPageContent\createPageContentNode(), and IL_INSERT_AFTER.

{
$this->node = $this->createPageContentNode();
$a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
$this->tab_node =& $this->dom->create_element("Table");
$this->tab_node =& $this->node->append_child($this->tab_node);
$this->tab_node->set_attribute("Language", "");
$this->tab_node->set_attribute("DataTable", "y");
}

+ Here is the call graph for this function:

ilPCDataTable::getCellNode (   $i,
  $j 
)

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

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

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

Referenced by getCellText(), and setData().

{
$xpc = xpath_new_context($this->dom);
$path = "//PageContent[@HierId='".$this->getHierId()."']".
"/Table/TableRow[$i+1]/TableData[$j+1]/PageContent[1]/Paragraph[1]";
$res =& xpath_eval($xpc, $path);
if (is_object($res->nodeset[0]))
{
return $res->nodeset[0];
}
else // no node -> delete all childs and create paragraph
{
$xpc2 = xpath_new_context($this->dom);
$path2 = "//PageContent[@HierId='".$this->getHierId()."']".
"/Table/TableRow[".($i+1)."]/TableData[".($j+1)."]";
//$path2 = "//PageContent";
$res2 =& xpath_eval($xpc2, $path2);
$td_node = $res2->nodeset[0];
if (is_object($td_node))
{
// delete children of paragraph node
$children = $td_node->child_nodes();
for($i=0; $i<count($children); $i++)
{
$td_node->remove_child($children[$i]);
}
// create page content and paragraph node here.
$pc_node = $this->createPageContentNode(false);
$pc_node = $td_node->append_child($pc_node);
$par_node = $this->dom->create_element("Paragraph");
$par_node = $pc_node->append_child($par_node);
$par_node->set_attribute("Characteristic", "TableContent");
$par_node->set_attribute("Language",
$this->getLanguage());
return $par_node;
}
}
return "";
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPCDataTable::getCellText (   $i,
  $j 
)

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

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

References getCellNode().

{
$cell_par = $this->getCellNode($i, $j);
if (is_object($cell_par))
{
$content = "";
$childs = $cell_par->child_nodes();
for($i=0; $i<count($childs); $i++)
{
$content.= $this->dom->dump_node($childs[$i]);
}
return $content;
}
else
{
return "";
}
}

+ Here is the call graph for this function:

ilPCDataTable::init ( )

Init page content component.

Reimplemented from ilPCTable.

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

References ilPageContent\setType().

{
$this->setType("dtab");
}

+ Here is the call graph for this function:

ilPCDataTable::setData (   $a_data)

Set data of cells.

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

References $ok, $res, domxml_open_mem(), getCellNode(), xpath_eval(), and xpath_new_context().

{
$ok = true;
//var_dump($a_data);
if (is_array($a_data))
{
foreach ($a_data as $i => $row)
{
if (is_array($row))
{
foreach ($row as $j => $cell)
{
$temp_dom = @domxml_open_mem('<?xml version="1.0" encoding="UTF-8"?><Paragraph>'.$cell.'</Paragraph>',
DOMXML_LOAD_PARSING, $error);
$par_node = $this->getCellNode($i, $j);
//echo "<br>=".htmlentities($this->dom->dump_node($par_node))."=";
//echo "<br>-$i-$j-$cell-";
// remove all childs
if(empty($error) && is_object($par_node))
{
// delete children of paragraph node
$children = $par_node->child_nodes();
for($k=0; $k < count($children); $k++)
{
$par_node->remove_child($children[$k]);
}
// copy new content children in paragraph node
$xpc = xpath_new_context($temp_dom);
$path = "//Paragraph";
$res =& xpath_eval($xpc, $path);
if (count($res->nodeset) == 1)
{
$new_par_node =& $res->nodeset[0];
$new_childs = $new_par_node->child_nodes();
for ($l = 0; $l < count($new_childs); $l++)
{
$cloned_child = $new_childs[$l]->clone_node(true);
$par_node->append_child($cloned_child);
//echo "<br>=".htmlentities($this->dom->dump_node($cloned_child))."=";
}
}
}
else
{
if (!empty($error))
{
return $error;
}
}
}
}
}
}
return true;
}

+ Here is the call graph for this function:

ilPCDataTable::setNode ( $a_node)

Set xml node of page content.

Parameters
object$a_nodenode object

Reimplemented from ilPCTable.

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

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

Field Documentation

ilPCDataTable::$dom

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

ilPCDataTable::$tab_node

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


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