]> git.mxchange.org Git - friendica.git/blobdiff - mod/display.php
Bump DB version
[friendica.git] / mod / display.php
index 52e9b59287f9843578a1ad805258dc17e6a93212..1f1fd112048f63e31077448ebde723341f39bdf9 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-function display_init(&$a) {
+function display_init(App $a) {
 
        if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
                return;
@@ -19,7 +19,7 @@ function display_init(&$a) {
                        $r = qu("SELECT `id`, `parent`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid`, `owner-link` FROM `item`
                                WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
                                        AND `guid` = '%s' AND `uid` = %d", dbesc($a->argv[1]), local_user());
-                       if (dbm::isresult($r)) {
+                       if (dbm::is_result($r)) {
                                $nick = $a->user["nickname"];
                                $itemuid = local_user();
                        }
@@ -35,7 +35,7 @@ function display_init(&$a) {
                                        AND `item`.`deny_cid`  = '' AND `item`.`deny_gid`  = ''
                                        AND NOT `item`.`private` AND NOT `user`.`hidewall`
                                        AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
-                       if (dbm::isresult($r)) {
+                       if (dbm::is_result($r)) {
                                $nick = $r[0]["nickname"];
                                $itemuid = $r[0]["uid"];
                        }
@@ -51,7 +51,7 @@ function display_init(&$a) {
                                        AND NOT `item`.`private` AND `item`.`uid` = 0
                                        AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
                }
-               if (dbm::isresult($r)) {
+               if (dbm::is_result($r)) {
                        if ($r[0]["id"] != $r[0]["parent"]) {
                                $r = qu("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid`, `owner-link` FROM `item`
                                        WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
@@ -81,8 +81,8 @@ function display_init(&$a) {
 
                        $profiledata = display_fetchauthor($a, $r[0]);
 
-                       if (strstr(normalise_link($profiledata["url"]), normalise_link($a->get_baseurl()))) {
-                               $nickname = str_replace(normalise_link($a->get_baseurl())."/profile/", "", normalise_link($profiledata["url"]));
+                       if (strstr(normalise_link($profiledata["url"]), normalise_link(App::get_baseurl()))) {
+                               $nickname = str_replace(normalise_link(App::get_baseurl())."/profile/", "", normalise_link($profiledata["url"]));
 
                                if (($nickname != $a->user["nickname"])) {
                                        $r = qu("SELECT `profile`.`uid` AS `profile_uid`, `profile`.* , `contact`.`avatar-date` AS picdate, `user`.* FROM `profile`
@@ -90,7 +90,7 @@ function display_init(&$a) {
                                                WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` AND `contact`.`self` LIMIT 1",
                                                dbesc($nickname)
                                        );
-                                       if (dbm::isresult($r)) {
+                                       if (dbm::is_result($r)) {
                                                $profiledata = $r[0];
                                        }
                                        $profiledata["network"] = NETWORK_DFRN;
@@ -128,7 +128,7 @@ function display_fetchauthor($a, $item) {
 
        // Skip if it isn't a pure repeated messages
        // Does it start with a share?
-       if (!$skip AND strpos($body, "[share") > 0) }
+       if (!$skip AND strpos($body, "[share") > 0) {
                $skip = true;
        }
        // Does it end with a share?
@@ -184,7 +184,7 @@ function display_fetchauthor($a, $item) {
 
        if (local_user()) {
                if (in_array($profiledata["network"], array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) {
-                       $profiledata["remoteconnect"] = $a->get_baseurl()."/follow?url=".urlencode($profiledata["url"]);
+                       $profiledata["remoteconnect"] = App::get_baseurl()."/follow?url=".urlencode($profiledata["url"]);
                }
        } elseif ($profiledata["network"] == NETWORK_DFRN) {
                $connect = str_replace("/profile/", "/dfrn_request/", $profiledata["url"]);
@@ -194,7 +194,7 @@ function display_fetchauthor($a, $item) {
        return($profiledata);
 }
 
-function display_content(&$a, $update = 0) {
+function display_content(App $a, $update = 0) {
 
        if ((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
                notice(t('Public access denied.') . EOL);
@@ -230,7 +230,7 @@ function display_content(&$a, $update = 0) {
                                $r = qu("SELECT `id` FROM `item`
                                        WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
                                                AND `guid` = '%s' AND `uid` = %d", dbesc($a->argv[1]), local_user());
-                               if (dbm::isresult($r)) {
+                               if (dbm::is_result($r)) {
                                        $item_id = $r[0]["id"];
                                        $nick = $a->user["nickname"];
                                }
@@ -244,7 +244,7 @@ function display_content(&$a, $update = 0) {
                                                AND NOT `item`.`private` AND NOT `user`.`hidewall`
                                                AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
                                        //      AND NOT `item`.`private` AND `item`.`wall`
-                               if (dbm::isresult($r)) {
+                               if (dbm::is_result($r)) {
                                        $item_id = $r[0]["id"];
                                        $nick = $r[0]["nickname"];
                                }
@@ -257,7 +257,7 @@ function display_content(&$a, $update = 0) {
                                                AND NOT `item`.`private` AND `item`.`uid` = 0
                                                AND `item`.`guid` = '%s'", dbesc($a->argv[1]));
                                        //      AND NOT `item`.`private` AND `item`.`wall`
-                               if (dbm::isresult($r)) {
+                               if (dbm::is_result($r)) {
                                        $item_id = $r[0]["id"];
                                }
                        }
@@ -303,7 +303,7 @@ function display_content(&$a, $update = 0) {
                        intval($contact_id),
                        intval($a->profile['uid'])
                );
-               if (dbm::isresult($r)) {
+               if (dbm::is_result($r)) {
                        $contact = $r[0];
                        $remote_contact = true;
                }
@@ -319,7 +319,7 @@ function display_content(&$a, $update = 0) {
        $r = qu("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1",
                intval($a->profile['uid'])
        );
-       if (dbm::isresult($r)) {
+       if (dbm::is_result($r)) {
                $a->page_contact = $r[0];
        }
        $is_owner = ((local_user()) && (local_user() == $a->profile['profile_uid']) ? true : false);
@@ -420,11 +420,17 @@ function display_content(&$a, $update = 0) {
                $title = trim(html2plain(bbcode($r[0]["title"], false, false), 0, true));
                $author_name = $r[0]["author-name"];
 
-               $image = $a->remove_baseurl($r[0]["thumb"]);
+               $image = $a->remove_baseurl($r[0]["author-thumb"]);
 
                if ($title == "") {
                        $title = $author_name;
                }
+
+               // Limit the description to 160 characters
+               if (strlen($description) > 160) {
+                       $description = substr($description, 0, 157) . '...';
+               }
+
                $description = htmlspecialchars($description, ENT_COMPAT, 'UTF-8', true); // allow double encoding here
                $title = htmlspecialchars($title, ENT_COMPAT, 'UTF-8', true); // allow double encoding here
                $author_name = htmlspecialchars($author_name, ENT_COMPAT, 'UTF-8', true); // allow double encoding here