StoryTopic 'Alphabetically' sort order

This commit is contained in:
Scott Walters 2010-07-27 18:42:31 -04:00
parent 33592f9dbb
commit e033192328
6 changed files with 110 additions and 9 deletions

View file

@ -37,6 +37,7 @@ sub definition {
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new($session, 'Asset_StoryTopic');
my $other_i18n = WebGUI::International->new($session, 'Asset_StoryArchive');
my %properties;
tie %properties, 'Tie::IxHash';
%properties = (
@ -72,6 +73,17 @@ sub definition {
namespace => 'Story',
defaultValue => 'TbDcVLbbznPi0I0rxQf2CQ',
},
storySortOrder => {
fieldType => "selectBox",
tab => 'display',
defaultValue => 'Chronologically',
options => {
Alphabetically => $other_i18n->get('alphabetically'),
Chronologically => $other_i18n->get('chronologically')
},
label => $other_i18n->get('sortAlphabeticallyChronologically'),
hoverHelp => $other_i18n->get('sortAlphabeticallyChronologically description'),
},
);
push(@{$definition}, {
assetName=>$i18n->get('assetName'),
@ -174,10 +186,11 @@ sub viewTemplateVariables {
my $wordList = WebGUI::Keyword::string2list($self->get('keywords'));
my $key = WebGUI::Keyword->new($session);
my $p = $key->getMatchingAssets({
keywords => $wordList,
isa => 'WebGUI::Asset::Story',
usePaginator => 1,
rowsPerPage => $numberOfStories,
sortOrder => $self->get('storySortOrder') || 'Chronologically',
keywords => $wordList,
isa => 'WebGUI::Asset::Story',
usePaginator => 1,
rowsPerPage => $numberOfStories,
});
my $storyIds = $p->getPageData();
$var->{story_loop} = [];

View file

@ -367,9 +367,18 @@ sub getMatchingAssets {
push @clauses, 'keyword in ('.join(',', @placeholders).')';
}
my $sortOrder = $options->{sortOrder} || 'Chronologically';
my $orderBy = $sortOrder eq 'Alphabetically' ? ' order by upper(title), lineage' : ' order by creationDate desc, lineage';
# write the query
my $query = 'select distinct assetKeyword.assetId from assetKeyword left join asset using (assetId)
where '.join(' and ', @clauses).' order by creationDate desc, lineage';
my $query = q{
select distinct assetKeyword.assetId
from assetKeyword
left join asset using (assetId)
left join assetData using (assetId)
where } .
join(' and ', @clauses) . $orderBy;
# perform the search
if ($options->{usePaginator}) {