]> git.mxchange.org Git - friendica-addons.git/commitdiff
Statusnet: Testing new plaintext function/avoiding warning when content couldn't...
authorMichael Vogel <icarus@dabo.de>
Wed, 21 May 2014 04:45:03 +0000 (06:45 +0200)
committerMichael Vogel <icarus@dabo.de>
Wed, 21 May 2014 04:45:03 +0000 (06:45 +0200)
statusnet/statusnet.php

index 1109a0f2cb1ff9ccb69fa38f0ad75f6d28f178f2..4888121231e321fd5764edf3b00093168bc1927a 100644 (file)
@@ -837,9 +837,29 @@ function statusnet_post_hook(&$a,&$b) {
                        $msg = trim($msg);
                        $postdata = array('status' => $msg);
                } else {
-                       $msgarr = statusnet_shortenmsg($b, $max_char);
+/*                     $msgarr = statusnet_shortenmsg($b, $max_char);
                        $msg = $msgarr["msg"];
                        $image = $msgarr["image"];
+*/
+                       require_once("include/plaintext.php");
+                       require_once("include/network.php");
+                       $msgarr = plaintext($a, $b, $max_char, true);
+                       $msg = $msgarr["text"];
+
+                       if (($msg == "") AND isset($msgarr["title"]))
+                               $msg = shortenmsg($msgarr["title"], $max_char - 50);
+
+                       $image = "";
+
+                       if (isset($msgarr["url"])) {
+                               if ((strlen($msgarr["url"]) > 20) AND
+                                       ((strlen($msg." ".$msgarr["url"]) > $max_char)))
+                                       $msg .= " ".short_link($msgarr["url"]);
+                               else
+                                       $msg .= " ".$msgarr["url"];
+                       } elseif (isset($msgarr["image"]))
+                               $image = $msgarr["image"];
+
                        if ($image != "") {
                                $img_str = fetch_url($image);
                                $tempfile = tempnam(get_config("system","temppath"), "cache");
@@ -1661,21 +1681,23 @@ function statusnet_complete_conversation($a, $uid, $self, $create_user, $nick, $
        $parameters["count"] = 200;
 
        $items = $connection->get('statusnet/conversation/'.$conversation, $parameters);
-       $posts = array_reverse($items);
+       if (is_array($items)) {
+               $posts = array_reverse($items);
 
-       foreach($posts AS $post) {
-               $postarray = statusnet_createpost($a, $uid, $post, $self, $create_user, true);
+               foreach($posts AS $post) {
+                       $postarray = statusnet_createpost($a, $uid, $post, $self, $create_user, true);
 
-               if (trim($postarray['body']) == "")
-                       continue;
+                       if (trim($postarray['body']) == "")
+                               continue;
 
-               //print_r($postarray);
-               $item = item_store($postarray);
+                       //print_r($postarray);
+                       $item = item_store($postarray);
 
-               logger('statusnet_complete_conversation: User '.$self["nick"].' posted home timeline item '.$item);
+                       logger('statusnet_complete_conversation: User '.$self["nick"].' posted home timeline item '.$item);
 
-               if ($item != 0)
-                       statusnet_checknotification($a, $uid, $nick, $item, $postarray);
+                       if ($item != 0)
+                               statusnet_checknotification($a, $uid, $nick, $item, $postarray);
+               }
        }
 }