From ab55978f55fc806d4211ad063418d69de28ab24e Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sat, 17 May 2008 18:58:22 +0000 Subject: [PATCH] fixed some keywords bugs took beta label away from event manager added option to shelf to include items below it and items included via keywords --- docs/gotcha.txt | 1 + lib/WebGUI/Asset/Wobject/Shelf.pm | 16 ++++++++-------- lib/WebGUI/Keyword.pm | 11 ++++------- .../i18n/English/Asset_EventManagementSystem.pm | 4 ++-- sbin/testEnvironment.pl | 1 + 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/docs/gotcha.txt b/docs/gotcha.txt index a6aea6195..9f44ba85b 100644 --- a/docs/gotcha.txt +++ b/docs/gotcha.txt @@ -14,6 +14,7 @@ save you many hours of grief. Exception::Class Path::Class Image::ExifTool + List::MoreUtils * WebGUI versions since 7.3.0 (when the new Calendar was added) have allowed users to post Events to Calendars, but the owner of diff --git a/lib/WebGUI/Asset/Wobject/Shelf.pm b/lib/WebGUI/Asset/Wobject/Shelf.pm index ac5fce202..191643f0e 100644 --- a/lib/WebGUI/Asset/Wobject/Shelf.pm +++ b/lib/WebGUI/Asset/Wobject/Shelf.pm @@ -11,6 +11,7 @@ package WebGUI::Asset::Wobject::Shelf; #------------------------------------------------------------------- use strict; +use List::MoreUtils; use Tie::IxHash; use WebGUI::International; use base 'WebGUI::Asset::Wobject'; @@ -90,20 +91,19 @@ sub view { } # get other child skus - my @childSkus = (); - foreach my $child (@{$self->getLineage(['children'],{includeOnlyClasses=>['WebGUI::Asset::Wobject::Shelf']})}) { - my $properties = $child->get; - $child->{url} = $self->getUrl; - push @childSkus, $child; - } + my @childSkus = @{$self->getLineage(['children'],{includeOnlyClasses=>['WebGUI::Asset::Wobject::Shelf']})}; # find products based upon keywords my @keywords = $self->get('keywords'); - my $keywordBasedAsssetIds = WebGUI::Keyword->new($session)->getMatchingAssets({ + my $keywordBasedAssetIds = WebGUI::Keyword->new($session)->getMatchingAssets({ matchAssetKeywords => $self, isa => 'WebGUI::Asset::Sku', }); - $p->setBaseUrl($self->getUrl('func=view')); + + # create paginator + my @products = List::MoreUtils::uniq(@childSkus, @{$keywordBasedAssetIds}); + my $p = WebGUI::Paginator->new($session, $self->getUrl('func=view')); + $p->setDataByArrayRef(\@products); # generate template variables my @skus = (); diff --git a/lib/WebGUI/Keyword.pm b/lib/WebGUI/Keyword.pm index 0075c1868..b37cea246 100644 --- a/lib/WebGUI/Keyword.pm +++ b/lib/WebGUI/Keyword.pm @@ -157,7 +157,7 @@ sub getKeywordsForAsset { return \@keywords; } else { - return join(" ", map({ m/\s/ ? '"' . $_ . '"' : $_ } @keywords)); + return join(" ", map({ (m/\s/) ? '"' . $_ . '"' : $_ } @keywords)); } } @@ -196,7 +196,7 @@ Instead of returning an array reference of assetId's, return a paginator object. sub getMatchingAssets { my ($self, $options) = @_; - + # base query my @clauses = (); my @params = (); @@ -228,13 +228,12 @@ sub getMatchingAssets { } # looking for a list of keywords - if (exists $options->{keywords}) { + if (exists $options->{keywords} && scalar(@{$options->{keywords}})) { my @placeholders = (); foreach my $word (@{$options->{keywords}}){ push @placeholders, '?'; push @params, $word; } - next unless scalar @placeholders; push @clauses, 'keyword in ('.join(',', @placeholders).')'; } @@ -248,9 +247,7 @@ sub getMatchingAssets { $p->setDataByQuery($query, undef, undef, \@params); return $p; } - else { - return $self->session->db->buildArrayRef($query, \@params); - } + return $self->session->db->buildArrayRef($query, \@params); } diff --git a/lib/WebGUI/i18n/English/Asset_EventManagementSystem.pm b/lib/WebGUI/i18n/English/Asset_EventManagementSystem.pm index af5a01485..5a3845775 100644 --- a/lib/WebGUI/i18n/English/Asset_EventManagementSystem.pm +++ b/lib/WebGUI/i18n/English/Asset_EventManagementSystem.pm @@ -423,8 +423,8 @@ our $I18N = { }, 'assetName' => { - message => q|Event Manager (beta)|, - lastUpdated => 1131394072, + message => q|Event Manager|, + lastUpdated => 1211045812, context => q|name of asset|, }, diff --git a/sbin/testEnvironment.pl b/sbin/testEnvironment.pl index cdadde9d1..17f385ee0 100644 --- a/sbin/testEnvironment.pl +++ b/sbin/testEnvironment.pl @@ -126,6 +126,7 @@ checkModule("Image::ExifTool","7.00"); checkModule("Archive::Any","0.093"); checkModule("Path::Class", '0.16'); checkModule("Exception::Class","1.23"); +checkModule("List::MoreUtils","0.22"); ###################################