diff --git a/lib/WebGUI/Asset/MatrixListing.pm b/lib/WebGUI/Asset/MatrixListing.pm
index 27416611d..3a090ed22 100644
--- a/lib/WebGUI/Asset/MatrixListing.pm
+++ b/lib/WebGUI/Asset/MatrixListing.pm
@@ -975,23 +975,23 @@ sub install {
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,
+ assetId char(22) binary not null,
revisionDate bigint not null,
- title varchar(255),
- screenshots varchar(22),
+ screenshots char(22),
description text,
- version varchar(255),
+ version char(255),
views int(11),
compares int(11),
clicks int(11),
- viewsLastIp varchar(255),
- comparesLastIp varchar(255),
- clicksLastIp varchar(255),
+ viewsLastIp char(255),
+ comparesLastIp char(255),
+ clicksLastIp char(255),
lastUpdated int(11),
- maintainer varchar(22),
- manufacturerName varchar(255),
- manufacturerURL varchar(255),
- productURL varchar(255),
+ maintainer char(22),
+ manufacturerName char(255),
+ manufacturerURL char(255),
+ productURL char(255),
+ score int(11),
primary key (assetId, revisionDate)
)");
$session->db->write("create table MatrixListing_attribute (
diff --git a/lib/WebGUI/Asset/Wobject/Matrix.pm b/lib/WebGUI/Asset/Wobject/Matrix.pm
index c4bf353ca..7d118379d 100644
--- a/lib/WebGUI/Asset/Wobject/Matrix.pm
+++ b/lib/WebGUI/Asset/Wobject/Matrix.pm
@@ -360,6 +360,8 @@ An array of listingIds that should be selected in the compare form.
sub getCompareForm {
my $self = shift;
+
+=cut
my @selectedListingIds = @_;
my (%options, @listings);
@@ -380,12 +382,19 @@ sub getCompareForm {
$options{$listing->getId} = ''.$listing->get('title').'';
}
-
- my $form = WebGUI::Form::formHeader($self->session,{action=>$self->getUrl})
- .WebGUI::Form::submit($self->session, {
- value=>"compare"
- })
- ."
"
+ my $maxComparisons;
+ if($self->session->user->isVisitor){
+ $maxComparisons = $self->get('maxComparisons');
+ }
+ else{
+ $maxComparisons = $self->get('maxComparisonsPrivileged');
+ }
+=cut
+ my $form = WebGUI::Form::formHeader($self->session,{action=>$self->getUrl,extras=>'name="doCompare"'})
+# .WebGUI::Form::submit($self->session, {
+# value=>"compare"
+# })
+# ."
"
."
"
.WebGUI::Form::hidden($self->session, {
name=>"func",
@@ -399,11 +408,21 @@ sub getCompareForm {
# options=>\%options,
# })
."
"
- .WebGUI::Form::submit($self->session,{
- value=>"compare"
- })
+# .WebGUI::Form::submit($self->session,{
+# value=>"compare"
+# })
.WebGUI::Form::formFooter($self->session);
- #.'
';
+
+ my $maxComparisons;
+ if($self->session->user->isVisitor){
+ $maxComparisons = $self->get('maxComparisons');
+ }
+ else{
+ $maxComparisons = $self->get('maxComparisonsPrivileged');
+ }
+ $form .= "\n\n";
return $form;
}
@@ -501,6 +520,8 @@ sub view {
$var->{isLoggedIn} = ($self->session->user->userId ne "1");
$var->{addMatrixListing_url} = $self->getUrl('func=add;class=WebGUI::Asset::MatrixListing');
$var->{compareForm} = $self->getCompareForm;
+ $var->{exportAttributes_url} = $self->getUrl('func=exportAttributes');
+ $var->{listAttributes_url} = $self->getUrl('func=listAttributes');
# Get the MatrixListing with the most views as an object using getLineage.
my ($bestViews_listing) = @{ $self->getLineage(['descendants'], {
@@ -709,16 +730,25 @@ sub www_compare {
$self->session->style->setLink($self->session->url->extras('yui/build/datatable/assets/skins/sam/datatable.css'),
{type =>'text/css', rel=>'stylesheet'});
+ my $maxComparisons;
+ if($self->session->user->isVisitor){
+ $maxComparisons = $self->get('maxComparisons');
+ }
+ else{
+ $maxComparisons = $self->get('maxComparisonsPrivileged');
+ }
+
foreach my $listingId (@listingIds){
my $listingId_safe = $listingId;
$listingId_safe =~ s/-/_____/g;
push(@columnKeys, $listingId_safe);
push(@columnKeys, $listingId_safe."_compareColor");
}
-
+
$var->{javascript} = "";
return $self->processStyle($self->processTemplate($var,$self->get("compareTemplateId")));
@@ -921,6 +951,31 @@ sub www_editAttributeSave {
#-------------------------------------------------------------------
+=head2 www_exportAttributes ( )
+
+Exports search attributes as csv.
+
+=cut
+
+sub www_exportAttributes {
+ my $self = shift;
+ my $session = $self->session;
+ my $output = WebGUI::Text::joinCSV("name","description","category");
+
+ my $attributes = $session->db->read("select name, description, category
+ from Matrix_attribute where assetId = ? order by category, name",[$self->getId]);
+
+ while (my $attribute = $attributes->hashRef) {
+ $output .= "\n".WebGUI::Text::joinCSV($attribute->{name},$attribute->{description},$attribute->{category});
+ }
+ my $fileName = "export_matrix_attributes.csv";
+ $self->session->http->setFilename($fileName,"application/octet-stream");
+ $self->session->http->sendHeader;
+ return $output;
+}
+
+#-------------------------------------------------------------------
+
=head2 www_getCompareFormData ( )
Returns the compare form data as JSON.
@@ -1255,14 +1310,14 @@ sub install {
primary key (assetId, revisionDate)
)");
$session->db->write("create table Matrix_attribute (
- assetId varchar(22) binary not null,
- attributeId varchar(22) binary not null,
- name varchar(255) not null,
+ assetId char(22) binary not null,
+ attributeId char(22) binary not null,
+ name char(255) not null,
description text,
- fieldType varchar(255) not null default 'MatrixField',
- category varchar(22) not null,
+ fieldType char(255) not null default 'MatrixCompare',
+ category char(22) not null,
options text,
- defaultValue varchar(255),
+ defaultValue char(255),
primary key (attributeId)
)");
$session->var->end;
diff --git a/www/extras/wobject/Matrix/matrix.js b/www/extras/wobject/Matrix/matrix.js
index 0783fd0e2..bd85203d5 100644
--- a/www/extras/wobject/Matrix/matrix.js
+++ b/www/extras/wobject/Matrix/matrix.js
@@ -82,19 +82,40 @@ YAHOO.util.Event.addListener(window, "load", function() {
// compareCheckBoxes[i].onchange = compareFormButton;
//}
- };
-});
- function compareFormButton () {
+ var btnCompare = new YAHOO.widget.Button("compare",{disabled:true,id:"compareButton"});
+ btnCompare.on("click", function(e) {
+ alert('bla');
+ window.document.forms['doCompare'].submit();
+ },this,true);
+
+ window.compareFormButton = function() {
var compareCheckBoxes = YAHOO.util.Dom.getElementsByClassName('compareCheckBox','input');
- //alert(compareCheckBoxes.length);
var checked = 0;
for (var i = compareCheckBoxes.length; i--; ) {
if(compareCheckBoxes[i].checked){
checked++;
}
}
- //alert(checked);
+ if (checked > 1 && checked < maxComparisons){
+ btnCompare.set("disabled",false);
+ }else{
+ btnCompare.set("disabled",true);
+ }
}
+ };
+});
+
+// function compareFormButton () {
+// var compareCheckBoxes = YAHOO.util.Dom.getElementsByClassName('compareCheckBox','input');
+ //alert(compareCheckBoxes.length);
+// var checked = 0;
+// for (var i = compareCheckBoxes.length; i--; ) {
+// if(compareCheckBoxes[i].checked){
+// checked++;
+// }
+// }
+ //alert(checked);
+// }
//function sort() {
// myCompareTable.sortColumn()
diff --git a/www/extras/wobject/Matrix/matrixCompareList.js b/www/extras/wobject/Matrix/matrixCompareList.js
index c24f95761..2db979d74 100644
--- a/www/extras/wobject/Matrix/matrixCompareList.js
+++ b/www/extras/wobject/Matrix/matrixCompareList.js
@@ -108,9 +108,7 @@ YAHOO.util.Event.addListener(window, "load", function() {
},this,true);
//btnCompare.set("disabled",true);
- alert(btnCompare.get("disabled"));
-
-
+ //alert(btnCompare.get("disabled"));
window.compareFormButton = function() {
var compareCheckBoxes = YAHOO.util.Dom.getElementsByClassName('compareCheckBox','input');
var checked = 0;
@@ -119,7 +117,8 @@ YAHOO.util.Event.addListener(window, "load", function() {
checked++;
}
}
- if (checked > 1){
+ //alert(maxComparisons);
+ if (checked > 1 && checked < maxComparisons){
btnCompare.set("disabled",false);
}else{
btnCompare.set("disabled",true);
diff --git a/www/extras/wobject/Matrix/matrixSearch.js b/www/extras/wobject/Matrix/matrixSearch.js
index 3380ca361..ee60d5e7f 100644
--- a/www/extras/wobject/Matrix/matrixSearch.js
+++ b/www/extras/wobject/Matrix/matrixSearch.js
@@ -62,6 +62,7 @@ YAHOO.util.Event.addListener(window, "load", function() {
myDataTable.getRecordSet().reset();
this.set("sortedBy", null);
this.onDataReturnAppendRows.apply(this,arguments);
+ compareFormButton();
};
var callback2 = {
@@ -77,19 +78,43 @@ YAHOO.util.Event.addListener(window, "load", function() {
newUri = newUri + ';search_' + attributeSelects[i].id + '=' + attributeSelects[i].value;
}
var elements = myDataTable.getRecordSet().getRecords();
- alert(elements.length);
for(i=0; i 1 && checked < maxComparisons){
+ btnCompare.set("disabled",false);
+ }else{
+ btnCompare.set("disabled",true);
+ }
+ }
};