rhymix/modules/editor/editor.view.php
Min-Soo Kim e7cb5ede82
에디터 스타일과 기본 스타일의 합병
* 기본 에디터 스타일과 기본 스타일 설정이 충돌하는 경우가 많았습니다.
 - 기본 스타일을 지정했는데, 기본 에디터 스타일 내의 스타일 지정이 있는 경우 반영이 안되는 경우, 또는 기본 에디터 스타일을 변경했는데 기본 스타일 설정 때문에 반영이 적절하게 되지 않는 경우 등.
* 기본 에디터 스타일에서도 less 또는 sass를 사용하도록 하고 싶었지만, 위지윅 에디터에서 본문에 나타날 스타일을 그대로 보여주는데 한계가 있었습니다.
 - 기본 에디터 스타일을 위지윅 에디터 내에서 나타내기 위해서 변칙적인 방법이 많이 활용되었습니다. 때문에 실제 본문에서 적용되는 스타일 시트의 우선순위와 위지윅 에디터 내에서 적용되는 스타일 시트의 우선순위에 차이가 있었습니다. 이 차이는 실제 보여지는 스타일과 작성하는 에디터 내의 스타일 차이를 크게 만들 가능성이 있었습니다.
* 기능의 의미가 많이 퇴색되었고, 의미 전달이 명확하지 않은 기능이었습니다.
 - 기능상 기본 에디터 스타일과 기본 스타일은 서로 겹치는 영역의 기능입니다. 기본으로 포함된 두 에디터 스타일 간에 차이가 크지 않기도 해서 어떤 기능인지 사용자가 알아채기도 어려웠습니다. 자료실에 배포되고 있는 에디터 스타일도 대단히 적었습니다.
* 게시판이나 각 글의 모듈 스킨에서 지정하는 스타일과 충돌할 가능성도 있습니다.

따라서, 에디터 스타일이 의도한 것 처럼 글의 스타일에 대한 관리자 통제 기능은 유지하면서, 다른 기능과 중복되거나 충돌할 수 있는 기능을 정리합니다.
가능한 많은 환경에서 테스트 하였으나, 추가로 이와 관련한 의견이 있을 경우 merge 후에도 계속 반영 해나가겠습니다.
2020-06-16 00:33:19 +09:00

189 lines
5.8 KiB
PHP

