Provided by: libdata-page-pageset-perl_1.02-1_all bug

NAME

       Data::Page::Pageset - change long page list to be shorter and well navigate

DESCRIPTION

       Pages number can be very high, and it is not comfortable to show user from the first page to the last
       page list. Sometimes we need split the page list into some sets to shorten the page list, the form is
       like:

        1-6 7-12 13 14 15 16 17 18 19-24 25-30 31-36 37-41

       the first two part indicats the two pagesets, and in current pageset, we provide the normal page list
       from the first one to the last one, and provide the rest pagesets to indicate the pages scope.

       In this module, you can specify the pages_per_set or max_pagesets for fine showing.

SYNOPSIS

        use Data::Page::Pageset;
        # we use Data::Page object, so do prepare
        my $page = Data::Page->new($total_entries, $entries_per_page, $current_page);
        # create the pageset object
        my $pageset = Data::Page::Pageset->new( $page );
        my $pageset = Data::Page::Pageset->new( $page, 12 );
        my $pageset = Data::Page::Pageset->new( $page, { max_pagesets => $max_pagesets } );
        my $pageset = Data::Page::Pageset->new( $page, { pages_per_set => $pages_per_set } );

        # for using
        foreach my $chunk ( $pageset->total_pagesets ){
               if ( $chunk->is_current ){
                       map { print "$_ " } ( $chunk->first .. $chunk->last );
               }else{
                       print "$chunk ";
               }
        }

METHODS

       new()
            # default page_per_set is 10
            my $pageset = Data::Page::Pageset->new( $page );

            # set the page_per_set to be 12
            my $pageset = Data::Page::Pageset->new( $page, 12 );
            # another the same by passing hashref
            my $pageset = Data::Page::Pageset->new( $page, { pages_per_set => $pages_per_set } );

            # set the max_pagesets value, default is 1
            my $pageset = Data::Page::Pageset->new( $page, { max_pagesets => $max_pagesets } );
            # if max_pagesets supplies, the pages_per_set setting will be ignore
            my $pageset = Data::Page::Pageset->new( $page,
                   { max_pagesets => $max_pagesets, pages_per_set => $pages_per_set } );

           We must need $page(isa Data::Page) object.

       max_pagesets( $number )
            # set the max_pagesets value, and the $pageset's info will changed immediately
            $pageset->max_pagesets( $number );

       pages_per_set( $number )
            # set the pages_per_set value, and the $pageset's info will changed immediately
            $pageset->pages_per_set( $number );
            my $present_setting = $pageset->pages_per_set();

       $pageset->total_pages
           return total pages' number.

       $pageset->total_pagesets
           return the actual pagesets number.

       $pageset->first_pageset
            my $chunk = $pageset->first_pageset;

           return the first pageset, it's Data::Page::Pageset::Chunk object

       $pageset->last_pageset
            my $chunk = $pageset->last_pageset;

           return the last pageset, it's Data::Page::Pageset::Chunk object

       $pageset->current_pageset
            my $chunk = $pageset->current_pageset;

           return the current pageset which current page is in this pageset, it's Data::Page::Pageset::Chunk
           object

       $pageset->previous_pageset
            my $chunk = $pageset->previous_pageset;

           return the previous pageset, it's Data::Page::Pageset::Chunk object

       $pageset->next_pageset
            my $chunk = $pageset->next_pageset;

           return the next pageset, it's Data::Page::Pageset::Chunk object

Data::Page::Pageset::Chunk object

       a $pageset gives you some $chunk to do more stuff as you see above. Here gives the $chunk methods

       first
            # return the first page number in this chunk
            $chunk->first;

       last
            # return the last page number in this chunk
            $chunk->last;

       middle
            # return the middle page number in this chunk
            $chunk->middle;

       pages
            # return the pages number in this chunk
            $chunk->pages;

       is_current
            # return true if this $chunk contains the current_page
            $chunk->is_current;

       as_string
            # if this chunk is from page 3 to 7, then print '3-7'
            print $chunk;
            print $chunk->as_string;
            print $chunk->as_string('-');

            # you can change default '-' as:
            print $chunk->as_string('~');

           if the $chunk only contains one page, it will only return the page number.

SEE ALSO

       Data::Page is what we need, Data::Pageset is the similar one, Template::Plugin::Pageset is the wrapper
       for this to using it more converiently in TT2 tempale.

BUGS

       just mail me to <me@chunzi.org>

COPYRIGHT AND LICENSE

       Copyright 2004 by Chun Sheng.

       This library is free software; you can redistribute it and/or modify it under the same terms as Perl
       itself.

AUTHOR

       Chun Sheng, <me@chunzi.org>