]> git.mxchange.org Git - friendica.git/blobdiff - src/Content/Conversation.php
Merge remote-tracking branch 'upstream/develop' into reduce-update-contacts
[friendica.git] / src / Content / Conversation.php
index 7773cdd508ea258dc31f7806db3adb27c8c26da7..6c5313fdc5a1115ef332a6c453783d8d3c0adae6 100644 (file)
@@ -146,7 +146,7 @@ class Conversation
                                        'url'     => $activity['author-link']
                                ];
                                $url = Contact::magicLinkByContact($author);
-                               if (strpos($url, 'redir/') === 0) {
+                               if (strpos($url, 'contact/redir/') === 0) {
                                        $sparkle = ' class="sparkle" ';
                                }
 
@@ -234,32 +234,32 @@ class Conversation
                                $likers .= ' ' . $this->l10n->t('and %d other people', $total - $this->config->get('system', 'max_likers'));
                        }
 
-                       $spanatts = "class=\"fakelink\" onclick=\"openClose('{$verb}list-$id');\"";
+                       $spanatts = "class=\"btn btn-link fakelink\" onclick=\"openClose('{$verb}list-$id');\"";
 
                        $explikers = '';
                        switch ($verb) {
                                case 'like':
-                                       $phrase    = $this->l10n->t('<span  %1$s>%2$d people</span> like this', $spanatts, $total);
+                                       $phrase    = $this->l10n->t('<button type="button" %1$s>%2$d people</button> like this', $spanatts, $total);
                                        $explikers = $this->l10n->t('%s like this.', $likers);
                                        break;
                                case 'dislike':
-                                       $phrase    = $this->l10n->t('<span  %1$s>%2$d people</span> don\'t like this', $spanatts, $total);
+                                       $phrase    = $this->l10n->t('<button type="button" %1$s>%2$d people</button> don\'t like this', $spanatts, $total);
                                        $explikers = $this->l10n->t('%s don\'t like this.', $likers);
                                        break;
                                case 'attendyes':
-                                       $phrase    = $this->l10n->t('<span  %1$s>%2$d people</span> attend', $spanatts, $total);
+                                       $phrase    = $this->l10n->t('<button type="button" %1$s>%2$d people</button> attend', $spanatts, $total);
                                        $explikers = $this->l10n->t('%s attend.', $likers);
                                        break;
                                case 'attendno':
-                                       $phrase    = $this->l10n->t('<span  %1$s>%2$d people</span> don\'t attend', $spanatts, $total);
+                                       $phrase    = $this->l10n->t('<button type="button" %1$s>%2$d people</button> don\'t attend', $spanatts, $total);
                                        $explikers = $this->l10n->t('%s don\'t attend.', $likers);
                                        break;
                                case 'attendmaybe':
-                                       $phrase    = $this->l10n->t('<span  %1$s>%2$d people</span> attend maybe', $spanatts, $total);
+                                       $phrase    = $this->l10n->t('<button type="button" %1$s>%2$d people</button> attend maybe', $spanatts, $total);
                                        $explikers = $this->l10n->t('%s attend maybe.', $likers);
                                        break;
                                case 'announce':
-                                       $phrase    = $this->l10n->t('<span  %1$s>%2$d people</span> reshared this', $spanatts, $total);
+                                       $phrase    = $this->l10n->t('<button type="button" %1$s>%2$d people</button> reshared this', $spanatts, $total);
                                        $explikers = $this->l10n->t('%s reshared this.', $likers);
                                        break;
                        }
@@ -493,7 +493,7 @@ class Conversation
                        if (!$update) {
                                $live_update_div = '<div id="live-notes"></div>' . "\r\n"
                                        . "<script> var profile_uid = " . $this->session->getLocalUserId()
-                                       . "; var netargs = '/?f='; </script>\r\n";
+                                       . "; var netargs = '?f='; </script>\r\n";
                        }
                } elseif ($mode === 'display') {
                        $items = $this->addChildren($items, false, $order, $uid, $mode);
@@ -520,13 +520,13 @@ class Conversation
                        if (!$update) {
                                $live_update_div = '<div id="live-contact"></div>' . "\r\n"
                                        . "<script> var profile_uid = -1; var netargs = '" . substr($this->args->getCommand(), 8)
-                                       ."/?f='; </script>\r\n";
+                                       ."?f='; </script>\r\n";
                        }
                } elseif ($mode === 'search') {
                        $live_update_div = '<div id="live-search"></div>' . "\r\n";
                }
 
