diff --git a/docs/previousVersion.sql b/docs/previousVersion.sql
index b175fcae7..10ce390a0 100644
--- a/docs/previousVersion.sql
+++ b/docs/previousVersion.sql
@@ -2511,6 +2511,7 @@ CREATE TABLE page (
INSERT INTO page VALUES ('1','0','Home','1001','3',0,'','home',1,'Home',NULL,'1',946710000,2082783600,NULL,NULL,NULL,NULL,NULL,NULL,'English','7','3',0,0,NULL,NULL,NULL,60,600,'3',0,1,22,0,'generate','WebGUI::Page',NULL,0,0);
+INSERT INTO page VALUES ('5','0','Packages','2','3',24,'','packages',0,'Packages',NULL,'1',946710000,2082783600,NULL,NULL,NULL,NULL,NULL,NULL,'English','6','6',1,0,NULL,NULL,NULL,60,600,'3',0,29,30,0,'generate','WebGUI::Page',NULL,0,1);
INSERT INTO page VALUES ('1000','1','Getting Started','1001','3',1,'','getting_started',1,'Getting Started','','1',946710000,2082783600,'',NULL,NULL,NULL,NULL,NULL,'English','7','3',0,0,NULL,NULL,NULL,60,600,'3',0,2,3,1,'generate','WebGUI::Page',NULL,0,0);
INSERT INTO page VALUES ('1001','1','What should you do next?','1001','3',2,'','your_next_step',1,'Your Next Step','','1',946710000,2082783600,'',NULL,NULL,NULL,NULL,NULL,'English','7','3',0,0,NULL,NULL,NULL,60,600,'3',0,4,15,1,'generate','WebGUI::Page',NULL,0,0);
INSERT INTO page VALUES ('1002','1','The Latest News','1001','3',3,'','the_latest_news',1,'The Latest News','','1',946710000,2082783600,'',NULL,NULL,NULL,NULL,NULL,'English','7','3',0,0,NULL,NULL,NULL,60,600,'3',0,16,17,1,'generate','WebGUI::Page',NULL,0,0);
diff --git a/docs/upgrades/upgrade_6.2.9-6.3.0.pl b/docs/upgrades/upgrade_6.2.9-6.3.0.pl
index e59aa6cc0..27633b883 100644
--- a/docs/upgrades/upgrade_6.2.9-6.3.0.pl
+++ b/docs/upgrades/upgrade_6.2.9-6.3.0.pl
@@ -143,7 +143,7 @@ WebGUI::SQL->write("alter table Article drop column attachment");
my %migration;
print "\tConverting navigation system to asset tree\n" unless ($quiet);
-my ($navRootLineage) = WebGUI::SQL->quickArray("select assetId,title,lineage from asset where length(lineage)=12 order by lineage desc limit 1");
+my ($navRootLineage) = WebGUI::SQL->quickArray("select lineage from asset where length(lineage)=12 order by lineage desc limit 1");
$navRootLineage = sprintf("%012d",($navRootLineage+1));
my $navRootId = WebGUI::SQL->setRow("asset","assetId",{
assetId=>"new",
@@ -174,13 +174,15 @@ WebGUI::SQL->setRow("Navigation","assetId",{
assetsToInclude=>"descendants",
showHiddenPages=>1
},undef,$navRootId);
-my $sth = WebGUI::SQL->read("select * from tempoldnav");
+my %macroCache;
my $navRankCounter = 1;
+my $sth = WebGUI::SQL->read("select * from tempoldnav");
while (my $data = $sth->hashRef) {
print "\t\tConverting ".$data->{identifier}."\n" unless ($quiet);
my (%newNav,%newAsset,%newWobject);
$newNav{assetId} = $newWobject{assetId} = $newAsset{assetId} = getNewId("nav",$data->{navigationId});
$newAsset{url} = fixUrl($newAsset{assetId},$data->{identifier});
+ $macroCache{$data->{identifier}} = $newAsset{url};
$newAsset{isHidden} = 1;
$newAsset{title} = $newAsset{menuTitle} = $data->{identifier};
$newAsset{ownerUserId} = "3";
@@ -265,112 +267,6 @@ $sth->finish;
WebGUI::SQL->write("update Navigation set startPoint='root' where startPoint='nameless_root'");
WebGUI::SQL->write("drop table tempoldnav");
-print "\tConverting collateral manager items into assets\n" unless ($quiet);
-my ($collateralRootLineage) = WebGUI::SQL->quickArray("select assetId,title,lineage from asset where length(lineage)=12 order by lineage desc limit 1");
-$collateralRootLineage = sprintf("%012d",($collateralRootLineage+1));
-my $collateralRootId = WebGUI::SQL->setRow("asset","assetId",{
- assetId=>"new",
- isHidden=>1,
- title=>"Navigation Configurations",
- menuTitle=>"Navigation Configurations",
- url=>fixUrl('doesntexistyet',"Navigation Configurations"),
- ownerUserId=>"3",
- groupIdView=>"4",
- groupIdEdit=>"4",
- parentId=>"PBasset000000000000001",
- lineage=>$collateralRootLineage,
- lastUpdated=>time(),
- className=>"WebGUI::Asset::Wobject::Navigation",
- state=>"published"
- });
-WebGUI::SQL->setRow("wobject","assetId",{
- assetId=>$collateralRootId,
- templateId=>"1",
- styleTemplateId=>"1",
- printableStyleTemplateId=>"3"
- },undef,$collateralRootId);
-WebGUI::SQL->setRow("Navigation","assetId",{
- assetId=>$collateralRootId,
- startType=>"relativeToCurrentUrl",
- startPoint=>"0",
- endPoint=>"55",
- assetsToInclude=>"descendants",
- showHiddenPages=>1
- },undef,$collateralRootId);
-my %folderCache = ('0'=>$collateralRootId);
-my $collateralRankCounter = 1;
-my $sth = WebGUI::SQL->read("select * from collateralFolder");
-while (my $data = $sth->hashRef) {
- my $folderId = WebGUI::SQL->setRow("asset","assetId",{
- assetId=>"new",
- className=>'WebGUI::Asset::Layout',
- lineage=>$collateralRootLineage.sprintf("%06d",$collateralRankCounter),
- parentId=>$collateralRootId,
- ownerUserId=>'3',
- groupIdView=>'4',
- groupIdEdit=>'4',
- lastUpdate=>time(),
- title=>quote($data->{name}),
- menuTitle=>quote($data->{name}),
- url=>quote(fixUrl('doesntexist',$data->{name})),
- state=>'published'
- });
- WebGUI::SQL->setRow("wobject","assetId",{
- assetId=>quote($folderId),
- templateId=>'15',
- styleTemplateId=>"1",
- printableStyleTemplateId=>"3",
- namespace=>'Layout',
- description=>quote($data->{description})
- },undef,$folderId);
- WebGUI::SQL->setRow("layout","assetId",{
- assetId=>quote($folderId)
- },undef,$folderId);
- $folderCache{$data->{collateralFolderId}} = $folderId;
- $collateralRankCounter++;
-}
-$sth->finish;
-my %collateralCache;
-my $lastCollateralFolderId = 'nolastid';
-my ($parentId, $baseLineage, $rank);
-my $sth = WebGUI::SQL->read("select * from collateral order by collateralFolderId");
-while (my $data = $sth->hashRef) {
- unless ($lastCollateralFolderId eq $data->{collateralFolderId}) {
- $rank = 1;
- $baseLineage = "";
- $parentId = "";
- }
- my $class;
- my $collateralId = WebGUI::Id::generate();
- if ($data->{filename} ne "") {
- my $storageId = copyFile($data->{filename},'images/'.$data->{collateralId});
- if (isIn(getFileExtension($data->{filename}), qw(jpg jpeg gif png))) {
- copyFile('thumb-'.$data->{filename},'images/'.$data->{collateralId},$storageId);
- WebGUI::SQL->write("insert into ImageAsset (assetId, thumbnailSize) values (".quote($newId).",
- ".quote($session{setting}{thumbnailSize}).")");
- $class = 'WebGUI::Asset::File::Image';
- } else {
- $class = 'WebGUI::Asset::File';
- }
- WebGUI::SQL->write("insert into FileAsset (assetId, filename, storageId, fileSize) values (
- ".quote($newId).", ".quote($data->{$field}).", ".quote($storageId).",
- ".quote(getFileSize($storageId,$data->{$field})).")");
- } else {
-
- }
- WebGUI::SQL->write("insert into asset (assetId, parentId, lineage, className, state, title, menuTitle,
- url, startDate, endDate, isHidden, ownerUserId, groupIdView, groupIdEdit, synopsis) values (".
- quote($collateralId).", ".quote($parentId).", ".quote($baseLineage.sprintf("%06d",$rank)).",
- '".$class."','published',".quote($data->{fileTitle}).", ".
- quote($data->{fileTitle}).", ".quote(fixUrl($newId,$wobjectUrl.'/'.$data->{$field})).",
- ".quote($wobject->{startDate}).", ".quote($wobject->{endDate}).", 1, ".quote($ownerId).",
- ".quote($data->{groupToView}).", ".quote($groupIdEdit).", ".quote($data->{briefSynopsis}).")");
- $collateralCache{$data->{collateralId}} = $collateralId;
- $rank++;
-}
-
-WebGUI::SQL->write("drop table collateralFolder");
-WebGUI::SQL->write("drop table collateral");
print "\tConverting navigation templates\n" unless ($quiet);
@@ -406,13 +302,164 @@ $sth->finish;
+
+print "\tConverting collateral manager items into assets\n" unless ($quiet);
+my ($collateralRootLineage) = WebGUI::SQL->quickArray("select lineage from asset where length(lineage)=12 order by lineage desc limit 1");
+$collateralRootLineage = sprintf("%012d",($collateralRootLineage+1));
+my $collateralRootId = WebGUI::SQL->setRow("asset","assetId",{
+ assetId=>"new",
+ isHidden=>1,
+ title=>"Files, Snippets, and Images",
+ menuTitle=>"Files, Snippets, and Images",
+ url=>fixUrl('doesntexistyet',"Collateral"),
+ ownerUserId=>"3",
+ groupIdView=>"4",
+ groupIdEdit=>"4",
+ parentId=>"PBasset000000000000001",
+ lineage=>$collateralRootLineage,
+ lastUpdated=>time(),
+ className=>"WebGUI::Asset::Wobject::Navigation",
+ state=>"published"
+ });
+WebGUI::SQL->setRow("wobject","assetId",{
+ assetId=>$collateralRootId,
+ templateId=>"1",
+ styleTemplateId=>"1",
+ printableStyleTemplateId=>"3"
+ },undef,$collateralRootId);
+WebGUI::SQL->setRow("Navigation","assetId",{
+ assetId=>$collateralRootId,
+ startType=>"relativeToCurrentUrl",
+ startPoint=>"0",
+ endPoint=>"55",
+ assetsToInclude=>"descendants",
+ showHiddenPages=>1
+ },undef,$collateralRootId);
+my %folderCache = ('0'=>$collateralRootId);
+my %folderNameCache;
+my $collateralRankCounter = 1;
+my $sth = WebGUI::SQL->read("select * from collateralFolder where collateralFolderId <> '0'");
+while (my $data = $sth->hashRef) {
+ my $url = fixUrl('doesntexist',$data->{name});
+ $folderNameCache{$data->{name}} = $url;
+ my $folderId = WebGUI::SQL->setRow("asset","assetId",{
+ assetId=>"new",
+ className=>'WebGUI::Asset::Layout',
+ lineage=>$collateralRootLineage.sprintf("%06d",$collateralRankCounter),
+ parentId=>$collateralRootId,
+ ownerUserId=>'3',
+ groupIdView=>'4',
+ groupIdEdit=>'4',
+ lastUpdated=>time(),
+ title=>$data->{name},
+ menuTitle=>$data->{name},
+ url=>$url,
+ state=>'published'
+ });
+ WebGUI::SQL->setRow("wobject","assetId",{
+ assetId=>quote($folderId),
+ templateId=>'15',
+ styleTemplateId=>"1",
+ printableStyleTemplateId=>"3",
+ description=>$data->{description}
+ },undef,$folderId);
+ WebGUI::SQL->setRow("layout","assetId",{
+ assetId=>$folderId
+ },undef,$folderId);
+ $folderCache{$data->{collateralFolderId}} = {
+ id=>$folderId,
+ lineage=>$collateralRootLineage.sprintf("%06d",$collateralRankCounter)
+ };
+ $collateralRankCounter++;
+}
+$sth->finish;
+my $lastCollateralFolderId = 'nolastid';
+my ($parentId, $baseLineage, $rank);
+my $sth = WebGUI::SQL->read("select * from collateral order by collateralFolderId");
+while (my $data = $sth->hashRef) {
+ unless ($lastCollateralFolderId eq $data->{collateralFolderId}) {
+ $rank = 1;
+ my $id = $data->{collateralFolderId};
+ $id = "0" unless (defined $id);
+ $baseLineage = $folderCache{$id}{lineage};
+ $parentId = $folderCache{$id}{id};
+ }
+ my $class;
+ my $collateralId = WebGUI::Id::generate();
+ my $fileSize;
+ if ($data->{collateralType} eq "file" || $data->{collateralType} eq "image") {
+ my $storageId = copyFile($data->{filename},'images/'.$data->{collateralId});
+ if (isIn(getFileExtension($data->{filename}), qw(jpg jpeg gif png))) {
+ copyFile('thumb-'.$data->{filename},'images/'.$data->{collateralId},$storageId);
+ WebGUI::SQL->write("insert into ImageAsset (assetId, parameters, thumbnailSize) values (".quote($collateralId).",
+ ".quote($data->{parameters}).", ".quote($data->{thumbnailSize}).")");
+ $class = 'WebGUI::Asset::File::Image';
+ } else {
+ $class = 'WebGUI::Asset::File';
+ }
+ WebGUI::SQL->write("insert into FileAsset (assetId, filename, storageId) values (
+ ".quote($collateralId).", ".quote($data->{filename}).", ".quote($storageId).")");
+ $fileSize = getFileSize($storageId,$data->{filename});
+ } else {
+ WebGUI::SQL->setRow("snippet","assetId",{
+ assetId=>$collateralId,
+ snippet=>$data->{parameters}
+ },undef,$collateralId);
+ $fileSize = length($data->{parameters});
+ }
+ my $url = fixUrl($collateralId,$data->{name});
+ $macroCache{$data->{name}} = $macroCache{$data->{collateralId}} = $url;
+ WebGUI::SQL->write("insert into asset (assetId, parentId, lineage, className, state, title, menuTitle,
+ url, ownerUserId, groupIdView, groupIdEdit, fileSize, lastUpdated) values (".
+ quote($collateralId).", ".quote($parentId).", ".quote($baseLineage.sprintf("%06d",$rank)).",
+ '".$class."','published',".quote($data->{name}).", ".
+ quote($data->{name}).", ".quote($url).", ".quote($data->{userId}).",
+ '7', '4', ".quote($fileSize).",".quote($data->{dateUploaded}).")");
+ $rank++;
+}
+WebGUI::SQL->write("drop table collateralFolder");
+WebGUI::SQL->write("drop table collateral");
+
+
+
+
+print "\tReplacing some old macros with new ones\n" unless ($quiet);
+my $sth = WebGUI::SQL->read("select templateId, namespace, template from template");
+while (my ($id, $namespace, $template) = $sth->array) {
+ WebGUI::SQL->write("update template set template=".quote(replaceMacros($template))." where
+ templateId=".quote($id)." and namespace=".quote($namespace));
+}
+$sth->finish;
+my $sth = WebGUI::SQL->read("select assetId, description from wobject");
+while (my ($id, $desc) = $sth->array) {
+ WebGUI::SQL->write("update wobject set description=".quote(replaceMacros($desc))." where assetId=".quote($id));
+}
+$sth->finish;
+
+my $sth = WebGUI::SQL->read("select assetId, snippet from snippet");
+while (my ($id, $snip) = $sth->array) {
+ WebGUI::SQL->write("update snippet set snippet=".quote(replaceMacros($snip))." where assetId=".quote($id));
+}
+$sth->finish;
+
+
+
+
+
print "\tDeleting files which are no longer used.\n" unless ($quiet);
#unlink("../../lib/WebGUI/Page.pm");
#unlink("../../lib/WebGUI/Operation/Page.pm");
#unlink("../../lib/WebGUI/Operation/Root.pm");
#unlink("../../lib/WebGUI/Navigation.pm");
-#unlink("../../lib/WebGUI/Macro/Navigation.pm");
#unlink("../../lib/WebGUI/Operation/Navigation.pm");
+#unlink("../../lib/WebGUI/Macro/Navigation.pm");
+#unlink("../../lib/WebGUI/Macro/File.pm");
+#unlink("../../lib/WebGUI/Macro/I_imageWithTags.pm");
+#unlink("../../lib/WebGUI/Macro/i_imageNoTags.pm");
+#unlink("../../lib/WebGUI/Macro/Snippet.pm");
+#unlink("../../lib/WebGUI/Macro/Backslash_pageUrl.pm");
+#unlink("../../lib/WebGUI/Macro/RandomSnippet.pm");
+#unlink("../../lib/WebGUI/Macro/RandomImage.pm");
#unlink("../../lib/WebGUI/Attachment.pm");
#unlink("../../lib/WebGUI/Node.pm");
#unlink("../../lib/WebGUI/Wobject/Article.pm");
@@ -421,25 +468,28 @@ print "\tDeleting files which are no longer used.\n" unless ($quiet);
#unlink("../../lib/WebGUI/Wobject/USS.pm");
#unlink("../../lib/WebGUI/Wobject/FileManager.pm");
+
+
+
#--------------------------------------------
print "\tUpdating config file.\n" unless ($quiet);
my $pathToConfig = '../../etc/'.$configFile;
my $conf = Parse::PlainConfig->new('DELIM' => '=', 'FILE' => $pathToConfig);
my $macros = $conf->get("macros");
delete $macros->{"\\"};
-$macros->{"\\\\"} = "Backslash_pageUrl";
+delete $macros->{"Backslash_pageUrl"};
+delete $macros->{"I_imageWithTags"};
+delete $macros->{"Snippet"};
+delete $macros->{"Navigation"};
+delete $macros->{"File"};
+delete $macros->{"RandomSnippet"};
+delete $macros->{"RandomImage"};
+delete $macros->{"i_imageNoTags"};
$macros->{"AssetProxy"} = "AssetProxy";
-$macros->{"Navigation"} = "AssetProxy";
-my %newMacros;
-foreach my $macro (keys %{$macros}) {
- unless (
- $macros->{$macro} eq "m_currentMenuHorizontal"
- || $macros->{$macro} eq "M_currentMenuVertical"
- ) {
- $newMacros{$macro} = $macros->{$macro};
- }
-}
-$conf->set("macros"=>\%newMacros);
+$macros->{"RandomAssetProxy"} = "RandomAssetProxy";
+$macros->{"FileUrl"} = "FileUrl";
+$macros->{"PageUrl"} = "PageUrl";
+$conf->set("macros"=>$macros);
$conf->set("assets"=>[
'WebGUI::Asset::Wobject::Navigation',
'WebGUI::Asset::Wobject::Layout',
@@ -456,9 +506,79 @@ $conf->set("assets"=>[
$conf->write;
+
+
+print "\tMiscellaneous other changes.\n" unless ($quiet);
+WebGUI::SQL->write("delete from settings where name='snippetPreviewLength'");
+WebGUI::SQL->write("delete from incrementer where incrementerId in ('collateralFolderId','themeId','themeComponentId')");
+
+
+
+
+
WebGUI::Session::close();
+
+
+
+
+
+
+sub replaceMacros {
+ my $content = shift;
+my $parenthesis;
+$parenthesis = qr /\( # Start with '(',
+ (?: # Followed by
+ (?>[^()]+) # Non-parenthesis
+ |(??{ $parenthesis }) # Or a balanced parenthesis block
+ )* # zero or more times
+ \)/x; # Ending with ')'
+my $nestedMacro;
+$nestedMacro = qr /(\^ # Start with carat
+ ([^\^;()]+) # And one or more none-macro characters -tagged-
+ ((?: # Followed by
+ (??{ $parenthesis }) # a balanced parenthesis block
+ |(?>[^\^;]) # Or not a carat or semicolon
+# |(??{ $nestedMacro }) # Or a balanced carat-semicolon block
+ )*) # zero or more times -tagged-
+ ;)/x; # End with a semicolon.
+ while ($content =~ /$nestedMacro/gs) {
+ my ($macro, $searchString, $params) = ($1, $2, $3);
+ next if ($searchString =~ /^\d+$/); # don't process ^0; ^1; ^2; etc.
+ next if ($searchString =~ /^\-$/); # don't process ^-;
+ if ($params ne "") {
+ $params =~ s/(^\(|\)$)//g; # remove parenthesis
+ }
+ my @parsed;
+ push(@parsed, $+) while $params =~ m {
+ "([^\"\\]*(?:\\.[^\"\\]*)*)",?
+ | ([^,]+),?
+ | ,
+ }gx;
+ push(@parsed, undef) if substr($params,-1,1) eq ',';
+ my $result;
+ if (isIn($searchString, qw(Navigation I Snippet File))) {
+ my $url = (exists $macroCache{$parsed[0]}) ? $macroCache{$parsed[0]} : $parsed[0];
+ $result = '^AssetProxy("'.$url.'");';
+ } elsif (isIn($searchString, qw(RandomSnippet RandomImage))) {
+ my $url = (exists $macroCache{$parsed[0]}) ? $folderCache{$parsed[0]} : $parsed[0];
+ $result = '^RandomAssetProxy("'.$url.'");';
+ } elsif (isIn($searchString, qw(i))) {
+ my $url = (exists $macroCache{$parsed[0]}) ? $macroCache{$parsed[0]} : $parsed[0];
+ $result = '^FileUrl("'.$url.'");';
+ } elsif (isIn($searchString, qw(\\))) {
+ $result = '^PageUrl;';
+ } else {
+ next;
+ }
+ $content =~ s/\Q$macro/$result/ges;
+ }
+ return $content;
+}
+
+
+
sub walkTree {
my $oldParentId = shift;
my $newParentId = shift;
@@ -594,22 +714,24 @@ sub walkTree {
my $class;
if (isIn(getFileExtension($data->{$field}), qw(jpg jpeg gif png))) {
copyFile('thumb-'.$data->{$field},$wobject->{wobjectId}.'/'.$data->{FileManager_fileId},$storageId);
- WebGUI::SQL->write("insert into ImageAsset (assetId, thumbnailSize) values (".quote($newId).",
- ".quote($session{setting}{thumbnailSize}).")");
+ WebGUI::SQL->write("insert into ImageAsset (assetId, thumbnailSize, parameters) values
+ (".quote($newId).",
+ ".quote($session{setting}{thumbnailSize}).", ".quote('alt="'.$wobject->{title}.'"').")");
$class = 'WebGUI::Asset::File::Image';
} else {
$class = 'WebGUI::Asset::File';
}
WebGUI::SQL->write("insert into FileAsset (assetId, filename, storageId, fileSize) values (
- ".quote($newId).", ".quote($data->{$field}).", ".quote($storageId).",
- ".quote(getFileSize($storageId,$data->{$field})).")");
+ ".quote($newId).", ".quote($data->{$field}).", ".quote($storageId).")");
WebGUI::SQL->write("insert into asset (assetId, parentId, lineage, className, state, title, menuTitle,
- url, startDate, endDate, isHidden, ownerUserId, groupIdView, groupIdEdit, synopsis) values (".
+ url, startDate, endDate, isHidden, ownerUserId, groupIdView, groupIdEdit, synopsis, fileSize
+ ) values (".
quote($newId).", ".quote($wobjectId).", ".quote($wobjectLineage.sprintf("%06d",1)).",
'".$class."','published',".quote($data->{fileTitle}).", ".
quote($data->{fileTitle}).", ".quote(fixUrl($newId,$wobjectUrl.'/'.$data->{$field})).",
".quote($wobject->{startDate}).", ".quote($wobject->{endDate}).", 1, ".quote($ownerId).",
- ".quote($data->{groupToView}).", ".quote($groupIdEdit).", ".quote($data->{briefSynopsis}).")");
+ ".quote($data->{groupToView}).", ".quote($groupIdEdit).", ".quote($data->{briefSynopsis}).",
+ ".quote(getFileSize($storageId,$data->{$field})).")");
$rank++;
}
}
@@ -661,6 +783,7 @@ sub walkTree {
sub fixUrl {
my $id = shift;
my $url = shift;
+ $url = WebGUI::Id::generate() unless (defined $url);
$url = WebGUI::URL::urlize($url);
my ($test) = WebGUI::SQL->quickArray("select url from asset where assetId<>".quote($id)." and url=".quote($url));
if ($test) {
@@ -671,7 +794,7 @@ sub fixUrl {
$parts[0] .= "2";
}
$url = join(".",@parts);
- $url = fixUrl($url);
+ $url = fixUrl($id,$url);
}
return $url;
}
diff --git a/lib/WebGUI/Macro/File.pm b/lib/WebGUI/Macro/File.pm
deleted file mode 100644
index 70a2b38fa..000000000
--- a/lib/WebGUI/Macro/File.pm
+++ /dev/null
@@ -1,37 +0,0 @@
-package WebGUI::Macro::File;
-
-#-------------------------------------------------------------------
-# WebGUI is Copyright 2001-2004 Plain Black Corporation.
-#-------------------------------------------------------------------
-# Please read the legal notices (docs/legal.txt) and the license
-# (docs/license.txt) that came with this distribution before using
-# this software.
-#-------------------------------------------------------------------
-# http://www.plainblack.com info@plainblack.com
-#-------------------------------------------------------------------
-
-use strict;
-use WebGUI::Collateral;
-use WebGUI::Macro;
-use WebGUI::Session;
-use WebGUI::Template;
-
-#-------------------------------------------------------------------
-sub process {
- my @param = WebGUI::Macro::getParams($_[0]);
- my %var;
- if (my $collateral = WebGUI::Collateral->find($param[0])) {
- $var{'file.url'} = $collateral->getURL;
- $var{'file.icon'} = $collateral->getIcon;
- $var{'file.name'} = $param[0];
- $var{'file.size'} = $collateral->getSize;
- $var{'file.thumbnail'} = $collateral->getThumbnail;
- return WebGUI::Template::process(WebGUI::Template::getIdByName($param[1],"Macro/File"),"Macro/File", \%var);
- } else {
- return undef;
- }
-}
-
-1;
-
-
diff --git a/lib/WebGUI/Macro/i_imageNoTags.pm b/lib/WebGUI/Macro/FileUrl.pm
similarity index 66%
rename from lib/WebGUI/Macro/i_imageNoTags.pm
rename to lib/WebGUI/Macro/FileUrl.pm
index dbdcc8519..01ba296f6 100644
--- a/lib/WebGUI/Macro/i_imageNoTags.pm
+++ b/lib/WebGUI/Macro/FileUrl.pm
@@ -1,4 +1,4 @@
-package WebGUI::Macro::i_imageNoTags;
+package WebGUI::Macro::FileUrl;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2004 Plain Black Corporation.
@@ -11,18 +11,21 @@ package WebGUI::Macro::i_imageNoTags;
#-------------------------------------------------------------------
use strict;
-use WebGUI::Collateral;
+use WebGUI::Asset;
use WebGUI::Macro;
use WebGUI::Session;
+use WebGUI::Storage;
#-------------------------------------------------------------------
sub process {
- my @param = WebGUI::Macro::getParams($_[0]);
- if (my $collateral = WebGUI::Collateral->find($param[0])) {
- return $collateral->getURL;
- } else {
- return "";
- }
+ my ($url) = WebGUI::Macro::getParams(shift);
+ my $asset = WebGUI::Asset->newByUrl($url);
+ if (defined $asset) {
+ my $storage = WebGUI::Storage->get($asset->get("storageId"));
+ return $storage->getUrl($asset->get("filename"));
+ } else {
+ return "Invalid Asset URL";
+ }
}
diff --git a/lib/WebGUI/Macro/Backslash_pageUrl.pm b/lib/WebGUI/Macro/PageUrl.pm
similarity index 95%
rename from lib/WebGUI/Macro/Backslash_pageUrl.pm
rename to lib/WebGUI/Macro/PageUrl.pm
index d7e65b6e1..f30d8ef56 100644
--- a/lib/WebGUI/Macro/Backslash_pageUrl.pm
+++ b/lib/WebGUI/Macro/PageUrl.pm
@@ -1,4 +1,4 @@
-package WebGUI::Macro::Backslash_pageUrl;
+package WebGUI::Macro::PageUrl;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2004 Plain Black Corporation.
diff --git a/lib/WebGUI/Macro/I_imageWithTags.pm b/lib/WebGUI/Macro/RandomAssetProxy.pm
similarity index 54%
rename from lib/WebGUI/Macro/I_imageWithTags.pm
rename to lib/WebGUI/Macro/RandomAssetProxy.pm
index 220c4f5d4..f33642217 100644
--- a/lib/WebGUI/Macro/I_imageWithTags.pm
+++ b/lib/WebGUI/Macro/RandomAssetProxy.pm
@@ -1,4 +1,4 @@
-package WebGUI::Macro::I_imageWithTags;
+package WebGUI::Macro::RandomAssetProxy;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2004 Plain Black Corporation.
@@ -11,22 +11,26 @@ package WebGUI::Macro::I_imageWithTags;
#-------------------------------------------------------------------
use strict;
-use WebGUI::Collateral;
+use WebGUI::Asset;
use WebGUI::Macro;
use WebGUI::Session;
#-------------------------------------------------------------------
sub process {
- my @param = WebGUI::Macro::getParams($_[0]);
- if (my $collateral = WebGUI::Collateral->find($param[0])) {
- my $tag = 'get("parameters");
- unless ($tag =~ /alt\=/i) {
- $tag .= ' alt="'.$collateral->get("name").'"';
+ my ($url) = WebGUI::Macro::getParams(shift);
+ my $asset = WebGUI::Asset->newByUrl($url);
+ if (defined $asset) {
+ my $children = $asset->getLineage(["descendants"],{endingLineageLength=>$asset->getLineageLength+1});
+ randomize;
+ my $randomAssetId = $children->[rand(scalar(@{$children})];
+ my $randomAsset = WebGUI::Asset->newByDynamicClass($randomAssetId);
+ if (defined $randomAsset) {
+ return $randomAsset->canView ? $randomAsset->view : "";
+ } else {
+ return "Asset has no children.";
}
- $tag .= ' />';
- return $tag;
} else {
- return "";
+ return "Invalid asset URL.";
}
}
diff --git a/lib/WebGUI/Macro/RandomImage.pm b/lib/WebGUI/Macro/RandomImage.pm
deleted file mode 100644
index 724c13f96..000000000
--- a/lib/WebGUI/Macro/RandomImage.pm
+++ /dev/null
@@ -1,41 +0,0 @@
-package WebGUI::Macro::RandomImage;
-
-#-------------------------------------------------------------------
-# WebGUI is Copyright 2001-2004 Plain Black Corporation.
-#-------------------------------------------------------------------
-# Please read the legal notices (docs/legal.txt) and the license
-# (docs/license.txt) that came with this distribution before using
-# this software.
-#-------------------------------------------------------------------
-# http://www.plainblack.com info@plainblack.com
-#-------------------------------------------------------------------
-
-use strict;
-use Tie::CPHash;
-use WebGUI::Collateral;
-use WebGUI::Macro;
-use WebGUI::Session;
-use WebGUI::SQL;
-
-#-------------------------------------------------------------------
-sub process {
- my @param = WebGUI::Macro::getParams($_[0]);
- my $collateralFolderId = 0;
- if ($param[0] ne "") {
- ($collateralFolderId) = WebGUI::SQL->quickArray("select collateralFolderId from collateralFolder
- where name=".quote($param[0]),WebGUI::SQL->getSlave);
- $collateralFolderId = 0 unless ($collateralFolderId);
- }
- my @images = WebGUI::SQL->buildArray("select collateralId from collateral
- where collateralType='image' and collateralFolderId=".quote($collateralFolderId),WebGUI::SQL->getSlave);
- if (my $collateral = WebGUI::Collateral->new($images[rand($#images+1)])) {
- return '
get("parameters").' />';
- } else {
- return undef;
- }
-}
-
-
-1;
-
-
diff --git a/lib/WebGUI/Macro/RandomSnippet.pm b/lib/WebGUI/Macro/RandomSnippet.pm
deleted file mode 100644
index 5f3cc5113..000000000
--- a/lib/WebGUI/Macro/RandomSnippet.pm
+++ /dev/null
@@ -1,41 +0,0 @@
-package WebGUI::Macro::RandomSnippet;
-
-#-------------------------------------------------------------------
-# WebGUI is Copyright 2001-2004 Plain Black Corporation.
-#-------------------------------------------------------------------
-# Please read the legal notices (docs/legal.txt) and the license
-# (docs/license.txt) that came with this distribution before using
-# this software.
-#-------------------------------------------------------------------
-# http://www.plainblack.com info@plainblack.com
-#-------------------------------------------------------------------
-
-use strict;
-use Tie::CPHash;
-use WebGUI::Collateral;
-use WebGUI::Macro;
-use WebGUI::Session;
-use WebGUI::SQL;
-
-#-------------------------------------------------------------------
-sub process {
- my @param = WebGUI::Macro::getParams($_[0]);
- my $collateralFolderId = 0;
- if ($param[0] ne "") {
- ($collateralFolderId) = WebGUI::SQL->quickArray("select collateralFolderId from collateralFolder
- where name=".quote($param[0]),WebGUI::SQL->getSlave);
- $collateralFolderId = 0 unless ($collateralFolderId);
- }
- my @snippets = WebGUI::SQL->buildArray("select collateralId from collateral
- where collateralType='snippet' and collateralFolderId=".quote($collateralFolderId),WebGUI::SQL->getSlave);
- if (my $collateral = WebGUI::Collateral->new($snippets[rand($#snippets+1)])) {
- return $collateral->get("parameters");
- } else {
- return undef;
- }
-}
-
-
-1;
-
-
diff --git a/lib/WebGUI/Macro/Snippet.pm b/lib/WebGUI/Macro/Snippet.pm
deleted file mode 100644
index 62ab8b0ee..000000000
--- a/lib/WebGUI/Macro/Snippet.pm
+++ /dev/null
@@ -1,36 +0,0 @@
-package WebGUI::Macro::Snippet;
-
-#-------------------------------------------------------------------
-# WebGUI is Copyright 2001-2004 Plain Black Corporation.
-#-------------------------------------------------------------------
-# Please read the legal notices (docs/legal.txt) and the license
-# (docs/license.txt) that came with this distribution before using
-# this software.
-#-------------------------------------------------------------------
-# http://www.plainblack.com info@plainblack.com
-#-------------------------------------------------------------------
-
-use strict;
-use Tie::CPHash;
-use WebGUI::Collateral;
-use WebGUI::Macro;
-use WebGUI::Session;
-
-#-------------------------------------------------------------------
-sub process {
- my @param = WebGUI::Macro::getParams($_[0]);
- if (my $collateral = WebGUI::Collateral->find($param[0])) {
- my $temp = $collateral->get("parameters");
- for my $i ( 1 .. $#param ) {
- $temp =~ s/\^$i\;/$param[$i]/g;
- }
- return $temp;
- } else {
- return undef;
- }
-}
-
-
-1;
-
-
diff --git a/www/extras/FileUploadControl.js b/www/extras/FileUploadControl.js
index 8759c06f2..8a4e3d673 100755
--- a/www/extras/FileUploadControl.js
+++ b/www/extras/FileUploadControl.js
@@ -16,7 +16,7 @@ function FileUploadControl(workspaceId, imageArray) {
str +='