]> git.mxchange.org Git - friendica.git/blobdiff - src/Object/Post.php
API: Support for reshared items
[friendica.git] / src / Object / Post.php
index 6e5088f1677bc12019cc8415f15412ac80bd93a5..83dc0c0944184972c462451c9db372bec943824a 100644 (file)
@@ -151,9 +151,10 @@ class Post
                }
                $sparkle = '';
                $buttons = [
-                       'like'    => null,
-                       'dislike' => null,
-                       'share'   => null,
+                       'like'     => null,
+                       'dislike'  => null,
+                       'share'    => null,
+                       'announce' => null,
                ];
                $dropping = false;
                $pinned = '';
@@ -175,6 +176,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;
 
@@ -221,15 +228,14 @@ class Post
                        $delete = $origin ? DI::l10n()->t('Delete globally') : DI::l10n()->t('Remove locally');
                }
 
-               $drop = [
-                       'dropping' => $dropping,
-                       'pagedrop' => $item['pagedrop'],
-                       'select'   => DI::l10n()->t('Select'),
-                       'delete'   => $delete,
-               ];
-
-               if (!local_user()) {
-                       $drop = false;
+               $drop = false;
+               if (local_user()) {
+                       $drop = [
+                               'dropping' => $dropping,
+                               'pagedrop' => $item['pagedrop'],
+                               'select'   => DI::l10n()->t('Select'),
+                               'delete'   => $delete,
+                       ];
                }
 
                $filer = (($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) ? DI::l10n()->t("save to folder") : false);
@@ -345,11 +351,14 @@ 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 and share this'), DI::l10n()->t('Quote Share')];
+                       }
+                       if ($announceable) {
+                               $buttons['announce'] = [DI::l10n()->t('Share this'), DI::l10n()->t('Share')];
                        }
                }
 
-               $comment = $this->getCommentBox($indent);
+               $comment_html = $this->getCommentBox($indent);
 
                if (strcmp(DateTimeFormat::utc($item['created']), DateTimeFormat::utc('now - 12 hours')) > 0) {
                        $shiny = 'shiny';
@@ -361,17 +370,12 @@ class Post
 
                list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item);
 
-               $name_e       = $profile_name;
-               $text       = strip_tags($body_html);
-
                if (!empty($item['content-warning']) && DI::pConfig()->get(local_user(), 'system', 'disable_cw', false)) {
-                       $title_e = ucfirst($item['content-warning']);
+                       $title = ucfirst($item['content-warning']);
                } else {
-                       $title_e = $item['title'];
+                       $title = $item['title'];
                }
 
-               $owner_name_e = $this->getOwnerName();
-
                if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) {
                        $buttons['dislike'] = false;
                }
@@ -412,11 +416,16 @@ class Post
                } elseif (DI::config()->get('debug', 'show_direction')) {
                        $conversation = DBA::selectFirst('conversation', ['direction'], ['item-uri' => $item['uri']]);
                        if (!empty($conversation['direction']) && in_array($conversation['direction'], [1, 2])) {
-                               $title = [1 => DI::l10n()->t('Pushed'), 2 => DI::l10n()->t('Pulled')];
-                               $direction = ['direction' => $conversation['direction'], 'title' => $title[$conversation['direction']]];
+                               $direction_title = [1 => DI::l10n()->t('Pushed'), 2 => DI::l10n()->t('Pulled')];
+                               $direction = ['direction' => $conversation['direction'], 'title' => $direction_title[$conversation['direction']]];
                        }
                }
 
+               $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)),
@@ -432,7 +441,7 @@ class Post
                        'categories'      => $categories,
                        'folders'         => $folders,
                        'body_html'       => $body_html,
-                       'text'            => $text,
+                       'text'            => strip_tags($body_html),
                        'id'              => $this->getId(),
                        'guid'            => urlencode($item['guid']),
                        'isevent'         => $isevent,
@@ -444,12 +453,12 @@ class Post
                        'wall'            => DI::l10n()->t('Wall-to-Wall'),
                        'vwall'           => DI::l10n()->t('via Wall-To-Wall:'),
                        'profile_url'     => $profile_link,
-                       'name'            => $name_e,
+                       'name'            => $profile_name,
                        'item_photo_menu_html' => item_photo_menu($item),
                        'thumb'           => DI::baseUrl()->remove($item['author-avatar']),
                        'osparkle'        => $osparkle,
                        'sparkle'         => $sparkle,
-                       'title'           => $title_e,
+                       'title'           => $title,
                        'localtime'       => DateTimeFormat::local($item['created'], 'r'),
                        'ago'             => $item['app'] ? DI::l10n()->t('%s from %s', $ago, $item['app']) : $ago,
                        'app'             => $item['app'],
@@ -461,7 +470,7 @@ class Post
                        'owner_self'      => $item['author-link'] == Session::get('my_url'),
                        'owner_url'       => $this->getOwnerUrl(),
                        'owner_photo'     => DI::baseUrl()->remove($item['owner-avatar']),
-                       'owner_name'      => $owner_name_e,
+                       'owner_name'      => $this->getOwnerName(),
                        'plink'           => Item::getPlink($item),
                        'edpost'          => $edpost,
                        'ispinned'        => $ispinned,
@@ -472,14 +481,15 @@ class Post
                        'ignore'          => $ignore,
                        'tagger'          => $tagger,
                        'filer'           => $filer,
+                       'language'        => $languages,
                        'drop'            => $drop,
                        'vote'            => $buttons,
-                       'like'            => $responses['like']['output'],
-                       'dislike'         => $responses['dislike']['output'],
+                       'like_html'       => $responses['like']['output'],
+                       'dislike_html'    => $responses['dislike']['output'],
                        'responses'       => $responses,
                        'switchcomment'   => DI::l10n()->t('Comment'),
-                       'reply_label'     => DI::l10n()->t('Reply to %s', $name_e),
-                       'comment'         => $comment,
+                       'reply_label'     => DI::l10n()->t('Reply to %s', $profile_name),
+                       'comment_html'    => $comment_html,
                        'remote_comment'  => $remote_comment,
                        'menu'            => DI::l10n()->t('More'),
                        'previewing'      => $conv->isPreview() ? ' preview ' : '',
@@ -983,7 +993,7 @@ class Post
 
                if ($this->isToplevel()) {
                        if ($conv->getMode() !== 'profile') {
-                               if ($this->getDataValue('wall') && !$this->getDataValue('self')) {
+                               if ($this->getDataValue('wall') && !$this->getDataValue('self') && !empty($a->page_contact)) {
                                        // On the network page, I am the owner. On the display page it will be the profile owner.
                                        // This will have been stored in $a->page_contact by our calling page.
                                        // Put this person as the wall owner of the wall-to-wall notice.