return $o;
}
- $pager = new Pager(DI::args()->getQueryString());
+ $pager = new Pager(DI::l10n(), DI::args()->getQueryString());
if ($cid) {
$common_friends = Model\GContact::commonFriends($uid, $cid, $pager->getStart(), $pager->getItemsPerPage());
$total = $r[0]['total'];
}
- $pager = new Pager(DI::args()->getQueryString());
+ $pager = new Pager(DI::l10n(), DI::args()->getQueryString());
$r = get_messages(local_user(), $pager->getStart(), $pager->getItemsPerPage());
}
}
- $pager = new Pager(DI::args()->getQueryString());
+ $pager = new Pager(DI::l10n(), DI::args()->getQueryString());
networkPager($a, $pager, $update);
$sql_range = '';
}
- $pager = new Pager(DI::args()->getQueryString());
+ $pager = new Pager(DI::l10n(), DI::args()->getQueryString());
$pager_sql = networkPager($a, $pager, $update);
$condition = ['uid' => local_user(), 'post-type' => Item::PT_PERSONAL_NOTE, 'gravity' => GRAVITY_PARENT,
'contact-id'=> $a->contact['id']];
- $pager = new Pager(DI::args()->getQueryString(), 40);
+ $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 40);
$params = ['order' => ['created' => true],
'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
$total = count($r);
}
- $pager = new Pager(DI::args()->getQueryString(), 20);
+ $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 20);
/// @TODO I have seen this many times, maybe generalize it script-wide and encapsulate it?
$order_field = $_GET['order'] ?? '';
$condition = ["`parent` = ? AND `parent` != `id`", $link_item['parent']];
$total = DBA::count('item', $condition);
- $pager = new Pager(DI::args()->getQueryString());
+ $pager = new Pager(DI::l10n(), DI::args()->getQueryString());
$params = ['order' => ['id'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
$result = Item::selectForUser($link_item['uid'], Item::ITEM_FIELDLIST, $condition, $params);
$total = count($r);
}
- $pager = new Pager(DI::args()->getQueryString(), 20);
+ $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 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`,
$total = count($r);
}
- $pager = new Pager(DI::args()->getQueryString(), 20);
+ $pager = new Pager(DI::l10n(), DI::args()->getQueryString(), 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`
namespace Friendica\Content;
+use Friendica\Core\L10n;
use Friendica\Core\Renderer;
-use Friendica\DI;
use Friendica\Util\Network;
use Friendica\Util\Strings;
/**
- * This pager should be used by lists using the since_id/max_id parameters
+ * This pager should be used by lists using the since_id†/max_id† parameters
*
- * In this context, "id" refers to the value of the column that the list is ordered by.
- * This pager automatically identifies if the sorting is done increasingly or decreasingly if the first item id
- * and last item id are different. Otherwise it defaults to decreasingly like reverse chronological lists.
+ * This pager automatically identifies if the sorting is done increasingly or decreasingly if the first item id†
+ * and last item id† are different. Otherwise it defaults to decreasingly like reverse chronological lists.
+ *
+ * † In this context, "id" refers to the value of the column that the item list is ordered by.
*/
class BoundariesPager extends Pager
{
/**
* Instantiates a new Pager with the base parameters.
*
+ * @param L10n $l10n
* @param string $queryString The query string of the current page
- * @param string $first_item_id The i
- * @param string $last_item_id
- * @param integer $itemsPerPage An optional number of items per page to override the default value
+ * @param string $first_item_id The id† of the first item in the displayed item list
+ * @param string $last_item_id The id† of the last item in the displayed item list
+ * @param integer $itemsPerPage An optional number of items per page to override the default value
*/
- public function __construct($queryString, $first_item_id = null, $last_item_id = null, $itemsPerPage = 50)
+ public function __construct(L10n $l10n, $queryString, $first_item_id = null, $last_item_id = null, $itemsPerPage = 50)
{
- parent::__construct($queryString, $itemsPerPage);
+ parent::__construct($l10n, $queryString, $itemsPerPage);
$this->first_item_id = $first_item_id;
$this->last_item_id = $last_item_id;
($this->first_item_id >= $this->last_item_id ?
'&since_id=' . $this->first_item_id : '&max_id=' . $this->first_item_id)
),
- 'text' => DI::l10n()->t('newer'),
+ 'text' => $this->l10n->t('newer'),
'class' => 'previous' . ($this->first_page ? ' disabled' : '')
],
'next' => [
($this->first_item_id >= $this->last_item_id ?
'&max_id=' . $this->last_item_id : '&since_id=' . $this->last_item_id)
),
- 'text' => DI::l10n()->t('older'),
+ 'text' => $this->l10n->t('older'),
'class' => 'next' . ($displayedItemCount < $this->getItemsPerPage() ? ' disabled' : '')
]
];
namespace Friendica\Content;
+use Friendica\Core\L10n;
use Friendica\Core\Renderer;
-use Friendica\DI;
use Friendica\Util\Strings;
/**
*/
class Pager
{
- /**
- * @var integer
- */
+ /** @var integer */
private $page = 1;
- /**
- * @var integer
- */
+ /** @var integer */
protected $itemsPerPage = 50;
-
- /**
- * @var string
- */
+ /** @var string */
protected $baseQueryString = '';
+ /** @var L10n */
+ protected $l10n;
+
/**
* Instantiates a new Pager with the base parameters.
*
* Guesses the page number from the GET parameter 'page'.
*
+ * @param L10n $l10n
* @param string $queryString The query string of the current page
* @param integer $itemsPerPage An optional number of items per page to override the default value
*/
- public function __construct($queryString, $itemsPerPage = 50)
+ public function __construct(L10n $l10n, $queryString, $itemsPerPage = 50)
{
+ $this->l10n = $l10n;
+
$this->setQueryString($queryString);
$this->setItemsPerPage($itemsPerPage);
$this->setPage(($_GET['page'] ?? 0) ?: 1);
'class' => 'pager',
'prev' => [
'url' => Strings::ensureQueryParameter($this->baseQueryString . '&page=' . ($this->getPage() - 1)),
- 'text' => DI::l10n()->t('newer'),
+ 'text' => $this->l10n->t('newer'),
'class' => 'previous' . ($this->getPage() == 1 ? ' disabled' : '')
],
'next' => [
'url' => Strings::ensureQueryParameter($this->baseQueryString . '&page=' . ($this->getPage() + 1)),
- 'text' => DI::l10n()->t('older'),
+ 'text' => $this->l10n->t('older'),
'class' => 'next' . ($displayedItemCount < $this->getItemsPerPage() ? ' disabled' : '')
]
];
if ($totalItemCount > $this->getItemsPerPage()) {
$data['first'] = [
'url' => Strings::ensureQueryParameter($this->baseQueryString . '&page=1'),
- 'text' => DI::l10n()->t('first'),
+ 'text' => $this->l10n->t('first'),
'class' => $this->getPage() == 1 ? 'disabled' : ''
];
$data['prev'] = [
'url' => Strings::ensureQueryParameter($this->baseQueryString . '&page=' . ($this->getPage() - 1)),
- 'text' => DI::l10n()->t('prev'),
+ 'text' => $this->l10n->t('prev'),
'class' => $this->getPage() == 1 ? 'disabled' : ''
];
$data['next'] = [
'url' => Strings::ensureQueryParameter($this->baseQueryString . '&page=' . ($this->getPage() + 1)),
- 'text' => DI::l10n()->t('next'),
+ 'text' => $this->l10n->t('next'),
'class' => $this->getPage() == $lastpage ? 'disabled' : ''
];
$data['last'] = [
'url' => Strings::ensureQueryParameter($this->baseQueryString . '&page=' . $lastpage),
- 'text' => DI::l10n()->t('last'),
+ 'text' => $this->l10n->t('last'),
'class' => $this->getPage() == $lastpage ? 'disabled' : ''
];
}
$cid, GRAVITY_PARENT, GRAVITY_COMMENT, local_user()];
}
- $pager = new Pager(DI::args()->getQueryString());
+ $pager = new Pager(DI::l10n(), DI::args()->getQueryString());
$params = ['order' => ['received' => true],
'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
$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()]]);
/* 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 = [
$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)) {
}
// 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 = [
$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, [
$header = DI::l10n()->t('Forum Search - %s', $search);
}
- $args = DI::args();
- $pager = new Pager($args->getQueryString());
+ $pager = new Pager(DI::l10n(), DI::args()->getQueryString());
if ($localSearch && empty($results)) {
$pager->setItemsPerPage(80);
}
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();
$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'],
$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);
$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()]];
$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());
// 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());
+ $pager = new Pager(DI::l10n(), DI::args()->getQueryString());
if ($tag) {
Logger::info('Start tag search.', ['q' => $search]);