From 1b51697dbd499abcf66f3e3e29f2c32262f2f342 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Fri, 26 Oct 2007 16:29:25 +0000 Subject: [PATCH] rfe: Search Asset returns URLs --- docs/changelog/7.x.x.txt | 1 + docs/upgrades/upgrade_7.4.11-7.5.0.pl | 16 +++---- lib/WebGUI/Asset/Wobject/Search.pm | 64 +++++++++++++++---------- lib/WebGUI/i18n/English/Asset_Search.pm | 12 +++++ 4 files changed, 60 insertions(+), 33 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index ae8b47d68..778034c18 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,5 +1,6 @@ 7.5.0 - rfe: Default log level to ERROR + - rfe: Search Asset returns URLs - Added link to return to inbox from message in inbox message template (Diona Kidd, Knowmad Technologies) - fix: Cannot delete private message (Diona Kidd, Knowmad Technologies) - fix: Workflow activities don't pick up new default values diff --git a/docs/upgrades/upgrade_7.4.11-7.5.0.pl b/docs/upgrades/upgrade_7.4.11-7.5.0.pl index 2a9ca925b..88c8729e4 100644 --- a/docs/upgrades/upgrade_7.4.11-7.5.0.pl +++ b/docs/upgrades/upgrade_7.4.11-7.5.0.pl @@ -20,19 +20,19 @@ my $quiet; # this line required my $session = start(); # this line required -# upgrade functions go here addFriendsNetwork($session); +addSearchWithContainers($session); finish($session); # this line required -##------------------------------------------------- -#sub exampleFunction { -# my $session = shift; -# print "\tWe're doing some stuff here that you should know about..." unless $quiet; -# # and here's our code -# print "DONE!\n" unless $quiet; -#} +#------------------------------------------------- +sub addSearchWithContainers { + my $session = shift; + print "\tMaking search capable of displaying containers in search results instead of individaul assets." unless $quiet; + $session->db->write("alter table Search add column useContainers int not null default 0"); + print "DONE!\n" unless $quiet; +} #---------------------------------------------------------------------------- sub addFriendsNetwork { diff --git a/lib/WebGUI/Asset/Wobject/Search.pm b/lib/WebGUI/Asset/Wobject/Search.pm index c2efd45c0..3cb269650 100644 --- a/lib/WebGUI/Asset/Wobject/Search.pm +++ b/lib/WebGUI/Asset/Wobject/Search.pm @@ -72,30 +72,37 @@ sub definition { my %properties; tie %properties, 'Tie::IxHash'; %properties = ( - templateId =>{ - fieldType=>"template", - defaultValue=>'PBtmpl0000000000000200', - tab=>"display", - namespace=>"Search", - hoverHelp=>$i18n->get('search template description'), - label=>$i18n->get('search template') + templateId => { + fieldType => "template", + defaultValue => 'PBtmpl0000000000000200', + tab => "display", + namespace => "Search", + hoverHelp => $i18n->get('search template description'), + label => $i18n->get('search template') }, searchRoot => { - fieldType=>"asset", - defaultValue=>$session->setting->get("defaultPage"), - tab=>"properties", - hoverHelp=>$i18n->get("search root description"), - label=>$i18n->get('search root') + fieldType => "asset", + defaultValue => $session->setting->get("defaultPage"), + tab => "properties", + hoverHelp => $i18n->get("search root description"), + label => $i18n->get('search root') }, classLimiter => { - fieldType => "checkList", - defaultValue => undef, - vertical=>1, - tab=>"properties", - hoverHelp=>$i18n->get("class limiter description"), - label=>$i18n->get("class limiter"), - options=>$session->db->buildHashRef("select distinct(className) from asset") - } + fieldType => "checkList", + defaultValue => undef, + vertical => 1, + tab => "properties", + hoverHelp => $i18n->get("class limiter description"), + label => $i18n->get("class limiter"), + options => $session->db->buildHashRef("select distinct(className) from asset") + }, + useContainers => { + tab => "properties", + hoverHelp => "useContainers help", + label => "useContainers", + fieldType => "yesNo", + defaultValue => 0, + }, ); push(@{$definition}, { assetName=>$i18n->get('assetName'), @@ -156,11 +163,18 @@ sub view { my $rs = $search->getResultSet; while (my $data = $rs->hashRef) { if ($self->session->user->userId eq $data->{ownerUserId} || $self->session->user->isInGroup($data->{groupIdView}) || $self->session->user->isInGroup($data->{groupIdEdit})) { - push(@results, { - url=>$data->{url}, - title=>$data->{title}, - synopsis=>$data->{synopsis}, - assetId=>$data->{assetId}, + my $url = $data->{url}; + if ($self->get("useContainers")) { + my $asset = WebGUI::Asset->new($self->session, $data->{assetId}, $data->{className}); + if (defined $asset) { + $url = $asset->getContainer->get("url"); + } + } + push(@results, { + url => $url, + title => $data->{title}, + synopsis => $data->{synopsis}, + assetId => $data->{assetId}, }); $var{results_found} = 1; } diff --git a/lib/WebGUI/i18n/English/Asset_Search.pm b/lib/WebGUI/i18n/English/Asset_Search.pm index 9941943d7..8923cb374 100644 --- a/lib/WebGUI/i18n/English/Asset_Search.pm +++ b/lib/WebGUI/i18n/English/Asset_Search.pm @@ -2,6 +2,18 @@ package WebGUI::i18n::English::Asset_Search; ##Be sure to change the package na our $I18N = { ##hashref of hashes + 'useContainers' => { + message => q|Use container URLs in results?|, + lastUpdated => 0, + context => q|an asset property| + }, + + 'useContainers help' => { + message => q|Set this to "Yes" if you'd like the search results to return full pages instead of individual assets.|, + lastUpdated => 0, + context => q|an asset property help| + }, + 'search' => { message => q|search|, lastUpdated => 0,