Get the offset for each page, optionally with a range

@return  array   Page number => offset
351992
protected function _offsets()
    {
        if ($display = $this->display) {
            $start  = (int) max($this->current - $display, 1);
            $start  = min($this->count, $start);
            $stop   = (int) min($this->current + $display, $this->count);
        } else { // show all pages
            $start = 1;
            $stop = $this->count;
        }

        $result = array();
        if ($start > 0) {
            foreach (range($start, $stop) as $pagenumber) {
                $result[$pagenumber] =  ($pagenumber-1) * $this->limit;
            }
        }

        return $result;
    }
999035
private function getRangeWidget()
    {
        if ('selection' === $this->get('rangemode')) {
            // Get all range options.
            $rangeOptions = [];

            foreach (StringUtil::deserialize($this->get('range_selection'), true) as $rangeItem) {
                $rangeOptions[$rangeItem['range']] = $rangeItem['range'] . 'km';
            }

            $rangeWidget = [
                'label'     => [
                    ($this->get('range_label') ?: $this->getAttributeName() . ' Range '),
                    'GET: ' . $this->getParamNameRange()
                ],
                'inputType' => 'select',
                'options'   => $rangeOptions,
                'eval'      => [
                    'colname'            => $this->getColname(),
                    'urlparam'           => $this->getParamNameRange(),
                    'template'           => $this->get('range_template')
                ]
            ];

            return $rangeWidget;
        }

        if ('free' === $this->get('rangemode')) {
            $rangeWidget = [
                'label'     => [
                    ($this->get('range_label') ?: $this->getAttributeName() . ' Range '),
                    'GET: ' . $this->getParamNameRange()
                ],
                'inputType' => 'text',
                'eval'      => [
                    'colname'     => $this->getColname(),
                    'urlparam'    => $this->getParamNameRange(),
                    'template'    => $this->get('range_template'),
                    'placeholder' => $this->get('range_placeholder')
                ]
            ];

            return $rangeWidget;
        }

        return null;
    }
57830
private function getSplitOffset()
    {
        $blocks = (int) $this->range->getLength() / $this->index->getKeyReader()->getReadLength();
        $centerBlock = (int) $blocks / 2;
        return $this->range->getOffset() + $centerBlock * $this->index->getKeyReader()->getReadLength();
    }
938322
public function getPrevPageUrl()
    {
        if ($this->pageOffset['end'] >= $this->getFilesize() - 1) {
            return false;
        }

        return [
            'file' => $this->file, 'offset' => $this->pageOffset['end']
        ];
    }
962555
protected function _pages()
    {
        $pages = new AnConfig();
        $current  = ($this->current - 1) * $this->limit;
        
        // First
        $page    = 1;
        $offset  = 0;
        $active  = $offset != $this->offset;
        
        $pages->first = array(
            'title' => 'First', 
            'page' => 1, 
            'offset' => $offset, 
            'limit' => $this->limit, 
            'current' => false, 
            'active' => $active, 
            'rel' => 'first'
        );
      
        // Previous
        $offset  = max(0, ($this->current - 2) * $this->limit);
        $active  = $offset != $this->offset;
        $pages->prev = array(
            'title' => 'Prev', 
            'page' => $this->current - 1, 
            'offset' => $offset, 
            'limit' => $this->limit, 
            'current' => false, 
            'active' => $active, 
            'rel' => 'prev'
        );

        // Pages
        $offsets = array();
        foreach ($this->_offsets() as $page => $offset) {
            $current = $offset == $this->offset;
            $offsets[] = array(
                'title' => $page, 
                'page' => $page, 
                'offset' => $offset, 
                'limit' => $this->limit, 
                'current' => $current, 
                'active' => !$current
            );
        }
        
        $pages->offsets = $offsets;
        
        // Next
        $offset = min(($this->count-1) * $this->limit, ($this->current) * $this->limit);
        $active = $offset != $this->offset;
        $pages->next = array(
            'title' => 'Next', 
            'page' => $this->current + 1, 
            'offset' => $offset, 
            'limit' => $this->limit, 
            'current' => false, 
            'active' => $active, 
            'rel' => 'next'
        );
       
        // Last
        $offset  = ($this->count - 1) * $this->limit;
        $active  = $offset != $this->offset;
        $pages->last = array(
            'title' => 'Last', 
            'page' => $this->count, 
            'offset' => $offset, 
            'limit' => $this->limit, 
            'current' => false, 
            'active' => $active, 
            'rel' => 'last'
        );
        
        return $pages;
    }
194292
public function getPages()
    {
        return (int)ceil((float)$this->provider->count() / (float)$this->pagelength);
    }
71855
private static int getPreviousPageOffset(final int offset, final int limit) {
        return hasFullPreviousPage(offset, limit) ? getPreviousFullPageOffset(offset, limit) : getFirstPageOffset();
    }
1362882
public function getPage($page = false)
    {
        $this->setCurrentPage($page);
        $offset = 0;
        if ($this->currentPage > 1) {
            $offset = min($this->itemsPerPage * ($this->currentPage - 1), 2147483647);
        }

        return $this->get($this->itemsPerPage, $offset);
    }
