Fix Search results for Threads when useContainers=1
This commit is contained in:
parent
25aad27cdb
commit
3a054b4895
7 changed files with 106 additions and 19 deletions
|
|
@ -497,13 +497,13 @@ sub getDeleteUrl {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDirectLinkUrl ( )
|
||||
=head2 getThreadLinkUrl ( )
|
||||
|
||||
Returns the URL for this Post, which links directly to its anchor and page.
|
||||
|
||||
=cut
|
||||
|
||||
sub getDirectLinkUrl {
|
||||
sub getThreadLinkUrl {
|
||||
my $self = shift;
|
||||
my $url;
|
||||
my $page_size = $self->getThread->getParent->get('postsPerPage');
|
||||
|
|
|
|||
|
|
@ -340,15 +340,39 @@ sub getAutoCommitWorkflowId {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDirectLinkUrl ( )
|
||||
=head2 getCSLinkUrl ( )
|
||||
|
||||
This URL links to the page of the CS containing this thread, similar
|
||||
to the getThreadLink for the Post. It does not contain the gateway
|
||||
for the site.
|
||||
|
||||
=cut
|
||||
|
||||
sub getCSLinkUrl {
|
||||
my $self = shift;
|
||||
my $url;
|
||||
my $cs = $self->getParent;
|
||||
my $page_size = $cs->get('threadsPerPage');
|
||||
my $place = $self->getRank+1;
|
||||
my $last_place = $cs->getLastChild->getRank+1;
|
||||
my $page = int(($last_place - $place)/$page_size) + 1;
|
||||
my $page_frag = 'pn='.$page.';sortBy=lineage;sortOrder=desc';
|
||||
$url = $self->session->url->append($cs->get('url'), $page_frag);
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getThreadLinkUrl ( )
|
||||
|
||||
Extend the base method from Post to remove the pagination query fragment
|
||||
|
||||
=cut
|
||||
|
||||
sub getDirectLinkUrl {
|
||||
sub getThreadLinkUrl {
|
||||
my $self = shift;
|
||||
my $url = $self->SUPER::getDirectLinkUrl();
|
||||
my $url = $self->SUPER::getThreadLinkUrl();
|
||||
$url =~ s/\?pn=\d+//;
|
||||
if ($url =~ m{;revision=\d+}) {
|
||||
$url =~ s/;revision/?revision/;
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ sub appendPostListTemplateVars {
|
|||
if ($self->get("displayLastReply")) {
|
||||
my $lastPost = $post->getLastPost();
|
||||
%lastReply = (
|
||||
"lastReply.url" => $lastPost->getDirectLinkUrl,
|
||||
"lastReply.url" => $lastPost->getThreadLinkUrl,
|
||||
"lastReply.title" => $lastPost->get("title"),
|
||||
"lastReply.user.isVisitor" => $lastPost->get("ownerUserId") eq "1",
|
||||
"lastReply.username" => $lastPost->get("username"),
|
||||
|
|
@ -145,7 +145,7 @@ sub appendPostListTemplateVars {
|
|||
my %postVars = (
|
||||
%{$post->get},
|
||||
"id" => $post->getId,
|
||||
"url" => $post->getDirectLinkUrl,
|
||||
"url" => $post->getThreadLinkUrl,
|
||||
rating_loop => \@rating_loop,
|
||||
"content" => $post->formatContent,
|
||||
"status" => $post->getStatus,
|
||||
|
|
@ -1161,10 +1161,14 @@ Collaboration System
|
|||
sub getThreadsPaginator {
|
||||
my $self = shift;
|
||||
|
||||
my $scratchSortBy = $self->getId."_sortBy";
|
||||
my $scratchSortBy = $self->getId."_sortBy";
|
||||
my $scratchSortOrder = $self->getId."_sortDir";
|
||||
my $sortBy = $self->session->form->process("sortBy") || $self->session->scratch->get($scratchSortBy) || $self->get("sortBy");
|
||||
my $sortOrder = $self->session->scratch->get($scratchSortOrder) || $self->get("sortOrder");
|
||||
my $sortBy = $self->session->form->process("sortBy")
|
||||
|| $self->session->scratch->get($scratchSortBy)
|
||||
|| $self->get("sortBy");
|
||||
my $sortOrder = $self->session->form->process("sortOrder")
|
||||
|| $self->session->scratch->get($scratchSortOrder)
|
||||
|| $self->get("sortOrder");
|
||||
if ($sortBy ne $self->session->scratch->get($scratchSortBy) && $self->session->form->process("func") ne "editSave") {
|
||||
$self->session->scratch->set($scratchSortBy,$self->session->form->process("sortBy"));
|
||||
$self->session->scratch->set($scratchSortOrder, $sortOrder);
|
||||
|
|
|
|||
|
|
@ -220,7 +220,8 @@ sub view {
|
|||
if (defined $asset) {
|
||||
my $properties = $asset->get;
|
||||
if ($self->get("useContainers")) {
|
||||
$properties->{url} = $asset->getContainer->get("url");
|
||||
$properties->{url} = $asset->isa('WebGUI::Asset::Post::Thread') ? $asset->getCSLinkUrl()
|
||||
: $asset->getContainer->get("url");
|
||||
}
|
||||
#Add highlighting
|
||||
$properties->{'title' } = $hl->highlight($properties->{title} || '');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue