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
de48e194
Commit
de48e194
authored
Jul 22, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace last_page method with property.
parent
c09481c5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
16 deletions
+8
-16
paginator.php
system/paginator.php
+8
-16
No files found.
system/paginator.php
View file @
de48e194
...
@@ -59,6 +59,8 @@ class Paginator {
...
@@ -59,6 +59,8 @@ class Paginator {
$this
->
per_page
=
$per_page
;
$this
->
per_page
=
$per_page
;
$this
->
results
=
$results
;
$this
->
results
=
$results
;
$this
->
total
=
$total
;
$this
->
total
=
$total
;
$this
->
last_page
=
ceil
(
$total
/
$per_page
);
}
}
/**
/**
...
@@ -88,7 +90,7 @@ class Paginator {
...
@@ -88,7 +90,7 @@ class Paginator {
*/
*/
public
function
links
(
$adjacent
=
3
)
public
function
links
(
$adjacent
=
3
)
{
{
return
(
$this
->
last_page
()
>
1
)
?
'<div class="pagination">'
.
$this
->
previous
()
.
$this
->
numbers
(
$adjacent
)
.
$this
->
next
()
:
''
;
return
(
$this
->
last_page
>
1
)
?
'<div class="pagination">'
.
$this
->
previous
()
.
$this
->
numbers
(
$adjacent
)
.
$this
->
next
()
:
''
;
}
}
/**
/**
...
@@ -104,7 +106,7 @@ class Paginator {
...
@@ -104,7 +106,7 @@ class Paginator {
*/
*/
private
function
numbers
(
$adjacent
=
3
)
private
function
numbers
(
$adjacent
=
3
)
{
{
return
(
$this
->
last_page
()
<
7
+
(
$adjacent
*
2
))
?
$this
->
range
(
1
,
$this
->
last_page
()
)
:
$this
->
slider
(
$adjacent
);
return
(
$this
->
last_page
<
7
+
(
$adjacent
*
2
))
?
$this
->
range
(
1
,
$this
->
last_page
)
:
$this
->
slider
(
$adjacent
);
}
}
/**
/**
...
@@ -119,9 +121,9 @@ class Paginator {
...
@@ -119,9 +121,9 @@ class Paginator {
{
{
return
$this
->
range
(
1
,
4
+
(
$adjacent
*
2
))
.
$this
->
ending
();
return
$this
->
range
(
1
,
4
+
(
$adjacent
*
2
))
.
$this
->
ending
();
}
}
elseif
(
$this
->
page
>=
$this
->
last_page
()
-
(
$adjacent
*
2
))
elseif
(
$this
->
page
>=
$this
->
last_page
-
(
$adjacent
*
2
))
{
{
return
$this
->
beginning
()
.
$this
->
range
(
$this
->
last_page
()
-
2
-
(
$adjacent
*
2
),
$this
->
last_page
()
);
return
$this
->
beginning
()
.
$this
->
range
(
$this
->
last_page
-
2
-
(
$adjacent
*
2
),
$this
->
last_page
);
}
}
else
else
{
{
...
@@ -155,7 +157,7 @@ class Paginator {
...
@@ -155,7 +157,7 @@ class Paginator {
{
{
$text
=
Lang
::
line
(
'pagination.next'
)
->
get
(
$this
->
language
);
$text
=
Lang
::
line
(
'pagination.next'
)
->
get
(
$this
->
language
);
if
(
$this
->
page
<
$this
->
last_page
()
)
if
(
$this
->
page
<
$this
->
last_page
)
{
{
return
HTML
::
link
(
Request
::
uri
()
.
'?page='
.
(
$this
->
page
+
1
),
$text
,
array
(
'class'
=>
'next_page'
));
return
HTML
::
link
(
Request
::
uri
()
.
'?page='
.
(
$this
->
page
+
1
),
$text
,
array
(
'class'
=>
'next_page'
));
}
}
...
@@ -180,17 +182,7 @@ class Paginator {
...
@@ -180,17 +182,7 @@ class Paginator {
*/
*/
private
function
ending
()
private
function
ending
()
{
{
return
'<span class="dots">...</span>'
.
$this
->
range
(
$this
->
last_page
()
-
1
,
$this
->
last_page
());
return
'<span class="dots">...</span>'
.
$this
->
range
(
$this
->
last_page
-
1
,
$this
->
last_page
);
}
/**
* Calculate the last page based on the last page and the items per page.
*
* @return int
*/
private
function
last_page
()
{
return
ceil
(
$this
->
total
/
$this
->
per_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