From 53b84b91f92de3448f4656adf5a2e05b5ec9a10e Mon Sep 17 00:00:00 2001 From: Cameron Date: Mon, 18 Mar 2013 02:16:41 -0700 Subject: [PATCH] Backward Compatibility fix for TinyMce editing. --- e107_core/bbcodes/bb_img.php | 2 +- e107_handlers/bbcode_handler.php | 1 + .../tinymce/plugins/e107bbcode/parser.php | 16 +++++++++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/e107_core/bbcodes/bb_img.php b/e107_core/bbcodes/bb_img.php index e7697305f..b51f2fd20 100644 --- a/e107_core/bbcodes/bb_img.php +++ b/e107_core/bbcodes/bb_img.php @@ -51,7 +51,7 @@ class bb_img extends e_bb_base $w = e107::getBB()->resizeWidth(); // varies depending on the class set by external script. see admin->media-manager->prefs - $w = vartrue($imgParms['width']) ? intval($imgParms['width']) : vartrue(e107::getBB()->resizeWidth(),300); + $w = vartrue($imgParms['width']) ? intval($imgParms['width']) : vartrue(e107::getBB()->resizeWidth(),0); // $h = vartrue($imgParms['height']) ? intval($imgParms['height']) : e107::getBB()->resizeHeight(); $resize = "&w=".$w; // Always resize - otherwise the thumbnailer returns nothing. diff --git a/e107_handlers/bbcode_handler.php b/e107_handlers/bbcode_handler.php index 4d6edd153..a2071e2d4 100644 --- a/e107_handlers/bbcode_handler.php +++ b/e107_handlers/bbcode_handler.php @@ -464,6 +464,7 @@ class e_bbcode // return the class for a bbcode function getClass($type='') { + $ret = "bbcode-".$type; if($this->class) { diff --git a/e107_plugins/tinymce/plugins/e107bbcode/parser.php b/e107_plugins/tinymce/plugins/e107bbcode/parser.php index 69acb4377..7358fc486 100644 --- a/e107_plugins/tinymce/plugins/e107bbcode/parser.php +++ b/e107_plugins/tinymce/plugins/e107bbcode/parser.php @@ -32,6 +32,16 @@ if($_POST['mode'] == 'tohtml') if(check_class($pref['post_html'])) // raw HTML within [html] tags. { + if(strstr($content,"[img]") || strstr($content, "[b]") || strstr($content, "[link")) // BC - convert old BB code text to html. + { + e107::getBB()->clearClass(); + + $content = str_replace('\r\n',"
",$content); + $content = nl2br($content, true); + $content = $tp->toHtml($content, true); + } + + $content = str_replace("{e_BASE}","",$content); // We want {e_BASE} in the final data going to the DB, but not the editor. $srch = array("","","[html]","[/html]"); @@ -61,11 +71,11 @@ if($_POST['mode'] == 'tobbcode') if(check_class($pref['post_html'])) // Plain HTML mode. { - $srch = array('src="'.e_HTTP.'thumb.php?'); - $repl = array('src="{e_BASE}thumb.php?'); + $srch = array('src="'.e_HTTP.'thumb.php?','src="/{e_MEDIA_IMAGE}'); + $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';