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. { 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}","",$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! 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); 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 echo ($content) ? "[html]".$content."[/html]" : ""; // Add the tags before saving to DB. } else // bbcode Mode. { // [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); } } /** * 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; } ?>