5 require_once(
"./Services/COPage/classes/class.ilPageContent.php");
 
   34                 $this->tab_node =& $a_node->first_child();              
 
   37         function create(&$a_pg_obj, $a_hier_id, $a_pc_id = 
"")
 
   41                 $this->tab_node =& $this->dom->create_element(
"Table");
 
   42                 $this->tab_node =& $this->node->append_child($this->tab_node);
 
   43                 $this->tab_node->set_attribute(
"Language", 
"");
 
   47                 $new_tr =& $this->dom->create_element(
"TableRow");
 
   48                 $new_tr = &$this->tab_node->append_child($new_tr);
 
   52         function &
addCell (&$aRow, $a_data = 
"", $a_lang = 
"")
 
   54                 $new_td =& $this->dom->create_element(
"TableData");
 
   55                 $new_td =& $aRow->append_child($new_td);
 
   61                         $new_par =& $this->dom->create_element(
"Paragraph");
 
   62                         $new_par =& $new_pg->append_child($new_par);
 
   63                         $new_par->set_attribute(
"Language", $a_lang);
 
   64                         $new_par->set_attribute(
"Characteristic", 
"TableContent");
 
   65                         $new_par->set_content($a_data);
 
   66                         $new_td->append_child ($new_pg);
 
   77                 for ($i=1; $i<=$a_nr_rows; $i++)
 
   80                         for ($j=1; $j<=$a_nr_cols; $j++)
 
   92                 str_replace($a_data, 
"\r", 
"\n");
 
   93                 str_replace($a_data, 
"\n\n", 
"\n");
 
   94                 $target_rows = array();
 
   95                 $rows = explode(
"\n", $a_data);
 
   99                 foreach($rows as 
$row)
 
  101                         $cells = explode(
"\t", $row);
 
  102                         $max_cols = ($max_cols > count($cells))
 
  105                         $target_rows[] = $cells;
 
  109                 foreach($target_rows as $row)
 
  112                         for ($j=0; $j<$max_cols; $j++)
 
  115                                 $data = str_replace(
"&",
"&", $row[$j]);
 
  222                 $this->tab_node->set_attribute(
"HorizontalAlign", $a_halign);
 
  242                         $path = 
"//TableData[@HierId = '".$a_hier_id.
"']";
 
  246                         $path = 
