24 require_once(
"./Services/COPage/classes/class.ilPageContent.php");
53 $this->tab_node =& $a_node->first_child();
56 function create(&$a_pg_obj, $a_hier_id, $a_pc_id =
"")
60 $this->tab_node =& $this->dom->create_element(
"Table");
61 $this->tab_node =& $this->node->append_child($this->tab_node);
62 $this->tab_node->set_attribute(
"Language",
"");
66 $new_tr =& $this->dom->create_element(
"TableRow");
67 $new_tr = &$this->tab_node->append_child($new_tr);
71 function &
addCell (&$aRow, $a_data =
"", $a_lang =
"")
73 $new_td =& $this->dom->create_element(
"TableData");
74 $new_td =& $aRow->append_child($new_td);
80 $new_par =& $this->dom->create_element(
"Paragraph");
81 $new_par =& $new_pg->append_child($new_par);
82 $new_par->set_attribute(
"Language", $a_lang);
83 $new_par->set_attribute(
"Characteristic",
"TableContent");
84 $new_par->set_content($a_data);
85 $new_td->append_child ($new_pg);
96 for ($i=1; $i<=$a_nr_rows; $i++)
99 for ($j=1; $j<=$a_nr_cols; $j++)
111 str_replace($a_data,
"\r",
"\n");
112 str_replace($a_data,
"\n\n",
"\n");
113 $target_rows = array();
114 $rows = explode(
"\n", $a_data);
118 foreach($rows as $row)
120 $cells = explode(
"\t", $row);
121 $max_cols = ($max_cols > count($cells))
124 $target_rows[] = $cells;
128 foreach($target_rows as $row)
131 for ($j=0; $j<$max_cols; $j++)
134 $data = str_replace(
"&",
"&", $row[$j]);
148 return $this->tab_node->get_attribute(
"Language");
160 $this->tab_node->set_attribute(
"Language", $a_lang);
169 return $this->tab_node->get_attribute(
"Width");
181 $this->tab_node->set_attribute(
"Width", $a_width);
185 if ($this->tab_node->has_attribute(
"Width"))
187 $this->tab_node->remove_attribute(
"Width");
199 return $this->tab_node->get_attribute(
"Border");
211 $this->tab_node->set_attribute(
"Border", $a_border);
215 if ($this->tab_node->has_attribute(
"Border"))
217 $this->tab_node->remove_attribute(
"Border");
227 return $this->tab_node->get_attribute(
"CellSpacing");
239 $this->tab_node->set_attribute(
"CellSpacing", $a_spacing);
243 if ($this->tab_node->has_attribute(
"CellSpacing"))
245 $this->tab_node->remove_attribute(
"CellSpacing");
255 return $this->tab_node->get_attribute(
"CellPadding");
267 $this->tab_node->set_attribute(
"CellPadding", $a_padding);
271 if ($this->tab_node->has_attribute(
"CellPadding"))
273 $this->tab_node->remove_attribute(
"CellPadding");
283 $this->tab_node->set_attribute(
"HorizontalAlign", $a_halign);
291 return $this->tab_node->get_attribute(
"HorizontalAlign");
303 $path =
"//TableData[@HierId = '".$a_hier_id.
"']";
307 $path =
"//TableData[@PCID = '".$a_pc_id.
"']";
311 if (count(
$res->nodeset) == 1)
315 $res->nodeset[0]->set_attribute(
"Width", $a_width);
319 if (
$res->nodeset[0]->has_attribute(
"Width"))
321 $res->nodeset[0]->remove_attribute(
"Width");
335 $path =
"//TableData[@HierId = '".$a_hier_id.
"']";
339 $path =
"//TableData[@PCID = '".$a_pc_id.
"']";
342 if (count(
$res->nodeset) == 1)
346 $res->nodeset[0]->set_attribute(
"Class", $a_class);
350 if (
$res->nodeset[0]->has_attribute(
"Class"))
352 $res->nodeset[0]->remove_attribute(
"Class");
367 $path =
"//PageContent[@HierId = '".$hier_id.
"']/Table/Caption";
370 if (count(
$res->nodeset) == 1)
372 return $res->nodeset[0]->get_content();
386 $path =
"//PageContent[@HierId = '".$hier_id.
"']/Table/Caption";
388 if (count(
$res->nodeset) == 1)
390 return $res->nodeset[0]->get_attribute(
"Align");
400 if ($a_content !=
"")
403 array(
"Summary",
"TableRow"), $a_content,
404 array(
"Align" => $a_align));
416 if (
$node->has_attributes ())
418 foreach(
$node->attributes() as
$n)
421 switch (strtolower(
$n->node_name ())) {
448 if (
$node->has_attributes ())
450 foreach(
$node->attributes() as
$n)
453 switch (strtolower(
$n->node_name ())) {
473 if (
$node->has_child_nodes())
475 foreach(
$node->child_nodes() as
$n)
477 if (
$n->node_type() == XML_ELEMENT_NODE &&
478 strcasecmp(
$n->node_name (),
"td") == 0)
489 $aCell = $this->
addCell($aRow);
491 $par->createAtNode($aCell);
492 $par->setText($par->input2xml($this->extractText ($cellNode)));
493 $par->setCharacteristic(
"TableContent");
494 $par->setLanguage(
$lng);
499 $owner_document =
$node->owner_document ();
500 $children =
$node->child_nodes();
501 $total_children = count($children);
502 for ($i = 0; $i < $total_children; $i++){
503 $cur_child_node = $children[$i];
504 $output .= $owner_document->dump_node($cur_child_node);
518 $path =
"//table[1] | //Table[1]";
521 if (count(
$res->nodeset) == 0)
523 $error =
"Could not find a table root node";
528 for($i = 0; $i < count(
$res->nodeset); $i++)
534 if (
$node->has_child_nodes())
536 foreach(
$node->child_nodes() as
$n)
538 if (
$n->node_type() == XML_ELEMENT_NODE &&
539 strcasecmp(
$n->node_name (),
"tr") == 0)
550 if (is_array($error)) {
552 foreach ($error as $errorline) { # Loop through all errors
553 $errmsg .=
"[" . $errorline[
'line'] .
", " . $errorline[
'col'] .
"]: ".$errorline[
'errormessage'].
" at Node '". $errorline[
'nodename'] .
"'<br />";
560 if (empty ($errmsg)) {
573 $childs = $this->tab_node->child_nodes();
574 foreach($childs as $child)
576 if ($child->node_name() ==
"TableRow")
578 $gchilds = $child->child_nodes();
579 foreach($gchilds as $gchild)
581 if ($gchild->node_name() ==
"TableData")
583 $gchild->set_attribute(
"Class", $a_class);