]> git.mxchange.org Git - friendica.git/blobdiff - include/bbcode.php
frio + core: some restructure in profiles.php + frio template for profiles settings
[friendica.git] / include / bbcode.php
index b2c278013d1e01650231235efef2218406467aa4..62f56558fb6871a233b3122886821a65420e7190 100644 (file)
@@ -38,6 +38,11 @@ function bb_attachment($Text, $simplehtml = false, $tryoembed = true) {
        if (!$data)
                return $Text;
 
+       if (isset($data["title"])) {
+               $data["title"] = strip_tags($data["title"]);
+               $data["title"] = str_replace(array("http://", "https://"), "", $data["title"]);
+       }
+
        if (((strpos($data["text"], "[img=") !== false) OR (strpos($data["text"], "[img]") !== false)) AND ($data["image"] != "")) {
                $data["preview"] = $data["image"];
                $data["image"] = "";
@@ -94,26 +99,32 @@ function bb_remove_share_information($Text, $plaintext = false, $nolink = false)
                return $Text;
 
        if ($nolink)
-               return $data["text"];
+               return $data["text"].$data["after"];
 
-       if ($plaintext)
+       $title = htmlentities($data["title"], ENT_QUOTES, 'UTF-8', false);
+       $text = htmlentities($data["text"], ENT_QUOTES, 'UTF-8', false);
+       if ($plaintext OR (($title != "") AND strstr($text, $title)))
                $data["title"] = $data["url"];
+       elseif (($text != "") AND strstr($title, $text)) {
+               $data["text"] = $data["title"];
+               $data["title"] = $data["url"];
+       }
 
        if (($data["text"] == "") AND ($data["title"] != "") AND ($data["url"] == ""))
-               return $data["title"];
+               return $data["title"].$data["after"];
 
        // If the link already is included in the post, don't add it again
        if (($data["url"] != "") AND strpos($data["text"], $data["url"]))
-               return $data["text"];
+               return $data["text"].$data["after"];
 
        $text = $data["text"];
 
        if (($data["url"] != "") AND ($data["title"] != ""))
                $text .= "\n[url=".$data["url"]."]".$data["title"]."[/url]";
-       elseif (($link != ""))
+       elseif (($data["url"] != ""))
                $text .= "\n".$data["url"];
 
-       return $text;
+       return $text."\n".$data["after"];
 }
 
 function bb_cleanstyle($st) {
@@ -385,18 +396,17 @@ function bb_ShareAttributes($share, $simplehtml) {
 
        $itemcache = get_itemcachepath();
 
-       // relative dates only make sense when they aren't cached
-       if ($itemcache == "") {
-               preg_match("/posted='(.*?)'/ism", $attributes, $matches);
-               if ($matches[1] != "")
-                       $posted = $matches[1];
+       preg_match("/posted='(.*?)'/ism", $attributes, $matches);
+       if ($matches[1] != "")
+               $posted = $matches[1];
 
-               preg_match('/posted="(.*?)"/ism', $attributes, $matches);
-               if ($matches[1] != "")
-                       $posted = $matches[1];
+       preg_match('/posted="(.*?)"/ism', $attributes, $matches);
+       if ($matches[1] != "")
+               $posted = $matches[1];
 
+       // relative dates only make sense when they aren't cached
+       if ($itemcache == "")
                $reldate = (($posted) ? " " . relative_date($posted) : '');
-       }
 
        $data = get_contact_details_by_url($profile);
 
@@ -478,13 +488,20 @@ function bb_ShareAttributes($share, $simplehtml) {
                                $text .= "<br /><br />".$link;
                        break;
                default:
-                       $headline = trim($share[1]).'<div class="shared_header">';
-                       if ($avatar != "")
-                               $headline .= '<img src="'.proxy_url($avatar, false, PROXY_SIZE_MICRO).'" height="32" width="32" >';
-
-                       $headline .= sprintf(t('<span><a href="%s" target="_blank">%s</a> wrote the following <a href="%s" target="_blank">post</a>'.$reldate.':</span>'), $profile, $author, $link);
-                       $headline .= "</div>";
-                       $text = $headline.'<blockquote class="shared_content">'.trim($share[3])."</blockquote>";
+                       $text = trim($share[1])."\n";
+
+                       $tpl = get_markup_template('shared_content.tpl');
+                       $text .= replace_macros($tpl,
+                                       array(
+                                               '$profile' => $profile,
+                                               '$avatar' => $avatar,
+                                               '$author' => $author,
+                                               '$link' => $link,
+                                               '$posted' => $posted,
+                                               '$reldate' => $reldate,
+                                               '$content' => trim($share[3])
+                                       )
+                               );
                        break;
        }
        return($text);
@@ -798,7 +815,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
                $Text = preg_replace("/([@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
                        '$1<span class="vcard"><a href="$2" class="url" title="$3"><span class="fn nickname mention">$3</span></a></span>',
                        $Text);
-
+       elseif (!$simplehtml)
+               $Text = preg_replace("/([@])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
+                       '$1<a href="$2" class="userinfo mention" title="$3">$3</a>',
+                       $Text);
 
        // Bookmarks in red - will be converted to bookmarks in friendica
        $Text = preg_replace("/#\^\[url\]([$URLSearchString]*)\[\/url\]/ism", '[bookmark=$1]$1[/bookmark]', $Text);
@@ -840,6 +860,9 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true, $simplehtml = fal
        if ($tryoembed)
                $Text = preg_replace_callback("/\[url\]([$URLSearchString]*)\[\/url\]/ism",'tryoembed',$Text);
 
+       $Text = preg_replace("/([#])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
+                               '$1<a href="$2" class="tag" title="$3">$3</a>', $Text);
+
        $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/ism", '<a href="$1" target="_blank">$1</a>', $Text);
        $Text = preg_replace("/\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '<a href="$1" target="_blank">$2</a>', $Text);
        //$Text = preg_replace("/\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[\/url\]/ism", '<a href="$1" target="_blank">$2</a>', $Text);