From 9238c028c6c74f29fee9cd95ccf1d77883a38acf Mon Sep 17 00:00:00 2001 From: JT Smith Date: Fri, 18 Feb 2005 01:04:05 +0000 Subject: [PATCH] more bug fixes --- docs/upgrades/upgrade_6.2.11-6.3.0.pl | 13 +++++++------ docs/upgrades/upgrade_6.2.11-6.3.0.sql | 4 ++-- lib/WebGUI/Asset.pm | 18 ++++++++++++++++++ lib/WebGUI/Asset/File.pm | 1 + lib/WebGUI/Asset/File/Image.pm | 1 + lib/WebGUI/Macro/AssetProxy.pm | 3 ++- lib/WebGUI/Macro/RandomAssetProxy.pm | 7 ++++--- lib/WebGUI/Macro/a_account.pm | 4 ++-- 8 files changed, 37 insertions(+), 14 deletions(-) diff --git a/docs/upgrades/upgrade_6.2.11-6.3.0.pl b/docs/upgrades/upgrade_6.2.11-6.3.0.pl index fb6d8d336..9f8b6865f 100644 --- a/docs/upgrades/upgrade_6.2.11-6.3.0.pl +++ b/docs/upgrades/upgrade_6.2.11-6.3.0.pl @@ -182,7 +182,7 @@ WebGUI::SQL->write("alter table WobjectProxy add column shortcutToAssetId varcha my $sth = WebGUI::SQL->read("select proxiedWobjectId from WobjectProxy"); while (my ($wobjectId) = $sth->array) { my ($assetId) = WebGUI::SQL->quickArray("select assetId from wobject where wobjectId=".quote($wobjectId)); - WebGUI::SQL->write("update WobjectProxy set shortcutToAssetId=".quote($assetId)." where wobjectId=".quote($wobjectId)); + WebGUI::SQL->write("update WobjectProxy set shortcutToAssetId=".quote($assetId)." where proxiedWobjectId=".quote($wobjectId)); } $sth->finish; foreach my $namespace (@allWobjects) { @@ -456,7 +456,7 @@ WebGUI::SQL->setRow("wobject","assetId",{ styleTemplateId=>"1", printableStyleTemplateId=>"3" },undef,$collateralRootId); -WebGUI::SQL->setRow("Navigation","assetId",{ +WebGUI::SQL->setRow("Folder","assetId",{ assetId=>$collateralRootId, templateId=>"PBtmpl0000000000000078" },undef,$collateralRootId); @@ -470,7 +470,7 @@ while (my $data = $sth->hashRef) { $folderNameCache{$data->{name}} = $url; my $folderId = WebGUI::SQL->setRow("asset","assetId",{ assetId=>"new", - className=>'WebGUI::Asset::Layout', + className=>'WebGUI::Asset::Wobject::Folder', lineage=>$collateralRootLineage.sprintf("%06d",$collateralRankCounter), parentId=>$collateralRootId, ownerUserId=>'3', @@ -488,8 +488,8 @@ while (my $data = $sth->hashRef) { printableStyleTemplateId=>"3", description=>$data->{description} },undef,$folderId); - WebGUI::SQL->setRow("Layout","assetId",{ - templateId=>'15', + WebGUI::SQL->setRow("Folder","assetId",{ + templateId=>'PBtmpl0000000000000078', assetId=>$folderId },undef,$folderId); $folderCache{$data->{collateralFolderId}} = { @@ -533,6 +533,7 @@ while (my $data = $sth->hashRef) { snippet=>$data->{parameters} },undef,$collateralId); $fileSize = length($data->{parameters}); + $class = 'WebGUI::Asset::Snippet'; } my $url = fixUrl($collateralId,$data->{name}); $macroCache{$data->{name}} = $macroCache{$data->{collateralId}} = $url; @@ -1512,7 +1513,7 @@ sub walkTree { WebGUI::SQL->write("update asset set className='WebGUI::Asset::Wobject::Navigation' where assetId=".quote($wobjectId)); WebGUI::SQL->write("update wobject set namespace='Navigation' where assetId=".quote($wobjectId)); } elsif ($wobject->{namespace} eq "FileManager") { - print "\t\t\tConverting File Manager ".$wobject->{wobjectId}." into File Folder Layout\n" unless ($quiet); + print "\t\t\tConverting File Manager ".$wobject->{wobjectId}." into File Folder\n" unless ($quiet); WebGUI::SQL->write("update asset set className='WebGUI::Asset::Folder' where assetId=".quote($wobjectId)); WebGUI::SQL->write("insert into Folder (assetId,templateId) values (".quote($wobjectId).", '15')"); WebGUI::SQL->write("update wobject set namespace='Folder' where wobjectId=".quote($wobject->{wobjectId})); diff --git a/docs/upgrades/upgrade_6.2.11-6.3.0.sql b/docs/upgrades/upgrade_6.2.11-6.3.0.sql index d3e9ea40b..eff69c98e 100644 --- a/docs/upgrades/upgrade_6.2.11-6.3.0.sql +++ b/docs/upgrades/upgrade_6.2.11-6.3.0.sql @@ -222,8 +222,8 @@ INSERT INTO template VALUES ('7','Side By Side','\"> INSERT INTO template VALUES ('6','Right Column','\">\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n
 
\r\n\r\n
\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n
\r\n\r\n
 
\r\n\r\n\r\n \r\n
 
\r\n \r\n
\r\n ','page',1,1); INSERT INTO template VALUES ('1','Default Page','\">\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n\r\n \r\n
 
\r\n \r\n
\r\n ','page',1,1); -INSERT INTO template VALUES ('1','File','\r\n

\r\n
\r\n\">\" alt=\"\" border=\"0\" />','FileAsset',1,1); -INSERT INTO template VALUES ('2','Image','\r\n

\r\n
\r\n\" />','ImageAsset',1,1); +INSERT INTO template VALUES ('1','File','\r\n\r\n\r\n\">\" alt=\"\" border=\"0\" />','FileAsset',1,1); +INSERT INTO template VALUES ('2','Image','\r\n\r\n\r\n\" />','ImageAsset',1,1); INSERT INTO template VALUES ('15','File Folder','\">\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n\r\n\r\n \r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n\r\n\r\n\r\n
\">\" border=\"0\" alt=\"\"> \">
\">\" border=\"0\" alt=\"\"> \">^D(\"%z %Z\",);
', 'Folder',1,1); diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index a01659096..a2a38f706 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -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. diff --git a/lib/WebGUI/Asset/File.pm b/lib/WebGUI/Asset/File.pm index 11c5ec9e6..11ef82b9a 100644 --- a/lib/WebGUI/Asset/File.pm +++ b/lib/WebGUI/Asset/File.pm @@ -248,6 +248,7 @@ sub view { my $self = shift; my %var = %{$self->get}; $var{controls} = $self->getToolbar; + $var{controls} = '

'.$var{controls}.'

' if (exists $var{controls}); $var{fileUrl} = $self->getFileUrl; $var{fileIcon} = $self->getFileIconUrl; return $self->processTemplate(\%var,"PBtmpl0000000000000024"); diff --git a/lib/WebGUI/Asset/File/Image.pm b/lib/WebGUI/Asset/File/Image.pm index 0957f9576..f64b6b0d3 100644 --- a/lib/WebGUI/Asset/File/Image.pm +++ b/lib/WebGUI/Asset/File/Image.pm @@ -193,6 +193,7 @@ sub view { my $self = shift; my %var = %{$self->get}; $var{controls} = $self->getToolbar; + $var{controls} = '

'.$var{controls}.'

' if (exists $var{controls}); $var{fileUrl} = $self->getFileUrl; $var{fileIcon} = $self->getFileIconUrl; $var{thumbnail} = $self->getThumbnailUrl; diff --git a/lib/WebGUI/Macro/AssetProxy.pm b/lib/WebGUI/Macro/AssetProxy.pm index 0afc3209d..da1bfba44 100644 --- a/lib/WebGUI/Macro/AssetProxy.pm +++ b/lib/WebGUI/Macro/AssetProxy.pm @@ -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"; } diff --git a/lib/WebGUI/Macro/RandomAssetProxy.pm b/lib/WebGUI/Macro/RandomAssetProxy.pm index 309135c97..f8f11e7db 100644 --- a/lib/WebGUI/Macro/RandomAssetProxy.pm +++ b/lib/WebGUI/Macro/RandomAssetProxy.pm @@ -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."; } diff --git a/lib/WebGUI/Macro/a_account.pm b/lib/WebGUI/Macro/a_account.pm index 88b00c4a0..d01474d65 100644 --- a/lib/WebGUI/Macro/a_account.pm +++ b/lib/WebGUI/Macro/a_account.pm @@ -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); }