diff --git a/common/js/common.js b/common/js/common.js index d5db12795..2f1080ea9 100644 --- a/common/js/common.js +++ b/common/js/common.js @@ -653,6 +653,7 @@ function doDocumentPreview(obj) { '
' ).appendTo(document.body); diff --git a/modules/comment/comment.controller.php b/modules/comment/comment.controller.php index b0530fda7..897c75059 100644 --- a/modules/comment/comment.controller.php +++ b/modules/comment/comment.controller.php @@ -358,7 +358,9 @@ class commentController extends comment { return new Object(-1, 'msg_invalid_document'); } - + + // creat the comment model object + $oCommentModel = getModel('comment'); // get a object of document model $oDocumentModel = getModel('document'); @@ -436,30 +438,9 @@ class commentController extends comment // if use editor of nohtml, Remove HTML tags from the contents. if(!$manual_inserted) { - $editor_config = getModel('editor')->getEditorConfig($obj->module_srl); - if (strpos($editor_config->sel_comment_editor_colorset, 'nohtml') !== false) - { - $is_html_content = false; - } - elseif ($obj->use_editor === 'Y' || $obj->use_html === 'Y') - { - $is_html_content = true; - } - elseif ($obj->use_editor === 'N' || $obj->use_html === 'N') - { - $is_html_content = false; - } - else - { - $is_html_content = is_html_content($obj->content); - } - - if (!$is_html_content) - { - $obj->content = nl2br($obj->use_html === 'Y' ? $obj->content : escape($obj->content, false)); - } + $obj->content = getModel('editor')->converter($obj, 'comment'); } - + if(!$obj->regdate) { $obj->regdate = date("YmdHis"); @@ -558,10 +539,7 @@ class commentController extends comment $oDB->rollback(); return $output; } - - // creat the comment model object - $oCommentModel = getModel('comment'); - + // get the number of all comments in the posting $comment_count = $oCommentModel->getCommentCount($document_srl); @@ -806,34 +784,13 @@ class commentController extends comment { return new Object(-1, 'msg_empty_content'); } - + // if use editor of nohtml, Remove HTML tags from the contents. if(!$manual_updated) { - $editor_config = getModel('editor')->getEditorConfig($obj->module_srl); - if (strpos($editor_config->sel_comment_editor_colorset, 'nohtml') !== false) - { - $is_html_content = false; - } - elseif ($obj->use_editor === 'Y' || $obj->use_html === 'Y') - { - $is_html_content = true; - } - elseif ($obj->use_editor === 'N' || $obj->use_html === 'N') - { - $is_html_content = false; - } - else - { - $is_html_content = is_html_content($obj->content); - } - - if (!$is_html_content) - { - $obj->content = nl2br($obj->use_html === 'Y' ? $obj->content : escape($obj->content, false)); - } + $obj->content = getModel('editor')->converter($obj, 'comment'); } - + // remove iframe and script if not a top administrator on the session if($logged_info->is_admin != 'Y') { diff --git a/modules/comment/comment.model.php b/modules/comment/comment.model.php index 746d521cc..d4a942969 100644 --- a/modules/comment/comment.model.php +++ b/modules/comment/comment.model.php @@ -951,7 +951,7 @@ class commentModel extends comment return $comment_config; } - + /** * Return a list of voting member * @return void diff --git a/modules/document/document.controller.php b/modules/document/document.controller.php index bd78e0054..6d5d7943c 100644 --- a/modules/document/document.controller.php +++ b/modules/document/document.controller.php @@ -457,30 +457,9 @@ class documentController extends document // if use editor of nohtml, Remove HTML tags from the contents. if(!$manual_inserted) { - $editor_config = getModel('editor')->getEditorConfig($obj->module_srl); - if (strpos($editor_config->sel_editor_colorset, 'nohtml') !== false) - { - $is_html_content = false; - } - elseif ($obj->use_editor === 'Y' || $obj->use_html === 'Y') - { - $is_html_content = true; - } - elseif ($obj->use_editor === 'N' || $obj->use_html === 'N') - { - $is_html_content = false; - } - else - { - $is_html_content = is_html_content($obj->content); - } - - if (!$is_html_content) - { - $obj->content = nl2br($obj->use_html === 'Y' ? $obj->content : escape($obj->content, false)); - } + $obj->content = getModel('editor')->converter($obj, 'document'); } - + // Remove iframe and script if not a top adminisrator in the session. if($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content); // An error appears if both log-in info and user name don't exist. @@ -716,30 +695,9 @@ class documentController extends document // if use editor of nohtml, Remove HTML tags from the contents. if(!$manual_updated) { - $editor_config = getModel('editor')->getEditorConfig($obj->module_srl); - if (strpos($editor_config->sel_editor_colorset, 'nohtml') !== false) - { - $is_html_content = false; - } - elseif ($obj->use_editor === 'Y' || $obj->use_html === 'Y') - { - $is_html_content = true; - } - elseif ($obj->use_editor === 'N' || $obj->use_html === 'N') - { - $is_html_content = false; - } - else - { - $is_html_content = is_html_content($obj->content); - } - - if (!$is_html_content) - { - $obj->content = nl2br($obj->use_html === 'Y' ? $obj->content : escape($obj->content, false)); - } + $obj->content = getModel('editor')->converter($obj, 'document'); } - + // Change not extra vars but language code of the original document if document's lang_code is different from author's setting. if($source_obj->get('lang_code') != Context::getLangType()) { diff --git a/modules/document/document.model.php b/modules/document/document.model.php index 1a500b7d2..194e2bdb0 100644 --- a/modules/document/document.model.php +++ b/modules/document/document.model.php @@ -1246,7 +1246,7 @@ class documentModel extends document return array_flip($this->getStatusList()); else return $lang->status_name_list; } - + /** * Setting sort index * @param object $obj diff --git a/modules/document/document.view.php b/modules/document/document.view.php index f1d6bb220..987445ca2 100644 --- a/modules/document/document.view.php +++ b/modules/document/document.view.php @@ -61,11 +61,21 @@ class documentView extends document return new Object(-1, 'msg_invalid_request'); } + $content = Context::get('content'); + if(Context::get('logged_info')->is_admin != 'Y') { - Context::set('content', removeHackTag(Context::get('content'))); + $content = removeHackTag($content); } + // Editor converter + $obj = new stdClass; + $obj->content = $content; + $obj->module_srl = getModel('module')->getModuleInfoByMid(Context::get('mid'))->module_srl; + $content = getModel('editor')->converter($obj, 'document'); + + Context::set('content', $content); + $this->setTemplatePath($this->module_path.'tpl'); $this->setTemplateFile('preview_page'); Context::set('layout', 'none'); diff --git a/modules/editor/conf/module.xml b/modules/editor/conf/module.xml index 73470d2f0..10d074053 100644 --- a/modules/editor/conf/module.xml +++ b/modules/editor/conf/module.xml @@ -5,7 +5,7 @@" + String($(this).val()).escape().replace(/\r?\n/g, "
\n") + "
"); - }); - - // Add use_editor and use_html fields to parent form. - var parentform = $('#textarea_instance_{$editor_sequence}').parents('form'); - var use_editor = parentform.find("input[name='use_editor']"); - var use_html = parentform.find("input[name='use_html']"); - if (use_editor.size()) { - use_editor.val("Y"); - } else { - parentform.append(''); - } - if (use_html.size()) { - use_html.val("Y"); - } else { - parentform.append(''); - } - + // Load + editorTextarea({$editor_sequence}); });{$XE_VALIDATOR_MESSAGE}
-{$lang->about_enable_autosave}
+{$lang->about_enable_autosave}
+