716190
function paging()
    {
        $this->num = $this->count();
        $offset = ($this->page - 1) * $this->page_size;
        if ($offset < 0)
        {
            $offset = 0;
        }
        if ($this->num % $this->page_size > 0)
        {
            $this->pages = intval($this->num / $this->page_size) + 1;
        }
        else
        {
            $this->pages = $this->num / $this->page_size;
        }
        $this->limit($offset . ',' . $this->page_size);
        $this->pager = new Pager(array('total'    => $this->num,
                                       'perpage'  => $this->page_size,
                                       'nowindex' => $this->page
        ));
    }
146419
public function calculate()
    {
        $this->calculatePageLimitAndOffset();
        $pageNumber = $this->getPageNumber();
        $offset = $this->getPaginationOffset();


        /* Setup page vars for display. */
        if ($pageNumber == 0) {
            $pageNumber = 1; //if no page var is given, default to 1.
        }
        $this->previous = $pageNumber - 1;
        $this->next = $pageNumber + 1;
        //last page is = total pages / items per page, rounded up.
        $this->lastPage = ceil($this->getTotalNumberOfPages() / $this->perPage);

        $this->lastPageMinusOne = $this->lastPage - 1;  //last page minus 1
        $this->create();
    }
704604
function getEnd() {
		$end = $this->getPageNum() * $this->limit;
		if ($end > $this->getTotal())
			return $this->getTotal();
		return $end;
	}
960538
protected function getOffset($arguments = null)
    {
        if (null === $arguments) {
            $arguments = $this->requestArguments;
        }

        $offset = 0;

        if (array_key_exists('start', $arguments)) {
            $offset = (int) $arguments['start'];
        } else {
            if (array_key_exists('page', $arguments)) {
                $offset = ((int) $arguments['page'] - 1) * $this->getCount();
            }
        }

        $this->setConfigurationValue('offset', $offset);

        return $offset;
    }
1016898
public static function getRangeAll()
    {
        $sheetObj = self::validSheetObj();
        
        return self::num2alpha(self::$_offsetCol+1). '1:'. $sheetObj->getHighestColumn(). $sheetObj->getHighestRow();
    }
40099
public function getPageNumbers(array $pages, $current)
    {
        $offset = $current * $this->step;
        return array_slice($pages, $offset, $this->step);
    }
1265625
private function calc()
    {
        $this->limitOffset = max((int)(($this->page - 1) * $this->count), 0);
        $this->limitEndOffset = $this->limitOffset + $this->count;
    }
466664
protected function getPaginationData()
	{
		// Choose page range ( window ) and set start/end page range.
		$this->setPageRange();

		// Set previous/next page number.
		$this->setPrevNumPage();
		$this->setNextNumPage();

		$pagination['template']		= $this->layout_template;
		$pagination['items_total'] 	= $this->getNumTotalResults();
		$pagination['item_start']		= ( ( $this->prev_num_page * $this->items_per_page ) + 1 );
		$pagination['item_end']		= ( $this->current_page_number * $this->items_per_page );
		$pagination['params']			= $this->params_template;
		if ( $pagination['item_end'] > $this->getNumTotalResults() )
		{
			$pagination['item_end'] = $this->getNumTotalResults();
		}
		$pagination['num_pages']		= $this->num_pages;
		$pagination['current_page']	= $this->current_page_number;

		// Links.
		for ( $i = $this->start_page_range; $i<= $this->end_page_range; $i++ )
		{
			$pagination['pages'][$i]['number']		= (int)$i;
		 	$pagination['pages'][$i]['is_current'] 	= ( $i == $this->current_page_number );

		 	$pagination['pages'][$i]['link'] 		= $this->url_base;
		 	if ( 1 != $i )
		 	{
		 		$pagination['pages'][$i]['link'] 	= $this->url_base . $this->separator_link_page . $i;
		 	}

		}

		if ( $this->prev_num_page > 0 )
		{
			$pagination['previous_page']['number'] 	= $this->prev_num_page;

			$pagination['previous_page']['link'] 		= $this->url_base;
			if ( 1 != $this->prev_num_page )
			{
				$pagination['previous_page']['link'] = $this->url_base . $this->separator_link_page . $this->prev_num_page;
			}
		}

		if ( $this->next_num_page > 0 )
		{
			$pagination['next_page']['number'] 		= $this->next_num_page;
			$pagination['next_page']['link'] 			= $this->url_base . $this->separator_link_page . $this->next_num_page;;
		}

		if ( 1 != $this->current_page_number )
		{
			$pagination['first_page']['number'] 		= 1;
			$pagination['first_page']['link'] 		= $this->url_base;
		}

		if ( $this->num_pages != $this->current_page_number )
		{
			$pagination['last_page']['number']	 	= $this->num_pages;
			$pagination['last_page']['link'] 			= $this->url_base . $this->separator_link_page . $this->num_pages;
		}

		$pagination['items_per_page'] 		= $this->items_per_page;
		$pagination['display_items_per_page'] = $this->display_items_per_page;

		return $pagination;
	}
887568
protected function getMinPage()
    {
        $minPageNumber = null;
        $minPage       = null;
        foreach ($this->pages as $page) {
            $pageNumber = $page->getPageNumber();
            if ($minPageNumber === null || $pageNumber < $minPageNumber) {
                $minPageNumber = $pageNumber;
                $minPage       = $page;
            }
        }
        return $minPage;
    }