diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index f1eb1bfee..ef70ac8d8 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -40,6 +40,9 @@ - Added a sort alphabetically option to the folder asset. - Added a symbol next to items in the asset manager to indicate if they have children or not. + - Added more templating options to the Paginator thanks to Jukka Raimovaara. + - Added the currentPage.rank variable to the nav template thanks to Jukka + Raimovaara. - Added a screenshot feature to the matrix. - Added an option to delete Matrix fields. - Added an API for retrieving email from POP3 servers. diff --git a/docs/credits.txt b/docs/credits.txt index 28270f055..3c4442ecf 100644 --- a/docs/credits.txt +++ b/docs/credits.txt @@ -36,6 +36,7 @@ Contributing Developers..............Peter Beardsley / Appropriate Solutions Tony Mountifield Tavis Parker / ParkerOne Consulting Daniel Quinlan + Jukka Raimovaara Alan Ritari / DonorWare Hal Roberts / Harvard Steve Simms diff --git a/lib/WebGUI/Asset/Wobject/Navigation.pm b/lib/WebGUI/Asset/Wobject/Navigation.pm index e3ac2436a..f81090a60 100644 --- a/lib/WebGUI/Asset/Wobject/Navigation.pm +++ b/lib/WebGUI/Asset/Wobject/Navigation.pm @@ -361,6 +361,7 @@ sub view { $var->{'currentPage.isHome'} = ($current->getId eq $self->session->setting->get("defaultPage")); $var->{'currentPage.url'} = $current->getUrl; $var->{'currentPage.hasChild'} = $current->hasChildren; + $var->{'currentPage.rank'} = $current->getRank; my $currentLineage = $current->get("lineage"); my $lineageToSkip = "noskip"; my $absoluteDepthOfLastPage; diff --git a/lib/WebGUI/Paginator.pm b/lib/WebGUI/Paginator.pm index cdc0a5183..8ff28cb38 100644 --- a/lib/WebGUI/Paginator.pm +++ b/lib/WebGUI/Paginator.pm @@ -73,16 +73,28 @@ sub appendTemplateVars { my $var = shift; $var->{'pagination.isFirstPage'} = ($self->getPageNumber == 1); $var->{'pagination.isLastPage'} = ($self->getPageNumber == $self->getNumberOfPages); - $var->{'pagination.firstPage'} = $self->getFirstPageLink; - $var->{'pagination.lastPage'} = $self->getLastPageLink; - $var->{'pagination.nextPage'} = $self->getNextPageLink; - $var->{'pagination.previousPage'} = $self->getPreviousPageLink; + ($var->{'pagination.firstPageUrl'}, + $var->{'pagination.firstPageText'}, + $var->{'pagination.firstPage'}) = $self->getFirstPageLink; + + ($var->{'pagination.lastPageUrl'}, + $var->{'pagination.lastPageText'}, + $var->{'pagination.lastPage'}) = $self->getLastPageLink; + + ($var->{'pagination.nextPageUrl'}, + $var->{'pagination.nextPageText'}, + $var->{'pagination.nextPage'}) = $self->getNextPageLink; + + ($var->{'pagination.previousPageUrl'}, + $var->{'pagination.previousPageText'}, + $var->{'pagination.previousPage'}) = $self->getPreviousPageLink; + $var->{'pagination.pageNumber'} = $self->getPageNumber; $var->{'pagination.pageCount'} = $self->getNumberOfPages; $var->{'pagination.pageCount.isMultiple'} = ($self->getNumberOfPages > 1); - $var->{'pagination.pageList'} = $self->getPageLinks; - $var->{'pagination.pageList.upTo10'} = $self->getPageLinks(10); - $var->{'pagination.pageList.upTo20'} = $self->getPageLinks(20); + ($var->{'pagination.pageLoop'},$var->{'pagination.pageList'}) = $self->getPageLinks; + ($var->{'pagination.pageLoop.upTo10'},$var->{'pagination.pageList.upTo10'}) = $self->getPageLinks(10); + ($var->{'pagination.pageLoop.upTo20'},$var->{'pagination.pageList.upTo20'}) = $self->getPageLinks(20); } @@ -215,16 +227,16 @@ Returns a link to the first page's data. sub getFirstPageLink { my ($self) = @_; - my ($text, $pn); + my ($text, $pn, $ctext); $pn = $self->getPageNumber; my $i18n = WebGUI::International->new($self->session); - $text = '|<'.$i18n->get(404); + $ctext = $i18n->get(404); + $text = '|<'.$ctext; if ($pn > 1) { - return ''.$text.''; + my $url = $self->session->url->append($self->{_url},($self->{_formVar}.'=1')); + return wantarray ? ($url,$ctext,''.$text.'') : ''.$text.''; } else { - return $text; + return wantarray ? (undef,$ctext,$text) : $text; } } @@ -239,16 +251,16 @@ Returns a link to the last page's data. sub getLastPageLink { my ($self) = @_; - my ($text, $pn); + my ($text, $pn, $ctext); $pn = $self->getPageNumber; my $i18n = WebGUI::International->new($self->session); - $text = $i18n->get(405).'>|'; + $ctext = $i18n->get(405); + $text = $ctext.'>|'; if ($pn != $self->getNumberOfPages) { - return ''.$text.''; + my $url = $self->session->url->append($self->{_url},($self->{_formVar}.'='.$self->getNumberOfPages)); + return wantarray ? ($url,$ctext,''.$text.'') : ''.$text.''; } else { - return $text; + return wantarray ? (undef,$ctext,$text) : $text; } } @@ -263,14 +275,16 @@ Returns a link to the next page's data. sub getNextPageLink { my ($self) = @_; - my ($text, $pn); + my ($text, $pn, $ctext); $pn = $self->getPageNumber; my $i18n = WebGUI::International->new($self->session); - $text = $i18n->get(92).'»'; + $ctext = $i18n->get(92); + $text = $ctext.'»'; if ($pn < $self->getNumberOfPages) { - return ''.$text.''; + my $url = $self->session->url->append($self->{_url},($self->{_formVar}.'='.($pn+1))); + return wantarray ? ($url,$ctext,''.$text.'') : ''.$text.''; } else { - return $text; + return wantarray ? (undef,$ctext,$text) : $text; } } @@ -365,11 +379,16 @@ sub getPageLinks { my $limit = shift; my $pn = $self->getPageNumber; my @pages; + my @pages_loop; for (my $i=0; $i<$self->getNumberOfPages; $i++) { if ($i+1 == $pn) { push(@pages,($i+1)); + push(@pages_loop,{ "pagination.url" => '', "pagination.text" => $i+1}); + } else { push(@pages,''.($i+1).''); + push(@pages_loop,{ "pagination.url" => $self->session->url->append($self->{_url},($self->{_formVar}.'='.($i+1))), "pagination.text" => $i+1}); + } } if ($limit) { @@ -379,15 +398,17 @@ sub getPageLinks { my $maxPage = $minPage + $limit; my $start = ($minPage > 0) ? $minPage : 1; my $end = ($maxPage < $self->getPageNumber) ? $self->getPageNumber : $maxPage; + my @temp; foreach my $page (@pages) { if ($i <= $end && $i >= $start) { $output .= $page.' '; + push(@temp, $pages_loop[$i-1]); } $i++; } - return $output; + return wantarray ? (\@temp,$output) : $output; } else { - return join(" ",@pages); + return wantarray ? (\@pages_loop,join(" ",@pages)) : join(" ",@pages); } } @@ -402,14 +423,16 @@ Returns a link to the previous page's data. sub getPreviousPageLink { my ($self) = @_; - my ($text, $pn); + my ($text, $pn, $ctext); $pn = $self->getPageNumber; my $i18n = WebGUI::International->new($self->session); - $text = '«'.$i18n->get(91); + $ctext = $i18n->get(91); + $text = '«'.$ctext; if ($pn > 1) { - return ''.$text.''; + my $url = $self->session->url->append($self->{_url},($self->{_formVar}.'='.($pn-1))); + return wantarray ? ($url,$ctext,''.$text.'') : ''.$text.''; } else { - return $text; + return wantarray ? (undef,$ctext,$text) : $text; } } @@ -573,4 +596,3 @@ sub setDataByQuery { 1; - diff --git a/lib/WebGUI/i18n/English/Asset_Navigation.pm b/lib/WebGUI/i18n/English/Asset_Navigation.pm index 9ddd57e5c..7e88a9e18 100644 --- a/lib/WebGUI/i18n/English/Asset_Navigation.pm +++ b/lib/WebGUI/i18n/English/Asset_Navigation.pm @@ -226,6 +226,7 @@ a Google sitemap of your site.

currentPage.title
The title of the start page.

currentPage.isHome
A conditional indicating whether the base page is the default page for the site.

currentPage.url
The URL of the start page.

+

currentPage.rank
The position of the current page compared to its siblings.

currentPage.hasChild
A conditional indicating whether the start page has daughters.

currentPage.hasSibling
A conditional indicating whether the start page has siblings.

currentPage.hasViewableSiblings
A conditional indicating whether the start page has siblings that are viewable by the current user.

@@ -281,7 +282,7 @@ a Google sitemap of your site.

page.parent.synopsis
The synopsis of the mother of this page.

page.parent.newWindow
A conditional indicating whether the mother of this page should be opened in a new window.

|, - lastUpdated => 1121933073, + lastUpdated => 1145060204, }, '1094' => { diff --git a/lib/WebGUI/i18n/English/WebGUI.pm b/lib/WebGUI/i18n/English/WebGUI.pm index 54e077b93..9819dcccf 100644 --- a/lib/WebGUI/i18n/English/WebGUI.pm +++ b/lib/WebGUI/i18n/English/WebGUI.pm @@ -2221,6 +2221,14 @@ As with any delete operation, you are prompted to be sure you wish to proceed wi A link to the first page in the paginator.

+pagination.firstPageUrl
+The url component of pagination.firstPage broken out. +

+ +pagination.firstPageText
+The text component of pagination.firstPage broken out. +

+ pagination.isFirstPage
A boolean indicating whether the current page is the first page.

@@ -2230,6 +2238,14 @@ A boolean indicating whether the current page is the first page. A link to the last page in the paginator.

+pagination.lastPageUrl
+The url component of pagination.lastPage broken out. +

+ +pagination.lastPageText
+The text component of pagination.lastPage broken out. +

+ pagination.isLastPage
A boolean indicating whether the current page is the last page.

@@ -2238,10 +2254,27 @@ A boolean indicating whether the current page is the last page. A link to the next page in the paginator relative to the current page.

+pagination.nextPageUrl
+The url component of pagination.nextPage broken out. +

+ +pagination.nextPageText
+The text component of pagination.nextPage broken out. +

+ pagination.previousPage
A link to the previous page in the paginator relative to the current page.

+pagination.previousPageUrl
+The url component of pagination.previousPage broken out. +

+ +pagination.previousPageText
+The text component of pagination.previousPage broken out. +

+ + pagination.pageNumber
The current page number.

@@ -2258,17 +2291,52 @@ A boolean indicating whether there is more than one page. A list of links to every page in the paginator.

+pagination.pageLoop
+Same as pagination.pageList except broken into individual elements. +

+pagination.url
+The URL of page X, where X is the number in the loop we're at. +

+pagination.text
+The number of page X, where X is the number in the loop we're at. +

+

+

+ pagination.pageList.upTo20
A list of links to the 20 nearest in the paginator relative to the current page. So if you're on page 60, you'll see links for 50-70.

+pagination.pageLoop.upTo20
+Same as pagination.pageList.upTo20 except broken into individual elements. +

+pagination.url
+The URL of page X, where X is the number in the loop we're at. +

+pagination.text
+The number of page X, where X is the number in the loop we're at. +

+

+

+ pagination.pageList.upTo10
A list of links to the 10 nearest in the paginator relative to the current page. So if you're on page 20, you'll see links for 15-25.

+pagination.pageLoop.upTo10
+Same as pagination.pageList.upTo10 except broken into individual elements. +

+pagination.url
+The URL of page X, where X is the number in the loop we're at. +

+pagination.text
+The number of page X, where X is the number in the loop we're at. +

+

+

|, - lastUpdated => 1102031794, + lastUpdated => 1145060787, }, '701' => {