From e85593e97057eaf041e6e63ec11b12b6beb2e0ce Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 6 May 2015 21:43:15 -0700 Subject: Hopefully this will make item_cache the default --- include/bbcode.php | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'include/bbcode.php') diff --git a/include/bbcode.php b/include/bbcode.php index 4ff6f842e..71c069c39 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -381,10 +381,47 @@ function bb_sanitize_style($input) { return '' . $input[2] . ''; } +function bb_observer($Text) { + + $observer = $a->get_observer(); + + if ((strpos($Text,'[/observer]') !== false) || (strpos($Text,'[/rpost]') !== false)) { + if ($observer) { + $Text = preg_replace("/\[observer\=1\](.*?)\[\/observer\]/ism", '$1', $Text); + $Text = preg_replace("/\[observer\=0\].*?\[\/observer\]/ism", '', $Text); + $Text = preg_replace_callback("/\[rpost(=(.*?))?\](.*?)\[\/rpost\]/ism", 'rpost_callback', $Text); + } else { + $Text = preg_replace("/\[observer\=1\].*?\[\/observer\]/ism", '', $Text); + $Text = preg_replace("/\[observer\=0\](.*?)\[\/observer\]/ism", '$1', $Text); + $Text = preg_replace("/\[rpost(=.*?)?\](.*?)\[\/rpost\]/ism", '', $Text); + } + } + + $channel = $a->get_channel(); + + if (strpos($Text,'[/channel]') !== false) { + if ($channel) { + $Text = preg_replace("/\[channel\=1\](.*?)\[\/channel\]/ism", '$1', $Text); + $Text = preg_replace("/\[channel\=0\].*?\[\/channel\]/ism", '', $Text); + } else { + $Text = preg_replace("/\[channel\=1\].*?\[\/channel\]/ism", '', $Text); + $Text = preg_replace("/\[channel\=0\](.*?)\[\/channel\]/ism", '$1', $Text); + } + } + + return $Text; +} + + + + + + + // BBcode 2 HTML was written by WAY2WEB.net // extended to work with Mistpark/Friendica/Red - Mike Macgirvin -function bbcode($Text, $preserve_nl = false, $tryoembed = true) { +function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) { $a = get_app(); @@ -420,7 +457,8 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true) { // process [observer] tags before we do anything else because we might // be stripping away stuff that then doesn't need to be worked on anymore - if(get_config('system','item_cache')) + + if($cache) $observer = false; else $observer = $a->get_observer(); @@ -437,7 +475,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true) { } } - if(get_config('system','item_cache')) + if($cache) $channel = false; else $channel = $a->get_channel(); @@ -452,6 +490,8 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true) { } } +*/ + $x = bb_extract_images($Text); $Text = $x['body']; -- cgit v1.2.3