<?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;
* 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
* @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);
. (!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);
$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') {
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);
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);
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);
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";
$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;
$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);
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;
-}