Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Tomáš Trávníček
doctrine-dbal
Commits
e01809d1
Commit
e01809d1
authored
Jan 11, 2008
by
wernerm
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed returned range bug(s)
parent
c6e20867
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
16 deletions
+25
-16
Sliding.php
lib/Doctrine/Pager/Range/Sliding.php
+25
-16
No files found.
lib/Doctrine/Pager/Range/Sliding.php
View file @
e01809d1
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
* and is licensed under the LGPL. For more information, see
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
* <http://www.phpdoctrine.com>.
*/
*/
Doctrine
::
autoload
(
'Doctrine_Pager_Range'
);
Doctrine
::
autoload
(
'Doctrine_Pager_Range'
);
/**
/**
...
@@ -81,7 +81,12 @@ class Doctrine_Pager_Range_Sliding extends Doctrine_Pager_Range
...
@@ -81,7 +81,12 @@ class Doctrine_Pager_Range_Sliding extends Doctrine_Pager_Range
*/
*/
protected
function
_setChunkLength
(
$chunkLength
)
protected
function
_setChunkLength
(
$chunkLength
)
{
{
$this
->
_chunkLength
=
$chunkLength
;
$chunkLength
=
(
int
)
$chunkLength
;
if
(
!
$chunkLength
)
{
$chunkLength
=
1
;
}
else
{
$this
->
_chunkLength
=
$chunkLength
;
}
}
}
...
@@ -95,25 +100,29 @@ class Doctrine_Pager_Range_Sliding extends Doctrine_Pager_Range
...
@@ -95,25 +100,29 @@ class Doctrine_Pager_Range_Sliding extends Doctrine_Pager_Range
public
function
rangeAroundPage
()
public
function
rangeAroundPage
()
{
{
$pager
=
$this
->
getPager
();
$pager
=
$this
->
getPager
();
$page
=
$pager
->
getPage
();
$page
=
$pager
->
getPage
();
$pages
=
$pager
->
getLastPage
();
// Define initial assignments for StartPage and EndPage
$chunk
=
$this
->
getChunkLength
();
$startPage
=
$page
-
floor
(
$this
->
getChunkLength
()
-
1
)
/
2
;
if
(
$chunk
>
$pages
)
{
$endPage
=
(
$startPage
+
$this
->
getChunkLength
())
-
1
;
$chunk
=
$pages
;
}
// Check for EndPage out-range
$chunkStart
=
$page
-
(
floor
(
$chunk
/
2
));
if
(
$endPage
>
$pager
->
getLastPage
())
{
$chunkEnd
=
$page
+
(
ceil
(
$chunk
/
2
)
-
1
);
$offset
=
$endPage
-
$pager
->
getLastPage
();
$endPage
=
$pager
->
getLastPage
();
if
(
$chunkStart
<
1
)
{
$startPage
=
$startPage
-
$offset
;
$adjust
=
1
-
$chunkStart
;
$chunkStart
=
1
;
$chunkEnd
=
$chunkEnd
+
$adjust
;
}
}
if
(
$chunkEnd
>
$pages
)
{
// Check for StartPage out-range
$adjust
=
$chunkEnd
-
$pages
;
if
(
$startPage
<
$pager
->
getFirstPage
())
{
$chunkStart
=
$chunkStart
-
$adjust
;
$
startPage
=
$pager
->
getFirstPage
()
;
$
chunkEnd
=
$pages
;
}
}
return
range
(
$startPage
,
$endPage
);
return
range
(
$chunkStart
,
$chunkEnd
);
}
}
}
}
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