From a7abe24382bac00243fd19ebc2cdde87569eab79 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 22 Oct 2012 19:46:18 -0700 Subject: more file cleanup --- include/bbcode.php | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) (limited to 'include/bbcode.php') diff --git a/include/bbcode.php b/include/bbcode.php index b383f43b6..dd0cc6958 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -5,23 +5,15 @@ require_once('include/event.php'); -function stripcode_br_cb($s) { - return '[code]' . str_replace('
', '', $s[1]) . '[/code]'; -} - -function tryoembed($match){ +function tryoembed($match) { $url = ((count($match)==2)?$match[1]:$match[2]); -// logger("tryoembed: $url"); $o = oembed_fetch_url($url); - //echo "
"; var_dump($match, $url, $o); killme();
-
 	if ($o->type=="error") return $match[0];
 
 	$html = oembed_format_object($o);
-	return $html; //oembed_iframe($html,$o->width,$o->height);
-
+	return $html; 
 }
 
 // [noparse][i]italic[/i][/noparse] turns into
@@ -115,25 +107,26 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
 
 	$a = get_app();
 
+	// Extract the private images which use data url's since preg has issues with
+	// large data sizes. Stash them away while we do bbcode conversion, and then put them back
+	// in after we've done all the regex matching. We cannot use any preg functions to do this.
+
+	$extracted = bb_extract_images($Text);
+	$Text = $extracted['body'];
+	$saved_image = $extracted['images'];
+
+
 	// Move all spaces out of the tags
 	$Text = preg_replace("/\[(\w*)\](\s*)/ism", '$2[$1]', $Text);
 	$Text = preg_replace("/(\s*)\[\/(\w*)\]/ism", '[/$2]$1', $Text);
 
 	// Hide all [noparse] contained bbtags by spacefying them
-	// POSSIBLE BUG --> Will the 'preg' functions crash if there's an embedded image?
 
 	$Text = preg_replace_callback("/\[noparse\](.*?)\[\/noparse\]/ism", 'bb_spacefy',$Text);
 	$Text = preg_replace_callback("/\[nobb\](.*?)\[\/nobb\]/ism", 'bb_spacefy',$Text);
 	$Text = preg_replace_callback("/\[pre\](.*?)\[\/pre\]/ism", 'bb_spacefy',$Text);
 
 
-	// Extract the private images which use data url's since preg has issues with
-	// large data sizes. Stash them away while we do bbcode conversion, and then put them back
-	// in after we've done all the regex matching. We cannot use any preg functions to do this.
-
-	$extracted = bb_extract_images($Text);
-	$Text = $extracted['body'];
-	$saved_image = $extracted['images'];
 
 	// If we find any event code, turn it into an event.
 	// After we're finished processing the bbcode we'll
@@ -266,8 +259,6 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
 
 	// Declare the format for [code] layout
 
-//	$Text = preg_replace_callback("/\[code\](.*?)\[\/code\]/ism",'stripcode_br_cb',$Text);
-
 	$CodeLayout = '$1';
 	// Check for [code] text
 	$Text = preg_replace("/\[code\](.*?)\[\/code\]/ism","$CodeLayout", $Text);
-- 
cgit v1.2.3