mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-17 04:15:15 +02:00
Move itemCount parameter from constructor to renderFull()
- Remove Pager->itemCount property and Pager->setItemCount() method - Update usage
This commit is contained in:
parent
14237a9599
commit
7c0b591043
12 changed files with 70 additions and 80 deletions
|
@ -483,7 +483,7 @@ function admin_page_contactblock(App $a)
|
|||
|
||||
$total = DBA::count('contact', $condition);
|
||||
|
||||
$pager = new Pager($a->query_string, $total, 30);
|
||||
$pager = new Pager($a->query_string, 30);
|
||||
|
||||
$statement = DBA::select('contact', [], $condition, ['limit' => [$pager->getStart(), $pager->getItemsPerPage()]]);
|
||||
|
||||
|
@ -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' => $pager->renderFull(),
|
||||
'$paginate' => $pager->renderFull($total),
|
||||
'$contacturl' => ['contact_url', L10n::t("Profile URL"), '', L10n::t("URL of the remote contact to block.")],
|
||||
]);
|
||||
return $o;
|
||||
|
@ -1812,7 +1812,7 @@ function admin_page_users(App $a)
|
|||
/* get pending */
|
||||
$pending = Register::getPending();
|
||||
|
||||
$pager = new Pager($a->query_string, DBA::count('user'), 100);
|
||||
$pager = new Pager($a->query_string, 100);
|
||||
|
||||
/* ordering */
|
||||
$valid_orders = [
|
||||
|
@ -1951,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 .= $pager->renderFull();
|
||||
$o .= $pager->renderFull(DBA::count('user'));
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ function allfriends_content(App $a)
|
|||
|
||||
$total = Model\GContact::countAllFriends(local_user(), $cid);
|
||||
|
||||
$pager = new Pager($a->query_string, $total);
|
||||
$pager = new Pager($a->query_string);
|
||||
|
||||
$r = Model\GContact::allFriends(local_user(), $cid, $pager->getStart(), $pager->getItemsPerPage());
|
||||
if (!DBA::isResult($r)) {
|
||||
|
@ -104,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' => $pager->renderFull(),
|
||||
'$paginate' => $pager->renderFull($total),
|
||||
]);
|
||||
|
||||
return $o;
|
||||
|
|
|
@ -82,44 +82,44 @@ function common_content(App $a)
|
|||
}
|
||||
|
||||
if ($cid) {
|
||||
$t = Model\GContact::countCommonFriends($uid, $cid);
|
||||
$total = Model\GContact::countCommonFriends($uid, $cid);
|
||||
} else {
|
||||
$t = Model\GContact::countCommonFriendsZcid($uid, $zcid);
|
||||
$total = Model\GContact::countCommonFriendsZcid($uid, $zcid);
|
||||
}
|
||||
|
||||
if ($t > 0) {
|
||||
$pager = new Pager($a->query_string, $t);
|
||||
} else {
|
||||
if ($total < 1) {
|
||||
notice(L10n::t('No contacts in common.') . EOL);
|
||||
return $o;
|
||||
}
|
||||
|
||||
$pager = new Pager($a->query_string);
|
||||
|
||||
if ($cid) {
|
||||
$r = Model\GContact::commonFriends($uid, $cid, $pager->getStart(), $pager->getItemsPerPage());
|
||||
$common_friends = Model\GContact::commonFriends($uid, $cid, $pager->getStart(), $pager->getItemsPerPage());
|
||||
} else {
|
||||
$r = Model\GContact::commonFriendsZcid($uid, $zcid, $pager->getStart(), $pager->getItemsPerPage());
|
||||
$common_friends = Model\GContact::commonFriendsZcid($uid, $zcid, $pager->getStart(), $pager->getItemsPerPage());
|
||||
}
|
||||
|
||||
if (!DBA::isResult($r)) {
|
||||
if (!DBA::isResult($common_friends)) {
|
||||
return $o;
|
||||
}
|
||||
|
||||
$id = 0;
|
||||
|
||||
$entries = [];
|
||||
foreach ($r as $rr) {
|
||||
foreach ($common_friends as $common_friend) {
|
||||
//get further details of the contact
|
||||
$contact_details = Model\Contact::getDetailsByURL($rr['url'], $uid);
|
||||
$contact_details = Model\Contact::getDetailsByURL($common_friend['url'], $uid);
|
||||
|
||||
// $rr['id'] is needed to use contact_photo_menu()
|
||||
/// @TODO Adding '/" here avoids E_NOTICE on missing constants
|
||||
$rr['id'] = $rr['cid'];
|
||||
$common_friend['id'] = $common_friend['cid'];
|
||||
|
||||
$photo_menu = Model\Contact::photoMenu($rr);
|
||||
$photo_menu = Model\Contact::photoMenu($common_friend);
|
||||
|
||||
$entry = [
|
||||
'url' => $rr['url'],
|
||||
'itemurl' => defaults($contact_details, 'addr', $rr['url']),
|
||||
'url' => $common_friend['url'],
|
||||
'itemurl' => defaults($contact_details, 'addr', $common_friend['url']),
|
||||
'name' => $contact_details['name'],
|
||||
'thumb' => ProxyUtils::proxifyUrl($contact_details['thumb'], false, ProxyUtils::SIZE_THUMB),
|
||||
'img_hover' => htmlentities($contact_details['name']),
|
||||
|
@ -148,7 +148,7 @@ function common_content(App $a)
|
|||
'$title' => $title,
|
||||
'$tab_str' => $tab_str,
|
||||
'$contacts' => $entries,
|
||||
'$paginate' => $pager->renderFull(),
|
||||
'$paginate' => $pager->renderFull($total),
|
||||
]);
|
||||
|
||||
return $o;
|
||||
|
|
|
@ -89,7 +89,7 @@ function directory_content(App $a)
|
|||
if (DBA::isResult($cnt)) {
|
||||
$total = $cnt['total'];
|
||||
}
|
||||
$pager = new Pager($a->query_string, $total, 60);
|
||||
$pager = new Pager($a->query_string, 60);
|
||||
|
||||
$order = " ORDER BY `name` ASC ";
|
||||
|
||||
|
@ -213,7 +213,7 @@ function directory_content(App $a)
|
|||
'$findterm' => (strlen($search) ? $search : ""),
|
||||
'$title' => L10n::t('Site Directory'),
|
||||
'$submit' => L10n::t('Find'),
|
||||
'$paginate' => $pager->renderFull(),
|
||||
'$paginate' => $pager->renderFull($total),
|
||||
]);
|
||||
} else {
|
||||
info(L10n::t("No entries \x28some entries may be hidden\x29.") . EOL);
|
||||
|
|
|
@ -188,7 +188,7 @@ function dirfind_content(App $a, $prefix = "") {
|
|||
}
|
||||
|
||||
if (!empty($j->results)) {
|
||||
$pager = new Pager($a->query_string, $j->total, $j->items_page);
|
||||
$pager = new Pager($a->query_string, $j->items_page);
|
||||
|
||||
$id = 0;
|
||||
|
||||
|
@ -254,7 +254,7 @@ function dirfind_content(App $a, $prefix = "") {
|
|||
$o .= replace_macros($tpl,[
|
||||
'title' => $header,
|
||||
'$contacts' => $entries,
|
||||
'$paginate' => $pager->renderFull(),
|
||||
'$paginate' => $pager->renderFull($j->total),
|
||||
]);
|
||||
|
||||
} else {
|
||||
|
|
|
@ -54,6 +54,8 @@ function match_content(App $a)
|
|||
$tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']);
|
||||
|
||||
if ($tags) {
|
||||
$pager = new Pager($a->query_string, $j->items_page);
|
||||
|
||||
$params['s'] = $tags;
|
||||
if ($pager->getPage() != 1) {
|
||||
$params['p'] = $pager->getPage();
|
||||
|
@ -68,8 +70,6 @@ function match_content(App $a)
|
|||
$j = json_decode($x);
|
||||
|
||||
if (count($j->results)) {
|
||||
$pager = new Pager($a->query_string, $j->total, $j->items_page);
|
||||
|
||||
$id = 0;
|
||||
|
||||
foreach ($j->results as $jj) {
|
||||
|
@ -112,13 +112,11 @@ function match_content(App $a)
|
|||
|
||||
$tpl = get_markup_template('viewcontact_template.tpl');
|
||||
|
||||
$o .= replace_macros(
|
||||
$tpl,
|
||||
[
|
||||
'$title' => L10n::t('Profile Match'),
|
||||
$o .= replace_macros($tpl, [
|
||||
'$title' => L10n::t('Profile Match'),
|
||||
'$contacts' => $entries,
|
||||
'$paginate' => $pager->renderFull()]
|
||||
);
|
||||
'$paginate' => $pager->renderFull($j->total)
|
||||
]);
|
||||
} else {
|
||||
info(L10n::t('No matches') . EOL);
|
||||
}
|
||||
|
|
|
@ -283,7 +283,7 @@ function message_content(App $a)
|
|||
$total = $r[0]['total'];
|
||||
}
|
||||
|
||||
$pager = new Pager($a->query_string, $total);
|
||||
$pager = new Pager($a->query_string);
|
||||
|
||||
$r = get_messages(local_user(), $pager->getStart(), $pager->getItemsPerPage());
|
||||
|
||||
|
@ -294,7 +294,7 @@ function message_content(App $a)
|
|||
|
||||
$o .= render_messages($r, 'mail_list.tpl');
|
||||
|
||||
$o .= $pager->renderFull();
|
||||
$o .= $pager->renderFull($total);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
|
|
@ -1146,7 +1146,7 @@ function photos_content(App $a)
|
|||
$total = count($r);
|
||||
}
|
||||
|
||||
$pager = new Pager($a->query_string, $total, 20);
|
||||
$pager = new Pager($a->query_string, 20);
|
||||
|
||||
/// @TODO I have seen this many times, maybe generalize it script-wide and encapsulate it?
|
||||
$order_field = defaults($_GET, 'order', '');
|
||||
|
@ -1227,14 +1227,14 @@ function photos_content(App $a)
|
|||
|
||||
$tpl = get_markup_template('photo_album.tpl');
|
||||
$o .= replace_macros($tpl, [
|
||||
'$photos' => $photos,
|
||||
'$album' => $album,
|
||||
'$can_post' => $can_post,
|
||||
'$upload' => [L10n::t('Upload New Photos'), 'photos/' . $a->data['user']['nickname'] . '/upload/' . bin2hex($album)],
|
||||
'$order' => $order,
|
||||
'$edit' => $edit,
|
||||
'$paginate' => $pager->renderFull(),
|
||||
]);
|
||||
'$photos' => $photos,
|
||||
'$album' => $album,
|
||||
'$can_post' => $can_post,
|
||||
'$upload' => [L10n::t('Upload New Photos'), 'photos/' . $a->data['user']['nickname'] . '/upload/' . bin2hex($album)],
|
||||
'$order' => $order,
|
||||
'$edit' => $edit,
|
||||
'$paginate' => $pager->renderFull($total),
|
||||
]);
|
||||
|
||||
return $o;
|
||||
|
||||
|
@ -1388,13 +1388,16 @@ function photos_content(App $a)
|
|||
|
||||
$map = null;
|
||||
$link_item = [];
|
||||
$total = 0;
|
||||
|
||||
if (DBA::isResult($linked_items)) {
|
||||
// This is a workaround to not being forced to rewrite the while $sql_extra handling
|
||||
$link_item = Item::selectFirst([], ['id' => $linked_items[0]['id']]);
|
||||
|
||||
$condition = ["`parent` = ? AND `parent` != `id`", $link_item['parent']];
|
||||
$pager = new Pager($a->query_string, DBA::count('item', $condition));
|
||||
$total = DBA::count('item', $condition);
|
||||
|
||||
$pager = new Pager($a->query_string);
|
||||
|
||||
$params = ['order' => ['id'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
|
||||
$result = Item::selectForUser($link_item['uid'], Item::ITEM_FIELDLIST, $condition, $params);
|
||||
|
@ -1611,7 +1614,7 @@ function photos_content(App $a)
|
|||
}
|
||||
$responses = get_responses($conv_responses, $response_verbs, '', $link_item);
|
||||
|
||||
$paginate = $pager->renderFull();
|
||||
$paginate = $pager->renderFull($total);
|
||||
}
|
||||
|
||||
$photo_tpl = get_markup_template('photo_view.tpl');
|
||||
|
@ -1647,18 +1650,19 @@ function photos_content(App $a)
|
|||
|
||||
// Default - show recent photos with upload link (if applicable)
|
||||
//$o = '';
|
||||
|
||||
$total = 0;
|
||||
$r = q("SELECT `resource-id`, max(`scale`) AS `scale` FROM `photo` WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s'
|
||||
$sql_extra GROUP BY `resource-id`",
|
||||
intval($a->data['user']['uid']),
|
||||
DBA::escape('Contact Photos'),
|
||||
DBA::escape(L10n::t('Contact Photos'))
|
||||
);
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
$pager = new Pager($a->query_string, count($r), 20);
|
||||
$total = count($r);
|
||||
}
|
||||
|
||||
$pager = new Pager($a->query_string, 20);
|
||||
|
||||
$r = q("SELECT `resource-id`, ANY_VALUE(`id`) AS `id`, ANY_VALUE(`filename`) AS `filename`,
|
||||
ANY_VALUE(`type`) AS `type`, ANY_VALUE(`album`) AS `album`, max(`scale`) AS `scale`,
|
||||
ANY_VALUE(`created`) AS `created` FROM `photo`
|
||||
|
@ -1711,7 +1715,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' => $pager->renderFull(),
|
||||
'$paginate' => $pager->renderFull($total),
|
||||
]);
|
||||
|
||||
return $o;
|
||||
|
|
|
@ -343,7 +343,8 @@ function videos_content(App $a)
|
|||
if (DBA::isResult($r)) {
|
||||
$total = count($r);
|
||||
}
|
||||
$pager = new Pager($a->query_string, $total, 20);
|
||||
|
||||
$pager = new Pager($a->query_string, 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`
|
||||
|
@ -389,7 +390,7 @@ function videos_content(App $a)
|
|||
'$delete_url' => (($can_post) ? System::baseUrl() . '/videos/' . $a->data['user']['nickname'] : false)
|
||||
]);
|
||||
|
||||
$o .= $pager->renderFull();
|
||||
$o .= $pager->renderFull($total);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ function viewcontacts_content(App $a)
|
|||
if (DBA::isResult($r)) {
|
||||
$total = $r[0]['total'];
|
||||
}
|
||||
$pager = new Pager($a->query_string, $total);
|
||||
$pager = new Pager($a->query_string);
|
||||
|
||||
$r = q("SELECT * FROM `contact`
|
||||
WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
|
||||
|
@ -128,7 +128,7 @@ function viewcontacts_content(App $a)
|
|||
$o .= replace_macros($tpl, [
|
||||
'$title' => L10n::t('Contacts'),
|
||||
'$contacts' => $contacts,
|
||||
'$paginate' => $pager->renderFull(),
|
||||
'$paginate' => $pager->renderFull($total),
|
||||
]);
|
||||
|
||||
return $o;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue