本文整理汇总了PHP中Paginator::get_page_range方法的典型用法代码示例。如果您正苦于以下问题:PHP Paginator::get_page_range方法的具体用法?PHP Paginator::get_page_range怎么用?PHP Paginator::get_page_range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Paginator
的用法示例。
在下文中一共展示了Paginator::get_page_range方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_pages
/**
* Returns an array of "local" pages given a page number and range.
*
* @param Paginator $paginator
* @param integer $page_range Unused
* @return array
*/
public function get_pages(Paginator $paginator, $page_range = null)
{
$page_range = $paginator->get_page_range();
$page_number = $paginator->get_current_page_number();
$delta = $page_number % $page_range;
if ($delta == 0) {
$delta = $page_range;
}
$offset = $page_number - $delta;
$lower_bound = $offset + 1;
$upper_bound = $offset + $page_range;
return $paginator->get_pages_in_range($lower_bound, $upper_bound);
}
示例2: get_pages
/**
* Returns an array of "local" pages given a page number and range.
*
* @param Paginator $paginator
* @param integer $page_range Unused
* @return array
*/
public function get_pages(Paginator $paginator, $page_range = null)
{
$page_range = $paginator->get_page_range();
$page_number = $paginator->get_current_page_number();
$original_page_range = $page_range;
$page_range = $page_range * 2 - 1;
if ($original_page_range + $page_number - 1 < $page_range) {
$page_range = $original_page_range + $page_number - 1;
} else {
if ($original_page_range + $page_number - 1 > count($paginator)) {
$page_range = $original_page_range + count($paginator) - $page_number;
}
}
return parent::get_pages($paginator, $page_range);
}
示例3: get_pages
/**
* Returns an array of "local" pages given a page number and range.
*
* @param Paginator $paginator
* @param integer $page_range (Optional) Page range
* @return array
*/
public function get_pages(Paginator $paginator, $page_range = null)
{
if ($page_range === null) {
$page_range = $paginator->get_page_range();
}
$page_number = $paginator->get_current_page_number();
$page_count = count($paginator);
if ($page_range > $page_count) {
$page_range = $page_count;
}
$delta = ceil($page_range / 2);
if ($page_number - $delta > $page_count - $page_range) {
$lower_bound = $page_count - $page_range + 1;
$upper_bound = $page_count;
} else {
if ($page_number - $delta < 0) {
$delta = $page_number;
}
$offset = $page_number - $delta;
$lower_bound = $offset + 1;
$upper_bound = $offset + $page_range;
}
return $paginator->get_pages_in_range($lower_bound, $upper_bound);
}