1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

[ticket/11849] Replace pagination in viewforum.php with class

PHPBB3-11849
This commit is contained in:
Joas Schilling
2013-12-12 02:30:56 +01:00
parent fcfa1a35cc
commit 725c512468
3 changed files with 105 additions and 21 deletions

View File

@@ -222,7 +222,7 @@ class pagination
* @param int $start the item which should be considered currently active, used to determine the page we're on
* @return int Current page number
*/
protected function get_on_page($per_page, $start)
public function get_on_page($per_page, $start)
{
return floor($start / $per_page) + 1;
}
@@ -253,8 +253,9 @@ class pagination
/**
* Get current page number
*
* @param int $per_page the number of items, posts, etc. per page
* @param int $start the item which should be considered currently active, used to determine the page we're on
* @param int $per_page the number of items, posts, etc. per page
* @param int $num_items the total number of items, posts, topics, etc.
* @return int Current page number
*/
public function validate_start($start, $per_page, $num_items)
@@ -266,4 +267,40 @@ class pagination
return $start;
}
/**
* Get new start when searching from the end
*
* If the user is trying to reach late pages, start searching from the end.
*
* @param int $start the item which should be considered currently active, used to determine the page we're on
* @param int $limit the number of items, posts, etc. to display
* @param int $num_items the total number of items, posts, topics, etc.
* @return int Current page number
*/
public function reverse_start($start, $limit, $num_items)
{
return max(0, $num_items - $limit - $start);
}
/**
* Get new item limit when searching from the end
*
* If the user is trying to reach late pages, start searching from the end.
* In this case the items to display might be lower then the actual per_page setting.
*
* @param int $start the item which should be considered currently active, used to determine the page we're on
* @param int $per_page the number of items, posts, etc. per page
* @param int $num_items the total number of items, posts, topics, etc.
* @return int Current page number
*/
public function reverse_limit($start, $per_page, $num_items)
{
if ($start + $per_page > $num_items)
{
return min($per_page, max(1, $num_items - $start));
}
return $per_page;
}
}