NAME
Data::Page::Pagination - calculates the pagination view
VERSION
0.006
SYNOPSIS
require Data::Page::Pagination;
require Data::Page;
my $p = Data::Page::Pagination->new(
page => Data::Page->new(110, 10, 6),
page_numbers => 11,
);
$p->visible_previous_page; # 5< ( $p->previous_page )
$p->visible_first_page; # 1 ( $p->first_page )
$p->visible_hidden_previous; # ..
@{ $p->previous_pages }; # 3 4 5 ( max_length = $p->max_list_length )
$p->page->current_page; # 6 ( $p->current_page )
@{ $p->next_pages }; # 7 8 9 ( max_length = $p->max_list_length )
$p->visible_hidden_next, # ..
$p->visible_last_page; # 11 ( $p->last_page )
$p->visible_next_page; # >7 ( $p->next_page )
$p->render_plaintext eq '5< 1 .. 3 4 5 [6] 7 8 9 .. 11 >7';
EXAMPLE
Inside of this Distribution is a directory named example. Run this *.pl files.
DESCRIPTION
This module calculates the pagination view using a Date::Page object. The provided methods are simple enough to use them in a template system.
SUBROUTINES/METHODS
method new
"page_numbers" is the count of pages for directly access.
my $pagination = Data::Page::Pagination->new(
page => Data::Page->new(...),
page_numbers => $integer_greater_than_2,
);
method current_page
Returns the number of the current page
$positive_integer = $pagination->current_page;
method max_list_length
Returns the maximal length of the list that can be left or right of the current page.
$positive_integer_or_zero = $pagination->max_list_length;
method visible_previous_page, visible_last_page
Returns boolean true if there is a previous/last page.
$boolean = $pagination->visible_previous_page;
$boolean = $pagination->visible_last_page;
method previous_page, last_page
Returns the number of the previous/last page.
$positive_integer = $pagination->previous_page;
$positive_integer = $pagination->last_page;
method visible_first_page, visible_last_page
Returns boolean true if the current page is not the fist/last page.
$boolean = $pagination->visible_first_page;
$boolean = $pagination->visible_last_page;
method first_page, last_page
Returns the number of the first/last page.
$positive_integer = $pagination->first_page;
$positive_integer = $pagination->last_page;
method visible_hidden_previous, visible_hidden_next
Returns boolean true if more pages then max_list_length pages are between first/last page and current page.
$boolean = $pagination->visible_hiddden_previous;
$boolean = $pagination->visible_hiddden_next;
method previous_pages, next_pages
Returns the page numbers before/after the current page, not more then max_list_length.
$array_ref = $pagination->previous_pages;
$array_ref = $pagination->next_pages;
method render_plaintext
Returns the test output.
$string = $pagination->render_plaintext;
DIAGNOSTICS
Moose exceptions
CONFIGURATION AND ENVIRONMENT
nothing
DEPENDENCIES
INCOMPATIBILITIES
none
BUGS AND LIMITATIONS
not known
SEE ALSO
AUTHOR
Steffen Winkler
LICENSE AND COPYRIGHT
Copyright (c) 2012 - 2015, Steffen Winkler <steffenw at cpan.org>
. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.