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 @@ - + diff --git a/modules/editor/editor.admin.controller.php b/modules/editor/editor.admin.controller.php index b0a5ccbb9..b3584c268 100644 --- a/modules/editor/editor.admin.controller.php +++ b/modules/editor/editor.admin.controller.php @@ -161,8 +161,8 @@ class editorAdminController extends editor $config->mobile_comment_editor_toolbar = $configVars->mobile_comment_editor_toolbar; $config->mobile_comment_editor_toolbar_hide = $configVars->mobile_comment_editor_toolbar_hide === 'Y' ? 'Y' : 'N'; $config->content_style = $configVars->content_style; - $config->sel_editor_colorset= $configVars->sel_editor_colorset; - $config->sel_comment_editor_colorset= $configVars->sel_comment_editor_colorset; + $config->sel_editor_colorset = $configVars->sel_editor_colorset; + $config->sel_comment_editor_colorset = $configVars->sel_comment_editor_colorset; if ($configVars->font_defined === 'Y') { @@ -227,6 +227,8 @@ class editorAdminController extends editor $config->content_paragraph_spacing = ctype_digit($config->content_paragraph_spacing) ? ($config->content_paragraph_spacing . 'px') : $config->content_paragraph_spacing; $config->content_word_break = $configVars->content_word_break; $config->content_word_break = in_array($config->content_word_break, array('normal', 'keep-all', 'break-all', 'none')) ? $config->content_word_break : 'normal'; + $config->enable_autosave = $configVars->enable_autosave ?: 'Y'; + $config->allow_html = $configVars->allow_html ?: 'Y'; $config->autoinsert_image = $configVars->autoinsert_image; $config->autoinsert_image = in_array($config->autoinsert_image, array('paragraph', 'inline', 'none')) ? $config->autoinsert_image : 'paragraph'; diff --git a/modules/editor/editor.class.php b/modules/editor/editor.class.php index ebb9d945f..2f526f885 100644 --- a/modules/editor/editor.class.php +++ b/modules/editor/editor.class.php @@ -45,6 +45,8 @@ class editor extends ModuleObject 'content_line_height' => '160%', 'content_paragraph_spacing' => '0px', 'content_word_break' => 'normal', + 'enable_autosave' => 'Y', + 'allow_html' => 'Y', 'autoinsert_image' => 'paragraph', 'additional_css' => array(), 'additional_mobile_css' => array(), diff --git a/modules/editor/editor.controller.php b/modules/editor/editor.controller.php index 89b22b672..2ceb16845 100644 --- a/modules/editor/editor.controller.php +++ b/modules/editor/editor.controller.php @@ -147,21 +147,21 @@ class editorController extends editor $editor_config->{$key} = explode('|@|', $grant); } } - + $editor_config->editor_height = (int)Context::get('editor_height'); $editor_config->comment_editor_height = (int)Context::get('comment_editor_height'); - $editor_config->enable_autosave = Context::get('enable_autosave'); - if($editor_config->enable_autosave != 'Y') $editor_config->enable_autosave = 'N'; - + $editor_config->enable_autosave = Context::get('enable_autosave') ?: 'Y'; + $editor_config->allow_html = Context::get('allow_html') ?: 'Y'; + $oModuleController = getController('module'); foreach ($module_srl as $srl) { - $oModuleController->insertModulePartConfig('editor',$srl,$editor_config); + $oModuleController->insertModulePartConfig('editor', $srl, $editor_config); } - + $this->setError(-1); $this->setMessage('success_updated', 'info'); - + $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispBoardAdminContent'); $this->setRedirectUrl($returnUrl); } diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php index 3aa02d2b7..1c1948e85 100644 --- a/modules/editor/editor.model.php +++ b/modules/editor/editor.model.php @@ -43,7 +43,6 @@ class editorModel extends editor } // Fill in some other values. - if($editor_config->enable_autosave != 'N') $editor_config->enable_autosave = 'Y'; if(!is_array($editor_config->enable_html_grant)) $editor_config->enable_html_grant = array(); if(!is_array($editor_config->enable_comment_html_grant)) $editor_config->enable_comment_html_grant = array(); if(!is_array($editor_config->upload_file_grant)) $editor_config->upload_file_grant = array(); @@ -74,10 +73,25 @@ class editorModel extends editor $editor_config->$key = $editor_default_config->$key ?: $val; } } - + return $editor_config; } + function getSkinConfig($skin_name) + { + $skin_config = new stdClass; + + if($skin_info = getModel('module')->loadSkinInfo($this->module_path, $skin_name)) + { + foreach ($skin_info->extra_vars as $val) + { + $skin_config->{$val->name} = $val->value; + } + } + + return $skin_config; + } + function loadDrComponents() { $drComponentPath = _XE_PATH_ . 'modules/editor/skins/dreditor/drcomponents/'; @@ -252,6 +266,9 @@ class editorModel extends editor } Context::set('enable_autosave', $option->enable_autosave); + // Set allow html + Context::set('allow_html', ($option->allow_html === false || $option->allow_html === 'N') ? false : true); + // Load editor components. $site_srl = Context::get('site_module_info')->site_srl ?: 0; if($option->editor_skin === 'dreditor') @@ -406,19 +423,22 @@ class editorModel extends editor } // Permission check for file upload - if ($logged_info->is_admin === 'Y' || !count($option->upload_file_grant)) + if($module_srl) { - $option->allow_fileupload = true; - } - else - { - $option->allow_fileupload = false; - foreach($group_list as $group_srl => $group_info) + if ($logged_info->is_admin === 'Y' || !count($option->upload_file_grant)) { - if(in_array($group_srl, $option->upload_file_grant)) + $option->allow_fileupload = true; + } + else + { + $option->allow_fileupload = false; + foreach($group_list as $group_srl => $group_info) { - $option->allow_fileupload = true; - break; + if(in_array($group_srl, $option->upload_file_grant)) + { + $option->allow_fileupload = true; + break; + } } } } @@ -865,6 +885,89 @@ class editorModel extends editor return $component_info; } + + /** + * Return converted content + * @param object $obj + * @return string + */ + function converter($obj, $type = null) + { + $converter = null; + $config = $this->getEditorConfig($obj->module_srl); + + // Get editor skin + if (in_array($type, array('document', 'comment'))) + { + $skin = ($type == 'comment') ? $config->comment_editor_skin : $config->editor_skin; + } + else + { + $converter = $obj->converter; + $skin = $obj->editor_skin ?: $config->editor_skin; + } + + // if not inserted converter, Get converter from skin + if (!$converter) + { + $converter = $this->getSkinConfig($skin)->converter; + } + + // if not inserted converter, Check + if (!$converter) + { + if ($config->allow_html === 'N' || $obj->use_html === 'N') + { + $converter = 'text'; + } + elseif (strpos($type == 'comment' ? $config->sel_comment_editor_colorset : $config->sel_editor_colorset, 'nohtml') !== false) + { + $converter = 'text'; + } + + if (!is_html_content($obj->content) || $obj->use_editor === 'N') + { + $converter = 'default'; + } + } + + // Convert + if ($converter) + { + if ($converter == 'text') + { + // Remove Tag + $obj->content = strip_tags($obj->content); + + // Trim space + $obj->content = utf8_trim($obj->content); + + // Escape + $obj->content = escape($obj->content, false); + + // Insert HTML line + $obj->content = nl2br($obj->content); + } + elseif ($converter == 'text2html') + { + $obj->content = Rhymix\Framework\Formatter::text2html($obj->content); + } + elseif ($converter == 'markdown2html') + { + $obj->content = Rhymix\Framework\Formatter::markdown2html($obj->content); + } + elseif ($converter == 'bbcode') + { + $obj->content = Rhymix\Framework\Formatter::bbcode($obj->content); + } + else + { + $obj->content = nl2br($obj->content); + } + } + + return $obj->content; + } } /* End of file editor.model.php */ /* Location: ./modules/editor/editor.model.php */ diff --git a/modules/editor/editor.view.php b/modules/editor/editor.view.php index 01f8b5da9..678551962 100644 --- a/modules/editor/editor.view.php +++ b/modules/editor/editor.view.php @@ -149,57 +149,8 @@ class editorView extends editor function dispEditorConfigPreview() { - $oEditorModel = getModel('editor'); - $config = $oEditorModel->getEditorConfig(); - - $mode = Context::get('mode'); - - if($mode != 'main') - { - $option_com = new stdClass(); - $option_com->allow_fileupload = false; - $option_com->content_style = $config->content_style; - $option_com->content_font = $config->content_font; - $option_com->content_font_size = $config->content_font_size; - $option_com->content_line_height = $config->content_line_height; - $option_com->content_paragraph_spacing = $config->content_paragraph_spacing; - $option_com->content_word_break = $config->content_word_break; - $option_com->enable_autosave = false; - $option_com->enable_default_component = true; - $option_com->enable_component = true; - $option_com->disable_html = false; - $option_com->height = $config->comment_editor_height; - $option_com->skin = $config->comment_editor_skin; - $option_com->content_key_name = 'dummy_content'; - $option_com->primary_key_name = 'dummy_key'; - $option_com->content_style = $config->comment_content_style; - $option_com->colorset = $config->sel_comment_editor_colorset; - $editor = $oEditorModel->getEditor(0, $option_com); - } - else - { - $option = new stdClass(); - $option->allow_fileupload = false; - $option->content_style = $config->content_style; - $option->content_font = $config->content_font; - $option->content_font_size = $config->content_font_size; - $option->content_line_height = $config->content_line_height; - $option->content_paragraph_spacing = $config->content_paragraph_spacing; - $option->content_word_break = $config->content_word_break; - $option->enable_autosave = false; - $option->enable_default_component = true; - $option->enable_component = true; - $option->disable_html = false; - $option->height = $config->editor_height; - $option->skin = $config->editor_skin; - $option->content_key_name = 'dummy_content'; - $option->primary_key_name = 'dummy_key'; - $option->colorset = $config->sel_editor_colorset; - $editor = $oEditorModel->getEditor(0, $option); - } - - Context::set('editor', $editor); - + Context::set('editor', getModel('editor')->getModuleEditor(Context::get('type'), 0, 0, 'dummy_key', 'dummy_content')); + $this->setLayoutFile('popup_layout'); $this->setTemplatePath($this->module_path.'tpl'); $this->setTemplateFile('config_preview'); diff --git a/modules/editor/lang/en.php b/modules/editor/lang/en.php index 1ab1bc11b..d970c3066 100644 --- a/modules/editor/lang/en.php +++ b/modules/editor/lang/en.php @@ -71,6 +71,7 @@ $lang->enable_default_component_grant = 'Permission to use default components'; $lang->enable_extra_component_grant = 'Permission to use extra components'; $lang->enable_html_grant = 'Permission to edit HTML'; $lang->enable_autosave = 'Enable Auto-Save'; +$lang->allow_html = 'allow HTML'; $lang->height_resizable = 'Height Resizable'; $lang->editor_height = 'Height of Editor'; $lang->about_default_editor_settings = 'Follow editor settings of Rhymix Admin page through whole site.'; diff --git a/modules/editor/lang/ko.php b/modules/editor/lang/ko.php index e6638f6ed..325bda73c 100644 --- a/modules/editor/lang/ko.php +++ b/modules/editor/lang/ko.php @@ -75,6 +75,7 @@ $lang->enable_default_component_grant = '기본 컴포넌트 사용 권한'; $lang->enable_extra_component_grant = '확장 컴포넌트 사용 권한'; $lang->enable_html_grant = 'HTML 편집 권한'; $lang->enable_autosave = '자동저장 사용'; +$lang->allow_html = 'HTML 허용'; $lang->height_resizable = '높이 조절 가능'; $lang->editor_height = '에디터 높이'; $lang->about_default_editor_settings = '사이트 전체 에디터 설정을 통일하여서 모듈별 에디터 설정을 단순하게 합니다.'; diff --git a/modules/editor/skins/ckeditor/skin.xml b/modules/editor/skins/ckeditor/skin.xml index 15f78ea3c..210944e74 100644 --- a/modules/editor/skins/ckeditor/skin.xml +++ b/modules/editor/skins/ckeditor/skin.xml @@ -1,23 +1,21 @@ - - CKEditor 스킨 - CKEditor - 1.0.0 - 2015-02-24 - - - NAVER - - - - - Moono - - - Moono Dark - - - Moono Lisa - - + + CKEditor 스킨 + CKEditor + 1.0.0 + 2015-02-24 + + NAVER + + + + Moono + + + Moono Dark + + + Moono Lisa + + diff --git a/modules/editor/skins/textarea/css/textarea.css b/modules/editor/skins/textarea/css/textarea.css index 7cb65f24a..74622abd9 100644 --- a/modules/editor/skins/textarea/css/textarea.css +++ b/modules/editor/skins/textarea/css/textarea.css @@ -1,8 +1,3 @@ - -.rx_editor_wrapper { - clear: both; -} - .rx_editor_wrapper .rx_editor_textarea { width: 100%; min-height: 64px; @@ -16,4 +11,5 @@ .rx_editor_wrapper .rx_editor_textarea.dark { border-color: #111; background: #333; + color: #fff; } diff --git a/modules/editor/skins/textarea/editor.html b/modules/editor/skins/textarea/editor.html index af006faef..f99c08a5d 100644 --- a/modules/editor/skins/textarea/editor.html +++ b/modules/editor/skins/textarea/editor.html @@ -1,4 +1,7 @@ + + +
@@ -19,33 +22,8 @@ textarea.css("word-wrap", "break-word"); } - // Load existing content - var content_key = textarea.data("editor-content-key-name"); - var content_input = textarea.parents("form").find("input[name='" + content_key + "']"); - if (content_input.size()) { - textarea.val(String(content_input.val()).stripTags().unescape()); - } - - // Save edited content - textarea.on("change", function() { - content_input.val("

