<?php
namespace App\Mvc\View\Listing; class Simple extends GeneralAbstract { protected $recordsCountTotal = 0; protected $resultsPerPageList = [5, 10, 15, 20]; public function __construct(Array $records = []) { parent::__construct($records); $this->dataTemplate = 'listingTable.tpl'; $this->headerTemplate = \Theme::getInstance()->getPath().'templates/smartyExtends/content/list/table/simple/header.tpl'; $this->containerTemplate = \Theme::getInstance()->getPath().'templates/smartyExtends/content/list/table/simple/index.tpl'; $this->paginationTemplate = \Theme::getInstance()->getPath().'templates/smartyExtends/content/list/table/simple/pagination.tpl'; $this->footerTemplate = \Theme::getInstance()->getPath().'templates/smartyExtends/content/list/table/simple/footer.tpl'; } public function setRecordsCountTotal($totalRecordsCount) { $this->recordsCountTotal=$totalRecordsCount; } public function getRecordsCountTotal() { return $this->recordsCountTotal; } public function setResultsPerPageList(Array $rppl) { $this->resultsPerPageList=$rppl; } public function getResultsPerPageList() { return $this->resultsPerPageList; } public function renderPagination() { $pg = new \App\Mvc\View\Listing\Members\Pagination(); if (!$this->getResultsPerPage()) { \Log::getInstance()->error(sprintf('[%s:%s] Results per page is not set.', __METHOD__, __LINE__)); } $pg ->setCurrentPage($this->getCurrentPage()) ->setItemsPerPage($this->getResultsPerPage()) ->setTotalItems($this->getRecordsCountTotal()) ->setTotalItemsIsCached($this->getRecordsCountTotalIsCached()) ->setItemsPerPageList(array_combine($this->getResultsPerPageList(), $this->getResultsPerPageList())); $smarty = \Engine\Smarty\SmartyMultiton::getInstance(); $smarty->assign('pagination', $pg); $output = $this->smarty_renderTemplate($this->paginationTemplate); $smarty->clearAssign('pagination'); return $output; } public function renderJsonPagination() { $pg = new \App\Mvc\View\Listing\Members\Pagination(); $pg ->setCurrentPage($this->getCurrentPage()) ->setItemsPerPage($this->getResultsPerPage()) ->setTotalItems($this->getRecordsCountTotal()) ->setTotalItemsIsCached($this->getRecordsCountTotalIsCached()) ->setItemsPerPageList(array_combine($this->getResultsPerPageList(), $this->getResultsPerPageList())); $jsonMessages = new \stdClass(); $jsonMessages->currentPage = $this->getCurrentPage(); $jsonMessages->resultsPerPage = $this->getResultsPerPage(); $jsonMessages->totalResults = $this->getRecordsCountTotal(); $jsonMessages->totalResultsForDisplay = $pg->getTotalItemsForDisplay(); $jsonMessages->totalResultsIsCached = $this->getRecordsCountTotalIsCached(); return $jsonMessages; } } 