From Zend\Paginator\Paginator.
188064
public function pagerPageRange(PagerViewInterface $pager, $pageRange = null)
    {
        if (null === $pageRange) {
            $pageRange = $this->config->getPageRange();
        }

        $pageNumber = $pager->getCurrentPageNumber();
        $pageCount = $pager->getPageCount();

        if ($pageRange > $pageCount) {
            $pageRange = $pageCount;
        }

        $delta = ceil($pageRange / 2);

        if ($pageNumber - $delta > $pageCount - $pageRange) {
            $lowerBound = $pageCount - $pageRange + 1;
            $upperBound = $pageCount;
        } else {
            if ($pageNumber - $delta < 0) {
                $delta = $pageNumber;
            }

            $offset = $pageNumber - $delta;
            $lowerBound = $offset + 1;
            $upperBound = $offset + $pageRange;
        }

        $pages = array();
        for ($pageNumber = $lowerBound; $pageNumber <= $upperBound; ++$pageNumber) {
            $pages[$pageNumber] = $pageNumber;
        }

        return $pages;
    }
298106
public function preparePaginationResponse()
    {
        return new Response($this->total, $this->perPage, $this->page, $this->lastPage);
    }
340079
protected function createPaginator()
    {
        $paginator = new Paginator($this->getLimit());
        $paginator = $paginator->withPage($this->getPage());

        return $paginator;
    }
1090198
public function index() {
        $this->paginate = array_merge(array(
            'limit' => 25,
            'order' => array('ItemReport.' . $this->Model->displayField => 'ASC'),
            'contain' => array_keys($this->Model->belongsTo),
            'conditions' => array('ItemReport.status' => ItemReport::PENDING)
        ), $this->Model->admin['paginate']);

        $this->AdminToolbar->setBelongsToData($this->Model);

        $this->request->data['ItemReport']['status'] = ItemReport::PENDING;

        // Filters
        if (!empty($this->request->params['named'])) {
            $this->paginate['conditions'] = $this->AdminToolbar->parseFilterConditions($this->Model, $this->request->params['named']);
        }

        $this->set('results', $this->paginate($this->Model));
    }
463388
public function indexAction()
    {
        $this->initializeScaffolding();

        $paginator = $this->scaffolding->doPaginate($this->request->get('page', 'int', 1));
        $this->view->page = $paginator->getPaginate();
        $this->view->fields = $this->indexFields;
    }
1263834
public function PagedComments()
    {
        $list = $this->Comments();

        // Add pagination
        $list = PaginatedList::create($list, Controller::curr()->getRequest());
        $list->setPaginationGetVar('commentsstart' . $this->owner->ID);
        $list->setPageLength($this->owner->getCommentsOption('comments_per_page'));

        $this->owner->extend('updatePagedComments', $list);
        return $list;
    }
1053216
public function setPagination()
    {

        $total = $this->getListTotal();

        if (empty($total))
            return null;

        //Get the current page state from the request;
        $limit = $this->getListLimit();
        $current = $this->getState("currentpage", 1);
        $pages = array();

        //@TODO: Calculates the pages from a recordset or an array of results
        $pages['total'] = ceil($total / $limit);
        $pages['limit'] = $limit;

        //Get the real path to the current page
        $route = $this->container->router->getMatchedRoute();


        $pages['current'] = $route->getURLfromPathWithValues(["page" => strval($current)]);
        //Previous page link
        if (intval($current - 1) > 0):
            $pages['previous'] = $route->getURLfromPathWithValues(["page" => strval($current - 1)] );
        endif;
        //Next page link
        if (intval($current + 1) <= $pages['total']):
            $pages['next'] = $route->getURLfromPathWithValues(["page" => strval($current + 1)] );
        endif;

        //Build the pages;
        for ($i = 0; $i < $pages['total']; $i++):
            $page = $i + 1;
            $pages['pages'][] = array(
                "page_title" => strval($page),
                "page_link" => $route->getURLfromPathWithValues(["page" => $page] ),
                "page_state" => ($page == $current) ? "active" : null,
            );
        endfor;

        //Sets the pagination output;
        if (sizeof($pages['pages']) > 1)
            $this->pagination = $pages;

    }
715684
protected function paginationRanger()
    {
        $parameters = [
            'first' => $this->paginator->firstItem(),
            'last'  => $this->paginator->lastItem(),
            'total' => $this->paginator->total(),
        ];

        $parameters = collect($parameters)->flatMap(function ($parameter, $key) {
            return [$key => "<b>$parameter</b>"];
        });

        return trans('admin.pagination.range', $parameters->all());
    }
823481
def paginator(context, adjacent_pages=2):
    
    current_page = context.get('page')
    paginator    = context.get('paginator')
    if not paginator:
        return
    pages        = paginator.num_pages
    current_range = range(current_page - adjacent_pages, current_page + adjacent_pages + 1)
    page_numbers = [n for n in current_range if n > 0 and n <= pages]
    slugtype = ''

    if 'topic_slug' in context:
        page_url = context["topic"].get_short_url()
        slugtype = 'topic'
    elif 'forum_slug' in context:
        page_url = '/forum/%s/' % context["forum_slug"]
        slugtype = 'forum'
    else:
        page_url = context['request'].get_full_path()

    return {
        "is_paginated": context["is_paginated"],
        "page": current_page,
        "pages": pages,
        "page_obj": context['page_obj'],
        "page_numbers": page_numbers,
        "has_next": context["page_obj"].has_next(),
        "has_previous": context["page_obj"].has_previous(),
        "page_url" : page_url,
        'slugtype' : slugtype,
    }