"//TableData[@PCID = '".$a_pc_id.
"']";
 
  250                 if (count(
$res->nodeset) == 1)
 
  254                                 $res->nodeset[0]->set_attribute(
"Width", $a_width);
 
  258                                 if (
$res->nodeset[0]->has_attribute(
"Width"))
 
  260                                         $res->nodeset[0]->remove_attribute(
"Width");
 
  272                 $rows = $this->tab_node->child_nodes();
 
  273                 foreach($rows as 
$row)
 
  275                         if ($row->node_name() == 
"TableRow")
 
  278                                 $cells = $row->child_nodes();
 
  279                                 foreach($cells as $cell)
 
  281                                         if ($cell->node_name() == 
"TableData")
 
  283                                                 $ckey = $cell->get_attribute(
"HierId").
":".$cell->get_attribute(
"PCID");
 
  284                                                 if((
int) $a_colspans[$ckey] > 1)
 
  286                                                         $cell->set_attribute(
"ColSpan", (
int) $a_colspans[$ckey]);
 
  290                                                         if ($cell->has_attribute(
"ColSpan"))
 
  292                                                                 $cell->remove_attribute(
"ColSpan");
 
  295                                                 if((
int) $a_rowspans[$ckey] > 1)
 
  297                                                         $cell->set_attribute(
"RowSpan", (
int) $a_rowspans[$ckey]);
 
  301                                                         if ($cell->has_attribute(
"RowSpan"))
 
  303                                                                 $cell->remove_attribute(
"RowSpan");
 
  326                 $rows = $this->tab_node->child_nodes();
 
  328                 foreach($rows as 
$row)
 
  330                         if ($row->node_name() == 
"TableRow")
 
  333                                 $cells = $row->child_nodes();
 
  334                                 foreach($cells as $cell)
 
  336                                         if ($cell->node_name() == 
"TableData")
 
  338                                                 $max_x = max ($max_x, $x);
 
  339                                                 $max_y = max ($max_y, $y);
 
  349                 $rows = $this->tab_node->child_nodes();
 
  350                 foreach($rows as $row)
 
  352                         if ($row->node_name() == 
"TableRow")
 
  355                                 $cells = $row->child_nodes();
 
  356                                 foreach($cells as $cell)
 
  358                                         if ($cell->node_name() == 
"TableData")
 
  360                                                 $cspan = max(1, (
int) $cell->get_attribute(
"ColSpan"));
 
  361                                                 $rspan = max(1, (
int) $cell->get_attribute(
"RowSpan"));
 
  364                                                 if ($cspan > $max_x - $x + 1)
 
  366                                                         $cell->set_attribute(
"ColSpan", $max_x - $x + 1);
 
  367                                                         $cspan = $max_x - $x + 1;
 
  369                                                 if ($rspan > $max_y - $y + 1)
 
  371                                                         $cell->set_attribute(
"RowSpan", $max_y - $y + 1);
 
  372                                                         $rspan = $max_y - $y + 1;
 
  379                                                         $cell->set_attribute(
"Hidden", 
"Y");
 
  382                                                         if ($cell->has_attribute(
"ColSpan"))
 
  384                                                                 $cell->remove_attribute(
"ColSpan");
 
  386                                                         if ($cell->has_attribute(
"RowSpan"))
 
  388                                                                 $cell->remove_attribute(
"RowSpan");
 
  395                                                         if ($cell->has_attribute(
"Hidden"))
 
  397                                                                 $cell->remove_attribute(
"Hidden");
 
  401                                                 $colspans[$x][$y] = $cspan;
 
  402                                                 $rowspans[$x][$y] = $rspan;
 
  419                 $children = $td_node->child_nodes();
 
  420                 for($i=0; $i<count($children); $i++)
 
  422                         $td_node->remove_child($children[$i]);
 
  431                 for ($i = 0; $i<=$x; $i++)
 
  433                         for ($j = 0; $j<=$y; $j++)
 
  435                                 if ($i != $x || $j != $y)
 
  437                                         if ((($i + $colspans[$i][$j] > $x) &&
 
  438                                                 ($j + $rowspans[$i][$j] > $y)))
 
  456                 $rows = $this->tab_node->child_nodes();
 
  457                 foreach($rows as 
$row)
 
  459                         if ($row->node_name() == 
"TableRow")
 
  461                                 $cells = $row->child_nodes();
 
  462                                 foreach($cells as $cell)
 
  464                                         if ($cell->node_name() == 
"TableData")
 
  466                                                 $classes[$cell->get_attribute(
"HierId").
":".$cell->get_attribute(
"PCID")]
 
  467                                                         = $cell->get_attribute(
"Class");
 
  484                 $rows = $this->tab_node->child_nodes();
 
  485                 foreach($rows as 
$row)
 
  487                         if ($row->node_name() == 
"TableRow")
 
  489                                 $cells = $row->child_nodes();
 
  490                                 foreach($cells as $cell)
 
  492                                         if ($cell->node_name() == 
"TableData")
 
  494                                                 $classes[$cell->get_attribute(
"HierId").
":".$cell->get_attribute(
"PCID")]
 
  495                                                         = $cell->get_attribute(
"HorizontalAlign");
 
  512                 $rows = $this->tab_node->child_nodes();
 
  516                 foreach($rows as 
$row)
 
  518                         if ($row->node_name() == 
"TableRow")
 
  521                                 $cells = $row->child_nodes();
 
  522                                 foreach($cells as $cell)
 
  524                                         if ($cell->node_name() == 
"TableData")
 
  526                                                 $spans[$cell->get_attribute(
"HierId").
":".$cell->get_attribute(
"PCID")]
 
  527                                                         = array(
"x" => $x, 
"y" => $y, 
"colspan" => $cell->get_attribute(
"ColSpan"),
 
  528                                                                 "rowspan" => $cell->get_attribute(
"RowSpan"));
 
  529                                                 $max_x = max($max_x, $x);
 
  530                                                 $max_y = max($max_y, $y);
 
  537                 foreach ($spans as $k => $v)
 
  539                         $spans[$k][
"max_x"] = $max_x;
 
  540                         $spans[$k][
"max_y"] = $max_y;
 
  554                 $rows = $this->tab_node->child_nodes();
 
  555                 foreach($rows as 
$row)
 
  557                         if ($row->node_name() == 
"TableRow")
 
  559                                 $cells = $row->child_nodes();
 
  560                                 foreach($cells as $cell)
 
  562                                         if ($cell->node_name() == 
"TableData")
 
  564                                                 $widths[$cell->get_attribute(
"HierId").
":".$cell->get_attribute(
"PCID")]
 
  565                                                         = $cell->get_attribute(
"Width");
 
  582                         $path = 
"//TableData[@HierId = '".$a_hier_id.
"']";
 
  586                         $path = 
