From bac1ed221472fae1ff86bd4091a341b2870ab941 Mon Sep 17 00:00:00 2001 From: tonnerkiller Date: Sat, 16 Aug 2014 15:48:44 +0200 Subject: Added "if(!function_exists('xpost_to_html2bbcode'))" This function name is also used by post to friendica plugin Both functions seem to be identical. If you have both plugins installed you get an error because of the identical function name This will avoid the attempt to load the function a second time in case it was already loaded by the post to friendica plugin --- util/wp/post_to_red/post_to_red.php | 132 +++++++++++++++++++----------------- 1 file changed, 68 insertions(+), 64 deletions(-) (limited to 'util/wp/post_to_red') diff --git a/util/wp/post_to_red/post_to_red.php b/util/wp/post_to_red/post_to_red.php index 5146b8be1..ea6026ae2 100644 --- a/util/wp/post_to_red/post_to_red.php +++ b/util/wp/post_to_red/post_to_red.php @@ -418,72 +418,76 @@ function post_to_red_get_avatar($avatar,$id_or_email,$size,$default,$alt) { // from: // http://www.docgate.com/tutorial/php/how-to-convert-html-to-bbcode-with-php-script.html -function xpost_to_html2bbcode($text) { - $htmltags = array( - '/\(.*?)\<\/b\>/is', - '/\(.*?)\<\/i\>/is', - '/\(.*?)\<\/u\>/is', - '/\(.*?)\<\/ul\>/is', - '/\(.*?)\<\/li\>/is', - '/\/is', // some smiley - '/\/is', - '/\/is', // some smiley - '/\
(.*?)\<\/div\>/is', - '/\
(.*?)\<\/div\>/is', - '/\
(.*?)\<\/div\>/is', - '/\
(.*?)\<\/div\>/is', - '/\(.*?)\<\/cite\>/is', - '/\(.*?)\<\/blockquote\>/is', - '/\(.*?)\<\/div\>/is', - '/\(.*?)\<\/code\>/is', - '/\/is', - '/\(.*?)\<\/strong\>/is', - '/\(.*?)\<\/em\>/is', - '/\(.*?)\<\/a\>/is', - '/\http:\/\/(.*?)\<\/a\>/is', - '/\(.*?)\<\/a\>/is' - ); - - $bbtags = array( - '[b]$1[/b]', - '[i]$1[/i]', - '[u]$1[/u]', - '[list]$1[/list]', - '[*]$1', - '$3', - '[img]http://$2[/img]' . "\n", - ':$3', - '[quote]$1[/quote]', - '[code]$1[/code]', - '', - '', - '', - '[quote]$1[/quote]', - '$1', - '[code]$1[/code]', - "\n", - '[b]$1[/b]', - '[i]$1[/i]', - '[email=$1]$3[/email]', - '[url]$1[/url]', - '[url=$1]$3[/url]' - ); - - $text = str_replace ("\n", ' ', $text); - $ntext = preg_replace ($htmltags, $bbtags, $text); - $ntext = preg_replace ($htmltags, $bbtags, $ntext); - - // for too large text and cannot handle by str_replace - if (!$ntext) { - $ntext = str_replace(array('
', '
'), "\n", $text); - $ntext = str_replace(array('', ''), array('[b]', '[/b]'), $ntext); - $ntext = str_replace(array('', ''), array('[i]', '[/i]'), $ntext); - } - $ntext = strip_tags($ntext); +//function exists also in post to friendica plugin; load only if not yet loaded by that plugin +if(!function_exists('xpost_to_html2bbcode')) { + function xpost_to_html2bbcode($text) { + $htmltags = array( + '/\(.*?)\<\/b\>/is', + '/\(.*?)\<\/i\>/is', + '/\(.*?)\<\/u\>/is', + '/\(.*?)\<\/ul\>/is', + '/\(.*?)\<\/li\>/is', + '/\/is', // some smiley + '/\/is', + '/\/is', // some smiley + '/\