| Server IP : 85.158.181.41 / Your IP : 216.73.217.12 Web Server : Apache System : Linux cloud9-vm129 6.1.178+1-ph #ph SMP PREEMPT_DYNAMIC Wed Jul 29 09:00:54 UTC 2026 x86_64 User : moncbefd ( 1024) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/moncbefd/www.moneta.at/GXMainComponents/Shared/ |
Upload File : |
<?php
/* --------------------------------------------------------------
ExtendedInformationPager.inc.php 2019-01-11
Gambio GmbH
http://www.gambio.de
Copyright (c) 2019 Gambio GmbH
Released under the GNU General Public License (Version 2)
[http://www.gnu.org/licenses/gpl-2.0.html]
--------------------------------------------------------------
*/
/**
* ExtendedInformationPager
*/
class ExtendedInformationPager extends Pager
{
/**
* @var int
*/
protected $totalItemCount;
/**
* @var string
*/
protected $pageParameter;
/**
* ExtendedInformationPager constructor.
*
* @param IntType $page
* @param IntType $perPage
* @param IntType $totalItemCount
* @param StringType $pageParameter
*/
public function __construct(IntType $page, IntType $perPage, IntType $totalItemCount, StringType $pageParameter)
{
parent::__construct($page, $perPage);
$this->totalItemCount = $totalItemCount->asInt();
$this->pageParameter = $pageParameter->asString();
$this->page = $page->asInt() < 1 ? 1 : min($page->asInt(), $this->totalPageCount());
$this->offset = $this->page <= 1 ? 0 : ($this->page - 1) * $this->perPage;
}
/**
* Named constructor of extended information pager.
*
* @param int $page Current page.
* @param int $perPage Items per page.
* @param int $totalItemCount Total number of items.
* @param string $pageParameter The name of the page parameter
*
* @return ExtendedInformationPager New instance.
*
* @throws InvalidArgumentException
*/
public static function createExtendedInformationPager($page, $perPage, $totalItemCount, $pageParameter)
{
return MainFactory::create(static::class,
new IntType($page),
new IntType($perPage),
new IntType($totalItemCount),
new StringType($pageParameter));
}
/**
* Gets the lowest item of the current page.
*
* @return int
*/
public function lowestOnPage()
{
return ($this->page - 1) * $this->perPage + 1;
}
/**
* Gets the highest item of the current page.
*
* @return int
*/
public function highestOnPage()
{
return (int)min($this->page * $this->perPage, $this->totalItemCount);
}
/**
* Gets the total number of pages.
*
* @return int
*/
public function totalPageCount()
{
return (int)ceil($this->totalItemCount / $this->perPage);
}
/**
* Gets the total number of items.
*
* @return int
*/
public function totalItemCount()
{
return $this->totalItemCount;
}
/**
* Returns true if the current page is the first page.
*
* @return bool
*/
public function isFirstPage()
{
return $this->page <= 1;
}
/**
* Returns true if the current page is the last page.
*
* @return bool
*/
public function isLastPage()
{
return $this->page >= $this->totalPageCount();
}
/**
* Gets the name of the page parameter.
*
* @return string
*/
public function pageParameter()
{
return $this->pageParameter;
}
}