Returns a OffsetBasedPagination class in order to be used for offset-based pagination.

The OffsetBasedPagination class stores the value of the "page[offset]" and "page[limit]" query parameters
if present or the $defaultOffset and $defaultLimit otherwise.
347958
public function createOffsetBasedPagination(int $defaultOffset = 0, int $defaultLimit = 0): OffsetBasedPagination
    {
        return OffsetBasedPagination::fromPaginationQueryParams($this->request->getPagination(), $defaultOffset, $defaultLimit);
    }
495173
public function getOffset(string $resourceClass = null, string $operationName = null, array $context = []): int
    {
        $graphql = $context['graphql'] ?? false;

        $limit = $this->getLimit($resourceClass, $operationName, $context);

        if ($graphql && null !== ($after = $this->getParameterFromContext($context, 'after'))) {
            return false === ($after = base64_decode($after, true)) ? 0 : (int) $after + 1;
        }

        if ($graphql && null !== ($before = $this->getParameterFromContext($context, 'before'))) {
            return ($offset = (false === ($before = base64_decode($before, true)) ? 0 : (int) $before - $limit)) < 0 ? 0 : $offset;
        }

        if ($graphql && null !== ($last = $this->getParameterFromContext($context, 'last'))) {
            return ($offset = ($context['count'] ?? 0) - $last) < 0 ? 0 : $offset;
        }

        return ($this->getPage($context) - 1) * $limit;
    }
678999
protected function getPagingParameter($key, $default, EncodingParametersInterface $parameters = null)
    {
        $value = $default;
        if ($parameters !== null) {
            $paging = $parameters->getPaginationParameters();
            if (empty($paging) === false && array_key_exists($key, $paging) === true) {
                $tmp   = (int)$paging[$key];
                $value = $tmp < 0 || $tmp > static::MAX_PAGE_SIZE ? static::MAX_PAGE_SIZE : $tmp;
            }
        }

        return $value;
    }
351190
public function getPage()
	{
		return $this->offset > $this->limit ? floor($this->offset / $this->limit) : 1;
	}
1128224
public function getDefaultPerPage()
    {
        if (!in_array($this->defaultPerPage, $this->perPageList)) {
            $this->defaultPerPage = $this->perPageList[0];
        }

        return $this->defaultPerPage;
    }
900731
public function getOffset($perPage = null)
    {
        if ($perPage && ($offset = $this->getOffsetFromNumber($perPage))) {
            return $offset;
        }

        $offset = (int) $this->getPage('offset');

        if ($offset < 0) {
            throw new InvalidParameterException('page[offset] must be >=0', 2, null, 'page[offset]');
        }

        return $offset;
    }
108
public function getSqlPaginateParams($pickedPage = false) {
        $p = new SqlPaginateParams();
        if ($pickedPage) {
            $this->pickedPage = $pickedPage;
        }
        if ($this->pages == 0) {
            $p->setOffset(0);
            $p->setLimit(20);
            return $p;
        }
        if ($this->pickedPage > $this->pages) {
            $this->pickedPage = $this->pages;
        }
        if ($this->pickedPage < 1) {
            $this->pickedPage = 1;
        }
        $p->setOffset($this->pickedPage * $this->elementsPerPage - $this->elementsPerPage);
        $p->setLimit($this->elementsPerPage);

        return $p;
    }
1002339
def paginate(self, request, offset=0, limit=None):
        """"""
        return self.collection.offset(offset).limit(limit), self.collection.count()
679177
@XmlElement(name = "lastPageLink")
    @JsonProperty(value = "lastPageLink")
    @ApiModelProperty(value = "The last pagination link.", position = 5)
    public PageRequestLinkDto getLastPageLink() {
        return lastPageLink;
    }
1253565
function pagination (schema, options) {
  options = options || {}

  // Options
  var defaultLimit = options.defaultLimit || 10
    , defaultQuery = options.defaultQuery || {}
    , defaultFields = options.defaultFields || {}
    , remember = options.remember || false
    , defaultPage = 1
    , currentLimit = defaultLimit
    , currentQuery = defaultQuery
    , currentFields = defaultFields

  // Main pagination method, can pass `query`, `page`, `limit`
  // and `fields` into the options to pass directly into the 
  // mongoose ORM, returns the standard `err` and `docs`, along with
  // the total object count, total pages, and current page
  schema.static('paginate', function (opt, fn) {
    if (!fn) { fn = opt; opt = {} }
    var self = this
      , query = opt.query || currentQuery
      , page = opt.page || defaultPage
      , limit = opt.limit || currentLimit
      , fields = opt.fields || currentFields

    if (remember) {
      opt.query && (currentQuery = opt.query)
      opt.limit && (currentLimit = opt.limit)
      opt.fields && (currentFields = opt.fields)
    }

    this.find(query, fields, {
      skip: (limit * (page - 1))
    , limit: limit
    }, function(err, docs) {
      if (err) return (fn && fn(err))
      self.count(query, function (err, count) {
        if (err) return (fn && fn(err))
        fn && fn(err, docs, count, Math.ceil(count / limit), page)
      })
    })
    return this
  })
  
  // Shortcut method for retrieving the first page
  schema.static('firstPage', function (opt, fn) {
    if (!fn) { fn = opt; opt = {} }
    var query = opt.query || currentQuery
      , limit = opt.limit || currentLimit
      , fields = opt.fields || currentFields
    
    this.paginate({
      query: query
    , page: 1
    , limit: limit
    , fields: fields
    }, fn)
    return this
  })

  // Shortcut method for retrieving the last page
  schema.static('lastPage', function (opt, fn) {
    if (!fn) { fn = opt; opt = {} }
    var self = this
      , query = opt.query || currentQuery
      , limit = opt.limit || currentLimit
      , fields = opt.fields || currentFields

    this.count(query, function (err, count) {
      if (err) return (fn && fn(err))
      self.paginate({
        query: query
      , page: Math.ceil(count / limit)
      , limit: limit
      , fields: fields
      }, fn)
    })
    return this
  })
}
1263075
public static function getPageOffsetAndLimit($pageNumber, $divider, $total = -1) {
        if ($pageNumber < 0 || $divider < 0) {
            return -1;
        }
        $offset = $pageNumber * $divider;
        $limit  = $divider;
        if (0 <= $total && ($total < $offset || $total < ($offset + $limit))) {
            $offset = (static::getPagesCount($total, $divider) - 1) * $divider;
            $limit  = $total - $offset;
        }
        return [$offset, $limit];
    }
1255960
public static Url getBaseUrl(final Class<? extends Page> pageClass,
		final PageParameters parameters)
	{
		return RequestCycle.get().mapUrlFor(pageClass, parameters);
	}
1371874
def get_pagination_context(
    page, pages_to_show=11, url=None, size=None, extra=None, parameter_name="page"
):
    
    pages_to_show = int(pages_to_show)
    if pages_to_show < 1:
        raise ValueError(
            "Pagination pages_to_show should be a positive integer, you specified {pages}".format(
                pages=pages_to_show
            )
        )
    num_pages = page.paginator.num_pages
    current_page = page.number
    half_page_num = int(floor(pages_to_show / 2))
    if half_page_num < 0:
        half_page_num = 0
    first_page = current_page - half_page_num
    if first_page <= 1:
        first_page = 1
    if first_page > 1:
        pages_back = first_page - half_page_num
        if pages_back < 1:
            pages_back = 1
    else:
        pages_back = None
    last_page = first_page + pages_to_show - 1
    if pages_back is None:
        last_page += 1
    if last_page > num_pages:
        last_page = num_pages
    if last_page < num_pages:
        pages_forward = last_page + half_page_num
        if pages_forward > num_pages:
            pages_forward = num_pages
    else:
        pages_forward = None
        if first_page > 1:
            first_page -= 1
        if pages_back is not None and pages_back > 1:
            pages_back -= 1
        else:
            pages_back = None
    pages_shown = []
    for i in range(first_page, last_page + 1):
        pages_shown.append(i)
        # Append proper character to url
    if url:
        # Remove existing page GET parameters
        url = force_text(url)
        url = re.sub(r"\?{0}\=[^\&]+".format(parameter_name), "?", url)
        url = re.sub(r"\&{0}\=[^\&]+".format(parameter_name), "", url)
        # Append proper separator
        if "?" in url:
            url += "&"
        else:
            url += "?"
            # Append extra string to url
    if extra:
        if not url:
            url = "?"
        url += force_text(extra) + "&"
    if url:
        url = url.replace("?&", "?")
    # Set CSS classes, see http://getbootstrap.com/components/#pagination
    pagination_css_classes = ["pagination"]
    if size == "small":
        pagination_css_classes.append("pagination-sm")
    elif size == "large":
        pagination_css_classes.append("pagination-lg")
        # Build context object
    return {
        "bootstrap_pagination_url": url,
        "num_pages": num_pages,
        "current_page": current_page,
        "first_page": first_page,
        "last_page": last_page,
        "pages_shown": pages_shown,
        "pages_back": pages_back,
        "pages_forward": pages_forward,
        "pagination_css_classes": " ".join(pagination_css_classes),
        "parameter_name": parameter_name,
    }
404147
function(callback) {
            callback = callback || function() {};
            
            var that = this;
            var params = {
                count: this._pagesize,
                offset: this._offset
            };
            return this._endpoint(params, function(err, results) {
                if (err) {
                    callback(err);
                }
                else {                    
                    var numResults = (results.rows ? results.rows.length : 0);
                    that._offset += numResults;
                    
                    callback(null, results, numResults > 0);
                }
            });
        }
1238852
protected function getOriginalPage()
    {
        if ($this->originalPage === false) {
            $originalPage = null;
            $ocID = $this->request->request->get('ocID', $this->request->query->get('ocID'));
            if ($ocID && is_scalar($ocID)) {
                $ocID = (int) $ocID;
                if ($ocID !== 0) {
                    $originalPage = Page::getByID($ocID);
                }
            }
            $this->setOriginalPage($originalPage);
        }

        return $this->originalPage;
    }
1162903
public function findDefaultPerPage()
	{
		if (!empty($this->per_page)) {
			return;
		}

		if (!empty($this->default_per_page)) {
			$this->per_page = $this->default_per_page;
		}

		$this->saveSessionData('_grid_per_page', $this->per_page);
	}
358571
public @Nullable Page getPage(@Nullable Predicate<Page> filter, @Nullable Page basePage) {
    List<Page> suffixPages = getPages(filter, basePage);
    if (suffixPages.isEmpty()) {
      return null;
    }
    else {
      return suffixPages.get(0);
    }
  }