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
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue