Example #1
0
File: Action.php Project: acp3/core
 /**
  * @return array
  */
 private function prepareRequestData()
 {
     $entries = [];
     if (is_array($this->request->getPost()->get('entries')) === true) {
         $entries = $this->request->getPost()->get('entries');
     } elseif ((bool) preg_match('/^((\\d+)\\|)*(\\d+)$/', $this->request->getParameters()->get('entries')) === true) {
         $entries = explode('|', $this->request->getParameters()->get('entries'));
     }
     return $entries;
 }
Example #2
0
 /**
  * @param bool         $customUris
  * @param array|string $page
  * @param int          $pageNumber
  * @param int          $currentIndex
  *
  * @return bool
  */
 protected function isCurrentPage($customUris, $page, $pageNumber, $currentIndex)
 {
     if ($customUris === true) {
         if (is_array($page) === true && $page['uri'] === $this->router->route($this->request->getQuery()) || $this->router->route($this->request->getQuery()) === $this->router->route($this->request->getFullPath()) && $currentIndex == 0) {
             return true;
         }
     } elseif ($this->integerValidationRule->isValid($this->request->getParameters()->get('page')) === false && $currentIndex === 0 || $this->request->getParameters()->get('page') === $pageNumber) {
         return true;
     }
     return false;
 }
Example #3
0
 /**
  * @return array
  */
 public function render()
 {
     if ($this->totalResults > $this->resultsPerPage) {
         $areaPrefix = $this->request->getArea() === AreaEnum::AREA_ADMIN ? 'acp/' : '';
         $link = $this->router->route($areaPrefix . $this->request->getUriWithoutPages());
         $this->currentPage = (int) $this->request->getParameters()->get('page', 1);
         $this->totalPages = (int) ceil($this->totalResults / $this->resultsPerPage);
         $this->setMetaStatements();
         $range = $this->calculateRange();
         $this->showFirstPageLink($link, $range);
         $this->showPreviousPageLink($link);
         for ($i = (int) $range['start']; $i <= $range['end']; ++$i) {
             $this->pagination[] = $this->buildPageNumber($i, $link . ($i > 1 ? 'page_' . $i . '/' : '') . $this->urlFragment, '', $this->currentPage === $i);
         }
         $this->showNextPageLink($link);
         $this->showLastPageLink($link, $range);
     }
     return $this->pagination;
 }
Example #4
0
 /**
  * @param array $pages
  *
  * @return int
  */
 private function getCurrentPage(array $pages)
 {
     $currentPage = (int) $this->request->getParameters()->get('page', 1);
     return $currentPage <= count($pages) ? $currentPage : 1;
 }