diff --git a/e107_admin/cache.php b/e107_admin/cache.php index 3e98adf17..730fa6f99 100644 --- a/e107_admin/cache.php +++ b/e107_admin/cache.php @@ -130,7 +130,7 @@ $text = " ".CACLAN_17." - ".CACLAN_1." + ".CACLAN_1." @@ -140,7 +140,7 @@ $text = "
".CACLAN_13."
{$contentcache_label} - + ".$frm->radio_switch('cachestatus', e107::getPref('cachestatus'))." @@ -150,7 +150,7 @@ $text = "
".CACLAN_14."
{$syscache_label} - + ".$frm->radio_switch('syscachestatus', e107::getPref('syscachestatus'))." @@ -160,7 +160,7 @@ $text = "
".CACLAN_21."
{$dbcache_label} - + ".LAN_ENABLED." @@ -170,13 +170,13 @@ $text = "
".CACLAN_23."
{$imgcache_label} - + ".LAN_ENABLED." -
+
".$frm->admin_button('submit_cache', CACLAN_2, 'update')."
".$frm->select('option_clear_cache', array( 'empty_all' => CACLAN_26, diff --git a/e107_handlers/bbcode_handler.php b/e107_handlers/bbcode_handler.php index 37d612cbf..7af644aa3 100644 --- a/e107_handlers/bbcode_handler.php +++ b/e107_handlers/bbcode_handler.php @@ -90,7 +90,7 @@ class e_bbcode * * Code uses a crude stack-based syntax analyser to handle nested bbcodes (including nested 'size' bbcodes, for example) */ - function parseBBCodes($value, $p_ID, $force_lower = 'default', $bbStrip = FALSE) + function parseBBCodes($value, $p_ID='', $force_lower = 'default', $bbStrip = FALSE) { global $postID; $postID = $p_ID; diff --git a/e107_plugins/tinymce4/plugins/e107/parser.php b/e107_plugins/tinymce4/plugins/e107/parser.php index f46dde5d3..fc2cb20f2 100644 --- a/e107_plugins/tinymce4/plugins/e107/parser.php +++ b/e107_plugins/tinymce4/plugins/e107/parser.php @@ -5,170 +5,225 @@ * Copyright (C) e107 Inc (e107.org) * Released under the terms and conditions of the * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) - * - * $URL: https://e107.svn.sourceforge.net/svnroot/e107/trunk/e107_0.8/e107_handlers/bbcode_handler.php $ - * $Id: bbcode_handler.php 12778 2012-06-02 08:12:16Z e107coders $ */ + + +if(empty($_POST['content'])) +{ + header('Content-Length: 0'); + exit; +} + +$_E107['no_online'] = true; +$_E107['no_menus'] = true; +$_E107['no_forceuserupdate'] = true; require_once("../../../../class2.php"); /** - * Two Modes supported below going to and from the Tinymce wysiwyg editor. - * 1) When the post_html pref is active - raw html is used in the editor and wrapped in [html] [/html] bbcodes in the background. - * 2) When the post_html pref is disabled - bbcodes are used in the background and converted to html for the editor. - * Tested extensively over 24 hours with Images - check with Cameron first if issues arise. - * TODO Test Lines breaks and out html tags. - * TODO Check with html5 tags active. - */ - - - -if($_POST['mode'] == 'tohtml') + * Two Modes supported below going to and from the Tinymce wysiwyg editor. + * 1) When the post_html pref is active - raw html is used in the editor and wrapped in [html] [/html] bbcodes in the background. + * 2) When the post_html pref is disabled - bbcodes are used in the background and converted to html for the editor. + * Tested extensively over 24 hours with Images - check with Cameron first if issues arise. + * TODO Check with html5 tags active. +*/ +class e107TinyMceParser { + protected $gzipCompression = true; - // 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']); - - if(check_class($pref['post_html'])) // raw HTML within [html] tags. - { - - - // $content = $tp->replaceConstants($content,'abs'); - - if(strstr($content,"[html]") === false) // 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}",e_HTTP,$content); // We want {e_BASE} in the final data going to the DB, but not the editor. - $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! - - if(!empty($content) && E107_DEBUG_LEVEL > 0) - { - $content = "-- DEBUG MODE ACTIVE -- \n".$content; - // echo htmlentities($content)."\n"; - // echo "
".$content."
"; - echo $content; - exit; - } - - - echo $content; - - } - else // bbcode Mode. - { - - // XXX @Cam this breaks new lines, currently we use \n instead [br] - //echo $tp->toHtml(str_replace("\n","",$content), true); - - $content = str_replace("{e_BASE}",e_HTTP, $content); // We want {e_BASE} in the final data going to the DB, but not the editor. - $content = $tp->toHtml($content, true); - $content = str_replace(e_MEDIA_IMAGE,"{e_MEDIA_IMAGE}",$content); - - if(!empty($content) && E107_DEBUG_LEVEL > 0) - { - echo ""; - //print_r(htmlentities($content))."\n"; - //exit; - } - - echo $content; - } - - e107::getBB()->clearClass(); -} - -if($_POST['mode'] == 'tobbcode') -{ - // echo $_POST['content']; - $content = stripslashes($_POST['content']); - - if(check_class($pref['post_html'])) // Plain HTML mode. - { - $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'; - // $prepl = 'parseBBTags($content,true); // replace html with bbcode equivalent - - if(strip_tags($content, '') == ' ') // Avoid this: [html]

 

