converter() 로 변경 및 개선

This commit is contained in:
conory 2017-07-14 16:17:26 +09:00
parent 146975f277
commit 35646700fe
6 changed files with 63 additions and 37 deletions

View file

@ -438,7 +438,7 @@ class commentController extends comment
// if use editor of nohtml, Remove HTML tags from the contents. // if use editor of nohtml, Remove HTML tags from the contents.
if(!$manual_inserted) if(!$manual_inserted)
{ {
$obj->content = getModel('editor')->convertHTML($obj); $obj->content = getModel('editor')->converter($obj, 'comment');
} }
if(!$obj->regdate) if(!$obj->regdate)
@ -788,7 +788,7 @@ class commentController extends comment
// if use editor of nohtml, Remove HTML tags from the contents. // if use editor of nohtml, Remove HTML tags from the contents.
if(!$manual_updated) if(!$manual_updated)
{ {
$obj->content = getModel('editor')->convertHTML($obj); $obj->content = getModel('editor')->converter($obj, 'comment');
} }
// remove iframe and script if not a top administrator on the session // remove iframe and script if not a top administrator on the session

View file

@ -457,7 +457,7 @@ class documentController extends document
// if use editor of nohtml, Remove HTML tags from the contents. // if use editor of nohtml, Remove HTML tags from the contents.
if(!$manual_inserted) if(!$manual_inserted)
{ {
$obj->content = getModel('editor')->convertHTML($obj); $obj->content = getModel('editor')->converter($obj, 'document');
} }
// Remove iframe and script if not a top adminisrator in the session. // Remove iframe and script if not a top adminisrator in the session.
@ -695,7 +695,7 @@ class documentController extends document
// if use editor of nohtml, Remove HTML tags from the contents. // if use editor of nohtml, Remove HTML tags from the contents.
if(!$manual_updated) if(!$manual_updated)
{ {
$obj->content = getModel('editor')->convertHTML($obj); $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. // Change not extra vars but language code of the original document if document's lang_code is different from author's setting.

View file

@ -891,61 +891,84 @@ class editorModel extends editor
* @param object $obj * @param object $obj
* @return string * @return string
*/ */
function convertHTML($obj) function converter($obj, $type = null)
{ {
$type = array(); $converter = array();
$add_converters = array();
$config = $this->getEditorConfig($obj->module_srl); $config = $this->getEditorConfig($obj->module_srl);
if($obj->module_srl) // Get editor skin
if (in_array($type, array('document', 'comment')))
{ {
$converter = array(); $skin = ($type == 'comment') ? $config->comment_editor_skin : $config->editor_skin;
$skin = $config->editor_skin;
} }
else else
{ {
$converter = array($obj->converter); $add_converters[] = $obj->converter;
$skin = $obj->editor_skin ?: $config->editor_skin; $skin = $obj->editor_skin ?: $config->editor_skin;
} }
$converter = array_merge($converter, explode(',', $this->getSkinConfig($skin)->converter)); // Get converter from skin
$add_converters[] = $this->getSkinConfig($skin)->converter;
// Add converter
foreach($add_converter as $name)
{
if(!$name)
{
continue;
}
if (is_array($name))
{
$converter = array_merge($converter, $name);
}
else
{
$converter[] = $name;
}
}
// Check // Check
if (in_array('text', $converter) || $config->allow_html === 'N' || $obj->use_html === 'N') if ($config->allow_html === 'N' || $obj->use_html === 'N')
{ {
$type[] = 'to_Text'; $converter[] = 'Text';
} }
elseif (strpos($obj->title ? $config->sel_editor_colorset : $config->sel_comment_editor_colorset, 'nohtml') !== false) elseif (strpos($type == 'comment' ? $config->sel_comment_editor_colorset : $config->sel_editor_colorset, 'nohtml') !== false)
{ {
$type[] = 'to_Text'; $converter[] = 'Text';
} }
if (!is_html_content($obj->content) || $obj->use_editor === 'N')
if (!is_html_content($obj->content) || in_array('to_Text', $type) || $obj->use_editor === 'N')
{ {
$type[] = 'to_HTML'; $converter[] = 'default';
}
if (in_array('markdown', $converter))
{
$type[] = 'Markdown2HTML';
} }
// Convert // Convert
if ($type) if ($converter)
{ {
if (in_array('to_Text', $type)) // To Text
if (in_array('Text', $converter))
{ {
$obj->content = escape(strip_tags($obj->content), false); $obj->content = escape(strip_tags($obj->content), false);
} }
if (in_array('to_HTML', $type)) // To HTML
if (in_array('Text2HTML', $converter))
{ {
$obj->content = nl2br($obj->content); $obj->content = Rhymix\Framework\Formatter::text2html($obj->content);
} }
elseif (in_array('Markdown2HTML', $converter))
if (in_array('Markdown2HTML', $type))
{ {
$obj->content = Rhymix\Framework\Formatter::markdown2html($obj->content); $obj->content = Rhymix\Framework\Formatter::markdown2html($obj->content);
} }
elseif (in_array('Bbcode2HTML', $converter))
{
$obj->content = Rhymix\Framework\Formatter::bbcode($obj->content);
}
else
{
$obj->content = nl2br($obj->content);
}
} }
return $obj->content; return $obj->content;

View file

@ -13,6 +13,6 @@
</color> </color>
</colorset> </colorset>
<extra_vars> <extra_vars>
<var name="converter" value="text"></var> <var name="converter" value="Text"></var>
</extra_vars> </extra_vars>
</skin> </skin>

View file

@ -1624,13 +1624,16 @@ class memberController extends member
return; return;
} }
if(getModel('member')->getMemberConfig()->signature_html == 'N') // Editor converter
$obj = new stdClass;
$config = getModel('member')->getMemberConfig();
if($config->signature_html == 'N')
{ {
$obj = new stdClass; $obj->converter = 'Text';
$obj->use_html = 'N';
$obj->content = $signature;
$signature = getModel('editor')->convertHTML($obj);
} }
$obj->content = $signature;
$obj->editor_skin = $config->signature_editor_skin;
$signature = getModel('editor')->converter($obj);
$filename = sprintf('files/member_extra_info/signature/%s%d.signature.php', getNumberingPath($member_srl), $member_srl); $filename = sprintf('files/member_extra_info/signature/%s%d.signature.php', getNumberingPath($member_srl), $member_srl);
$buff = sprintf('<?php if(!defined("__XE__")) exit();?>%s', $signature); $buff = sprintf('<?php if(!defined("__XE__")) exit();?>%s', $signature);

View file

@ -1218,9 +1218,9 @@ class moduleModel extends module
$obj->value = $val->attrs->value; $obj->value = $val->attrs->value;
$obj->default = $val->attrs->default; $obj->default = $val->attrs->default;
if(strpos($obj->value, '|@|') !== false) if(preg_match('/,|\|@\|/', $obj->value, $delimiter) && $delimiter[0])
{ {
$obj->value = explode('|@|', $obj->value); $obj->value = explode($delimiter[0], $obj->value);
} }
if($obj->type == 'mid_list' && !is_array($obj->value)) if($obj->type == 'mid_list' && !is_array($obj->value))
{ {