]> git.mxchange.org Git - friendica-addons.git/blobdiff - windowsphonepush/windowsphonepush.php
Merge remote-tracking branch 'upstream/develop' into item-abstraction
[friendica-addons.git] / windowsphonepush / windowsphonepush.php
index 206b0883e4b03241db96b7909d50ea28372a853e..a7453b1d383ed35b18ef8743dbc812f7b3cb255b 100644 (file)
 
 use Friendica\App;
 use Friendica\Content\Text\BBCode;
+use Friendica\Content\Text\HTML;
 use Friendica\Core\Addon;
 use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
 use Friendica\Model\User;
+use Friendica\Model\Item;
 
 function windowsphonepush_install()
 {
@@ -195,26 +197,24 @@ function windowsphonepush_cron()
                                        $senditemtext = PConfig::get($rr['uid'], 'windowsphonepush', 'senditemtext');
                                        if ($senditemtext == 1) {
                                                // load item with the max id
-                                               $item = q("SELECT `author-name` as author, `body` as body FROM `item` where `id` = %d", intval($count[0]['max']));
+                                               $item = Item::selectFirst(local_user(), ['author-name', 'body'], ['id' => $count[0]['max']]);
 
                                                // as user allows to send the item, we want to show the sender of the item in the toast
                                                // toasts are limited to one line, therefore place is limited - author shall be in
                                                // max. 15 chars (incl. dots); author is displayed in bold font
-                                               $author = $item[0]['author'];
+                                               $author = $item['author-name'];
                                                $author = ((strlen($author) > 12) ? substr($author, 0, 12) . "..." : $author);
 
                                                // normally we show the body of the item, however if it is an url or an image we cannot
                                                // show this in the toast (only test), therefore changing to an alternate text
                                                // Otherwise BBcode-Tags will be eliminated and plain text cutted to 140 chars (incl. dots)
                                                // BTW: information only possible in English
-                                               $body = $item[0]['body'];
+                                               $body = $item['body'];
                                                if (substr($body, 0, 4) == "[url") {
                                                        $body = "URL/Image ...";
                                                } else {
-                                                       require_once("include/html2plain.php");
-
                                                        $body = BBCode::convert($body, false, 2, true);
-                                                       $body = html2plain($body, 0);
+                                                       $body = HTML::toPlaintext($body, 0);
                                                        $body = ((strlen($body) > 137) ? substr($body, 0, 137) . "..." : $body);
                                                }
                                        } else {