mirror of
https://github.com/e107inc/e107.git
synced 2025-04-20 04:32:01 +02:00
Experimental: Insert e107 BBcodes using TinyMce (Insert Menu)
This commit is contained in:
parent
8dee70cef5
commit
bad3a54eee
@ -3621,7 +3621,7 @@ class e_parser
|
||||
'th' => array('id', 'style', 'class', 'colspan', 'rowspan'),
|
||||
'col' => array('id', 'span', 'class','style'),
|
||||
'embed' => array('id', 'src', 'style', 'class', 'wmode', 'type', 'title', 'width', 'height'),
|
||||
|
||||
'x-bbcode' => array('alt'),
|
||||
);
|
||||
|
||||
protected $badAttrValues = array('javascript[\s]*?:','alert\(','vbscript[\s]*?:','data:text\/html', 'mhtml[\s]*?:', 'data:[\s]*?image');
|
||||
@ -3633,7 +3633,7 @@ class e_parser
|
||||
protected $allowedTags = array('html', 'body','div','a','img','table','tr', 'td', 'th', 'tbody', 'thead', 'colgroup', 'b',
|
||||
'i', 'pre','code', 'strong', 'u', 'em','ul', 'ol', 'li','img','h1','h2','h3','h4','h5','h6','p',
|
||||
'div','pre','section','article', 'blockquote','hgroup','aside','figure','figcaption', 'abbr','span', 'audio', 'video', 'br',
|
||||
'small', 'caption', 'noscript', 'hr', 'section', 'iframe', 'sub', 'sup', 'cite'
|
||||
'small', 'caption', 'noscript', 'hr', 'section', 'iframe', 'sub', 'sup', 'cite', 'x-bbcode'
|
||||
);
|
||||
protected $scriptTags = array('script','applet','form','input','button', 'embed', 'object', 'ins', 'select','textarea'); //allowed when $pref['post_script'] is enabled.
|
||||
|
||||
@ -4654,29 +4654,31 @@ class e_parser
|
||||
|
||||
|
||||
/**
|
||||
* Parse new <bbcode> tags into bbcode output.
|
||||
* @param $retainTags : when you want to replace html and retain the <bbcode> tags wrapping it.
|
||||
* @return html
|
||||
* Parse new <x-bbcode> tags into bbcode output.
|
||||
* @param bool $retainTags : when you want to replace html and retain the <bbcode> tags wrapping it.
|
||||
* @return string html
|
||||
*/
|
||||
function parseBBTags($text,$retainTags = false)
|
||||
{
|
||||
$bbcodes = $this->getTags($text, 'bbcode');
|
||||
|
||||
$stext = str_replace(""", '"', $text);
|
||||
|
||||
$bbcodes = $this->getTags($stext, 'x-bbcode');
|
||||
|
||||
foreach($bbcodes as $v)
|
||||
{
|
||||
foreach($v as $val)
|
||||
{
|
||||
$tag = urldecode($val['alt']);
|
||||
$tag = base64_decode($val['alt']);
|
||||
$repl = ($retainTags == true) ? '$1'.$tag.'$2' : $tag;
|
||||
$text = preg_replace('/(<bbcode[^>]*>).*(<\/bbcode>)/s',$repl, $text); //FIXME - handle multiple instances of bbcodes.
|
||||
$text = preg_replace('/(<x-bbcode[^>]*>).*(<\/x-bbcode>)/i',$repl, $text);
|
||||
}
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Perform and render XSS Test Comparison
|
||||
*/
|
||||
@ -5044,7 +5046,7 @@ return;
|
||||
}
|
||||
|
||||
|
||||
$tag = preg_replace('/([a-z0-9\[\]\/]*)?\/([\w]*)(\[(\d)*\])?$/i', "$2", $path);
|
||||
$tag = preg_replace('/([a-z0-9\[\]\/]*)?\/([\w\-]*)(\[(\d)*\])?$/i', "$2", $path);
|
||||
if(!in_array($tag, $this->allowedTags))
|
||||
{
|
||||
|
||||
|
@ -135,7 +135,9 @@ TEMPL;
|
||||
$content = str_replace("{e_BASE}",e_HTTP,$content); // We want {e_BASE} in the final data going to the DB, but not the editor.
|
||||
$srch = array("<!-- bbcode-html-start -->","<!-- bbcode-html-end -->","[html]","[/html]");
|
||||
$content = str_replace($srch,"",$content);
|
||||
$content = e107::getBB()->parseBBCodes($content); // parse the <bbcode> tag so we see the HTML equivalent while editing!
|
||||
$content = $tp->parseBBTags($content,true); // parse the <bbcode> tag so we see the HTML equivalent while editing!
|
||||
$content = e107::getBB()->parseBBCodes($content);
|
||||
|
||||
|
||||
if(!empty($content) && E107_DEBUG_LEVEL > 0)
|
||||
{
|
||||
@ -204,7 +206,7 @@ TEMPL;
|
||||
|
||||
// $content = preg_replace($psrch, $prepl, $content);
|
||||
$content = $this->updateImg($content);
|
||||
$content = $tp->parseBBTags($content,true); // replace html with bbcode equivalent
|
||||
// $content = $tp->parseBBTags($content,true); // replace html with bbcode equivalent
|
||||
|
||||
if(strip_tags($content, '<i>') == ' ') // Avoid this: [html]<p> </p>[/html]
|
||||
{
|
||||
|
@ -49,29 +49,55 @@
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
// Emoticons
|
||||
ed.addButton('e107-bbcode', {
|
||||
text: 'bbcode',
|
||||
icon: 'emoticons',
|
||||
// ed.addButton('e107-bbcode', {
|
||||
ed.addMenuItem('e107-bbcode', {
|
||||
text: 'e107 BBcode',
|
||||
context: 'insert',
|
||||
icon: 'code',
|
||||
onclick: function() {
|
||||
// Open window
|
||||
|
||||
ed.windowManager.open({
|
||||
title: 'Example plugin',
|
||||
title: 'Insert e107 BBcode',
|
||||
body: [
|
||||
{type: 'textbox', name: 'code', label: 'BbCode'},
|
||||
{type: 'textbox', name: 'parm', label: 'Parameters'}
|
||||
{type: 'textbox', name: 'code', label: 'BbCode', text: 'widget', size: 80, tooltip: 'eg. [b]bold[/b]', autofocus: true} //,
|
||||
// {type: 'textbox', name: 'parm', label: 'Parameters'}
|
||||
],
|
||||
onsubmit: function(e) {
|
||||
|
||||
s = e.data.code;
|
||||
s = s.trim(s);
|
||||
|
||||
var html = $.ajax({
|
||||
type: 'POST',
|
||||
url: url +'/parser.php',
|
||||
data: { content: s, mode: 'tohtml' },
|
||||
async : false,
|
||||
|
||||
dataType: 'html',
|
||||
success: function(html) {
|
||||
return html;
|
||||
}
|
||||
}).responseText;
|
||||
|
||||
html = '<x-bbcode alt=\"'+btoa(s)+'\">' + html + '</x-bbcode> ' ;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Insert content when the window form is submitted
|
||||
ed.insertContent('Title: ' + e.data.title);
|
||||
// console.log(url);
|
||||
// console.log(html);
|
||||
ed.insertContent(html);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
*/
|
||||
|
||||
// Media Manager Button
|
||||
ed.addButton('e107-image', {
|
||||
text: '',
|
||||
|
Loading…
x
Reference in New Issue
Block a user