1344810
public function createComponentPaginator()
	{
		/**
		 * Init paginator
		 */
		$component = new Components\DataGridPaginator\DataGridPaginator(
			$this->getTranslator(),
			static::$icon_prefix
		);
		$paginator = $component->getPaginator();

		$paginator->setPage($this->page);
		$paginator->setItemsPerPage($this->getPerPage());

		if ($this->custom_paginator_template) {
			$component->setTemplateFile($this->custom_paginator_template);
		}

		return $component;
	}
1310886
public function paginate()
    {
        $this->total = $this->dataSource->getTotal($this->source);

        if (
            ($this->getPagesCount() > 0 && $this->getPage() > $this->getPagesCount()) ||
            $this->getPage() <= 0
        ) {
            $this->handler->wrongPageCallback();
        }

        $this->data = $this->dataSource->applyLimit(
            $this->source,
            $this->getPage(),
            $this->getPageSize()
        );

        return $this->data;
    }
463533
public function index() {
        if ($this->overrideAction('index')) {
            return;
        }

        $this->paginate = array_merge(array(
            'limit' => 25,
            'order' => array($this->Model->alias . '.' . $this->Model->displayField => 'ASC'),
            'contain' => array_keys($this->Model->belongsTo)
        ), $this->Model->admin['paginate']);

        $this->AdminToolbar->setBelongsToData($this->Model);

        // Filters
        if (!empty($this->request->params['named'])) {
            $this->paginate['conditions'] = $this->AdminToolbar->parseFilterConditions($this->Model, $this->request->params['named']);
        }

        // Batch delete
        if ($this->request->is('post')) {
            if (!$this->Model->admin['batchProcess']) {
                throw new ForbiddenException(__d('admin', 'Batch Access Protected'));
            }

            $action = $this->request->data[$this->Model->alias]['batch_action'];
            $items = $this->request->data[$this->Model->alias]['items'];
            $processed = array();

            foreach ($items as $id) {
                if (!$id) {
                    continue;
                }

                if ($action === 'delete_item') {
                    if ($this->Model->delete($id, true)) {
                        $processed[] = $id;
                    }
                } else {
                    if (call_user_func(array($this->Model, $action), $id)) {
                        $processed[] = $id;
                    }
                }
            }

            $count = count($processed);

            if ($count > 0) {
                $this->AdminToolbar->logAction(ActionLog::BATCH_DELETE, $this->Model, '', sprintf('Processed IDs: %s', implode(', ', $processed)));
                $this->AdminToolbar->setFlashMessage(__d('admin', '%s %s have been processed', array($count, mb_strtolower($this->Model->pluralName))));

                $this->request->data[$this->Model->alias] = array();
            }
        }

        $this->set('results', $this->paginate($this->Model));
        $this->overrideView('index');
    }
384514
public function pagination() {
		global $post, $page, $numpages, $multipage;
		$post = $this;
		$ret = array();
		if ( $multipage ) {
			for ( $i = 1; $i <= $numpages; $i++ ) {
				$link = self::get_wp_link_page($i);
				$data = array('name' => $i, 'title' => $i, 'text' => $i, 'link' => $link);
				if ( $i == $page ) {
					$data['current'] = true;
				}
				$ret['pages'][] = $data;
			}
			$i = $page - 1;
			if ( $i ) {
				$link = self::get_wp_link_page($i);
				$ret['prev'] = array('link' => $link);
			}
			$i = $page + 1;
			if ( $i <= $numpages ) {
				$link = self::get_wp_link_page($i);
				$ret['next'] = array('link' => $link);
			}
		}
		return $ret;
	}
491661
public function getPagination(): array
    {
        if ($this->pagination === null) {
            $this->pagination = $this->setPagination();
        }

        return $this->pagination;
    }
681819
public function index()
    {
        $parameters = $this->request->getParameters();
        $paginator = $this->repository->getPaginatedCollection($parameters);
        return $this->paginatedResponse($paginator);
    }
39356
public function index()
    {
        $pagination = new Pagination();
        $pattern = StaticFilter::filter(
            'text',
            $this->getController()->request->getQuery('pattern', null)
        );
        $this->view = 'scaffold/index';
        $descriptor =  $this->getDescriptor();

        /** @var Select $query */
        $query = call_user_func_array([$this->getModelName(), 'find'], []);
        $field = $descriptor->getDisplayField();
        $tableName = $descriptor->getDescriptor()->getEntity()->getTableName();
        $query->where(
            [
                "{$tableName}.{$field} LIKE :pattern" => [
                    ':pattern' => "%{$pattern}%"
                ]
            ]
        );
        $pagination->setTotal($query->count());
        $query->limit(
            $pagination->rowsPerPage,
            $pagination->offset
        );
        $records = $query->all();
        $this->set(compact('pagination', 'records', 'pattern', 'descriptor'));
    }
565358
protected function calculatePagination()
    {
        if (empty($this->pagination['array']) && empty($this->pagination['call'])) {
            return;
        }
        if (isset($this->pagination['call'])) {
            $this->pagination['array'] = $this->callFunction($this->pagination['call']);
        }

        $keys = ['toPlaceholder'];
        $pagination = $this->template->getSnippet('pagination', ArrayHelper::diffByKeys($this->pagination, $keys));
        if (!empty($this->pagination['toPlaceholder'])) {
            $this->template->addPlaceholder($this->pagination['toPlaceholder'], $pagination);
            $this->template->cachePlaceholders[$this->pagination['toPlaceholder']] = $pagination;
            return;
        }
        $this->template->addPlaceholder('pagination', $pagination);
    }