-               $page_dropping = $this->session->getLocalUserId() && $this->session->getLocalUserId() == $uid;
+               $page_dropping = $this->session->getLocalUserId() && $this->session->getLocalUserId() == $uid && $mode != 'search';
 
                if (!$update) {
                        $_SESSION['return_path'] = $this->args->getQueryString();
@@ -612,7 +612,7 @@ class Conversation
                                        $profile_link = Contact::magicLinkByContact($author);
 
                                        $sparkle = '';
-                                       if (strpos($profile_link, 'redir/') === 0) {
+                                       if (strpos($profile_link, 'contact/redir/') === 0) {
                                                $sparkle = ' sparkle';
                                        }
 
@@ -794,7 +794,7 @@ class Conversation
                        return [];
                }
 
-               $str_blocked = str_replace(["\n", "\r"], ",", $this->pConfig->get($this->session->getLocalUserId(), 'system', 'blocked'));
+               $str_blocked = str_replace(["\n", "\r"], ",", $this->pConfig->get($this->session->getLocalUserId(), 'system', 'blocked') ?? '');
                if (empty($str_blocked)) {
                        return [];
                }
@@ -970,7 +970,7 @@ class Conversation
                }
 
                $condition = DBA::mergeConditions($condition,
-                       ["`uid` IN (0, ?) AND (`vid` != ? OR `vid` IS NULL)", $uid, Verb::getID(Activity::FOLLOW)]);
+                       ["`uid` IN (0, ?) AND (NOT `vid` IN (?, ?, ?) OR `vid` IS NULL)", $uid, Verb::getID(Activity::FOLLOW), Verb::getID(Activity::VIEW), Verb::getID(Activity::READ)]);
 
                $thread_parents = Post::select(['uri-id', 'causer-id'], $condition, ['order' => ['uri-id' => false, 'uid']]);
 
@@ -985,7 +985,8 @@ class Conversation
 
                $thread_items = Post::selectForUser($uid, array_merge(ItemModel::DISPLAY_FIELDLIST, ['featured', 'contact-uid', 'gravity', 'post-type', 'post-reason']), $condition, $params);
 
-               $items = [];
+               $items         = [];
+               $quote_uri_ids = [];
 
                while ($row = Post::fetch($thread_items)) {
                        if (!empty($items[$row['uri-id']]) && ($row['uid'] == 0)) {
@@ -1005,11 +1006,37 @@ class Conversation
                                }
                        }
 
+                       if (in_array($row['gravity'], [ItemModel::GRAVITY_PARENT, ItemModel::GRAVITY_COMMENT])) {
+                               $quote_uri_ids[$row['uri-id']] = [
+                                       'uri-id'        => $row['uri-id'],
+                                       'uri'           => $row['uri'],
+                                       'parent-uri-id' => $row['parent-uri-id'],
+                                       'parent-uri'    => $row['parent-uri'],
+                               ];
+                       }
+
                        $items[$row['uri-id']] = $this->addRowInformation($row, $activities[$row['uri-id']] ?? [], $thr_parent[$row['thr-parent-id']] ?? []);
                }
 
                DBA::close($thread_items);
 
+               $quotes = Post::select(array_merge(ItemModel::DISPLAY_FIELDLIST, ['featured', 'contact-uid', 'gravity', 'post-type', 'post-reason']), ['quote-uri-id' => array_column($quote_uri_ids, 'uri-id'), 'body' => '', 'uid' => 0]);
+               while ($quote = Post::fetch($quotes)) {
+                       $row = $quote;
+
+                       $row['uid']           = $uid;
+                       $row['verb']          = $row['body'] = $row['raw-body'] = Activity::ANNOUNCE;
+                       $row['gravity']       = ItemModel::GRAVITY_ACTIVITY;
+                       $row['object-type']   = Activity\ObjectType::NOTE;
+                       $row['parent-uri']    = $quote_uri_ids[$quote['quote-uri-id']]['parent-uri'];
+                       $row['parent-uri-id'] = $quote_uri_ids[$quote['quote-uri-id']]['parent-uri-id'];
+                       $row['thr-parent']    = $quote_uri_ids[$quote['quote-uri-id']]['uri'];
+                       $row['thr-parent-id'] = $quote_uri_ids[$quote['quote-uri-id']]['uri-id'];
+
+                       $items[$row['uri-id']] = $this->addRowInformation($row, [], []);
+               }
+               DBA::close($quotes);
+
                $items = $this->convSort($items, $order);
 
                $this->profiler->stopRecording();