diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt
index 28e42accf..90553ab52 100644
--- a/docs/changelog/7.x.x.txt
+++ b/docs/changelog/7.x.x.txt
@@ -38,6 +38,7 @@
- rfe: Thingy can now copy thingy entries
- Added a switch to subscriptions so that they can be also non-recurring to
facilitate eg. limited time meberships (Martin Kamerbeek / Oqapi)
+ - Replaced Matrix with newer version
7.6.3
- improved performance of file uploads
diff --git a/docs/upgrades/upgrade_7.6.3-7.6.4.pl b/docs/upgrades/upgrade_7.6.3-7.6.4.pl
index 1a3135262..09f1f179c 100644
--- a/docs/upgrades/upgrade_7.6.3-7.6.4.pl
+++ b/docs/upgrades/upgrade_7.6.3-7.6.4.pl
@@ -41,8 +41,134 @@ removeProcessRecurringPaymentsFromConfig( $session );
addExtendedProfilePrivileges( $session );
addStorageUrlMacro( $session );
addRecurringSubscriptionSwitch( $session );
+upgradeMatrix( $session );
finish($session); # this line required
+#----------------------------------------------------------------------------
+sub upgradeMatrix {
+ my $session = shift;
+ print "\tUpgrading matrix assets... \n" unless $quiet;
+ my $db = $session->db;
+ $db->write("alter table Matrix drop column groupToRate, drop column groupToAdd, drop column privilegedGroup,
+ drop column ratingTimeout, drop column ratingTimeoutPrivileged, drop column ratingDetailTemplateId,
+ drop column visitorCacheTimeout");
+ $db->write("alter table Matrix add column defaultSort char(22) not null default 'score',
+ add column compareColorNo char(22) default '#ffaaaa',
+ add column compareColorLimited char(22) not null default '#ffffaa',
+ add column compareColorCostsExtra char(22) not null default '#ffffaa',
+ add column compareColorFreeAddOn char(22) not null default '#ffffaa',
+ add column compareColorYes char(22) not null default '#aaffaa',
+ add column submissionApprovalWorkflowId char(22) not null,
+ add column ratingsDuration int(11) not null default 7776000");
+ $db->write("create table MatrixListing (
+ assetId char(22) binary not null,
+ revisionDate bigint not null,
+ screenshots char(22),
+ description text,
+ version char(255),
+ views int(11),
+ compares int(11),
+ clicks int(11),
+ viewsLastIp char(255),
+ comparesLastIp char(255),
+ clicksLastIp char(255),
+ lastUpdated int(11),
+ maintainer char(22),
+ manufacturerName char(255),
+ manufacturerURL char(255),
+ productURL char(255),
+ score int(11),
+ primary key (assetId, revisionDate)
+ )");
+ $db->write("create table MatrixListing_attribute (
+ matrixId char(22) not null,
+ matrixListingId char(22) not null,
+ attributeId char(22) not null,
+ value char(255),
+ primary key (matrixId, matrixListingId, attributeId)
+ )");
+ $db->write("alter table Matrix_rating rename MatrixListing_rating");
+ $db->write("alter table Matrix_ratingSummary rename MatrixListing_ratingSummary");
+ $db->write("alter table Matrix_field rename Matrix_attribute");
+ $db->write("alter table Matrix_attribute drop column label");
+ $db->write("alter table Matrix_attribute add column options text");
+ $db->write("alter table Matrix_attribute change fieldType fieldType char(255) not null default 'MatrixCompare'");
+ $db->write("alter table Matrix_attribute change fieldId attributeId char(22) not null");
+ $db->write("update Matrix_attribute set fieldType = 'MatrixCompare' where fieldType = 'GoodBad'");
+ $db->write("update Matrix_attribute set fieldType = 'Combo' where fieldType != 'MatrixCompare'");
+ $db->write("update Matrix_listingData set value = 0 where value = 'No'");
+ $db->write("update Matrix_listingData set value = 1 where value = 'Limited'");
+ $db->write("update Matrix_listingData set value = 2 where value = 'Costs Extra'");
+ $db->write("update Matrix_listingData set value = 3 where value = 'Free Add On'");
+ $db->write("update Matrix_listingData set value = 4 where value = 'Yes'");
+
+ # get existing Matrix wobjects
+ my $matrices = WebGUI::Asset->getRoot($session)->getLineage(['descendants'],
+ {
+ statesToInclude => ['published','trash','clipboard','clipboard-limbo','trash-limbo'],
+ statusToInclude => ['pending','approved','deleted','archived'],
+ includeOnlyClasses => ['WebGUI::Asset::Wobject::Matrix'],
+ returnObjects => 1,
+ });
+
+ for my $matrix (@{$matrices})
+ {
+ next unless defined $matrix;
+ # If the asset is in the trash, ignore the migration, we're just going
+ # to purge it.
+ if ($matrix->get("state") =~ m/trash/) {
+ $matrix->purge;
+ next;
+ }
+
+ # get listings for each Matrix
+ my @listings = @{ $db->buildArrayRefOfHashRefs("select * from Matrix_listing where assetId =?",[$matrix->getId]) };
+ foreach my $listing (@listings){
+ # add MatrixListing asset for each listing
+ print "Migrating listing: ".$listing->{productName}."\n" unless $quiet;;
+ $listing->{className} = 'WebGUI::Asset::MatrixListing';
+ $listing->{assetId} = 'new';
+ $listing->{title} = $listing->{productName};
+ $listing->{version} = $listing->{versionNumber};
+ $listing->{screenshots} = $listing->{storageId};
+ $listing->{productURL} = $listing->{productUrl};
+ $listing->{manufacturerURL} = $listing->{manufacturerUrl};
+ my $newMatrixListing = $matrix->addChild($listing,undef,undef,{skipAutoCommitWorkflows=>1});
+ # get listingData for each listing
+ my $listingData = $db->buildArrayRefOfHashRefs("select * from Matrix_listingData where listingId =?",[$listing->{listingId}]);
+ # add listing attribute for each listing field
+ foreach my $attribute (@{$listingData}){
+ $db->write("insert into MatrixListing_attribute (matrixId, matrixListingId, attributeId, value) values
+ (?,?,?,?)",[$matrix->getId,$newMatrixListing->getId,$attribute->{fieldId},$attribute->{value}]);
+ }
+ # update listingIds to MatrixListingIds in MatrixListing_rating/Summary tables
+ $db->write("update MatrixListing_rating set listingId = ? where listingId =?",
+ [$newMatrixListing->getId,$listing->{listingId}]);
+ $db->write("update MatrixListing_ratingSummary set listingId = ? where listingId =?",
+ [$newMatrixListing->getId,$listing->{listingId}]);
+ # migrate comments
+ if($listing->{forumId}){
+ my $forum = WebGUI::Asset::Wobject::Collaboration->new($session, $listing->{forumId});
+ my @comments = @{ $forum->getLineage(['descendants'], {
+ includeOnlyClasses => ["WebGUI::Asset::Post", "WebGUI::Asset::Post::Thread"],
+ returnObjects => 1,
+ }) };
+ foreach my $comment (@comments){
+ # add comment
+ my $content = $comment->get('content');
+ $content =~ s/^
//;
+ $content =~ s/<\/p>//;
+ my $ownerUser = WebGUI::User->new($session,$comment->get('ownerUserId'));
+ $newMatrixListing->addComment($content,0,$ownerUser);
+ }
+ }
+ }
+ }
+ $db->write("drop table Matrix_listing");
+ $db->write("drop table Matrix_listingData");
+ print "DONE!\n" unless $quiet;
+}
+
#----------------------------------------------------------------------------
sub addExtendedProfilePrivileges {
my $session = shift;
diff --git a/lib/WebGUI/Asset/MatrixListing.pm b/lib/WebGUI/Asset/MatrixListing.pm
new file mode 100644
index 000000000..730a86086
--- /dev/null
+++ b/lib/WebGUI/Asset/MatrixListing.pm
@@ -0,0 +1,914 @@
+package WebGUI::Asset::MatrixListing;
+
+=head1 LEGAL
+
+ -------------------------------------------------------------------
+ WebGUI is Copyright 2001-2008 Plain Black Corporation.
+ -------------------------------------------------------------------
+ Please read the legal notices (docs/legal.txt) and the license
+ (docs/license.txt) that came with this distribution before using
+ this software.
+ -------------------------------------------------------------------
+ http://www.plainblack.com info@plainblack.com
+ -------------------------------------------------------------------
+
+=cut
+
+use strict;
+use Tie::IxHash;
+use Class::C3;
+use base qw(WebGUI::AssetAspect::Comments WebGUI::Asset);
+use WebGUI::Utility;
+
+
+
+=head1 NAME
+
+Package WebGUI::Asset::MatrixListing
+
+=head1 DESCRIPTION
+
+Describe your New Asset's functionality and features here.
+
+=head1 SYNOPSIS
+
+use WebGUI::Asset::MatrixListing;
+
+
+=head1 METHODS
+
+These methods are available from this class:
+
+=cut
+
+
+
+#-------------------------------------------------------------------
+
+=head2 addRevision
+
+ This method exists for demonstration purposes only. The superclass
+ handles revisions to MatrixListing Assets.
+
+=cut
+
+sub addRevision {
+ my $self = shift;
+ my $newSelf = $self->next::method(@_);
+ return $newSelf;
+}
+
+#-------------------------------------------------------------------
+
+=head2 definition ( session, definition )
+
+defines asset properties for MatrixListing instances.
+
+=head3 session
+
+=head3 definition
+
+A hash reference passed in from a subclass definition.
+
+=cut
+
+sub definition {
+ my $class = shift;
+ my $session = shift;
+ my $definition = shift;
+ my %properties;
+ tie %properties, 'Tie::IxHash';
+ my $i18n = WebGUI::International->new($session, "Asset_MatrixListing");
+ %properties = (
+ screenshots => {
+ tab =>"properties",
+ fieldType =>"image",
+ defaultValue =>undef,
+ maxAttachments =>20,
+ label =>$i18n->get("screenshots label"),
+ hoverHelp =>$i18n->get("screenshots description")
+ },
+ description => {
+ tab =>"properties",
+ fieldType =>"HTMLArea",
+ defaultValue =>undef,
+ label =>$i18n->get("description label"),
+ hoverHelp =>$i18n->get("description description")
+ },
+ version => {
+ tab =>"properties",
+ fieldType =>"text",
+ defaultValue =>undef,
+ label =>$i18n->get("version label"),
+ hoverHelp =>$i18n->get("version description")
+ },
+ score => {
+ defaultValue =>0,
+ autoGenerate =>0,
+ noFormPost =>1,
+ },
+ views => {
+ defaultValue =>0,
+ autoGenerate =>0,
+ noFormPost =>1,
+ },
+ compares => {
+ defaultValue =>0,
+ autoGenerate =>0,
+ noFormPost =>1,
+ },
+ clicks => {
+ defaultValue =>0,
+ autoGenerate =>0,
+ noFormPost =>1,
+ },
+ viewsLastIp => {
+ defaultValue =>undef,
+ autoGenerate =>0,
+ noFormPost =>1,
+ },
+ comparesLastIp => {
+ defaultValue =>undef,
+ autoGenerate =>0,
+ noFormPost =>1,
+ },
+ clicksLastIp => {
+ defaultValue =>undef,
+ autoGenerate =>0,
+ noFormPost =>1,
+ },
+ maintainer => {
+ tab =>"properties",
+ fieldType =>"user",
+ defaultValue =>$session->user->userId,
+ label =>$i18n->get("maintainer label"),
+ hoverHelp =>$i18n->get("maintainer description")
+ },
+ manufacturerName => {
+ tab =>"properties",
+ fieldType =>"text",
+ defaultValue =>undef,
+ label =>$i18n->get("manufacturerName label"),
+ hoverHelp =>$i18n->get("manufacturerName description")
+ },
+ manufacturerURL => {
+ tab =>"properties",
+ fieldType =>"url",
+ defaultValue =>undef,
+ label =>$i18n->get("manufacturerURL label"),
+ hoverHelp =>$i18n->get("manufacturerURL description")
+ },
+ productURL => {
+ tab =>"properties",
+ fieldType =>"url",
+ defaultValue =>undef,
+ label =>$i18n->get("productURL label"),
+ hoverHelp =>$i18n->get("productURL description")
+ },
+ lastUpdated => {
+ defaultValue =>time(),
+ autoGenerate =>0,
+ noFormPost =>1,
+ },
+ );
+ push(@{$definition}, {
+ assetName=>$i18n->get('assetName'),
+ icon=>'MatrixListing.gif',
+ autoGenerateForms=>1,
+ tableName=>'MatrixListing',
+ className=>'WebGUI::Asset::MatrixListing',
+ properties=>\%properties
+ });
+ return $class->next::method($session, $definition);
+}
+
+
+#-------------------------------------------------------------------
+
+=head2 duplicate
+
+ This method exists for demonstration purposes only. The superclass
+ handles duplicating MatrixListing Assets. This method will be called
+ whenever a copy action is executed
+
+=cut
+
+sub duplicate {
+ my $self = shift;
+ my $newAsset = $self->next::method(@_);
+ return $newAsset;
+}
+
+#-------------------------------------------------------------------
+
+=head2 getAutoCommitWorkflowId
+
+Gets the WebGUI::VersionTag workflow to use to automatically commit MatrixListings.
+By specifying this method, you activate this feature.
+
+=cut
+
+sub getAutoCommitWorkflowId {
+ my $self = shift;
+ return $self->getParent->get("submissionApprovalWorkflowId");
+}
+
+#-------------------------------------------------------------------
+
+=head2 getEditForm ( )
+
+Returns the TabForm object that will be used in generating the edit page for this asset.
+
+=cut
+
+sub getEditForm {
+ my $self = shift;
+ my $session = $self->session;
+ my $db = $session->db;
+ my $matrixId = $self->getParent->getId;
+ my $tabform = $self->next::method();
+ my $i18n = WebGUI::International->new($session, 'Asset_MatrixListing');
+
+ foreach my $category (keys %{$self->getParent->getCategories}) {
+ $tabform->getTab('properties')->raw('
'.$category.' ');
+ my $attributes;
+ if ($session->form->process('func') eq 'add'){
+ $attributes = $db->read("select * from Matrix_attribute where category = ? and assetId = ?",
+ [$category,$matrixId]);
+ }
+ else{
+ $attributes = $db->read("select * from Matrix_attribute as a
+ left join MatrixListing_attribute as l on (a.attributeId = l.attributeId and l.matrixListingId = ?)
+ where category =? and a.assetId = ?",
+ [$self->getId,$category,$matrixId]);
+ }
+ while (my $attribute = $attributes->hashRef) {
+ $attribute->{label} = $attribute->{name};
+ $attribute->{subtext} = $attribute->{description};
+ $attribute->{name} = 'attribute_'.$attribute->{attributeId};
+ $tabform->getTab("properties")->dynamicField(%{$attribute});
+ }
+ }
+ return $tabform;
+}
+
+#-------------------------------------------------------------------
+
+=head2 hasRated ( )
+
+Returns whether the user has already rated this listing or not.
+
+=cut
+
+sub hasRated {
+ my $self = shift;
+ my $session = $self->session;
+
+ my $hasRated = $self->session->db->quickScalar("select count(*) from MatrixListing_rating where
+ ((userId=? and userId<>'1') or (userId='1' and ipAddress=?)) and listingId=?",
+ [$session->user->userId,$session->env->get("HTTP_X_FORWARDED_FOR"),$self->getId]);
+ return $hasRated;
+
+}
+
+#-------------------------------------------------------------------
+
+=head2 incrementCounter ( counter )
+
+Increments one of the Matrix Listing's counters.
+
+=head3 counter
+
+The name of the counter to increment this should be 'views', 'clicks' or 'compares').
+
+=cut
+
+sub incrementCounter {
+ my $self = shift;
+ my $db = $self->session->db;
+ my $counter = shift;
+
+ my $currentIp = $self->session->env->get("HTTP_X_FORWARDED_FOR");
+
+ unless ($self->get($counter."LastIp") eq $currentIp) {
+ $self->update({
+ $counter."LastIp" => $currentIp,
+ $counter => $self->get($counter)+1,
+ });
+ }
+}
+
+#-------------------------------------------------------------------
+
+=head2 indexContent ( )
+
+Making private. See WebGUI::Asset::indexContent() for additonal details.
+
+=cut
+
+sub indexContent {
+ my $self = shift;
+ my $indexer = $self->next::method;
+ $indexer->setIsPublic(0);
+}
+
+
+#-------------------------------------------------------------------
+
+=head2 prepareView ( )
+
+See WebGUI::Asset::prepareView() for details.
+
+=cut
+
+sub prepareView {
+ my $self = shift;
+ $self->next::method();
+ my $template = WebGUI::Asset::Template->new($self->session, $self->getParent->get('detailTemplateId'));
+ $template->prepare;
+ $self->{_viewTemplate} = $template;
+}
+
+
+#-------------------------------------------------------------------
+
+=head2 processPropertiesFromFormPost ( )
+
+Used to process properties from the form posted.
+
+=cut
+
+sub processPropertiesFromFormPost {
+ my $self = shift;
+ my $session = $self->session;
+ my $score = 0;
+
+ $self->next::method(@_);
+
+ my $attributes = $session->db->read("select * from Matrix_attribute where assetId = ?",[$self->getParent->getId]);
+ while (my $attribute = $attributes->hashRef) {
+ my $name = 'attribute_'.$attribute->{attributeId};
+ my $value;
+ if ($attribute->{fieldType} eq 'MatrixCompare'){
+ $value = $session->form->process($name);
+ $score = $score + $value;
+ }
+ else{
+ $value = $session->form->process($name,$attribute->{fieldType},$attribute->{defaultValue},$attribute);
+ }
+ $session->db->write("replace into MatrixListing_attribute (matrixId, matrixListingId, attributeId, value)
+ values (?, ?, ?, ?)",
+ [$self->getParent->getId,$self->getId,$attribute->{attributeId},$value]);
+ }
+ $self->update({score => $score});
+
+ $self->requestAutoCommit;
+}
+
+
+#-------------------------------------------------------------------
+
+=head2 purge ( )
+
+This method is called when data is purged by the system.
+removes collateral data associated with a MatrixListing when the system
+purges it's data.
+
+=cut
+
+sub purge {
+ my $self = shift;
+ my $db = $self->session->db;
+
+ $db->write("delete from MatrixListing_attribute where matrixListingId=?",[$self->getId]);
+ $db->write("delete from MatrixListing_rating where listingId=?" ,[$self->getId]);
+ $db->write("delete from MatrixListing_ratingSummary where listingId=?" ,[$self->getId]);
+
+ return $self->next::method;
+}
+
+#-------------------------------------------------------------------
+
+=head2 purgeRevision ( )
+
+This method is called when data is purged by the system.
+
+=cut
+
+sub purgeRevision {
+ my $self = shift;
+ return $self->next::method;
+}
+
+#-------------------------------------------------------------------
+
+=head2 setRatings ( ratings )
+
+Sets the ratings for a matrix listing
+
+=head3 ratings
+
+A hashref containing the ratings to set for this listing.
+
+=cut
+
+sub setRatings {
+ my $self = shift;
+ my $ratings = shift;
+ my $session = $self->session;
+ my $db = $session->db;
+ my $matrixId = $self->getParent->getId;
+
+ foreach my $category (keys %{$self->getParent->getCategories}) {
+ if ($ratings->{$category}) {
+ $db->write("insert into MatrixListing_rating
+ (userId, category, rating, timeStamp, listingId, ipAddress, matrixId) values (?,?,?,?,?,?,?)",
+ [$session->user->userId,$category,$ratings->{$category},$session->datetime->time(),$self->getId,
+ $session->env->get("HTTP_X_FORWARDED_FOR"),$matrixId]);
+ }
+ my $sql = "from MatrixListing_rating where listingId=? and category=?";
+ my $sum = $db->quickScalar("select sum(rating) $sql", [$self->getId,$category]);
+ my $count = $db->quickScalar("select count(*) $sql", [$self->getId,$category]);
+
+ my $half = round($count/2);
+ my $mean = $sum / ($count || 1);
+ my $median = $db->quickScalar("select rating $sql limit $half,$half",[$self->getId,$category]);
+
+ $db->write("replace into MatrixListing_ratingSummary
+ (listingId, category, meanValue, medianValue, countValue, matrixId)
+ values (?,?,?,?,?,?)",[$self->getId,$category,$mean,$median,$count,$matrixId]);
+ }
+}
+
+#-------------------------------------------------------------------
+
+=head2 view ( hasRated )
+
+method called by the container www_view method.
+
+=head3 hasRated
+
+A boolean indicating if the user has rated this listing.
+
+=head3 hasRated
+
+A boolean indicating if an email to the listing maintianer was sent.
+
+=cut
+
+sub view {
+ my $self = shift;
+ my $hasRated = shift || $self->hasRated;
+ my $emailSent = shift;
+ my $db = $self->session->db;
+ my $i18n = WebGUI::International->new($self->session, "Asset_Matrix");
+ my @categories = keys %{$self->getParent->getCategories};
+
+ # Increment views before getting template var hash so that the views tmpl_var has the incremented value.
+ $self->incrementCounter("views");
+
+ my $var = $self->get;
+ if ($emailSent){
+ $var->{emailSent} = 1;
+ }
+ $var->{controls} = $self->getToolbar;
+ $var->{comments} = $self->getFormattedComments(),
+ $var->{productName} = $var->{title};
+ $var->{lastUpdated_epoch} = $self->get('lastUpdated');
+ $var->{lastUpdated_date} = $self->session->datetime->epochToHuman($self->get('lastUpdated'),"%z");
+
+ $var->{manufacturerUrl_click} = $self->getUrl("func=click;manufacturer=1");
+ $var->{productUrl_click} = $self->getUrl("func=click");
+
+ # Attributes
+
+ foreach my $category (@categories) {
+ my $attributes;
+ my @attribute_loop;
+ my $categoryLoopName = $self->session->url->urlize($category)."_loop";
+ $attributes = $db->read("select * from Matrix_attribute as a
+ left join MatrixListing_attribute as l on (a.attributeId = l.attributeId and l.matrixListingId = ?)
+ where category =? and a.assetId = ?",
+ [$self->getId,$category,$self->getParent->getId]);
+ while (my $attribute = $attributes->hashRef) {
+ $attribute->{label} = $attribute->{name};
+ if ($attribute->{fieldType} eq 'MatrixCompare'){
+ $attribute->{value} = WebGUI::Form::MatrixCompare->new($self->session,$attribute)->getValueAsHtml;
+ }
+ push(@attribute_loop,$attribute);
+ }
+ $var->{$categoryLoopName} = \@attribute_loop;
+ push(@{$var->{category_loop}},{
+ categoryLabel => $category,
+ attribute_loop => \@attribute_loop,
+ });
+ }
+
+ # Screenshots
+
+ if ($var->{screenshots}) {
+ my $file = WebGUI::Form::File->new($self->session,{ value=>$var->{screenshots} });
+ my $storage = $file->getStorageLocation;
+ my @files = @{ $storage->getFiles } if (defined $storage);
+
+ $var->{screenshots} = qq|
+
+
+
+
+
+
+
+
+
+
+
+|;
+ }
+
+ # Rating form
+
+ my %rating;
+ tie %rating, 'Tie::IxHash';
+ %rating = (
+ 1=>"1 - Worst",
+ 2=>2,
+ 3=>3,
+ 4=>4,
+ 5=>"5 - Respectable",
+ 6=>6,
+ 7=>7,
+ 8=>8,
+ 9=>9,
+ 10=>"10 - Best"
+ );
+ my $ratingsTable = "';
+ $ratingForm->submit(
+ -extras =>'class="ratingForm"',
+ -value =>$i18n->get('rate submit label'),
+ -label =>''.$i18n->get('show ratings').' '
+ );
+ if ($hasRated) {
+ $var->{ratings} = $ratingsTable;
+ } else {
+ $var->{ratings} = $ratingForm->print;
+ }
+
+ # Mail form
+
+ my $mailForm = WebGUI::HTMLForm->new($self->session,
+ -extras =>'class="content"',
+ -tableExtras=>'class="content"'
+ );
+ $mailForm->hidden(
+ -name =>"func",
+ -value =>"sendEmail"
+ );
+ $mailForm->captcha(
+ -name =>"verify"
+ );
+ $mailForm->email(
+ -extras =>'class="content"',
+ -name =>"from",
+ -value =>$self->session->user->profileField("email"),
+ -label =>$i18n->get('your email label'),
+ );
+ $mailForm->selectBox(
+ -name =>"subject",
+ -extras =>'class="content"',
+ -options =>{
+ $i18n->get('report error label') =>$i18n->get('report error label'),
+ $i18n->get('general comment label') =>$i18n->get('general comment label'),
+ },
+ -label =>$i18n->get('request type label'),
+ );
+ $mailForm->textarea(
+ -rows =>4,
+ -extras =>'class="content"',
+ -columns =>35,
+ -name =>"body",
+ -label =>$i18n->get('comment label'),
+ );
+ $mailForm->submit(
+ -extras =>'class="content"',
+ -value =>$i18n->get('send button label'),
+ );
+ $var->{emailForm} = $mailForm->print;
+
+ return $self->getParent->processStyle($self->processTemplate($var,undef, $self->{_viewTemplate}));
+}
+
+
+#-------------------------------------------------------------------
+
+=head2 www_click ( )
+
+Redirects to the manufacturerUrl or productUrl and increments clicks.
+
+=cut
+
+sub www_click {
+ my $self = shift;
+
+ return $self->session->privilege->noAccess() unless $self->canView;
+
+ my $session = $self->session;
+
+ $self->incrementCounter('clicks');
+ if ($session->form->process("manufacturer")) {
+ $session->http->setRedirect( $self->get('manufacturerUrl') );
+ }
+ else {
+ $session->http->setRedirect( $self->get('productUrl') );
+ }
+ return undef;
+}
+
+#-------------------------------------------------------------------
+
+=head2 www_edit ( )
+
+Web facing method which is the default edit page
+
+=cut
+
+sub www_edit {
+ my $self = shift;
+
+ return $self->session->privilege->noAccess() unless $self->getParent->canAddMatrixListing();
+
+ my $i18n = WebGUI::International->new($self->session, "Asset_MatrixListing");
+ return $self->session->privilege->insufficient() unless $self->canEdit;
+ return $self->session->privilege->locked() unless $self->canEditIfLocked;
+ return $self->getAdminConsole->render($self->getEditForm->print,$i18n->get('edit matrix listing title'));
+}
+
+#-------------------------------------------------------------------
+
+=head2 www_getScreenshots ( )
+
+Returns the screenshots as xml.
+
+=cut
+
+sub www_getScreenshots {
+ my $self = shift;
+
+ return $self->session->privilege->noAccess() unless $self->canView;
+
+ $self->session->http->setMimeType('text/xml');
+
+ my $xml = qq |
+
+
+|;
+
+ if ( $self->get('screenshots') ) {
+ my $fileObject = WebGUI::Form::File->new($self->session,{ value=>$self->get('screenshots') });
+ my $storage = $fileObject->getStorageLocation;
+ my $path = $storage->getPath;
+ my @files = @{ $storage->getFiles } if (defined $storage);
+ foreach my $file (@files) {
+ unless ($file =~ m/^thumb-/){
+ my $thumb = 'thumb-'.$file;
+ $xml .= "
+
+ 400
+ 300
+ Slide One]]>
+
+ ".$storage->getUrl($file)."
+ 5
+ ".$storage->getUrl($thumb)."
+
+ ";
+ }
+ }
+ }
+
+ $xml .= qq |
+
+
+|;
+
+ return $xml;
+}
+
+#-------------------------------------------------------------------
+
+=head2 www_getScreenshotsConfig ( )
+
+Returns the xml config file for the ukplayer that displays the screenshots.
+
+=cut
+
+sub www_getScreenshotsConfig {
+ my $self = shift;
+
+ return $self->session->privilege->noAccess() unless $self->canView;
+
+ $self->session->http->setMimeType('text/xml');
+
+ my $xml = qq|
+
+
+ ?func=getScreenshots
+
+ 400
+ 300
+ 0xDDDDEE
+ 20
+ 100
+ 100
+
+ Verdana
+ 12
+ 0xCCCCCC
+ 0xCCCCCC
+ 0x000000
+ true
+
+ 0xCCCCCC
+ 0xCCCCCC
+ 0x000000
+ false
+
+ 48
+ 36
+ 0x000000
+ true
+ 100
+ 5
+
+ false
+ true
+ false
+ false
+
+
+
+
+|;
+
+ return $xml;
+}
+
+#-------------------------------------------------------------------
+
+=head2 www_rate ( )
+
+Saves a rating of a matrix listing and returns the listing view.
+
+=cut
+
+sub www_rate {
+ my $self = shift;
+ my $form = $self->session->form;
+
+ my $hasRated = $self->hasRated;
+ my $sameRating = 1;
+ my $first = 1;
+ my $lastRating;
+
+ foreach my $category (keys %{$self->getParent->getCategories}) {
+ if ($first) {
+ $first=0;
+ } else {
+ if ($lastRating != $form->process($category)) {
+ $sameRating = 0;
+ }
+ }
+ $lastRating = $form->process($category);
+ }
+
+ # Throw out ratings that are all the same number, or if the user rates twice.
+ unless ($hasRated || $sameRating) {
+ $self->setRatings($self->session->form->paramsHashRef);
+ }
+
+ $self->prepareView;
+ return $self->view;
+}
+
+#-------------------------------------------------------------------
+
+=head2 www_sendEmail ( )
+
+Sends an email to the maintainer of this matrix listing and returns www_view
+
+=cut
+
+sub www_sendEmail {
+ my $self = shift;
+ my $form = $self->session->form;
+
+ return $self->session->privilege->noAccess() unless $self->canView;
+
+ if ($form->process("verify","captcha")) {
+ if ($form->process("body") ne "") {
+ my $user = WebGUI::User->new($self->session, $self->get('maintainerId'));
+ my $mail = WebGUI::Mail::Send->create($self->session,{
+ to =>$user->profileField("email"),
+ subject =>$self->get('productName')." - ".$form->process("subject"),
+ from=>$form->process("from")
+ });
+ $mail->addText($form->process("body"));
+ $mail->addFooter;
+ $mail->queue;
+ }
+ }
+
+ $self->prepareView;
+ return $self->view(0,1);
+}
+
+#-------------------------------------------------------------------
+
+=head2 www_view ( )
+
+Web facing method which is the default view page. This method does a
+302 redirect to the "showPage" file in the storage location.
+
+=cut
+
+sub www_view {
+ my $self = shift;
+ return $self->session->privilege->noAccess() unless $self->canView;
+ $self->prepareView;
+ return $self->view;
+}
+
+
+1;
+
+#vim:ft=perl
diff --git a/lib/WebGUI/Asset/Wobject/Matrix.pm b/lib/WebGUI/Asset/Wobject/Matrix.pm
index 85bf29c32..753d12b48 100644
--- a/lib/WebGUI/Asset/Wobject/Matrix.pm
+++ b/lib/WebGUI/Asset/Wobject/Matrix.pm
@@ -1,183 +1,393 @@
package WebGUI::Asset::Wobject::Matrix;
-
+
+$VERSION = "2.0.0";
+
+#-------------------------------------------------------------------
+# WebGUI is Copyright 2001-2008 Plain Black Corporation.
+#-------------------------------------------------------------------
+# Please read the legal notices (docs/legal.txt) and the license
+# (docs/license.txt) that came with this distribution before using
+# this software.
+#-------------------------------------------------------------------
+# http://www.plainblack.com info@plainblack.com
+#-------------------------------------------------------------------
+
use strict;
+use warnings;
use Tie::IxHash;
-use WebGUI::Form;
-use WebGUI::HTMLForm;
-use WebGUI::Cache;
-use WebGUI::Mail::Send;
-use WebGUI::SQL;
-use WebGUI::Storage::Image;
-use WebGUI::User;
+use JSON;
+use WebGUI::International;
use WebGUI::Utility;
-use WebGUI::Inbox;
-use WebGUI::Asset::Wobject;
-use WebGUI::Asset::Wobject::Collaboration;
+use WebGUI::Asset::MatrixListing;
+use base 'WebGUI::Asset::Wobject';
+
+#----------------------------------------------------------------------------
+
+=head2 canAddMatrixListing ( )
+
+Returns true if able to add MatrixListings.
+
+ Checks to make sure that the
+ Calendar has been committed at least once. Checks to make sure that
+ the user is in the appropriate group (either the group that can edit
+ the calendar, or the group that can edit events in the calendar).
+
+=cut
+
+sub canAddMatrixListing {
+ my $self = shift;
+
+ return 1;
+=cut
+ my $userId = shift;
+
+ my $user = $userId
+ ? WebGUI::User->new( $self->session, $userId )
+ : $self->session->user
+ ;
+
+ return 1 if (
+ $user->isInGroup( $self->get("groupIdEventEdit") )
+ );
+=cut
+}
-
-our @ISA = qw(WebGUI::Asset::Wobject);
-
#-------------------------------------------------------------------
+
+=head2 definition ( )
+
+defines wobject properties for Matrix instances.
+
+=cut
+
sub definition {
- my $class = shift;
+ my $class = shift;
my $session = shift;
- my $definition = shift;
- my $i18n = WebGUI::International->new($session,"Asset_Matrix");
- push(@{$definition}, {
- icon=>'matrix.gif',
- tableName=>'Matrix',
- className=>'WebGUI::Asset::Wobject::Matrix',
+ my $definition = shift;
+ my $i18n = WebGUI::International->new($session, 'Asset_Matrix');
+
+ my %properties;
+ tie %properties, 'Tie::IxHash';
+ %properties = (
+ templateId =>{
+ fieldType =>"template",
+ defaultValue =>'matrixtmpl000000000001',
+ tab =>"display",
+ noFormPost =>0,
+ namespace =>"Matrix",
+ hoverHelp =>$i18n->get('template description'),
+ label =>$i18n->get('template label'),
+ },
+ searchTemplateId=>{
+ defaultValue =>"matrixtmpl000000000005",
+ fieldType =>"template",
+ tab =>"display",
+ namespace =>"Matrix/Search",
+ hoverHelp =>$i18n->get('search template description'),
+ label =>$i18n->get('search template label'),
+ },
+ detailTemplateId=>{
+ defaultValue =>"matrixtmpl000000000003",
+ fieldType =>"template",
+ tab =>"display",
+ namespace =>"Matrix/Detail",
+ hoverHelp =>$i18n->get('detail template description'),
+ label =>$i18n->get('detail template label'),
+ },
+ compareTemplateId=>{
+ defaultValue =>"matrixtmpl000000000002",
+ fieldType =>"template",
+ tab =>"display",
+ namespace =>"Matrix/Compare",
+ hoverHelp =>$i18n->get('compare template description'),
+ label =>$i18n->get('compare template label'),
+ },
+ defaultSort=>{
+ fieldType =>"selectBox",
+ tab =>"display",
+ options =>{
+ score => $i18n->get('sort by score label'),
+ title => $i18n->get('sort alpha numeric label'),
+ lineage => $i18n->get('sort by asset rank label'),
+ revisionDate => $i18n->get('sort by last updated label'),
+ },
+ defaultValue =>"score",
+ hoverHelp =>$i18n->get('default sort description'),
+ label =>$i18n->get('default sort label'),
+ },
+ compareColorNo=>{
+ fieldType =>"color",
+ tab =>"display",
+ defaultValue =>"#ffaaaa",
+ hoverHelp =>$i18n->get('compare color no description'),
+ label =>$i18n->get('compare color no label'),
+ },
+ compareColorLimited=>{
+ fieldType =>"color",
+ tab =>"display",
+ defaultValue =>"#ffffaa",
+ hoverHelp =>$i18n->get('compare color limited description'),
+ label =>$i18n->get('compare color limited label'),
+ },
+ compareColorCostsExtra=>{
+ fieldType =>"color",
+ tab =>"display",
+ defaultValue =>"#ffffaa",
+ hoverHelp =>$i18n->get('compare color costs extra description'),
+ label =>$i18n->get('compare color costs extra label'),
+ },
+ compareColorFreeAddOn=>{
+ fieldType =>"color",
+ tab =>"display",
+ defaultValue =>"#ffffaa",
+ hoverHelp =>$i18n->get('compare color free add on description'),
+ label =>$i18n->get('compare color free add on label'),
+ },
+ compareColorYes=>{
+ fieldType =>"color",
+ tab =>"display",
+ defaultValue =>"#aaffaa",
+ hoverHelp =>$i18n->get('compare color yes description'),
+ label =>$i18n->get('compare color yes label'),
+ },
+ categories=>{
+ fieldType =>"textarea",
+ tab =>"properties",
+ defaultValue =>$i18n->get('categories default value'),
+ hoverHelp =>$i18n->get('categories description'),
+ label =>$i18n->get('categories label'),
+ subtext =>$i18n->get('categories subtext'),
+ },
+ maxComparisons=>{
+ fieldType =>"integer",
+ tab =>"properties",
+ defaultValue =>25,
+ hoverHelp =>$i18n->get('max comparisons description'),
+ label =>$i18n->get('max comparisons label'),
+ },
+ maxComparisonsPrivileged=>{
+ fieldType =>"integer",
+ tab =>"properties",
+ defaultValue =>10,
+ hoverHelp =>$i18n->get('max comparisons privileged description'),
+ label =>$i18n->get('max comparisons privileged label'),
+ },
+ submissionApprovalWorkflowId=>{
+ fieldType =>"workflow",
+ tab =>"security",
+ type =>'WebGUI::VersionTag',
+ defaultValue =>"pbworkflow000000000003",
+ hoverHelp =>$i18n->get('submission approval workflow description'),
+ label =>$i18n->get('submission approval workflow label'),
+ },
+ ratingsDuration=>{
+ fieldType =>"interval",
+ tab =>"properties",
+ defaultValue =>7776000, # 3 months 3*30*24*60*60
+ hoverHelp =>$i18n->get('ratings duration description'),
+ label =>$i18n->get('ratings duration label'),
+ },
+ );
+ push(@{$definition}, {
assetName=>$i18n->get('assetName'),
- properties=>{
- visitorCacheTimeout => {
- tab => "display",
- fieldType => "interval",
- defaultValue => 3600,
- uiLevel => 8,
- label => $i18n->get("visitor cache timeout"),
- hoverHelp => $i18n->get("visitor cache timeout help")
- },
- categories=>{
- defaultValue=>"Features\nBenefits",
- fieldType=>"textarea"
- },
- maxComparisons=>{
- defaultValue=>10,
- fieldName=>"integer"
- },
- templateId=>{
- defaultValue=>"matrixtmpl000000000001",
- fieldType=>"template"
- },
- searchTemplateId=>{
- defaultValue=>"matrixtmpl000000000005",
- fieldType=>"template"
- },
- detailTemplateId=>{
- defaultValue=>"matrixtmpl000000000003",
- fieldType=>"template"
- },
- ratingDetailTemplateId=>{
- defaultValue=>"matrixtmpl000000000004",
- fieldType=>"template"
- },
- compareTemplateId=>{
- defaultValue=>"matrixtmpl000000000002",
- fieldType=>"template"
- },
- privilegedGroup=>{
- defaultValue=>'2',
- fieldType=>"group",
- },
- groupToRate=>{
- defaultValue=>'2',
- fieldType=>"group",
- },
- groupToAdd=>{
- defaultValue=>'2',
- fieldType=>"group",
- },
- maxComparisonsPrivileged=>{
- defaultValue=>10,
- fieldType=>"integer",
- },
- ratingTimeout=>{
- defaultValue=>60*60*24*365,
- fieldType=>"interval"
- },
- ratingTimeoutPrivileged=>{
- defaultValue=>60*60*24*365,
- fieldType=>"interval"
- }
- }
- });
- return $class->SUPER::definition($session, $definition);
+ icon=>'matrix.gif',
+ autoGenerateForms=>1,
+ tableName=>'Matrix',
+ className=>'WebGUI::Asset::Wobject::Matrix',
+ properties=>\%properties
+ });
+ return $class->SUPER::definition($session, $definition);
}
#-------------------------------------------------------------------
+
+=head2 deleteAttribute ( attributeId )
+
+Deletes an attribute and listing data for this attribute from Collateral.
+
+=head3 attributeId
+
+The id of the attribute that should be deleted.
+
+=cut
+
+sub deleteAttribute {
+
+ my $self = shift;
+ my $attributeId = shift;
+
+ $self->deleteCollateral("Matrix_attribute","attributeId",$attributeId);
+ #TODO: delete listing data, $self->deleteCollateral("Matrix_listingData","attributeId",$attributeId);
+
+ return undef;
+}
+
+#-------------------------------------------------------------------
+
+=head2 duplicate ( )
+
+duplicates a Matrix.
+
+=cut
+
sub duplicate {
- # Buggo: how do we duplicate these?
- return undef;
-}
-
-#-------------------------------------------------------------------
-# Too much data to keep track of modification dates, always assume new data
-sub getContentLastModified {
- return time();
-}
-
-#-------------------------------------------------------------------
-sub formatURL {
my $self = shift;
- my $func = shift;
- my $listingId = shift;
- my $url = $self->getUrl("func=".$func.";listingId=".$listingId);
- return $url;
+ my $newAsset = $self->SUPER::duplicate(@_);
+ return $newAsset;
}
+#-------------------------------------------------------------------
+
+=head2 editAttributeSave ( attributeProperties )
+
+Saves an attribute.
+
+=head3 attributeProperties
+
+A hashref containing the properties of the attribute.
+
+=cut
+
+sub editAttributeSave {
+ my $self = shift;
+ my $attributeProperties = shift;
+ my $session = $self->session;
+ my $form = $session->form;
+
+ return $session->privilege->insufficient() unless $self->canEdit;
+
+ my $attributeId = $self->setCollateral("Matrix_attribute","attributeId",$attributeProperties,0,1);
+
+ return $attributeId;
+}
#-------------------------------------------------------------------
+
+=head2 getAttribute ( attributeId )
+
+Returns a hash reference of the properties of an attribute.
+
+=head3 attributeId
+
+The unique id of an attribute.
+
+=cut
+
+sub getAttribute {
+ my ($self, $attributeId) = @_;
+ return $self->session->db->quickHashRef("select * from Matrix_attribute where attributeId=?",[$attributeId]);
+}
+
+#-------------------------------------------------------------------
+
+=head2 getCategories ( )
+
+Returns the categories for this Matrix as a hashref.
+
+=cut
+
sub getCategories {
- my $self = shift;
- my $cat = $self->getValue("categories");
- $cat =~ s/\r//g;
- chomp($cat);
- my @categories = split(/\n/,$cat);
- return @categories;
+ my $self = shift;
+ my %categories;
+ tie %categories, 'Tie::IxHash';
+ my $categories = $self->getValue("categories");
+ $categories =~ s/\r//g;
+ chomp($categories);
+ my @categories = split(/\n/,$categories);
+ foreach my $category (@categories) {
+ $categories{$category} = $category;
+ }
+ return \%categories;
+
}
#-------------------------------------------------------------------
+
+=head2 getCompareColor ( )
+
+Returns the compare form.
+
+=head3 value
+
+The value of a MatrixCompare form field.
+
+=cut
+
+sub getCompareColor {
+
+ my $self = shift;
+ my $value = shift;
+
+ if($value == 0){
+ return $self->get('compareColorNo');
+ }
+ elsif($value == 1){
+ return $self->get('compareColorLimited');
+ }
+ elsif($value == 2){
+ return $self->get('compareColorCostsExtra');
+ }
+ elsif($value == 3){
+ return $self->get('compareColorFreeAddOn');
+ }
+ elsif($value == 3){
+ return $self->get('compareColorYes');
+ }
+
+}
+
+#-------------------------------------------------------------------
+
+=head2 getCompareForm ( )
+
+Returns the compare form.
+
+=head3 selectedListingIds
+
+An array of listingIds that should be selected in the compare form.
+
+=cut
+
sub getCompareForm {
- my $self = shift;
- my @ids = @_;
- my $form = WebGUI::Form::formHeader($self->session,{action=>$self->getUrl})
- .WebGUI::Form::submit($self->session, {
- value=>"compare"
- })
- ." "
- ." "
- .WebGUI::Form::hidden($self->session, {
- name=>"func",
- value=>"compare"
- })
- .WebGUI::Form::checkList($self->session, {
- name=>"listingId",
- vertical=>1,
- value=>\@ids,
- options=>$self->session->db->buildHashRef("select listingId, concat('getUrl("func=viewDetail").";listingId=',listingId,'\\\">', productName,' ') from Matrix_listing
- where assetId=".$self->session->db->quote($self->getId)." and status='approved' order by productName")
- })
- ." "
- .WebGUI::Form::submit($self->session,{
- value=>"compare"
- })
- .WebGUI::Form::formFooter($self->session);
- return $form;
+ my $self = shift;
+
+ my $form = WebGUI::Form::formHeader($self->session,{action=>$self->getUrl,extras=>'name="doCompare"'})
+ ." "
+ .WebGUI::Form::hidden($self->session, {
+ name=>"func",
+ value=>"compare"
+ })
+ .'
'
+ ." "
+ .WebGUI::Form::formFooter($self->session);
+
+ my $maxComparisons;
+ if($self->session->user->isVisitor){
+ $maxComparisons = $self->get('maxComparisons');
+ }
+ else{
+ $maxComparisons = $self->get('maxComparisonsPrivileged');
+ }
+ $form .= "\n\n";
+ return $form;
}
-#-------------------------------------------------------------------
-sub hasRated {
- my $self = shift;
- my $listingId = shift;
- return 1 unless ($self->session->user->isInGroup($self->get("groupToRate")));
- my $ratingTimeout = $self->session->user->isInGroup($self->get("privilegedGroup")) ? $self->get("ratingTimeoutPrivileged") : $self->get("ratingTimeout");
- my ($hasRated) = $self->session->db->quickArray("select count(*) from Matrix_rating where
- ((userId=".$self->session->db->quote($self->session->user->userId)." and userId<>'1') or (userId='1' and ipAddress=".$self->session->db->quote($self->session->env->get("HTTP_X_FORWARDED_FOR")).")) and
- listingId=".$self->session->db->quote($listingId)." and timeStamp>".($self->session->datetime->time()-$ratingTimeout));
- return $hasRated;
-}
#-------------------------------------------------------------------
-sub incrementCounter {
+
+=head2 getEditForm ( )
+
+returns the tabform object that will be used in generating the edit page for Matrix.
+
+=cut
+
+sub getEditForm {
my $self = shift;
- my $listingId = shift;
- my $counter = shift;
- my ($lastIp) = $self->session->db->quickArray("select ".$counter."LastIp from Matrix_listing where listingId = ".$self->session->db->quote($listingId));
- unless ($lastIp eq $self->session->env->get("HTTP_X_FORWARDED_FOR")) {
- $self->session->db->write("update Matrix_listing set $counter=$counter+1, ".$counter."LastIp=".$self->session->db->quote($self->session->env->get("HTTP_X_FORWARDED_FOR"))." where listingId=".$self->session->db->quote($listingId));
- }
+ my $tabform = $self->SUPER::getEditForm();
+ return $tabform;
}
#-------------------------------------------------------------------
@@ -192,1184 +402,737 @@ sub prepareView {
my $self = shift;
$self->SUPER::prepareView();
my $template = WebGUI::Asset::Template->new($self->session, $self->get("templateId"));
- $template->prepare($self->getMetaDataAsTemplateVariables);
+ $template->prepare;
$self->{_viewTemplate} = $template;
}
#-------------------------------------------------------------------
+
+=head2 purge ( )
+
+removes collateral data associated with a Matrix when the system
+purges it's data.
+
+=cut
+
sub purge {
- my $self = shift;
- $self->session->db->write("delete from Matrix_listing where assetId=".$self->session->db->quote($self->getId));
- $self->session->db->write("delete from Matrix_listingData where assetId=".$self->session->db->quote($self->getId));
- $self->session->db->write("delete from Matrix_field where assetId=".$self->session->db->quote($self->getId));
- $self->session->db->write("delete from Matrix_rating where assetId=".$self->session->db->quote($self->getId));
- $self->session->db->write("delete from Matrix_ratingSummary where assetId=".$self->session->db->quote($self->getId));
- $self->SUPER::purge;
+ my $self = shift;
+ #purge your wobject-specific data here. This does not include fields
+ # you create for your Matrix asset/wobject table.
+ return $self->SUPER::purge;
}
#-------------------------------------------------------------------
-=head2 purgeCache ( )
+=head2 view ( )
-See WebGUI::Asset::purgeCache() for details.
+method called by the www_view method. Returns a processed template
+to be displayed within the page style.
=cut
-sub purgeCache {
- my $self = shift;
- WebGUI::Cache->new($self->session,"view_".$self->getId)->delete;
- $self->SUPER::purgeCache;
-}
-
-#-------------------------------------------------------------------
-sub setRatings {
- my $self = shift;
- my $listingId = shift;
- my $ratings = shift;
- foreach my $category ($self->getCategories) {
- if ($ratings->{$category}) {
- $self->session->db->write("insert into Matrix_rating (userId, category, rating, timeStamp, listingId,ipAddress, assetId) values (
- ".$self->session->db->quote($self->session->user->userId).", ".$self->session->db->quote($category).", ".$self->session->db->quote($ratings->{$category}).", ".$self->session->datetime->time()
- .", ".$self->session->db->quote($listingId).", ".$self->session->db->quote($self->session->env->get("HTTP_X_FORWARDED_FOR")).",".$self->session->db->quote($self->getId).")");
- }
- my $sql = "from Matrix_rating where listingId=".$self->session->db->quote($listingId)." and category=".$self->session->db->quote($category);
- my ($sum) = $self->session->db->quickArray("select sum(rating) $sql");
- my ($count) = $self->session->db->quickArray("select count(*) $sql");
- my $half = round($count/2);
- my $mean = $sum / ($count || 1);
- my ($median) = $self->session->db->quickArray("select rating $sql limit $half,$half");
- $self->session->db->write("replace into Matrix_ratingSummary (listingId, category, meanValue, medianValue, countValue,assetId) values (
- ".$self->session->db->quote($listingId).", ".$self->session->db->quote($category).", $mean, ".$self->session->db->quote($median).", $count, ".$self->session->db->quote($self->getId).")");
- }
-}
-
-#-------------------------------------------------------------------
-sub www_approveListing {
- my $self = shift;
- return $self->session->privilege->insufficient() unless($self->canEdit);
- my $listing = $self->session->db->getRow("Matrix_listing","listingId",$self->session->form->process("listingId"));
- $self->session->db->write("update Matrix_listing set status='approved' where listingId=".$self->session->db->quote($self->session->form->process("listingId")));
- my $inbox = WebGUI::Inbox->new($self->session);
- $inbox->addMessage({
- subject=>"New Listing Approved",
- message=>"Your new listing, ".$listing->{productName}.", has been approved.",
- status=>'completed',
- userId=>$listing->{maintainerId}
- });
- my $message = $inbox->getMessage($listing->{approvalMessageId});
- if (defined $message) {
- $message->setCompleted;
- }
- return $self->www_viewDetail;
-}
-
-
-#-------------------------------------------------------------------
-sub www_click {
- my $self = shift;
- $self->incrementCounter($self->session->form->process("listingId"),"clicks");
- my $listing = $self->session->db->getRow("Matrix_listing","listingId",$self->session->form->process("listingId"));
- if ($self->session->form->process("m")) {
- $self->session->http->setRedirect($listing->{manufacturerUrl});
- }
- else {
- $self->session->http->setRedirect($listing->{productUrl});
- }
- return undef;
-}
-
-
-#-------------------------------------------------------------------
-sub www_compare {
- my $self = shift;
- my @cmsList = @_;
- unless (scalar(@cmsList)) {
- @cmsList = $self->session->form->checkList("listingId");
- }
- my ($style, $url) = ($self->session->style, $self->session->url);
- my ( %var, @prodcol, @datecol);
- my $max = $self->session->user->isInGroup($self->get("privilegedGroup")) ? $self->get("maxComparisonsPrivileged") : $self->get("maxComparisons");
- $var{isTooMany} = (scalar(@cmsList)>$max);
- $var{isTooFew} = (scalar(@cmsList)<2);
- $var{'compare.form'} = $self->getCompareForm(@cmsList);
- $var{'isLoggedIn'} = ($self->session->user->isRegistered);
- if ($var{isTooMany} || $var{isTooFew}) {
- return $self->processStyle($self->processTemplate(\%var,$self->get("compareTemplateId")));
- }
- foreach my $cms (@cmsList) {
- $self->incrementCounter($cms,"compares");
- my $data = $self->session->db->quickHashRef("select listingId, productName, versionNumber, lastUpdated
- from Matrix_listing where listingId=".$self->session->db->quote($cms));
- push(@prodcol, {
- name=>$data->{productName} || "__untitled__",
- version=>$data->{versionNumber},
- url=>$self->formatURL("viewDetail",$cms)
- });
- push(@datecol, {
- 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.fieldType, a.label, a.description";
- my $from = "from Matrix_field a";
- my $tableCount = "b";
- foreach my $cms (@cmsList) {
- $select .= ", ".$tableCount.".value";
- $from .= " left join Matrix_listingData ".$tableCount." on a.fieldId="
- .$tableCount.".fieldId and ".$tableCount.".listingId=".$self->session->db->quote($cms);
- $tableCount++;
- }
- my $sth = $self->session->db->read("$select $from where a.category=".$self->session->db->quote($category)." and a.assetId=".$self->session->db->quote($self->getId)." order by a.label");
- while (my @row = $sth->array) {
- my @columnloop;
- my $first = 1;
- my $type = shift @row;
- foreach my $value (@row) {
- my $desc = "";
- if ($first) {
- $desc = $row[1];
- shift(@row);
- $first = 0;
- }
- elsif ($type eq 'goodBad') {
- $value = $goodBad{$value};
- }
- my $class = lc($value);
- $class =~ s/\s/_/g;
- $class =~ s/\W//g;
- push(@columnloop,{
- value=>$value,
- class=>$class,
- description=>$desc
- });
- }
- push(@rowloop,{
- column_loop=>\@columnloop
- });
- }
- $sth->finish;
- push(@categoryloop,{
- category=>$category,
- columnCount=>$#cmsList+2,
- row_loop=>\@rowloop
- });
- }
- $var{category_loop} = \@categoryloop;
- return $self->processStyle($self->processTemplate(\%var,$self->get("compareTemplateId")));
-}
-
-#-------------------------------------------------------------------
-sub www_copy {
- my $self = shift;
- my $i18n = WebGUI::International->new($self->session,'Asset_Matrix');
- return $i18n->get('no copy');
-}
-
-#-------------------------------------------------------------------
-sub www_deleteField {
- my $self = shift;
- my $id = $self->session->form->param("fieldId");
- $self->session->db->write("delete from Matrix_field where fieldId=?",[$id]);
- $self->session->db->write("delete from Matrix_listingData where fieldId=?",[$id]);
- $self->www_listFields();
-}
-
-#-------------------------------------------------------------------
-sub www_deleteListing {
- my $self = shift;
- my $i18n = WebGUI::International->new($self->session,'Asset_Matrix');
- my $output = sprintf $i18n->get('delete listing confirmation'),
- $self->getUrl("func=deleteListingConfirm;listingId=".$self->session->form->process("listingId")),
- $self->formatURL("viewDetail",$self->session->form->process("listingId"));
- return $self->processStyle($output);
-}
-
-#-------------------------------------------------------------------
-sub www_deleteListingConfirm {
- my $self = shift;
- return $self->session->privilege->insufficient() unless($self->canEdit);
- my $listing = $self->session->db->getRow("Matrix_listing","listingId",$self->session->form->process("listingId"));
- WebGUI::Asset::Wobject::Collaboration->new($self->session, $listing->{forumId})->purge;
- $self->session->db->write("delete from Matrix_listing where listingId=".$self->session->db->quote($self->session->form->process("listingId")));
- $self->session->db->write("delete from Matrix_listingData where listingId=".$self->session->db->quote($self->session->form->process("listingId")));
- $self->session->db->write("delete from Matrix_rating where listingId=".$self->session->db->quote($self->session->form->process("listingId")));
- $self->session->db->write("delete from Matrix_ratingSummary where listingId=".$self->session->db->quote($self->session->form->process("listingId")));
- my $inbox = WebGUI::Inbox->new($self->session);
- $inbox->addMessage({
- status=>'completed',
- subject=>"Listing Deleted",
- message=>"Your listing, ".$listing->{productName}.", has been deleted from the matrix.",
- userId=>$listing->{maintainerId}
- });
- my $message = $inbox->getMessage($listing->{approvalMessageId});
- if (defined $message) {
- $message->setCompleted;
- }
- return "";
-}
-
-#-------------------------------------------------------------------
-sub getEditForm {
- my $self = shift;
- my $tabform = $self->SUPER::getEditForm();
- my $i18n = WebGUI::International->new($self->session,'Asset_Matrix');
- $tabform->getTab("display")->interval(
- -name=>"visitorCacheTimeout",
- -label=>$i18n->get('visitor cache timeout'),
- -hoverHelp=>$i18n->get('visitor cache timeout help'),
- -value=>$self->getValue('visitorCacheTimeout'),
- -uiLevel=>8,
- -defaultValue=>3600
- );
- $tabform->getTab("properties")->textarea(
- -name=>"categories",
- -label=>$i18n->get('categories'),
- -hoverHelp=>$i18n->get('categories description'),
- -value=>$self->getValue("categories"),
- -subtext=>$i18n->get('categories subtext'),
- );
- $tabform->getTab("properties")->integer(
- -name=>"maxComparisons",
- -label=>$i18n->get("max comparisons"),
- -hoverHelp=>$i18n->get("max comparisons description"),
- -value=>$self->getValue("maxComparisons")
- );
- $tabform->getTab("properties")->integer(
- -name=>"maxComparisonsPrivileged",
- -label=>$i18n->get("max comparisons privileged"),
- -hoverHelp=>$i18n->get("max comparisons privileged description"),
- -value=>$self->getValue("maxComparisonsPrivileged")
- );
- $tabform->getTab("properties")->interval(
- -name=>"ratingTimeout",
- -label=>$i18n->get("rating timeout"),
- -hoverHelp=>$i18n->get("rating timeout description"),
- -value=>$self->getValue("ratingTimeout")
- );
- $tabform->getTab("properties")->interval(
- -name=>"ratingTimeoutPrivileged",
- -label=>$i18n->get("rating timeout privileged"),
- -hoverHelp=>$i18n->get("rating timeout privileged description"),
- -value=>$self->getValue("ratingTimeoutPrivileged")
- );
- $tabform->getTab("security")->group(
- -name=>"groupToAdd",
- -label=>$i18n->get("group to add"),
- -hoverHelp=>$i18n->get("group to add description"),
- -value=>[$self->getValue("groupToAdd")]
- );
- $tabform->getTab("security")->group(
- -name=>"privilegedGroup",
- -label=>$i18n->get("privileged group"),
- -hoverHelp=>$i18n->get("privileged group description"),
- -value=>[$self->getValue("privilegedGroup")]
- );
- $tabform->getTab("security")->group(
- -name=>"groupToRate",
- -label=>$i18n->get("rating group"),
- -hoverHelp=>$i18n->get("rating group description"),
- -value=>[$self->getValue("groupToRate")]
- );
- $tabform->getTab("display")->template(
- -name=>"templateId",
- -value=>$self->getValue("templateId"),
- -label=>$i18n->get("main template"),
- -hoverHelp=>$i18n->get("main template description"),
- -namespace=>"Matrix"
- );
- $tabform->getTab("display")->template(
- -name=>"detailTemplateId",
- -value=>$self->getValue("detailTemplateId"),
- -label=>$i18n->get("detail template"),
- -hoverHelp=>$i18n->get("detail template description"),
- -namespace=>"Matrix/Detail"
- );
- $tabform->getTab("display")->template(
- -name=>"ratingDetailTemplateId",
- -value=>$self->getValue("ratingDetailTemplateId"),
- -label=>$i18n->get("rating detail template"),
- -hoverHelp=>$i18n->get("rating detail template description"),
- -namespace=>"Matrix/RatingDetail"
- );
- $tabform->getTab("display")->template(
- -name=>"searchTemplateId",
- -value=>$self->getValue("searchTemplateId"),
- -label=>$i18n->get("search template"),
- -hoverHelp=>$i18n->get("search template description"),
- -namespace=>"Matrix/Search"
- );
- $tabform->getTab("display")->template(
- -name=>"compareTemplateId",
- -value=>$self->getValue("compareTemplateId"),
- -label=>$i18n->get("compare template"),
- -hoverHelp=>$i18n->get("compare template description"),
- -namespace=>"Matrix/Compare"
- );
- return $tabform;
-}
-
-#-------------------------------------------------------------------
-sub www_edit {
- my $self = shift;
- return $self->session->privilege->insufficient() unless $self->canEdit;
- return $self->session->privilege->locked() unless $self->canEditIfLocked;
- my $i18n = WebGUI::International->new($self->session, 'Asset_Wobject');
- my $addEdit = ($self->session->form->process("func") eq 'add') ? $i18n->get('add') : $i18n->get('edit');
- return $self->getAdminConsole->render($self->getEditForm->print, $self->addEditLabel);
-}
-
-#-------------------------------------------------------------------
-
-=head2 www_deleteImage ( )
-
-Deletes and attached file.
-
-=cut
-
-sub www_deleteImage {
- my $self = shift;
- my $listing = $self->session->db->getRow("Matrix_listing","listingId",$self->session->form->process("listingId"));
- my $i18n = WebGUI::International->new($self->session,'Asset_Matrix');
- return $i18n->get('no edit rights') unless ($self->session->user->userId eq $listing->{maintainerId} || $self->canEdit);
- if ($listing->{storageId} ne "") {
- my $storage = WebGUI::Storage::Image->get($self->session, $listing->{storageId});
- $storage->delete;
- }
- return $self->www_editListing($listing, $i18n);
-}
-
-
-
-#-------------------------------------------------------------------
-sub www_editListing {
- my $self = shift;
- my $listing= shift || $self->session->db->getRow("Matrix_listing","listingId",$self->session->form->process("listingId"));
- my $i18n = shift || WebGUI::International->new($self->session,'Asset_Matrix');
- return $i18n->get('no edit rights') unless (($self->session->form->process("listingId") eq "new" && $self->session->user->isInGroup($self->get("groupToAdd"))) || $self->session->user->userId eq $listing->{maintainerId} || $self->canEdit);
- my $f = WebGUI::HTMLForm->new($self->session,-action=>$self->getUrl);
- $f->hidden(
- -name=>"func",
- -value=>"editListingSave"
- );
- $f->hidden(
- -name=>"listingId",
- -value=>$self->session->form->process("listingId")
- );
- $f->text(
- -name=>"productName",
- -value=>$listing->{productName} || 'Undefined',
- -label=>$i18n->get('product name'),
- -hoverHelp=>$i18n->get('product name description'),
- -maxLength=>25
- );
- $f->text(
- -name=>"versionNumber",
- -value=>$listing->{versionNumber},
- -label=>$i18n->get('version number'),
- -hoverHelp=>$i18n->get('version number description'),
- );
- $f->url(
- -name=>"productUrl",
- -value=>$listing->{productUrl},
- -label=>$i18n->get('product url'),
- -hoverHelp=>$i18n->get('product url description'),
- );
- $f->image(
- name=>"screenshot",
- label=>$i18n->get("screenshot"),
- value=>$listing->{storageId},
- hoverHelp=>$i18n->get("screenshot help"),
- deleteFileUrl=>$self->getUrl("func=deleteImage;listingId=".$listing->{listingId}.";filename=")
- );
- $f->text(
- -name=>"manufacturerName",
- -value=>$listing->{manufacturerName},
- -label=>$i18n->get('manufacturer name'),
- -hoverHelp=>$i18n->get('manufacturer name description'),
- );
- $f->url(
- -name=>"manufacturerUrl",
- -value=>$listing->{manufacturerUrl},
- -label=>$i18n->get('manufacturer url'),
- );
- $f->textarea(
- -name=>"description",
- -value=>$listing->{description},
- -label=>$i18n->get('description'),
- );
- if ($self->canEdit) {
- $f->user(
- name=>"maintainerId",
- value=>$listing->{maintainerId},
- label=>$i18n->get('listing maintainer'),
- hoverHelp=>$i18n->get('listing maintainer description'),
- );
- }
- 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"),
- );
- foreach my $category ($self->getCategories()) {
- $f->raw(''.$category.' ');
- my $a;
- if ($self->session->form->process("listingId") ne "new") {
- $a = $self->session->db->read(
- "select a.name, a.fieldType, a.defaultValue, a.description, a.label, b.value, a.fieldId
- from Matrix_field a left join Matrix_listingData b on a.fieldId=b.fieldId and
- listingId=? where a.category=? and a.assetId=? order by a.label",
- [$self->session->form->process("listingId"), $category, $self->getId]);
- } else {
- $a = $self->session->db->read("select name, fieldType, defaultValue, description, label, fieldId
- from Matrix_field where category=".$self->session->db->quote($category)." and assetId=".$self->session->db->quote($self->getId));
- }
- while (my $field = $a->hashRef) {
- if ($field->{fieldType} eq "text") {
- $f->text(
- -name=>$field->{name},
- -value=>$field->{value} || $field->{defaultValue},
- -label=>$field->{label},
- -subtext=>" ".$field->{description}
- );
- } elsif ($field->{fieldType} eq "goodBad") {
- my $value = ($field->{value} || $field->{defaultValue} || $i18n->get("no"));
- $f->selectBox(
- -name=>$field->{name},
- -value=>[$value],
- -label=>$field->{label},
- -options=>\%goodBad,
- -subtext=>" ".$field->{description}
- );
- } elsif ($field->{fieldType} eq "textarea") {
- $f->textarea(
- -name=>$field->{name},
- -value=>$field->{value} || $field->{defaultValue},
- -label=>$field->{label},
- -subtext=>" ".$field->{description}
- );
- } elsif ($field->{fieldType} eq "url") {
- $f->url(
- -name=>$field->{name},
- -value=>$field->{value} || $field->{defaultValue},
- -label=>$field->{label},
- -subtext=>" ".$field->{description}
- );
- } elsif ($field->{fieldType} eq "combo") {
- my $value = ($field->{value} || $field->{defaultValue});
- $f->combo(
- -name=>$field->{name},
- -value=>[$value],
- -label=>$field->{label},
- -options=>$self->session->db->buildHashRef("select distinct value,value from Matrix_listingData
- where fieldId=".$self->session->db->quote($field->{fieldId})." and
- assetId=".$self->session->db->quote($self->getId)." order by value"),
- -subtext=>" ".$field->{description}
- );
- }
-
- }
- $a->finish;
- }
- $f->submit;
- return $self->processStyle($i18n->get('edit listing').$f->print);
-}
-
-
-#-------------------------------------------------------------------
-sub www_editListingSave {
- my $self = shift;
- my $listing = $self->session->db->getRow("Matrix_listing","listingId",$self->session->form->process("listingId"));
- my $i18n = WebGUI::International->new($self->session,'Asset_Matrix');
- return $i18n->get('no edit rights') unless (($self->session->form->process("listingId") eq "new" && $self->session->user->isInGroup($self->get("groupToAdd"))) || $self->session->user->userId eq $listing->{maintainerId} || $self->canEdit);
- my %data = (
- listingId => $self->session->form->process("listingId"),
- lastUpdated => $self->session->datetime->time(),
- productName => $self->session->form->process("productName") || 'Undefined',
- productUrl => $self->session->form->process("productUrl"),
- manufacturerName => $self->session->form->process("manufacturerName"),
- manufacturerUrl => $self->session->form->process("manufacturerUrl"),
- description => $self->session->form->process("description"),
- versionNumber=>$self->session->form->process("versionNumber")
- );
-
- my $storageId = WebGUI::Form::Image->new($self->session,{name => 'screenshot', value => $listing->{storageId}})->getValue;
- if ($storageId) {
- $data{storageId} = $storageId;
- $data{filename} = WebGUI::Storage->get($self->session, $storageId)->getFiles->[0];
- }
-
- my $productName = $self->session->form->process("productName");
-
- my $isNew = 0;
- if ($self->session->form->process("listingId") eq "new") {
- $data{maintainerId} = $self->session->user->userId if ($self->session->form->process("listingId") eq "new");
-
- my $newTag = WebGUI::VersionTag->create($self->session, {
- name => $productName.' / '.$self->session->user->username,
- workflowId => 'pbworkflow000000000003' });
- my $oldTag = WebGUI::VersionTag->getWorking($self->session, 1);
- $newTag->setWorking;
-
- my $forum = $self->addChild({
- className=>"WebGUI::Asset::Wobject::Collaboration",
- title=>$productName,
- menuTitle=>$productName,
- url=>$productName,
- groupIdView=>$self->get('groupIdView'),
- groupIdEdit=>$self->get('groupIdEdit'),
- displayLastReply => 0,
- allowReplies => 1,
- threadsPerPage => 30,
- postsPerPage => 10,
- archiveAfter =>31536000,
- useContentFilter => 1,
- filterCode => 'javascript',
- richEditor => "PBrichedit000000000002",
- attachmentsPerPost => 0,
- editTimeout => 3600,
- addEditStampToPosts => 0,
- usePreview => 1,
- sortOrder => 'desc',
- sortBy => 'assetData.revisionDate',
- rssTemplateId=>'PBtmpl0000000000000142',
- notificationTemplateId=>'PBtmpl0000000000000027',
- searchTemplateId=>'PBtmpl0000000000000031',
- postFormTemplateId=>'PBtmpl0000000000000029',
- threadTemplateId=>'PBtmpl0000000000000032',
- collaborationTemplateId=>'PBtmpl0000000000000026',
- karmaPerPost =>0,
- karmaSpentToRate => 0,
- approvalWorkflow=>"pbworkflow000000000003",
- karmaRatingMultiplier => 0,
- moderatePosts => 0,
- moderateGroupId => $self->get('groupIdEdit'),
- postGroupId => $self->get('groupIdView'),
- styleTemplateId => $self->get('styleTemplateId'),
- printableStyleTemplateId => $self->get('printableStyleTemplateId'),
- });
- $newTag->requestCommit;
- $newTag->clearWorking;
- $oldTag->setWorking if defined $oldTag;
-
- $data{forumId} = $forum->getId;
- $data{status} = "pending";
- $isNew = 1;
- }
- else {
- my $forum = WebGUI::Asset::Wobject::Collaboration->new($self->session, $listing->{forumId});
- if ($forum && $forum->get('title') ne $productName) {
- my $oldTag = WebGUI::VersionTag->getWorking($self->session, 1);
- my $newTag = WebGUI::VersionTag->create($self->session, {
- name => $productName.' / '.$self->session->user->username,
- workflowId => 'pbworkflow000000000003' });
- $newTag->setWorking;
- $forum->addRevision({
- title => $productName,
- menuTitle => $productName,
- url => $productName,
- });
- $newTag->requestCommit;
- $newTag->clearWorking;
- $oldTag->setWorking
- if defined $oldTag;
- }
- }
- $data{maintainerId} = $self->session->form->process("maintainerId") if ($self->canEdit);
- $data{assetId} = $self->getId;
- my $listingId = $self->session->db->setRow("Matrix_listing","listingId",\%data);
- if ($data{status} eq "pending" && !$listing->{approvalMessageId}) {
- my $approvalMessage = WebGUI::Inbox->new($self->session)->addMessage({
- status=>'pending',
- groupId=>$self->get("groupIdEdit"),
- userId=>$self->get("ownerUserId"),
- subject=>"New Listing Added",
- message=>"A new listing, ".$data{productName}.", is waiting to be added.\n\n".$self->session->url->getSiteURL()."/".$self->formatURL("viewDetail",$listingId)
- });
- $self->session->db->setRow("Matrix_listing","listingId",{listingId=>$listingId, approvalMessageId=>$approvalMessage->getId});
- }
- my $a = $self->session->db->read("select fieldId, name, fieldType from Matrix_field");
- while (my ($id, $name, $type) = $a->array) {
- my $value;
- if ($type eq "goodBad") {
- $value = $self->session->form->selectBox($name);
- } else {
- $value = $self->session->form->process($name,$type);
- }
- $self->session->db->write("replace into Matrix_listingData (assetId, listingId, fieldId, value) values (
- ".$self->session->db->quote($self->getId).", ".$self->session->db->quote($listingId).", ".$self->session->db->quote($id).", ".$self->session->db->quote($value).")");
- }
- $a->finish;
- return $self->www_viewDetail($listingId);
-}
-
-#-------------------------------------------------------------------
-sub www_editField {
- my $self = shift;
- return $self->session->privilege->insufficient() unless($self->canEdit);
- my $i18n = WebGUI::International->new($self->session,'Asset_Matrix');
- my $field = $self->session->db->getRow("Matrix_field","fieldId",$self->session->form->process("fieldId"));
- my $f = WebGUI::HTMLForm->new($self->session,-action=>$self->getUrl);
- $f->hidden(
- -name=>"func",
- -value=>"editFieldSave"
- );
- $f->hidden(
- -name=>"fieldId",
- -value=>$self->session->form->process("fieldId")
- );
- $f->text(
- -name=>"name",
- -value=>$field->{name},
- -label=>$i18n->get('field name'),
- -hoverHelp=>$i18n->get('field name description'),
- );
- $f->text(
- -name=>"label",
- -value=>$field->{label},
- -label=>$i18n->get('field label'),
- -hoverHelp=>$i18n->get('field label description'),
- );
- $f->selectBox(
- -name=>"fieldType",
- -value=>[$field->{fieldType}],
- -label=>$i18n->get('field type'),
- -hoverHelp=>$i18n->get('field type description'),
- -options=>{
- 'goodBad' => $i18n->get('good bad'),
- 'text' => $i18n->get('text'),
- 'url' => $i18n->get('url'),
- 'textarea' => $i18n->get('text area'),
- 'combo' => $i18n->get('combo'),
- }
- );
- $f->textarea(
- -name=>"description",
- -value=>$field->{description},
- -label=>$i18n->get('field description'),
- -hoverHelp=>$i18n->get('field description description'),
- );
- $f->text(
- -name=>"defaultValue",
- -value=>$field->{defaultValue},
- -label=>$i18n->get('default value'),
- -hoverHelp=>$i18n->get('default value description'),
- );
- my %cats;
- foreach my $category ($self->getCategories) {
- $cats{$category} = $category;
- }
- $f->selectBox(
- -name=>"category",
- -value=>[$field->{category}],
- -label=>$i18n->get('category'),
- -hoverHelp=>$i18n->get('category description'),
- -options=>\%cats
- );
- $f->submit;
- return $self->processStyle($i18n->get('edit field').$f->print);
-}
-
-
-#-------------------------------------------------------------------
-sub www_editFieldSave {
- my $self = shift;
- return $self->session->privilege->insufficient() unless($self->canEdit);
- $self->session->db->setRow("Matrix_field","fieldId",{
- fieldId=>$self->session->form->process("fieldId"),
- name=>$self->session->form->process("name"),
- label=>$self->session->form->process("label"),
- fieldType=>$self->session->form->process("fieldType"),
- description=>$self->session->form->process("description"),
- defaultValue=>$self->session->form->process("defaultValue"),
- category=>$self->session->form->process("category"),
- assetId=>$self->getId
- });
- return $self->www_listFields();
-}
-
-#-------------------------------------------------------------------
-sub www_listFields {
- my $self = shift;
- return $self->session->privilege->insufficient() unless($self->canEdit);
- my $i18n = WebGUI::International->new($self->session,'Asset_Matrix');
- my $output = sprintf $i18n->get('list fields'),
- $self->getUrl("func=editField;fieldId=new");
- my $sth = $self->session->db->read("select fieldId, label from Matrix_field where assetId=".$self->session->db->quote($self->getId)." order by label");
- while (my ($id, $label) = $sth->array) {
- $output .= $self->session->icon->delete("func=deleteField;fieldId=".$id, $self->get("url"), $i18n->get("delete field confirm"))
- .$self->session->icon->edit("func=editField;fieldId=".$id)
- .' '.$label." \n";
- }
- $sth->finish;
- return $self->processStyle($output);
-}
-
-
-#-------------------------------------------------------------------
-sub www_rate {
- my $self = shift;
- my $hasRated = $self->hasRated($self->session->form->process("listingId"));
- my $sameRating = 1;
- my $first = 1;
- my $lastRating;
- foreach my $category ($self->getCategories) {
- if ($first) {
- $first=0;
- } else {
- if ($lastRating != $self->session->form->process($category)) {
- $sameRating = 0;
- }
- }
- $lastRating = $self->session->form->process($category);
- }
- return $self->www_viewDetail("",1) if ($hasRated || $sameRating); # Throw out ratings that are all the same number, or if the user rates twice.
- $self->setRatings($self->session->form->process("listingId"),$self->session->form->paramsHashRef);
- return $self->www_viewDetail;
-}
-
-#-------------------------------------------------------------------
-sub www_search {
- my $self = shift;
- my %var;
- my @list = $self->session->db->buildArray("select listingId from Matrix_listing");
- if ($self->session->form->process("doit")) {
- my $count;
- my $keyword;
- if ($self->session->form->process("keyword")) {
- $keyword = " and (a.value like ".$self->session->db->quote('%'.$self->session->form->process("keyword").'%')." or a.value='Any')";
- }
- my $sth = $self->session->db->read("select name,fieldType from Matrix_field");
- while (my ($name,$fieldType) = $sth->array) {
- next unless ($self->session->form->process($name));
- push(@list,0);
- my $where;
- if ($fieldType ne "goodBad") {
- $where = "("
- ."a.value like ".$self->session->db->quote("%".$self->session->form->process($name)."%")
- ." or a.value='Any'"
- ." or a.value='Free'"
- .")";
- } else {
- $where = "a.value<>'no'";
- }
- @list = $self->session->db->buildArray("select a.listingId from Matrix_listingData a left join Matrix_field b
- on (a.fieldId=b.fieldId)
- where a.listingId in (".$self->session->db->quoteAndJoin(\@list).") and $where and b.name=".$self->session->db->quote($name));
- $count = scalar(@list);
- last unless ($count > 0);
- }
- $sth->finish;
- if ($count > 1 && $count < 11) {
- return $self->www_compare(@list);
- } elsif ($count == 1) {
- return $self->www_viewDetail($list[0]);
- } else {
- my $max = $self->session->user->isInGroup($self->get("privilegedGroup")) ? $self->get("maxComparisonsPrivileged") : $self->get("maxComparisons");
- $var{isTooMany} = ($count>$max);
- $var{isTooFew} = ($count<2);
- }
- }
- $var{'isLoggedIn'} = ($self->session->user->isRegistered);
- $var{'compare.form'} = $self->getCompareForm(@list);
- $var{'form.header'} = WebGUI::Form::formHeader($self->session,{action=>$self->getUrl})
- .WebGUI::Form::hidden($self->session,{
- name=>"doit",
- value=>"1"
- })
- .WebGUI::Form::hidden($self->session,{
- name=>"func",
- value=>"search"
- });
- $var{'form.footer'} = "";
- $var{'form.keyword'} = WebGUI::Form::text($self->session,{
- name=>"keyword",
- value=>$self->session->form->process("keyword")
- });
- $var{'form.submit'} = WebGUI::Form::submit($self->session,{
- value=>"search"
- });
- foreach my $category ($self->getCategories()) {
- my $sth = $self->session->db->read("select name, fieldType, label, description from Matrix_field where category = ".$self->session->db->quote($category)." order by label");
- my @loop;
- while (my $data = $sth->hashRef) {
- if ($data->{fieldType} ne "goodBad") {
- $data->{form} = WebGUI::Form::text($self->session,{
- name=>$data->{name},
- value=>$self->session->form->process($data->{name})
- });
- } else {
- $data->{form} = WebGUI::Form::checkbox($self->session,{
- name=>$data->{name},
- value=>"1",
- checked=>$self->session->form->process($data->{name})
- });
- }
- push(@loop,$data);
- }
- $sth->finish;
- $var{$self->session->url->urlize($category)."_loop"} = \@loop;
- }
- return $self->processStyle($self->processTemplate(\%var,$self->get("searchTemplateId")));
-}
-
-
-#-------------------------------------------------------------------
sub view {
- my $self = shift;
- if ($self->session->user->isVisitor) {
- my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get;
- return $out if $out;
- }
- my (%var);
- $var{'compare.form'} = $self->getCompareForm;
- $var{'search.url'} = $self->getUrl("func=search");
- $var{'isLoggedIn'} = ($self->session->user->isRegistered);
- $var{'field.list.url'} = $self->getUrl('func=listFields');
- $var{'listing.add.url'} = $self->formatURL("editListing","new");
+ my $self = shift;
+ my $session = $self->session;
+ my $db = $session->db;
- my $data = $self->session->db->quickHashRef("select views, productName, listingId from Matrix_listing
- where assetId=".$self->session->db->quote($self->getId)." and status='approved' order by views desc limit 1");
- $var{'best.views.url'} = $self->formatURL("viewDetail",$data->{listingId});
- $var{'best.views.count'} = $data->{views};
- $var{'best.views.name'} = $data->{productName};
- $data = $self->session->db->quickHashRef("select compares, productName, listingId from Matrix_listing
- where assetId=".$self->session->db->quote($self->getId)." and status='approved' order by compares desc limit 1");
- $var{'best.compares.url'} = $self->formatURL("viewDetail",$data->{listingId});
- $var{'best.compares.count'} = $data->{compares};
- $var{'best.compares.name'} = $data->{productName};
- $data = $self->session->db->quickHashRef("select clicks, productName, listingId from Matrix_listing
- where assetId=".$self->session->db->quote($self->getId)." and status='approved' order by clicks desc limit 1");
- $var{'best.clicks.url'} = $self->formatURL("viewDetail",$data->{listingId});
- $var{'best.clicks.count'} = $data->{clicks};
- $var{'best.clicks.name'} = $data->{productName};
- my (@best,@worst);
- foreach my $category ($self->getCategories) {
- my $sql = "
- select
- Matrix_listing.productName,
- Matrix_listing.listingId,
- Matrix_ratingSummary.meanValue,
- Matrix_ratingSummary.medianValue,
- Matrix_ratingSummary.countValue
- from
- Matrix_listing
- left join
- Matrix_ratingSummary
- on
- Matrix_listing.listingId=Matrix_ratingSummary.listingId and
- Matrix_ratingSummary.category=".$self->session->db->quote($category)."
- where
- Matrix_listing.assetId=".$self->session->db->quote($self->getId)." and
- Matrix_listing.status='approved' and
- Matrix_ratingSummary.countValue >= 10
- order by
- Matrix_ratingSummary.meanValue
- ";
- $data = $self->session->db->quickHashRef($sql." desc limit 1");
- push(@best,{
- url=>$self->formatURL("viewDetail",$data->{listingId}),
- category=>$category,
- name=>$data->{productName},
- mean=>$data->{meanValue},
- median=>$data->{medianValue},
- count=>$data->{countValue}
- });
- $data = $self->session->db->quickHashRef($sql." asc limit 1");
- push(@worst,{
- url=>$self->formatURL("viewDetail",$data->{listingId}),
- category=>$category,
- name=>$data->{productName},
- mean=>$data->{meanValue},
- median=>$data->{medianValue},
- count=>$data->{countValue}
- });
- }
- $var{'best_rating_loop'} = \@best;
- $var{'worst_rating_loop'} = \@worst;
- $var{'ratings.details.url'} = $self->getUrl("func=viewRatingDetails");
- $data = $self->session->db->quickHashRef("select lastUpdated, productName, listingId from Matrix_listing
- where assetId=".$self->session->db->quote($self->getId)." and status='approved' order by lastUpdated desc limit 1");
- my @lastUpdated;
- my $sth = $self->session->db->read("select listingId,lastUpdated,productName from Matrix_listing order by lastUpdated desc limit 20");
- while (my ($listingId, $lastUpdated, $productName) = $sth->array) {
- push(@lastUpdated, {
- url => $self->formatURL("viewDetail",$listingId),
- name=>$productName,
- lastUpdated=>$self->session->datetime->epochToHuman($lastUpdated,"%z")
- });
- }
- $var{'last_updated_loop'} = \@lastUpdated;
- $var{'best.updated.url'} = $self->formatURL("viewDetail",$data->{listingId});
- $var{'best.updated.date'} = $self->session->datetime->epochToHuman($data->{lastUpdated},"%z");;
- $var{'best.updated.name'} = $data->{productName};
+ # javascript and css files for compare form datatable
+ $self->session->style->setLink($self->session->url->extras('yui/build/datatable/assets/skins/sam/datatable.css'),
+ {type =>'text/css', rel=>'stylesheet'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/json/json-min.js'), {type =>
+ 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/connection/connection-min.js'), {type =>
+ 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/get/get-min.js'), {type =>
+ 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/element/element-beta-min.js'), {type =>
+ 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/datasource/datasource-min.js'), {type =>
+ 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/datatable/datatable-min.js'), {type =>
+ 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/button/button-min.js'), {type =>
+ 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('wobject/Matrix/matrix.js'), {type =>
+ 'text/javascript'});
- # site stats
- ($var{'user.count'}) = $self->session->db->quickArray("select count(*) from users");
- ($var{'current.user.count'}) = $self->session->db->quickArray("select count(*)+0 from userSession where lastPageView>".($self->session->datetime->time()-600));
- ($var{'listing.count'}) = $self->session->db->quickArray("select count(*) from Matrix_listing where status = 'approved' and assetId=".$self->session->db->quote($self->getId));
- $sth = $self->session->db->read("select listingId,productName from Matrix_listing where status='pending' and assetId=?",[$self->getId]);
- while (my ($id,$name) = $sth->array) {
- push(@{$var{pending_list}},{
- url=>$self->formatURL("viewDetail",$id),
- productName=>$name
- });
- }
- $sth->finish;
- my $out = $self->processTemplate(\%var,undef,$self->{_viewTemplate});
- if ($self->session->user->isVisitor) {
- WebGUI::Cache->new($self->session,"view_".$self->getId)->set($out,$self->get("visitorCacheTimeout"));
- }
- return $out;
-}
+ my $var = $self->get;
+ $var->{isLoggedIn} = ($self->session->user->userId ne "1");
+ $var->{addMatrixListing_url} = $self->getUrl('func=add;class=WebGUI::Asset::MatrixListing');
+ $var->{compareForm} = $self->getCompareForm;
+ $var->{exportAttributes_url} = $self->getUrl('func=exportAttributes');
+ $var->{listAttributes_url} = $self->getUrl('func=listAttributes');
+
+ # Get the MatrixListing with the most views as an object using getLineage.
+ my ($bestViews_listing) = @{ $self->getLineage(['descendants'], {
+ includeOnlyClasses => ['WebGUI::Asset::MatrixListing'],
+ joinClass => "WebGUI::Asset::MatrixListing",
+ orderByClause => "views desc",
+ limit => 1,
+ returnObjects => 1,
+ }) };
+ $var->{bestViews_url} = $bestViews_listing->getUrl;
+ $var->{bestViews_count} = $bestViews_listing->get('views');
+ $var->{bestViews_name} = $bestViews_listing->get('title');
+ $var->{bestViews_sortButton} = "Sort by views ";
+
+ # Get the MatrixListing with the most compares as an object using getLineage.
+
+ my ($bestCompares_listing) = @{ $self->getLineage(['descendants'], {
+ includeOnlyClasses => ['WebGUI::Asset::MatrixListing'],
+ joinClass => "WebGUI::Asset::MatrixListing",
+ orderByClause => "compares desc",
+ limit => 1,
+ returnObjects => 1,
+ }) };
+ $var->{bestCompares_url} = $bestCompares_listing->getUrl;
+ $var->{bestCompares_count} = $bestCompares_listing->get('views');
+ $var->{bestCompares_name} = $bestCompares_listing->get('title');
+ $var->{bestCompares_sortButton} = "Sort by compares ";
+
+ # Get the MatrixListing with the most clicks as an object using getLineage.
+ my ($bestClicks_listing) = @{ $self->getLineage(['descendants'], {
+ includeOnlyClasses => ['WebGUI::Asset::MatrixListing'],
+ joinClass => "WebGUI::Asset::MatrixListing",
+ orderByClause => "clicks desc",
+ limit => 1,
+ returnObjects => 1,
+ }) };
+ $var->{bestClicks_url} = $bestClicks_listing->getUrl;
+ $var->{bestClicks_count} = $bestClicks_listing->get('views');
+ $var->{bestClicks_name} = $bestClicks_listing->get('title');
+ $var->{bestClicks_sortButton} = "Sort by clicks ";
+
+ # Get the 5 MatrixListings that were last updated as objects using getLineage.
+
+ my @lastUpdatedListings = @{ $self->getLineage(['descendants'], {
+ includeOnlyClasses => ['WebGUI::Asset::MatrixListing'],
+ orderByClause => "revisionDate desc",
+ limit => 5,
+ returnObjects => 1,
+ }) };
+ foreach my $lastUpdatedListing (@lastUpdatedListings){
+ push (@{ $var->{last_updated_loop} }, {
+ url => $lastUpdatedListing->getUrl,
+ name => $lastUpdatedListing->get('title'),
+ lastUpdated => $self->session->datetime->epochToHuman($lastUpdatedListing->get('revisionDate'),"%z")
+ });
+ }
+ $var->{lastUpdated_sortButton} = "Sort by updated ";
+
+
+ # Get all the MatrixListings that are still pending.
+
+ my @pendingListings = @{ $self->getLineage(['descendants'], {
+ includeOnlyClasses => ['WebGUI::Asset::MatrixListing'],
+ orderByClause => "revisionDate asc",
+ returnObjects => 1,
+ statusToInclude => ['pending'],
+ }) };
+ foreach my $pendingListing (@pendingListings){
+ push (@{ $var->{pending_loop} }, {
+ url => $pendingListing->getUrl,
+ name => $pendingListing->get('title'),
+ });
+ }
+ # For each category, get the MatrixListings with the best ratings.
+
+ foreach my $category (keys %{$self->getCategories}) {
+ my $data;
+ my $sql = "
+ select
+ assetData.title as productName,
+ assetData.url,
+ listing.assetId,
+ rating.meanValue,
+ rating.medianValue,
+ rating.countValue
+ from MatrixListing as listing
+ left join asset on listing.assetId = asset.assetId
+ left join MatrixListing_ratingSummary as rating on rating.listingId = listing.assetId
+ left join assetData on assetData.assetId = listing.assetId and listing.revisionDate =
+assetData.revisionDate
+ where
+ asset.parentId=?
+ and asset.state='published'
+ and asset.className='WebGUI::Asset::MatrixListing'
+ and assetData.revisionDate=(
+ select
+ max(revisionDate)
+ from
+ assetData
+ where
+ assetData.assetId=asset.assetId
+ and (status='approved' or status='archived')
+ )
+ and status='approved'
+ and rating.category=?
+ group by
+ assetData.assetId
+ order by rating.meanValue ";
+
+ $data = $db->quickHashRef($sql." desc limit 1",[$self->getId,$category]);
+ push(@{ $var->{best_rating_loop} },{
+ url=>'/'.$data->{url},
+ category=>$category,
+ name=>$data->{productName},
+ mean=>$data->{meanValue},
+ median=>$data->{medianValue},
+ count=>$data->{countValue}
+ });
+ $data = $db->quickHashRef($sql." asc limit 1",[$self->getId,$category]);
+ push(@{ $var->{worst_rating_loop} },{
+ url=>'/'.$data->{url},
+ category=>$category,
+ name=>$data->{productName},
+ mean=>$data->{meanValue},
+ median=>$data->{medianValue},
+ count=>$data->{countValue}
+ });
+ }
+
+ $var->{listingCount} = scalar $db->buildArray("
+ select *
+ from asset, assetData
+ where asset.assetId=assetData.assetId
+ and asset.parentId=?
+ and asset.state='published'
+ and asset.className='WebGUI::Asset::MatrixListing'
+ and assetData.status='approved'
+ group by asset.assetId",
+ [$self->getId]);
+
+ return $self->processTemplate($var, undef, $self->{_viewTemplate});
+}
+
#-------------------------------------------------------------------
-=head2 www_view ( )
+=head2 www_compare ( )
-See WebGUI::Asset::Wobject::www_view() for details.
+Returns the compare screen
=cut
-sub www_view {
- my $self = shift;
- $self->session->http->setCacheControl($self->get("visitorCacheTimeout")) if ($self->session->user->isVisitor);
- $self->SUPER::www_view(@_);
+sub www_compare {
+
+ my $self = shift;
+ my $var = $self->get;
+ my @listingIds = @_;
+ my @columnKeys;
+
+ unless (scalar(@listingIds)) {
+ @listingIds = $self->session->form->checkList("listingId");
+ }
+
+ $self->session->style->setScript($self->session->url->extras('yui/build/yahoo/yahoo-min.js'),
+ {type => 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/dom/dom-min.js'),
+ {type => 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/event/event-min.js'),
+ {type => 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/json/json-min.js'), {type =>
+ 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/connection/connection-min.js'),
+ {type => 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/get/get-min.js'), {type =>
+ 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/element/element-beta-min.js'), {type =>
+ 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/datasource/datasource-min.js'),
+ {type => 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/datatable/datatable-min.js'),
+ {type =>'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/button/button-min.js'),
+ {type =>'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('wobject/Matrix/matrixCompareList.js'), {type =>
+ 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('wobject/Matrix/matrix.js'), {type =>
+ 'text/javascript'});
+ $self->session->style->setLink($self->session->url->extras('yui/build/datatable/assets/skins/sam/datatable.css'),
+ {type =>'text/css', rel=>'stylesheet'});
+
+ my $maxComparisons;
+ if($self->session->user->isVisitor){
+ $maxComparisons = $self->get('maxComparisons');
+ }
+ else{
+ $maxComparisons = $self->get('maxComparisonsPrivileged');
+ }
+
+ foreach my $listingId (@listingIds){
+ my $listingId_safe = $listingId;
+ $listingId_safe =~ s/-/_____/g;
+ push(@columnKeys, $listingId_safe);
+ push(@columnKeys, $listingId_safe."_compareColor");
+ }
+
+ $var->{javascript} = "";
+
+ return $self->processStyle($self->processTemplate($var,$self->get("compareTemplateId")));
}
#-------------------------------------------------------------------
-sub www_viewDetail {
- my $self = shift;
- my $listingId = shift || $self->session->form->process("listingId");
- my $hasRated = shift || $self->hasRated($listingId);
- my %var;
- my $i18n = WebGUI::International->new($self->session,'Asset_Matrix');
- my $listing = $self->session->db->getRow("Matrix_listing","listingId",$listingId);
- my $forum = WebGUI::Asset::Wobject::Collaboration->new($self->session, $listing->{forumId});
- if ($listing->{storageId} && $listing->{filename}) {
- my $storage = WebGUI::Storage::Image->get($self->session, $listing->{storageId});
- $var{screenshot} = $storage->getUrl($listing->{filename});
- $var{thumbnail} = $storage->getThumbnailUrl($listing->{filename});
- }
- $var{"discussion"} = $forum && $forum->view;
- $var{'isLoggedIn'} = ($self->session->user->isRegistered);
- if ($self->session->form->process("do") eq "sendEmail" && $self->session->form->process("verify","captcha")) {
- if ($self->session->form->process("body") ne "") {
- my $u = WebGUI::User->new($self->session, $listing->{maintainerId});
- my $mail = WebGUI::Mail::Send->create($self->session, {to=>$u->profileField("email"),subject=>$listing->{productName}." - ".$self->session->form->process("subject"),from=>$self->session->form->process("from")});
- $mail->addText($self->session->form->process("body"));
- $mail->addFooter;
- $mail->queue;
- }
- $var{'email.wasSent'} = 1;
- } else {
- $self->incrementCounter($listingId,"views");
- }
- $var{'edit.url'} = $self->formatURL("editListing",$listingId);
- $var{id} = $listingId;
- $var{'user.canEdit'} = ($self->session->user->userId eq $listing->{maintainerId} || $self->canEdit);
- $var{'user.canApprove'} = $self->canEdit;
- $var{'approve.url'} = $self->getUrl("func=approveListing;listingId=".$listingId);
- $var{'delete.url'} = $self->getUrl("func=deleteListing;listingId=".$listingId);
- $var{'isPending'} = ($listing->{status} eq "pending");
- $var{'lastUpdated.epoch'} = $listing->{lastupdated};
- $var{'lastUpdated.date'} = $self->session->datetime->epochToHuman($listing->{lastUpdated},"%z");
- $var{description} = $listing->{description};
- $var{productName} = $listing->{productName};
- $var{productUrl} = $listing->{productUrl};
- $var{'productUrl.click'} = $self->formatURL("click",$listingId);
- $var{manufacturerName} = $listing->{manufacturerName};
- $var{manufacturerUrl} = $listing->{manufacturerUrl};
- $var{'manufacturerUrl.click'} = $self->getUrl("m=1;func=click;listingId=".$listingId);
- $var{versionNumber} = $listing->{versionNumber};
- my $f = WebGUI::HTMLForm->new($self->session,
- -extras=>'class="content"',
- -tableExtras=>'class="content"'
- );
- $f->hidden(
- -name=>"func",
- -value=>"viewDetail"
- );
- $f->hidden(
- -name=>"do",
- -value=>"sendEmail"
- );
- $f->hidden(
- -name=>"listingId",
- -value=>$listingId
- );
- $f->captcha(
- -name=>"verify"
- );
- $f->email(
- -extras=>'class="content"',
- -name=>"from",
- -value=>$self->session->user->profileField("email"),
- -label=>$i18n->get('your email'),
- );
- $f->selectBox(
- -name=>"subject",
- -extras=>'class="content"',
- -options=>{
- $i18n->get('report error')=>"Report an error.",
- $i18n->get('general comment')=>"General comment.",
- },
- -label=>$i18n->get('request type'),
- );
- $f->textarea(
- -rows=>4,
- -extras=>'class="content"',
- -columns=>35,
- -name=>"body",
- -label=>$i18n->get('comment'),
- );
- $f->submit(
- -extras=>'class="content"',
- -value=>"Send..."
- );
- $var{'email.form'} = $f->print;
- $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, 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]);
- 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}};
+
+=head2 www_deleteAttribute ( )
+
+Deletes an Attribute, including listing data for this attribute.
+
+=cut
+
+sub www_deleteAttribute {
+ my $self = shift;
+ my $attributeId = $self->session->form->process("attributeId");
+ return $self->session->privilege->insufficient() unless $self->canEdit;
+
+ $self->deleteAttribute($attributeId);
+
+ return $self->www_listAttributes;
+}
+
+#-------------------------------------------------------------------
+
+=head2 www_editAttribute ( )
+
+Shows a form to edit or add an attribute.
+
+=cut
+
+sub www_editAttribute {
+ my $self = shift;
+ my $session = $self->session;
+ my ($attributeId, $attribute);
+
+ return $session->privilege->insufficient() unless $self->canEdit;
+ my $i18n = WebGUI::International->new($session, "Asset_Matrix");
+
+ $attributeId = $session->form->process("attributeId") || 'new';
+
+ unless($attributeId eq 'new'){
+ $attribute = $self->getAttribute($attributeId);
+ }
+
+ my $form = WebGUI::HTMLForm->new($self->session,-action=>$self->getUrl);
+ $form->hidden(
+ -name =>"func",
+ -value =>"editAttributeSave"
+ );
+ $form->hidden(
+ -name =>"attributeId",
+ -value =>$attributeId,
+ );
+ $form->text(
+ -name =>"name",
+ -value =>$attribute->{name},
+ -label =>$i18n->get('attribute name label'),
+ -hoverHelp =>$i18n->get('attribute name description'),
+ );
+ $form->textarea(
+ -name =>"description",
+ -value =>$attribute->{description},
+ -label =>$i18n->get('attribute description label'),
+ -hoverHelp =>$i18n->get('attribute description description'),
+ );
+ $form->matrixFieldType(
+ -name =>"fieldType",
+ -value =>$attribute->{fieldType},
+ -label =>$i18n->get('fieldType label'),
+ -hoverHelp =>$i18n->get('fieldType description'),
+ );
+ my $defaultValueForm = WebGUI::Form::Text($self->session, {
+ name=>"defaultValue",
+ value=>$attribute->{defaultValue},
+ #subtext=>' '.$i18n->get('default value subtext'),
+ #width=>200,
+ #height=>60,
+ resizable=>0,
+ });
+ my $optionsForm = WebGUI::Form::Textarea($self->session, {
+ name=>"options",
+ value=>$attribute->{options},
+ });
+
+ my $html = "\n\n";
+ $html .= "\t\n";
+ $html .= "\t
\n";
+ $html .= "\t
\n";
+
+ $html .= "\t"
+ .$i18n->get('attribute defaultValue label')
+ ."".$i18n->get('attribute defaultValue description')."
"
+ .""
+ .$defaultValueForm." "
+ ."\t\n \n";
+
+ $html .= "\t"
+ .$i18n->get('attribute options label')
+ ."".$i18n->get('attribute options description')."
"
+ .""
+ .$optionsForm." "
+ ."\t\n \n";
+
+
+ $html .= "\t
";
+ $html .= "\t\n
\t\n
\n";
+ $html .= " ";
+
+ $html .= "\n";
+
+ $form->raw($html);
+
+ $form->selectBox(
+ -name =>"category",
+ -value =>[$attribute->{category}],
+ -label =>$i18n->get('category label'),
+ -hoverHelp =>$i18n->get('category description'),
+ -options =>$self->getCategories,
+ );
+ $form->submit;
+ return $self->getAdminConsole->render($form->print, $i18n->get('edit attribute title'));
+}
+
+#-------------------------------------------------------------------
+
+=head2 www_editAttributeSave ( )
+
+Processes and saves an attribute.
+
+=cut
+
+sub www_editAttributeSave {
+ my $self = shift;
+ my $session = $self->session;
+ my $form = $session->form;
+
+ return $session->privilege->insufficient() unless $self->canEdit;
+
+ my $attributeProperties = {
+ attributeId =>$form->process("attributeId") || 'new',
+ assetId =>$self->getId,
+ name =>$form->process('name'),
+ description =>$form->process('description'),
+ fieldType =>$form->process('fieldType'),
+ options =>$form->process('options'),
+ defaultValue =>$form->process('defaultValue'),
+ category =>$form->process('category'),
+ };
+
+ $self->editAttributeSave($attributeProperties);
+
+ return $self->www_listAttributes;
+}
+
+#-------------------------------------------------------------------
+
+=head2 www_exportAttributes ( )
+
+Exports search attributes as csv.
+
+=cut
+
+sub www_exportAttributes {
+ my $self = shift;
+ my $session = $self->session;
+ my $output = WebGUI::Text::joinCSV("name","description","category");
+
+ my $attributes = $session->db->read("select name, description, category
+ from Matrix_attribute where assetId = ? order by category, name",[$self->getId]);
+
+ while (my $attribute = $attributes->hashRef) {
+ $output .= "\n".WebGUI::Text::joinCSV($attribute->{name},$attribute->{description},$attribute->{category});
+ }
+ my $fileName = "export_matrix_attributes.csv";
+ $self->session->http->setFilename($fileName,"application/octet-stream");
+ $self->session->http->sendHeader;
+ return $output;
+}
+
+#-------------------------------------------------------------------
+
+=head2 www_getCompareFormData ( )
+
+Returns the compare form data as JSON.
+
+=cut
+
+sub www_getCompareFormData {
+
+ my $self = shift;
+ my $session = $self->session;
+ my $form = $session->form;
+ my $sortDirection = ' asc';
+
+ my @results;
+ my @listingIds = $self->session->form->checkList("listingId");
+
+ $self->session->http->setMimeType("application/json");
+
+ my $sql = "
+ select
+ assetData.title,
+ assetData.url,
+ listing.assetId,
+ listing.views,
+ listing.compares,
+ listing.clicks,
+ listing.lastUpdated
+ from MatrixListing as listing
+ left join asset on listing.assetId = asset.assetId
+ left join assetData on assetData.assetId = listing.assetId and listing.revisionDate =
+assetData.revisionDate
+ where
+ asset.parentId=?
+ and asset.state='published'
+ and asset.className='WebGUI::Asset::MatrixListing'
+ and assetData.revisionDate=(
+ select
+ max(revisionDate)
+ from
+ assetData
+ where
+ assetData.assetId=asset.assetId
+ and (status='approved' or status='archived')
+ )
+ and status='approved'
+ group by
+ assetData.assetId
+ order by ".$self->get('defaultSort').$sortDirection;
+
+ @results = @{ $session->db->buildArrayRefOfHashRefs($sql,[$self->getId]) };
+ foreach my $result (@results){
+ if($form->process("search")){
+ $self->session->errorHandler->warn("checking listing: ".$result->{title});
+ foreach my $param ($form->param) {
+ if($param =~ m/^search_/){
+ my $attributeId = $param;
+ $attributeId =~ s/^search_//;
+ $attributeId =~ s/_____/-/;
+ my ($listingValue,$fieldType) = $session->db->quickArray("
+ select value, fieldType from MatrixListing_attribute as listing
+ left join Matrix_attribute using(attributeId)
+ where listing.attributeId = ? and listing.matrixListingId = ?
+ ",[$attributeId,$result->{assetId}]);
+ $self->session->errorHandler->warn("fieldType:".$fieldType.", attributeValue: ".$form->process($param).", listingvalue: ".$listingValue);
+ if(($fieldType eq 'MatrixCompare') && ($listingValue < $form->process($param))){
+ undef $result->{checked};
+ last;
+ }
+ elsif(($fieldType ne 'MatrixCompare') && ($form->process($param) ne $listingValue)){
+ undef $result->{checked};
+ last;
+ }
+ else{
+ $self->session->errorHandler->warn("--Checked--");
+ $result->{checked} = 'checked';
+ }
+ }
+ }
+ }
+ else{
+ $result->{assetId} =~ s/-/_____/g;
+ if(WebGUI::Utility::isIn($result->{assetId},@listingIds)){
+ $result->{checked} = 'checked';
+ }
+ }
+ $result->{assetId} =~ s/-/_____/g;
+ $result->{url} = "/".$result->{url};
+ $result->{checkBox} = " {checked}){
+ $result->{checkBox} .= " checked='checked'";
+ }
+ $result->{checkBox} .= " onChange='javascript:compareFormButton()' class='compareCheckBox'>";
+ }
+
+ my $jsonOutput;
+ $jsonOutput->{ResultSet} = {Result=>\@results};
+
+ return JSON->new->utf8->encode($jsonOutput);
+}
+
+#-------------------------------------------------------------------
+
+=head2 www_getCompareListData ( )
+
+Returns the compare list data as JSON.
+
+=cut
+
+sub www_getCompareListData {
+
+ my $self = shift;
+ my @listingIds = @_;
+ unless (scalar(@listingIds)) {
+ @listingIds = $self->session->form->checkList("listingId");
+ }
+
+ my $session = $self->session;
+ my (@results,$results,@columnDefs);
+ my $sortDirection = ' asc';
+
+ foreach my $listingId (@listingIds){
+ $listingId =~ s/_____/-/g;
+ my $listing = WebGUI::Asset::MatrixListing->new($session,$listingId);
+ $listing->incrementCounter("compares");
+ my $listingId_safe = $listingId;
+ $listingId_safe =~ s/-/_____/g;
+ push(@columnDefs,{key=>$listingId_safe,label=>$listing->get('title'),formatter=>"formatColors"});
+ }
+
+ my $jsonOutput;
+ $jsonOutput->{ColumnDefs} = \@columnDefs;
+
+ foreach my $category (keys %{$self->getCategories}) {
+ my $fields = " a.name, a.fieldType, a.attributeId ";
+ my $from = "from Matrix_attribute a";
+ my $tableCount = "b";
+ foreach my $listingId (@listingIds) {
+ my $listingId_safe = $listingId;
+ $listingId_safe =~ s/-/_____/g;
+ $fields .= ", ".$tableCount.".value as `$listingId_safe`";
+ $from .= " left join MatrixListing_attribute ".$tableCount." on a.attributeId="
+ .$tableCount.".attributeId and ".$tableCount.".matrixListingId=? ";
+ $tableCount++;
}
- my $cat = $self->session->url->urlize($data->{category})."_loop";
- push(@{$var{$cat}},$data);
- }
- $sth->finish;
- my %rating;
- tie %rating, 'Tie::IxHash';
- %rating = (
- 1=>"1 - Worst",
- 2=>2,
- 3=>3,
- 4=>4,
- 5=>"5 - Respectable",
- 6=>6,
- 7=>7,
- 8=>8,
- 9=>9,
- 10=>"10 - Best"
- );
- my $ratingsTable = '';
- $f->submit(
- -extras=>'class="ratingForm"',
- -value=>"Rate",
- -label=>''.$i18n->get('show ratings').' '
- );
- if ($hasRated) {
- $var{'ratings'} = $ratingsTable;
- } else {
- $var{'ratings'} = $f->print;
- }
- return $self->processStyle($self->processTemplate(\%var,$self->get("detailTemplateId")));
+ push(@results, @{ $self->session->db->buildArrayRefOfHashRefs(
+ "select $fields $from where a.category=? and a.assetId=? order by a.name",
+ [@listingIds,$category,$self->getId]
+ ) });
+ }
+ foreach my $result (@results){
+ foreach my $listingId (@listingIds) {
+ $result->{attributId} =~ s/-/_____/g;
+ my $listingId_safe = $listingId;
+ $listingId_safe =~ s/-/_____/g;
+ if ($result->{fieldType} eq 'MatrixCompare'){
+ my $originalValue = $result->{$listingId_safe};
+ $result->{$listingId_safe.'_compareColor'} = $self->getCompareColor($result->{$listingId_safe});
+ $result->{$listingId_safe} = WebGUI::Form::MatrixCompare->new( $self->session,
+ { value=>$result->{$listingId_safe} },defaultValue=>0)->getValueAsHtml;
+ }
+ }
+ }
+
+ $jsonOutput->{ResultSet} = {Result=>\@results};
+
+ $session->http->setMimeType("application/json");
+
+ return JSON->new->utf8->encode($jsonOutput);
+}
+#-------------------------------------------------------------------
+
+=head2 www_listAttributes ( )
+
+Lists all attributes of this Matrix.
+
+=cut
+
+sub www_listAttributes {
+ my $self = shift;
+ my $session = $self->session;
+
+ return $session->privilege->insufficient() unless($self->canEdit);
+
+ my $i18n = WebGUI::International->new($session,'Asset_Matrix');
+ my $output = ""
+ .$i18n->get('add attribute label')." ";
+
+ my $attributes = $session->db->read("select attributeId, name from Matrix_attribute where assetId=? order by name"
+ ,[$self->getId]);
+ while (my $attribute = $attributes->hashRef) {
+ $output .= $session->icon->delete("func=deleteAttribute;attributeId=".$attribute->{attributeId}
+ , $self->getUrl,$i18n->get("delete attribute confirm message"))
+ .$session->icon->edit("func=editAttribute;attributeId=".$attribute->{attributeId})
+ .' '.$attribute->{name}." \n";
+ }
+ return $self->getAdminConsole->render($output, $i18n->get('list attributes title'));
}
+#-------------------------------------------------------------------
-#-----------------------------------------------
-sub www_viewRatingDetails {
- my $self = shift;
- my %var;
- my @ratingloop;
- foreach my $category ($self->getCategories) {
- my @detailloop;
- my $sql = "
- select
- Matrix_listing.productName,
- Matrix_listing.listingId,
- Matrix_ratingSummary.meanValue,
- Matrix_ratingSummary.medianValue,
- Matrix_ratingSummary.countValue
- from
- Matrix_listing
- left join
- Matrix_ratingSummary
- on
- Matrix_listing.listingId=Matrix_ratingSummary.listingId and
- Matrix_ratingSummary.category=".$self->session->db->quote($category)."
- where
- Matrix_listing.assetId=".$self->session->db->quote($self->getId)." and
- Matrix_listing.status='approved' and
- Matrix_ratingSummary.countValue > 0
- order by
- Matrix_ratingSummary.meanValue desc
- ";
- my $sth = $self->session->db->read($sql);
- while (my $data = $sth->hashRef) {
- push(@detailloop,{
- url=>$self->formatURL("viewDetail",$data->{listingId}),
- mean=>$data->{meanValue},
- median=>$data->{medianValue},
- count=>$data->{countValue},
- name=>$data->{productName}
- });
- }
- $sth->finish;
- push(@ratingloop,{
- category=>$category,
- detail_loop=>\@detailloop
- });
- }
- $var{rating_loop} = \@ratingloop;
- return $self->processStyle($self->processTemplate(\%var,$self->get("ratingDetailTemplateId")));
+=head2 www_search ( )
+
+Returns the search screen.
+
+=cut
+
+sub www_search {
+
+ my $self = shift;
+ my $var = $self->get;
+
+ $var->{compareForm} = $self->getCompareForm;
+ $self->session->style->setScript($self->session->url->extras('yui/build/yahoo/yahoo-min.js'),
+ {type => 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/dom/dom-min.js'),
+ {type => 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/event/event-min.js'),
+ {type => 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/json/json-min.js'), {type =>
+ 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/connection/connection-min.js'),
+ {type => 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/get/get-min.js'), {type =>
+ 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/element/element-beta-min.js'), {type =>
+ 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/datasource/datasource-min.js'),
+ {type => 'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/datatable/datatable-min.js'),
+ {type =>'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('yui/build/button/button-min.js'),
+ {type =>'text/javascript'});
+ $self->session->style->setScript($self->session->url->extras('wobject/Matrix/matrixSearch.js'), {type =>
+ 'text/javascript'});
+ $self->session->style->setLink($self->session->url->extras('yui/build/datatable/assets/skins/sam/datatable.css'),
+ {type =>'text/css', rel=>'stylesheet'});
+
+ foreach my $category (keys %{$self->getCategories}) {
+ my $attributes;
+ my @attribute_loop;
+ my $categoryLoopName = $self->session->url->urlize($category)."_loop";
+ $attributes = $self->session->db->read("select * from Matrix_attribute where category =? and assetId = ?",
+ [$category,$self->getId]);
+ while (my $attribute = $attributes->hashRef) {
+ $attribute->{label} = $attribute->{name};
+ $attribute->{id} = $attribute->{attributeId};
+ $attribute->{id} =~ s/-/_____/g;
+ $attribute->{extras} = " class='attributeSelect'";
+ if($attribute->{fieldType} eq 'Combo'){
+ $attribute->{fieldType} = 'SelectBox';
+ }
+ $attribute->{form} = WebGUI::Form::DynamicField->new($self->session,%{$attribute})->toHtml;
+ push(@attribute_loop,$attribute);
+ }
+ $var->{$categoryLoopName} = \@attribute_loop;
+ push(@{$var->{category_loop}},{
+ categoryLabel => $category,
+ attribute_loop => \@attribute_loop,
+ });
+ }
+
+ return $self->processStyle($self->processTemplate($var,$self->get("searchTemplateId")));
}
-
-
1;
-
diff --git a/lib/WebGUI/Help/Asset_Matrix.pm b/lib/WebGUI/Help/Asset_Matrix.pm
index 2d20b0f42..7ec7f6d0b 100644
--- a/lib/WebGUI/Help/Asset_Matrix.pm
+++ b/lib/WebGUI/Help/Asset_Matrix.pm
@@ -153,16 +153,16 @@ our $HELP = {
{ 'name' => 'search.url' },
{ 'name' => 'isLoggedIn' },
{ 'name' => 'field.list.url' },
- { 'name' => 'listing.add.url' },
- { 'name' => 'best.views.url' },
- { 'name' => 'best.views.count' },
- { 'name' => 'best.views.name' },
- { 'name' => 'best.compares.url' },
- { 'name' => 'best.compares.count' },
- { 'name' => 'best.compares.name' },
- { 'name' => 'best.clicks.url' },
- { 'name' => 'best.clicks.count' },
- { 'name' => 'best.clicks.name' },
+ { 'name' => 'addMatrixListing_url' },
+ { 'name' => 'bestViews_url' },
+ { 'name' => 'bestViews_count' },
+ { 'name' => 'bestViews_name' },
+ { 'name' => 'bestCompares_url' },
+ { 'name' => 'bestCompares_count' },
+ { 'name' => 'bestCompares_name' },
+ { 'name' => 'bestClicks_url' },
+ { 'name' => 'bestClicks_count' },
+ { 'name' => 'bestClicks_name' },
{ 'name' => 'best_rating_loop',
'variables' => [
{ 'name' => 'url',
@@ -203,9 +203,9 @@ our $HELP = {
},
{ 'name' => 'ratings.details.url' },
{ 'name' => 'best.posts.url' },
- { 'name' => 'best.updated.url' },
- { 'name' => 'best.updated.date' },
- { 'name' => 'best.updated.name' },
+ { 'name' => 'bestUpdated_url' },
+ { 'name' => 'bestUpdated_date' },
+ { 'name' => 'bestUpdated_name' },
{ 'name' => 'last_update_loop',
'variables' => [
{ 'name' => 'url',
@@ -221,7 +221,7 @@ our $HELP = {
},
{ 'name' => 'user.count' },
{ 'name' => 'current.user.count' },
- { 'name' => 'listing.count' },
+ { 'name' => 'listingCount' },
{ 'name' => 'pending_list',
'variables' => [
{ 'name' => 'url',
@@ -266,8 +266,8 @@ our $HELP = {
{ 'name' => 'approve.url' },
{ 'name' => 'delete.url' },
{ 'name' => 'isPending' },
- { 'name' => 'lastUpdated.epoch' },
- { 'name' => 'lastUpdated.date' },
+ { 'name' => 'lastUpdated_epoch' },
+ { 'name' => 'lastUpdated_date' },
{ 'name' => 'id' },
{ 'name' => 'description',
'description' => 'listing description'
diff --git a/lib/WebGUI/i18n/English/Asset_Matrix.pm b/lib/WebGUI/i18n/English/Asset_Matrix.pm
index a120a9156..f386ae918 100644
--- a/lib/WebGUI/i18n/English/Asset_Matrix.pm
+++ b/lib/WebGUI/i18n/English/Asset_Matrix.pm
@@ -4,30 +4,18 @@ use strict;
our $I18N = {
'delete field confirm' => {
message => q|Are you certain you wish to delete this field and all the data linked to it?|,
- lastUpdated => 0,
+ lastUpdated => 1230,
context => q|displayed in field manager before delete|
},
- 'screenshot' => {
- message => q|Screenshot/Photo|,
- lastUpdated => 0,
- context => q|edit listing property|
- },
-
- 'screenshot help' => {
- message => q|Upload a picture of the product, or a screen shot if it's a software package.|,
- lastUpdated => 0,
- context => q|edit listing property help|
- },
-
'visitor cache timeout' => {
message => q|Visitor Cache Timeout|,
- lastUpdated => 0
+ lastUpdated => 1230
},
'visitor cache timeout help' => {
message => q|Since all visitors will see this asset the same way, we can cache it to increase performance. How long should we cache it?|,
- lastUpdated => 0
+ lastUpdated => 1230
},
'isTooMany' => {
@@ -55,11 +43,6 @@ our $I18N = {
lastUpdated => 1149783768,
},
- 'version' => {
- message => q|The version number or model number of the product.|,
- lastUpdated => 1149783768,
- },
-
'details url' => {
message => q|The URL to the details page for this listing.|,
lastUpdated => 1149783768,
@@ -80,6 +63,12 @@ our $I18N = {
lastUpdated => 1149783768,
},
+ 'categoryLabel' => {
+ message => q|The label of a category.|,
+ lastUpdated => 1149783768,
+ },
+
+
'tmplVar category' => {
message => q|The name of the current category.|,
lastUpdated => 1149783768,
@@ -175,74 +164,59 @@ our $I18N = {
lastUpdated => 1167186037,
},
- 'lastUpdated.epoch' => {
+ 'lastUpdated_epoch' => {
message => q|The epoch date of when this listing was last updated.|,
- lastUpdated => 1149784175,
+ lastUpdated => 0,
},
- 'lastUpdated.date' => {
+ 'lastUpdated_date' => {
message => q|A human readable date of when this listing was last updated.|,
- lastUpdated => 1149784175,
+ lastUpdated => 0,
},
- 'id' => {
- message => q|The unique identifier of this listing.|,
- lastUpdated => 1149784175,
- },
-
- 'listing description' => {
+ 'description' => {
message => q|The description of this listing.|,
- lastUpdated => 1149784175,
+ lastUpdated => 0,
},
'productName' => {
- message => q|The name of this listing.|,
- lastUpdated => 1149784175,
+ message => q|The name of this listing. This is the same as this matrix listing's asset title.|,
+ lastUpdated => 0,
},
'productUrl' => {
message => q|The manufacturer's URL for this listing.|,
- lastUpdated => 1149784175,
+ lastUpdated => 0,
},
- 'productUrl.click' => {
+ 'productUrl_click' => {
message => q|The product URL to use if you want to register the click count for this listing.|,
- lastUpdated => 1149784175,
- },
-
- 'manufacturerName' => {
- message => q|The name of the company that manufactures the product or provides the service represented in this listing.|,
- lastUpdated => 1167186054,
+ lastUpdated => 0,
},
'manufacturerUrl' => {
message => q|The manufacturer's URL.|,
- lastUpdated => 1149784175,
+ lastUpdated => 0,
},
- 'manufacturerUrl.click' => {
+ 'manufacturerUrl_click' => {
message => q|The manufacturer URL to use if you want to register the click count for this listing.|,
- lastUpdated => 1149784175,
- },
-
- 'versionNumber' => {
- message => q|The version number or model number of this product.|,
- lastUpdated => 1149784175,
+ lastUpdated => 0,
},
'views' => {
message => q|The total number of views this listing has received.|,
- lastUpdated => 1149784175,
+ lastUpdated => 0,
},
'compares' => {
message => q|The total number of compares this listing has received.|,
- lastUpdated => 1149784175,
+ lastUpdated => 0,
},
'clicks' => {
message => q|The total number of clicks this listing has received.|,
- lastUpdated => 1149784175,
+ lastUpdated => 0,
},
'ratings' => {
@@ -251,10 +225,15 @@ our $I18N = {
},
'CATEGORY_NAME_loop' => {
- message => q|A loop is created for each category in this matrix. The name of the loop is the category name with spaces replaced with hyphens and a _loop added to the end. So if you have a category called "Bells and Whistles" then the loop would be called "bells-and-whistles_loop".|,
- lastUpdated => 1167186070,
+ message => q|A loop containting attributes and values for those attributes is created for each category in this matrix. The name of the loop is the category name with spaces replaced with hyphens and a _loop added to the end. So if you have a category called "Bells and Whistles" then the loop would be called "bells-and-whistles_loop".|,
+ lastUpdated => 0,
},
+ 'attribute_loop' => {
+ message => q|A loop containing attributes and values for those attributes.|,
+ lastUpdated => 0,
+ },
+
'tmplVar name' => {
message => q|The name of this field.|,
lastUpdated => 1149784175,
@@ -281,7 +260,7 @@ our $I18N = {
},
'detail template help title' => {
- lastUpdated => 0,
+ lastUpdated =>
message => q|Matrix Listing Detail Template Variables|
},
@@ -300,124 +279,124 @@ our $I18N = {
lastUpdated => 1149795214,
},
- 'listing.add.url' => {
+ 'addMatrixListing_url' => {
message => q|The URL to the page where a user can add a new listing to the matrix.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
- 'best.views.url' => {
+ 'bestViews_url' => {
message => q|The URL to the listing that has the most views.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
- 'best.views.count' => {
+ 'bestViews_count' => {
message => q|The total number of views of the listing that has the most views.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
- 'best.views.name' => {
+ 'bestViews_name' => {
message => q|The name of the listing that has the most views.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
- 'best.compares.url' => {
+ 'bestCompares_url' => {
message => q|The URL to the listing that has the most compares.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
- 'best.compares.count' => {
+ 'bestCompares_count' => {
message => q|The number of compares of the listing that has the most compares.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
- 'best.compares.name' => {
+ 'bestCompares_name' => {
message => q|The name of the listing that has the most compares.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
- 'best.clicks.url' => {
+ 'bestClicks_url' => {
message => q|The URL of the listing that has the most clicks.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
- 'best.clicks.count' => {
+ 'bestClicks_count' => {
message => q|The number of clicks of the listing that has the most clicks.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
- 'best.clicks.name' => {
+ 'bestClicks_name' => {
message => q|The name of the listing that has the most clicks.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
'best_rating_loop' => {
message => q|A loop containing all of the categories for this matrix and their best ratings.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
'tmplVar best.url' => {
message => q|The URL of the listing that has the best rating for this category.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
'tmplVar best.category' => {
message => q|The name of this category.|,
- lastUpdated => 1167186103,
+ lastUpdated => 0,
},
'tmplVar best.name' => {
message => q|The name of the listing that has the best rating for this category.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
'mean' => {
message => q|The mean (or average) rating of the best listing in this category.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
'median' => {
message => q|The median (or middle) rating of the best listing in this category.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
'count' => {
message => q|The sum of all the votes of the best listing in this category.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
'worst_rating_loop' => {
message => q|A loop containing all of the categories for this matrix and their worst ratings.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
'tmplVar worst.url' => {
message => q|The URL of the listing that has the worst rating for this category.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
'tmplVar worst.category' => {
message => q|The name of this category.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
'tmplVar worst.name' => {
message => q|The name of the listing that has the worst rating for this category.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
'tmplVar worst.mean' => {
message => q|The mean (or average) rating of the worst listing in this category.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
'tmplVar worst.median' => {
message => q|The median (or middle) rating of the worst listing in this category.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
'tmplVar worst.count' => {
message => q|The sum of all the votes of the worst listing in this category.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
'ratings.details.url' => {
@@ -430,19 +409,19 @@ our $I18N = {
lastUpdated => 1149795214,
},
- 'best.updated.url' => {
+ 'bestUpdated_url' => {
message => q|The URL to the listing that was updated most recently.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
- 'best.updated.date' => {
+ 'bestUpdated_date' => {
message => q|The date of the most recently updated listing.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
- 'best.updated.name' => {
+ 'bestUpdated_name' => {
message => q|The name of the listing that was most recently updated.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
'last_update_loop' => {
@@ -475,33 +454,43 @@ our $I18N = {
lastUpdated => 1149795214,
},
- 'listing.count' => {
+ 'listingCount' => {
message => q|The number of listings in this matrix.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
- 'pending_list' => {
+ 'pending_loop' => {
message => q|A loop containing the list of pending listing.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
'tmplVar pending.url' => {
message => q|The URL to the pending listing.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
- 'tmplVar pending.productName' => {
+ 'tmplVar pending.name' => {
message => q|The product title of the pending listing.|,
- lastUpdated => 1149795214,
+ lastUpdated => 0,
},
+ 'narrow the matrix label' => {
+ message => q|Narrow The Matrix|,
+ lastUpdated => 0,
+ },
+
+ 'expand the matrix label' => {
+ message => q|Expand The Matrix|,
+ lastUpdated => 0,
+ },
+
'matrix template help title' => {
message => q|Matrix Main Template Variables|,
lastUpdated => 1184949132,
},
'ratings detail template help title' => {
- lastUpdated => 0,
+ lastUpdated => 1230,
message => q|Matrix Ratings Detail Template Variables|
},
@@ -582,23 +571,68 @@ our $I18N = {
'categories description' => {
message => q|Specify one category per line here to define the categories for this matrix. Categories are used to subdivide fields and also represent the things users can rate each listing on.|,
- lastUpdated => 1136503559,
- },
+ lastUpdated => 0,
+ },
+
+ 'categories default value' => {
+ message => q|Features\nBenefits|,
+ lastUpdated => 0,
+ },
+
+ 'submission approval workflow description' => {
+ message => q|Select the workflow that is used to approve submissions.|,
+ lastUpdated => 0,
+ },
+
+ 'ratings duration description' => {
+ message => q|Select the interval after which old ratings are cleaned out.|,
+ lastUpdated => 0,
+ },
+
+ 'default sort description' => {
+ message => q|Select the default sort order for the listings in the compare box.|,
+ lastUpdated => 0,
+ },
+
+ 'compare color no description' => {
+ message => q|Select the color for compare result 'No' in the compare display.|,
+ lastUpdated => 0,
+ },
+
+ 'compare color limited description' => {
+ message => q|Select the color for compare result 'Limited' in the compare display.|,
+ lastUpdated => 0,
+ },
+
+ 'compare color costs extra description' => {
+ message => q|Select the color for compare result 'Costs Extra' in the compare display.|,
+ lastUpdated => 0,
+ },
+
+ 'compare color free add on description' => {
+ message => q|Select the color for compare result 'Free Add On' in the compare display.|,
+ lastUpdated => 0,
+ },
+
+ 'compare color yes description' => {
+ message => q|Select the color for compare result 'Yes' in the compare display.|,
+ lastUpdated => 0,
+ },
'categories subtext' => {
message => q| Enter one per line in the order you want them to appear. Be sure to watch leading and trailing whitespace.|,
lastUpdated => 1135271460,
},
- 'max comparisons description' => {
- message => q|Specifies how many comparisons are allowed in searches and comparisons.|,
- lastUpdated => 1135271460,
- },
+ 'max comparisons description' => {
+ message => q|Specifies how many comparisons are allowed in searches and comparisons.|,
+ lastUpdated => 0,
+ },
- 'max comparisons privileged description' => {
- message => q|Specifies how many comparisons are allowed in searches and comparisons for users in the privileged group.|,
- lastUpdated => 1135271460,
- },
+ 'max comparisons privileged description' => {
+ message => q|Specifies how many comparisons are allowed in searches and comparisons for users in the privileged group.|,
+ lastUpdated => 0,
+ },
'rating timeout description' => {
message => q|Set a timeout so that users are prevented from rating a given listing too often.|,
@@ -625,43 +659,103 @@ our $I18N = {
lastUpdated => 1135271460,
},
- 'main template description' => {
+ 'template description' => {
message => q|Select a template to be used to display the default view of the Matrix.|,
- lastUpdated => 1135271460,
+ lastUpdated => 0,
},
'detail template description' => {
message => q|Select a template to be used to display the detailed information about a listing.|,
- lastUpdated => 1135271460,
+ lastUpdated => 0,
},
'rating detail template description' => {
message => q|Select a template to be used to display the detailed ratings information.|,
- lastUpdated => 1135271460,
+ lastUpdated => 0,
},
'search template description' => {
message => q|Select a template to be used to display the search engine interface.|,
- lastUpdated => 1135271460,
+ lastUpdated => 0,
},
'compare template description' => {
message => q|Select a template to be used to show the listing comparison data.|,
- lastUpdated => 1135271460,
+ lastUpdated => 0,
},
- 'categories' => {
+ 'categories label' => {
message => q|Categories|,
- lastUpdated => 1133758944,
+ lastUpdated => 0,
},
- 'max comparisons' => {
+ 'submission approval workflow label' => {
+ message => q|Submission Approval Workflow|,
+ lastUpdated => 0,
+ },
+
+ 'ratings duration label' => {
+ message => q|Ratings Duration|,
+ lastUpdated => 0,
+ },
+
+ 'default sort label' => {
+ message => q|Default Sort|,
+ lastUpdated => 0,
+ },
+
+ 'sort by score label' => {
+ message => q|Score|,
+ lastUpdated => 0,
+ },
+
+ 'sort alpha numeric label' => {
+ message => q|Alpha Numeric|,
+ lastUpdated => 0,
+ },
+
+ 'sort by asset rank label' => {
+ message => q|Asset Rank|,
+ lastUpdated => 0,
+ },
+
+ 'sort by last updated label' => {
+ message => q|Most Recent Update|,
+ lastUpdated => 0,
+ },
+
+ 'compare color no label' => {
+ message => q|Compare Color: No|,
+ lastUpdated => 0,
+ },
+
+ 'compare color limited label' => {
+ message => q|Compare Color: Limited|,
+ lastUpdated => 0,
+ },
+
+ 'compare color costs extra label' => {
+ message => q|Compare Color: Costs Extra|,
+ lastUpdated => 0,
+ },
+
+ 'compare color free add on label' => {
+ message => q|Compare Color: Free Add On|,
+ lastUpdated => 0,
+ },
+
+ 'compare color yes label' => {
+ message => q|Compare Color: Yes|,
+ lastUpdated => 0,
+ },
+
+ 'max comparisons label' => {
message => q|Maximum Comparisons|,
- lastUpdated => 1133758944,
+ lastUpdated => 0,
},
- 'max comparisons privileged' => {
+ 'max comparisons privileged label' => {
message => q|Maximum Comparisons (For Privileged Users)|,
- lastUpdated => 1133758944,
+ lastUpdated => 0,
},
'rating timeout' => {
@@ -689,29 +783,29 @@ our $I18N = {
lastUpdated => 1133758944,
},
- 'main template' => {
- message => q|Main Template|,
- lastUpdated => 1133758944,
+ 'template label' => {
+ message => q|Matrix Template|,
+ lastUpdated => 0,
},
- 'detail template' => {
+ 'detail template label' => {
message => q|Detail Template|,
- lastUpdated => 1133758944,
+ lastUpdated => 0,
},
- 'rating detail template' => {
+ 'rating detail template label' => {
message => q|Rating Detail Template|,
- lastUpdated => 1133758944,
+ lastUpdated => 0,
},
- 'search template' => {
+ 'search template label' => {
message => q|Search Template|,
- lastUpdated => 1133758944,
+ lastUpdated => 0,
},
- 'compare template' => {
+ 'compare template label' => {
message => q|Compare Template|,
- lastUpdated => 1133758944,
+ lastUpdated => 0,
},
'product name' => {
@@ -719,91 +813,77 @@ our $I18N = {
lastUpdated => 1133758944,
},
- 'version number' => {
- message => q|Version/Model Number|,
- lastUpdated => 1133758944,
+ 'attribute name label' => {
+ message => q|Name|,
+ lastUpdated => 0,
},
- 'product url' => {
- message => q|Product URL|,
- lastUpdated => 1135279964,
- },
-
- 'manufacturer name' => {
- message => q|Manufacturer Name|,
- lastUpdated => 1133758944,
- },
-
- 'manufacturer url' => {
- message => q|Manufacturer URL|,
- lastUpdated => 1133758944,
- },
-
- 'description' => {
- message => q|Description|,
- lastUpdated => 1133758944,
- },
-
- 'listing maintainer' => {
- message => q|Listing Maintainer|,
- lastUpdated => 1133758944,
- },
-
- 'field name' => {
- message => q|Field Name|,
- lastUpdated => 1136499280,
- },
-
- 'field label' => {
- message => q|Field Label|,
- lastUpdated => 1136499282,
- },
-
- 'field type' => {
+# 'field label' => {
+# message => q|Field Label|,
+# lastUpdated => 1136499282,
+# },
+
+ 'fieldType label' => {
message => q|Field Type|,
- lastUpdated => 1136499283,
+ lastUpdated => 0,
},
- 'default value' => {
+ 'attribute defaultValue label' => {
message => q|Default Value|,
- lastUpdated => 1133758944,
+ lastUpdated => 0,
},
- 'category' => {
+ 'attribute options label' => {
+ message => q|Options|,
+ lastUpdated => 0,
+ },
+
+ 'category label' => {
message => q|Category|,
- lastUpdated => 1133758944,
+ lastUpdated => 0,
},
- 'your email' => {
+ 'your email label' => {
message => q|Your Email Address|,
- lastUpdated => 1133758944,
+ lastUpdated => 0,
},
- 'report error' => {
+ 'report error label' => {
message => q|Report an error.|,
- lastUpdated => 1133758944,
+ lastUpdated => 0,
},
- 'general comment' => {
+ 'general comment label' => {
message => q|General comment.|,
- lastUpdated => 1133758944,
+ lastUpdated => 0,
},
- 'request type' => {
+ 'request type label' => {
message => q|Type of Request|,
- lastUpdated => 1133758944,
+ lastUpdated => 0,
},
- 'comment' => {
+ 'comment label' => {
message => q|Comment|,
- lastUpdated => 1133758944,
+ lastUpdated => 0,
},
+ 'send button label' => {
+ message => q|Send...|,
+ lastUpdated => 0,
+ },
+
+
'show ratings' => {
message => q|Show Ratings|,
- lastUpdated => 1133758944,
+ lastUpdated => 0,
},
+ 'rate submit label' => {
+ message => q|Rate|,
+ lastUpdated => 0,
+ },
+
'no copy' => {
message => q|This asset may not be copied.|,
lastUpdated => 1133758944,
@@ -829,9 +909,9 @@ our $I18N = {
message => q|Edit Listing |
},
- 'edit field' => {
- lastUpdated => 1135279558,
- message => q|Edit Field |
+ 'edit attribute title' => {
+ lastUpdated => 0,
+ message => q|Edit/Add Attribute|
},
'good bad' => {
@@ -869,12 +949,20 @@ our $I18N = {
No, I made a mistake.
|,
},
- 'list fields' => {
- lastUpdated => 1135289632,
- message => q|Field List
- Add new field.
-
|,
- },
+ 'list attributes title' => {
+ lastUpdated => 0,
+ message => q|Attribute List|,
+ },
+
+ 'delete attribute confirm message' => {
+ message => q|Are you certain you wish to delete this attribute and all the data linked to it?|,
+ lastUpdated => 0,
+ },
+
+ 'add attribute label' => {
+ lastUpdated => 0,
+ message => q|Add Attribute|,
+ },
'yes' => {
lastUpdated => 1135279558,
@@ -906,38 +994,6 @@ our $I18N = {
message => q|Enter the name of the product. If there are entries for the product with different revisions, it would be best to make sure the names are the same.|
},
- 'version number description' => {
- lastUpdated => 1135279558,
- message => q|Enter the release or version number for the product.|
- },
-
- 'product url description' => {
- lastUpdated => 1135279558,
- message => q|If the product has its own website, enter the complete URL for it here.|
- },
-
- 'manufacturer name description' => {
- lastUpdated => 1135279558,
- message => q|Enter the manufacturer of the product.|
- },
-
- 'manufacturer url description' => {
- lastUpdated => 1135279558,
- message => q|If the manufacturer has a website, enter the complete URL for it here.|
- },
-
- 'description description' => {
- lastUpdated => 1135279558,
- message => q|Please give a general description of the product. Specific details can be rated in the form fields below.|
- },
-
- 'listing maintainer description' => {
- lastUpdated => 1136488950,
- message => q|If left blank, this will be the name of the user who created this product listing. The
- listing maintainer is allowed to edit this listing, even if they are not members of the group
- to add or edit listings.|
- },
-
'matrix specific fields description' => {
lastUpdated => 1135279558,
message => q|Each matrix is configured to compare the features and performance of various products. These features and performance criteria are displayed for you to rate on an item by item basis.|
@@ -948,55 +1004,46 @@ our $I18N = {
message => q|Matrix Specific Fields|
},
- 'field name description' => {
- lastUpdated => 1135279558,
- message => q|The name of the field that you are creating. It is case sensitive and must be unique.|
+ 'attribute name description' => {
+ lastUpdated => 0,
+ message => q|The name of the attribute that you are creating. It is case sensitive and must be unique.|
},
- 'field label description' => {
- lastUpdated => 1135279558,
- message => q|The name of the field that you are creating. It is case sensitive and must be unique.|
+# 'field label description' => {
+# lastUpdated => 1135279558,
+# message => q|The name of the field that you are creating. It is case sensitive and must be unique.|
+# },
+
+ 'fieldType description' => {
+ lastUpdated => 0,
+ message => q|The field type of attribute you are creating. Please select the field type from the options in the drop-down list.
|
},
- 'field type description' => {
- lastUpdated => 1167185918,
- message => q|The type of field you are creating. Please select the type from the following options in the drop-down list.
-
-
- Good Bad
- Defines availability of a feature, has it, doesn't have it, limited functionality, free add on, etc.
- Text
- A single line of text, like a short description or title.
- TextArea
- Multiple lines of text.
- URL
- A URL.
- Combo
- A combination Text box and drop down list.
- |
+ 'attribute description label' => {
+ lastUpdated => 0,
+ message => q|Description|
},
- 'field description' => {
- lastUpdated => 1135279558,
- message => q|Field Description|
+ 'attribute description description' => {
+ lastUpdated => 0,
+ message => q|Please give a general description of the attribute.|
},
- 'field description description' => {
- lastUpdated => 1135279558,
- message => q|Please give a general description of the field.|
+ 'attribute defaultValue description' => {
+ lastUpdated => 0,
+ message => q|Enter in a default value for the attribute that will be used if the fieldType is
+selectBox.
|
},
- 'default value description' => {
- translatorsNote => q|Please do not translate the GoodBad field values, as described below|,
- lastUpdated => 1135279558,
- message => q|Enter in a default value for the field that will be used if the user leaves the field blank.
- For the GoodBad field, the possible values are "No", "Yes", "Free Add On", "Costs Extra", "Limited". While the displayed labels are internationalized, these values are not.
- For the Combo field, you may only enter in 1 value, but the user will be allowed to select any value entered in by other users. In other words, the drop-down list will contain all values entered in by users who enter unique data into this field.
|
+ 'attribute options description' => {
+ lastUpdated => 0,
+ message => q|Enter in options (one per line) for the attribute that will be used if the fieldType is
+selectBox.
|
},
'category description' => {
- lastUpdated => 1136503500,
- message => q|Select the category which this field falls into.|
+ lastUpdated => 0,
+ message => q|Select the category which this attribute falls into.|
},
};
diff --git a/t/Asset/MatrixListing.t b/t/Asset/MatrixListing.t
new file mode 100644
index 000000000..3ff5fd1a0
--- /dev/null
+++ b/t/Asset/MatrixListing.t
@@ -0,0 +1,63 @@
+#-------------------------------------------------------------------
+# WebGUI is Copyright 2001-2008 Plain Black Corporation.
+#-------------------------------------------------------------------
+# Please read the legal notices (docs/legal.txt) and the license
+# (docs/license.txt) that came with this distribution before using
+# this software.
+#-------------------------------------------------------------------
+# http://www.plainblack.com info@plainblack.com
+#-------------------------------------------------------------------
+
+use FindBin;
+use strict;
+use lib "$FindBin::Bin/../lib";
+
+##The goal of this test is to test the creation of a MatrixListing Asset.
+
+use WebGUI::Test;
+use WebGUI::Session;
+use Test::More tests => 2; # increment this value for each test you create
+use WebGUI::Asset::Wobject::Matrix;
+use WebGUI::Asset::MatrixListing;
+
+
+my $session = WebGUI::Test->session;
+my $node = WebGUI::Asset->getImportNode($session);
+my ($matrix, $matrixListing);
+
+my $versionTag = WebGUI::VersionTag->getWorking($session);
+$versionTag->set({name=>"Matrix Listing Test"});
+
+$matrix = $node->addChild({className=>'WebGUI::Asset::Wobject::Matrix'});
+$versionTag->commit;
+$matrixListing = $matrix->addChild({className=>'WebGUI::Asset::MatrixListing'});
+
+# Wikis create and autocommit a version tag when a child is added. Lets get the name so we can roll it back.
+my $secondVersionTag = WebGUI::VersionTag->new($session,$matrixListing->get("tagId"));
+
+# Test for sane object types
+isa_ok($matrix, 'WebGUI::Asset::Wobject::Matrix');
+isa_ok($matrixListing, 'WebGUI::Asset::MatrixListing');
+
+# Try to add content under a MatrixListing asset
+#my $article = $matrixListing->addChild({className=>'WebGUI::Asset::Wobject::Article'});
+#is($article, undef, "Can't add an Article wobject as a child to a Matrix Listing.");
+
+# See if the duplicate method works
+#my $wikiPageCopy = $wikipage->duplicate();
+#isa_ok($wikiPageCopy, 'WebGUI::Asset::WikiPage');
+#my $thirdVersionTag = WebGUI::VersionTag->new($session,$wikiPageCopy->get("tagId"));
+
+
+#TODO: {
+# local $TODO = "Tests to make later";
+# ok(0, 'Lots and lots to do');
+#}
+
+END {
+ # Clean up after thy self
+ $versionTag->rollback();
+ $secondVersionTag->rollback();
+ #$thirdVersionTag->rollback();
+}
+
diff --git a/t/Asset/Wobject/Matrix.t b/t/Asset/Wobject/Matrix.t
new file mode 100644
index 000000000..4fc36012b
--- /dev/null
+++ b/t/Asset/Wobject/Matrix.t
@@ -0,0 +1,98 @@
+#-------------------------------------------------------------------
+# WebGUI is Copyright 2001-2008 Plain Black Corporation.
+#-------------------------------------------------------------------
+# Please read the legal notices (docs/legal.txt) and the license
+# (docs/license.txt) that came with this distribution before using
+# this software.
+#-------------------------------------------------------------------
+# http://www.plainblack.com info@plainblack.com
+#-------------------------------------------------------------------
+
+use FindBin;
+use strict;
+use File::Spec;
+use lib "$FindBin::Bin/../../lib";
+
+##The goal of this test is to test the creation of UserList Wobjects.
+
+use WebGUI::Test;
+use WebGUI::Session;
+use Test::More tests => 10; # increment this value for each test you create
+use Test::Deep;
+use WebGUI::Asset::Wobject::Matrix;
+
+my $session = WebGUI::Test->session;
+
+# Do our work in the import node
+my $node = WebGUI::Asset->getImportNode($session);
+
+my $versionTag = WebGUI::VersionTag->getWorking($session);
+$versionTag->set({name=>"Matrix Test"});
+my $matrix = $node->addChild({className=>'WebGUI::Asset::Wobject::Matrix'});
+
+# Test for a sane object type
+isa_ok($matrix, 'WebGUI::Asset::Wobject::Matrix');
+
+# Test to see if we can set new values
+my $newMatrixSettings = {
+ maxComparisons => 20,
+ defaultSort => 'assetRank',
+ compareColorNo => '#aaffaa',
+ submissionApprovalWorkflowId => 'pbworkflow000000000005',
+ categories => "category1\ncategory2",
+};
+$matrix->update($newMatrixSettings);
+
+foreach my $newSetting (keys %{$newMatrixSettings}) {
+ unless ($newSetting eq 'categories'){
+ is ($matrix->get($newSetting), $newMatrixSettings->{$newSetting}, "updated $newSetting is ".$newMatrixSettings->{$newSetting});
+ }
+}
+
+cmp_deeply (
+ $matrix->getCategories,
+ {
+ category1=>'category1',
+ category2=>'category2'
+ },
+ 'getCategories method returned correct hashref'
+ );
+
+
+# add a new attribute
+
+$session->user({userId => 3});
+
+my $attributeProperties = {
+ name =>'test attribute',
+ description =>'description of the test attribute',
+ category =>'category1',
+ };
+
+my $newAttributeId = $matrix->editAttributeSave($attributeProperties);
+
+my $newAttribute = $matrix->getAttribute($newAttributeId);
+
+my $isValidId = $session->id->valid($newAttributeId);
+
+is($isValidId,1,"editAttributeSave returnes a valid guid");
+
+is($newAttribute->{name},'test attribute',"Adding a new attribute, attribute name was set correctly");
+is($newAttribute->{fieldType},'MatrixCompare',"Adding a new attribute, undefined fieldType was set correctly to
+default value");
+
+# delete new attribute
+
+$matrix->deleteAttribute($newAttributeId);
+
+my $newAttribute = $matrix->getAttribute($newAttributeId);
+
+is($newAttribute->{attributeId},undef,"The new attribute was successfully deleted.");
+
+# TODO: test deleting of listing data for attribute
+
+END {
+ # Clean up after thy self
+ $versionTag->rollback();
+}
+