more template variables in nav and pagination

This commit is contained in:
JT Smith 2006-04-15 00:34:02 +00:00
parent 6a2ba37ef1
commit 5136efc983
6 changed files with 128 additions and 32 deletions

View file

@ -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.

View file

@ -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

View file

@ -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;

View file

@ -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 '<a href="'.
$self->session->url->append($self->{_url},($self->{_formVar}.'=1'))
.'">'.$text.'</a>';
my $url = $self->session->url->append($self->{_url},($self->{_formVar}.'=1'));
return wantarray ? ($url,$ctext,'<a href="'.$url.'">'.$text.'</a>') : '<a href="'.$url.'">'.$text.'</a>';
} 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).'&gt;|';
$ctext = $i18n->get(405);
$text = $ctext.'&gt;|';
if ($pn != $self->getNumberOfPages) {
return '<a href="'.
$self->session->url->append($self->{_url},($self->{_formVar}.'='.$self->getNumberOfPages))
.'">'.$text.'</a>';
my $url = $self->session->url->append($self->{_url},($self->{_formVar}.'='.$self->getNumberOfPages));
return wantarray ? ($url,$ctext,'<a href="'.$url.'">'.$text.'</a>') : '<a href="'.$url.'">'.$text.'</a>';
} 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).'&raquo;';
$ctext = $i18n->get(92);
$text = $ctext.'&raquo;';
if ($pn < $self->getNumberOfPages) {
return '<a href="'.$self->session->url->append($self->{_url},($self->{_formVar}.'='.($pn+1))).'">'.$text.'</a>';
my $url = $self->session->url->append($self->{_url},($self->{_formVar}.'='.($pn+1)));
return wantarray ? ($url,$ctext,'<a href="'.$url.'">'.$text.'</a>') : '<a href="'.$url.'">'.$text.'</a>';
} 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,'<a href="'.$self->session->url->append($self->{_url},($self->{_formVar}.'='.($i+1))).'">'.($i+1).'</a>');
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 = '&laquo;'.$i18n->get(91);
$ctext = $i18n->get(91);
$text = '&laquo;'.$ctext;
if ($pn > 1) {
return '<a href="'.$self->session->url->append($self->{_url},($self->{_formVar}.'='.($pn-1))).'">'.$text.'</a>';
my $url = $self->session->url->append($self->{_url},($self->{_formVar}.'='.($pn-1)));
return wantarray ? ($url,$ctext,'<a href="'.$url.'">'.$text.'</a>') : '<a href="'.$url.'">'.$text.'</a>';
} else {
return $text;
return wantarray ? (undef,$ctext,$text) : $text;
}
}
@ -573,4 +596,3 @@ sub setDataByQuery {
1;

View file

@ -226,6 +226,7 @@ a Google sitemap of your site.
<P><STRONG>currentPage.title</STRONG><BR>The title of the start page.</P>
<P><STRONG>currentPage.isHome</STRONG><BR>A conditional indicating whether the base page is the default page for the site.</P>
<P><STRONG>currentPage.url</STRONG><BR>The URL of the start page.</P>
<P><STRONG>currentPage.rank</STRONG><BR>The position of the current page compared to its siblings.</P>
<P><STRONG>currentPage.hasChild</STRONG><BR>A conditional indicating whether the start page has daughters.</P>
<P><STRONG>currentPage.hasSibling</STRONG><BR>A conditional indicating whether the start page has siblings.</P>
<P><STRONG>currentPage.hasViewableSiblings</STRONG><BR>A conditional indicating whether the start page has siblings that are viewable by the current user.</P>
@ -281,7 +282,7 @@ a Google sitemap of your site.
<P dir=ltr><STRONG>page.parent.synopsis</STRONG><BR>The synopsis of the mother of this page.</P>
<P dir=ltr><STRONG>page.parent.newWindow</STRONG><BR>A conditional indicating whether the mother of this page should be opened in a new window.</P>
</BLOCKQUOTE>|,
lastUpdated => 1121933073,
lastUpdated => 1145060204,
},
'1094' => {

View file

@ -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.
<p>
<b>pagination.firstPageUrl</b><br>
The url component of pagination.firstPage broken out.
<p>
<b>pagination.firstPageText</b><br>
The text component of pagination.firstPage broken out.
<p>
<b>pagination.isFirstPage</b><br>
A boolean indicating whether the current page is the first page.
<p>
@ -2230,6 +2238,14 @@ A boolean indicating whether the current page is the first page.
A link to the last page in the paginator.
<p>
<b>pagination.lastPageUrl</b><br>
The url component of pagination.lastPage broken out.
<p>
<b>pagination.lastPageText</b><br>
The text component of pagination.lastPage broken out.
<p>
<b>pagination.isLastPage</b><br>
A boolean indicating whether the current page is the last page.
<p>
@ -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.
<p>
<b>pagination.nextPageUrl</b><br>
The url component of pagination.nextPage broken out.
<p>
<b>pagination.nextPageText</b><br>
The text component of pagination.nextPage broken out.
<p>
<b>pagination.previousPage</b><br>
A link to the previous page in the paginator relative to the current page.
<p>
<b>pagination.previousPageUrl</b><br>
The url component of pagination.previousPage broken out.
<p>
<b>pagination.previousPageText</b><br>
The text component of pagination.previousPage broken out.
<p>
<b>pagination.pageNumber</b><br>
The current page number.
<p>
@ -2258,17 +2291,52 @@ A boolean indicating whether there is more than one page.
A list of links to every page in the paginator.
<p>
<b>pagination.pageLoop</b><br>
Same as pagination.pageList except broken into individual elements.
<blockquote>
<b>pagination.url</b><br>
The URL of page X, where X is the number in the loop we're at.
<p>
<b>pagination.text</b><br>
The number of page X, where X is the number in the loop we're at.
<p>
</blockquote>
<p>
<b>pagination.pageList.upTo20</b><br>
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.
<p>
<b>pagination.pageLoop.upTo20</b><br>
Same as pagination.pageList.upTo20 except broken into individual elements.
<blockquote>
<b>pagination.url</b><br>
The URL of page X, where X is the number in the loop we're at.
<p>
<b>pagination.text</b><br>
The number of page X, where X is the number in the loop we're at.
<p>
</blockquote>
<p>
<b>pagination.pageList.upTo10</b><br>
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.
<p>
<b>pagination.pageLoop.upTo10</b><br>
Same as pagination.pageList.upTo10 except broken into individual elements.
<blockquote>
<b>pagination.url</b><br>
The URL of page X, where X is the number in the loop we're at.
<p>
<b>pagination.text</b><br>
The number of page X, where X is the number in the loop we're at.
<p>
</blockquote>
<p>
|,
lastUpdated => 1102031794,
lastUpdated => 1145060787,
},
'701' => {