에디터 스킨단에서 converter를 지정할 수 있도록 추가

This commit is contained in:
conory 2017-07-13 22:37:15 +09:00
parent 6e9e9e9171
commit 0e0bc311c9
4 changed files with 93 additions and 51 deletions

View file

@ -73,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/';
@ -879,24 +894,37 @@ class editorModel extends editor
function convertHTML($obj)
{
$type = array();
$editor_config = $this->getEditorConfig($obj->module_srl);
$config = $this->getEditorConfig($obj->module_srl);
if($obj->module_srl)
{
$converter = array();
$skin = $config->editor_skin;
}
else
{
$converter = array($obj->converter);
$skin = $obj->editor_skin ?: $config->editor_skin;
}
$converter = array_merge($converter, explode(',', $this->getSkinConfig($skin)->converter));
// Check
if ($editor_config->allow_html === 'N' || $obj->use_html === 'N')
if (in_array('text', $converter) || $config->allow_html === 'N' || $obj->use_html === 'N')
{
$type[] = 'to_Text';
}
elseif (strpos($obj->title ? $editor_config->sel_editor_colorset : $editor_config->sel_comment_editor_colorset, 'nohtml') !== false)
elseif (strpos($obj->title ? $config->sel_editor_colorset : $config->sel_comment_editor_colorset, 'nohtml') !== false)
{
$type[] = 'to_Text';
}
if (in_array('to_Text', $type) || $obj->use_editor === 'N' || !is_html_content($obj->content))
if (!is_html_content($obj->content) || in_array('to_Text', $type) || $obj->use_editor === 'N')
{
$type[] = 'to_HTML';
}
if ($obj->markdown === 'Y')
if (in_array('markdown', $converter))
{
$type[] = 'Markdown2HTML';
}

View file

@ -1,23 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<skin version="0.1">
<title xml:lang="ko">CKEditor 스킨</title>
<description xml:lang="ko">CKEditor</description>
<version>1.0.0</version>
<date>2015-02-24</date>
<author email_address="developers@xpressengine.com" link="https://www.xpressengine.com">
<name xml:lang="ko">NAVER</name>
</author>
<colorset>
<color name="moono">
<title xml:lang="ko">Moono</title>
</color>
<color name="moono-dark">
<title xml:lang="ko">Moono Dark</title>
</color>
<color name="moono-lisa">
<title xml:lang="ko">Moono Lisa</title>
</color>
</colorset>
<skin version="0.2">
<title xml:lang="ko">CKEditor 스킨</title>
<description xml:lang="ko">CKEditor</description>
<version>1.0.0</version>
<date>2015-02-24</date>
<author email_address="developers@xpressengine.com" link="https://www.xpressengine.com">
<name xml:lang="ko">NAVER</name>
</author>
<colorset>
<color name="moono">
<title xml:lang="ko">Moono</title>
</color>
<color name="moono-dark">
<title xml:lang="ko">Moono Dark</title>
</color>
<color name="moono-lisa">
<title xml:lang="ko">Moono Lisa</title>
</color>
</colorset>
</skin>

View file

@ -1,15 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<skin version="0.1">
<title xml:lang="ko">Textarea</title>
<description xml:lang="ko">Textarea</description>
<version>1.0.0</version>
<date>2017-06-27</date>
<colorset>
<color name="light">
<title xml:lang="ko">Light</title>
</color>
<color name="dark">
<title xml:lang="ko">Dark</title>
</color>
</colorset>
<skin version="0.2">
<title xml:lang="ko">Textarea</title>
<description xml:lang="ko">Textarea</description>
<version>1.0.0</version>
<date>2017-06-27</date>
<colorset>
<color name="light">
<title xml:lang="ko">Light</title>
</color>
<color name="dark">
<title xml:lang="ko">Dark</title>
</color>
</colorset>
<extra_vars>
<var name="converter" value="text"></var>
</extra_vars>
</skin>

View file

@ -1160,6 +1160,9 @@ class moduleModel extends module
// Skin Name
$skin_info = new stdClass();
$skin_info->title = $xml_obj->title->body;
$skin_info->author = array();
$skin_info->extra_vars = array();
$skin_info->colorset = array();
// Author information
if($xml_obj->version && $xml_obj->attrs->version == '0.2')
{
@ -1172,7 +1175,7 @@ class moduleModel extends module
$skin_info->license_link = $xml_obj->license->attrs->link;
$skin_info->description = $xml_obj->description->body;
if(!is_array($xml_obj->author)) $author_list[] = $xml_obj->author;
if(!is_array($xml_obj->author)) $author_list = array($xml_obj->author);
else $author_list = $xml_obj->author;
foreach($author_list as $author)
@ -1197,22 +1200,32 @@ class moduleModel extends module
{
continue;
}
if(!is_array($group->var)) $extra_vars = array($group->var);
if(!is_array($group->var))
{
$extra_vars = array($group->var);
}
foreach($extra_vars as $key => $val)
{
$obj = new stdClass();
if(!$val->attrs->type) { $val->attrs->type = 'text'; }
$obj = new stdClass;
$obj->group = $group->title->body;
$obj->name = $val->attrs->name;
$obj->title = $val->title->body;
$obj->type = $val->attrs->type;
$obj->type = $val->attrs->type ?: 'text';
$obj->description = $val->description->body;
$obj->value = $extra_vals->{$obj->name};
$obj->value = $val->attrs->value;
$obj->default = $val->attrs->default;
if(strpos($obj->value, '|@|') != false) { $obj->value = explode('|@|', $obj->value); }
if($obj->type == 'mid_list' && !is_array($obj->value)) { $obj->value = array($obj->value); }
if(strpos($obj->value, '|@|') !== false)
{
$obj->value = explode('|@|', $obj->value);
}
if($obj->type == 'mid_list' && !is_array($obj->value))
{
$obj->value = array($obj->value);
}
// Get an option list from 'select'type
if(is_array($val->options))
{
@ -1231,7 +1244,7 @@ class moduleModel extends module
$obj->options[0]->title = $val->options->title->body;
$obj->options[0]->value = $val->options->attrs->value;
}
$skin_info->extra_vars[] = $obj;
}
}