X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fbbcode.php;h=d1cb1a9110d3484a48f75e4dc66dd9e5ff379d89;hb=30efb0c1e641b0b9d3aa40a5a79897c6d06ac3ef;hp=7f70563c7ae330bf20df95828d6764356e23bc2d;hpb=57db109474fcdb9e2b2a9173e6a3397e20f2ca7a;p=friendica.git
diff --git a/include/bbcode.php b/include/bbcode.php
index 7f70563c7a..d1cb1a9110 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -2,6 +2,35 @@
require_once("include/oembed.php");
require_once('include/event.php');
+function bb_rearrange_link($shared) {
+ if ($shared[1] != "type-link")
+ return($shared[0]);
+
+ $newshare = trim($shared[2]);
+ $newshare = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.*?)\[\/img\]/ism", '[img]$3[/img]', $newshare);
+
+ if (!strpos($shared[0], "[bookmark"))
+ $newshare = preg_replace("/\[url\=(.*?)\](.*?)\[\/url\]/ism", '[bookmark=$1]$2[/bookmark]', $newshare, 1);
+
+ preg_match("/\[img\](.*?)\[\/img\]/ism", $newshare, $matches);
+
+ if ($matches) {
+ $newshare = str_replace($matches[0], '', $newshare);
+ $newshare = "[img]".$matches[1]."[/img]\n".$newshare;
+ }
+
+ $search = array("\n\n", "\n ", " \n");
+ $replace = array("\n", "\n", "\n");
+ do {
+ $oldtext = $newshare;
+ $newshare = str_replace($search, $replace, $newshare);
+ } while ($oldtext != $newshare);
+
+ $newshare = "[class=type-link]".$newshare."[/class]";
+
+ return($newshare);
+}
+
function bb_remove_share_information($Text) {
$Text = preg_replace_callback("((.*?)\[class=(.*?)\](.*?)\[\/class\])ism","bb_cleanup_share",$Text);
return($Text);
@@ -26,8 +55,8 @@ function bb_cleanup_share($shared) {
if (strpos($shared[1],$title) !== false)
$title = "";
- if (strpos($shared[1],$link) !== false)
- $link = "";
+// if (strpos($shared[1],$link) !== false)
+// $link = "";
$text = trim($shared[1]);
@@ -491,7 +520,8 @@ function bb_ShareAttributesSimple2($match) {
$userid = GetProfileUsername($profile,$author);
- $text = "
".html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').' '.$userid.":
".$match[2];
+ //$text = "
".html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').' '.$userid.":
".$match[2];
+ $text = "
".html_entity_decode("♲ ", ENT_QUOTES, 'UTF-8').' '.$userid.":
".$match[2];
return($text);
}
@@ -525,10 +555,13 @@ function GetProfileUsername($profile, $username) {
}
}
- // To-Do: Better check for pumpio
- $pumpio = preg_replace("=https?://([^/]*).*/(\w*)=ism", "$2@$1", $profile);
- if ($pumpio != $profile)
- return($username." (".$pumpio.")");
+ // pumpio (http://host.name/user)
+ $rest = preg_replace("=https?://([\.\w]+)/([\.\w]+)(.*)=ism", "$3", $profile);
+ if ($rest == "") {
+ $pumpio = preg_replace("=https?://([\.\w]+)/([\.\w]+)(.*)=ism", "*$2@$1*", $profile);
+ if ($pumpio != $profile)
+ return($username." (".$pumpio.")");
+ }
return($username);
}
@@ -670,6 +703,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
$Text = preg_replace("/\n\[code\]/ism", "[code]", $Text);
$Text = preg_replace("/\[\/code\]\n/ism", "[/code]", $Text);
+ // Rearrange shared links
+ if (get_config("system", "rearrange_shared_links") AND (!$simplehtml OR $tryoembed))
+ $Text = preg_replace_callback("(\[class=(.*?)\](.*?)\[\/class\])ism","bb_rearrange_link",$Text);
+
// when the content is meant exporting to other systems then remove the avatar picture since this doesn't really look good on these systems
if (!$tryoembed)
$Text = preg_replace("/\[share(.*?)avatar\s?=\s?'.*?'\s?(.*?)\]\s?(.*?)\s?\[\/share\]\s?/ism","\n[share$1$2]$3[/share]",$Text);