<?php
/* Copyright (C) NAVER <http://www.navercorp.com> */
/**
* @class editorView
* @author NAVER (developers@xpressengine.com)
* @brief view class of the editor module
*/
class editorView extends editor
{
/**
* @brief Initialization
*/
function init()
{
}
/**
* @brief Display editor in an iframe
*/
function dispEditorFrame()
{
// Check parent input ID
$parent_input_id = Context::get('parent_input_id');
Context::set('parent_input_id', preg_replace('/[^a-z0-9_]/i', '', $parent_input_id));
Context::addBodyClass('disable_debug_panel');
// Load editor
$oEditorModel = getModel('editor');
$option = $oEditorModel->getEditorConfig();
$option->editor_skin = 'ckeditor';
$option->sel_editor_colorset = 'moono-lisa';
$option->primary_key_name = 'primary_key';
$option->content_key_name = 'content';
$option->allow_fileupload = FALSE;
$option->enable_autosave = FALSE;
$option->enable_default_component = TRUE;
$option->enable_component = FALSE;
$option->height = 300;
$option->editor_focus = 'Y';
$editor = $oEditorModel->getEditor(0, $option);
Context::set('editor', $editor);
// Set template
$this->setLayoutPath('./common/tpl/');
$this->setLayoutFile("default_layout");
$this->setTemplatePath($this->module_path . 'tpl');
$this->setTemplateFile('editor_frame');
}
/**
* @brief Action to get a request to display compoenet pop-up
*/
function dispEditorPopup()
{
// add a css file
Context::loadFile($this->module_path."tpl/css/editor.css", true);
// List variables
$editor_sequence = Context::get('editor_sequence');
$component = Context::get('component');
$site_module_info = Context::get('site_module_info');
$site_srl = (int)$site_module_info->site_srl;
// Get compoenet object
$oEditorModel = getModel('editor');
$oComponent = &$oEditorModel->getComponentObject($component, $editor_sequence, $site_srl);
if(!$oComponent->toBool())
{
Context::set('message', sprintf(lang('msg_component_is_not_founded'), $component));
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('component_not_founded');
}
else
{
// Get the result after executing a method to display popup url of the component
$popup_content = $oComponent->getPopupContent();
Context::set('popup_content', $popup_content);
// Set layout to popup_layout
$this->setLayoutFile('popup_layout');
// Set a template
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('popup');
}
}
/**
* @brief Get component information
*/
function dispEditorComponentInfo()
{
$component_name = Context::get('component_name');
$site_module_info = Context::get('site_module_info');
$site_srl = (int)$site_module_info->site_srl;
$oEditorModel = getModel('editor');
$component = $oEditorModel->getComponent($component_name, $site_srl);
if(!$component->component_name)
{
throw new Rhymix\Framework\Exceptions\InvalidRequest;
}
Context::set('component', $component);
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('view_component');
$this->setLayoutFile("popup_layout");
}
/**
* @brief Add a form for editor addition setup
*/
function triggerDispEditorAdditionSetup(&$obj)
{
$current_module_srl = Context::get('module_srl');
$current_module_srls = Context::get('module_srls');
if(!$current_module_srl && !$current_module_srls)
{
// Get information of the current module
$current_module_info = Context::get('current_module_info');
$current_module_srl = $current_module_info->module_srl;
if(!$current_module_srl) return new BaseObject();
}
// Get editors settings
$oEditorModel = getModel('editor');
$editor_config = $oEditorModel->getEditorConfig($current_module_srl);
Context::set('editor_config', $editor_config);
$oModuleModel = getModel('module');
// Get a list of editor skin
$editor_skin_list = FileHandler::readDir(_XE_PATH_.'modules/editor/skins');
$editor_skin_list = array_filter($editor_skin_list, function($name) { return !starts_with('xpresseditor', $name) && !starts_with('dreditor', $name); });
Context::set('editor_skin_list', $editor_skin_list);
$skin_info = $oModuleModel->loadSkinInfo($this->module_path,$editor_config->editor_skin);
Context::set('editor_colorset_list', $skin_info->colorset);
$skin_info = $oModuleModel->loadSkinInfo($this->module_path,$editor_config->comment_editor_skin);
Context::set('editor_comment_colorset_list', $skin_info->colorset);
// Get a group list
$oMemberModel = getModel('member');
$site_module_info = Context::get('site_module_info');
$group_list = $oMemberModel->getGroups($site_module_info->site_srl);
Context::set('group_list', $group_list);
//Security
$security = new Security();
$security->encodeHTML('group_list..title');
$security->encodeHTML('group_list..description');
$security->encodeHTML('editor_comment_colorset_list..title');
// Set a template file
$oTemplate = &TemplateHandler::getInstance();
$tpl = $oTemplate->compile($this->module_path.'tpl', 'editor_module_config');
$obj .= $tpl;
return new BaseObject();
}
function dispEditorPreview()
{
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('preview');
}
function dispEditorSkinColorset()
{
$skin = Context::get('skin');
$oModuleModel = getModel('module');
$skin_info = $oModuleModel->loadSkinInfo($this->module_path,$skin);
$colorset = $skin_info->colorset;
Context::set('colorset', $colorset);
}
function dispEditorConfigPreview()
{
Context::set('editor', getModel('editor')->getModuleEditor(Context::get('type'), 0, 0, 'dummy_key', 'dummy_content'));
$this->setLayoutFile('default_layout');
$this->setTemplatePath($this->module_path.'tpl');
$this->setTemplateFile('config_preview');
}
}
/* End of file editor.view.php */
/* Location: ./modules/editor/editor.view.php */