Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
acc27998
Commit
acc27998
authored
Jul 21, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move last page logic into Paginator class.
parent
b933b19d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
4 deletions
+7
-4
paginator.php
system/paginator.php
+7
-4
No files found.
system/paginator.php
View file @
acc27998
...
@@ -47,11 +47,11 @@ class Paginator {
...
@@ -47,11 +47,11 @@ class Paginator {
*/
*/
public
function
__construct
(
$results
,
$total
,
$per_page
)
public
function
__construct
(
$results
,
$total
,
$per_page
)
{
{
$this
->
page
=
static
::
page
(
$total
,
$per_page
);
$this
->
per_page
=
$per_page
;
$this
->
per_page
=
$per_page
;
$this
->
results
=
$results
;
$this
->
results
=
$results
;
$this
->
total
=
$total
;
$this
->
total
=
$total
;
$this
->
page
=
static
::
page
(
$this
->
last_page
());
}
}
/**
/**
...
@@ -60,11 +60,14 @@ class Paginator {
...
@@ -60,11 +60,14 @@ class Paginator {
* The page will be validated and adjusted if it is less than 1 or
* The page will be validated and adjusted if it is less than 1 or
* greater than the last page number.
* greater than the last page number.
*
*
* @param int $last_page
* @param int $total
* @param int $per_page
* @return int
* @return int
*/
*/
public
static
function
page
(
$
last
_page
)
public
static
function
page
(
$
total
,
$per
_page
)
{
{
$last_page
=
ceil
(
$total
/
$per_page
);
$page
=
Input
::
get
(
'page'
,
1
);
$page
=
Input
::
get
(
'page'
,
1
);
if
(
is_numeric
(
$page
)
and
$page
>
$last_page
)
if
(
is_numeric
(
$page
)
and
$page
>
$last_page
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment