]> git.mxchange.org Git - friendica.git/blobdiff - src/Object/Post.php
New post class in the rest of the classes
[friendica.git] / src / Object / Post.php
index 51b952d610481dc326793d3e83fd5164e7bfd79c..4c838f771458462498318fd26728fcfb5376820e 100644 (file)
@@ -33,6 +33,7 @@ use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Model\Contact;
 use Friendica\Model\Item;
+use Friendica\Model\Post as ModelPost;
 use Friendica\Model\Tag;
 use Friendica\Model\User;
 use Friendica\Protocol\Activity;
@@ -151,9 +152,10 @@ class Post
                }
                $sparkle = '';
                $buttons = [
-                       'like'    => null,
-                       'dislike' => null,
-                       'share'   => null,
+                       'like'     => null,
+                       'dislike'  => null,
+                       'share'    => null,
+                       'announce' => null,
                ];
                $dropping = false;
                $pinned = '';
@@ -175,6 +177,12 @@ class Post
                        : false);
 
                $shareable = in_array($conv->getProfileOwner(), [0, local_user()]) && $item['private'] != Item::PRIVATE;
+               $announceable = $shareable && in_array($item['network'], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::TWITTER]);
+
+               // On Diaspora only toplevel posts can be reshared
+               if ($announceable && ($item['network'] == Protocol::DIASPORA) && ($item['gravity'] != GRAVITY_PARENT)) {
+                       $announceable = false;
+               }
 
                $edpost = false;
 
@@ -205,7 +213,7 @@ class Post
                if (!$origin) {
                        /// @todo This shouldn't be done as query here, but better during the data creation.
                        // it is now done here, since during the RC phase we shouldn't make to intense changes.
-                       $parent = Item::selectFirst(['origin'], ['id' => $item['parent']]);
+                       $parent = ModelPost::selectFirst(['origin'], ['id' => $item['parent']]);
                        if (DBA::isResult($parent)) {
                                $origin = $parent['origin'];
                        }
@@ -273,8 +281,8 @@ class Post
                $responses = [];
                foreach ($response_verbs as $value => $verb) {
                        $responses[$verb] = [
-                               'self'   => $conv_responses[$verb][$item['uri'] . '-self'] ?? 0,
-                               'output' => !empty($conv_responses[$verb][$item['uri']]) ? format_like($conv_responses[$verb][$item['uri']], $conv_responses[$verb][$item['uri'] . '-l'], $verb, $item['uri']) : '',
+                               'self'   => $conv_responses[$verb][$item['uri']]['self'] ?? 0,
+                               'output' => !empty($conv_responses[$verb][$item['uri']]) ? format_activity($conv_responses[$verb][$item['uri']]['links'], $verb, $item['uri']) : '',
                        ];
                }
 
@@ -344,7 +352,11 @@ class Post
                        $buttons['like']    = [DI::l10n()->t("I like this \x28toggle\x29")      , DI::l10n()->t("like")];
                        $buttons['dislike'] = [DI::l10n()->t("I don't like this \x28toggle\x29"), DI::l10n()->t("dislike")];
                        if ($shareable) {
-                               $buttons['share'] = [DI::l10n()->t('Share this'), DI::l10n()->t('share')];
+                               $buttons['share'] = [DI::l10n()->t('Quote share this'), DI::l10n()->t('Quote Share')];
+                       }
+                       if ($announceable) {
+                               $buttons['announce'] = [DI::l10n()->t('Reshare this'), DI::l10n()->t('Reshare')];
+                               $buttons['unannounce'] = [DI::l10n()->t('Cancel your Reshare'), DI::l10n()->t('Unshare')];
                        }
                }
 
@@ -411,6 +423,11 @@ class Post
                        }
                }
 
+               $languages = [];
+               if (!empty($item['language'])) {
+                       $languages = [DI::l10n()->t('Languages'), Item::getLanguageMessage($item)];
+               }
+
                $tmp_item = [
                        'template'        => $this->getTemplate(),
                        'type'            => implode("", array_slice(explode("/", $item['verb']), -1)),
@@ -466,6 +483,7 @@ class Post
                        'ignore'          => $ignore,
                        'tagger'          => $tagger,
                        'filer'           => $filer,
+                       'language'        => $languages,
                        'drop'            => $drop,
                        'vote'            => $buttons,
                        'like_html'       => $responses['like']['output'],
@@ -858,7 +876,7 @@ class Post
                        return '';
                }
 
-               $item = Item::selectFirst(['author-addr', 'uri-id'], ['id' => $this->getId()]);
+               $item = ModelPost::selectFirst(['author-addr', 'uri-id'], ['id' => $this->getId()]);
                if (!DBA::isResult($item) || empty($item['author-addr'])) {
                        // Should not happen
                        return '';