Fix Folder sortOrder to be moosey. Convert to using Moose accessors.

This commit is contained in:
Colin Kuskie 2010-02-04 13:07:19 -08:00
parent 5203c35563
commit d3e2970075

View file

@ -40,18 +40,24 @@ property sortAlphabetically => (
hoverHelp => ['sort alphabetically help', 'Asset_Folder'],
);
# my %optionsSortOrder = (
# ASC => $i18n->get( "editForm sortOrder ascending" ),
# DESC => $i18n->get( "editForm sortOrder descending" ),
# );
property sortOrder => (
tab => 'display',
fieldType => "selectBox",
#options => \%optionsSortOrder,
options => \&_sortOrder_options,
default => "ASC",
label => [ "editForm sortOrder label" , 'Asset_Folder'],
hoverHelp => [ "editForm sortOrder description" , 'Asset_Folder'],
);
sub _sortOrder_options {
my $self = shift;
my $i18n = WebGUI::International->new($self->session, 'Asset_Folder');
my $optionsSortOrder = {
ASC => $i18n->get( "editForm sortOrder ascending" ),
DESC => $i18n->get( "editForm sortOrder descending" ),
};
return $optionsSortOrder;
}
property templateId => (
fieldType => "template",
default => 'PBtmpl0000000000000078',
@ -94,7 +100,7 @@ Overridden to check the revision dates of children as well
sub getContentLastModified {
my $self = shift;
my $mtime = $self->get("revisionDate");
my $mtime = $self->revisionDate;
foreach my $child (@{ $self->getLineage(["children"],{returnObjects=>1}) }) {
my $child_mtime = $child->getContentLastModified;
$mtime = $child_mtime if ($child_mtime > $mtime);
@ -114,7 +120,7 @@ sub getEditForm {
my $self = shift;
my $tabform = $self->SUPER::getEditForm();
my $i18n = WebGUI::International->new($self->session,"Asset_Folder");
if ($self->get("assetId") eq "new") {
if ($self->assetId eq "new") {
$tabform->getTab("properties")->whatNext(
-options=>{
view=>$i18n->get(823),
@ -158,11 +164,11 @@ See WebGUI::Asset::prepareView() for details.
sub prepareView {
my $self = shift;
$self->SUPER::prepareView();
my $template = WebGUI::Asset::Template->new($self->session, $self->get("templateId"));
my $template = WebGUI::Asset::Template->new($self->session, $self->templateId);
if (!$template) {
WebGUI::Error::ObjectNotFound::Template->throw(
error => qq{Template not found},
templateId => $self->get("templateId"),
templateId => $self->templateId,
assetId => $self->getId,
);
}
@ -208,11 +214,11 @@ sub view {
# TODO: Getting the children template vars should be a seperate method.
my %rules = ( returnObjects => 1);
if ( $self->get( "sortAlphabetically" ) ) {
$rules{ orderByClause } = "assetData.title " . $self->get( "sortOrder" );
if ( $self->sortAlphabetically ) {
$rules{ orderByClause } = "assetData.title " . $self->sortOrder;
}
else {
$rules{ orderByClause } = "asset.lineage " . $self->get( "sortOrder" );
$rules{ orderByClause } = "asset.lineage " . $self->sortOrder;
}
my $children = $self->getLineage( ["children"], \%rules);
@ -222,9 +228,9 @@ sub view {
push @{ $vars->{ "subfolder_loop" } }, {
id => $child->getId,
url => $child->getUrl,
title => $child->get("title"),
menuTitle => $child->get("menuTitle"),
synopsis => $child->get("synopsis") || '',
title => $child->title,
menuTitle => $child->menuTitle,
synopsis => $child->synopsis || '',
canView => $child->canView(),
"icon.small" => $child->getIcon(1),
"icon.big" => $child->getIcon,
@ -234,11 +240,11 @@ sub view {
my $childVars = {
id => $child->getId,
canView => $child->canView(),
title => $child->get("title"),
menuTitle => $child->get("menuTitle"),
synopsis => $child->get("synopsis") || '',
size => WebGUI::Utility::formatBytes($child->get("assetSize")),
"date.epoch" => $child->get("revisionDate"),
title => $child->title,
menuTitle => $child->menuTitle,
synopsis => $child->synopsis || '',
size => WebGUI::Utility::formatBytes($child->assetSize),
"date.epoch" => $child->revisionDate,
"icon.small" => $child->getIcon(1),
"icon.big" => $child->getIcon,
type => $child->getName,
@ -265,7 +271,7 @@ sub view {
# Update the cache
if ($self->session->user->isVisitor) {
eval{$cache->set("view_".$self->getId, $out, $self->get("visitorCacheTimeout"))};
eval{$cache->set("view_".$self->getId, $out, $self->visitorCacheTimeout)};
}
return $out;
@ -282,7 +288,7 @@ See WebGUI::Asset::Wobject::www_view() for details.
sub www_view {
my $self = shift;
$self->session->http->setCacheControl($self->get("visitorCacheTimeout")) if ($self->session->user->isVisitor);
$self->session->http->setCacheControl($self->visitorCacheTimeout) if ($self->session->user->isVisitor);
$self->SUPER::www_view(@_);
}