/** * Adds support for an RTE in an ILIAS form * * Adds support for an RTE in an ILIAS form * * @param string $a_module Module or object which should use the HTML tags * @access public */ function addRTESupport($obj_id, $obj_type, $a_module = "", $allowFormElements = FALSE, $cfg_template = null, $hide_switch = false) { global $ilBrowser; include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php"; /* if (array_key_exists("show_rte", $_POST)) { ilObjAdvancedEditing::_setRichTextEditorUserState($_POST["show_rte"]); } */ if ($ilBrowser->isMobile()) { ilObjAdvancedEditing::_setRichTextEditorUserState(0); } else { ilObjAdvancedEditing::_setRichTextEditorUserState(1); } include_once "./Services/UICore/classes/class.ilTemplate.php"; if (ilObjAdvancedEditing::_getRichTextEditorUserState() != 0 && strcmp(ilObjAdvancedEditing::_getRichTextEditor(), "0") != 0) { $tpl = new ilTemplate($cfg_template === null ? "tpl.tinymce.html" : $cfg_template, true, true, "Services/RTE"); $this->handleImgContextMenuItem($tpl); $tags =& ilObjAdvancedEditing::_getUsedHTMLTags($a_module); if ($allowFormElements) { $tpl->touchBlock("formelements"); } $tpl->setCurrentBlock("tinymce"); $tpl->setVariable("JAVASCRIPT_LOCATION", "./Services/RTE/tiny_mce" . $this->vd . "/tiny_mce.js"); include_once "./Services/Object/classes/class.ilObject.php"; $tpl->setVariable("OBJ_ID", $obj_id); $tpl->setVariable("OBJ_TYPE", $obj_type); $tpl->setVariable("CLIENT_ID", CLIENT_ID); $tpl->setVariable("SESSION_ID", $_COOKIE["PHPSESSID"]); $tpl->setVariable("BLOCKFORMATS", $this->_buildAdvancedBlockformatsFromHTMLTags($tags)); $tpl->setVariable("VALID_ELEMENTS", $this->_getValidElementsFromHTMLTags($tags)); $buttons_1 = $this->_buildAdvancedButtonsFromHTMLTags(1, $tags); $buttons_2 = $this->_buildAdvancedButtonsFromHTMLTags(2, $tags) . ',' . $this->_buildAdvancedTableButtonsFromHTMLTags($tags) . ($this->getStyleSelect() ? ',styleselect' : ''); $buttons_3 = $this->_buildAdvancedButtonsFromHTMLTags(3, $tags); $tpl->setVariable('BUTTONS_1', self::_removeRedundantSeparators($buttons_1)); $tpl->setVariable('BUTTONS_2', self::_removeRedundantSeparators($buttons_2)); $tpl->setVariable('BUTTONS_3', self::_removeRedundantSeparators($buttons_3)); $tpl->setVariable("ADDITIONAL_PLUGINS", join(",", $this->plugins)); include_once "./Services/Utilities/classes/class.ilUtil.php"; //$tpl->setVariable("STYLESHEET_LOCATION", $this->getContentCSS()); $tpl->setVariable("STYLESHEET_LOCATION", ilUtil::getNewContentStyleSheetLocation() . "," . ilUtil::getStyleSheetLocation("output", "delos.css")); $tpl->setVariable("LANG", $this->_getEditorLanguage()); if ($this->getRTERootBlockElement() !== null) { $tpl->setVariable('FORCED_ROOT_BLOCK', $this->getRTERootBlockElement()); } $tpl->parseCurrentBlock(); $this->tpl->setVariable("CONTENT_BLOCK", $tpl->get()); } /* if (!$hide_switch && strcmp(ilObjAdvancedEditing::_getRichTextEditor(), "0") != 0) { $tpl = new ilTemplate("tpl.rte.switch.html", true, true, "Services/RTE"); $tpl->setVariable("FORMACTION", $this->ctrl->getFormActionByClass($this->ctrl->getCmdClass()), $this->ctrl->getCmd()); $tpl->setVariable("TEXT_SET_MODE", $this->lng->txt("set_edit_mode")); $tpl->setVariable("TEXT_ENABLED", $this->lng->txt("rte_editor_enabled")); $tpl->setVariable("TEXT_DISABLED", $this->lng->txt("rte_editor_disabled")); if (ilObjAdvancedEditing::_getRichTextEditorUserState() != 0) { $tpl->setVariable("SELECTED_ENABLED", " selected=\"selected\""); } $tpl->setVariable("BTN_COMMAND", $this->ctrl->getCmd()); $this->tpl->setVariable("RTE_SWITCH", $tpl->get()); } */ }
private function initReplyEditForm() { /** * @var $ilUser ilObjUser * @var $rbacsystem ilRbacSystem * @var $ilSetting ilSetting */ global $ilUser, $rbacsystem, $ilSetting; // init objects $oForumObjects = $this->getForumObjects(); /** * @var $frm ilForum */ $frm = $oForumObjects['frm']; /** * @var $oFDForum ilFileDataForum */ $oFDForum = $oForumObjects['file_obj']; require_once 'Services/Form/classes/class.ilPropertyFormGUI.php'; $this->replyEditForm = new ilPropertyFormGUI(); $this->replyEditForm->setTableWidth('100%'); // titel if ($_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply') { $this->ctrl->setParameter($this, 'action', 'ready_showreply'); } else { $this->ctrl->setParameter($this, 'action', 'ready_showedit'); } // form action $this->ctrl->setParameter($this, 'pos_pk', $this->objCurrentPost->getId()); $this->ctrl->setParameter($this, 'thr_pk', $this->objCurrentPost->getThreadId()); $this->ctrl->setParameter($this, 'offset', (int) $_GET['offset']); $this->ctrl->setParameter($this, 'orderby', $_GET['orderby']); $this->replyEditForm->setFormAction($this->ctrl->getFormAction($this, 'savePost', $this->objCurrentPost->getId())); $this->ctrl->clearParameters($this); if ($_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply') { $this->replyEditForm->setTitle($this->lng->txt('forums_your_reply')); } else { $this->replyEditForm->setTitle($this->lng->txt('forums_edit_post')); } // alias if ($this->objProperties->isAnonymized() && in_array($_GET['action'], array('showreply', 'ready_showreply'))) { $oAnonymousNameGUI = new ilTextInputGUI($this->lng->txt('forums_your_name'), 'alias'); $oAnonymousNameGUI->setMaxLength(64); $oAnonymousNameGUI->setInfo($this->lng->txt('forums_use_alias')); $this->replyEditForm->addItem($oAnonymousNameGUI); } // subject $oSubjectGUI = new ilTextInputGUI($this->lng->txt('forums_subject'), 'subject'); $oSubjectGUI->setMaxLength(64); $oSubjectGUI->setRequired(true); if ($this->objProperties->getSubjectSetting() == 'empty_subject') { $oSubjectGUI->setInfo($this->lng->txt('enter_new_subject')); } $this->replyEditForm->addItem($oSubjectGUI); // post $oPostGUI = new ilTextAreaInputGUI($_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply' ? $this->lng->txt('forums_your_reply') : $this->lng->txt('forums_edit_post'), 'message'); $oPostGUI->setRequired(true); $oPostGUI->setCols(50); $oPostGUI->setRows(15); $oPostGUI->setUseRte(true); $oPostGUI->addPlugin('latex'); $oPostGUI->addButton('latex'); $oPostGUI->addButton('pastelatex'); $oPostGUI->addPlugin('ilfrmquote'); //$oPostGUI->addPlugin('code'); if ($_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply') { $oPostGUI->addButton('ilFrmQuoteAjaxCall'); } $oPostGUI->removePlugin('advlink'); $oPostGUI->setRTERootBlockElement(''); $oPostGUI->usePurifier(true); $oPostGUI->disableButtons(array('charmap', 'undo', 'redo', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'anchor', 'fullscreen', 'cut', 'copy', 'paste', 'pastetext', 'formatselect')); if ($_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply') { $oPostGUI->setRTESupport($ilUser->getId(), 'frm~', 'frm_post', 'tpl.tinymce_frm_post.html', false, '3.4.7'); } else { $oPostGUI->setRTESupport($this->objCurrentPost->getId(), 'frm', 'frm_post', 'tpl.tinymce_frm_post.html', false, '3.4.7'); } // purifier require_once 'Services/Html/classes/class.ilHtmlPurifierFactory.php'; $oPostGUI->setPurifier(ilHtmlPurifierFactory::_getInstanceByType('frm_post')); $this->replyEditForm->addItem($oPostGUI); // notification only if gen. notification is disabled and forum isn't anonymous include_once 'Services/Mail/classes/class.ilMail.php'; $umail = new ilMail($ilUser->getId()); if ($rbacsystem->checkAccess('internal_mail', $umail->getMailObjectReferenceId()) && !$frm->isThreadNotificationEnabled($ilUser->getId(), $this->objCurrentPost->getThreadId()) && !$this->objProperties->isAnonymized()) { $oNotificationGUI = new ilCheckboxInputGUI('', 'notify'); $oNotificationGUI->setInfo($this->lng->txt('forum_notify_me')); $this->replyEditForm->addItem($oNotificationGUI); } // attachments $oFileUploadGUI = new ilFileWizardInputGUI($this->lng->txt('forums_attachments_add'), 'userfile'); $oFileUploadGUI->setFilenames(array(0 => '')); $this->replyEditForm->addItem($oFileUploadGUI); require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php'; if ($ilUser->isAnonymous() && !$ilUser->isCaptchaVerified() && ilCaptchaUtil::isActiveForForum()) { require_once 'Services/Captcha/classes/class.ilCaptchaInputGUI.php'; $captcha = new ilCaptchaInputGUI($this->lng->txt('cont_captcha_code'), 'captcha_code'); $captcha->setRequired(true); $this->replyEditForm->addItem($captcha); } // edit attachments if (count($oFDForum->getFilesOfPost()) && ($_GET['action'] == 'showedit' || $_GET['action'] == 'ready_showedit')) { $oExistingAttachmentsGUI = new ilCheckboxGroupInputGUI($this->lng->txt('forums_delete_file'), 'del_file'); foreach ($oFDForum->getFilesOfPost() as $file) { $oAttachmentGUI = new ilCheckboxInputGUI($file['name'], 'del_file'); $oAttachmentGUI->setValue($file['md5']); $oExistingAttachmentsGUI->addOption($oAttachmentGUI); } $this->replyEditForm->addItem($oExistingAttachmentsGUI); } // buttons $this->replyEditForm->addCommandButton('savePost', $this->lng->txt('create')); if ($_GET['action'] == 'showreply' || $_GET['action'] == 'ready_showreply') { include_once 'Services/RTE/classes/class.ilRTE.php'; $rtestring = ilRTE::_getRTEClassname(); if (array_key_exists('show_rte', $_POST)) { ilObjAdvancedEditing::_setRichTextEditorUserState($_POST['show_rte']); } if (strtolower($rtestring) != 'iltinymce' || !ilObjAdvancedEditing::_getRichTextEditorUserState()) { $this->replyEditForm->addCommandButton('quotePost', $this->lng->txt('forum_add_quote')); } } $this->replyEditForm->addCommandButton('cancelPost', $this->lng->txt('cancel')); }