[/html] - { - exit; - } - - echo $content ? "[html]".$content."[/html]" : ""; // Add the tags before saving to DB. - } - else // bbcode Mode. //XXX Disabled at the moment in tinymce/e_meta.php - post_html is required to activate. - { - // [img width=400]/e107_2.0/thumb.php?src={e_MEDIA_IMAGE}2012-12/e107org_white_stripe.png&w=400&h=0[/img] - // $content = str_replace("{e_BASE}","", $content); // We want {e_BASE} in the final data going to the DB, but not the editor. - - echo e107::getBB()->htmltoBBcode($content); // not reliable enough yet. - } - -} - -/** - * Rebuld tags with modified thumbnail size. - */ -function updateImg($text) -{ - - $arr = e107::getParser()->getTags($text,'img'); - - $srch = array("?","&"); - $repl = array("\?","&"); - - foreach($arr['img'] as $img) + /** + * + */ + function __construct() { - $regexp = '#(]*src="'.str_replace($srch, $repl, $img['src']).'"[^>]*>)#'; + $html = ''; - $width = vartrue($img['width']) ? ' width="'.$img['width'].'"' : ''; - $height = vartrue($img['height']) ? ' height="'.$img['height'].'"' : ''; - $style = vartrue($img['style']) ? ' style="'.$img['style'].'"' : ''; - $class = vartrue($img['class']) ? ' class="'.$img['class'].'"' : ''; - $alt = vartrue($img['alt']) ? ' alt="'.$img['alt'].'"' : ''; - - list($url,$qry) = explode("?",$img['src']); - - parse_str($qry,$qr); - - $qr['w'] = $img['width']; - $qr['h'] = $img['height']; - - $src = $url."?".urldecode(http_build_query($qr)); - - $replacement = ''; - - $text = preg_replace($regexp, $replacement, $text); - - - } + if($_POST['mode'] == 'tohtml') + { + $html = $this->toHtml($_POST['content']); + } + + if($_POST['mode'] == 'tobbcode') + { + $html = $this->toBBcode($_POST['content']); + } + + if($this->gzipCompression == true) + { + header('Content-Encoding: gzip'); + $gzipoutput = gzencode($html,6); + header('Content-Length: '.strlen($gzipoutput)); + echo $gzipoutput; + } + else + { + echo $html; + } + + } + + + + function toHtml($content) + { + global $pref, $tp; //XXX faster? + // XXX @Cam possible fix - convert to BB first, see news admin AJAX request/response values for reference why + $content = stripslashes($content); + + // $content = e107::getBB()->htmltoBBcode($content); //XXX This breaks inserted images from media-manager. :/ + e107::getBB()->setClass($_SESSION['media_category']); + + if(check_class($pref['post_html'])) // raw HTML within [html] tags. + { + + // $content = $tp->replaceConstants($content,'abs'); + + if(strstr($content,"[html]") === false) // 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}",e_HTTP,$content); // We want {e_BASE} in the final data going to the DB, but not the editor. + $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! + + if(!empty($content) && E107_DEBUG_LEVEL > 0) + { + $content = "-- DEBUG MODE ACTIVE -- \n".$content; + // echo htmlentities($content)."\n"; + // echo "
".$content."
"; + $text = $content; + return $text; + // exit; + } + else + { + $text = $content; + } + + + + } + else // bbcode Mode. + { + + // XXX @Cam this breaks new lines, currently we use \n instead [br] + //echo $tp->toHtml(str_replace("\n","",$content), true); + + $content = str_replace("{e_BASE}",e_HTTP, $content); // We want {e_BASE} in the final data going to the DB, but not the editor. + $content = $tp->toHtml($content, true); + $content = str_replace(e_MEDIA_IMAGE,"{e_MEDIA_IMAGE}",$content); + + $text = ""; + if(!empty($content) && E107_DEBUG_LEVEL > 0) + { + $text .= ""; + //print_r(htmlentities($content))."\n"; + //exit; + } + + $text .= $content; + } + + e107::getBB()->clearClass(); + return $text; + + } + + + + function toBBcode($content) + { + // echo $_POST['content']; + global $pref, $tp; + $content = stripslashes($content); + + if(check_class($pref['post_html'])) // Plain HTML mode. + { + $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'; + // $prepl = 'updateImg($content); + $content = $tp->parseBBTags($content,true); // replace html with bbcode equivalent + + if(strip_tags($content, '') == ' ') // Avoid this: [html]

 

