]> git.mxchange.org Git - friendica.git/blobdiff - src/Object/Post.php
Unneeded logging removed
[friendica.git] / src / Object / Post.php
index 91500cb99f8b1f00cc0e86d81a3daece1c5f1d31..d52a05dddcf990aa76b029aa4c9584bb1c6959a2 100644 (file)
@@ -320,7 +320,7 @@ class Post
                $location_html = $locate['html'] ?: Strings::escapeHtml($locate['location'] ?: $locate['coord'] ?: '');
 
                // process action responses - e.g. like/dislike/attend/agree/whatever
-               $response_verbs = ['like', 'dislike', 'announce'];
+               $response_verbs = ['like', 'dislike', 'announce', 'comment'];
 
                $isevent = false;
                $attend = [];
@@ -335,14 +335,31 @@ class Post
                        }
                }
 
+               $emojis = $this->getEmojis($item);
+
+               $verbs = [
+                       'like'        => Activity::LIKE,
+                       'dislike'     => Activity::DISLIKE,
+                       'announce'    => Activity::ANNOUNCE,
+                       'comment'     => Activity::POST,
+                       'attendyes'   => Activity::ATTEND,
+                       'attendno'    => Activity::ATTENDNO,
+                       'attendmaybe' => Activity::ATTENDMAYBE,
+               ];
+               $reactions = $emojis;
                $responses = [];
                foreach ($response_verbs as $value => $verb) {
                        $responses[$verb] = [
                                'self'   => $conv_responses[$verb][$item['uri-id']]['self'] ?? 0,
-                               'output' => !empty($conv_responses[$verb][$item['uri-id']]) ? DI::conversation()->formatActivity($conv_responses[$verb][$item['uri-id']]['links'], $verb, $item['uri-id']) : '',
+                               'output' => !empty($conv_responses[$verb][$item['uri-id']]) ? DI::conversation()->formatActivity($conv_responses[$verb][$item['uri-id']]['links'], $verb, $item['uri-id'], $verbs[$verb], $emojis) : '',
+                               'total'  => $emojis[$verbs[$verb]]['total'] ?? '',
+                               'title'  => $emojis[$verbs[$verb]]['title'] ?? '',
                        ];
+                       unset($reactions[$verbs[$verb]]);
                }
 
+               unset($emojis[Activity::POST]);
+
                /*
                 * We should avoid doing this all the time, but it depends on the conversation mode
                 * And the conv mode may change when we change the conv, or it changes its mode
@@ -441,7 +458,8 @@ class Post
                        $title = '';
                }
 
-               if (DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike')) {
+               $hide_dislike = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'system', 'hide_dislike');
+               if ($hide_dislike) {
                        $buttons['dislike'] = false;
                }
 
@@ -499,13 +517,13 @@ class Post
 
                $parent_guid     = $thread_parent[$item['thr-parent-id']]['guid'] ?? '';
                $parent_username = $thread_parent[$item['thr-parent-id']]['name'] ?? '';
-               $parent_unknown  = $parent_username ? '' : DI::l10n()->t('parent unknown');
+               $parent_unknown  = $parent_username ? '' : DI::l10n()->t('Unknown parent');
 
                $tmp_item = [
                        'parentguid'      => $parent_guid,
-                       'isreplyto'       => DI::l10n()->t('is reply to %s', $parent_username),
+                       'inreplyto'       => DI::l10n()->t('in reply to %s', $parent_username),
                        'isunknown'       => $parent_unknown,
-                       'isunknown_label' => DI::l10n()->t('parent is probably private or not federated'),
+                       'isunknown_label' => DI::l10n()->t('Parent is probably private or not federated.'),
                        'template'        => $this->getTemplate(),
                        'type'            => implode('', array_slice(explode('/', $item['verb']), -1)),
                        'comment_firstcollapsed' => false,
@@ -572,12 +590,16 @@ class Post
                        'ignore_author'   => $ignore,
                        'collapse'        => $collapse,
                        'report'          => $report,
-                       'ignore_server'     => $ignoreServer,
+                       'ignore_server'   => $ignoreServer,
                        'vote'            => $buttons,
                        'like_html'       => $responses['like']['output'],
                        'dislike_html'    => $responses['dislike']['output'],
-                       'emojis'          => $this->getEmojis($item),
+                       'hide_dislike'    => $hide_dislike,
+                       'emojis'          => $emojis,
+                       'quoteshares'     => $this->getQuoteShares($item['quoteshares']),
+                       'reactions'       => $reactions,
                        'responses'       => $responses,
+                       'legacy_activities' => DI::config()->get('system', 'legacy_activities'),
                        'switchcomment'   => DI::l10n()->t('Comment'),
                        'reply_label'     => DI::l10n()->t('Reply to %s', $profile_name),
                        'comment_html'    => $comment_html,
@@ -662,6 +684,7 @@ class Post
 
                $emojis = [];
                foreach ($item['emojis'] as $index => $element) {
+                       $key    = $element['verb'];
                        $actors = implode(', ', $element['title']);
                        switch ($element['verb']) {
                                case Activity::ANNOUNCE:
@@ -699,18 +722,38 @@ class Post
                                        $icon  = ['fa' => 'fa-times', 'icon' => 'icon-remove'];
                                        break;
 
+                               case Activity::POST:
+                                       $title = DI::l10n()->t('Commented by: %s', $actors);
+                                       $icon  = ['fa' => 'fa-commenting', 'icon' => 'icon-commenting'];
+                                       break;
+       
                                default:
                                        $title = DI::l10n()->t('Reacted with %s by: %s', $element['emoji'], $actors);
                                        $icon  = [];
+                                       $key   = $element['emoji'];
                                        break;
                        }
-                       $emojis[$index] = ['emoji' => $element['emoji'], 'total' => $element['total'], 'title' => $title, 'icon' => $icon];
+                       $emojis[$key] = ['emoji' => $element['emoji'], 'total' => $element['total'], 'title' => $title, 'icon' => $icon];
                }
-               ksort($emojis);
 
                return $emojis;
        }
 
+       /**
+        * Fetch quote shares
+        *
+        * @param array $quoteshares
+        * @return array
+        */
+       private function getQuoteShares($quoteshares)
+       {
+               if (empty($quoteshares)) {
+                       return [];
+               }
+
+               return ['total' => $quoteshares['total'], 'title' => DI::l10n()->t('Quote shared by: %s', implode(', ', $quoteshares['title']))];
+       }
+
        /**
         * @return integer
         */