Handle linking to posts not on the first page on a thread view. Fixes bug #11318.
This commit is contained in:
parent
7281a3dd8e
commit
173bec1574
3 changed files with 31 additions and 11 deletions
|
|
@ -495,6 +495,33 @@ sub getDeleteUrl {
|
|||
return $self->getUrl("func=delete;revision=".$self->get("revisionDate"));
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDirectLinkUrl ( )
|
||||
|
||||
Returns the URL for this Post, which links directly to its anchor and page.
|
||||
|
||||
=cut
|
||||
|
||||
sub getDirectLinkUrl {
|
||||
my $self = shift;
|
||||
my $url;
|
||||
my $page_size = $self->getThread->getParent->get('postsPerPage');
|
||||
my $place = $self->getRank+1;
|
||||
my $page = int($place/$page_size) + 1;
|
||||
my $page_frag = 'pn='.$page;
|
||||
if ($self->get("status") eq "pending") {
|
||||
$url = $self->getUrl($page_frag.";revision=".$self->get("revisionDate"));
|
||||
}
|
||||
else {
|
||||
$url = $self->getUrl($page_frag);
|
||||
}
|
||||
$url .= "#id".$self->getId;
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getEditUrl ( )
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ sub appendPostListTemplateVars {
|
|||
if ($self->get("displayLastReply")) {
|
||||
my $lastPost = $post->getLastPost();
|
||||
%lastReply = (
|
||||
"lastReply.url" => $lastPost->getUrl.'#id'.$lastPost->getId,
|
||||
"lastReply.url" => $lastPost->getDirectLinkUrl,
|
||||
"lastReply.title" => $lastPost->get("title"),
|
||||
"lastReply.user.isVisitor" => $lastPost->get("ownerUserId") eq "1",
|
||||
"lastReply.username" => $lastPost->get("username"),
|
||||
|
|
@ -142,17 +142,10 @@ sub appendPostListTemplateVars {
|
|||
}
|
||||
$hasRead = $post->isMarkedRead;
|
||||
}
|
||||
my $url;
|
||||
if ($post->get("status") eq "pending") {
|
||||
$url = $post->getUrl("revision=".$post->get("revisionDate"))."#id".$post->getId;
|
||||
}
|
||||
else {
|
||||
$url = $post->getUrl."#id".$post->getId;
|
||||
}
|
||||
my %postVars = (
|
||||
%{$post->get},
|
||||
"id" => $post->getId,
|
||||
"url" => $url,
|
||||
"url" => $post->getDirectLinkUrl,
|
||||
rating_loop => \@rating_loop,
|
||||
"content" => $post->formatContent,
|
||||
"status" => $post->getStatus,
|
||||
|
|
|
|||
|
|
@ -89,8 +89,8 @@ ok( !$posts->[0]->{'user.isVisitor'}, 'first post made by visitor');
|
|||
ok( $posts->[0]->{'hideProfileUrl'}, 'hide profile url, and user is visitor');
|
||||
ok( !$posts->[0]->{'lastReply.user.isVisitor'}, 'lastReply not made by visitor');
|
||||
ok( $posts->[0]->{'lastReply.hideProfileUrl'}, 'lastReply hide profile url, since user is visitor');
|
||||
is( $posts->[0]->{'lastReply.url'}, $threads[1]->getUrl.'#id'.$threads[1]->getId, 'lastReply url has a query fragment prefixed by "id"');
|
||||
is( $posts->[0]->{'url'}, $threads[1]->getUrl.'#id'.$threads[1]->getId, 'url has a query fragment prefixed by "id"');
|
||||
is( $posts->[0]->{'lastReply.url'}, $threads[1]->getUrl.'?pn=1#id'.$threads[1]->getId, 'lastReply url has a query fragment prefixed by "id"');
|
||||
is( $posts->[0]->{'url'}, $threads[1]->getUrl.'?pn=1#id'.$threads[1]->getId, 'url has a query fragment prefixed by "id"');
|
||||
|
||||
|
||||
###################################################################
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue