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
8d2eefe1
Commit
8d2eefe1
authored
Jul 25, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactoring paginator.
parent
7ca5a235
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
18 deletions
+29
-18
paginator.php
system/paginator.php
+29
-18
No files found.
system/paginator.php
View file @
8d2eefe1
...
...
@@ -110,8 +110,6 @@ class Paginator {
*/
private
function
numbers
(
$adjacent
=
3
)
{
// "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.
return
(
$this
->
last_page
<
7
+
(
$adjacent
*
2
))
?
$this
->
range
(
1
,
$this
->
last_page
)
:
$this
->
slider
(
$adjacent
);
}
...
...
@@ -125,7 +123,7 @@ class Paginator {
{
if
(
$this
->
page
<=
$adjacent
*
2
)
{
return
$this
->
range
(
1
,
4
+
(
$adjacent
*
2
))
.
$this
->
ending
();
return
$this
->
range
(
1
,
2
+
(
$adjacent
*
2
))
.
$this
->
ending
();
}
elseif
(
$this
->
page
>=
$this
->
last_page
-
(
$adjacent
*
2
))
{
...
...
@@ -144,12 +142,7 @@ class Paginator {
{
$text
=
Lang
::
line
(
'pagination.previous'
)
->
get
(
$this
->
language
);
if
(
$this
->
page
>
1
)
{
return
HTML
::
link
(
Request
::
uri
()
.
'?page='
.
(
$this
->
page
-
1
),
$text
,
array
(
'class'
=>
'prev_page'
),
$this
->
https
)
.
' '
;
}
return
"<span class=
\"
disabled prev_page
\"
>
$text
</span> "
;
return
(
$this
->
page
>
1
)
?
$this
->
link
(
$this
->
page
-
1
,
$text
,
'prev_page'
)
.
' '
:
HTML
::
span
(
$text
,
array
(
'class'
=>
'disabled prev_page'
))
.
' '
;
}
/**
...
...
@@ -161,12 +154,7 @@ class Paginator {
{
$text
=
Lang
::
line
(
'pagination.next'
)
->
get
(
$this
->
language
);
if
(
$this
->
page
<
$this
->
last_page
)
{
return
HTML
::
link
(
Request
::
uri
()
.
'?page='
.
(
$this
->
page
+
1
),
$text
,
array
(
'class'
=>
'next_page'
),
$this
->
https
);
}
return
"<span class=
\"
disabled next_page
\"
>
$text
</span>"
;
return
(
$this
->
page
<
$this
->
last_page
)
?
$this
->
link
(
$this
->
page
+
1
,
$text
,
'next_page'
)
:
HTML
::
span
(
$text
,
array
(
'class'
=>
'disabled next_page'
))
.
' '
;
}
/**
...
...
@@ -176,7 +164,7 @@ class Paginator {
*/
private
function
beginning
()
{
return
$this
->
range
(
1
,
2
)
.
'<span class="dots">...</span> '
;
return
$this
->
range
(
1
,
2
)
.
$this
->
dots
()
;
}
/**
...
...
@@ -186,7 +174,30 @@ class Paginator {
*/
private
function
ending
()
{
return
'<span class="dots">...</span> '
.
$this
->
range
(
$this
->
last_page
-
1
,
$this
->
last_page
);
return
$this
->
dots
()
.
$this
->
range
(
$this
->
last_page
-
1
,
$this
->
last_page
);
}
/**
* Create a HTML page link.
*
* @param int $page
* @param string $text
* @param string $attributes
* @return string
*/
private
function
link
(
$page
,
$text
,
$class
)
{
return
HTML
::
link
(
Request
::
uri
()
.
'?page='
.
$page
,
$text
,
array
(
'class'
=>
$class
),
$this
->
https
);
}
/**
* Build a "dots" HTML span element.
*
* @return string
*/
private
function
dots
()
{
return
HTML
::
span
(
'...'
,
array
(
'class'
=>
'dots'
))
.
' '
;
}
/**
...
...
@@ -204,7 +215,7 @@ class Paginator {
for
(
$i
=
$start
;
$i
<=
$end
;
$i
++
)
{
$pages
.=
(
$this
->
page
==
$i
)
?
"<span class=
\"
current
\"
>
$i
</span> "
:
HTML
::
link
(
Request
::
uri
()
.
'?page='
.
$i
,
$i
,
array
(),
$this
->
https
)
.
' '
;
$pages
.=
(
$this
->
page
==
$i
)
?
HTML
::
span
(
$i
,
array
(
'class'
=>
'current'
))
.
' '
:
$this
->
link
(
$i
,
$i
,
null
)
.
' '
;
}
return
$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