more bug fixes

This commit is contained in:
JT Smith 2005-02-18 01:04:05 +00:00
parent 09abb2d440
commit 9238c028c6
8 changed files with 37 additions and 14 deletions

View file

@ -1436,6 +1436,7 @@ Returns a toolbar with a set of icons that hyperlink to functions that delete, e
sub getToolbar {
my $self = shift;
return undef if ($self->{_toolbarOff});
my $toolbar = deleteIcon('func=delete',$self->get("url"),WebGUI::International::get(43))
.editIcon('func=edit',$self->get("url"))
.moveUpIcon('func=promote',$self->get("url"))
@ -2032,6 +2033,23 @@ sub trash {
#-------------------------------------------------------------------
=head2 toggleToolbar ( )
Toggles whether to render a toolbar in an asset. This is mostly useful for macros that wish to proxy an asset but not display the toolbar.
=cut
sub toggleToolbar {
my $self = shift;
if ($self->{_toolbarOff}) {
$self->{_toolbarOff} = 0;
} else {
$self->{_toolbarOff} = 1;
}
}
#-------------------------------------------------------------------
=head2 update ( properties )
Returns 1. Updates properties of an Asset to given or default values.

View file

@ -248,6 +248,7 @@ sub view {
my $self = shift;
my %var = %{$self->get};
$var{controls} = $self->getToolbar;
$var{controls} = '<p>'.$var{controls}.'</p>' if (exists $var{controls});
$var{fileUrl} = $self->getFileUrl;
$var{fileIcon} = $self->getFileIconUrl;
return $self->processTemplate(\%var,"PBtmpl0000000000000024");

View file

@ -193,6 +193,7 @@ sub view {
my $self = shift;
my %var = %{$self->get};
$var{controls} = $self->getToolbar;
$var{controls} = '<p>'.$var{controls}.'</p>' if (exists $var{controls});
$var{fileUrl} = $self->getFileUrl;
$var{fileIcon} = $self->getFileIconUrl;
$var{thumbnail} = $self->getThumbnailUrl;

View file

@ -20,7 +20,8 @@ sub process {
my ($url) = WebGUI::Macro::getParams(shift);
my $asset = WebGUI::Asset->newByUrl($url);
if (defined $asset) {
return $asset->canView ? $asset->view : "";
$asset->toggleToolbar if ($asset->get("className") =~ /WebGUI::Asset::File/ || $asset->get("className") =~ /WebGUI::Asset::Snippet/ );
return $asset->canView ? $asset->view : undef;
} else {
return "Invalid Asset URL";
}

View file

@ -21,11 +21,12 @@ sub process {
my $asset = WebGUI::Asset->newByUrl($url);
if (defined $asset) {
my $children = $asset->getLineage(["children"]);
randomize;
my $randomAssetId = $children->[rand(scalar(@{$children})];
#randomize;
my $randomAssetId = $children->[rand(scalar(@{$children}))];
my $randomAsset = WebGUI::Asset->newByDynamicClass($randomAssetId);
if (defined $randomAsset) {
return $randomAsset->canView ? $randomAsset->view : "";
$randomAsset->toggleToolbar;
return $randomAsset->canView ? $randomAsset->view : undef;
} else {
return "Asset has no children.";
}

View file

@ -20,11 +20,11 @@ use WebGUI::URL;
#-------------------------------------------------------------------
sub process {
my %var;
my @param = WebGUI::Macro::getParams($_[0]);
my @param = WebGUI::Macro::getParams(shift);
return WebGUI::URL::page("op=displayAccount") if ($param[0] eq "linkonly");
$var{'account.url'} = WebGUI::URL::page('op=displayAccount');
$var{'account.text'} = $param[0] || WebGUI::International::get(46);
return WebGUI::Asset::Template->newByUrl($param[1])->process(\%var);
return WebGUI::Asset::Template->newByUrl($param[1]||"default_account_macro")->process(\%var);
}