]> git.mxchange.org Git - friendica.git/blobdiff - include/bbcode.php
Merge pull request #4365 from MrPetovan/task/4116-add-autoload-to-library
[friendica.git] / include / bbcode.php
index f95c911d5eb299e081b925cf44675dcb0523a7d6..20631818a2503fbe8167130edd644e1cccd6a41b 100644 (file)
@@ -5,6 +5,7 @@
 use Friendica\App;
 use Friendica\Content\Smilies;
 use Friendica\Content\OEmbed;
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\Cache;
 use Friendica\Core\L10n;
@@ -12,10 +13,10 @@ use Friendica\Core\System;
 use Friendica\Core\Config;
 use Friendica\Model\Contact;
 use Friendica\Util\Map;
+use Friendica\Util\Network;
 
 require_once 'include/event.php';
 require_once 'mod/proxy.php';
-require_once 'include/plaintext.php';
 
 function bb_PictureCacheExt($matches) {
        if (strpos($matches[3], "data:image/") === 0) {
@@ -57,7 +58,7 @@ function bb_map_location($match) {
  */
 function bb_attachment($return, $simplehtml = false, $tryoembed = true)
 {
-       $data = get_attachment_data($return);
+       $data = BBCode::getAttachmentData($return);
        if (!$data) {
                return $return;
        }
@@ -106,7 +107,7 @@ function bb_attachment($return, $simplehtml = false, $tryoembed = true)
                        }
 
                        if ($data["type"] == "link") {
-                               $return .= sprintf('<h5><a href="%s">%s</a></h5>', $data['url'], parse_url($data['url'], PHP_URL_HOST));
+                               $return .= sprintf('<sup><a href="%s">%s</a></sup>', $data['url'], parse_url($data['url'], PHP_URL_HOST));
                        }
 
                        if ($simplehtml != 4) {
@@ -120,7 +121,7 @@ function bb_attachment($return, $simplehtml = false, $tryoembed = true)
 
 function bb_remove_share_information($Text, $plaintext = false, $nolink = false) {
 
-       $data = get_attachment_data($Text);
+       $data = BBCode::getAttachmentData($Text);
 
        if (!$data) {
                return $Text;
@@ -688,7 +689,7 @@ function GetProfileUsername($profile, $username, $compact = false, $getnetwork =
                $StatusnetUser = preg_replace("=https?://(.*)/user/(.*)=ism", "$2", $profile);
                if ($StatusnetUser != $profile) {
                        /// @TODO Some hosts run on https, not just http and sometimes http is disabled, let's support both here
-                       $UserData = fetch_url("http://".$StatusnetHost."/api/users/show.json?user_id=".$StatusnetUser);
+                       $UserData = Network::fetchUrl("http://".$StatusnetHost."/api/users/show.json?user_id=".$StatusnetUser);
                        $user = json_decode($UserData);
                        if ($user) {
                                if ($getnetwork) {
@@ -747,9 +748,7 @@ function bb_RemovePictureLinks($match) {
                        $text = "[url=".$match[2]."]".$match[2]."[/url]";
 
                        // if its not a picture then look if its a page that contains a picture link
-                       require_once("include/network.php");
-
-                       $body = fetch_url($match[1]);
+                       $body = Network::fetchUrl($match[1]);
 
                        $doc = new DOMDocument();
                        @$doc->loadHTML($body);
@@ -804,9 +803,7 @@ function bb_CleanPictureLinksSub($match) {
                        $text = "[img]".$match[2]."[/img]";
 
                        // if its not a picture then look if its a page that contains a picture link
-                       require_once("include/network.php");
-
-                       $body = fetch_url($match[1]);
+                       $body = Network::fetchUrl($match[1]);
 
                        $doc = new DOMDocument();
                        @$doc->loadHTML($body);
@@ -1000,8 +997,9 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $simplehtml = fa
        if ((!$tryoembed || $simplehtml) && !in_array($simplehtml, [3, 7])) {
                $Text = preg_replace("/([#@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism", '$1$3', $Text);
        } elseif ($simplehtml == 3) {
+               // The ! is converted to @ since Diaspora only understands the @
                $Text = preg_replace("/([@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",
-                       '$1<a href="$2">$3</a>',
+                       '@<a href="$2">$3</a>',
                        $Text);
        } elseif ($simplehtml == 7) {
                $Text = preg_replace("/([@!])\[url\=([$URLSearchString]*)\](.*?)\[\/url\]/ism",