Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3443915
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3443915
Commits
25416c1e
Commit
25416c1e
authored
12 years ago
by
Tim Plunkett
Committed by
Tim Plunkett
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#1758766
by tim.plunkett, dawehner: Clean up current_page() code and API usage.
parent
cf22d23b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/Drupal/views/Plugin/views/pager/Full.php
+5
-12
5 additions, 12 deletions
lib/Drupal/views/Plugin/views/pager/Full.php
lib/Drupal/views/Tests/Plugin/PagerTest.php
+4
-0
4 additions, 0 deletions
lib/Drupal/views/Tests/Plugin/PagerTest.php
with
9 additions
and
12 deletions
lib/Drupal/views/Plugin/views/pager/Full.php
+
5
−
12
View file @
25416c1e
...
...
@@ -317,7 +317,7 @@ function render($input) {
*/
function
set_current_page
(
$number
=
NULL
)
{
if
(
isset
(
$number
))
{
$this
->
current_page
=
$number
;
$this
->
current_page
=
max
(
0
,
$number
)
;
return
;
}
...
...
@@ -338,11 +338,8 @@ function set_current_page($number = NULL) {
$pager_page_array
[
$i
]
=
empty
(
$page
[
$i
])
?
0
:
$page
[
$i
];
}
$this
->
current_page
=
intval
(
$pager_page_array
[
$this
->
options
[
'id'
]]);
if
(
$this
->
current_page
<
0
)
{
$this
->
current_page
=
0
;
}
// Don't allow the number to be less than zero.
$this
->
current_page
=
max
(
0
,
intval
(
$pager_page_array
[
$this
->
options
[
'id'
]]));
}
function
get_pager_total
()
{
...
...
@@ -380,14 +377,10 @@ function update_page_info() {
// Calculate and set the count of available pages.
$pager_total
[
$this
->
options
[
'id'
]]
=
$this
->
get_pager_total
();
//
@todo Use set_current_page() here: http://drupal.org/node/1758766
//
See if the requested page was within range:
if
(
$this
->
current_page
>=
$pager_total
[
$this
->
options
[
'id'
]])
{
// Pages are numbered from 0 so if there are 10 pages, the last page is 9.
$this
->
current_page
=
$pager_total
[
$this
->
options
[
'id'
]]
-
1
;
}
// See if the requested page was within range:
if
(
$this
->
current_page
<
0
)
{
$this
->
current_page
=
0
;
$this
->
set_current_page
(
$pager_total
[
$this
->
options
[
'id'
]]
-
1
);
}
// Put this number in to guarantee that we do not generate notices when the pager
...
...
This diff is collapsed.
Click to expand it.
lib/Drupal/views/Tests/Plugin/PagerTest.php
+
4
−
0
View file @
25416c1e
...
...
@@ -319,6 +319,10 @@ function testPagerApi() {
$rand_number
=
rand
(
6
,
11
);
$view
->
pager
->
set_current_page
(
$rand_number
);
$this
->
assertEqual
(
$view
->
getCurrentPage
(),
$rand_number
,
'Make sure get_current_page uses the settings of set_current_page.'
);
// Set an invalid page and make sure the method takes care about it.
$view
->
setCurrentPage
(
-
1
);
$this
->
assertEqual
(
$view
->
getCurrentPage
(),
0
,
'Make sure setCurrentPage always sets a valid page number.'
);
}
}
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