/**
  * Save input coming from ajax
  *
  * @param
  * @return
  */
 function saveJS($a_pg_obj, $a_content, $a_char, $a_pc_id, $a_insert_at = "")
 {
     global $ilUser;
     $t = self::handleAjaxContent($a_content);
     if ($text === false) {
         return false;
     }
     $pc_id = explode(":", $a_pc_id);
     $insert_at = explode(":", $a_insert_at);
     $t_id = explode(":", $t["id"]);
     // insert new paragraph
     if ($a_insert_at != "") {
         $par = new ilPCParagraph($this->dom);
         $par->create($a_pg_obj, $insert_at[0], $insert_at[1]);
     } else {
         $par = $a_pg_obj->getContentObject($pc_id[0], $pc_id[1]);
     }
     if ($a_insert_at != "") {
         $pc_id = $a_pg_obj->generatePCId();
         $par->writePCId($pc_id);
         $this->inserted_pc_id = $pc_id;
     } else {
         $this->inserted_pc_id = $pc_id[1];
     }
     $par->setLanguage($ilUser->getLanguage());
     $par->setCharacteristic($t["class"]);
     $t2 = $par->input2xml($t["text"], true, false);
     $t2 = ilPCParagraph::handleAjaxContentPost($t2);
     $updated = $par->setText($t2, true);
     if ($updated !== true) {
         echo $updated;
         exit;
         return false;
     }
     $updated = $a_pg_obj->update();
     return $updated;
 }
 /**
  * Update via JavaScript
  */
 function updateJS()
 {
     global $ilBench, $lng, $ilCtrl;
     if ($_POST["cancel_update"]) {
         //			$this->ctrl->redirect($this, "editData");
         $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
     }
     // handle input data
     include_once "./Services/COPage/classes/class.ilPCParagraph.php";
     include_once "./Services/COPage/classes/class.ilPCParagraphGUI.php";
     $data = array();
     foreach ($_POST as $k => $content) {
         if (substr($k, 0, 5) != "cell_") {
             continue;
         }
         // determine cell content
         $div = ilUtil::stripSlashes($content, false);
         $p1 = strpos($div, '>');
         $div = substr($div, $p1 + 1);
         $div = "<div class='ilc_text_block_TableContent'>" . $div;
         $text = ilPCParagraph::handleAjaxContent($div);
         if ($text === false) {
             $ilCtrl->returnToParent($this, "jump" . $this->hier_id);
         }
         $text = $text["text"];
         $text = ilPCParagraph::_input2xml($text, $this->content_obj->getLanguage(), true, false);
         $text = ilPCParagraph::handleAjaxContentPost($text);
         // set content in data array
         $id = explode("_", $k);
         $data[(int) $id[1]][(int) $id[2]] = $text;
     }
     // update data
     $this->updated = $this->content_obj->setData($data);
     if ($this->updated !== true) {
         $this->editData();
         return;
     }
     $this->updated = $this->pg_obj->update();
     // perform table action? (move...?)
     //$this->update(false);
     $this->pg_obj->addHierIDs();
     if ($_POST["tab_cmd"] != "") {
         $cell_hier_id = $_POST["tab_cmd_type"] == "col" ? $this->hier_id . "_1_" . ($_POST["tab_cmd_id"] + 1) : $this->hier_id . "_" . ($_POST["tab_cmd_id"] + 1) . "_1";
         $cell_obj = $this->pg_obj->getContentObject($cell_hier_id);
         if (is_object($cell_obj)) {
             $cell_obj->{$_POST}["tab_cmd"]();
             $_SESSION["il_pg_error"] = $this->pg_obj->update();
         }
     }
     ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
     if ($_POST["save_return"]) {
         $this->ctrl->returnToParent($this, "jump" . $this->hier_id);
     } else {
         $this->ctrl->redirect($this, "editData");
     }
 }