Replaced Matrix with newer version

This commit is contained in:
Yung Han Khoe 2008-11-19 19:01:34 +00:00
commit 79bfa826e0
8 changed files with 2592 additions and 1580 deletions

View file

@ -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

View file

@ -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/^<p>//;
$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;

View file

@ -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('<tr><td colspan="2"><b>'.$category.'</b></td></tr>');
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|
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="/extras/ukplayer/AC_RunActiveContent.js" language="javascript"></script>
<script language="javascript">
if (AC_FL_RunContent == 0) {
alert("This page requires AC_RunActiveContent.js.");
} else {
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
'width', '400',
'height', '300',
'src', 'swc/assets',
'quality', 'high',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'slideShow',
'bgcolor', '#ffffff',
'name', 'coverflow',
'menu', 'true',
// note: the width & height in the flashVars below MUST match the width & height set above
'flashVars',
'config=?func=getScreenshotsConfig&width=400&height=300&backgroundColor=0xCCCCCC&fontColor=&textBorderColor=&textBackgroundColor=&controlsColor=&controlsBorderColor=&controlsBackgroundColor=',
'allowFullScreen', 'false',
'allowScriptAccess','sameDomain',
'movie', '/extras/ukplayer/slideShow',
'salign', ''
); //end AC code
}
</script>
<noscript>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="400"
height="300" id="swc/assets" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="flashVars" value="config=?func=getScreenshotsConfig" />
<param name="movie" value="/extras/ukplayer/slideShow.swf" /><param name="quality" value="high" /><param
name="bgcolor" value="#ffffff" /> <embed src="/extras/ukplayer/slideShow.swf" quality="high" bgcolor="#ffffff"
width="400" height="300" name="swc/assets" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false"
flashvars="config=?func=getScreenshotsConfig" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</noscript>
|;
}
# 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 = "<table class='ratingForm'><tbody>\n
<tr><th></th><th>Mean</th><th>Median</th><th>Count</th></tr>\n";
my $ratingForm = WebGUI::HTMLForm->new($self->session,
-extras =>'class="content"',
-tableExtras=>'class="content"'
);
$ratingForm = WebGUI::HTMLForm->new($self->session,
-extras =>'class="ratingForm"',
-tableExtras=>'class="ratingForm"'
);
$ratingForm->hidden(
-name =>"listingId",
-value =>$self->getId
);
$ratingForm->hidden(
-name =>"func",
-value =>"rate"
);
foreach my $category (@categories) {
my ($mean,$median,$count) = $db->quickArray("select meanValue, medianValue, countValue
from MatrixListing_ratingSummary
where listingId=? and category=?",[$self->getId,$category]);
$ratingsTable .= '<tr><th>'.$category.'</th><td>'.$mean.'</td><td>'.$median.'</td><td>'.$count.'</td></tr>';
$ratingForm->selectBox(
-name =>$category,
-label =>$category,
-value =>[5],
-extras =>'class="ratingForm"',
-options=>\%rating
);
}
$ratingsTable .= '</tbody></table>';
$ratingForm->submit(
-extras =>'class="ratingForm"',
-value =>$i18n->get('rate submit label'),
-label =>'<a href="'.$self->getUrl("func=rate").'">'.$i18n->get('show ratings').'</a>'
);
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 |<?xml version="1.0" encoding="UTF-8"?>
<content>
<slides>
|;
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 .= "
<slide>
<width>400</width>
<height>300</height>
<title><![CDATA[<b>Slide</b> One]]></title>
<description><![CDATA[ Screenshots ]]></description>
<image_source>".$storage->getUrl($file)."</image_source>
<duration>5</duration>
<thumb_source>".$storage->getUrl($thumb)."</thumb_source>
</slide>
";
}
}
}
$xml .= qq |
</slides>
</content>
|;
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|<?xml version="1.0" encoding="UTF-8"?>
<config>
<content_url>?func=getScreenshots</content_url>
<width>400</width><!-- this value is overwritten by the flashVars but the tag needs to be here (and it is
useful for offline testing) -->
<height>300</height><!-- this value is overwritten by the flashVars but the tag needs to be here (and it is
useful for offline testing) -->
<background_color>0xDDDDEE</background_color>
<default_duration>20</default_duration>
<default_slidewidth>100</default_slidewidth>
<default_slideheight>100</default_slideheight>
<font>Verdana</font>
<font_size>12</font_size>
<font_color>0xCCCCCC</font_color>
<text_border_color>0xCCCCCC</text_border_color>
<text_bg_color>0x000000</text_bg_color>
<text_autohide>true</text_autohide>
<controls_color>0xCCCCCC</controls_color>
<controls_border_color>0xCCCCCC</controls_border_color>
<controls_bg_color>0x000000</controls_bg_color>
<controls_autohide>false</controls_autohide>
<thumbnail_width>48</thumbnail_width>
<thumbnail_height>36</thumbnail_height>
<thumbnail_border_color>0x000000</thumbnail_border_color>
<menu_autohide>true</menu_autohide>
<menu_dead_zone_width>100</menu_dead_zone_width>
<menu_gaps>5</menu_gaps>
<mute_at_start>false</mute_at_start>
<autostart>true</autostart>
<autopause>false</autopause>
<loop>false</loop>
<error_message_content><![CDATA[XML not found: ]]></error_message_content>
<error_message_image><![CDATA[Image not found]]></error_message_image>
</config>
|;
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

File diff suppressed because it is too large Load diff

View file

@ -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'

View file

@ -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|<br />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|<h1>Edit Listing</h1>|
},
'edit field' => {
lastUpdated => 1135279558,
message => q|<h1>Edit Field</h1>|
'edit attribute title' => {
lastUpdated => 0,
message => q|Edit/Add Attribute|
},
'good bad' => {
@ -869,12 +949,20 @@ our $I18N = {
<p><a href="%s">No, I made a mistake.</a></p>|,
},
'list fields' => {
lastUpdated => 1135289632,
message => q|<h1>Field List</h1>
<a href="%s">Add new field.</a>
<p />|,
},
'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|<p>The field type of attribute you are creating. Please select the field type from the options in the drop-down list.</p>|
},
'field type description' => {
lastUpdated => 1167185918,
message => q|<p>The type of field you are creating. Please select the type from the following options in the drop-down list.</p>
<div>
<dl>
<dt>Good Bad</dt>
<dd>Defines availability of a feature, has it, doesn't have it, limited functionality, free add on, etc.</dd>
<dt>Text</dt>
<dd>A single line of text, like a short description or title.</dd>
<dt>TextArea</dt>
<dd>Multiple lines of text.</dd>
<dt>URL</dt>
<dd>A URL.</dd>
<dt>Combo</dt>
<dd>A combination Text box and drop down list.</dd>
</dl></div>|
'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|<p>Enter in a default value for the attribute that will be used if the fieldType is
selectBox.</p>|
},
'default value description' => {
translatorsNote => q|Please do not translate the GoodBad field values, as described below|,
lastUpdated => 1135279558,
message => q|<p>Enter in a default value for the field that will be used if the user leaves the field blank.</p>
<p>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.</p>
<p>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.</p>|
'attribute options description' => {
lastUpdated => 0,
message => q|<p>Enter in options (one per line) for the attribute that will be used if the fieldType is
selectBox.</p>|
},
'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.|
},
};

63
t/Asset/MatrixListing.t Normal file
View file

@ -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();
}

98
t/Asset/Wobject/Matrix.t Normal file
View file

@ -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();
}