added collateral migration and some other bug fixes

This commit is contained in:
JT Smith 2004-12-30 02:00:28 +00:00
parent b6f9315976
commit 4f8489300f
12 changed files with 321 additions and 329 deletions

View file

@ -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);

View file

@ -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;
}

View file

@ -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;

View file

@ -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";
}
}

View file

@ -1,4 +1,4 @@
package WebGUI::Macro::Backslash_pageUrl;
package WebGUI::Macro::PageUrl;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2004 Plain Black Corporation.

View file

@ -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 = '<img src="'.$collateral->getURL.'" '.$collateral->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.";
}
}

View file

@ -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 '<img src="'.$collateral->getURL.'" '.$collateral->get("parameters").' />';
} else {
return undef;
}
}
1;

View file

@ -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;

View file

@ -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;

View file

@ -16,7 +16,7 @@ function FileUploadControl(workspaceId, imageArray) {
str +='<table style="display: none;">'
str += '<tr id="' + workspaceId + '.template" class="fileUploadRow"><td><img src="' + images["unknown"] + '" style="visibility: hidden"></td>';
str +='<td><input type="file" name="files" size="40" onchange="FileUploadControl_valueChange(event)"></td><td><input type="button" value="Remove" onclick="FileUploadControl_removeButtonClick(event)"></td></tr>';
str +='<td><input type="file" name="file" size="40" onchange="FileUploadControl_valueChange(event)"></td><td><input type="button" value="Remove" onclick="FileUploadControl_removeButtonClick(event)"></td></tr>';
str += '</table>';
@ -120,4 +120,4 @@ function FileUploadControl_valueChange(e) {
}
control.swapImage(firedobj);
}
}

View file

