diff --git a/lib/WebGUI/Asset/MatrixListing.pm b/lib/WebGUI/Asset/MatrixListing.pm
new file mode 100644
index 000000000..8f92a93d6
--- /dev/null
+++ b/lib/WebGUI/Asset/MatrixListing.pm
@@ -0,0 +1,420 @@
+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 base '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->SUPER::addRevision(@_);
+ 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 = (
+ templateId => {
+ tab =>"display",
+ fieldType =>"template",
+ defaultValue =>'MatrixListingTmpl00001',
+ noFormPost =>0,
+ namespace =>"MatrixListing",
+ hoverHelp =>$i18n->get('template description'),
+ label =>$i18n->get('template label')
+ },
+ screenshots => {
+ tab =>"properties",
+ fieldType =>"image",
+ defaultValue =>undef,
+ 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")
+ },
+ 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->SUPER::definition($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->SUPER::duplicate(@_);
+ 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 indexContent ( )
+
+Making private. See WebGUI::Asset::indexContent() for additonal details.
+
+=cut
+
+sub indexContent {
+ my $self = shift;
+ my $indexer = $self->SUPER::indexContent;
+ $indexer->setIsPublic(0);
+}
+
+
+#-------------------------------------------------------------------
+
+=head2 prepareView ( )
+
+See WebGUI::Asset::prepareView() for details.
+
+=cut
+
+sub prepareView {
+ my $self = shift;
+ $self->SUPER::prepareView();
+ my $template = WebGUI::Asset::Template->new($self->session, $self->get("templateId"));
+ $template->prepare;
+ $self->{_viewTemplate} = $template;
+}
+
+
+#-------------------------------------------------------------------
+
+=head2 processPropertiesFromFormPost ( )
+
+Used to process properties from the form posted. Do custom things with
+noFormPost fields here, or do whatever you want. This method is called
+when /yourAssetUrl?func=editSave is requested/posted.
+
+=cut
+
+sub processPropertiesFromFormPost {
+ my $self = shift;
+ $self->SUPER::processPropertiesFromFormPost;
+ $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;
+ return $self->SUPER::purge;
+}
+
+#-------------------------------------------------------------------
+
+=head2 purgeRevision ( )
+
+This method is called when data is purged by the system.
+
+=cut
+
+sub purgeRevision {
+ my $self = shift;
+ return $self->SUPER::purgeRevision;
+}
+
+#-------------------------------------------------------------------
+=head2 view ( )
+
+method called by the container www_view method.
+
+=cut
+
+sub view {
+ my $self = shift;
+ my $var = $self->get; # $var is a hash reference.
+ $var->{controls} = $self->getToolbar;
+ $var->{fileUrl} = $self->getFileUrl;
+ $var->{fileIcon} = $self->getFileIconUrl;
+ return $self->processTemplate($var,undef, $self->{_viewTemplate});
+}
+
+
+#-------------------------------------------------------------------
+
+=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_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;
+ if ($self->session->var->isAdminOn) {
+ return $self->getContainer->www_view;
+ }
+ $self->session->http->setRedirect($self->getFileUrl($self->getValue("showPage")));
+ return undef;
+}
+
+#-------------------------------------------------------------------
+# Everything below here is to make it easier to install your custom
+# asset, but has nothing to do with assets in general
+#-------------------------------------------------------------------
+# cd /data/WebGUI/lib
+# perl -MWebGUI::Asset::MatrixListing -e install www.example.com.conf [ /path/to/WebGUI ]
+# - or -
+# perl -MWebGUI::Asset::MatrixListing -e uninstall www.example.com.conf [ /path/to/WebGUI ]
+#-------------------------------------------------------------------
+
+
+use base 'Exporter';
+our @EXPORT = qw(install uninstall);
+use WebGUI::Session;
+
+#-------------------------------------------------------------------
+sub install {
+ my $config = $ARGV[0];
+ my $home = $ARGV[1] || "/data/WebGUI";
+ die "usage: perl -MWebGUI::Asset::MatrixListing -e install www.example.com.conf\n" unless ($home && $config);
+ print "Installing asset.\n";
+ my $session = WebGUI::Session->open($home, $config);
+ $session->config->addToArray("assets","WebGUI::Asset::MatrixListing");
+ $session->db->write("create table MatrixListing (
+ assetId varchar(22) binary not null,
+ revisionDate bigint not null,
+ title varchar(255),
+ screenshots varchar(22),
+ description text,
+ version varchar(255),
+ views int(11),
+ compares int(11),
+ clicks int(11),
+ viewsLastIp varchar(255),
+ comparesLastIp varchar(255),
+ clicksLastIp varchar(255),
+ lastUpdated int(11),
+ maintainer varchar(22),
+ manufacturerName varchar(255),
+ manufacturerURL varchar(255),
+ productURL varchar(255),
+ primary key (assetId, revisionDate)
+ )");
+ $session->var->end;
+ $session->close;
+ print "Done. Please restart Apache.\n";
+}
+
+#-------------------------------------------------------------------
+sub uninstall {
+ my $config = $ARGV[0];
+ my $home = $ARGV[1] || "/data/WebGUI";
+ die "usage: perl -MWebGUI::Asset::MatrixListing -e uninstall www.example.com.conf\n" unless ($home && $config);
+ print "Uninstalling asset.\n";
+ my $session = WebGUI::Session->open($home, $config);
+ $session->config->deleteFromArray("assets","WebGUI::Asset::MatrixListing");
+ my $rs = $session->db->read("select assetId from asset where className='WebGUI::Asset::MatrixListing'");
+ while (my ($id) = $rs->array) {
+ my $asset = WebGUI::Asset->new($session, $id, "WebGUI::Asset::MatrixListing");
+ $asset->purge if defined $asset;
+ }
+ $session->db->write("drop table MatrixListing");
+ $session->var->end;
+ $session->close;
+ print "Done. Please restart Apache.\n";
+}
+
+
+1;
+
+#vim:ft=perl
diff --git a/lib/WebGUI/Asset/Wobject/Matrix.pm b/lib/WebGUI/Asset/Wobject/Matrix.pm
index 8c4120e2c..b71ad07b2 100644
--- a/lib/WebGUI/Asset/Wobject/Matrix.pm
+++ b/lib/WebGUI/Asset/Wobject/Matrix.pm
@@ -1,183 +1,334 @@
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 WebGUI::International;
use WebGUI::Utility;
-use WebGUI::Inbox;
-use WebGUI::Asset::Wobject;
-use WebGUI::Asset::Wobject::Collaboration;
+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",
+ #www_editSave will ignore anyone's attempts to update this field if this is set to 1
+ noFormPost =>0,
+ #This is an option specific to the template fieldType.
+ 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'),
+ },
+ ratingDetailTemplateId=>{
+ defaultValue =>"matrixtmpl000000000004",
+ fieldType =>"template",
+ tab =>"display",
+ namespace =>"Matrix/RatingDetail",
+ hoverHelp =>$i18n->get('rating detail template description'),
+ label =>$i18n->get('rating 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'),
+ alphaNumeric => $i18n->get('sort alpha numeric label'),
+ assetRank => $i18n->get('sort by asset rank label'),
+ lastUpdated => $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;
-#-------------------------------------------------------------------
-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;
}
#-------------------------------------------------------------------
-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();
+=cut
+ $tabform->getTab("display")->template(
+ -value=>$self->getValue("templateId"),
+ -label=>WebGUI::International::get("template_label","Asset_Matrix"),
+ -namespace=>"Matrix"
+ );
+=cut
+ return $tabform;
}
#-------------------------------------------------------------------
@@ -192,1185 +343,350 @@ 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('
| Mean | Median | Count | |
|---|---|---|---|
| '.$category.' | '.$mean.' | '.$median.' | '.$count.' |
| "
+ .$i18n->get('attribute defaultValue label')
+ ." ".$i18n->get('attribute defaultValue description')." | "
+ ."" + .$defaultValueForm." | " + ."\t\n
| "
+ .$i18n->get('attribute options label')
+ ." ".$i18n->get('attribute options description')." | "
+ ."" + .$optionsForm." | " + ."\t\n
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.
-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/lib/WebGUI/i18n/English/Asset_MatrixListing.pm b/lib/WebGUI/i18n/English/Asset_MatrixListing.pm new file mode 100644 index 000000000..100a6393f --- /dev/null +++ b/lib/WebGUI/i18n/English/Asset_MatrixListing.pm @@ -0,0 +1,103 @@ +package WebGUI::i18n::English::Asset_MatrixListing; + +use strict; + +our $I18N = { + 'assetName' => { + message => q|Matrix Listing|, + lastUpdated => 0, + }, + + 'edit matrix listing title' => { + message => q|Edit/Add Listing|, + lastUpdated => 0, + }, + + + 'template description' => { + message => q|Select a template to be used to display the default view of the Matrix.|, + lastUpdated => 0, + }, + + 'template label' => { + message => q|Matrix Listing Template|, + lastUpdated => 0, + }, + + 'screenshots description' => { + message => q|Upload a picture of the product, or a screen shot if it's a software package.|, + lastUpdated => 0, + }, + + 'screenshots label' => { + message => q|Screenshots/Photos|, + lastUpdated => 0, + }, + + 'description description' => { + message => q|Please give a general description of the product. Specific details can be rated in the form +fields below.|, + lastUpdated => 0, + }, + + 'description label' => { + message => q|Description|, + lastUpdated => 0, + }, + + 'version description' => { + message => q|Enter the version/edition/model number for the product.|, + lastUpdated => 0, + }, + + 'version label' => { + message => q|Version/Model|, + lastUpdated => 0, + }, + + 'maintainer description' => { + 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.|, + lastUpdated => 0, + }, + + 'maintainer label' => { + message => q|Maintainer|, + lastUpdated => 0, + }, + + 'manufacturerName description' => { + message => q|The name of the company that manufactures the product or provides the service represented in +this listing.|, + lastUpdated => 0, + }, + + 'manufacturerName label' => { + message => q|Manufacturer Name|, + lastUpdated => 0, + }, + + 'manufacturerURL description' => { + message => q|If the manufacturer has a website, enter the complete URL for it here.|, + lastUpdated => 0, + }, + + 'manufacturerURL label' => { + message => q|Manufacturer URL|, + lastUpdated => 0, + }, + + 'productURL description' => { + message => q|If the product has its own website, enter the complete URL for it here.|, + lastUpdated => 0, + }, + + 'productURL label' => { + message => q|Product URL|, + lastUpdated => 0, + }, + +}; + +1; diff --git a/lib/WebGUI/i18n/English/Form_MatrixCompare.pm b/lib/WebGUI/i18n/English/Form_MatrixCompare.pm new file mode 100644 index 000000000..2c3dff83f --- /dev/null +++ b/lib/WebGUI/i18n/English/Form_MatrixCompare.pm @@ -0,0 +1,32 @@ +package WebGUI::i18n::English::Form_MatrixCompare; +use strict; + +our $I18N = { + 'no' => { + message => q|No|, + lastUpdated => 0, + }, + + 'limited' => { + message => q|Limited|, + lastUpdated => 0, + }, + + 'costs extra' => { + message => q|Costs Extra|, + lastUpdated => 0, + }, + + 'free add on' => { + message => q|Free Add On|, + lastUpdated => 0, + }, + + 'yes' => { + message => q|Yes|, + lastUpdated => 0, + }, + +}; + +1; diff --git a/lib/WebGUI/i18n/English/WebGUI.pm b/lib/WebGUI/i18n/English/WebGUI.pm index 080cbfcdf..ea63f9f0a 100644 --- a/lib/WebGUI/i18n/English/WebGUI.pm +++ b/lib/WebGUI/i18n/English/WebGUI.pm @@ -2880,6 +2880,18 @@ or are under your current version tag. context => q|Field type name| }, + 'matrix fieldtype' => { + message => q|Matrix Field Type|, + lastUpdated =>0, + context => q|Field type name| + }, + + 'matrix compare' => { + message => q|Matrix Compare|, + lastUpdated =>0, + context => q|Field type name| + }, + 'hidden list' => { message => q|Hidden List|, lastUpdated =>0, 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(); +} +