"//TableData[@PCID = '".$a_pc_id.
"']";
 
  589                 if (count(
$res->nodeset) == 1)
 
  593                                 $res->nodeset[0]->set_attribute(
"Class", $a_class);
 
  597                                 if (
$res->nodeset[0]->has_attribute(
"Class"))
 
  599                                         $res->nodeset[0]->remove_attribute(
"Class");
 
  613                         $path = 
"//TableData[@HierId = '".$a_hier_id.
"']";
 
  617                         $path = 
"//TableData[@PCID = '".$a_pc_id.
"']";
 
  620                 if (count(
$res->nodeset) == 1)
 
  624                                 $res->nodeset[0]->set_attribute(
"HorizontalAlign", $a_class);
 
  628                                 if (
$res->nodeset[0]->has_attribute(
"HorizontalAlign"))
 
  630                                         $res->nodeset[0]->remove_attribute(
"HorizontalAlign");
 
  645                         $path = 
"//PageContent[@HierId = '".$hier_id.
"']/Table/Caption";
 
  648                         if (count(
$res->nodeset) == 1)
 
  650                                 return $res->nodeset[0]->get_content();
 
  664                         $path = 
"//PageContent[@HierId = '".$hier_id.
"']/Table/Caption";
 
  666                         if (count(
$res->nodeset) == 1)
 
  668                                 return $res->nodeset[0]->get_attribute(
"Align");
 
  678                 if ($a_content != 
"")
 
  681                         array(
"Summary", 
"TableRow"), $a_content,
 
  682                         array(
"Align" => $a_align));
 
  694                 if (
$node->has_attributes ())
 
  696                         foreach(
$node->attributes() as 
$n)
 
  699                                 switch (strtolower(
$n->node_name ())) {
 
  726                 if (
$node->has_attributes ())
 
  728                         foreach(
$node->attributes() as 
$n)
 
  731                                 switch (strtolower(
$n->node_name ())) {
 
  751                 if (
$node->has_child_nodes())
 
  753                         foreach(
$node->child_nodes() as 
$n)
 
  755                                 if (
$n->node_type() == XML_ELEMENT_NODE &&
 
  756                                 strcasecmp(
$n->node_name (), 
"td") == 0)
 
  767                 $aCell = $this->
addCell($aRow);
 
  769                 $par->createAtNode($aCell);
 
  770                 $par->setText($par->input2xml($this->extractText ($cellNode)));
 
  771                 $par->setCharacteristic(
"TableContent");
 
  772                 $par->setLanguage(
$lng);
 
  777                 $owner_document = 
$node->owner_document ();
 
  778                 $children = 
$node->child_nodes();
 
  779                 $total_children = count($children);
 
  780                 for ($i = 0; $i < $total_children; $i++){
 
  781                         $cur_child_node = $children[$i];
 
  782                         $output .= $owner_document->dump_node($cur_child_node);
 
  796                         $path = 
"//table[1] | //Table[1]";
 
  799                         if (count(
$res->nodeset) == 0)
 
  801                                 $error = 
"Could not find a table root node";
 
  806                                 for($i = 0; $i < count(
$res->nodeset); $i++)
 
  812                                         if (
$node->has_child_nodes())
 
  814                                                 foreach(
$node->child_nodes() as 
$n)
 
  816                                                         if (
$n->node_type() == XML_ELEMENT_NODE &&
 
  817                                                         strcasecmp(
$n->node_name (), 
"tr") == 0)
 
  828                 if (is_array($error)) {
 
  830                         foreach ($error as $errorline) {    # Loop through all errors
 
  831                                 $errmsg .=  
"[" . $errorline[
'line'] . 
", " . $errorline[
'col'] . 
"]: ".$errorline[
'errormessage'].
" at Node '". $errorline[
'nodename'] . 
"'<br />";
 
  838                 if (empty ($errmsg)) {
 
  851                 $childs = $this->tab_node->child_nodes();
 
  852                 foreach($childs as $child)
 
  854                         if ($child->node_name() == 
"TableRow")
 
  856                                 $gchilds = $child->child_nodes();
 
  857                                 foreach($gchilds as $gchild)
 
  859                                         if ($gchild->node_name() == 
"TableData")
 
  861                                                 $gchild->set_attribute(
"Class", $a_class);
 
  997                 if (!empty($a_value))
 
  999                         $this->tab_node->set_attribute($a_attr, $a_value);
 
 1003                         if ($this->tab_node->has_attribute($a_attr))
 
 1005                                 $this->tab_node->remove_attribute($a_attr);
 
 1017                 if (is_object($this->tab_node))
 
 1019                         return  $this->tab_node->get_attribute($a_attr);