[/html] + { + exit; + } + + $text = $content ? "[html]".$content."[/html]" : ""; // Add the tags before saving to DB. + } + else // bbcode Mode. //XXX Disabled at the moment in tinymce/e_meta.php - post_html is required to activate. + { + // [img width=400]/e107_2.0/thumb.php?src={e_MEDIA_IMAGE}2012-12/e107org_white_stripe.png&w=400&h=0[/img] + // $content = str_replace("{e_BASE}","", $content); // We want {e_BASE} in the final data going to the DB, but not the editor. + + $text = e107::getBB()->htmltoBBcode($content); // not reliable enough yet. + } + + return $text; + + } + + + /** + * Rebuld tags with modified thumbnail size. + */ + function updateImg($text) + { + + $arr = e107::getParser()->getTags($text,'img'); + + $srch = array("?","&"); + $repl = array("\?","&"); + + foreach($arr['img'] as $img) + { + $regexp = '#(]*src="'.str_replace($srch, $repl, $img['src']).'"[^>]*>)#'; + + $width = vartrue($img['width']) ? ' width="'.$img['width'].'"' : ''; + $height = vartrue($img['height']) ? ' height="'.$img['height'].'"' : ''; + $style = vartrue($img['style']) ? ' style="'.$img['style'].'"' : ''; + $class = vartrue($img['class']) ? ' class="'.$img['class'].'"' : ''; + $alt = vartrue($img['alt']) ? ' alt="'.$img['alt'].'"' : ''; + + list($url,$qry) = explode("?",$img['src']); + + parse_str($qry,$qr); + + $qr['w'] = $img['width']; + $qr['h'] = $img['height']; + + $src = $url."?".urldecode(http_build_query($qr)); + + $replacement = ''; + + $text = preg_replace($regexp, $replacement, $text); + + + } + + return $text; + + + } - return $text; } +new e107TinyMceParser(); + + ?> \ No newline at end of file