MyBB Community Forums

Full Version: remove BRs in quotes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello.
I do a modification into doquotes() function that thought its better that show it to you.
it is a common problem with Quoting when we quote a message we like to insert an "Enter" between quoted message and our new message. also other new lines are common! but there is no need to them atall. because the CSS class of coute seperate them automatically.
I suggest removing extra <br> \n\r &etc from original messages and output view. this way our post will have a beautifull view.

function doquotes($message)
{
	global $lang;
	$removeBR="[\n\r]{0,2}";
	// user sanity check
	$pattern = array("#$removeBR\[quote=(?:&quot;|\"|')?(.*?)[\"']?(?:&quot;|\"|')?\]$removeBR(.*?)$removeBR\[\/quote\]$removeBR#si",
					 "#$removeBR\[quote\]$removeBR(.*?)$removeBR\[\/quote\]$removeBR#si");
	
	$replace = array("<div class=\"quote_header\">$1 $lang->wrote</div><div class=\"quote_body\">$2</div>",
					 "<div class=\"quote_header\">$lang->quote</div><div class=\"quote_body\">$1</div>\n");
	
	while (preg_match($pattern[0], $message) or preg_match($pattern[1], $message))
	{
		$message = preg_replace($pattern, $replace, $message);
	}
	$message = str_replace("<div class=\"quote_body\"><br />", "<div class=\"quote_body\">", $message);
	$message = str_replace("<br /></div>", "</div>", $message);
	// Remove [attachment=x] from quoted posts.
    	//$message = preg_replace("#\[attachment=([0-9]+?)\]#i", "", $message);
	return $message;
}
I also have modified newreply.php:
if($pid && !$mybb->input['previewpost'] && $mybb->input['action'] != "editdraft")
	{
		$query = $db->query("SELECT p.*, u.username FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid) WHERE p.pid='$pid' AND p.tid='$tid' AND p.visible='1'");
		$quoted = $db->fetch_array($query);
		$quoted['subject'] = preg_replace("#RE:#i", "", stripslashes($quoted['subject']));
		//$subject = "RE: ".$quoted['subject'];
		$quoted['message'] = preg_replace('#^/me (.*)$#im', "* $quoted[username] \\1", $quoted['message']);
		if($quoted['username'])
		{
			$message = "[quote=$quoted[username]]$quoted[message][/quote]";
		}
		else
		{
			$message = "[quote]$quoted[message][/quote]";
		}
	}
near line 170.
http://www.gozarehforum.com/showthread.p...8&pid=6941
here is an example! I cant decrease or increase Breaks!