| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- namespace Meramo\Mrmbepages\Controller;
- use Meramo\Mrmbepages\Domain\Repository\ActivepageRepository;
- use Meramo\Mrmbepages\Controller\AbstractBackendController;
- use TYPO3\CMS\Backend\View\BackendTemplateView;
- use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
- use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
- use TYPO3\CMS\Core\Utility\GeneralUtility;
- /**
- * Dashboard controller class
- */
- class DashboardController extends AbstractBackendController
- {
- /**
- * Activepage repository
- *
- * @var Meramo\Mrmbepages\Domain\Repository\ActivepageRepository activepageRepository;
- */
- protected $activepageRepository;
- /**
- * Import Active repository by dependency injection
- *
- * @param ActivepageRepository $activepageRepository
- */
- public function injectBlogRepository(\Meramo\Mrmbepages\Domain\Repository\ActivepageRepository $activepageRepository): void
- {
- $this->activepageRepository = $activepageRepository;
- }
- /**
- * Initialize view
- *
- * @param ViewInterface
- */
- protected function initializeView(ViewInterface $view): void
- {
- if ($view instanceof BackendTemplateView) {
- /** @var BackendTemplateView $view */
- parent::initializeView($view);
- $this->generateMenu();
- }
- }
- /**
- * Initialize action
- */
- public function initializeAction(): void
- {
- $querySettings = $this->objectManager->get(Typo3QuerySettings::class);
- $querySettings->setRespectStoragePage(false);
- $querySettings->setIgnoreEnableFields(true);
- $this->activepageRepository->setDefaultQuerySettings($querySettings);
- }
- /**
- * Index action
- */
- public function indexAction()
- {
- $allActivepages = $this->activepageRepository->findActivePages();
- if(!$this->request->hasArgument('currentPage')) {
- $currentPage = 1;
- } else {
- $currentPage = $this->request->getArgument('currentPage');
- }
- $itemsPerPage = GeneralUtility::_GP('itemsPerPage') ?? 50;
-
- $paginations = $this->buildPagination($allActivepages, $itemsPerPage, $currentPage);
- //DebuggerUtility::var_dump($paginations);
-
- $pagination = [
- 'pages' => $paginations['paginatedData'],
- 'totalRecords' => $paginations['totalRecords'],
- 'totalPages' => $paginations['totalPages'],
- 'currentPage' => $paginations['currentPage'],
- 'previousPage' => $paginations['previousPage'],
- 'nextPage' => $paginations['nextPage'],
- 'firstPage' => $paginations['firstPage'],
- 'lastPage' => $paginations['lastPage'],
- 'pageRange' => range($paginations['firstPage'], $paginations['lastPage']),
- 'isFirstPage' => $paginations['isFirstPage'],
- 'isLastPage' => $paginations['isLastPage'],
- ];
- $this->view->assign('pagination', $pagination);
-
- }
- }
|