diff --git a/docs/upgrades/packages-7.7.6/matrix-default-view-template.wgpkg b/docs/upgrades/packages-7.7.6/matrix-default-view-template.wgpkg new file mode 100644 index 000000000..80b93c31a Binary files /dev/null and b/docs/upgrades/packages-7.7.6/matrix-default-view-template.wgpkg differ diff --git a/lib/WebGUI/Asset/Wobject/Matrix.pm b/lib/WebGUI/Asset/Wobject/Matrix.pm index 36da074b1..129195f34 100644 --- a/lib/WebGUI/Asset/Wobject/Matrix.pm +++ b/lib/WebGUI/Asset/Wobject/Matrix.pm @@ -458,6 +458,54 @@ sub getCompareForm { #------------------------------------------------------------------- +=head2 getListings ( ) + +Returns the listings as an arrayRef of hashRefs. + +=head3 sort + +The criterium by which the listings should be sorted. + +=cut + +sub getListings { + + my $self = shift; + my $session = $self->session; + my $sort = shift || $session->scratch->get('matrixSort') || $self->get('defaultSort'); + + my $sortDirection = ' desc'; + if ($sort eq 'title'){ + $sortDirection = ' asc'; + } + + my $sql = " + select + assetData.title, + assetData.url, + listing.assetId, + listing.views, + listing.compares, + listing.clicks, + listing.lastUpdated + from asset + left join assetData using(assetId) + left join MatrixListing as listing on listing.assetId = assetData.assetId and listing.revisionDate = +assetData.revisionDate + where + asset.parentId=? + and asset.state='published' + and asset.className='WebGUI::Asset::MatrixListing' + and assetData.revisionDate = (SELECT max(revisionDate) from assetData where assetId=asset.assetId and status='approved') + and status='approved' + order by ".$sort.$sortDirection; + + return $session->db->buildArrayRefOfHashRefs($sql,[$self->getId]); + +} + +#------------------------------------------------------------------- + =head2 getEditForm ( ) returns the tabform object that will be used in generating the edit page for Matrix. @@ -544,12 +592,13 @@ sub view { my ($varStatistics,$varStatisticsEncoded); my $var = $self->get; + $var->{listing_loop} = $self->getListings; $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'); $var->{search_url} = $self->getUrl('func=search'); + $var->{compareForm_url} = $self->getUrl(); if ($self->canEdit){ # Get all the MatrixListings that are still pending. @@ -1053,32 +1102,9 @@ sub www_getCompareFormData { @searchParams_sorted = sort { $b->{value} <=> $a->{value} } @searchParams; } - my $sql = " - select - assetData.title, - assetData.url, - listing.assetId, - listing.views, - listing.compares, - listing.clicks, - listing.lastUpdated - from asset - left join assetData using(assetId) - left join MatrixListing as listing on listing.assetId = assetData.assetId and listing.revisionDate = -assetData.revisionDate - where - asset.parentId=? - and asset.state='published' - and asset.className='WebGUI::Asset::MatrixListing' - and assetData.revisionDate = (SELECT max(revisionDate) from assetData where assetId=asset.assetId and status='approved') - and status='approved' - order by ".$sort.$sortDirection; - - my $sth = $session->db->read($sql,[$self->getId]); my @results; - if($form->process("search")){ - while (my $result = $sth->hashRef) { + while (my $result = $self->getListings) { my $matrixListing_attributes = $session->db->buildHashRefOfHashRefs(" select value, fieldType, attributeId from Matrix_attribute left join MatrixListing_attribute as listing using(attributeId) @@ -1105,7 +1131,7 @@ assetData.revisionDate push @results, $result; } }else{ - while (my $result = $sth->hashRef) { + foreach my $result (@{$self->getListings}) { $result->{assetId} =~ s/-/_____/g; if(WebGUI::Utility::isIn($result->{assetId},@listingIds)){ $result->{checked} = 'checked'; @@ -1114,7 +1140,6 @@ assetData.revisionDate push @results, $result; } } - $sth->finish; my $jsonOutput; $jsonOutput->{ResultSet} = {Result=>\@results}; diff --git a/www/extras/wobject/Matrix/matrix.js b/www/extras/wobject/Matrix/matrix.js index 464742f2c..6711e0358 100644 --- a/www/extras/wobject/Matrix/matrix.js +++ b/www/extras/wobject/Matrix/matrix.js @@ -29,16 +29,14 @@ YAHOO.util.Event.addListener(window, "load", function() { } } - this.myDataSource = new YAHOO.util.DataSource(matrixUrl + "?"); - this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON; - this.myDataSource.connXhrMode = "queueRequests"; - this.myDataSource.responseSchema = { - resultsList: "ResultSet.Result", - fields: ["title",{key: "views", parser: "number"},{key: "clicks", parser: "number"},{key: "compares", parser: "number"},{key: "checked"},{key: "lastUpdated", parser: "number"},"url","assetId"] - }; + this.myDataSource = new YAHOO.util.DataSource(YAHOO.util.Dom.get("compareFormTable")); + this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE; + this.myDataSource.responseSchema = { + fields: [{key: "checked"},"assetId","title",{key: "views", parser: "number"},{key: "clicks", parser: "number"},{key: "compares", parser: "number"},{key: "lastUpdated", parser: "number"},"url"] + }; - this.myDataTable = new YAHOO.widget.DataTable("compareForm", myColumnDefs, - this.myDataSource, {initialRequest:uri}); + this.myDataTable = new YAHOO.widget.DataTable("compareForm", myColumnDefs, + this.myDataSource); this.myDataTable.hideColumn(this.myDataTable.getColumn(2)); this.myDataTable.hideColumn(this.myDataTable.getColumn(3));