]> git.mxchange.org Git - friendica-addons.git/blobdiff - buffer/buffer.php
langfilter added NL translation THX Karel Vandecandelaere
[friendica-addons.git] / buffer / buffer.php
index aef9a0fdcaacb370500ebaeaa865367d0875f8b0..bb1d8482e5405d23a3b642bba7f74e8d3277a3f7 100644 (file)
@@ -8,6 +8,7 @@
 require 'addon/buffer/bufferapp.php';
 
 use Friendica\App;
+use Friendica\Content\Text\BBCode;
 use Friendica\Content\Text\Plaintext;
 use Friendica\Core\Addon;
 use Friendica\Core\Config;
@@ -271,11 +272,9 @@ function buffer_send(App $a, &$b)
        $client_secret = Config::get("buffer", "client_secret");
        $access_token = PConfig::get($b['uid'], "buffer","access_token");
 
-       if($access_token) {
+       if ($access_token) {
                $buffer = new BufferApp($client_id, $client_secret, $callback_url, $access_token);
 
-               require_once 'include/network.php';
-
                $profiles = $buffer->go('/profiles');
                if (is_array($profiles)) {
                        logger("Will send these parameter ".print_r($b, true), LOGGER_DEBUG);
@@ -339,7 +338,7 @@ function buffer_send(App $a, &$b)
                                        $item["body"] = preg_replace("(\[s\](.*?)\[\/s\])ism",'-$1-',$item["body"]);
                                }
 
-                               $post = Plaintext::toPlaintext($item, $limit, $includedlinks, $htmlmode);
+                               $post = BBCode::toPlaintext($item, $limit, $includedlinks, $htmlmode);
                                logger("buffer_send: converted message ".$b["id"]." result: ".print_r($post, true), LOGGER_DEBUG);
 
                                // The image proxy is used as a sanitizer. Buffer seems to be really picky about pictures
@@ -352,11 +351,11 @@ function buffer_send(App $a, &$b)
 
                                //if ($includedlinks) {
                                //      if (isset($post["url"]))
-                               //              $post["url"] = short_link($post["url"]);
+                               //              $post["url"] = Network::shortenUrl($post["url"]);
                                //      if (isset($post["image"]))
-                               //              $post["image"] = short_link($post["image"]);
+                               //              $post["image"] = Network::shortenUrl($post["image"]);
                                //      if (isset($post["preview"]))
-                               //              $post["preview"] = short_link($post["preview"]);
+                               //              $post["preview"] = Network::shortenUrl($post["preview"]);
                                //}
 
                                // Seems like a bug to me
@@ -365,8 +364,8 @@ function buffer_send(App $a, &$b)
                                if (($profile->service == "twitter") && isset($post["url"]) && ($post["type"] != "photo"))
                                        $post["text"] .= " ".$post["url"];
                                elseif (($profile->service == "appdotnet") && isset($post["url"]) && isset($post["title"]) && ($post["type"] != "photo")) {
-                                       $post["title"] = Plaintext::shortenMsg($post["title"], 90);
-                                       $post["text"] = Plaintext::shortenMsg($post["text"], $limit - (24 + strlen($post["title"])));
+                                       $post["title"] = Plaintext::shorten($post["title"], 90);
+                                       $post["text"] = Plaintext::shorten($post["text"], $limit - (24 + strlen($post["title"])));
                                        $post["text"] .= "\n[".$post["title"]."](".$post["url"].")";
                                } elseif (($profile->service == "appdotnet") && isset($post["url"]) && ($post["type"] != "photo"))
                                        $post["text"] .= " ".$post["url"];