mirror of
https://github.com/friendica/friendica
synced 2025-04-22 00:30:10 +00:00
Merge pull request #8293 from MrPetovan/task/5562-community-pagination
Improve community pagination
This commit is contained in:
commit
da124af6ed
36 changed files with 710 additions and 499 deletions
|
@ -68,7 +68,7 @@ class Contact extends BaseAdmin
|
|||
|
||||
$total = DBA::count('contact', $condition);
|
||||
|
||||
$pager = new Pager(DI::args()->getQueryString(), 30);
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 30);
|
||||
|
||||
$contacts = Model\Contact::selectToArray([], $condition, ['limit' => [$pager->getStart(), $pager->getItemsPerPage()]]);
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ class Users extends BaseAdmin
|
|||
/* get pending */
|
||||
$pending = Register::getPending();
|
||||
|
||||
$pager = new Pager(DI::args()->getQueryString(), 100);
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 100);
|
||||
|
||||
// @TODO Move below block to Model\User::getUsers($start, $count, $order = 'contact.name', $order_direction = '+')
|
||||
$valid_orders = [
|
||||
|
|
|
@ -67,7 +67,7 @@ class AllFriends extends BaseModule
|
|||
|
||||
$total = Model\GContact::countAllFriends(local_user(), $cid);
|
||||
|
||||
$pager = new Pager(DI::args()->getQueryString());
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString());
|
||||
|
||||
$friends = Model\GContact::allFriends(local_user(), $cid, $pager->getStart(), $pager->getItemsPerPage());
|
||||
if (empty($friends)) {
|
||||
|
|
|
@ -102,7 +102,7 @@ abstract class BaseNotifications extends BaseModule
|
|||
}
|
||||
|
||||
// Set the pager
|
||||
$pager = new Pager(DI::args()->getQueryString(), self::ITEMS_PER_PAGE);
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), self::ITEMS_PER_PAGE);
|
||||
|
||||
// Add additional informations (needed for json output)
|
||||
$notifications = [
|
||||
|
@ -132,7 +132,7 @@ abstract class BaseNotifications extends BaseModule
|
|||
$tabs = self::getTabs();
|
||||
|
||||
// Set the pager
|
||||
$pager = new Pager(DI::args()->getQueryString(), self::ITEMS_PER_PAGE);
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), self::ITEMS_PER_PAGE);
|
||||
|
||||
$notif_tpl = Renderer::getMarkupTemplate('notifications/notifications.tpl');
|
||||
return Renderer::replaceMacros($notif_tpl, [
|
||||
|
|
|
@ -81,8 +81,15 @@ class BaseSearch extends BaseModule
|
|||
$header = DI::l10n()->t('Forum Search - %s', $search);
|
||||
}
|
||||
|
||||
$args = DI::args();
|
||||
$pager = new Pager($args->getQueryString());
|
||||
if (DI::mode()->isMobile()) {
|
||||
$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
|
||||
DI::config()->get('system', 'itemspage_network_mobile'));
|
||||
} else {
|
||||
$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
|
||||
DI::config()->get('system', 'itemspage_network'));
|
||||
}
|
||||
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemsPerPage);
|
||||
|
||||
if ($localSearch && empty($results)) {
|
||||
$pager->setItemsPerPage(80);
|
||||
|
|
|
@ -731,7 +731,7 @@ class Contact extends BaseModule
|
|||
}
|
||||
DBA::close($stmt);
|
||||
|
||||
$pager = new Pager(DI::args()->getQueryString());
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString());
|
||||
|
||||
$sql_values[] = $pager->getStart();
|
||||
$sql_values[] = $pager->getItemsPerPage();
|
||||
|
|
337
src/Module/Conversation/Community.php
Normal file
337
src/Module/Conversation/Community.php
Normal file
|
@ -0,0 +1,337 @@
|
|||
<?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/>.
|
||||
*
|
||||
* See update_profile.php for documentation
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Conversation;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\BoundariesPager;
|
||||
use Friendica\Content\Feature;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Widget\TrendingTags;
|
||||
use Friendica\Core\ACL;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Network\HTTPException;
|
||||
|
||||
class Community extends BaseModule
|
||||
{
|
||||
protected static $page_style;
|
||||
protected static $content;
|
||||
protected static $accounttype;
|
||||
protected static $itemsPerPage;
|
||||
protected static $since_id;
|
||||
protected static $max_id;
|
||||
|
||||
public static function content(array $parameters = [])
|
||||
{
|
||||
self::parseRequest($parameters);
|
||||
|
||||
$tabs = [];
|
||||
|
||||
if ((Session::isAuthenticated() || in_array(self::$page_style, [CP_USERS_AND_GLOBAL, CP_USERS_ON_SERVER])) && empty(DI::config()->get('system', 'singleuser'))) {
|
||||
$tabs[] = [
|
||||
'label' => DI::l10n()->t('Local Community'),
|
||||
'url' => 'community/local',
|
||||
'sel' => self::$content == 'local' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Posts from local users on this server'),
|
||||
'id' => 'community-local-tab',
|
||||
'accesskey' => 'l'
|
||||
];
|
||||
}
|
||||
|
||||
if (Session::isAuthenticated() || in_array(self::$page_style, [CP_USERS_AND_GLOBAL, CP_GLOBAL_COMMUNITY])) {
|
||||
$tabs[] = [
|
||||
'label' => DI::l10n()->t('Global Community'),
|
||||
'url' => 'community/global',
|
||||
'sel' => self::$content == 'global' ? 'active' : '',
|
||||
'title' => DI::l10n()->t('Posts from users of the whole federated network'),
|
||||
'id' => 'community-global-tab',
|
||||
'accesskey' => 'g'
|
||||
];
|
||||
}
|
||||
|
||||
$tab_tpl = Renderer::getMarkupTemplate('common_tabs.tpl');
|
||||
$o = Renderer::replaceMacros($tab_tpl, ['$tabs' => $tabs]);
|
||||
|
||||
Nav::setSelected('community');
|
||||
|
||||
$items = self::getItems();
|
||||
|
||||
if (!DBA::isResult($items)) {
|
||||
info(DI::l10n()->t('No results.'));
|
||||
return $o;
|
||||
}
|
||||
|
||||
// We need the editor here to be able to reshare an item.
|
||||
if (Session::isAuthenticated()) {
|
||||
$x = [
|
||||
'is_owner' => true,
|
||||
'allow_location' => DI::app()->user['allow_location'],
|
||||
'default_location' => DI::app()->user['default-location'],
|
||||
'nickname' => DI::app()->user['nickname'],
|
||||
'lockstate' => (is_array(DI::app()->user) && (strlen(DI::app()->user['allow_cid']) || strlen(DI::app()->user['allow_gid']) || strlen(DI::app()->user['deny_cid']) || strlen(DI::app()->user['deny_gid'])) ? 'lock' : 'unlock'),
|
||||
'acl' => ACL::getFullSelectorHTML(DI::page(), DI::app()->user, true),
|
||||
'bang' => '',
|
||||
'visitor' => 'block',
|
||||
'profile_uid' => local_user(),
|
||||
];
|
||||
$o .= status_editor(DI::app(), $x, 0, true);
|
||||
}
|
||||
|
||||
$o .= conversation(DI::app(), $items, 'community', false, false, 'commented', local_user());
|
||||
|
||||
$pager = new BoundariesPager(
|
||||
DI::l10n(),
|
||||
DI::args()->getQueryString(),
|
||||
$items[0]['commented'],
|
||||
$items[count($items) - 1]['commented'],
|
||||
self::$itemsPerPage
|
||||
);
|
||||
|
||||
$o .= $pager->renderMinimal(count($items));
|
||||
|
||||
if (Feature::isEnabled(local_user(), 'trending_tags')) {
|
||||
DI::page()['aside'] .= TrendingTags::getHTML(self::$content);
|
||||
}
|
||||
|
||||
$t = Renderer::getMarkupTemplate("community.tpl");
|
||||
return Renderer::replaceMacros($t, [
|
||||
'$content' => $o,
|
||||
'$header' => '',
|
||||
'$show_global_community_hint' => (self::$content == 'global') && DI::config()->get('system', 'show_global_community_hint'),
|
||||
'$global_community_hint' => DI::l10n()->t("This community stream shows all public posts received by this node. They may not reflect the opinions of this node’s users.")
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes module parameters from the request and local configuration
|
||||
*
|
||||
* @param array $parameters
|
||||
* @throws HTTPException\BadRequestException
|
||||
* @throws HTTPException\ForbiddenException
|
||||
*/
|
||||
protected static function parseRequest(array $parameters)
|
||||
{
|
||||
if (DI::config()->get('system', 'block_public') && !Session::isAuthenticated()) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Public access denied.'));
|
||||
}
|
||||
|
||||
self::$page_style = DI::config()->get('system', 'community_page_style');
|
||||
|
||||
if (self::$page_style == CP_NO_INTERNAL_COMMUNITY) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Access denied.'));
|
||||
}
|
||||
|
||||
switch ($parameters['accounttype'] ?? '') {
|
||||
case 'person':
|
||||
self::$accounttype = User::ACCOUNT_TYPE_PERSON;
|
||||
break;
|
||||
case 'organisation':
|
||||
self::$accounttype = User::ACCOUNT_TYPE_ORGANISATION;
|
||||
break;
|
||||
case 'news':
|
||||
self::$accounttype = User::ACCOUNT_TYPE_NEWS;
|
||||
break;
|
||||
case 'community':
|
||||
self::$accounttype = User::ACCOUNT_TYPE_COMMUNITY;
|
||||
break;
|
||||
default:
|
||||
self::$accounttype = null;
|
||||
break;
|
||||
}
|
||||
|
||||
self::$content = $parameters['content'] ?? '';
|
||||
if (!self::$content) {
|
||||
if (!empty(DI::config()->get('system', 'singleuser'))) {
|
||||
// On single user systems only the global page does make sense
|
||||
self::$content = 'global';
|
||||
} else {
|
||||
// When only the global community is allowed, we use this as default
|
||||
self::$content = self::$page_style == CP_GLOBAL_COMMUNITY ? 'global' : 'local';
|
||||
}
|
||||
}
|
||||
|
||||
if (!in_array(self::$content, ['local', 'global'])) {
|
||||
throw new HTTPException\BadRequestException(DI::l10n()->t('Community option not available.'));
|
||||
}
|
||||
|
||||
// Check if we are allowed to display the content to visitors
|
||||
if (!Session::isAuthenticated()) {
|
||||
$available = self::$page_style == CP_USERS_AND_GLOBAL;
|
||||
|
||||
if (!$available) {
|
||||
$available = (self::$page_style == CP_USERS_ON_SERVER) && (self::$content == 'local');
|
||||
}
|
||||
|
||||
if (!$available) {
|
||||
$available = (self::$page_style == CP_GLOBAL_COMMUNITY) && (self::$content == 'global');
|
||||
}
|
||||
|
||||
if (!$available) {
|
||||
throw new HTTPException\ForbiddenException(DI::l10n()->t('Not available.'));
|
||||
}
|
||||
}
|
||||
|
||||
if (DI::mode()->isMobile()) {
|
||||
self::$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
|
||||
DI::config()->get('system', 'itemspage_network_mobile'));
|
||||
} else {
|
||||
self::$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
|
||||
DI::config()->get('system', 'itemspage_network'));
|
||||
}
|
||||
|
||||
// now that we have the user settings, see if the theme forces
|
||||
// a maximum item number which is lower then the user choice
|
||||
if ((DI::app()->force_max_items > 0) && (DI::app()->force_max_items < self::$itemsPerPage)) {
|
||||
self::$itemsPerPage = DI::app()->force_max_items;
|
||||
}
|
||||
|
||||
self::$since_id = $_GET['since_id'] ?? null;
|
||||
self::$max_id = $_GET['max_id'] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the displayed items.
|
||||
*
|
||||
* Community pages have a restriction on how many successive posts by the same author can show on any given page,
|
||||
* so we may have to retrieve more content beyond the first query
|
||||
*
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
protected static function getItems()
|
||||
{
|
||||
$items = self::selectItems(self::$since_id, self::$max_id, self::$itemsPerPage);
|
||||
|
||||
$maxpostperauthor = (int) DI::config()->get('system', 'max_author_posts_community_page');
|
||||
if ($maxpostperauthor != 0 && self::$content == 'local') {
|
||||
$count = 1;
|
||||
$previousauthor = '';
|
||||
$numposts = 0;
|
||||
$selected_items = [];
|
||||
|
||||
while (count($selected_items) < self::$itemsPerPage && ++$count < 50 && count($items) > 0) {
|
||||
foreach ($items as $item) {
|
||||
if ($previousauthor == $item["author-link"]) {
|
||||
++$numposts;
|
||||
} else {
|
||||
$numposts = 0;
|
||||
}
|
||||
$previousauthor = $item["author-link"];
|
||||
|
||||
if (($numposts < $maxpostperauthor) && (count($selected_items) < self::$itemsPerPage)) {
|
||||
$selected_items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
// If we're looking at a "previous page", the lookup continues forward in time because the list is
|
||||
// sorted in chronologically decreasing order
|
||||
if (isset(self::$since_id)) {
|
||||
self::$since_id = $items[0]['commented'];
|
||||
} else {
|
||||
// In any other case, the lookup continues backwards in time
|
||||
self::$max_id = $items[count($items) - 1]['commented'];
|
||||
}
|
||||
|
||||
$items = self::selectItems(self::$since_id, self::$max_id, self::$itemsPerPage);
|
||||
}
|
||||
} else {
|
||||
$selected_items = $items;
|
||||
}
|
||||
|
||||
return $selected_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Database query for the comunity page
|
||||
*
|
||||
* @param $since_id
|
||||
* @param $max_id
|
||||
* @param $itemspage
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
* @TODO Move to repository/factory
|
||||
*/
|
||||
private static function selectItems($since_id, $max_id, $itemspage)
|
||||
{
|
||||
$r = false;
|
||||
|
||||
if (self::$content == 'local') {
|
||||
$values = [];
|
||||
|
||||
$sql_accounttype = '';
|
||||
$sql_boundaries = '';
|
||||
if (!is_null(self::$accounttype)) {
|
||||
$sql_accounttype = " AND `user`.`account-type` = ?";
|
||||
$values[] = [self::$accounttype];
|
||||
}
|
||||
|
||||
if (isset($since_id)) {
|
||||
$sql_boundaries .= " AND `thread`.`commented` > ?";
|
||||
$values[] = $since_id;
|
||||
}
|
||||
|
||||
if (isset($max_id)) {
|
||||
$sql_boundaries .= " AND `thread`.`commented` < ?";
|
||||
$values[] = $max_id;
|
||||
}
|
||||
|
||||
$values[] = $itemspage;
|
||||
|
||||
/// @todo Use "unsearchable" here as well (instead of "hidewall")
|
||||
$r = DBA::p("SELECT `item`.`uri`, `author`.`url` AS `author-link`, `thread`.`commented` FROM `thread`
|
||||
STRAIGHT_JOIN `user` ON `user`.`uid` = `thread`.`uid` AND NOT `user`.`hidewall`
|
||||
STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
|
||||
STRAIGHT_JOIN `contact` AS `author` ON `author`.`id`=`item`.`author-id`
|
||||
WHERE `thread`.`visible` AND NOT `thread`.`deleted` AND NOT `thread`.`moderated`
|
||||
AND NOT `thread`.`private` AND `thread`.`wall` AND `thread`.`origin`
|
||||
$sql_accounttype
|
||||
$sql_boundaries
|
||||
ORDER BY `thread`.`commented` DESC
|
||||
LIMIT ?", $values);
|
||||
} elseif (self::$content == 'global') {
|
||||
if (!is_null(self::$accounttype)) {
|
||||
$condition = ["`uid` = ? AND NOT `author`.`unsearchable` AND NOT `owner`.`unsearchable` AND `owner`.`contact-type` = ?", 0, self::$accounttype];
|
||||
} else {
|
||||
$condition = ["`uid` = ? AND NOT `author`.`unsearchable` AND NOT `owner`.`unsearchable`", 0];
|
||||
}
|
||||
|
||||
if (isset($max_id)) {
|
||||
$condition[0] .= " AND `commented` < ?";
|
||||
$condition[] = $max_id;
|
||||
}
|
||||
|
||||
if (isset($since_id)) {
|
||||
$condition[0] .= " AND `commented` > ?";
|
||||
$condition[] = $since_id;
|
||||
}
|
||||
|
||||
$r = Item::selectThreadForUser(0, ['uri', 'commented'], $condition, ['order' => ['commented' => true], 'limit' => $itemspage]);
|
||||
}
|
||||
|
||||
return DBA::toArray($r);
|
||||
}
|
||||
}
|
|
@ -70,7 +70,7 @@ class Directory extends BaseModule
|
|||
$gDirPath = Profile::zrl($dirURL, true);
|
||||
}
|
||||
|
||||
$pager = new Pager(DI::args()->getQueryString(), 60);
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 60);
|
||||
|
||||
$profiles = Profile::searchProfiles($pager->getStart(), $pager->getItemsPerPage(), $search);
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ class Contacts extends BaseProfile
|
|||
|
||||
$total = DBA::count('contact', $condition);
|
||||
|
||||
$pager = new Pager(DI::args()->getQueryString());
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString());
|
||||
|
||||
$params = ['order' => ['name' => false], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
|
||||
|
||||
|
|
|
@ -166,12 +166,12 @@ class Status extends BaseProfile
|
|||
$sql_extra3 = "";
|
||||
}
|
||||
|
||||
// check if we serve a mobile device and get the user settings
|
||||
// accordingly
|
||||
if (DI::mode()->isMobile()) {
|
||||
$itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network', 10);
|
||||
$itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
|
||||
DI::config()->get('system', 'itemspage_network_mobile'));
|
||||
} else {
|
||||
$itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_network', 20);
|
||||
$itemspage_network = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
|
||||
DI::config()->get('system', 'itemspage_network'));
|
||||
}
|
||||
|
||||
// now that we have the user settings, see if the theme forces
|
||||
|
@ -180,7 +180,7 @@ class Status extends BaseProfile
|
|||
$itemspage_network = $a->force_max_items;
|
||||
}
|
||||
|
||||
$pager = new Pager($args->getQueryString(), $itemspage_network);
|
||||
$pager = new Pager(DI::l10n(), $args->getQueryString(), $itemspage_network);
|
||||
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ", $pager->getStart(), $pager->getItemsPerPage());
|
||||
|
||||
|
@ -231,7 +231,7 @@ class Status extends BaseProfile
|
|||
$items = array_merge($items, $pinned);
|
||||
}
|
||||
|
||||
$o .= conversation($a, $items, $pager, 'profile', false, false, 'pinned_received', $a->profile['uid']);
|
||||
$o .= conversation($a, $items, 'profile', false, false, 'pinned_received', $a->profile['uid']);
|
||||
|
||||
$o .= $pager->renderMinimal(count($items));
|
||||
|
||||
|
|
|
@ -137,7 +137,15 @@ class Index extends BaseSearch
|
|||
// OR your own posts if you are a logged in member
|
||||
// No items will be shown if the member has a blocked profile wall.
|
||||
|
||||
$pager = new Pager(DI::args()->getQueryString());
|
||||
if (DI::mode()->isMobile()) {
|
||||
$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_mobile_network',
|
||||
DI::config()->get('system', 'itemspage_network_mobile'));
|
||||
} else {
|
||||
$itemsPerPage = DI::pConfig()->get(local_user(), 'system', 'itemspage_network',
|
||||
DI::config()->get('system', 'itemspage_network'));
|
||||
}
|
||||
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString(), $itemsPerPage);
|
||||
|
||||
if ($tag) {
|
||||
Logger::info('Start tag search.', ['q' => $search]);
|
||||
|
@ -200,7 +208,7 @@ class Index extends BaseSearch
|
|||
|
||||
Logger::info('Start Conversation.', ['q' => $search]);
|
||||
|
||||
$o .= conversation(DI::app(), $r, $pager, 'search', false, false, 'commented', local_user());
|
||||
$o .= conversation(DI::app(), $r, 'search', false, false, 'commented', local_user());
|
||||
|
||||
$o .= $pager->renderMinimal(count($r));
|
||||
|
||||
|
|
44
src/Module/Update/Community.php
Normal file
44
src/Module/Update/Community.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?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/>.
|
||||
*
|
||||
* See update_profile.php for documentation
|
||||
*/
|
||||
|
||||
namespace Friendica\Module\Update;
|
||||
|
||||
use Friendica\Core\System;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\Conversation\Community as CommunityModule;
|
||||
|
||||
/**
|
||||
* Asynchronous update module for the community page
|
||||
*
|
||||
* @package Friendica\Module\Update
|
||||
*/
|
||||
class Community extends CommunityModule
|
||||
{
|
||||
public static function rawContent(array $parameters = [])
|
||||
{
|
||||
self::parseRequest($parameters);
|
||||
|
||||
$o = conversation(DI::app(), self::getItems(), 'community', true, false, 'commented', local_user());
|
||||
|
||||
System::htmlUpdateExit($o);
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ namespace Friendica\Module\Update;
|
|||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\Session;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -95,8 +96,6 @@ class Profile extends BaseModule
|
|||
return '';
|
||||
}
|
||||
|
||||
$pager = new Pager(DI::args()->getQueryString());
|
||||
|
||||
// Set a time stamp for this page. We will make use of it when we
|
||||
// search for new items (update routine)
|
||||
$last_updated_array[$last_updated_key] = time();
|
||||
|
@ -116,29 +115,8 @@ class Profile extends BaseModule
|
|||
|
||||
$items = DBA::toArray($items_stmt);
|
||||
|
||||
$o .= conversation($a, $items, $pager, 'profile', $profile_uid, false, 'received', $a->profile['uid']);
|
||||
$o .= conversation($a, $items, 'profile', $profile_uid, false, 'received', $a->profile['uid']);
|
||||
|
||||
header("Content-type: text/html");
|
||||
echo "<!DOCTYPE html><html><body>\r\n";
|
||||
// We can remove this hack once Internet Explorer recognises HTML5 natively
|
||||
echo "<section>";
|
||||
echo $o;
|
||||
if (DI::pConfig()->get(local_user(), "system", "bandwidth_saver")) {
|
||||
$replace = "<br />".DI::l10n()->t("[Embedded content - reload page to view]")."<br />";
|
||||
$pattern = "/<\s*audio[^>]*>(.*?)<\s*\/\s*audio>/i";
|
||||
$o = preg_replace($pattern, $replace, $o);
|
||||
$pattern = "/<\s*video[^>]*>(.*?)<\s*\/\s*video>/i";
|
||||
$o = preg_replace($pattern, $replace, $o);
|
||||
$pattern = "/<\s*embed[^>]*>(.*?)<\s*\/\s*embed>/i";
|
||||
$o = preg_replace($pattern, $replace, $o);
|
||||
$pattern = "/<\s*iframe[^>]*>(.*?)<\s*\/\s*iframe>/i";
|
||||
$o = preg_replace($pattern, $replace, $o);
|
||||
}
|
||||
|
||||
// reportedly some versions of MSIE don't handle tabs in XMLHttpRequest documents very well
|
||||
echo str_replace("\t", " ", $o);
|
||||
echo "</section>";
|
||||
echo "</body></html>\r\n";
|
||||
exit();
|
||||
System::htmlUpdateExit($o);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue