/** * Cleans up the media objects for all text fields in a test which are using an RTE field * * @access private */ function cleanupMediaobjectUsage() { include_once "./Services/RTE/classes/class.ilRTE.php"; $completecontent = ""; foreach ($this->getAllRTEContent() as $content) { $completecontent .= $content; } ilRTE::_cleanupMediaObjectUsage($completecontent, $this->getType() . ":html", $this->getId()); }
function savePageContentObject() { include_once "Services/XHTMLPage/classes/class.ilXHTMLPage.php"; include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php"; $xpage_id = ilContainer::_lookupContainerSetting($this->object->getId(), "xhtml_page"); /*include_once("./Services/Form/classes/class.ilFormPropertyGUI.php"); include_once("./Services/Form/classes/class.ilTextAreaInputGUI.php"); $ta = new ilTextAreaInputGUI(); $ta->setRteTagSet("extended_table_img"); $tags = $ta->getRteTagString();*/ //$text = ilUtil::stripSlashes($_POST["page_content"], // true, // $tags); $text = ilUtil::stripSlashes($_POST["page_content"], true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString()); if ($xpage_id > 0) { $xpage = new ilXHTMLPage($xpage_id); $xpage->setContent($text); $xpage->save(); } else { $xpage = new ilXHTMLPage(); $xpage->setContent($text); $xpage->save(); ilContainer::_writeContainerSetting($this->object->getId(), "xhtml_page", $xpage->getId()); } include_once "Services/RTE/classes/class.ilRTE.php"; ilRTE::_cleanupMediaObjectUsage($text, $this->object->getType() . ":html", $this->object->getId()); ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true); $this->ctrl->redirect($this, ""); }
/** * synchronises appearances of media objects in the question with media * object usage table */ function cleanupMediaObjectUsage() { $combinedtext = $this->getRTETextWithMediaObjects(); include_once "./Services/RTE/classes/class.ilRTE.php"; ilRTE::_cleanupMediaObjectUsage($combinedtext, "qpl:html", $this->getId()); }
/** * Saves a SurveyQuestion object to a database * * @param integer $original_id * @access public */ function saveToDb($original_id = "") { global $ilDB; // cleanup RTE images which are not inserted into the question text include_once "./Services/RTE/classes/class.ilRTE.php"; ilRTE::_cleanupMediaObjectUsage($this->getQuestiontext(), "spl:html", $this->getId()); $affectedRows = 0; if ($this->getId() == -1) { // Write new dataset $next_id = $ilDB->nextId('svy_question'); $affectedRows = $ilDB->insert("svy_question", array("question_id" => array("integer", $next_id), "questiontype_fi" => array("integer", $this->getQuestionTypeID()), "obj_fi" => array("integer", $this->getObjId()), "owner_fi" => array("integer", $this->getOwner()), "title" => array("text", $this->getTitle()), "label" => array("text", strlen($this->label) ? $this->label : null), "description" => array("text", $this->getDescription()), "author" => array("text", $this->getAuthor()), "questiontext" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestiontext(), 0)), "obligatory" => array("text", $this->getObligatory()), "complete" => array("text", $this->isComplete()), "created" => array("integer", time()), "original_id" => array("integer", $original_id ? $original_id : NULL), "tstamp" => array("integer", time()))); $this->setId($next_id); } else { // update existing dataset $affectedRows = $ilDB->update("svy_question", array("title" => array("text", $this->getTitle()), "label" => array("text", strlen($this->label) ? $this->label : null), "description" => array("text", $this->getDescription()), "author" => array("text", $this->getAuthor()), "questiontext" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestiontext(), 0)), "obligatory" => array("text", $this->getObligatory()), "complete" => array("text", $this->isComplete()), "tstamp" => array("integer", time())), array("question_id" => array("integer", $this->getId()))); } // #12420 $set = $ilDB->query("SELECT survey_id FROM svy_svy" . " WHERE obj_fi = " . $ilDB->quote($this->getObjId(), "integer")); $survey_fi = $ilDB->fetchAssoc($set); $survey_fi = $survey_fi["survey_id"]; // pool? if ($survey_fi) { $set = $ilDB->query("SELECT obligatory FROM svy_qst_oblig" . " WHERE survey_fi = " . $ilDB->quote($survey_fi, "integer") . " AND question_fi = " . $ilDB->quote($this->getId(), "integer")); $has_obligatory_states_entry = (bool) $ilDB->numRows($set); $is_obligatory = $ilDB->fetchAssoc($set); $is_obligatory = (bool) $is_obligatory["obligatory"]; if (!$this->getObligatory()) { if ($has_obligatory_states_entry) { $ilDB->manipulate("DELETE FROM svy_qst_oblig" . " WHERE survey_fi = " . $ilDB->quote($survey_fi, "integer") . " AND question_fi = " . $ilDB->quote($this->getId(), "integer")); } } else { if ($this->getObligatory()) { if (!$has_obligatory_states_entry) { // ilObjSurvey::setObligatoryStates() $next_id = $ilDB->nextId('svy_qst_oblig'); $affectedRows = $ilDB->manipulateF("INSERT INTO svy_qst_oblig (question_obligatory_id, survey_fi, question_fi, " . "obligatory, tstamp) VALUES (%s, %s, %s, %s, %s)", array('integer', 'integer', 'integer', 'text', 'integer'), array($next_id, $survey_fi, $this->getId(), 1, time())); } else { if (!$is_obligatory) { $ilDB->manipulate("UPDATE svy_qst_oblig" . " SET obligatory = " . $ilDB->quote(1, "integer") . " WHERE survey_fi = " . $ilDB->quote($survey_fi, "integer") . " AND question_fi = " . $ilDB->quote($this->getId(), "integer")); } } } } } return $affectedRows; }
/** * Saves a SurveyQuestion object to a database * * @param integer $original_id * @access public */ function saveToDb($original_id = "") { global $ilDB; // cleanup RTE images which are not inserted into the question text include_once "./Services/RTE/classes/class.ilRTE.php"; ilRTE::_cleanupMediaObjectUsage($this->getQuestiontext(), "spl:html", $this->getId()); $affectedRows = 0; if ($this->getId() == -1) { // Write new dataset $next_id = $ilDB->nextId('svy_question'); $affectedRows = $ilDB->insert("svy_question", array("question_id" => array("integer", $next_id), "questiontype_fi" => array("integer", $this->getQuestionTypeID()), "obj_fi" => array("integer", $this->getObjId()), "owner_fi" => array("integer", $this->getOwner()), "title" => array("text", $this->getTitle()), "label" => array("text", strlen($this->label) ? $this->label : null), "description" => array("text", $this->getDescription()), "author" => array("text", $this->getAuthor()), "questiontext" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestiontext(), 0)), "obligatory" => array("text", $this->getObligatory()), "complete" => array("text", $this->isComplete()), "created" => array("integer", time()), "original_id" => array("integer", $original_id ? $original_id : NULL), "tstamp" => array("integer", time()))); $this->setId($next_id); } else { // update existing dataset $affectedRows = $ilDB->update("svy_question", array("title" => array("text", $this->getTitle()), "label" => array("text", strlen($this->label) ? $this->label : null), "description" => array("text", $this->getDescription()), "author" => array("text", $this->getAuthor()), "questiontext" => array("clob", ilRTE::_replaceMediaObjectImageSrc($this->getQuestiontext(), 0)), "obligatory" => array("text", $this->getObligatory()), "complete" => array("text", $this->isComplete()), "tstamp" => array("integer", time())), array("question_id" => array("integer", $this->getId()))); } return $affectedRows; }