Move $pager and $page_offset out of App
- Move infinite scroll data output in a module hook - Use Pager instead of paginate() and alt_pager()
This commit is contained in:
parent
a976a4cb68
commit
14237a9599
29 changed files with 234 additions and 385 deletions
|
@ -8,6 +8,7 @@
|
|||
use Friendica\App;
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Content\Feature;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Text\Markdown;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
|
@ -482,10 +483,9 @@ function admin_page_contactblock(App $a)
|
|||
|
||||
$total = DBA::count('contact', $condition);
|
||||
|
||||
$a->setPagerTotal($total);
|
||||
$a->setPagerItemsPage(30);
|
||||
$pager = new Pager($a->query_string, $total, 30);
|
||||
|
||||
$statement = DBA::select('contact', [], $condition, ['limit' => [$a->pager['start'], $a->pager['itemspage']]]);
|
||||
$statement = DBA::select('contact', [], $condition, ['limit' => [$pager->getStart(), $pager->getItemsPerPage()]]);
|
||||
|
||||
$contacts = DBA::toArray($statement);
|
||||
|
||||
|
@ -513,7 +513,7 @@ function admin_page_contactblock(App $a)
|
|||
|
||||
'$contacts' => $contacts,
|
||||
'$total_contacts' => L10n::tt('%s total blocked contact', '%s total blocked contacts', $total),
|
||||
'$paginate' => paginate($a),
|
||||
'$paginate' => $pager->renderFull(),
|
||||
'$contacturl' => ['contact_url', L10n::t("Profile URL"), '', L10n::t("URL of the remote contact to block.")],
|
||||
]);
|
||||
return $o;
|
||||
|
@ -1812,12 +1812,7 @@ function admin_page_users(App $a)
|
|||
/* get pending */
|
||||
$pending = Register::getPending();
|
||||
|
||||
/* get users */
|
||||
$total = q("SELECT COUNT(*) AS `total` FROM `user` WHERE 1");
|
||||
if (count($total)) {
|
||||
$a->setPagerTotal($total[0]['total']);
|
||||
$a->setPagerItemsPage(100);
|
||||
}
|
||||
$pager = new Pager($a->query_string, DBA::count('user'), 100);
|
||||
|
||||
/* ordering */
|
||||
$valid_orders = [
|
||||
|
@ -1849,7 +1844,7 @@ function admin_page_users(App $a)
|
|||
FROM `user`
|
||||
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
|
||||
WHERE `user`.`verified`
|
||||
ORDER BY $sql_order $sql_order_direction LIMIT %d, %d", intval($a->pager['start']), intval($a->pager['itemspage'])
|
||||
ORDER BY $sql_order $sql_order_direction LIMIT %d, %d", $pager->getStart(), $pager->getItemsPerPage()
|
||||
);
|
||||
|
||||
$adminlist = explode(",", str_replace(" ", "", Config::get('config', 'admin_email')));
|
||||
|
@ -1947,7 +1942,7 @@ function admin_page_users(App $a)
|
|||
'$form_security_token' => BaseModule::getFormSecurityToken("admin_users"),
|
||||
|
||||
// values //
|
||||
'$baseurl' => System::baseUrl(true),
|
||||
'$baseurl' => $a->getBaseURL(true),
|
||||
|
||||
'$pending' => $pending,
|
||||
'deleted' => $deleted,
|
||||
|
@ -1956,7 +1951,7 @@ function admin_page_users(App $a)
|
|||
'$newusernickname' => ['new_user_nickname', L10n::t("Nickname"), '', L10n::t("Nickname of the new user.")],
|
||||
'$newuseremail' => ['new_user_email', L10n::t("Email"), '', L10n::t("Email address of the new user."), '', '', 'email'],
|
||||
]);
|
||||
$o .= paginate($a);
|
||||
$o .= $pager->renderFull();
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\ContactSelector;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
|
@ -45,9 +46,9 @@ function allfriends_content(App $a)
|
|||
|
||||
$total = Model\GContact::countAllFriends(local_user(), $cid);
|
||||
|
||||
$a->setPagerTotal($total);
|
||||
$pager = new Pager($a->query_string, $total);
|
||||
|
||||
$r = Model\GContact::allFriends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
|
||||
$r = Model\GContact::allFriends(local_user(), $cid, $pager->getStart(), $pager->getItemsPerPage());
|
||||
if (!DBA::isResult($r)) {
|
||||
$o .= L10n::t('No friends to display.');
|
||||
return $o;
|
||||
|
@ -103,7 +104,7 @@ function allfriends_content(App $a)
|
|||
//'$title' => L10n::t('Friends of %s', htmlentities($c[0]['name'])),
|
||||
'$tab_str' => $tab_str,
|
||||
'$contacts' => $entries,
|
||||
'$paginate' => paginate($a),
|
||||
'$paginate' => $pager->renderFull(),
|
||||
]);
|
||||
|
||||
return $o;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\ContactSelector;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model;
|
||||
|
@ -87,16 +88,16 @@ function common_content(App $a)
|
|||
}
|
||||
|
||||
if ($t > 0) {
|
||||
$a->setPagerTotal($t);
|
||||
$pager = new Pager($a->query_string, $t);
|
||||
} else {
|
||||
notice(L10n::t('No contacts in common.') . EOL);
|
||||
return $o;
|
||||
}
|
||||
|
||||
if ($cid) {
|
||||
$r = Model\GContact::commonFriends($uid, $cid, $a->pager['start'], $a->pager['itemspage']);
|
||||
$r = Model\GContact::commonFriends($uid, $cid, $pager->getStart(), $pager->getItemsPerPage());
|
||||
} else {
|
||||
$r = Model\GContact::commonFriendsZcid($uid, $zcid, $a->pager['start'], $a->pager['itemspage']);
|
||||
$r = Model\GContact::commonFriendsZcid($uid, $zcid, $pager->getStart(), $pager->getItemsPerPage());
|
||||
}
|
||||
|
||||
if (!DBA::isResult($r)) {
|
||||
|
@ -147,7 +148,7 @@ function common_content(App $a)
|
|||
'$title' => $title,
|
||||
'$tab_str' => $tab_str,
|
||||
'$contacts' => $entries,
|
||||
'$paginate' => paginate($a),
|
||||
'$paginate' => $pager->renderFull(),
|
||||
]);
|
||||
|
||||
return $o;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\ACL;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
|
@ -153,9 +154,9 @@ function community_content(App $a, $update = 0)
|
|||
$itemspage_network = $a->force_max_items;
|
||||
}
|
||||
|
||||
$a->setPagerItemsPage($itemspage_network);
|
||||
$pager = new Pager($a->query_string, null, $itemspage_network);
|
||||
|
||||
$r = community_getitems($a->pager['start'], $a->pager['itemspage'], $content, $accounttype);
|
||||
$r = community_getitems($pager->getStart(), $pager->getItemsPerPage(), $content, $accounttype);
|
||||
|
||||
if (!DBA::isResult($r)) {
|
||||
info(L10n::t('No results.') . EOL);
|
||||
|
@ -179,22 +180,22 @@ function community_content(App $a, $update = 0)
|
|||
}
|
||||
$previousauthor = $item["author-link"];
|
||||
|
||||
if (($numposts < $maxpostperauthor) && (count($s) < $a->pager['itemspage'])) {
|
||||
if (($numposts < $maxpostperauthor) && (count($s) < $pager->getItemsPerPage())) {
|
||||
$s[] = $item;
|
||||
}
|
||||
}
|
||||
if (count($s) < $a->pager['itemspage']) {
|
||||
$r = community_getitems($a->pager['start'] + ($count * $a->pager['itemspage']), $a->pager['itemspage'], $content, $accounttype);
|
||||
if (count($s) < $pager->getItemsPerPage()) {
|
||||
$r = community_getitems($pager->getStart() + ($count * $pager->getItemsPerPage()), $pager->getItemsPerPage(), $content, $accounttype);
|
||||
}
|
||||
} while ((count($s) < $a->pager['itemspage']) && ( ++$count < 50) && (count($r) > 0));
|
||||
} while ((count($s) < $pager->getItemsPerPage()) && ( ++$count < 50) && (count($r) > 0));
|
||||
} else {
|
||||
$s = $r;
|
||||
}
|
||||
|
||||
$o .= conversation($a, $s, 'community', $update, false, 'commented', local_user());
|
||||
$o .= conversation($a, $s, $pager, 'community', $update, false, 'commented', local_user());
|
||||
|
||||
if (!$update) {
|
||||
$o .= alt_pager($a, count($r));
|
||||
$o .= $pager->renderMinimal(count($r));
|
||||
}
|
||||
|
||||
$t = get_markup_template("community.tpl");
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
|
@ -16,8 +17,6 @@ use Friendica\Util\Proxy as ProxyUtils;
|
|||
|
||||
function directory_init(App $a)
|
||||
{
|
||||
$a->setPagerItemsPage(60);
|
||||
|
||||
if (local_user()) {
|
||||
$a->page['aside'] .= Widget::findPeople();
|
||||
$a->page['aside'] .= Widget::follow();
|
||||
|
@ -83,16 +82,18 @@ function directory_content(App $a)
|
|||
$publish = (Config::get('system', 'publish_all') ? '' : " AND `publish` = 1 " );
|
||||
|
||||
|
||||
$total = 0;
|
||||
$cnt = DBA::fetchFirst("SELECT COUNT(*) AS `total` FROM `profile`
|
||||
LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid`
|
||||
WHERE `is-default` $publish AND NOT `user`.`blocked` AND NOT `user`.`account_removed` $sql_extra");
|
||||
if (DBA::isResult($cnt)) {
|
||||
$a->setPagerTotal($cnt['total']);
|
||||
$total = $cnt['total'];
|
||||
}
|
||||
$pager = new Pager($a->query_string, $total, 60);
|
||||
|
||||
$order = " ORDER BY `name` ASC ";
|
||||
|
||||
$limit = intval($a->pager['start'])."," . intval($a->pager['itemspage']);
|
||||
$limit = $pager->getStart()."," . $pager->getItemsPerPage();
|
||||
|
||||
$r = DBA::p("SELECT `profile`.*, `profile`.`uid` AS `profile_uid`, `user`.`nickname`, `user`.`timezone` , `user`.`page-flags`,
|
||||
`contact`.`addr`, `contact`.`url` AS profile_url FROM `profile`
|
||||
|
@ -212,7 +213,7 @@ function directory_content(App $a)
|
|||
'$findterm' => (strlen($search) ? $search : ""),
|
||||
'$title' => L10n::t('Site Directory'),
|
||||
'$submit' => L10n::t('Find'),
|
||||
'$paginate' => paginate($a),
|
||||
'$paginate' => $pager->renderFull(),
|
||||
]);
|
||||
} else {
|
||||
info(L10n::t("No entries \x28some entries may be hidden\x29.") . EOL);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\ContactSelector;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
|
@ -71,7 +72,7 @@ function dirfind_content(App $a, $prefix = "") {
|
|||
$j = new stdClass();
|
||||
$j->total = 1;
|
||||
$j->items_page = 1;
|
||||
$j->page = $a->pager['page'];
|
||||
$j->page = $pager->getPage();
|
||||
|
||||
$objresult = new stdClass();
|
||||
$objresult->cid = 0;
|
||||
|
@ -100,7 +101,7 @@ function dirfind_content(App $a, $prefix = "") {
|
|||
$extra_sql = "";
|
||||
|
||||
$perpage = 80;
|
||||
$startrec = (($a->pager['page']) * $perpage) - $perpage;
|
||||
$startrec = (($pager->getPage()) * $perpage) - $perpage;
|
||||
|
||||
if (Config::get('system','diaspora_enabled')) {
|
||||
$diaspora = Protocol::DIASPORA;
|
||||
|
@ -141,7 +142,7 @@ function dirfind_content(App $a, $prefix = "") {
|
|||
$j = new stdClass();
|
||||
$j->total = $count[0]["total"];
|
||||
$j->items_page = $perpage;
|
||||
$j->page = $a->pager['page'];
|
||||
$j->page = $pager->getPage();
|
||||
foreach ($results AS $result) {
|
||||
if (PortableContact::alternateOStatusUrl($result["nurl"])) {
|
||||
continue;
|
||||
|
@ -178,7 +179,7 @@ function dirfind_content(App $a, $prefix = "") {
|
|||
Worker::add(PRIORITY_LOW, 'DiscoverPoCo', "dirsearch", urlencode($search));
|
||||
} else {
|
||||
|
||||
$p = (($a->pager['page'] != 1) ? '&p=' . $a->pager['page'] : '');
|
||||
$p = (($pager->getPage() != 1) ? '&p=' . $pager->getPage() : '');
|
||||
|
||||
if(strlen(Config::get('system','directory')))
|
||||
$x = Network::fetchUrl(get_server().'/lsearch?f=' . $p . '&search=' . urlencode($search));
|
||||
|
@ -186,12 +187,8 @@ function dirfind_content(App $a, $prefix = "") {
|
|||
$j = json_decode($x);
|
||||
}
|
||||
|
||||
if ($j->total) {
|
||||
$a->setPagerTotal($j->total);
|
||||
$a->setPagerItemsPage($j->items_page);
|
||||
}
|
||||
|
||||
if (!empty($j->results)) {
|
||||
$pager = new Pager($a->query_string, $j->total, $j->items_page);
|
||||
|
||||
$id = 0;
|
||||
|
||||
|
@ -252,13 +249,13 @@ function dirfind_content(App $a, $prefix = "") {
|
|||
$entries[] = $entry;
|
||||
}
|
||||
|
||||
$tpl = get_markup_template('viewcontact_template.tpl');
|
||||
$tpl = get_markup_template('viewcontact_template.tpl');
|
||||
|
||||
$o .= replace_macros($tpl,[
|
||||
'title' => $header,
|
||||
'$contacts' => $entries,
|
||||
'$paginate' => paginate($a),
|
||||
]);
|
||||
$o .= replace_macros($tpl,[
|
||||
'title' => $header,
|
||||
'$contacts' => $entries,
|
||||
'$paginate' => $pager->renderFull(),
|
||||
]);
|
||||
|
||||
} else {
|
||||
info(L10n::t('No matches') . EOL);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Core\ACL;
|
||||
|
@ -16,9 +17,8 @@ use Friendica\Model\Contact;
|
|||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Protocol\DFRN;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Util\Security;
|
||||
use Friendica\Protocol\DFRN;
|
||||
|
||||
function display_init(App $a)
|
||||
{
|
||||
|
@ -358,7 +358,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
|
|||
$o .= "<script> var netargs = '?f=&item_id=" . $item_id . "'; </script>";
|
||||
}
|
||||
|
||||
$o .= conversation($a, [$item], 'display', $update_uid, false, 'commented', local_user());
|
||||
$o .= conversation($a, [$item], new Pager($a->query_string), 'display', $update_uid, false, 'commented', local_user());
|
||||
|
||||
// Preparing the meta header
|
||||
$description = trim(HTML::toPlaintext(BBCode::convert($item["body"], false), 0, true));
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Content\Text\HTML;
|
||||
use Friendica\Core\Addon;
|
||||
|
@ -33,6 +34,7 @@ use Friendica\Protocol\Email;
|
|||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Emailer;
|
||||
use Friendica\Util\Security;
|
||||
use function Friendica\Core\function_exists;
|
||||
|
||||
require_once 'include/enotify.php';
|
||||
require_once 'include/text.php';
|
||||
|
@ -667,10 +669,10 @@ function item_post(App $a) {
|
|||
$datarray["item_id"] = -1;
|
||||
$datarray["author-network"] = Protocol::DFRN;
|
||||
|
||||
$o = conversation($a,[array_merge($contact_record,$datarray)],'search', false, true);
|
||||
$o = conversation($a, [array_merge($contact_record, $datarray)], new Pager($a->query_string), 'search', false, true);
|
||||
logger('preview: ' . $o);
|
||||
echo json_encode(['preview' => $o]);
|
||||
killme();
|
||||
exit();
|
||||
}
|
||||
|
||||
Addon::callHooks('post_local',$datarray);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
|
@ -54,8 +55,8 @@ function match_content(App $a)
|
|||
|
||||
if ($tags) {
|
||||
$params['s'] = $tags;
|
||||
if ($a->pager['page'] != 1) {
|
||||
$params['p'] = $a->pager['page'];
|
||||
if ($pager->getPage() != 1) {
|
||||
$params['p'] = $pager->getPage();
|
||||
}
|
||||
|
||||
if (strlen(Config::get('system', 'directory'))) {
|
||||
|
@ -66,12 +67,9 @@ function match_content(App $a)
|
|||
|
||||
$j = json_decode($x);
|
||||
|
||||
if ($j->total) {
|
||||
$a->setPagerTotal($j->total);
|
||||
$a->setPagerItemsPage($j->items_page);
|
||||
}
|
||||
|
||||
if (count($j->results)) {
|
||||
$pager = new Pager($a->query_string, $j->total, $j->items_page);
|
||||
|
||||
$id = 0;
|
||||
|
||||
foreach ($j->results as $jj) {
|
||||
|
@ -119,7 +117,7 @@ function match_content(App $a)
|
|||
[
|
||||
'$title' => L10n::t('Profile Match'),
|
||||
'$contacts' => $entries,
|
||||
'$paginate' => paginate($a)]
|
||||
'$paginate' => $pager->renderFull()]
|
||||
);
|
||||
} else {
|
||||
info(L10n::t('No matches') . EOL);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Smilies;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\ACL;
|
||||
|
@ -13,10 +14,10 @@ use Friendica\Core\System;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Mail;
|
||||
use Friendica\Module\Login;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Proxy as ProxyUtils;
|
||||
use Friendica\Util\Temporal;
|
||||
use Friendica\Module\Login;
|
||||
|
||||
require_once 'include/conversation.php';
|
||||
|
||||
|
@ -273,16 +274,18 @@ function message_content(App $a)
|
|||
|
||||
$o .= $header;
|
||||
|
||||
$total = 0;
|
||||
$r = q("SELECT count(*) AS `total`, ANY_VALUE(`created`) AS `created` FROM `mail`
|
||||
WHERE `mail`.`uid` = %d GROUP BY `parent-uri` ORDER BY `created` DESC",
|
||||
intval(local_user())
|
||||
);
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
$a->setPagerTotal($r[0]['total']);
|
||||
$total = $r[0]['total'];
|
||||
}
|
||||
|
||||
$r = get_messages(local_user(), $a->pager['start'], $a->pager['itemspage']);
|
||||
$pager = new Pager($a->query_string, $total);
|
||||
|
||||
$r = get_messages(local_user(), $pager->getStart(), $pager->getItemsPerPage());
|
||||
|
||||
if (!DBA::isResult($r)) {
|
||||
info(L10n::t('No messages.') . EOL);
|
||||
|
@ -291,7 +294,7 @@ function message_content(App $a)
|
|||
|
||||
$o .= render_messages($r, 'mail_list.tpl');
|
||||
|
||||
$o .= paginate($a);
|
||||
$o .= $pager->renderFull();
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
|
123
mod/network.php
123
mod/network.php
|
@ -8,14 +8,15 @@ use Friendica\App;
|
|||
use Friendica\Content\Feature;
|
||||
use Friendica\Content\ForumManager;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\ACL;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
|
@ -35,6 +36,8 @@ function network_init(App $a)
|
|||
return;
|
||||
}
|
||||
|
||||
Hook::add('head', __FILE__, 'network_infinite_scroll_head');
|
||||
|
||||
$search = (x($_GET, 'search') ? escape_tags($_GET['search']) : '');
|
||||
|
||||
if (($search != '') && !empty($_GET['submit'])) {
|
||||
|
@ -279,7 +282,7 @@ function network_query_get_sel_group(App $a)
|
|||
* @param integer $update Used for the automatic reloading
|
||||
* @return string SQL with the appropriate LIMIT clause
|
||||
*/
|
||||
function networkPager($a, $update)
|
||||
function networkPager(App $a, Pager $pager, $update)
|
||||
{
|
||||
if ($update) {
|
||||
// only setup pagination on initial page view
|
||||
|
@ -302,9 +305,9 @@ function networkPager($a, $update)
|
|||
$itemspage_network = $a->force_max_items;
|
||||
}
|
||||
|
||||
$a->setPagerItemsPage($itemspage_network);
|
||||
$pager->setItemsPerPage($itemspage_network);
|
||||
|
||||
return sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
return sprintf(" LIMIT %d, %d ", $pager->getStart(), $pager->getItemsPerPage());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -328,24 +331,24 @@ function networkSetSeen($condition)
|
|||
/**
|
||||
* @brief Create the conversation HTML
|
||||
*
|
||||
* @param App $a The global App
|
||||
* @param array $items Items of the conversation
|
||||
* @param string $mode Display mode for the conversation
|
||||
* @param App $a The global App
|
||||
* @param array $items Items of the conversation
|
||||
* @param string $mode Display mode for the conversation
|
||||
* @param integer $update Used for the automatic reloading
|
||||
* @return string HTML of the conversation
|
||||
*/
|
||||
function networkConversation($a, $items, $mode, $update, $ordering = '')
|
||||
function networkConversation(App $a, $items, Pager $pager, $mode, $update, $ordering = '')
|
||||
{
|
||||
// Set this so that the conversation function can find out contact info for our wall-wall items
|
||||
$a->page_contact = $a->contact;
|
||||
|
||||
$o = conversation($a, $items, $mode, $update, false, $ordering, local_user());
|
||||
$o = conversation($a, $items, $pager, $mode, $update, false, $ordering, local_user());
|
||||
|
||||
if (!$update) {
|
||||
if (PConfig::get(local_user(), 'system', 'infinite_scroll')) {
|
||||
$o .= scroll_loader();
|
||||
} else {
|
||||
$o .= alt_pager($a, count($items));
|
||||
$o .= $pager->renderMinimal(count($items));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -372,7 +375,7 @@ function network_content(App $a, $update = 0, $parent = 0)
|
|||
}
|
||||
}
|
||||
|
||||
if (x($_GET, 'file')) {
|
||||
if (!empty($_GET['file'])) {
|
||||
$flat_mode = true;
|
||||
}
|
||||
|
||||
|
@ -388,12 +391,14 @@ function network_content(App $a, $update = 0, $parent = 0)
|
|||
/**
|
||||
* @brief Get the network content in flat view
|
||||
*
|
||||
* @param App $a The global App
|
||||
* @param Pager $pager
|
||||
* @param App $a The global App
|
||||
* @param integer $update Used for the automatic reloading
|
||||
* @return string HTML of the network content in flat view
|
||||
*/
|
||||
function networkFlatView(App $a, $update = 0)
|
||||
{
|
||||
global $pager;
|
||||
// Rawmode is used for fetching new content at the end of the page
|
||||
$rawmode = (isset($_GET['mode']) && ($_GET['mode'] == 'raw'));
|
||||
|
||||
|
@ -405,7 +410,7 @@ function networkFlatView(App $a, $update = 0)
|
|||
|
||||
$o = '';
|
||||
|
||||
$file = ((x($_GET, 'file')) ? $_GET['file'] : '');
|
||||
$file = defaults($_GET, 'file', '');
|
||||
|
||||
if (!$update && !$rawmode) {
|
||||
$tabs = network_tabs($a);
|
||||
|
@ -437,12 +442,15 @@ function networkFlatView(App $a, $update = 0)
|
|||
}
|
||||
}
|
||||
|
||||
$pager_sql = networkPager($a, $update);
|
||||
$pager = new Pager($a->query_string);
|
||||
|
||||
/// @TODO Figure out why this variable is unused
|
||||
$pager_sql = networkPager($a, $pager, $update);
|
||||
|
||||
if (strlen($file)) {
|
||||
$condition = ["`term` = ? AND `otype` = ? AND `type` = ? AND `uid` = ?",
|
||||
$file, TERM_OBJ_POST, TERM_FILE, local_user()];
|
||||
$params = ['order' => ['tid' => true], 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
||||
$params = ['order' => ['tid' => true], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
|
||||
$result = DBA::select('term', ['oid'], $condition);
|
||||
|
||||
$posts = [];
|
||||
|
@ -456,14 +464,14 @@ function networkFlatView(App $a, $update = 0)
|
|||
$condition = ['uid' => local_user()];
|
||||
}
|
||||
|
||||
$params = ['order' => ['id' => true], 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
||||
$params = ['order' => ['id' => true], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
|
||||
$result = Item::selectForUser(local_user(), [], $condition, $params);
|
||||
$items = Item::inArray($result);
|
||||
|
||||
$condition = ['unseen' => true, 'uid' => local_user()];
|
||||
networkSetSeen($condition);
|
||||
|
||||
$o .= networkConversation($a, $items, 'network-new', $update);
|
||||
$o .= networkConversation($a, $items, $pager, 'network-new', $update);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
@ -471,12 +479,17 @@ function networkFlatView(App $a, $update = 0)
|
|||
/**
|
||||
* @brief Get the network content in threaded view
|
||||
*
|
||||
* @param App $a The global App
|
||||
* @param integer $update Used for the automatic reloading
|
||||
* @global Pager $pager
|
||||
* @param App $a The global App
|
||||
* @param integer $update Used for the automatic reloading
|
||||
* @param integer $parent
|
||||
* @return string HTML of the network content in flat view
|
||||
*/
|
||||
function networkThreadedView(App $a, $update, $parent)
|
||||
{
|
||||
/// @TODO this will have to be converted to a static property of the converted Module\Network class
|
||||
global $pager;
|
||||
|
||||
// Rawmode is used for fetching new content at the end of the page
|
||||
$rawmode = (isset($_GET['mode']) AND ( $_GET['mode'] == 'raw'));
|
||||
|
||||
|
@ -543,13 +556,11 @@ function networkThreadedView(App $a, $update, $parent)
|
|||
$tabs = network_tabs($a);
|
||||
$o .= $tabs;
|
||||
|
||||
if ($gid) {
|
||||
if (($t = Contact::getOStatusCountByGroupId($gid)) && !PConfig::get(local_user(), 'system', 'nowarn_insecure')) {
|
||||
notice(L10n::tt("Warning: This group contains %s member from a network that doesn't allow non public messages.",
|
||||
"Warning: This group contains %s members from a network that doesn't allow non public messages.",
|
||||
$t) . EOL);
|
||||
notice(L10n::t("Messages in this group won't be send to these receivers.").EOL);
|
||||
}
|
||||
if ($gid && ($t = Contact::getOStatusCountByGroupId($gid)) && !PConfig::get(local_user(), 'system', 'nowarn_insecure')) {
|
||||
notice(L10n::tt("Warning: This group contains %s member from a network that doesn't allow non public messages.",
|
||||
"Warning: This group contains %s members from a network that doesn't allow non public messages.",
|
||||
$t) . EOL);
|
||||
notice(L10n::t("Messages in this group won't be send to these receivers.").EOL);
|
||||
}
|
||||
|
||||
Nav::setSelected('network');
|
||||
|
@ -706,13 +717,15 @@ function networkThreadedView(App $a, $update, $parent)
|
|||
|
||||
$sql_order = "$sql_table.$ordering";
|
||||
|
||||
if (x($_GET, 'offset')) {
|
||||
if (!empty($_GET['offset'])) {
|
||||
$sql_range = sprintf(" AND $sql_order <= '%s'", DBA::escape($_GET['offset']));
|
||||
} else {
|
||||
$sql_range = '';
|
||||
}
|
||||
|
||||
$pager_sql = networkPager($a, $update);
|
||||
$pager = new Pager($a->query_string);
|
||||
|
||||
$pager_sql = networkPager($a, $pager, $update);
|
||||
|
||||
$last_date = '';
|
||||
|
||||
|
@ -721,31 +734,31 @@ function networkThreadedView(App $a, $update, $parent)
|
|||
if ($last_received != '') {
|
||||
$last_date = $last_received;
|
||||
$sql_range .= sprintf(" AND $sql_table.`received` < '%s'", DBA::escape($last_received));
|
||||
$a->setPagerPage(1);
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
$pager->setPage(1);
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ", $pager->getStart(), $pager->getItemsPerPage());
|
||||
}
|
||||
break;
|
||||
case 'commented':
|
||||
if ($last_commented != '') {
|
||||
$last_date = $last_commented;
|
||||
$sql_range .= sprintf(" AND $sql_table.`commented` < '%s'", DBA::escape($last_commented));
|
||||
$a->setPagerPage(1);
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
$pager->setPage(1);
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ", $pager->getStart(), $pager->getItemsPerPage());
|
||||
}
|
||||
break;
|
||||
case 'created':
|
||||
if ($last_created != '') {
|
||||
$last_date = $last_created;
|
||||
$sql_range .= sprintf(" AND $sql_table.`created` < '%s'", DBA::escape($last_created));
|
||||
$a->setPagerPage(1);
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
$pager->setPage(1);
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ", $pager->getStart(), $pager->getItemsPerPage());
|
||||
}
|
||||
break;
|
||||
case 'id':
|
||||
if (($last_id > 0) && ($sql_table == '`thread`')) {
|
||||
$sql_range .= sprintf(" AND $sql_table.`iid` < '%s'", DBA::escape($last_id));
|
||||
$a->setPagerPage(1);
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
$pager->setPage(1);
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ", $pager->getStart(), $pager->getItemsPerPage());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -835,7 +848,7 @@ function networkThreadedView(App $a, $update, $parent)
|
|||
|
||||
if ($last_date > $top_limit) {
|
||||
$top_limit = $last_date;
|
||||
} elseif ($a->pager['page'] == 1) {
|
||||
} elseif ($pager->getPage() == 1) {
|
||||
// Highest possible top limit when we are on the first page
|
||||
$top_limit = DateTimeFormat::utcNow();
|
||||
}
|
||||
|
@ -898,7 +911,12 @@ function networkThreadedView(App $a, $update, $parent)
|
|||
$date_offset = $_GET['offset'];
|
||||
}
|
||||
|
||||
$a->page_offset = $date_offset;
|
||||
$query_string = $a->query_string;
|
||||
if ($date_offset && !preg_match('/[?&].offset=/', $query_string)) {
|
||||
$query_string .= '&offset=' . urlencode($date_offset);
|
||||
}
|
||||
|
||||
$pager->setQueryString($query_string);
|
||||
|
||||
// We aren't going to try and figure out at the item, group, and page
|
||||
// level which items you've seen and which you haven't. If you're looking
|
||||
|
@ -914,7 +932,7 @@ function networkThreadedView(App $a, $update, $parent)
|
|||
|
||||
|
||||
$mode = 'network';
|
||||
$o .= networkConversation($a, $items, $mode, $update, $ordering);
|
||||
$o .= networkConversation($a, $items, $pager, $mode, $update, $ordering);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
@ -1019,3 +1037,30 @@ function network_tabs(App $a)
|
|||
|
||||
// --- end item filter tabs
|
||||
}
|
||||
|
||||
/**
|
||||
* Network hook into the HTML head to enable infinite scroll.
|
||||
*
|
||||
* Since the HTML head is built after the module content has been generated, we need to retrieve the base query string
|
||||
* of the page to make the correct asynchronous call. This is obtained through the Pager that was instantiated in
|
||||
* networkThreadedView or networkFlatView.
|
||||
*
|
||||
* @global Pager $pager
|
||||
* @param App $a
|
||||
* @param string $htmlhead The head tag HTML string
|
||||
*/
|
||||
function network_infinite_scroll_head(App $a, &$htmlhead)
|
||||
{
|
||||
/// @TODO this will have to be converted to a static property of the converted Module\Network class
|
||||
global $pager;
|
||||
|
||||
if (PConfig::get(local_user(), 'system', 'infinite_scroll')
|
||||
&& defaults($_GET, 'mode', '') != 'minimal'
|
||||
) {
|
||||
$tpl = get_markup_template('infinite_scroll_head.tpl');
|
||||
$htmlhead .= replace_macros($tpl, [
|
||||
'$pageno' => $pager->getPage(),
|
||||
'$reload_uri' => $pager->getBaseQueryString()
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Item;
|
||||
|
@ -60,10 +61,10 @@ function notes_content(App $a, $update = false)
|
|||
$condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT,
|
||||
'wall' => false, 'contact-id'=> $a->contact['id']];
|
||||
|
||||
$a->setPagerItemsPage(40);
|
||||
$pager = new Pager($a->query_string, null, 40);
|
||||
|
||||
$params = ['order' => ['created' => true],
|
||||
'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
||||
'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
|
||||
$r = Item::selectThreadForUser(local_user(), ['uri'], $condition, $params);
|
||||
|
||||
$count = 0;
|
||||
|
@ -73,10 +74,10 @@ function notes_content(App $a, $update = false)
|
|||
|
||||
$count = count($notes);
|
||||
|
||||
$o .= conversation($a, $notes, 'notes', $update);
|
||||
$o .= conversation($a, $notes, $pager, 'notes', $update);
|
||||
}
|
||||
|
||||
$o .= alt_pager($a, $count);
|
||||
$o .= $pager->renderMinimal($count);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
use Friendica\App;
|
||||
use Friendica\Content\ContactSelector;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\NotificationsManager;
|
||||
use Friendica\Core\Protocol;
|
||||
|
@ -120,11 +121,11 @@ function notifications_content(App $a)
|
|||
}
|
||||
|
||||
// Set the pager
|
||||
$a->setPagerItemsPage($perpage);
|
||||
$pager = new Pager($a->query_string, null, $perpage);
|
||||
|
||||
// Add additional informations (needed for json output)
|
||||
$notifs['items_page'] = $a->pager['itemspage'];
|
||||
$notifs['page'] = $a->pager['page'];
|
||||
$notifs['items_page'] = $pager->getItemsPerPage();
|
||||
$notifs['page'] = $pager->getPage();
|
||||
|
||||
// Json output
|
||||
if (intval($json) === 1) {
|
||||
|
@ -315,7 +316,7 @@ function notifications_content(App $a)
|
|||
'$notif_content' => $notif_content,
|
||||
'$notif_nocontent' => $notif_nocontent,
|
||||
'$notif_show_lnk' => $notif_show_lnk,
|
||||
'$notif_paginate' => alt_pager($a, count($notif_content))
|
||||
'$notif_paginate' => $pager->renderMinimal(count($notif_content))
|
||||
]);
|
||||
|
||||
return $o;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
use Friendica\App;
|
||||
use Friendica\Content\Feature;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\ACL;
|
||||
use Friendica\Core\Addon;
|
||||
|
@ -25,8 +26,8 @@ use Friendica\Object\Image;
|
|||
use Friendica\Protocol\DFRN;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Map;
|
||||
use Friendica\Util\Temporal;
|
||||
use Friendica\Util\Security;
|
||||
use Friendica\Util\Temporal;
|
||||
|
||||
require_once 'include/items.php';
|
||||
|
||||
|
@ -1135,16 +1136,18 @@ function photos_content(App $a)
|
|||
if ($datatype === 'album') {
|
||||
$album = hex2bin($datum);
|
||||
|
||||
$total = 0;
|
||||
$r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` = '%s'
|
||||
AND `scale` <= 4 $sql_extra GROUP BY `resource-id`",
|
||||
intval($owner_uid),
|
||||
DBA::escape($album)
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
$a->setPagerTotal(count($r));
|
||||
$a->setPagerItemsPage(20);
|
||||
$total = count($r);
|
||||
}
|
||||
|
||||
$pager = new Pager($a->query_string, $total, 20);
|
||||
|
||||
/// @TODO I have seen this many times, maybe generalize it script-wide and encapsulate it?
|
||||
$order_field = defaults($_GET, 'order', '');
|
||||
if ($order_field === 'posted') {
|
||||
|
@ -1160,8 +1163,8 @@ function photos_content(App $a)
|
|||
AND `scale` <= 4 $sql_extra GROUP BY `resource-id` ORDER BY `created` $order LIMIT %d , %d",
|
||||
intval($owner_uid),
|
||||
DBA::escape($album),
|
||||
intval($a->pager['start']),
|
||||
intval($a->pager['itemspage'])
|
||||
$pager->getStart(),
|
||||
$pager->getItemsPerPage()
|
||||
);
|
||||
|
||||
// edit album name
|
||||
|
@ -1230,7 +1233,7 @@ function photos_content(App $a)
|
|||
'$upload' => [L10n::t('Upload New Photos'), 'photos/' . $a->data['user']['nickname'] . '/upload/' . bin2hex($album)],
|
||||
'$order' => $order,
|
||||
'$edit' => $edit,
|
||||
'$paginate' => paginate($a),
|
||||
'$paginate' => $pager->renderFull(),
|
||||
]);
|
||||
|
||||
return $o;
|
||||
|
@ -1391,9 +1394,9 @@ function photos_content(App $a)
|
|||
$link_item = Item::selectFirst([], ['id' => $linked_items[0]['id']]);
|
||||
|
||||
$condition = ["`parent` = ? AND `parent` != `id`", $link_item['parent']];
|
||||
$a->setPagerTotal(DBA::count('item', $condition));
|
||||
$pager = new Pager($a->query_string, DBA::count('item', $condition));
|
||||
|
||||
$params = ['order' => ['id'], 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
||||
$params = ['order' => ['id'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
|
||||
$result = Item::selectForUser($link_item['uid'], Item::ITEM_FIELDLIST, $condition, $params);
|
||||
$items = Item::inArray($result);
|
||||
|
||||
|
@ -1608,7 +1611,7 @@ function photos_content(App $a)
|
|||
}
|
||||
$responses = get_responses($conv_responses, $response_verbs, '', $link_item);
|
||||
|
||||
$paginate = paginate($a);
|
||||
$paginate = $pager->renderFull();
|
||||
}
|
||||
|
||||
$photo_tpl = get_markup_template('photo_view.tpl');
|
||||
|
@ -1653,8 +1656,7 @@ function photos_content(App $a)
|
|||
);
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
$a->setPagerTotal(count($r));
|
||||
$a->setPagerItemsPage(20);
|
||||
$pager = new Pager($a->query_string, count($r), 20);
|
||||
}
|
||||
|
||||
$r = q("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`,
|
||||
|
@ -1665,8 +1667,8 @@ function photos_content(App $a)
|
|||
intval($a->data['user']['uid']),
|
||||
DBA::escape('Contact Photos'),
|
||||
DBA::escape(L10n::t('Contact Photos')),
|
||||
intval($a->pager['start']),
|
||||
intval($a->pager['itemspage'])
|
||||
$pager->getStart(),
|
||||
$pager->getItemsPerPage()
|
||||
);
|
||||
|
||||
$photos = [];
|
||||
|
@ -1709,7 +1711,7 @@ function photos_content(App $a)
|
|||
'$can_post' => $can_post,
|
||||
'$upload' => [L10n::t('Upload New Photos'), 'photos/'.$a->data['user']['nickname'].'/upload'],
|
||||
'$photos' => $photos,
|
||||
'$paginate' => paginate($a),
|
||||
'$paginate' => $pager->renderFull(),
|
||||
]);
|
||||
|
||||
return $o;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Content\Widget;
|
||||
use Friendica\Core\ACL;
|
||||
use Friendica\Core\Addon;
|
||||
|
@ -18,10 +19,10 @@ use Friendica\Model\Group;
|
|||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Module\Login;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
use Friendica\Protocol\DFRN;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Security;
|
||||
use Friendica\Protocol\ActivityPub;
|
||||
|
||||
function profile_init(App $a)
|
||||
{
|
||||
|
@ -307,9 +308,9 @@ function profile_content(App $a, $update = 0)
|
|||
$itemspage_network = $a->force_max_items;
|
||||
}
|
||||
|
||||
$a->setPagerItemsPage($itemspage_network);
|
||||
$pager = new Pager($a->query_string, null, $itemspage_network);
|
||||
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
|
||||
$pager_sql = sprintf(" LIMIT %d, %d ", $pager->getStart(), $pager->getItemsPerPage());
|
||||
|
||||
$items = q("SELECT `item`.`uri`
|
||||
FROM `thread`
|
||||
|
@ -344,10 +345,10 @@ function profile_content(App $a, $update = 0)
|
|||
}
|
||||
}
|
||||
|
||||
$o .= conversation($a, $items, 'profile', $update, false, 'created', local_user());
|
||||
$o .= conversation($a, $items, $pager, 'profile', $update, false, 'created', local_user());
|
||||
|
||||
if (!$update) {
|
||||
$o .= alt_pager($a, count($items));
|
||||
$o .= $pager->renderMinimal(count($items));
|
||||
}
|
||||
|
||||
return $o;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
use Friendica\App;
|
||||
use Friendica\Content\Feature;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
|
@ -200,6 +201,8 @@ function search_content(App $a) {
|
|||
// 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($a->query_string);
|
||||
|
||||
if ($tag) {
|
||||
logger("Start tag search for '".$search."'", LOGGER_DEBUG);
|
||||
|
||||
|
@ -207,7 +210,7 @@ function search_content(App $a) {
|
|||
AND `otype` = ? AND `type` = ? AND `term` = ?",
|
||||
local_user(), TERM_OBJ_POST, TERM_HASHTAG, $search];
|
||||
$params = ['order' => ['created' => true],
|
||||
'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
||||
'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
|
||||
$terms = DBA::select('term', ['oid'], $condition, $params);
|
||||
|
||||
$itemids = [];
|
||||
|
@ -230,7 +233,7 @@ function search_content(App $a) {
|
|||
AND `body` LIKE CONCAT('%',?,'%')",
|
||||
local_user(), $search];
|
||||
$params = ['order' => ['id' => true],
|
||||
'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
||||
'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
|
||||
$items = Item::selectForUser(local_user(), [], $condition, $params);
|
||||
$r = Item::inArray($items);
|
||||
}
|
||||
|
@ -252,9 +255,9 @@ function search_content(App $a) {
|
|||
]);
|
||||
|
||||
logger("Start Conversation for '".$search."'", LOGGER_DEBUG);
|
||||
$o .= conversation($a, $r, 'search', false, false, 'commented', local_user());
|
||||
$o .= conversation($a, $r, $pager, 'search', false, false, 'commented', local_user());
|
||||
|
||||
$o .= alt_pager($a,count($r));
|
||||
$o .= $pager->renderMinimal(count($r));
|
||||
|
||||
logger("Done '".$search."'", LOGGER_DEBUG);
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\System;
|
||||
|
@ -334,15 +335,15 @@ function videos_content(App $a)
|
|||
// Default - show recent videos (no upload link for now)
|
||||
//$o = '';
|
||||
|
||||
$total = 0;
|
||||
$r = q("SELECT hash FROM `attach` WHERE `uid` = %d AND filetype LIKE '%%video%%'
|
||||
$sql_extra GROUP BY hash",
|
||||
intval($a->data['user']['uid'])
|
||||
);
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
$a->setPagerTotal(count($r));
|
||||
$a->setPagerItemsPage(20);
|
||||
$total = count($r);
|
||||
}
|
||||
$pager = new Pager($a->query_string, $total, 20);
|
||||
|
||||
$r = q("SELECT hash, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`created`) AS `created`,
|
||||
ANY_VALUE(`filename`) AS `filename`, ANY_VALUE(`filetype`) as `filetype`
|
||||
|
@ -350,8 +351,8 @@ function videos_content(App $a)
|
|||
WHERE `uid` = %d AND filetype LIKE '%%video%%'
|
||||
$sql_extra GROUP BY hash ORDER BY `created` DESC LIMIT %d , %d",
|
||||
intval($a->data['user']['uid']),
|
||||
intval($a->pager['start']),
|
||||
intval($a->pager['itemspage'])
|
||||
$pager->getStart(),
|
||||
$pager->getItemsPerPage()
|
||||
);
|
||||
|
||||
$videos = [];
|
||||
|
@ -388,7 +389,7 @@ function videos_content(App $a)
|
|||
'$delete_url' => (($can_post) ? System::baseUrl() . '/videos/' . $a->data['user']['nickname'] : false)
|
||||
]);
|
||||
|
||||
$o .= paginate($a);
|
||||
$o .= $pager->renderFull();
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
|
|
@ -2,17 +2,19 @@
|
|||
/**
|
||||
* @file mod/viewcontacts.php
|
||||
*/
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\ContactSelector;
|
||||
use Friendica\Content\Nav;
|
||||
use Friendica\Content\Pager;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Profile;
|
||||
use Friendica\Util\Proxy as ProxyUtils;
|
||||
use Friendica\Core\System;
|
||||
|
||||
function viewcontacts_init(App $a)
|
||||
{
|
||||
|
@ -61,6 +63,7 @@ function viewcontacts_content(App $a)
|
|||
return $o;
|
||||
}
|
||||
|
||||
$total = 0;
|
||||
$r = q("SELECT COUNT(*) AS `total` FROM `contact`
|
||||
WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
|
||||
AND NOT `hidden` AND NOT `archive`
|
||||
|
@ -71,8 +74,9 @@ function viewcontacts_content(App $a)
|
|||
DBA::escape(Protocol::OSTATUS)
|
||||
);
|
||||
if (DBA::isResult($r)) {
|
||||
$a->setPagerTotal($r[0]['total']);
|
||||
$total = $r[0]['total'];
|
||||
}
|
||||
$pager = new Pager($a->query_string, $total);
|
||||
|
||||
$r = q("SELECT * FROM `contact`
|
||||
WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
|
||||
|
@ -83,8 +87,8 @@ function viewcontacts_content(App $a)
|
|||
DBA::escape(Protocol::DFRN),
|
||||
DBA::escape(Protocol::DIASPORA),
|
||||
DBA::escape(Protocol::OSTATUS),
|
||||
intval($a->pager['start']),
|
||||
intval($a->pager['itemspage'])
|
||||
$pager->getStart(),
|
||||
$pager->getItemsPerPage()
|
||||
);
|
||||
if (!DBA::isResult($r)) {
|
||||
info(L10n::t('No contacts.').EOL);
|
||||
|
@ -124,7 +128,7 @@ function viewcontacts_content(App $a)
|
|||
$o .= replace_macros($tpl, [
|
||||
'$title' => L10n::t('Contacts'),
|
||||
'$contacts' => $contacts,
|
||||
'$paginate' => paginate($a),
|
||||
'$paginate' => $pager->renderFull(),
|
||||
]);
|
||||
|
||||
return $o;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue