$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()]]);
'$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;
/* 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 = [
'$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;
}
$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)) {
//'$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;
}
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']),
'$title' => $title,
'$tab_str' => $tab_str,
'$contacts' => $entries,
- '$paginate' => $pager->renderFull(),
+ '$paginate' => $pager->renderFull($total),
]);
return $o;
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 ";
'$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);
}
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;
$o .= replace_macros($tpl,[
'title' => $header,
'$contacts' => $entries,
- '$paginate' => $pager->renderFull(),
+ '$paginate' => $pager->renderFull($j->total),
]);
} else {
$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();
$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) {
$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);
}
$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());
$o .= render_messages($r, 'mail_list.tpl');
- $o .= $pager->renderFull();
+ $o .= $pager->renderFull($total);
return $o;
}
$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', '');
$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;
$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);
}
$responses = get_responses($conv_responses, $response_verbs, '', $link_item);
- $paginate = $pager->renderFull();
+ $paginate = $pager->renderFull($total);
}
$photo_tpl = get_markup_template('photo_view.tpl');
// 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`
'$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;
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`
'$delete_url' => (($can_post) ? System::baseUrl() . '/videos/' . $a->data['user']['nickname'] : false)
]);
- $o .= $pager->renderFull();
+ $o .= $pager->renderFull($total);
return $o;
}
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`
$o .= replace_macros($tpl, [
'$title' => L10n::t('Contacts'),
'$contacts' => $contacts,
- '$paginate' => $pager->renderFull(),
+ '$paginate' => $pager->renderFull($total),
]);
return $o;
* @var integer
*/
private $itemsPerPage = 50;
- /**
- * @var integer
- */
- private $itemCount = 0;
/**
* @var string
* Guesses the page number from the GET parameter 'page'.
*
* @param string $queryString The query string of the current page
- * @param integer $itemCount The total item count (for the full mode) or null (for the minimal mode)
* @param integer $itemsPerPage An optional number of items per page to override the default value
*/
- public function __construct($queryString, $itemCount = null, $itemsPerPage = 50)
+ public function __construct($queryString, $itemsPerPage = 50)
{
$this->setQueryString($queryString);
$this->setItemsPerPage($itemsPerPage);
- $this->setItemCount(defaults($itemCount, $this->getItemsPerPage()));
$this->setPage(defaults($_GET, 'page', 1));
}
* Returns the base query string.
*
* Warning: this isn't the same value as passed to the constructor.
- * See setQueryString for the inventory of transformations
+ * See setQueryString() for the inventory of transformations
*
* @see setBaseQuery()
* @return string
$this->page = max(1, intval($page));
}
- /**
- * Sets the item count, 0 minimum.
- *
- * @param integer $itemCount
- */
- public function setItemCount($itemCount)
- {
- $this->itemCount = max(0, intval($itemCount));
- }
-
/**
* Sets the base query string from a full query string.
*
*/
public function renderMinimal($itemCount)
{
- $this->setItemCount($itemCount);
+ $displayedItemCount = max(0, intval($itemCount));
$data = [
'class' => 'pager',
'next' => [
'url' => $this->ensureQueryParameter($this->baseQueryString . '&page=' . ($this->getPage() + 1)),
'text' => L10n::t('older'),
- 'class' => 'next' . ($this->itemCount <= 0 ? ' disabled' : '')
+ 'class' => 'next' . ($displayedItemCount <= 0 ? ' disabled' : '')
]
];
*
* $html = $pager->renderFull();
*
+ * @param integer $itemCount The total number of items including those note displayed on the page
* @return string HTML string of the pager
*/
- public function renderFull()
+ public function renderFull($itemCount)
{
+ $totalItemCount = max(0, intval($itemCount));
+
$data = [];
$data['class'] = 'pagination';
- if ($this->itemCount > $this->getItemsPerPage()) {
+ if ($totalItemCount > $this->getItemsPerPage()) {
$data['first'] = [
'url' => $this->ensureQueryParameter($this->baseQueryString . '&page=1'),
'text' => L10n::t('first'),
'class' => $this->getPage() == 1 ? 'disabled' : ''
];
- $numpages = $this->itemCount / $this->getItemsPerPage();
+ $numpages = $totalItemCount / $this->getItemsPerPage();
$numstart = 1;
$numstop = $numpages;
}
}
- if (($this->itemCount % $this->getItemsPerPage()) != 0) {
+ if (($totalItemCount % $this->getItemsPerPage()) != 0) {
if ($i == $this->getPage()) {
$pages[$i] = [
'url' => '#',
if (DBA::isResult($r)) {
$total = $r[0]['total'];
}
- $pager = new Pager($a->query_string, $total);
+ $pager = new Pager($a->query_string);
$sql_extra3 = Widget::unavailableNetworks();
'contacts_batch_drop' => L10n::t('Delete'),
],
'$h_batch_actions' => L10n::t('Batch Actions'),
- '$paginate' => $pager->renderFull(),
+ '$paginate' => $pager->renderFull($total),
]);
return $o;