Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
UserAdminV2
Overview
Overview
Details
Activity
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
UserAdminV2
Commits
c19ab70a
Commit
c19ab70a
authored
Aug 02, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor paginator for readability.
parent
be3266d2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
4 deletions
+23
-4
system/paginator.php
+23
-4
No files found.
system/paginator.php
View file @
c19ab70a
...
...
@@ -107,7 +107,9 @@ class Paginator {
*/
public
function
links
(
$adjacent
=
3
)
{
return
(
$this
->
last_page
>
1
)
?
'<div class="pagination">'
.
$this
->
previous
()
.
$this
->
numbers
(
$adjacent
)
.
$this
->
next
()
.
'</div>'
:
''
;
if
(
$this
->
last_page
<=
1
)
return
''
;
return
'<div class="pagination">'
.
$this
->
previous
()
.
$this
->
numbers
(
$adjacent
)
.
$this
->
next
()
.
'</div>'
;
}
/**
...
...
@@ -120,7 +122,14 @@ class Paginator {
*/
private
function
numbers
(
$adjacent
=
3
)
{
return
(
$this
->
last_page
<
7
+
(
$adjacent
*
2
))
?
$this
->
range
(
1
,
$this
->
last_page
)
:
$this
->
slider
(
$adjacent
);
// The hard-coded "7" is to account for all of the constant elements in a sliding range.
// Namely: The the current page, the two ellipses, the two beginning pages, and the two ending pages.
if
(
$this
->
last_page
<
7
+
(
$adjacent
*
2
))
{
return
$this
->
range
(
1
,
$this
->
last_page
);
}
return
$this
->
slider
(
$adjacent
);
}
/**
...
...
@@ -152,7 +161,12 @@ class Paginator {
{
$text
=
Lang
::
line
(
'pagination.previous'
)
->
get
(
$this
->
language
);
return
(
$this
->
page
>
1
)
?
$this
->
link
(
$this
->
page
-
1
,
$text
,
'prev_page'
)
.
' '
:
HTML
::
span
(
$text
,
array
(
'class'
=>
'disabled prev_page'
))
.
' '
;
if
(
$this
->
page
>
1
)
{
return
$this
->
link
(
$this
->
page
-
1
,
$text
,
'prev_page'
)
.
' '
;
}
return
HTML
::
span
(
$text
,
array
(
'class'
=>
'disabled prev_page'
))
.
' '
;
}
/**
...
...
@@ -164,7 +178,12 @@ class Paginator {
{
$text
=
Lang
::
line
(
'pagination.next'
)
->
get
(
$this
->
language
);
return
(
$this
->
page
<
$this
->
last_page
)
?
$this
->
link
(
$this
->
page
+
1
,
$text
,
'next_page'
)
:
HTML
::
span
(
$text
,
array
(
'class'
=>
'disabled next_page'
));
if
(
$this
->
page
<
$this
->
last_page
)
{
return
$this
->
link
(
$this
->
page
+
1
,
$text
,
'next_page'
);
}
return
HTML
::
span
(
$text
,
array
(
'class'
=>
'disabled next_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