]> git.mxchange.org Git - friendica.git/blobdiff - include/conversation.php
Merge pull request #8293 from MrPetovan/task/5562-community-pagination
[friendica.git] / include / conversation.php
index d09c918d1501019972d2292dfbae851c2c1d790b..e713994bc6f6b1d8eab5042357bf8932a5c906ec 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;
@@ -8,9 +24,7 @@ use Friendica\Content\ContactSelector;
 use Friendica\Content\Feature;
 use Friendica\Content\Pager;
 use Friendica\Content\Text\BBCode;
-use Friendica\Core\Config;
 use Friendica\Core\Hook;
-use Friendica\Core\L10n;
 use Friendica\Core\Logger;
 use Friendica\Core\Protocol;
 use Friendica\Core\Renderer;
@@ -446,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
@@ -456,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);
 
@@ -492,11 +505,11 @@ 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);
-               $profile_owner = $a->profile['profile_uid'];
+               $profile_owner = $a->profile['uid'];
 
                if (!$update) {
                        $tab = 'posts';
@@ -510,8 +523,8 @@ 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['profile_uid']
-                                       . "; var netargs = '?f='; var profile_page = " . $pager->getPage() . "; </script>\r\n";
+                                       . "<script> var profile_uid = " . $a->profile['uid']
+                                       . "; var netargs = '?f='; </script>\r\n";
                        }
                }
        } elseif ($mode === 'notes') {
@@ -521,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);
@@ -530,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);
@@ -539,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);
@@ -548,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";
@@ -659,7 +672,11 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
                                $isstarred = "unstarred";
 
                                $lock = false;
-                               $likebuttons = false;
+                               $likebuttons = [
+                                       'like'    => null,
+                                       'dislike' => null,
+                                       'share'   => null,
+                               ];
 
                                $body = Item::prepareBody($item, true, $preview);
 
@@ -793,7 +810,7 @@ function conversation(App $a, array $items, Pager $pager, $mode, $update, $previ
 /**
  * Fetch all comments from a query. Additionally set the newest resharer as thread owner.
  *
- * @param array   $thread_items Database statement with thread posts
+ * @param mixed   $thread_items Database statement with thread posts
  * @param boolean $pinned       Is the item pinned?
  *
  * @return array items with parents and comments
@@ -851,7 +868,7 @@ function conversation_fetch_comments($thread_items, $pinned) {
  * @throws \Friendica\Network\HTTPException\InternalServerErrorException
  */
 function conversation_add_children(array $parents, $block_authors, $order, $uid) {
-       $max_comments = Config::get('system', 'max_comments', 100);
+       $max_comments = DI::config()->get('system', 'max_comments', 100);
 
        $params = ['order' => ['uid', 'commented' => true]];
 
@@ -921,9 +938,9 @@ function item_photo_menu($item) {
        }
 
        if ($sparkle) {
-               $status_link = $profile_link . '?tab=status';
+               $status_link = $profile_link . '/status';
                $photos_link = str_replace('/profile/', '/photos/', $profile_link);
-               $profile_link = $profile_link . '?=profile';
+               $profile_link = $profile_link . '/profile';
        }
 
        if (!empty($pcid)) {
@@ -1216,6 +1233,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'),
@@ -1581,19 +1599,19 @@ function get_response_button_text($v, $count)
        $return = '';
        switch ($v) {
                case 'like':
-                       $return = L10n::tt('Like', 'Likes', $count);
+                       $return = DI::l10n()->tt('Like', 'Likes', $count);
                        break;
                case 'dislike':
-                       $return = L10n::tt('Dislike', 'Dislikes', $count);
+                       $return = DI::l10n()->tt('Dislike', 'Dislikes', $count);
                        break;
                case 'attendyes':
-                       $return = L10n::tt('Attending', 'Attending', $count);
+                       $return = DI::l10n()->tt('Attending', 'Attending', $count);
                        break;
                case 'attendno':
-                       $return = L10n::tt('Not Attending', 'Not Attending', $count);
+                       $return = DI::l10n()->tt('Not Attending', 'Not Attending', $count);
                        break;
                case 'attendmaybe':
-                       $return = L10n::tt('Undecided', 'Undecided', $count);
+                       $return = DI::l10n()->tt('Undecided', 'Undecided', $count);
                        break;
        }