Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
1a866d14
Commit
1a866d14
authored
Jan 14, 2006
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#44498
by m3vrck: improved HTML generated code for pagers.
parent
776e6501
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
includes/pager.inc
+51
-53
51 additions, 53 deletions
includes/pager.inc
misc/drupal.css
+1
-1
1 addition, 1 deletion
misc/drupal.css
with
52 additions
and
54 deletions
includes/pager.inc
+
51
−
53
View file @
1a866d14
...
...
@@ -95,24 +95,24 @@ function pager_query($query, $limit = 10, $element = 0, $count_query = NULL) {
* The number of query results to display per page.
* @param $element
* An optional integer to distinguish between multiple pagers on one page.
* @param $
attribu
tes
* @param $
parame
te
r
s
* An associative array of query string parameters to append to the pager links.
* @return
* An HTML string that generates the query pager.
*
* @ingroup themeable
*/
function
theme_pager
(
$tags
=
array
(),
$limit
=
10
,
$element
=
0
,
$
attribu
tes
=
array
())
{
function
theme_pager
(
$tags
=
array
(),
$limit
=
10
,
$element
=
0
,
$
parame
te
r
s
=
array
())
{
global
$pager_total
;
$output
=
''
;
if
(
$pager_total
[
$element
]
>
1
)
{
$output
.
=
'<div id="pager"
class="container-inline"
>'
;
$output
.
=
theme
(
'pager_first'
,
(
$tags
[
0
]
?
$tags
[
0
]
:
t
(
'first
page
'
)),
$limit
,
$element
,
$
attribu
tes
);
$output
.
=
theme
(
'pager_previous'
,
(
$tags
[
1
]
?
$tags
[
1
]
:
t
(
'previous
page
'
)),
$limit
,
$element
,
1
,
$
attribu
tes
);
$output
.
=
theme
(
'pager_list'
,
$limit
,
$element
,
(
$tags
[
2
]
?
$tags
[
2
]
:
9
),
''
,
$
attribu
tes
);
$output
.
=
theme
(
'pager_next'
,
(
$tags
[
3
]
?
$tags
[
3
]
:
t
(
'next
page
'
)),
$limit
,
$element
,
1
,
$
attribu
tes
);
$output
.
=
theme
(
'pager_last'
,
(
$tags
[
4
]
?
$tags
[
4
]
:
t
(
'last
page
'
)),
$limit
,
$element
,
$
attribu
tes
);
$output
.
=
'<div id="pager">'
;
$output
.
=
theme
(
'pager_first'
,
(
$tags
[
0
]
?
$tags
[
0
]
:
t
(
'
«
first'
)),
$limit
,
$element
,
$
parame
te
r
s
);
$output
.
=
theme
(
'pager_previous'
,
(
$tags
[
1
]
?
$tags
[
1
]
:
t
(
'
‹
previous'
)),
$limit
,
$element
,
1
,
$
parame
te
r
s
);
$output
.
=
theme
(
'pager_list'
,
$limit
,
$element
,
(
$tags
[
2
]
?
$tags
[
2
]
:
9
),
''
,
$
parame
te
r
s
);
$output
.
=
theme
(
'pager_next'
,
(
$tags
[
3
]
?
$tags
[
3
]
:
t
(
'next
›
'
)),
$limit
,
$element
,
1
,
$
parame
te
r
s
);
$output
.
=
theme
(
'pager_last'
,
(
$tags
[
4
]
?
$tags
[
4
]
:
t
(
'last
»
'
)),
$limit
,
$element
,
$
parame
te
r
s
);
$output
.
=
'</div>'
;
return
$output
;
...
...
@@ -135,25 +135,22 @@ function theme_pager($tags = array(), $limit = 10, $element = 0, $attributes = a
* The number of query results to display per page.
* @param $element
* An optional integer to distinguish between multiple pagers on one page.
* @param $
attribu
tes
* @param $
parame
te
r
s
* An associative array of query string parameters to append to the pager links.
* @return
* An HTML string that generates this piece of the query pager.
*
* @ingroup themeable
*/
function
theme_pager_first
(
$text
,
$limit
,
$element
=
0
,
$
attribu
tes
=
array
())
{
function
theme_pager_first
(
$text
,
$limit
,
$element
=
0
,
$
parame
te
r
s
=
array
())
{
global
$pager_page_array
;
$output
=
'
<div class="pager-first">
'
;
$output
=
''
;
// If we are anywhere but the first page
if
(
$pager_page_array
[
$element
]
>
0
)
{
$output
.
=
theme
(
'pager_link'
,
$text
,
pager_load_array
(
0
,
$element
,
$pager_page_array
),
$element
,
$attributes
);
}
else
{
$output
.
=
' '
;
$output
=
theme
(
'pager_link'
,
$text
,
pager_load_array
(
0
,
$element
,
$pager_page_array
),
$element
,
$parameters
,
array
(
'class'
=>
'pager-first'
));
}
$output
.
=
'</div>'
;
return
$output
;
}
...
...
@@ -168,29 +165,30 @@ function theme_pager_first($text, $limit, $element = 0, $attributes = array()) {
* An optional integer to distinguish between multiple pagers on one page.
* @param $interval
* The number of pages to move backward when the link is clicked.
* @param $
attribu
tes
* @param $
parame
te
r
s
* An associative array of query string parameters to append to the pager links.
* @return
* An HTML string that generates this piece of the query pager.
*
* @ingroup themeable
*/
function
theme_pager_previous
(
$text
,
$limit
,
$element
=
0
,
$interval
=
1
,
$
attribu
tes
=
array
())
{
function
theme_pager_previous
(
$text
,
$limit
,
$element
=
0
,
$interval
=
1
,
$
parame
te
r
s
=
array
())
{
global
$pager_page_array
;
$output
=
'<div class="pager-previous">'
;
$output
=
''
;
// If we are anywhere but the first page
if
(
$pager_page_array
[
$element
]
>
0
)
{
$page_new
=
pager_load_array
(
$pager_page_array
[
$element
]
-
$interval
,
$element
,
$pager_page_array
);
// If the previous page is the first page, mark the link as such.
if
(
$page_new
[
$element
]
==
0
)
{
$output
.
=
theme
(
'pager_first'
,
$text
,
$limit
,
$element
,
$
attribu
tes
);
$output
=
theme
(
'pager_first'
,
$text
,
$limit
,
$element
,
$
parame
te
r
s
);
}
// The previous page is not the first page.
else
{
$output
.
=
theme
(
'pager_link'
,
$text
,
$page_new
,
$element
,
$
attributes
);
$output
=
theme
(
'pager_link'
,
$text
,
$page_new
,
$element
,
$
parameters
,
array
(
'class'
=>
'pager-previous'
)
);
}
}
$output
.
=
'</div>'
;
return
$output
;
}
...
...
@@ -205,32 +203,30 @@ function theme_pager_previous($text, $limit, $element = 0, $interval = 1, $attri
* An optional integer to distinguish between multiple pagers on one page.
* @param $interval
* The number of pages to move forward when the link is clicked.
* @param $
attribu
tes
* @param $
parame
te
r
s
* An associative array of query string parameters to append to the pager links.
* @return
* An HTML string that generates this piece of the query pager.
*
* @ingroup themeable
*/
function
theme_pager_next
(
$text
,
$limit
,
$element
=
0
,
$interval
=
1
,
$
attribu
tes
=
array
())
{
function
theme_pager_next
(
$text
,
$limit
,
$element
=
0
,
$interval
=
1
,
$
parame
te
r
s
=
array
())
{
global
$pager_page_array
,
$pager_total
;
$output
=
'<div class="pager-next">'
;
$output
=
''
;
// If we are anywhere but the last page
if
(
$pager_page_array
[
$element
]
<
(
$pager_total
[
$element
]
-
1
))
{
$page_new
=
pager_load_array
(
$pager_page_array
[
$element
]
+
$interval
,
$element
,
$pager_page_array
);
// If the next page is the last page, mark the link as such.
if
(
$page_new
[
$element
]
==
(
$pager_total
[
$element
]
-
1
))
{
$output
.
=
theme
(
'pager_last'
,
$text
,
$limit
,
$element
,
$
attribu
tes
);
$output
=
theme
(
'pager_last'
,
$text
,
$limit
,
$element
,
$
parame
te
r
s
);
}
// The next page is not the last page.
else
{
$output
.
=
theme
(
'pager_link'
,
$text
,
$page_new
,
$element
,
$
attributes
);
$output
=
theme
(
'pager_link'
,
$text
,
$page_new
,
$element
,
$
parameters
,
array
(
'class'
=>
'pager-next'
)
);
}
}
else
{
$output
.
=
' '
;
}
$output
.
=
'</div>'
;
return
$output
;
}
...
...
@@ -243,25 +239,22 @@ function theme_pager_next($text, $limit, $element = 0, $interval = 1, $attribute
* The number of query results to display per page.
* @param $element
* An optional integer to distinguish between multiple pagers on one page.
* @param $
attribu
tes
* @param $
parame
te
r
s
* An associative array of query string parameters to append to the pager links.
* @return
* An HTML string that generates this piece of the query pager.
*
* @ingroup themeable
*/
function
theme_pager_last
(
$text
,
$limit
,
$element
=
0
,
$
attribu
tes
=
array
())
{
function
theme_pager_last
(
$text
,
$limit
,
$element
=
0
,
$
parame
te
r
s
=
array
())
{
global
$pager_page_array
,
$pager_total
;
$output
=
''
;
$output
=
'<div class="pager-last">'
;
// If we are anywhere but the last page
if
(
$pager_page_array
[
$element
]
<
(
$pager_total
[
$element
]
-
1
))
{
$output
.
=
theme
(
'pager_link'
,
$text
,
pager_load_array
(
$pager_total
[
$element
]
-
1
,
$element
,
$pager_page_array
),
$element
,
$attributes
);
}
else
{
$output
.
=
' '
;
$output
=
theme
(
'pager_link'
,
$text
,
pager_load_array
(
$pager_total
[
$element
]
-
1
,
$element
,
$pager_page_array
),
$element
,
$parameters
,
array
(
'class'
=>
'pager-last'
));
}
$output
.
=
'</div>'
;
return
$output
;
}
...
...
@@ -276,17 +269,17 @@ function theme_pager_last($text, $limit, $element = 0, $attributes = array()) {
* The number of pages in the list.
* @param $text
* A string of text to display before the page list.
* @param $
attribu
tes
* @param $
parame
te
r
s
* An associative array of query string parameters to append to the pager links.
* @return
* An HTML string that generates this piece of the query pager.
*
* @ingroup themeable
*/
function
theme_pager_list
(
$limit
,
$element
=
0
,
$quantity
=
5
,
$text
=
''
,
$
attribu
tes
=
array
())
{
function
theme_pager_list
(
$limit
,
$element
=
0
,
$quantity
=
5
,
$text
=
''
,
$
parame
te
r
s
=
array
())
{
global
$pager_page_array
,
$pager_total
;
$output
=
'<
div
class="pager-list">'
;
$output
=
'<
span
class="pager-list">'
;
// Calculate various markers within this pager piece:
// Middle is used to "center" pages around the current page.
$pager_middle
=
ceil
(
$quantity
/
2
);
...
...
@@ -318,27 +311,27 @@ function theme_pager_list($limit, $element = 0, $quantity = 5, $text = '', $attr
if
(
$i
!=
$pager_max
)
{
$output
.
=
$text
;
if
(
$i
>
1
)
{
$output
.
=
'<
div
class="pager-
list-dots-left">... </div
>'
;
$output
.
=
'<
span
class="pager-
ellipses">…</span
>'
;
}
// Now generate the actual pager piece.
for
(;
$i
<=
$pager_last
&&
$i
<=
$pager_max
;
$i
++
)
{
if
(
$i
<
$pager_current
)
{
$output
.
=
theme
(
'pager_previous'
,
$i
,
$limit
,
$element
,
(
$pager_current
-
$i
),
$
attribu
tes
)
.
" "
;
$output
.
=
theme
(
'pager_previous'
,
$i
,
$limit
,
$element
,
(
$pager_current
-
$i
),
$
parame
te
r
s
);
}
if
(
$i
==
$pager_current
)
{
$output
.
=
'<strong>'
.
$i
.
'</strong>
'
;
$output
.
=
'<strong
class="pager-current"
>'
.
$i
.
'</strong>'
;
}
if
(
$i
>
$pager_current
)
{
$output
.
=
theme
(
'pager_next'
,
$i
,
$limit
,
$element
,
(
$i
-
$pager_current
),
$
attribu
tes
)
.
" "
;
$output
.
=
theme
(
'pager_next'
,
$i
,
$limit
,
$element
,
(
$i
-
$pager_current
),
$
parame
te
r
s
);
}
}
if
(
$i
<
$pager_max
)
{
$output
.
=
'<
div
class="pager-
list-dots-right">...</div
>'
;
$output
.
=
'<
span
class="pager-
ellipses">…</span
>'
;
}
}
$output
.
=
'</
div
>'
;
$output
.
=
'</
span
>'
;
return
$output
;
}
...
...
@@ -350,23 +343,28 @@ function theme_pager_list($limit, $element = 0, $quantity = 5, $text = '', $attr
* The first result to display on the linked page.
* @param $element
* An optional integer to distinguish between multiple pagers on one page.
* @param $
attribu
tes
* @param $
parame
te
r
s
* An associative array of query string parameters to append to the pager link.
* @param $attributes
* An associative array of HTML attributes to apply to a pager anchor tag.
* @return
* An HTML string that generates the link.
*/
function
theme_pager_link
(
$text
,
$page_new
,
$element
,
$attributes
=
array
())
{
function
theme_pager_link
(
$text
,
$page_new
,
$element
,
$parameters
=
array
(),
$attributes
=
array
())
{
$page
=
isset
(
$_GET
[
'page'
])
?
$_GET
[
'page'
]
:
''
;
if
(
$new_page
=
implode
(
','
,
pager_load_array
(
$page_new
[
$element
],
$element
,
explode
(
','
,
$page
))))
{
$
attribu
tes
[
'page'
]
=
$new_page
;
$
parame
te
r
s
[
'page'
]
=
$new_page
;
}
$query
=
array
();
foreach
(
$
attribu
tes
as
$key
=>
$value
)
{
foreach
(
$
parame
te
r
s
as
$key
=>
$value
)
{
$query
[]
=
$key
.
'='
.
$value
;
}
return
l
(
$text
,
$_GET
[
'q'
],
array
(),
count
(
$query
)
?
implode
(
'&'
,
$query
)
:
NULL
);
// Set each pager link title with correct page number (clean out HTML entities, title doesn't like those)
$attributes
[
'title'
]
=
is_numeric
(
$text
)
?
'goto page '
.
$text
:
'goto '
.
str_replace
(
array
(
'« '
,
'‹ '
,
' ›'
,
' »'
),
''
,
$text
)
.
' page'
;
return
l
(
$text
,
$_GET
[
'q'
],
$attributes
,
count
(
$query
)
?
implode
(
'&'
,
$query
)
:
NULL
,
NULL
,
FALSE
,
TRUE
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
misc/drupal.css
+
1
−
1
View file @
1a866d14
...
...
@@ -181,7 +181,7 @@ tr.odd .form-item, tr.even .form-item {
clear
:
both
;
text-align
:
center
;
}
#pager
div
{
#pager
a
,
#pager
strong
.pager-current
{
padding
:
0.5em
;
}
.path
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment