]> git.mxchange.org Git - friendica.git/blobdiff - include/conversation.php
Merge pull request #8385 from annando/issue-8383
[friendica.git] / include / conversation.php
index 0194e4ea56368486ca46736fa782d07391778730..8c09fa98b34379aebee0facb95623db1bd4e36cd 100644 (file)
@@ -1,6 +1,22 @@
 <?php
 /**
- * @file include/conversation.php
+ * @copyright Copyright (C) 2020, Friendica
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
  */
 
 use Friendica\App;
@@ -444,7 +460,6 @@ function conv_get_blocklist()
  * that are based on unique features of the calling module.
  * @param App    $a
  * @param array  $items
- * @param Pager  $pager
  * @param        $mode
  * @param        $update
  * @param bool   $preview
@@ -454,7 +469,7 @@ function conv_get_blocklist()
  * @throws ImagickException
  * @throws \Friendica\Network\HTTPException\InternalServerErrorException
  */
-function conversation(App $a, array $items, Pager $pager, $mode, $update, $preview = false, $order = 'commented', $uid = 0)
+function conversation(App $a, array $items, $mode, $update, $preview = false, $order = 'commented', $uid = 0)
 {
        $ssl_state = (local_user() ? true : false);
 
@@ -490,7 +505,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
                                . (!empty($_GET['cmax'])   ? '&cmax='   . rawurlencode($_GET['cmax'])   : '')
                                . (!empty($_GET['file'])   ? '&file='   . rawurlencode($_GET['file'])   : '')
 
-                               . "'; var profile_page = " . $pager->getPage() . "; </script>\r\n";
+                               . "'; </script>\r\n";
                }
        } elseif ($mode === 'profile') {
                $items = conversation_add_children($items, false, $order, $uid);
@@ -509,7 +524,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
 
                                $live_update_div = '<div id="live-profile"></div>' . "\r\n"
                                        . "<script> var profile_uid = " . $a->profile['uid']
-                                       . "; var netargs = '?f='; var profile_page = " . $pager->getPage() . "; </script>\r\n";
+                                       . "; var netargs = '?f='; </script>\r\n";
                        }
                }
        } elseif ($mode === 'notes') {
@@ -519,7 +534,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
                if (!$update) {
                        $live_update_div = '<div id="live-notes"></div>' . "\r\n"
                                . "<script> var profile_uid = " . local_user()
-                               . "; var netargs = '/?f='; var profile_page = " . $pager->getPage() . "; </script>\r\n";
+                               . "; var netargs = '/?f='; </script>\r\n";
                }
        } elseif ($mode === 'display') {
                $items = conversation_add_children($items, false, $order, $uid);
@@ -528,7 +543,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
                if (!$update) {
                        $live_update_div = '<div id="live-display"></div>' . "\r\n"
                                . "<script> var profile_uid = " . Session::get('uid', 0) . ";"
-                               . " var profile_page = 1; </script>";
+                               . "</script>";
                }
        } elseif ($mode === 'community') {
                $items = conversation_add_children($items, true, $order, $uid);
@@ -537,7 +552,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
                if (!$update) {
                        $live_update_div = '<div id="live-community"></div>' . "\r\n"
                                . "<script> var profile_uid = -1; var netargs = '" . substr(DI::args()->getCommand(), 10)
-                               ."/?f='; var profile_page = " . $pager->getPage() . "; </script>\r\n";
+                               ."/?f='; </script>\r\n";
                }
        } elseif ($mode === 'contacts') {
                $items = conversation_add_children($items, false, $order, $uid);
@@ -546,7 +561,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
                if (!$update) {
                        $live_update_div = '<div id="live-contacts"></div>' . "\r\n"
                                . "<script> var profile_uid = -1; var netargs = '" . substr(DI::args()->getCommand(), 9)
-                               ."/?f='; var profile_page = " . $pager->getPage() . "; </script>\r\n";
+                               ."/?f='; </script>\r\n";
                }
        } elseif ($mode === 'search') {
                $live_update_div = '<div id="live-search"></div>' . "\r\n";
@@ -564,14 +579,18 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
        $items = $cb['items'];
 
        $conv_responses = [
-               'like' => ['title' => DI::l10n()->t('Likes','title')],
-               'dislike' => ['title' => DI::l10n()->t('Dislikes','title')],
-               'attendyes' => ['title' => DI::l10n()->t('Attending','title')],
-               'attendno' => ['title' => DI::l10n()->t('Not attending','title')],
-               'attendmaybe' => ['title' => DI::l10n()->t('Might attend','title')],
-               'announce' => ['title' => DI::l10n()->t('Reshares','title')]
+               'like'        => [],
+               'dislike'     => [],
+               'attendyes'   => [],
+               'attendno'    => [],
+               'attendmaybe' => [],
+               'announce'    => [],    
        ];
 
+       if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) {
+               unset($conv_responses['dislike']);
+       }
+
        // array with html for each thread (parent+comments)
        $threads = [];
        $threadsid = -1;
@@ -657,7 +676,15 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
                                $isstarred = "unstarred";
 
                                $lock = false;
-                               $likebuttons = false;
+                               $likebuttons = [
+                                       'like'    => null,
+                                       'dislike' => null,
+                                       'share'   => null,
+                               ];
+
+                               if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) {
+                                       unset($likebuttons['dislike']);
+                               }
 
                                $body = Item::prepareBody($item, true, $preview);
 
@@ -1214,6 +1241,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
                '$return_path'  => $query_str,
                '$action'       => 'item',
                '$share'        => ($x['button'] ?? '') ?: DI::l10n()->t('Share'),
+               '$loading'      => DI::l10n()->t('Loading...'),
                '$upload'       => DI::l10n()->t('Upload photo'),
                '$shortupload'  => DI::l10n()->t('upload photo'),
                '$attach'       => DI::l10n()->t('Attach file'),
@@ -1544,56 +1572,3 @@ function render_location_dummy(array $item) {
                return $item['coord'];
        }
 }
-
-function get_responses(array $conv_responses, array $response_verbs, array $item, Post $ob = null) {
-       $ret = [];
-       foreach ($response_verbs as $v) {
-               $ret[$v] = [];
-               $ret[$v]['count'] = $conv_responses[$v][$item['uri']] ?? 0;
-               $ret[$v]['list']  = $conv_responses[$v][$item['uri'] . '-l'] ?? [];
-               $ret[$v]['self']  = $conv_responses[$v][$item['uri'] . '-self'] ?? '0';
-               if (count($ret[$v]['list']) > MAX_LIKERS) {
-                       $ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS);
-                       array_push($ret[$v]['list_part'], '<a href="#" data-toggle="modal" data-target="#' . $v . 'Modal-'
-                               . (($ob) ? $ob->getId() : $item['id']) . '"><b>' . DI::l10n()->t('View all') . '</b></a>');
-               } else {
-                       $ret[$v]['list_part'] = '';
-               }
-               $ret[$v]['button'] = get_response_button_text($v, $ret[$v]['count']);
-               $ret[$v]['title'] = $conv_responses[$v]['title'];
-       }
-
-       $count = 0;
-       foreach ($ret as $key) {
-               if ($key['count'] == true) {
-                       $count++;
-               }
-       }
-       $ret['count'] = $count;
-
-       return $ret;
-}
-
-function get_response_button_text($v, $count)
-{
-       $return = '';
-       switch ($v) {
-               case 'like':
-                       $return = DI::l10n()->tt('Like', 'Likes', $count);
-                       break;
-               case 'dislike':
-                       $return = DI::l10n()->tt('Dislike', 'Dislikes', $count);
-                       break;
-               case 'attendyes':
-                       $return = DI::l10n()->tt('Attending', 'Attending', $count);
-                       break;
-               case 'attendno':
-                       $return = DI::l10n()->tt('Not Attending', 'Not Attending', $count);
-                       break;
-               case 'attendmaybe':
-                       $return = DI::l10n()->tt('Undecided', 'Undecided', $count);
-                       break;
-       }
-
-       return $return;
-}