5require_once(
"./Services/COPage/classes/class.ilPageContent.php");
 
   33        parent::setNode($a_node);               
 
   34        $this->tab_node = $a_node->first_child();               
 
   37    public 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", 
"");
 
   48        $new_tr = $this->dom->create_element(
"TableRow");
 
   49        $new_tr = &$this->tab_node->append_child($new_tr);
 
   53    public function &
addCell(&$aRow, $a_data = 
"", $a_lang = 
"")
 
   55        $new_td = $this->dom->create_element(
"TableData");
 
   56        $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);
 
   75    public function addRows($a_nr_rows, $a_nr_cols)
 
   77        for (
$i=1; 
$i<=$a_nr_rows; 
$i++) {
 
   79            for ($j=1; $j<=$a_nr_cols; $j++) {
 
   90        str_replace($a_data, 
"\r", 
"\n");
 
   91        str_replace($a_data, 
"\n\n", 
"\n");
 
   92        $target_rows = array();
 
   93        $rows = explode(
"\n", $a_data);
 
   98            $cells = explode(
"\t", 
$row);
 
   99            $max_cols = ($max_cols > count($cells))
 
  102            $target_rows[] = $cells;
 
  106        foreach ($target_rows as 
$row) {
 
  108            for ($j=0; $j<$max_cols; $j++) {
 
  110                $data = str_replace(
"&", 
"&", 
$row[$j]);
 
  216        $this->tab_node->set_attribute(
"HorizontalAlign", $a_halign);
 
  230    public function setTDWidth($a_hier_id, $a_width, $a_pc_id = 
"")
 
  234        if ($a_pc_id == 
"") {
 
  235            $path = 
"//TableData[@HierId = '" . $a_hier_id . 
"']";
 
  237            $path = 
"//TableData[@PCID = '" . $a_pc_id . 
"']";
 
  241        if (count(
$res->nodeset) == 1) {
 
  242            if ($a_width != 
"") {
 
  243                $res->nodeset[0]->set_attribute(
"Width", $a_width);
 
  245                if (
$res->nodeset[0]->has_attribute(
"Width")) {
 
  246                    $res->nodeset[0]->remove_attribute(
"Width");
 
  258        $rows = $this->tab_node->child_nodes();
 
  260            if (
$row->node_name() == 
"TableRow") {
 
  262                $cells = 
$row->child_nodes();
 
  263                foreach ($cells as $cell) {
 
  264                    if ($cell->node_name() == 
"TableData") {
 
  265                        $ckey = $cell->get_attribute(
"HierId") . 
":" . $cell->get_attribute(
"PCID");
 
  266                        if ((
int) $a_colspans[$ckey] > 1) {
 
  267                            $cell->set_attribute(
"ColSpan", (
int) $a_colspans[$ckey]);
 
  269                            if ($cell->has_attribute(
"ColSpan")) {
 
  270                                $cell->remove_attribute(
"ColSpan");
 
  273                        if ((
int) $a_rowspans[$ckey] > 1) {
 
  274                            $cell->set_attribute(
"RowSpan", (
int) $a_rowspans[$ckey]);
 
  276                            if ($cell->has_attribute(
"RowSpan")) {
 
  277                                $cell->remove_attribute(
"RowSpan");
 
  300        $rows = $this->tab_node->child_nodes();
 
  303            if (
$row->node_name() == 
"TableRow") {
 
  305                $cells = 
$row->child_nodes();
 
  306                foreach ($cells as $cell) {
 
  307                    if ($cell->node_name() == 
"TableData") {
 
  308                        $max_x = max($max_x, 
$x);
 
  309                        $max_y = max($max_y, 
$y);
 
  319        $rows = $this->tab_node->child_nodes();
 
  321            if (
$row->node_name() == 
"TableRow") {
 
  323                $cells = 
$row->child_nodes();
 
  324                foreach ($cells as $cell) {
 
  325                    if ($cell->node_name() == 
"TableData") {
 
  326                        $cspan = max(1, (
int) $cell->get_attribute(
"ColSpan"));
 
  327                        $rspan = max(1, (
int) $cell->get_attribute(
"RowSpan"));
 
  330                        if ($cspan > $max_x - 
$x + 1) {
 
  331                            $cell->set_attribute(
"ColSpan", $max_x - 
$x + 1);
 
  332                            $cspan = $max_x - 
$x + 1;
 
  334                        if ($rspan > $max_y - 
$y + 1) {
 
  335                            $cell->set_attribute(
"RowSpan", $max_y - 
$y + 1);
 
  336                            $rspan = $max_y - 
$y + 1;
 
  342                            $cell->set_attribute(
"Hidden", 
"Y");
 
  345                            if ($cell->has_attribute(
"ColSpan")) {
 
  346                                $cell->remove_attribute(
"ColSpan");
 
  348                            if ($cell->has_attribute(
"RowSpan")) {
 
  349                                $cell->remove_attribute(
"RowSpan");
 
  354                            if ($cell->has_attribute(
"Hidden")) {
 
  355                                $cell->remove_attribute(
"Hidden");
 
  359                        $colspans[
$x][
$y] = $cspan;
 
  360                        $rowspans[
$x][
$y] = $rspan;
 
  376        $children = $td_node->child_nodes();
 
  377        for (
$i=0; 
$i<count($children); 
$i++) {
 
  378            $td_node->remove_child($children[
$i]);
 
  388            for ($j = 0; $j<=
$y; $j++) {
 
  389                if (
$i != 
$x || $j != 
$y) {
 
  390                    if (((
$i + $colspans[
$i][$j] > 
$x) &&
 
  391                        ($j + $rowspans[
$i][$j] > 
$y))) {
 
  408        $rows = $this->tab_node->child_nodes();
 
  410            if (
$row->node_name() == 
"TableRow") {
 
  411                $cells = 
$row->child_nodes();
 
  412                foreach ($cells as $cell) {
 
  413                    if ($cell->node_name() == 
"TableData") {
 
  414                        $classes[$cell->get_attribute(
"HierId") . 
":" . $cell->get_attribute(
"PCID")]
 
  415                            = $cell->get_attribute(
"Class");
 
  432        $rows = $this->tab_node->child_nodes();
 
  434            if (
$row->node_name() == 
"TableRow") {
 
  435                $cells = 
$row->child_nodes();
 
  436                foreach ($cells as $cell) {
 
  437                    if ($cell->node_name() == 
"TableData") {
 
  438                        $classes[$cell->get_attribute(
"HierId") . 
":" . $cell->get_attribute(
"PCID")]
 
  439                            = $cell->get_attribute(
"HorizontalAlign");
 
  456        $rows = $this->tab_node->child_nodes();
 
  461            if (
$row->node_name() == 
"TableRow") {
 
  463                $cells = 
$row->child_nodes();
 
  464                foreach ($cells as $cell) {
 
  465                    if ($cell->node_name() == 
"TableData") {
 
  466                        $spans[$cell->get_attribute(
"HierId") . 
":" . $cell->get_attribute(
"PCID")]
 
  467                            = array(
"x" => 
$x, 
"y" => 
$y, 
"colspan" => $cell->get_attribute(
"ColSpan"),
 
  468                                "rowspan" => $cell->get_attribute(
"RowSpan"));
 
  469                        $max_x = max($max_x, 
$x);
 
  470                        $max_y = max($max_y, 
$y);
 
  477        foreach ($spans as $k => $v) {
 
  478            $spans[$k][
"max_x"] = $max_x;
 
  479            $spans[$k][
"max_y"] = $max_y;
 
  493        $rows = $this->tab_node->child_nodes();
 
  495            if (
$row->node_name() == 
"TableRow") {
 
  496                $cells = 
$row->child_nodes();
 
  497                foreach ($cells as $cell) {
 
  498                    if ($cell->node_name() == 
"TableData") {
 
  499                        $widths[$cell->get_attribute(
"HierId") . 
":" . $cell->get_attribute(
"PCID")]
 
  500                            = $cell->get_attribute(
"Width");
 
  512    public function setTDClass($a_hier_id, $a_class, $a_pc_id = 
"")
 
  515        if ($a_pc_id == 
"") {
 
  516            $path = 
"//TableData[@HierId = '" . $a_hier_id . 
"']";
 
  518            $path = 
"//TableData[@PCID = '" . $a_pc_id . 
"']";
 
  521        if (count(
$res->nodeset) == 1) {
 
  522            if ($a_class != 
"") {
 
  523                $res->nodeset[0]->set_attribute(
"Class", $a_class);
 
  525                if (
$res->nodeset[0]->has_attribute(
"Class")) {
 
  526                    $res->nodeset[0]->remove_attribute(
"Class");
 
  538        if ($a_pc_id == 
"") {
 
  539            $path = 
"//TableData[@HierId = '" . $a_hier_id . 
"']";
 
  541            $path = 
"//TableData[@PCID = '" . $a_pc_id . 
"']";
 
  544        if (count(
$res->nodeset) == 1) {
 
  545            if ($a_class != 
"") {
 
  546                $res->nodeset[0]->set_attribute(
"HorizontalAlign", $a_class);
 
  548                if (
$res->nodeset[0]->has_attribute(
"HorizontalAlign")) {
 
  549                    $res->nodeset[0]->remove_attribute(
"HorizontalAlign");
 
  563            $path = 
"//PageContent[@HierId = '" . 
$hier_id . 
"']/Table/Caption";
 
  566            if (count(
$res->nodeset) == 1) {
 
  567                return $res->nodeset[0]->get_content();
 
  580            $path = 
"//PageContent[@HierId = '" . 
$hier_id . 
"']/Table/Caption";
 
  582            if (count(
$res->nodeset) == 1) {
 
  583                return $res->nodeset[0]->get_attribute(
"Align");
 
  598                array(
"Summary", 
"TableRow"),
 
  600                array(
"Align" => $a_align)
 
  612        if (
$node->has_attributes()) {
 
  613            foreach (
$node->attributes() as 
$n) {
 
  614                switch (strtolower(
$n->node_name())) {
 
  641        if (
$node->has_attributes()) {
 
  642            foreach (
$node->attributes() as 
$n) {
 
  643                switch (strtolower(
$n->node_name())) {
 
  645                    $par->set_attribute(
"Class", $this->
extractText($n));
 
  648                    $par->set_attribute(
"Width", $this->
extractText($n));
 
  663        if (
$node->has_child_nodes()) {
 
  664            foreach (
$node->child_nodes() as 
$n) {
 
  665                if (
$n->node_type() == XML_ELEMENT_NODE &&
 
  666                strcasecmp(
$n->node_name(), 
"td") == 0) {
 
  677        $aCell = $this->
addCell($aRow);
 
  679        $par->createAtNode($aCell);
 
  680        $par->setText($par->input2xml($this->extractText($cellNode)));
 
  681        $par->setCharacteristic(
"TableContent");
 
  682        $par->setLanguage(
$lng);
 
  688        $owner_document = 
$node->owner_document();
 
  689        $children = 
$node->child_nodes();
 
  690        $total_children = count($children);
 
  691        for (
$i = 0; 
$i < $total_children; 
$i++) {
 
  692            $cur_child_node = $children[
$i];
 
  693            $output .= $owner_document->dump_node($cur_child_node);
 
  707            $path = 
"//table[1] | //Table[1]";
 
  710            if (count(
$res->nodeset) == 0) {
 
  711                $error = 
"Could not find a table root node";
 
  715                for (
$i = 0; 
$i < count(
$res->nodeset); 
$i++) {
 
  720                    if (
$node->has_child_nodes()) {
 
  721                        foreach (
$node->child_nodes() as 
$n) {
 
  722                            if (
$n->node_type() == XML_ELEMENT_NODE &&
 
  723                            strcasecmp(
$n->node_name(), 
"tr") == 0) {
 
  734            foreach (
$error as $errorline) {    # Loop through all errors
 
  735                $errmsg .=  
"[" . $errorline[
'line'] . 
", " . $errorline[
'col'] . 
"]: " . $errorline[
'errormessage'] . 
" at Node '" . $errorline[
'nodename'] . 
"'<br />";
 
  741        if (empty($errmsg)) {
 
  754        $childs = $this->tab_node->child_nodes();
 
  755        foreach ($childs as $child) {
 
  756            if ($child->node_name() == 
"TableRow") {
 
  757                $gchilds = $child->child_nodes();
 
  758                foreach ($gchilds as $gchild) {
 
  759                    if ($gchild->node_name() == 
"TableData") {
 
  760                        $gchild->set_attribute(
"Class", $a_class);
 
  896        if (!empty($a_value)) {
 
  897            $this->tab_node->set_attribute($a_attr, $a_value);
 
  899            if ($this->tab_node->has_attribute($a_attr)) {
 
  900                $this->tab_node->remove_attribute($a_attr);
 
  912        if (is_object($this->tab_node)) {
 
  913            return  $this->tab_node->get_attribute($a_attr);
 
  923        return array(
"ed_insert_dtable", 
"ed_insert_atable",
"ed_new_row_after", 
"ed_new_row_before",
 
  924            "ed_new_col_after", 
"ed_new_col_before", 
"ed_delete_col",
 
  925            "ed_delete_row", 
"ed_edit_data", 
"ed_row_up", 
"ed_row_down",
 
  926            "ed_col_left", 
"ed_col_right");
 
  936    public static function handleCopiedContent(DOMDocument $a_domdoc, $a_self_ass = 
true, $a_clone_mobs = 
false)
 
  938        $xpath = 
new DOMXPath($a_domdoc);
 
  939        $nodes = $xpath->query(
"//Table");
 
  940        foreach ($nodes as 
$node) {
 
  941            $node->removeAttribute(
"Id");
 
An exception for terminatinating execution or to throw for unit testing.
static setFirstOptionalElement( $doc, $parent_node, $a_node_name, $a_successors, $a_content, $a_attributes, $a_remove_childs=true)
searches for an element $a_node_name within the childs of $parent_node if no node is found,...
static deleteAllChildsByName($a_parent, $a_node_names)
delete all childs of a node by names in $a_node_names
getHeaderCols()
Get header cols.
setCellPadding($a_padding)
set table cell padding
setFirstRowStyle($a_class)
Set first row td style.
setFooterCols($a_nr)
Set footer cols.
setTDSpans($a_colspans, $a_rowspans)
Set TDSpans.
& addCell(&$aRow, $a_data="", $a_lang="")
checkCellHidden($colspans, $rowspans, $x, $y)
Check hidden status.
setHeaderCols($a_nr)
Set header cols.
setFooterRows($a_nr)
Set footer rows.
getCellPadding()
get table cell padding
getFooterRows()
Get footer rows.
addRows($a_nr_rows, $a_nr_cols)
add rows to table
static handleCopiedContent(DOMDocument $a_domdoc, $a_self_ass=true, $a_clone_mobs=false)
Handle copied content.
getWidth()
get table width
importTableAttributes(&$node)
setHorizontalAlign($a_halign)
set horizontal align
static getLangVars()
Get lang vars needed for editing.
getAllCellAlignments()
Get all cell alignments.
setTableAttribute($a_attr, $a_value)
Set attribute of table tag.
makeEmptyCell($td_node)
Make cell empty.
getHeaderRows()
Get header rows.
setWidth($a_width)
set table width
setTemplate($a_template)
Set template.
setTDClass($a_hier_id, $a_class, $a_pc_id="")
set class of table data cell
create(&$a_pg_obj, $a_hier_id, $a_pc_id="")
setLanguage($a_lang)
set table language
importSpreadsheet($a_lang, $a_data)
import from table
setTDAlignment($a_hier_id, $a_class, $a_pc_id="")
set alignment of table data cell
setBorder($a_border)
set table border
getFooterCols()
Get footer cols.
setClass($a_class)
Set Style Class of table.
setCaption($a_content, $a_align)
set table caption
importCell($lng, &$cellNode, &$aRow)
getTableAttribute($a_attr)
Get table tag attribute.
importHtml($lng, $htmlTable)
getBorder()
get table border width
getTemplate()
Get template.
getHorizontalAlign()
get table cell padding
fixHideAndSpans()
Fix Hide and Spans.
getAllCellClasses()
Get all cell classes.
setCellSpacing($a_spacing)
set table cell spacing
importCellAttributes(&$node, &$par)
getAllCellSpans()
Get all cell spans.
init()
Init page content component.
getCaptionAlign()
get caption alignment (Top | Bottom)
getAllCellWidths()
Get all cell widhts.
setNode($a_node)
Set xml node of page content.
setTDWidth($a_hier_id, $a_width, $a_pc_id="")
set width of table data cell
getClass()
Get characteristic of section.
getLanguage()
get table language
getCellSpacing()
get table cell spacing
setHeaderRows($a_nr)
Set header rows.
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element)
getHierId()
Get hierarchical id.
setType($a_type)
Set Type.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\s+" &#(? foreach( $entity_files as $file) $output
xpath_eval($xpath_context, $eval_str, $contextnode=null)
domxml_open_mem($str, $mode=0, &$error=null)
xpath_new_context($dom_document)
const DOMXML_LOAD_PARSING
foreach($_POST as $key=> $value) $res