Commit d5ba82ed authored by Tino Goratsch's avatar Tino Goratsch

refs #8

- adjusted the usages of the pagination to use the new ResultsPerPage::getResultsPerPage() method
parent 41a1540d
......@@ -87,50 +87,68 @@ class Pagination
/**
* @param int $results
* @return $this
*/
public function setResultsPerPage($results)
{
$this->resultsPerPage = (int)$results;
return $this;
}
/**
* @param int $results
* @return $this
*/
public function setTotalResults($results)
{
$this->totalResults = (int)$results;
return $this;
}
/**
* @param string $fragment
* @return $this
*/
public function setUrlFragment($fragment)
{
$this->urlFragment = $fragment;
return $this;
}
/**
* @param int $pagesToDisplay
* @return $this
*/
public function setPagesToDisplay($pagesToDisplay)
{
$this->pagesToDisplay = (int)$pagesToDisplay;
return $this;
}
/**
* @param int $showFirstLast
* @return $this
*/
public function setShowFirstLast($showFirstLast)
{
$this->showFirstLast = (int)$showFirstLast;
return $this;
}
/**
* @param int $showPreviousNext
* @return $this
*/
public function setShowPreviousNext($showPreviousNext)
{
$this->showPreviousNext = (int)$showPreviousNext;
return $this;
}
/**
......
......@@ -59,14 +59,17 @@ class Index extends Core\Controller\AbstractFrontendAction
{
$this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
$resultsPerPage = $this->resultsPerPage->getResultsPerPage(Articles\Installer\Schema::MODULE_NAME);
$time = $this->date->getCurrentDateTime();
$this->pagination
->setResultsPerPage($resultsPerPage)
->setTotalResults($this->articleRepository->countAll($time));
$articles = $this->articleRepository->getAll(
$time,
$this->pagination->getResultsStartOffset(),
$this->resultsPerPage->getResultsPerPage(Articles\Installer\Schema::MODULE_NAME)
$resultsPerPage
);
$this->pagination->setTotalResults($this->articleRepository->countAll($time));
return [
'articles' => $articles,
'pagination' => $this->pagination->render()
......
......@@ -52,35 +52,34 @@ class Index extends AbstractFrontendAction
{
$this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
$resultsPerPage = $this->resultsPerPage->getResultsPerPage(Comments\Installer\Schema::MODULE_NAME);
$this->pagination
->setResultsPerPage($resultsPerPage)
->setTotalResults(
$this->commentRepository->countAllByModule($this->modules->getModuleId($module), $entryId)
);
$comments = $this->commentRepository->getAllByModule(
$this->modules->getModuleId($module),
$entryId,
$this->pagination->getResultsStartOffset(),
$this->resultsPerPage->getResultsPerPage(Comments\Installer\Schema::MODULE_NAME)
$resultsPerPage
);
$cComments = count($comments);
if ($cComments > 0) {
$this->pagination->setTotalResults(
$this->commentRepository->countAllByModule($this->modules->getModuleId($module), $entryId)
);
for ($i = 0; $i < $cComments; ++$i) {
if (empty($comments[$i]['name'])) {
$comments[$i]['name'] = $this->translator->t('users', 'deleted_user');
}
if ($this->emoticonsActive === true && $this->emoticonsHelpers) {
$comments[$i]['message'] = $this->emoticonsHelpers->emoticonsReplace($comments[$i]['message']);
}
for ($i = 0; $i < $cComments; ++$i) {
if (empty($comments[$i]['name'])) {
$comments[$i]['name'] = $this->translator->t('users', 'deleted_user');
}
if ($this->emoticonsActive === true && $this->emoticonsHelpers) {
$comments[$i]['message'] = $this->emoticonsHelpers->emoticonsReplace($comments[$i]['message']);
}
return [
'comments' => $comments,
'dateformat' => $this->commentsSettings['dateformat'],
'pagination' => $this->pagination->render()
];
}
return [];
return [
'comments' => $comments,
'dateformat' => $this->commentsSettings['dateformat'],
'pagination' => $this->pagination->render()
];
}
}
<section>
<h3 class="text-center">{lang t="comments|comments"}</h3>
{redirect_message}
{if isset($comments)}
{if !empty($comments)}
{include file="asset:System/Partials/pagination.tpl" pagination=$pagination}
{foreach $comments as $row}
<article class="dataset-box dataset-box__comments">
......
......@@ -59,15 +59,17 @@ class Index extends AbstractAction
{
$this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
$resultsPerPage = $this->resultsPerPage->getResultsPerPage(Gallery\Installer\Schema::MODULE_NAME);
$time = $this->date->getCurrentDateTime();
$this->pagination->setTotalResults($this->galleryRepository->countAll($time));
$this->pagination
->setResultsPerPage($resultsPerPage)
->setTotalResults($this->galleryRepository->countAll($time));
return [
'galleries' => $this->galleryRepository->getAll(
$time,
$this->pagination->getResultsStartOffset(),
$this->resultsPerPage->getResultsPerPage(Gallery\Installer\Schema::MODULE_NAME)
$resultsPerPage
),
'dateformat' => $this->settings['dateformat'],
'pagination' => $this->pagination->render()
......
......@@ -30,8 +30,8 @@ class Index extends AbstractAction
/**
* Index constructor.
*
* @param \ACP3\Core\Controller\Context\FrontendContext $context
* @param \ACP3\Core\Pagination $pagination
* @param \ACP3\Core\Controller\Context\FrontendContext $context
* @param \ACP3\Core\Pagination $pagination
* @param \ACP3\Modules\ACP3\Guestbook\Model\Repository\GuestbookRepository $guestbookRepository
*/
public function __construct(
......@@ -52,20 +52,21 @@ class Index extends AbstractAction
{
$this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
$resultsPerPage = $this->resultsPerPage->getResultsPerPage(Guestbook\Installer\Schema::MODULE_NAME);
$this->pagination
->setResultsPerPage($resultsPerPage)
->setTotalResults($this->guestbookRepository->countAll($this->guestbookSettings['notify']));
$guestbook = $this->guestbookRepository->getAll(
$this->guestbookSettings['notify'],
$this->pagination->getResultsStartOffset(),
$this->resultsPerPage->getResultsPerPage(Guestbook\Installer\Schema::MODULE_NAME)
$resultsPerPage
);
$cGuestbook = count($guestbook);
if ($cGuestbook > 0) {
$this->pagination->setTotalResults($this->guestbookRepository->countAll($this->guestbookSettings['notify']));
for ($i = 0; $i < $cGuestbook; ++$i) {
if ($this->guestbookSettings['emoticons'] == 1 && $this->emoticonsHelpers) {
$guestbook[$i]['message'] = $this->emoticonsHelpers->emoticonsReplace($guestbook[$i]['message']);
}
for ($i = 0; $i < $cGuestbook; ++$i) {
if ($this->guestbookSettings['emoticons'] == 1 && $this->emoticonsHelpers) {
$guestbook[$i]['message'] = $this->emoticonsHelpers->emoticonsReplace($guestbook[$i]['message']);
}
}
......
......@@ -52,12 +52,12 @@ class Index extends AbstractAction
/**
* Index constructor.
*
* @param \ACP3\Core\Controller\Context\FrontendContext $context
* @param \ACP3\Core\Date $date
* @param \ACP3\Core\Helpers\StringFormatter $stringFormatter
* @param \ACP3\Core\Pagination $pagination
* @param \ACP3\Modules\ACP3\News\Model\Repository\NewsRepository $newsRepository
* @param \ACP3\Modules\ACP3\Categories\Helpers $categoriesHelpers
* @param \ACP3\Core\Controller\Context\FrontendContext $context
* @param \ACP3\Core\Date $date
* @param \ACP3\Core\Helpers\StringFormatter $stringFormatter
* @param \ACP3\Core\Pagination $pagination
* @param \ACP3\Modules\ACP3\News\Model\Repository\NewsRepository $newsRepository
* @param \ACP3\Modules\ACP3\Categories\Helpers $categoriesHelpers
* @param \ACP3\Modules\ACP3\Categories\Model\Repository\CategoryRepository $categoryRepository
*/
public function __construct(
......@@ -99,23 +99,23 @@ class Index extends AbstractAction
$this->addBreadcrumbStep($cat);
$time = $this->date->getCurrentDateTime();
$this->pagination
->setResultsPerPage($this->resultsPerPage->getResultsPerPage(News\Installer\Schema::MODULE_NAME))
->setTotalResults($this->newsRepository->countAll($time, $cat));
$news = $this->fetchNews($cat, $time);
$cNews = count($news);
if ($cNews > 0) {
$this->pagination->setTotalResults($this->newsRepository->countAll($time, $cat));
for ($i = 0; $i < $cNews; ++$i) {
$news[$i]['text'] = $this->view->fetchStringAsTemplate($news[$i]['text']);
if ($this->commentsActive === true && $news[$i]['comments'] == 1) {
$news[$i]['comments_count'] = $this->get('comments.helpers')->commentsCount(
News\Installer\Schema::MODULE_NAME,
$news[$i]['id']
);
}
if ($this->newsSettings['readmore'] == 1 && $news[$i]['readmore'] == 1) {
$news[$i]['text'] = $this->addReadMoreLink($news[$i]);
}
for ($i = 0; $i < $cNews; ++$i) {
$news[$i]['text'] = $this->view->fetchStringAsTemplate($news[$i]['text']);
if ($this->commentsActive === true && $news[$i]['comments'] == 1) {
$news[$i]['comments_count'] = $this->get('comments.helpers')->commentsCount(
News\Installer\Schema::MODULE_NAME,
$news[$i]['id']
);
}
if ($this->newsSettings['readmore'] == 1 && $news[$i]['readmore'] == 1) {
$news[$i]['text'] = $this->addReadMoreLink($news[$i]);
}
}
......@@ -128,7 +128,7 @@ class Index extends AbstractAction
}
/**
* @param int $categoryId
* @param int $categoryId
* @param string $time
*
* @return array
......
......@@ -50,13 +50,16 @@ class Index extends Core\Controller\AbstractFrontendAction
{
$this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
$this->pagination->setTotalResults($this->newsletterRepository->countAll(1));
$resultsPerPage = $this->resultsPerPage->getResultsPerPage(Newsletter\Installer\Schema::MODULE_NAME);
$this->pagination
->setResultsPerPage($resultsPerPage)
->setTotalResults($this->newsletterRepository->countAll(1));
return [
'newsletters' => $this->newsletterRepository->getAll(
Newsletter\Helper\AccountStatus::ACCOUNT_STATUS_CONFIRMED,
$this->pagination->getResultsStartOffset(),
$this->resultsPerPage->getResultsPerPage(Newsletter\Installer\Schema::MODULE_NAME)
$resultsPerPage
),
'pagination' => $this->pagination->render()
];
......
......@@ -52,13 +52,16 @@ class Index extends Core\Controller\AbstractFrontendAction
{
$this->setCacheResponseCacheable($this->config->getSettings(Schema::MODULE_NAME)['cache_lifetime']);
$resultsPerPage = $this->resultsPerPage->getResultsPerPage(Users\Installer\Schema::MODULE_NAME);
$allUsers = $this->userRepository->countAll();
$this->pagination
->setResultsPerPage($resultsPerPage)
->setTotalResults($allUsers);
$users = $this->userRepository->getAll(
$this->pagination->getResultsStartOffset(),
$this->resultsPerPage->getResultsPerPage(Users\Installer\Schema::MODULE_NAME)
$resultsPerPage
);
$allUsers = $this->userRepository->countAll();
$this->pagination->setTotalResults($allUsers);
return [
'users' => $users,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment