From 3c5a801a2926f67497b7382f882769b398814b21 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Thu, 4 Oct 2007 20:51:25 +0000 Subject: [PATCH] localize matrix good bad field --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/Wobject/Matrix.pm | 36 +++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index c2a683903..7f901cb18 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -8,6 +8,7 @@ - fix: Calendar generated iCal for last 30 days instead of next 30 days - fix: hover help doesn't appear for matrix fields - Collaboration systems should always tell browser there is new content + - fix: Good Bad fields not properly localized 7.4.8 - fix: Syndicated Content doesn't display all items with multiple feeds in interleaved mode diff --git a/lib/WebGUI/Asset/Wobject/Matrix.pm b/lib/WebGUI/Asset/Wobject/Matrix.pm index 877951279..bf56af92b 100644 --- a/lib/WebGUI/Asset/Wobject/Matrix.pm +++ b/lib/WebGUI/Asset/Wobject/Matrix.pm @@ -281,6 +281,14 @@ sub www_compare { unless (scalar(@cmsList)) { @cmsList = $self->session->form->checkList("listingId"); } + my ($style, $url) = ($self->session->style, $self->session->url); + $style->setLink($url->extras('/yui/build/container/assets/container.css'),{ type=>'text/css', rel=>"stylesheet" }); + $style->setLink($url->extras('/hoverhelp.css'),{ type=>'text/css', rel=>"stylesheet" }); + $style->setScript($url->extras('/yui/build/yahoo/yahoo-min.js'),{ type=>'text/javascript' }); + $style->setScript($url->extras('/yui/build/dom/dom-min.js'),{ type=>'text/javascript' }); + $style->setScript($url->extras('/yui/build/event/event-min.js'),{ type=>'text/javascript' }); + $style->setScript($url->extras('/yui/build/container/container-min.js'),{ type=>'text/javascript' }); + $style->setScript($url->extras('/hoverhelp.js'),{ type=>'text/javascript' }); my ( %var, @prodcol, @datecol); my $max = $self->session->user->isInGroup($self->get("privilegedGroup")) ? $self->get("maxComparisonsPrivileged") : $self->get("maxComparisons"); $var{isTooMany} = (scalar(@cmsList)>$max); @@ -303,12 +311,20 @@ sub www_compare { lastUpdated=>$self->session->datetime->epochToHuman($data->{lastUpdated},"%z") }); } + my $i18n = WebGUI::International->new($self->session,'Asset_Matrix'); + my %goodBad = ( + "No" => $i18n->get("no"), + "Yes" => $i18n->get("yes"), + "Free Add On" => $i18n->get("free"), + "Costs Extra" => $i18n->get("extra"), + "Limited" => $i18n->get("limited"), + ); $var{product_loop} = \@prodcol; $var{lastupdated_loop} = \@datecol; my @categoryloop; foreach my $category ($self->getCategories()) { my @rowloop; - my $select = "select a.label, a.description"; + my $select = "select a.fieldType, a.label, a.description"; my $from = "from Matrix_field a"; my $tableCount = "b"; foreach my $cms (@cmsList) { @@ -321,6 +337,7 @@ sub www_compare { while (my @row = $sth->array) { my @columnloop; my $first = 1; + my $type = shift @row; foreach my $value (@row) { my $desc = ""; if ($first) { @@ -328,6 +345,9 @@ sub www_compare { shift(@row); $first = 0; } + elsif ($type eq 'goodBad') { + $value = $goodBad{$value}; + } my $class = lc($value); $class =~ s/\s/_/g; $class =~ s/\W//g; @@ -1206,12 +1226,22 @@ sub www_viewDetail { $var{views} = $listing->{views}; $var{compares} = $listing->{compares}; $var{clicks} = $listing->{clicks}; - my $sth = $self->session->db->read("select a.value, b.name, b.label, b.description, category from Matrix_listingData a left join + my $sth = $self->session->db->read("select a.value, b.name, b.label, b.description, category, fieldType from Matrix_listingData a left join Matrix_field b on a.fieldId=b.fieldId and b.assetId=? where listingId=? order by b.label",[$self->getId, $listingId]); - while (my $data = $sth->hashRef) { + my %goodBad = ( + "No" => $i18n->get("no"), + "Yes" => $i18n->get("yes"), + "Free Add On" => $i18n->get("free"), + "Costs Extra" => $i18n->get("extra"), + "Limited" => $i18n->get("limited"), + ); + while (my $data = $sth->hashRef) { $data->{class} = lc($data->{value}); $data->{class} =~ s/\s/_/g; $data->{class} =~ s/\W//g; + if ($data->{fieldType} eq 'goodBad') { + $data->{value} = $goodBad{$data->{value}}; + } my $cat = $self->session->url->urlize($data->{category})."_loop"; push(@{$var{$cat}},$data); }