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

Class ilPCTable. More...

+ Inheritance diagram for ilPCTable:
+ Collaboration diagram for ilPCTable:

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="")
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 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 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:
class.ilPCTable.php 17373 2008-09-09 08:55:24Z akill

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

Member Function Documentation

& ilPCTable::addCell ( $aRow,
  $a_data = "",
  $a_lang = "" 
)

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

References ilPageContent\createPageContentNode().

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

{
$new_td =& $this->dom->create_element("TableData");
$new_td =& $aRow->append_child($new_td);
// insert data if given
if ($a_data != "")
{
$new_pg =& $this->createPageContentNode(false);
$new_par =& $this->dom->create_element("Paragraph");
$new_par =& $new_pg->append_child($new_par);
$new_par->set_attribute("Language", $a_lang);
$new_par->set_attribute("Characteristic", "TableContent");
$new_par->set_content($a_data);
$new_td->append_child ($new_pg);
}
return $new_td;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

& ilPCTable::addRow ( )

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

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

{
$new_tr =& $this->dom->create_element("TableRow");
$new_tr = &$this->tab_node->append_child($new_tr);
return $new_tr;
}

+ Here is the caller graph for this function:

ilPCTable::addRows (   $a_nr_rows,
  $a_nr_cols 
)

add rows to table

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

References addCell(), and addRow().

{
for ($i=1; $i<=$a_nr_rows; $i++)
{
$aRow = $this->addRow();
for ($j=1; $j<=$a_nr_cols; $j++)
{
$this->addCell($aRow);
}
}
}

+ Here is the call graph for this function:

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

Reimplemented in ilPCDataTable.

Definition at line 56 of file class.ilPCTable.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", "");
}

+ Here is the call graph for this function:

ilPCTable::extractText ( $node)

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

References ilPageContent\$node.

Referenced by importCellAttributes(), and importTableAttributes().

{
$owner_document = $node->owner_document ();
$children = $node->child_nodes();
$total_children = count($children);
for ($i = 0; $i < $total_children; $i++){
$cur_child_node = $children[$i];
$output .= $owner_document->dump_node($cur_child_node);
}
return $output;
}

+ Here is the caller graph for this function:

ilPCTable::getBorder ( )

get table border width

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

{
return $this->tab_node->get_attribute("Border");
}
ilPCTable::getCaption ( )

get caption

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

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

{
$hier_id = $this->getHierId();
if(!empty($hier_id))
{
$xpc = xpath_new_context($this->dom);
$path = "//PageContent[@HierId = '".$hier_id."']/Table/Caption";
$res =& xpath_eval($xpc, $path);
if (count($res->nodeset) == 1)
{
return $res->nodeset[0]->get_content();
}
}
}

+ Here is the call graph for this function:

ilPCTable::getCaptionAlign ( )

get caption alignment (Top | Bottom)

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

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

{
$hier_id = $this->getHierId();
if(!empty($hier_id))
{
$xpc = xpath_new_context($this->dom);
$path = "//PageContent[@HierId = '".$hier_id."']/Table/Caption";
$res =& xpath_eval($xpc, $path);
if (count($res->nodeset) == 1)
{
return $res->nodeset[0]->get_attribute("Align");
}
}
}

+ Here is the call graph for this function:

ilPCTable::getCellPadding ( )

get table cell padding

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

{
return $this->tab_node->get_attribute("CellPadding");
}
ilPCTable::getCellSpacing ( )

get table cell spacing

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

{
return $this->tab_node->get_attribute("CellSpacing");
}
ilPCTable::getHorizontalAlign ( )

get table cell padding

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

{
return $this->tab_node->get_attribute("HorizontalAlign");
}
ilPCTable::getLanguage ( )

get table language

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

Referenced by ilPCDataTable\getCellNode().

{
return $this->tab_node->get_attribute("Language");
}

+ Here is the caller graph for this function:

ilPCTable::getWidth ( )

get table width

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

{
return $this->tab_node->get_attribute("Width");
}
ilPCTable::importCell (   $lng,
$cellNode,
$aRow 
)

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

References $lng, addCell(), and importCellAttributes().

Referenced by importRow().

{
/*echo "add Cell";
var_dump($cellNode);*/
$aCell = $this->addCell($aRow);
$par = new ilPCParagraph($this->dom);
$par->createAtNode($aCell);
$par->setText($par->input2xml($this->extractText ($cellNode)));
$par->setCharacteristic("TableContent");
$par->setLanguage($lng);
$this->importCellAttributes($cellNode, $aCell);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPCTable::importCellAttributes ( $node,
$par 
)

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

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

Referenced by importCell().

{
/*echo "importing table attributes";
var_dump($tableNode);*/
if ($node->has_attributes ())
{
foreach($node->attributes() as $n)
{
switch (strtolower($n->node_name ())) {
case "class":
$par->set_attribute("Class", $this->extractText($n));
break;
case "width":
$par->set_attribute("Width", $this->extractText($n));
break;
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPCTable::importHtml (   $lng,
  $htmlTable 
)

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

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

{
$dummy = ilUtil::stripSlashes($htmlTable, false);
//echo htmlentities($dummy);
$dom = @domxml_open_mem($dummy,DOMXML_LOAD_PARSING, $error);
if ($dom)
{
// extract first table object
$path = "//table[1] | //Table[1]";
$res = @xpath_eval($xpc, $path);
if (count($res->nodeset) == 0)
{
$error = "Could not find a table root node";
}
if (empty ($error))
{
for($i = 0; $i < count($res->nodeset); $i++)
{
$node = $res->nodeset[$i];
if ($node->has_child_nodes())
{
foreach($node->child_nodes() as $n)
{
if ($n->node_type() == XML_ELEMENT_NODE &&
strcasecmp($n->node_name (), "tr") == 0)
{
$this->importRow ($lng, $n);
}
}
}
}
}
$dom->free ();
}
if (is_array($error)) {
$errmsg = "";
foreach ($error as $errorline) { # Loop through all errors
$errmsg .= "[" . $errorline['line'] . ", " . $errorline['col'] . "]: ".$errorline['errormessage']." at Node '". $errorline['nodename'] . "'<br />";
}
}else
{
$errmsg = $error;
}
if (empty ($errmsg)) {
return true;
}
$_SESSION["message"] = $errmsg;
return false;
}

+ Here is the call graph for this function:

ilPCTable::importRow (   $lng,
$node 
)

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

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

Referenced by importHtml().

{
/*echo "add Row";
var_dump($node);*/
$aRow = $this->addRow();
if ($node->has_child_nodes())
{
foreach($node->child_nodes() as $n)
{
if ($n->node_type() == XML_ELEMENT_NODE &&
strcasecmp($n->node_name (), "td") == 0)
{
$this->importCell ($lng, $n, $aRow);
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPCTable::importSpreadsheet (   $a_lang,
  $a_data 
)

import from table

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

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

{
str_replace($a_data, "\r", "\n");
str_replace($a_data, "\n\n", "\n");
$target_rows = array();
$rows = explode("\n", $a_data);
// get maximum of cols in a row and
// put data in target_row arrays
foreach($rows as $row)
{
$cells = explode("\t", $row);
$max_cols = ($max_cols > count($cells))
? $max_cols
: count($cells);
$target_rows[] = $cells;
}
// iterate target row arrays and insert data
foreach($target_rows as $row)
{
$aRow = $this->addRow();
for ($j=0; $j<$max_cols; $j++)
{
// mask html
$data = str_replace("&","&amp;", $row[$j]);
$data = str_replace("<","&lt;", $data);
$data = str_replace(">","&gt;", $data);
$this->addCell($aRow, $data, $a_lang);
}
}
}

+ Here is the call graph for this function:

ilPCTable::importTableAttributes ( $node)

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

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

Referenced by importHtml().

{
/*echo "importing table attributes";
var_dump($tableNode);*/
if ($node->has_attributes ())
{
foreach($node->attributes() as $n)
{
switch (strtolower($n->node_name ())) {
case "border":
$this->setBorder ($this->extractText($n));
break;
case "align":
$this->setHorizontalAlign(ucfirst(strtolower($this->extractText($n))));
break;
case "cellspacing":
$this->setCellSpacing($this->extractText($n));
break;
case "cellpadding":
$this->setCellPadding($this->extractText($n));
break;
case "width":
$this->setWidth($this->extractText($n));
break;
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPCTable::init ( )

Init page content component.

Reimplemented from ilPageContent.

Reimplemented in ilPCDataTable.

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

References ilPageContent\setType().

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

+ Here is the call graph for this function:

ilPCTable::setBorder (   $a_border)

set table border

Parameters
string$a_bordertable border

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

Referenced by importTableAttributes().

{
if($a_border != "")
{
$this->tab_node->set_attribute("Border", $a_border);
}
else
{
if ($this->tab_node->has_attribute("Border"))
{
$this->tab_node->remove_attribute("Border");
}
}
}

+ Here is the caller graph for this function:

ilPCTable::setCaption (   $a_content,
  $a_align 
)

set table caption

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

References ilDOMUtil\deleteAllChildsByName(), and ilDOMUtil\setFirstOptionalElement().

{
if ($a_content != "")
{
ilDOMUtil::setFirstOptionalElement($this->dom, $this->tab_node, "Caption",
array("Summary", "TableRow"), $a_content,
array("Align" => $a_align));
}
else
{
ilDOMUtil::deleteAllChildsByName($this->tab_node, array("Caption"));
}
}

+ Here is the call graph for this function:

ilPCTable::setCellPadding (   $a_padding)

set table cell padding

Parameters
string$a_paddingtable cell padding

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

Referenced by importTableAttributes().

{
if($a_padding != "")
{
$this->tab_node->set_attribute("CellPadding", $a_padding);
}
else
{
if ($this->tab_node->has_attribute("CellPadding"))
{
$this->tab_node->remove_attribute("CellPadding");
}
}
}

+ Here is the caller graph for this function:

ilPCTable::setCellSpacing (   $a_spacing)

set table cell spacing

Parameters
string$a_spacingtable cell spacing

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

Referenced by importTableAttributes().

{
if($a_spacing != "")
{
$this->tab_node->set_attribute("CellSpacing", $a_spacing);
}
else
{
if ($this->tab_node->has_attribute("CellSpacing"))
{
$this->tab_node->remove_attribute("CellSpacing");
}
}
}

+ Here is the caller graph for this function:

ilPCTable::setFirstRowStyle (   $a_class)

Set first row td style.

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

{
$childs = $this->tab_node->child_nodes();
foreach($childs as $child)
{
if ($child->node_name() == "TableRow")
{
$gchilds = $child->child_nodes();
foreach($gchilds as $gchild)
{
if ($gchild->node_name() == "TableData")
{
$gchild->set_attribute("Class", $a_class);
}
}
return;
}
}
}
ilPCTable::setHorizontalAlign (   $a_halign)

set horizontal align

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

Referenced by importTableAttributes().

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

+ Here is the caller graph for this function:

ilPCTable::setLanguage (   $a_lang)

set table language

Parameters
string$a_langlanguage code

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

{
if($a_lang != "")
{
$this->tab_node->set_attribute("Language", $a_lang);
}
}
ilPCTable::setNode ( $a_node)

Set xml node of page content.

Parameters
object$a_nodenode object

Reimplemented from ilPageContent.

Reimplemented in ilPCDataTable.

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

{
parent::setNode($a_node); // this is the PageContent node
$this->tab_node =& $a_node->first_child(); // this is the Table node
}
ilPCTable::setTDClass (   $a_hier_id,
  $a_class,
  $a_pc_id = "" 
)

set class of table data cell

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

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

{
$xpc = xpath_new_context($this->dom);
if ($a_pc_id == "")
{
$path = "//TableData[@HierId = '".$a_hier_id."']";
}
else
{
$path = "//TableData[@PCID = '".$a_pc_id."']";
}
$res =& xpath_eval($xpc, $path);
if (count($res->nodeset) == 1)
{
if($a_class != "")
{
$res->nodeset[0]->set_attribute("Class", $a_class);
}
else
{
if ($res->nodeset[0]->has_attribute("Class"))
{
$res->nodeset[0]->remove_attribute("Class");
}
}
}
}

+ Here is the call graph for this function:

ilPCTable::setTDWidth (   $a_hier_id,
  $a_width,
  $a_pc_id = "" 
)

set width of table data cell

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

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

{
$xpc = xpath_new_context($this->dom);
if ($a_pc_id == "")
{
$path = "//TableData[@HierId = '".$a_hier_id."']";
}
else
{
$path = "//TableData[@PCID = '".$a_pc_id."']";
}
$res =& xpath_eval($xpc, $path);
if (count($res->nodeset) == 1)
{
if($a_width != "")
{
$res->nodeset[0]->set_attribute("Width", $a_width);
}
else
{
if ($res->nodeset[0]->has_attribute("Width"))
{
$res->nodeset[0]->remove_attribute("Width");
}
}
}
}

+ Here is the call graph for this function:

ilPCTable::setWidth (   $a_width)

set table width

Parameters
string$a_widthtable width

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

Referenced by importTableAttributes().

{
if($a_width != "")
{
$this->tab_node->set_attribute("Width", $a_width);
}
else
{
if ($this->tab_node->has_attribute("Width"))
{
$this->tab_node->remove_attribute("Width");
}
}
}

+ Here is the caller graph for this function:

Field Documentation

ilPCTable::$dom

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

Referenced by importHtml().

ilPCTable::$tab_node

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


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