diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index 474f31def..5e448f190 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -1421,14 +1421,15 @@ class e_parse extends e_parser case 'html' : // This overrides and deprecates html.bb $proc_funcs = TRUE; - $convertNL = FALSE; - $code_text = str_replace("\r\n", " ", $code_text); + $noBreak = TRUE; + // $code_text = str_replace("\r\n", " ", $code_text); $code_text = html_entity_decode($code_text, ENT_QUOTES, CHARSET); $html_start = ""; // markers for html-to-bbcode replacement. $html_end = ""; $full_text = str_replace(array("[html]","[/html]"), "",$code_text); // quick fix.. security issue? $full_text =$this->replaceConstants($full_text,'abs'); $full_text = $html_start.$full_text.$html_end; + $full_text = $this->parseBBTags($full_text); // strip tags. break; case 'table' : // strip
from end of @@ -1558,9 +1559,10 @@ class e_parse extends e_parser // Reduce newlines in all forms to a single newline character (finds '\n', '\r\n', '\n\r') if (!$opts['nobreak']) { - if ($convertNL) + if ($convertNL && substr($sub_blk,0,6) != '[html]') //XXX Quick Fix, find a cleaner way. { // We may need to convert to
later + $sub_blk = preg_replace("#[\r]*\n[\r]*#", E_NL, $sub_blk); } else @@ -2431,19 +2433,32 @@ class e_parser { $tmp = $doc->getElementsByTagName($find); + foreach($tmp as $k=>$node) { $tag = $node->nodeName; + $inner = $node->C14N(); + $inner = str_replace(" ","",$inner); foreach ($node->attributes as $attr) { $name = $attr->nodeName; $value = $attr->nodeValue; $ret[$tag][$k][$name] = $value; - } + } + + $ret[$tag][$k]['@value'] = $inner; + + } } + if($header == false) + { + unset($ret['html'],$ret['body']); + } + + return $ret; } @@ -2456,6 +2471,29 @@ class e_parser return $text; } + /** + * Parse new tags into bbcode output. + * @param $retainTags : when you want to replace html and retain the tags wrapping it. + * @return html + */ + function parseBBTags($text,$retainTags = false) + { + $bbcodes = $this->getTags($text, 'bbcode'); + + foreach($bbcodes as $v) + { + foreach($v as $val) + { + $tag = urldecode($val['alt']); + $repl = ($retainTags == true) ? '$1'.$tag.'$2' : $tag; + $text = preg_replace('/(]*>).*(<\/bbcode>)/s',$repl, $text); //FIXME - handle multiple instances of bbcodes. + } + } + return $text; + } + + + /** * Perform and render XSS Test Comparison diff --git a/e107_plugins/tinymce/plugins/e107bbcode/dialog.php b/e107_plugins/tinymce/plugins/e107bbcode/dialog.php index 7c32c2b16..2323077b0 100644 --- a/e107_plugins/tinymce/plugins/e107bbcode/dialog.php +++ b/e107_plugins/tinymce/plugins/e107bbcode/dialog.php @@ -4,7 +4,7 @@ define("e_ADMIN_AREA", true); require_once("../../../../class2.php"); //e107::lan('core','admin',TRUE); define("e_IFRAME",true); -require_once(e_ADMIN."auth.php"); +//require_once(e_ADMIN."auth.php"); if(!USER || check_class($pref['post_html']) == FALSE){ @@ -71,7 +71,33 @@ $(document).ready(function() tinyMCEPopup.close(); }); + $('#bbcodeInsert').click(function () + { + s = $('#bbcodeValue').val(); + s = s.trim(s); + var html = $.ajax({ + type: 'POST', + url: './parser.php', + data: { content: s, mode: 'tohtml' }, + async : false, + + dataType: 'html', + success: function(html) { + return html; + } + }).responseText; + + html = '' + html + ' ' ; + + tinyMCEPopup.editor.execCommand('mceInsertContent', false, html); + tinyMCEPopup.close(); + }); + + $('a.bbcodeSelect').click(function () { + var html = $(this).html(); + $('#bbcodeValue').val(html); + }); $('#e-cancel').click(function () { @@ -95,6 +121,19 @@ class e_bootstrap { $ns = e107::getRender(); + + if(e_QUERY == 'bbcode') + { + echo $this->bbcodeForm(); + return; + } + + + + + + + $text = ' '; $text .= '
'; @@ -112,6 +152,8 @@ class e_bootstrap $text .= '
'.$this->badgeForm().'
'; $text .= '
'.$this->glyphicons().'
'; + + $text .= '
'; echo $text; @@ -204,9 +246,46 @@ class e_bootstrap } - - + + function bbcodeForm() + { + $list = e107::getPref('bbcode_list'); + + $text .= " +

e107 Bbcodes

+
+
+ + + + "; + foreach($list as $plugin=>$val) + { + $text .= " + + "; + } + + $text .= "
PluginBbcode
".$plugin.""; + foreach($val as $bb=>$v) + { + $text .= "[".$bb."][/".$bb."]"; + } + $text .= "
+ "; + + $frm = e107::getForm(); + $text .= $frm->text('bbcodeValue','',false,'size=xlarge'); + $text .= $frm->button('bbcodeInsert','go','other','Insert'); + + + return $text; + + + } + + function glyphicons() { diff --git a/e107_plugins/tinymce/plugins/e107bbcode/editor_plugin.js b/e107_plugins/tinymce/plugins/e107bbcode/editor_plugin.js index adf0ef336..c6c3984c8 100644 --- a/e107_plugins/tinymce/plugins/e107bbcode/editor_plugin.js +++ b/e107_plugins/tinymce/plugins/e107bbcode/editor_plugin.js @@ -9,6 +9,7 @@ tinymce.create('tinymce.plugins.e107BBCodePlugin', { init : function(ed, url) { + // Bootstrap ed.addCommand('mceBoot', function() { ed.windowManager.open({ file : url + '/dialog.php', @@ -22,11 +23,33 @@ }); // Register button - ed.addButton('e107bbcode', { - title : 'example.desc', + ed.addButton('bootstrap', { + title : 'Insert Bootstrap Elements', cmd : 'mceBoot', image : url + '/img/bootstrap.png' }); + + // e107 Bbcode + ed.addCommand('mcee107', function() { + ed.windowManager.open({ + file : url + '/dialog.php?bbcode', + width : 900 , // + parseInt(ed.getLang('e107bbcode.delta_width', 0)), + height : 450, // + parseInt(ed.getLang('e107bbcode.delta_height', 0)), + inline : 1 + }, { + plugin_url : url, // Plugin absolute URL + some_custom_arg : 'custom arg' // Custom argument + }); + }); + + // Register button + ed.addButton('e107bbcode', { + title : 'Insert e107 Bbcode', + cmd : 'mcee107', + image : url + '/img/bbcode.png' + }); + + // Add a node change handler, selects the button in the UI when a image is selected ed.onNodeChange.add(function(ed, cm, n) { diff --git a/e107_plugins/tinymce/plugins/e107bbcode/parser.php b/e107_plugins/tinymce/plugins/e107bbcode/parser.php index 92a56390b..af57c64e8 100644 --- a/e107_plugins/tinymce/plugins/e107bbcode/parser.php +++ b/e107_plugins/tinymce/plugins/e107bbcode/parser.php @@ -26,6 +26,9 @@ if($_POST['mode'] == 'tohtml') // XXX @Cam possible fix - convert to BB first, see news admin AJAX request/response values for reference why $content = stripslashes($_POST['content']); + + + // $content = e107::getBB()->htmltoBBcode($content); //XXX This breaks inserted images from media-manager. :/ e107::getBB()->setClass($_SESSION['media_category']); @@ -47,6 +50,7 @@ if($_POST['mode'] == 'tohtml') $srch = array("","","[html]","[/html]"); $content = str_replace($srch,"",$content); + $content = e107::getBB()->parseBBCodes($content); // parse the tag so we see the HTML equivalent while editing! echo $content; } else // bbcode Mode. @@ -76,13 +80,14 @@ if($_POST['mode'] == 'tobbcode') $repl = array('src="{e_BASE}thumb.php?','src="{e_BASE}thumb.php?src=e_MEDIA_IMAGE/'); $content = str_replace($srch, $repl, $content); - + // resize the thumbnail to match wysiwyg width/height. $psrch = '/]*src="{e_BASE}thumb.php\?src=([\S]*)w=([\d]*)&h=([\d]*)"(.*)width="([\d]*)" height="([\d]*)"/i'; $prepl = 'parseBBTags($content,true); // replace html with bbcode equivalent echo ($content) ? "[html]".$content."[/html]" : ""; // Add the tags before saving to DB. } diff --git a/e107_plugins/tinymce/templates/mainadmin.xml b/e107_plugins/tinymce/templates/mainadmin.xml index 8e7d6ed57..d091fbaf5 100644 --- a/e107_plugins/tinymce/templates/mainadmin.xml +++ b/e107_plugins/tinymce/templates/mainadmin.xml @@ -2,6 +2,6 @@ Main Admin advhr,advlink,autosave,contextmenu,directionality,e107bbcode,emoticons,ibrowser,jqueryinlinepopups,paste,table,visualchars,wordcount,xhtmlxtras,youtube,fullscreen - link, unlink, bold, italic, underline, undo, redo,formatselect,justifyleft,justifycenter,justifyright,justifyfull, |, ibrowser, forecolor, removeformat, table, bullist, numlist, outdent, indent, cleanup, emoticons, youtube, e107bbcode, fullscreen - i[*], object[*],embed[*] + link, unlink, bold, italic, underline, undo, redo,formatselect,justifyleft,justifycenter,justifyright,justifyfull, |, ibrowser, forecolor, removeformat, table, bullist, numlist, outdent, indent, cleanup, emoticons, youtube, e107bbcode, bootstrap, fullscreen + i[*], object[*],embed[*],bbcode[*] diff --git a/e107_plugins/tinymce/wysiwyg.php b/e107_plugins/tinymce/wysiwyg.php index 4cb6081fd..16c60573a 100644 --- a/e107_plugins/tinymce/wysiwyg.php +++ b/e107_plugins/tinymce/wysiwyg.php @@ -326,6 +326,8 @@ class wysiwyg 'cleanup' => 'true', 'convert_fonts_to_spans' => 'true', 'content_css' => $tp->replaceConstants($content_css), + 'popup_css' => 'false', + 'trim_span_elements' => 'true', 'inline_styles' => 'true', 'auto_resize' => 'false',