From 57d5ea36a1d934c3291c94c303e24c55d8233c64 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Wed, 5 Apr 2006 04:45:20 +0000 Subject: [PATCH] speeding up next/previous threads by only calculating them when necessary --- lib/WebGUI/Asset/Post/Thread.pm | 42 +++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/lib/WebGUI/Asset/Post/Thread.pm b/lib/WebGUI/Asset/Post/Thread.pm index 485d185a6..4aa72fef7 100644 --- a/lib/WebGUI/Asset/Post/Thread.pm +++ b/lib/WebGUI/Asset/Post/Thread.pm @@ -812,7 +812,6 @@ sub view { $replyVars{depth} = $reply->getLineageLength - $self->getLineageLength; $replyVars{depthX10} = $replyVars{depth}*10; my @depth_loop; - #@{$replyVars{indent_loop}} = {}; for (my $i=0; $i<$replyVars{depth}; $i++) { push(@{$replyVars{indent_loop}},{depth=>$i}); } @@ -821,10 +820,8 @@ sub view { $p->appendTemplateVars($var); $var->{'add.url'} = $self->getParent->getNewThreadUrl; - my $previous = $self->getPreviousThread; - $var->{"previous.url"} = $previous->getUrl if (defined $previous); - my $next = $self->getNextThread; - $var->{"next.url"} = $next->getUrl if (defined $next); + $var->{"previous.url"} = $self->getUrl("func=previousThread"); + $var->{"next.url"} = $self->getUrl("func=nextThread"); $var->{"search.url"} = $self->getParent->getSearchUrl; $var->{"collaboration.url"} = $self->getThread->getParent->getUrl; @@ -864,6 +861,41 @@ sub www_lockThread { #------------------------------------------------------------------- +=head2 www_nextThread ( ) + +Displays the next logical thread after this one. + +=cut + +sub www_nextThread { + my $self = shift; + my $next = $self->getNextThread; + if (defined $next) { + return $next->www_view; + } + return $self->getParent->www_view; +} + + +#------------------------------------------------------------------- + +=head2 www_previousThread ( ) + +Displays the previous logical thread before this one. + +=cut + +sub www_previousThread { + my $self = shift; + my $previous = $self->getPreviousThread; + if (defined $previous) { + return $previous->www_view; + } + return $self->getParent->www_view; +} + +#------------------------------------------------------------------- + =head2 www_stick ( ) The web method to make a thread sticky.