]> 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 2223eac63422b204f19b6bb8a897274f11fe19c5..20631818a2503fbe8167130edd644e1cccd6a41b 100644 (file)
@@ -5,7 +5,7 @@
 use Friendica\App;
 use Friendica\Content\Smilies;
 use Friendica\Content\OEmbed;
-use Friendica\Content\Text\Plaintext;
+use Friendica\Content\Text\BBCode;
 use Friendica\Core\Addon;
 use Friendica\Core\Cache;
 use Friendica\Core\L10n;
@@ -13,6 +13,7 @@ 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';
@@ -57,7 +58,7 @@ function bb_map_location($match) {
  */
 function bb_attachment($return, $simplehtml = false, $tryoembed = true)
 {
-       $data = Plaintext::getAttachmentData($return);
+       $data = BBCode::getAttachmentData($return);
        if (!$data) {
                return $return;
        }
@@ -120,7 +121,7 @@ function bb_attachment($return, $simplehtml = false, $tryoembed = true)
 
 function bb_remove_share_information($Text, $plaintext = false, $nolink = false) {
 
-       $data = Plaintext::getAttachmentData($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",