Issues

ZF-7020: Zend_Paginator_ScrollingStyle_Elastic is only "elastic" near first pages, but not near last pages

Issue Type: Bug Created: 2009-06-15T10:14:14.000+0000 Last Updated: 2009-10-15T10:56:20.000+0000 Status: Resolved Fix version(s): Reporter: Jan-Christoph Ihrens (enigmatic_user) Assignee: Jurrien Stutterheim (norm2782) Tags: - Zend_Paginator

Related issues: Attachments:

Description

When using Zend_Paginator_ScrollingStyle_Elastic e. g. with a pageRange of 3 and a number of 10 pages, the following page links are generated:

page 1: [1] 2 3

page 2: 1 [2] 3 4

page 3: 1 2 [3] 4 5

[...]

page 8: 6 7 [8] 9 10

page 9: 6 7 8 [9] 10 (should be 7 8 [9] 10)

page 10: 6 7 8 9 [10] (should be 8 9 [10])

This is easy to fix:

<pre class="highlight">
    public function getPages(Zend_Paginator $paginator, $pageRange = null)
    {
        $pageRange  = $paginator->getPageRange();
        $pageNumber = $paginator->getCurrentPageNumber();

        $originalPageRange = $pageRange;
        $pageRange         = $pageRange * 2 - 1;

        if ($originalPageRange + $pageNumber - 1 < $pageRange) {
            $pageRange = $originalPageRange + $pageNumber - 1;
        }

        // start bugfix
        elseif ($originalPageRange + $pageNumber - 1 > count($paginator)) {
            $pageRange = $originalPageRange + count($paginator) - $pageNumber;
        }
        // end bugfix

        return parent::getPages($paginator, $pageRange);
    }

Comments

Posted by Jan-Christoph Ihrens (enigmatic_user) on 2009-06-15T10:15:34.000+0000

Set Issue Type from "Improvement" to "Bug"

Posted by Jurrien Stutterheim (norm2782) on 2009-06-21T14:25:42.000+0000

Closing this issue as not an issue. For an example of an elastic scrollingstyle, see Google's pagination.

Posted by Jan-Christoph Ihrens (enigmatic_user) on 2009-06-21T14:48:33.000+0000

Yes, I know Google's pagination. And it works just the way I'd like Zend_Paginator_ScrollingStyle_Elastic to work - but it doesn't.

Google shows you 10 items before the actual page and 9 behind it when being in the middle of the result set. At the end of the result set it shows 10 items before the actual (last) page. Zend_Paginator_ScrollingStyle_Elastic shows 18 items before the actual page when being at the end of the result set at a PageRange of 10 (or 20 at a PageRange of 11 - unlike Google it always shows the same number of items before and after the actual page when being in the middle of the result set).

Maybe you'd like to test it yourself...

Posted by Jan-Christoph Ihrens (enigmatic_user) on 2009-06-21T14:54:00.000+0000

Also, maybe you'd like to ask yourself why there is a correction algorithm for the first pages:

<pre class="highlight">
        if ($originalPageRange + $pageNumber - 1 < $pageRange) {
            $pageRange = $originalPageRange + $pageNumber - 1;
        }

but not for the last pages...

Posted by Jurrien Stutterheim (norm2782) on 2009-06-21T15:17:57.000+0000

I asked myself... the answer was that either Matthew or myself put it there in our free time while we contributed to this framework for free.

I double checked Google's behavior. It does some weird things with larger resultsets, so it doesn't completely act like your example does. On smaller resultsets it does do what you describe. Reopening issue.

Posted by Jan-Christoph Ihrens (enigmatic_user) on 2009-06-21T15:40:14.000+0000

{quote} I asked myself... the answer was that either Matthew or myself put it there in our free time while we contributed to this framework for free. {quote}

Well, I respect what you are doing, but what has this to do with the issue I described? I reported a bug - this is what the issue tracker is for. You implicitly told me that I was too dumb to recognize an elastic scrolling style when I see one, and I just asked you to take a closer look at it. No need to be huffy...

{quote} It does some weird things with larger resultsets {quote}

That's indeed true. :-) But if you somehow manage to get to the end of the result set, the number of items before the actual page is correct (at least during my tests).

Posted by Matthew Ratzloff (mratzloff) on 2009-08-13T13:07:30.000+0000

The scrolling behavior mimicked Google for my test set of queries when the component was released. It may be that my test set was not complete, however.

Posted by Jurrien Stutterheim (norm2782) on 2009-10-15T10:56:20.000+0000

Resolved in r18552. Merged to release-1.9 in r18553

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts