/**
  * Edit data of table
  */
 function editData()
 {
     global $lng, $ilCtrl;
     if (!ilPageEditorGUI::_doJSEditing()) {
         return $this->editDataCl();
     }
     //var_dump($_GET);
     //var_dump($_POST);
     $this->setTabs();
     $this->displayValidationError();
     include_once "./Services/COPage/classes/class.ilPCParagraph.php";
     $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tabledata2.html", "Services/COPage");
     $dtpl = $this->tpl;
     //$dtpl = new ilTemplate("tpl.tabledata.html", true, true, "Services/COPage");
     $dtpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "tableAction"));
     //		$dtpl->setVariable("BB_MENU", $this->getBBMenu("cell_0_0"));
     //		$this->tpl->addJavascript("./Services/COPage/phpBB/3_0_5/editor.js");
     //		$this->tpl->addJavascript("./Services/COPage/js/page_editing.js");
     $this->tpl->setVariable("WYSIWYG_ACTION", $ilCtrl->getFormAction($this, "updateJS"));
     // get all rows
     $xpc = xpath_new_context($this->dom);
     $path = "//PageContent[@HierId='" . $this->getHierId() . "']" . "/Table/TableRow";
     $res =& xpath_eval($xpc, $path);
     for ($i = 0; $i < count($res->nodeset); $i++) {
         $xpc2 = xpath_new_context($this->dom);
         $path2 = "//PageContent[@HierId='" . $this->getHierId() . "']" . "/Table/TableRow[{$i}+1]/TableData";
         $res2 =& xpath_eval($xpc2, $path2);
         // if this is the first row -> col icons
         if ($i == 0) {
             for ($j = 0; $j < count($res2->nodeset); $j++) {
                 if ($j == 0) {
                     $dtpl->touchBlock("empty_td");
                 }
                 if ($j == 0) {
                     if (count($res2->nodeset) == 1) {
                         $move_type = "none";
                     } else {
                         $move_type = "forward";
                     }
                 } else {
                     if ($j == count($res2->nodeset) - 1) {
                         $move_type = "backward";
                     } else {
                         $move_type = "both";
                     }
                 }
                 $dtpl->setCurrentBlock("col_icon");
                 $dtpl->setVariable("COL_ICON_ALT", $lng->txt("content_column"));
                 $dtpl->setVariable("COL_ICON", ilUtil::getImagePath("col.png"));
                 $dtpl->setVariable("COL_ONCLICK", "COL_" . $move_type);
                 $dtpl->setVariable("NR", $j);
                 $dtpl->parseCurrentBlock();
             }
             $dtpl->setCurrentBlock("row");
             $dtpl->parseCurrentBlock();
         }
         for ($j = 0; $j < count($res2->nodeset); $j++) {
             // first col: row icons
             if ($j == 0) {
                 if ($i == 0) {
                     if (count($res->nodeset) == 1) {
                         $move_type = "none";
                     } else {
                         $move_type = "forward";
                     }
                 } else {
                     if ($i == count($res->nodeset) - 1) {
                         $move_type = "backward";
                     } else {
                         $move_type = "both";
                     }
                 }
                 $dtpl->setCurrentBlock("row_icon");
                 $dtpl->setVariable("ROW_ICON_ALT", $lng->txt("content_row"));
                 $dtpl->setVariable("ROW_ICON", ilUtil::getImagePath("row.png"));
                 $dtpl->setVariable("ROW_ONCLICK", "ROW_" . $move_type);
                 $dtpl->setVariable("NR", $i);
                 $dtpl->parseCurrentBlock();
             }
             // cell
             if ($res2->nodeset[$j]->get_attribute("Hidden") != "Y") {
                 $dtpl->setCurrentBlock("cell");
                 if (is_array($_POST["cmd"]) && key($_POST["cmd"]) == "update") {
                     $s_text = ilUtil::stripSlashes("cell_" . $i . "_" . $j, false);
                 } else {
                     $s_text = ilPCParagraph::xml2output($this->content_obj->getCellText($i, $j), true, false);
                     include_once "./Services/COPage/classes/class.ilPCParagraphGUI.php";
                     $s_text = ilPCParagraphGUI::xml2outputJS($s_text, "TableContent", $this->content_obj->readPCId() . "_" . $i . "_" . $j);
                 }
                 $dtpl->setVariable("PAR_TA_NAME", "cell[" . $i . "][" . $j . "]");
                 $dtpl->setVariable("PAR_TA_ID", "cell_" . $i . "_" . $j);
                 $dtpl->setVariable("PAR_TA_CONTENT", $s_text);
                 $cs = $res2->nodeset[$j]->get_attribute("ColSpan");
                 $rs = $res2->nodeset[$j]->get_attribute("RowSpan");
                 $dtpl->setVariable("WIDTH", "140");
                 $dtpl->setVariable("HEIGHT", "80");
                 if ($cs > 1) {
                     $dtpl->setVariable("COLSPAN", 'colspan="' . $cs . '"');
                     $dtpl->setVariable("WIDTH", 140 + ($cs - 1) * 146);
                 }
                 if ($rs > 1) {
                     $dtpl->setVariable("ROWSPAN", 'rowspan="' . $rs . '"');
                     $dtpl->setVariable("HEIGHT", 80 + ($rs - 1) * 86);
                 }
                 $dtpl->parseCurrentBlock();
             }
         }
         $dtpl->setCurrentBlock("row");
         $dtpl->parseCurrentBlock();
     }
     // init menues
     $types = array("row", "col");
     $moves = array("none", "backward", "both", "forward");
     $commands = array("row" => array("newRowAfter" => "cont_ed_new_row_after", "newRowBefore" => "cont_ed_new_row_before", "moveRowUp" => "cont_ed_row_up", "moveRowDown" => "cont_ed_row_down", "deleteRow" => "cont_ed_delete_row"), "col" => array("newColAfter" => "cont_ed_new_col_after", "newColBefore" => "cont_ed_new_col_before", "moveColLeft" => "cont_ed_col_left", "moveColRight" => "cont_ed_col_right", "deleteCol" => "cont_ed_delete_col"));
     foreach ($types as $type) {
         foreach ($moves as $move) {
             foreach ($commands[$type] as $command => $lang_var) {
                 if ($move == "none" && substr($command, 0, 4) == "move") {
                     continue;
                 }
                 if ($move == "backward" && in_array($command, array("movedown", "moveright")) || $move == "forward" && in_array($command, array("moveup", "moveleft"))) {
                     continue;
                 }
                 $this->tpl->setCurrentBlock("menu_item");
                 $this->tpl->setVariable("MENU_ITEM_TITLE", $lng->txt($lang_var));
                 $this->tpl->setVariable("CMD", $command);
                 $this->tpl->setVariable("TYPE", $type);
                 $this->tpl->parseCurrentBlock();
             }
             $this->tpl->setCurrentBlock("menu");
             $this->tpl->setVariable("TYPE", $type);
             $this->tpl->setVariable("MOVE", $move);
             $this->tpl->parseCurrentBlock();
         }
     }
     $this->tpl->setVariable("FORMACTION2", $ilCtrl->getFormAction($this, "tableAction"));
     $this->tpl->setVariable("TXT_ACTION", $this->lng->txt("cont_table"));
     // js editing preparation
     include_once "./Services/YUI/classes/class.ilYuiUtil.php";
     ilYuiUtil::initDragDrop();
     ilYuiUtil::initConnection();
     ilYuiUtil::initPanel(false);
     $GLOBALS["tpl"]->addJavascript("Services/RTE/tiny_mce_3_3_9_2/il_tiny_mce_src.js");
     $GLOBALS["tpl"]->addJavaScript("./Services/COPage/js/ilcopagecallback.js");
     $GLOBALS["tpl"]->addJavascript("Services/COPage/js/page_editing.js");
     $GLOBALS["tpl"]->addOnloadCode("var preloader = new Image();\n\t\t\tpreloader.src = './templates/default/images/loader.gif';\n\t\t\tilCOPage.setContentCss('" . ilObjStyleSheet::getContentStylePath((int) $this->getStyleId()) . ", " . ilUtil::getStyleSheetLocation() . ", ./Services/COPage/css/tiny_extra.css');\n\t\t\tilCOPage.editTD('cell_0_0');\n\t\t\t\t");
     $this->tpl->setVariable("IL_TINY_MENU", ilPageObjectGUI::getTinyMenu($this->pg_obj->getParentType(), false, $this->pg_obj->getParentType() == "wpg", false, $this->getStyleId(), false, true));
 }