@ -5,6 +5,12 @@
function Display() {
this.dom=document.getElementById&&!document.all;
this.documentElement = document.documentElement;
if (document.compatMode == "BackCompat") {
this.documentElement = document.body;
}
this.focusObjects = new Array();
this.overObjects = new Array();
this.topLevelElement=this.dom? "HTML" : "BODY"
@ -55,8 +61,8 @@ function Display_dragStart(firedobj,xCoordinate,yCoordinate) {
this.dragEnabled=true;
this.pageHeight = document.documentElement.scrollHeight;
this.pageWidth = document.documentElement.scrollWidth;
this.pageHeight = this.documentElement.scrollHeight;
this.pageWidth = this.documentElement.scrollWidth;
this.focusObjects[0]=firedobj.asset;
@ -138,10 +144,10 @@ function Display_move(e){
if (this.dragEnabled){
this.adjustScrollBars(e);
var topScroll = document.documentElement.scrollTop;
var leftScroll =document.documentElement.scrollLeft;
var topScroll = this.documentElement.scrollTop;
var leftScroll =this.documentElement.scrollLeft;
var act = this.spy(this.dom? e.pageX: (e.clientX + document.documentElement.scrollLeft),this.dom? e.pageY: (e.clientY + document.documentElement.scrollTop));
var act = this.spy(this.dom? e.pageX: (e.clientX + this.documentElement.scrollLeft),this.dom? e.pageY: (e.clientY + this.documentElement.scrollTop));
if (act && act.asset) {
this.selectAsset(act.asset);
@ -213,11 +219,13 @@ function Display_keyUp(e) {
function Display_adjustScrollBars(e) {
var scrY=0;
var scrX=0;
if (!this.documentElement) return;
var topScroll = document.documentElement.scrollTop;
var leftScroll = document.documentElement.scrollLeft;
var innerHeight = document.documentElement.clientHeight;
var innerWidth = document.documentElement.clientWidth;
var topScroll = this.documentElement.scrollTop;
var leftScroll = this.documentElement.scrollLeft;
var innerHeight = this.documentElement.clientHeight;
var innerWidth = this.documentElement.clientWidth;
if (e.clientY > innerHeight-this.scrollJump) {
if (e.clientY + topScroll < this.pageHeight - (this.scrollJump + 40)) {

View file

@ -10,6 +10,7 @@ var dragableList=new Array();
//browser check
var dom=document.getElementById&&!document.all
var docElement = document.documentElement;
var pageURL = "";
var dragging=false;
var z,x,y
@ -74,36 +75,36 @@ function dragable_adjustScrollBars(e) {
scrY=0;
scrX=0;
if (e.clientY > document.body.clientHeight-scrollJump) {
if (e.clientY + document.body.scrollTop < pageHeight - (scrollJump + 60)) {
if (e.clientY > docElement.clientHeight-scrollJump) {
if (e.clientY + docElement.scrollTop < pageHeight - (scrollJump + 60)) {
scrY=scrollJump;
window.scroll(document.body.scrollLeft,document.body.scrollTop + scrY);
window.scroll(docElement.scrollLeft,docElement.scrollTop + scrY);
y-=scrY;
}
}else if (e.clientY < scrollJump) {
if (document.body.scrollTop < scrollJump) {
scrY = document.body.scrollTop;
if (docElement.scrollTop < scrollJump) {
scrY = docElement.scrollTop;
}else {
scrY=scrollJump;
}
window.scroll(document.body.scrollLeft,document.body.scrollTop - scrY);
window.scroll(docElement.scrollLeft,docElement.scrollTop - scrY);
y+=scrY;
}
if (e.clientX > document.body.clientWidth-scrollJump) {
if (e.clientX + document.body.scrollLeft < pageWidth - (scrollJump + 60)) {
if (e.clientX > docElement.clientWidth-scrollJump) {
if (e.clientX + docElement.scrollLeft < pageWidth - (scrollJump + 60)) {
scrX=scrollJump;
window.scroll(document.body.scrollLeft + scrX,document.body.scrollTop);
window.scroll(docElement.scrollLeft + scrX,docElement.scrollTop);
x-=scrX;
}
}else if (e.clientX < scrollJump) {
if (document.body.scrollLeft < scrollJump) {
scrX = document.body.scrollLeft;
if (docElement.scrollLeft < scrollJump) {
scrX = docElement.scrollLeft;
}else {
scrX=scrollJump;
}
window.scroll(document.body.scrollLeft - scrX,document.body.scrollTop);
window.scroll(docElement.scrollLeft - scrX,docElement.scrollTop);
x+=scrX;
}
}
@ -111,6 +112,13 @@ function dragable_adjustScrollBars(e) {
//initialization routine, must be called on load. Sets up event handlers
function dragable_init(url) {
docElement = document.documentElement;
if (document.compatMode == "BackCompat") {
docElement = document.body;
}
pageURL = url;
//window.scroll(10,500);
//set up event handlers
@ -149,7 +157,7 @@ function dragable_move(e){
if (dragging){
if (accuracyCount==accuracy) {
tmp = dragable_spy(dom? e.pageX: (e.clientX + document.body.scrollLeft),dom? e.pageY: (e.clientY + document.body.scrollTop));
tmp = dragable_spy(dom? e.pageX: (e.clientX + docElement.scrollLeft),dom? e.pageY: (e.clientY + docElement.scrollTop));
if (tmp.length != 0) {
dragable_dragOver(tmp[0],tmp[1]);
}else {
@ -178,7 +186,7 @@ function dragable_move(e){
return false
}else {
tmp = dragable_spy(dom? e.pageX: (e.clientX + document.body.scrollLeft),dom? e.pageY: (e.clientY + document.body.scrollTop));
tmp = dragable_spy(dom? e.pageX: (e.clientX + docElement.scrollLeft),dom? e.pageY: (e.clientY + docElement.scrollTop));
if (tmp.length == 0) {
currentDiv = null;
@ -207,8 +215,8 @@ function dragable_dragStart(e){
fObj.className="dragging";
//set the page height and width in a var since IE changes them when scrolling
pageHeight = window.document.body.scrollHeight;
pageWidth = window.document.body.scrollWidth;
pageHeight = docElement.scrollHeight;
pageWidth = docElement.scrollWidth;
dragging=true
z=fObj;