mirror of
https://github.com/friendica/friendica
synced 2025-04-24 23:50:20 +00:00
Add L10n parameter to Pager classes
This commit is contained in:
parent
682fb7e4e2
commit
561472b975
20 changed files with 53 additions and 52 deletions
|
@ -21,8 +21,8 @@
|
|||
|
||||
namespace Friendica\Content;
|
||||
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Util\Strings;
|
||||
|
||||
/**
|
||||
|
@ -30,30 +30,29 @@ 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);
|
||||
|
@ -166,12 +165,12 @@ class Pager
|
|||
'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' : '')
|
||||
]
|
||||
];
|
||||
|
@ -211,12 +210,12 @@ class Pager
|
|||
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' : ''
|
||||
];
|
||||
|
||||
|
@ -271,12 +270,12 @@ class Pager
|
|||
|
||||
$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' : ''
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue