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
539eb28c
Commit
539eb28c
authored
Jul 21, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring Paginator.
parent
556fff9f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
14 deletions
+12
-14
paginator.php
system/paginator.php
+12
-14
No files found.
system/paginator.php
View file @
539eb28c
...
...
@@ -57,8 +57,7 @@ class Paginator {
/**
* Get the current page from the request query string.
*
* The page will be validated and adjusted if it is less than 1 or
* greater than the last page number.
* The page will be validated and adjusted if it is less than one or greater than the last page.
*
* @param int $total
* @param int $per_page
...
...
@@ -98,15 +97,16 @@ class Paginator {
/**
* Generate the HTML numeric page links.
*
* If there are not enough pages to make it worth sliding, all of the pages will be listed.
*
* Note: "7" is added to the adjacent range to account for the seven constant elements
* in a slider: the first and last two links, the current page, and the two "..." strings.
*
* @param int $adjacent
* @return string
*/
p
ublic
function
numbers
(
$adjacent
=
3
)
p
rivate
function
numbers
(
$adjacent
=
3
)
{
// If there are not enough pages to make it worth sliding, we will show all of the pages.
//
// We add "7" for the constant elements in a slider: the first and last two links, the
// current page, and the two "..." strings.
return
(
$this
->
last_page
()
<
7
+
(
$adjacent
*
2
))
?
$this
->
range
(
1
,
$this
->
last_page
())
:
$this
->
slider
(
$adjacent
);
}
...
...
@@ -116,18 +116,16 @@ class Paginator {
* @param int $adjacent
* @return string
*/
pr
otected
function
slider
(
$adjacent
)
pr
ivate
function
slider
(
$adjacent
)
{
$pagination
=
''
;
if
(
$this
->
page
<=
$adjacent
*
2
)
{
// Buffer the current page with four pages to the right. Any more pages will interfere with hiding.
$pagination
.=
$this
->
range
(
1
,
4
+
(
$adjacent
*
2
))
.
$this
->
ending
();
}
elseif
(
$this
->
page
>=
$this
->
last_page
()
-
(
$adjacent
*
2
))
{
// Buffer with at least two pages to the left of the current page.
$pagination
.=
$this
->
beginning
()
.
$this
->
range
(
$this
->
last_page
()
-
2
-
(
$adjacent
*
2
),
$this
->
last_page
());
}
else
...
...
@@ -179,7 +177,7 @@ class Paginator {
*
* @return string
*/
pr
otected
function
beginning
()
pr
ivate
function
beginning
()
{
return
$this
->
range
(
1
,
2
)
.
'<span class="dots">...</span>'
;
}
...
...
@@ -189,7 +187,7 @@ class Paginator {
*
* @return string
*/
pr
otected
function
ending
()
pr
ivate
function
ending
()
{
return
'<span class="dots">...</span>'
.
$this
->
range
(
$this
->
last_page
()
-
1
,
$this
->
last_page
());
}
...
...
@@ -199,7 +197,7 @@ class Paginator {
*
* @return int
*/
pr
otected
function
last_page
()
pr
ivate
function
last_page
()
{
return
ceil
(
$this
->
total
/
$this
->
per_page
);
}
...
...
@@ -213,7 +211,7 @@ class Paginator {
* @param int $end
* @return string
*/
pr
otected
function
range
(
$start
,
$end
)
pr
ivate
function
range
(
$start
,
$end
)
{
$pages
=
''
;
...
...
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