本文整理匯總了PHP中Paginator::get_current_page_number方法的典型用法代碼示例。如果您正苦於以下問題:PHP Paginator::get_current_page_number方法的具體用法?PHP Paginator::get_current_page_number怎麽用?PHP Paginator::get_current_page_number使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Paginator
的用法示例。
在下文中一共展示了Paginator::get_current_page_number方法的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);
}