From fd4453df58a3167bbd0950e15c55bbfa69e50c68 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Fri, 14 Apr 2006 02:35:35 +0000 Subject: [PATCH] added a sort alphabetically option to the folder asset --- docs/changelog/6.x.x.txt | 1 + docs/upgrades/upgrade_6.8.8-6.99.0.pl | 7 +++++++ lib/WebGUI/Asset/Wobject/Folder.pm | 14 +++++++++++++- lib/WebGUI/AssetLineage.pm | 4 ++++ lib/WebGUI/i18n/English/Asset_Folder.pm | 10 ++++++++++ 5 files changed, 35 insertions(+), 1 deletion(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index d1b171f34..525df9811 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -37,6 +37,7 @@ everything should cache in the same way. - Converted WebGUI to use a new object oriented session system. More details in migation.txt. + - Added a sort alphabetically option to the folder asset. - Added a screenshot feature to the matrix. - Added an option to delete Matrix fields. - Added an API for retrieving email from POP3 servers. diff --git a/docs/upgrades/upgrade_6.8.8-6.99.0.pl b/docs/upgrades/upgrade_6.8.8-6.99.0.pl index 603e93bfa..a4db47d16 100644 --- a/docs/upgrades/upgrade_6.8.8-6.99.0.pl +++ b/docs/upgrades/upgrade_6.8.8-6.99.0.pl @@ -45,9 +45,16 @@ updateHelpTemplate(); fixImportNodePrivileges(); addAdManager(); updateMatrix(); +updateFolder(); finish($session); # this line required +#------------------------------------------------- +sub updateFolder { + print "\tAdding sort option to folder.\n"; + $session->db->write("alter table Folder add column sortAlphabetically int not null default 0"); +} + #------------------------------------------------- sub updateMatrix { print "\tAdding new features to the matrix.\n"; diff --git a/lib/WebGUI/Asset/Wobject/Folder.pm b/lib/WebGUI/Asset/Wobject/Folder.pm index b968a1a76..113067887 100644 --- a/lib/WebGUI/Asset/Wobject/Folder.pm +++ b/lib/WebGUI/Asset/Wobject/Folder.pm @@ -74,6 +74,10 @@ sub definition { label => $i18n->get("visitor cache timeout"), hoverHelp => $i18n->get("visitor cache timeout help") }, + sortAlphabetically => { + fieldType=>"yesNo", + defaultValue=>0 + }, templateId =>{ fieldType=>"template", defaultValue=>'PBtmpl0000000000000078' @@ -105,6 +109,12 @@ sub getEditForm { -uiLevel=>8, -defaultValue=>3600 ); + $tabform->getTab("display")->yesNo( + -value=>$self->getValue('sortAlphabetically'), + -label=>$i18n->get('sort alphabetically'), + -hoverHelp=>$i18n->get('sort alphabetically help'), + -name=>"sortAlphabetically" + ); $tabform->getTab("display")->template( -value=>$self->getValue('templateId'), -label=>$i18n->get('folder template title'), @@ -162,7 +172,9 @@ sub view { my $out = WebGUI::Cache->new($self->session,"view_".$self->getId)->get; return $out if $out; } - my $children = $self->getLineage( ["children"], { returnObjects=>1 }); + my %rules = ( returnObjects => 1); + $rules{orderByClause} = 'assetData.title' if ($self->get("sortAlphabetically")); + my $children = $self->getLineage( ["children"], \%rules); my %vars; foreach my $child (@{$children}) { if (ref($child) eq "WebGUI::Asset::Wobject::Folder") { diff --git a/lib/WebGUI/AssetLineage.pm b/lib/WebGUI/AssetLineage.pm index 91a999951..e9ac4af60 100644 --- a/lib/WebGUI/AssetLineage.pm +++ b/lib/WebGUI/AssetLineage.pm @@ -257,6 +257,10 @@ An array reference containing asset classes to join in. There is no real reason A string containing extra where clause information for the query. +=head4 orderByClause + +A string containing an order by clause (without the "order by"). + =cut sub getLineage { diff --git a/lib/WebGUI/i18n/English/Asset_Folder.pm b/lib/WebGUI/i18n/English/Asset_Folder.pm index e42246d78..925644994 100644 --- a/lib/WebGUI/i18n/English/Asset_Folder.pm +++ b/lib/WebGUI/i18n/English/Asset_Folder.pm @@ -2,6 +2,16 @@ package WebGUI::i18n::English::Asset_Folder; our $I18N = { + 'sort alphabetically' => { + message => q|Sort alphabetically?|, + lastUpdated => 0 + }, + + 'sort alphabetically help' => { + message => q|Do you want to sort the items in this folder alphabetically? If you select no then it will sort according to rank.|, + lastUpdated => 0 + }, + 'visitor cache timeout' => { message => q|Visitor Cache Timeout|, lastUpdated => 0