" + 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}); });
diff --git a/modules/editor/skins/textarea/js/interface.js b/modules/editor/skins/textarea/js/interface.js new file mode 100644 index 000000000..f5d3a91b6 --- /dev/null +++ b/modules/editor/skins/textarea/js/interface.js @@ -0,0 +1,16 @@ +function _getTextareaInstance(editor_sequence) { + return jQuery('#textarea_instance_' + editor_sequence); +} + +function editorGetContent(editor_sequence) { + return _getTextareaInstance(editor_sequence).val().escape(); +} + +function editorReplaceHTML(iframe_obj, content) { + var editor_sequence = parseInt(iframe_obj.id.replace(/^.*_/, ''), 10); + _getTextareaInstance(editor_sequence).val(String(content).stripTags()); +} + +function editorGetIFrame(editor_sequence) { + return _getTextareaInstance(editor_sequence).get(0); +} diff --git a/modules/editor/skins/textarea/js/textarea.js b/modules/editor/skins/textarea/js/textarea.js new file mode 100644 index 000000000..1f624b4a2 --- /dev/null +++ b/modules/editor/skins/textarea/js/textarea.js @@ -0,0 +1,28 @@ +function editorTextarea(editor_sequence) { + var textarea = jQuery("#textarea_instance_" + editor_sequence); + var content_key = textarea.data("editor-content-key-name"); + var primary_key = textarea.data("editor-primary-key-name"); + var insert_form = textarea.closest("form"); + var content_input = insert_form.find("input[name='" + content_key + "']"); + + // Set editor keys + editorRelKeys[editor_sequence] = {}; + editorRelKeys[editor_sequence].primary = insert_form.find("input[name='" + primary_key + "']"); + editorRelKeys[editor_sequence].content = content_input; + editorRelKeys[editor_sequence].func = editorGetContent; + + // Set editor_sequence + insert_form[0].setAttribute('editor_sequence', editor_sequence); + + // Load existing content + if (content_input.size()) { + var content = String(content_input.val()).stripTags(); + content_input.val(content); + textarea.val(content.unescape()); + } + + // Save edited content + textarea.on("change", function() { + content_input.val(String(jQuery(this).val()).escape()); + }); +} \ No newline at end of file diff --git a/modules/editor/skins/textarea/skin.xml b/modules/editor/skins/textarea/skin.xml index ead4ab883..af395ea5d 100644 --- a/modules/editor/skins/textarea/skin.xml +++ b/modules/editor/skins/textarea/skin.xml @@ -1,15 +1,18 @@ - - Textarea - Textarea - 1.0.0 - 2017-06-27 - - - Light - - - Dark - - + + Textarea + Textarea + 1.0.0 + 2017-06-27 + + + Light + + + Dark + + + + + diff --git a/modules/editor/tpl/admin_index.html b/modules/editor/tpl/admin_index.html index 49328b4b0..776762c8a 100644 --- a/modules/editor/tpl/admin_index.html +++ b/modules/editor/tpl/admin_index.html @@ -7,7 +7,7 @@

{$XE_VALIDATOR_MESSAGE}

-
+