added collateral migration and some other bug fixes
This commit is contained in:
parent
b6f9315976
commit
4f8489300f
12 changed files with 321 additions and 329 deletions
|
|
@ -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;
|
||||
|
||||
|
||||
|
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package WebGUI::Macro::Backslash_pageUrl;
|
||||
package WebGUI::Macro::PageUrl;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2004 Plain Black Corporation.
|
||||
|
|
@ -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.";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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;
|
||||
|
||||
|
||||
|
|
@ -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;
|
||||
|
||||
|
||||
|
|
@ -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;
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue