removing a bunch of grap we no longer need

This commit is contained in:
JT Smith 2004-12-30 03:17:12 +00:00
parent 4f8489300f
commit 9e31680f41
28 changed files with 52 additions and 8280 deletions

View file

@ -29,7 +29,6 @@ use WebGUI::Id;
use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Node;
use WebGUI::Page;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::Style;
@ -39,7 +38,7 @@ use WebGUI::Template;
use WebGUI::URL;
use WebGUI::Utility;
use WebGUI::MetaData;
use WebGUI::Wobject::WobjectProxy;
#use WebGUI::Asset::Wobject::WobjectProxy;
our @ISA = qw(WebGUI::Asset);

View file

@ -27,8 +27,6 @@ use WebGUI::HTTP;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Node;
use WebGUI::Page;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::TabForm;

View file

@ -1,292 +0,0 @@
package WebGUI::Collateral;
=head1 LEGAL
-------------------------------------------------------------------
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
-------------------------------------------------------------------
=cut
use WebGUI::Attachment;
use WebGUI::DateTime;
use WebGUI::Id;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Utility;
our @ISA = qw(WebGUI::Attachment);
=head1 NAME
Package WebGUI::Collateral
=head1 DESCRIPTION
Package to manipulate items in WebGUI's collateral manager.
=head1 SYNOPSIS
use WebGUI::Collateral;
$collateral = WebGUI::Collateral->new(1234);
$collateral = WebGUI::Collateral->find("My Snippet");
$collateral->delete;
$collateral->deleteFile;
$collateral->get("parameters");
$collateral->set(\%hash);
=head1 SEE ALSO
This package is derived from WebGUI::Attachment. See that package for documentation of its methods.
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
# extended only to save info to database
sub createThumbnail {
$_[0]->SUPER::createThumbnail($_[1]);
if ($_[1] != $_[0]->get("thumbnailSize")) {
$_[0]->set({thumbnailSize=>$_[1]});
}
}
#-------------------------------------------------------------------
=head2 delete ( )
Delete's this collateral item.
=cut
sub delete {
if ($_[0]->{_properties}->{collateralId}) { # blocks deletion of all collateral in the event that no valid collateral id exists
$_[0]->deleteNode;
WebGUI::SQL->write("delete from collateral where collateralId=".quote($_[0]->get("collateralId")));
}
}
#-------------------------------------------------------------------
=head2 deleteFile ( )
Deletes the file attached to this collateral item.
=cut
sub deleteFile {
$_[0]->SUPER::delete;
WebGUI::SQL->write("update collateral set filename='' where collateralId=".quote($_[0]->get("collateralId")));
$_[0]->{_properties}{filename}='';
}
#-------------------------------------------------------------------
=head2 find ( name )
An alternative to the constructor "new", use find as a constructor by name rather than id.
=head3 name
The name of the collateral item you wish to instanciate.
=cut
sub find {
my ($collateralId) = WebGUI::SQL->quickArray("select collateralId from collateral where name=".quote($_[1]));
return WebGUI::Collateral->new($collateralId);
}
#-------------------------------------------------------------------
=head2 get ( [ propertyName ] )
Returns a hash reference containing all of the properties of this collateral item.
=head3 propertyName
If an individual propertyName is specified, then only that property value is returned as a scalar.
=cut
sub get {
if ($_[1] ne "") {
return $_[0]->{_properties}{$_[1]};
} else {
return $_[0]->{_properties};
}
}
#-------------------------------------------------------------------
=head2 new ( collateralId )
Constructor.
=head3 collateralId
The unique identifier for this piece of collateral. If set to "new" an id will be generated.
=cut
sub new {
my ($class, $collateralId) = @_;
my $properties;
if ($collateralId eq "new") {
$properties = {
collateralId=>WebGUI::Id::generate(),
collateralFolderId=>0,
collateralType=>"image",
userId=>$session{user}{userId},
dateUploaded=>time(),
thumbnailSize=>$session{setting}{thumbnailSize},
name=>"untitled",
username=>$session{user}{username}
};
WebGUI::SQL->write("insert into collateral (collateralId, collateralFolderId, collateraltype, userId,
dateUploaded, thumbnailSize, name, username) values ( ".quote($properties->{collateralId}).",
".quote($properties->{collateralFolderId}).", ".quote($properties->{collateralType}).",
".quote($properties->{userId}).", ".$properties->{dateUploaded}.", ".$properties->{thumbnailSize}.",
".quote($properties->{name}).", ".quote($properties->{username}).")");
} else {
$properties = WebGUI::SQL->quickHashRef("select * from collateral where collateralId=".quote($collateralId));
}
return $class->_new($properties);
}
#-------------------------------------------------------------------
# Reuse this code for multiNew
sub _new {
my ($class,$properties) = @_;
return undef unless $properties;
my $self = WebGUI::Attachment->new($properties->{filename},"images",$properties->{collateralId});
$self->{_properties} = $properties;
bless $self, $class;
}
#-------------------------------------------------------------------
=head2 multiDelete ( @collateraIds )
Deletes the nodes and database entries for a list of collateral items.
=cut
sub multiDelete {
my ($class,@ids) = @_;
return undef unless @ids;
my @collateral = $class->multiNew(@ids);
foreach my $obj (@collateral) {
$obj->deleteNode();
}
my $clause = "collateralId in (".quoteAndJoin(\@ids).")";
WebGUI::SQL->write("delete from collateral where $clause");
}
#-------------------------------------------------------------------
=head2 multiNew ( @collateralIds )
Returns a list of WebGUI::Collateral objects.
=cut
sub multiNew {
my ($class,@collateralIds) = @_;
return () unless @collateralIds;
my (@objs);
my $clause = "collateralId in (".quoteAndJoin(\@collateralIds).")";
my $sth = WebGUI::SQL->read("select * from collateral where $clause");
while (my $hash = $sth->hashRef()) {
push @objs,$class->_new($hash);
}
return @objs;
}
#-------------------------------------------------------------------
=head2 set ( properties )
Sets the value of a property for this collateral item.
=head3 properties
A hash reference containing the list of properties to set. The valid property names are "name", "parameters", "userId", "username", "collateralFolderId", "collateralType", and "thumbnailSize".
If username or userId are not specified, the current user will be used.
=cut
sub set {
my ($key, $sql, @update, $i);
my $self = shift;
my $properties = shift;
$self->{_properties}->{dateUploaded} = time();
$properties->{userId} = $session{user}{userId} if ($properties->{userId} eq "");
$properties->{username} = $session{user}{username} if ($properties->{username} eq "");
$properties->{thumbnailSize} = $session{setting}{thumbnailSize} if ($properties->{thumbnailSize} eq "");
$sql = "update collateral set";
foreach $key (keys %{$properties}) {
$self->{_property}{$key} = $properties->{$key};
if (isIn($key, qw(name parameters userId username collateralFolderId collateralType thumbnailSize))) {
$sql .= " ".$key."=".quote($properties->{$key}).",";
}
}
$sql .= " dateUploaded=".$self->{_properties}{dateUploaded}."
where collateralid=".quote($self->get("collateralId"));
WebGUI::SQL->write($sql);
}
#-------------------------------------------------------------------
# extended only to save info to database
sub save {
my $filename = $_[0]->SUPER::save($_[1],$_[2],$_[3]);
if ($filename) {
WebGUI::SQL->write("update collateral set filename=".quote($filename)
." where collateralId=".quote($_[0]->get("collateralId")));
$_[0]->{_properties}{filename} = $filename;
}
return $filename;
}
#-------------------------------------------------------------------
# extended only to save info to database
sub saveFromFilesystem {
my $filename = $_[0]->SUPER::saveFromFilesystem($_[1],$_[2],$_[3]);
if ($filename) {
WebGUI::SQL->write("update collateral set filename=".quote($filename)
." where collateralId=".quote($_[0]->get("collateralId")));
$_[0]->{_properties}{filename} = $filename;
}
return $filename;
}
1;

View file

@ -1,82 +0,0 @@
package WebGUI::CollateralFolder;
=head1 LEGAL
-------------------------------------------------------------------
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
-------------------------------------------------------------------
=cut
use strict;
use warnings;
use WebGUI::Collateral;
use WebGUI::Persistent::Tree;
use WebGUI::SQL;
our @ISA = qw(WebGUI::Persistent::Tree);
=head1 NAME
Package WebGUI::CollateralFolder
=head1 DESCRIPTION
This is a management package for the collateral folder system.
=head2 SYNOPSIS
use WebGUI::CollateralFolder;
$collateralFolder->recursiveDelete;
=head1 METHODS
For inherited methods see L<WebGUI::Persistent::Tree>.
=cut
#-------------------------------------------------------------------
sub classSettings {
return {
properties => {
name => { quote => 1 },
parentId => { quote => 1 },
collateralFolderId => { key => 1 },
description => { quote => 1 }
},
table => 'collateralFolder'
}
}
#-------------------------------------------------------------------
=head2 recursiveDelete ()
Recursively delete a folder, sub folders and contents
=cut
sub recursiveDelete {
my ($self) = @_;
my @ids = $self->SUPER::recursiveDelete();
return unless @ids;
# If WebGUI::Collateral inherited from WebGUI::Persistent then we would only
# need the following line:
# WebGUI::Collateral->multiDelete(collateralFolderId => \@ids);
my @collateralIds = WebGUI::SQL->buildArray("select collateralId from collateral where collateralFolderId in (".quoteAndJoin(\@ids).")");
WebGUI::Collateral->multiDelete(@collateralIds);
}
1;

View file

@ -1,16 +1,6 @@
package WebGUI::Help::WebGUI;
our $HELP = {
'image add/edit' => {
title => '670',
body => '625',
related => [
{
tag => 'collateral manage',
namespace => 'WebGUI'
}
]
},
'packages creating' => {
title => '681',
body => '636',
@ -395,10 +385,6 @@ our $HELP = {
title => '669',
body => '624',
related => [
{
tag => 'collateral macros',
namespace => 'WebGUI'
},
{
tag => 'navigation macros',
namespace => 'WebGUI'
@ -467,36 +453,6 @@ our $HELP = {
}
]
},
'collateral manage' => {
title => '785',
body => '786',
related => [
{
tag => 'collateral macros',
namespace => 'WebGUI'
},
{
tag => 'file add/edit',
namespace => 'WebGUI'
},
{
tag => 'folder add/edit',
namespace => 'WebGUI'
},
{
tag => 'image add/edit',
namespace => 'WebGUI'
},
{
tag => 'themes manage',
namespace => 'WebGUI'
},
{
tag => 'snippet add/edit',
namespace => 'WebGUI'
}
]
},
'template language' => {
title => '825',
body => '826',
@ -583,50 +539,6 @@ our $HELP = {
}
]
},
'collateral macros' => {
title => '831',
body => '832',
related => [
{
tag => 'collateral manage',
namespace => 'WebGUI'
},
{
tag => 'macros using',
namespace => 'WebGUI'
}
]
},
'file add/edit' => {
title => '833',
body => '834',
related => [
{
tag => 'collateral manage',
namespace => 'WebGUI'
}
]
},
'snippet add/edit' => {
title => '835',
body => '836',
related => [
{
tag => 'collateral manage',
namespace => 'WebGUI'
}
]
},
'folder add/edit' => {
title => '837',
body => '838',
related => [
{
tag => 'collateral manage',
namespace => 'WebGUI'
}
]
},
'programmer macros' => {
title => '839',
body => '840',
@ -689,10 +601,6 @@ our $HELP = {
title => '931',
body => '932',
related => [
{
tag => 'collateral manage',
namespace => 'WebGUI'
},
{
tag => 'templates manage',
namespace => 'WebGUI'

View file

@ -12,13 +12,12 @@ package WebGUI::Macro::CanEditText;
use strict;
use WebGUI::Macro;
use WebGUI::Page;
use WebGUI::Session;
#-------------------------------------------------------------------
sub process {
my @param = WebGUI::Macro::getParams($_[0]);
if (WebGUI::Page::canEdit()) {
if (exists $session{asset} && $session{asset}->canEdit) {
return $param[0];
} else {
return "";

View file

@ -14,14 +14,13 @@ use strict;
use WebGUI::Grouping;
use WebGUI::International;
use WebGUI::Macro;
use WebGUI::Page;
use WebGUI::Session;
use WebGUI::Template;
use WebGUI::URL;
#-------------------------------------------------------------------
sub process {
if (WebGUI::Page::canEdit() && WebGUI::Grouping::isInGroup(12)) {
if (exists $session{asset} && $session{asset}->canEdit && WebGUI::Grouping::isInGroup(12)) {
my %var;
my @param = WebGUI::Macro::getParams($_[0]);
my $turnOn = $param[0] || WebGUI::International::get(516);

View file

@ -11,14 +11,20 @@ package WebGUI::Macro::RootTitle;
#-------------------------------------------------------------------
use strict;
use Tie::CPHash;
use WebGUI::Page;
use WebGUI::Asset;
use WebGUI::Session;
#-------------------------------------------------------------------
sub process {
my $root = WebGUI::Page->getWebGUIRoot;
return $root->get("title");
if (exists $session{asset}) {
my $lineage = $session{asset}->get("lineage");
$lineage = substr($lineage,0,6);
my $root = WebGUI::Asset->newByLineage($lineage);
if (defined $root) {
return $root->get("title");
}
}
return "";
}

View file

@ -94,23 +94,6 @@ sub getOperations {
'emptyClipboard' => 'WebGUI::Operation::Clipboard',
'emptyClipboardConfirm' => 'WebGUI::Operation::Clipboard',
'manageClipboard' => 'WebGUI::Operation::Clipboard',
'editCollateral' => 'WebGUI::Operation::Collateral',
'editCollateralSave' => 'WebGUI::Operation::Collateral',
'deleteCollateral' => 'WebGUI::Operation::Collateral',
'deleteCollateralConfirm' => 'WebGUI::Operation::Collateral',
'listCollateral' => 'WebGUI::Operation::Collateral',
'deleteCollateralFile' => 'WebGUI::Operation::Collateral',
'editCollateralFolder' => 'WebGUI::Operation::Collateral',
'editCollateralFolderSave' => 'WebGUI::Operation::Collateral',
'deleteCollateralFolder' => 'WebGUI::Operation::Collateral',
'deleteCollateralFolderConfirm' => 'WebGUI::Operation::Collateral',
'emptyCollateralFolder' => 'WebGUI::Operation::Collateral',
'emptyCollateralFolderConfirm' => 'WebGUI::Operation::Collateral',
'htmlArealistCollateral' => 'WebGUI::Operation::Collateral',
'htmlAreaviewCollateral' => 'WebGUI::Operation::Collateral',
'htmlAreaUpload' => 'WebGUI::Operation::Collateral',
'htmlAreaDelete' => 'WebGUI::Operation::Collateral',
'htmlAreaCreateFolder' => 'WebGUI::Operation::Collateral',
'copyDatabaseLink' => 'WebGUI::Operation::DatabaseLink',
'deleteDatabaseLink' => 'WebGUI::Operation::DatabaseLink',
'deleteDatabaseLinkConfirm' => 'WebGUI::Operation::DatabaseLink',
@ -147,22 +130,6 @@ sub getOperations {
'saveMetaDataSettings' => 'WebGUI::Operation::MetaData',
'deployPackage' => 'WebGUI::Operation::Package',
'managePackages' => 'WebGUI::Operation::Package',
'viewPageTree' => 'WebGUI::Operation::Page',
'movePageUp' => 'WebGUI::Operation::Page',
'movePageDown' => 'WebGUI::Operation::Page',
'cutPage' => 'WebGUI::Operation::Page',
'deletePageConfirm' => 'WebGUI::Operation::Page',
'editPage' => 'WebGUI::Operation::Page',
'editPageSave' => 'WebGUI::Operation::Page',
'exportPage' => 'WebGUI::Operation::Page',
'exportPageStatus' => 'WebGUI::Operation::Page',
'pastePage' => 'WebGUI::Operation::Page',
'moveTreePageUp' => 'WebGUI::Operation::Page',
'rearrangeWobjects' => 'WebGUI::Operation::Page',
'moveTreePageDown' => 'WebGUI::Operation::Page',
'moveTreePageLeft' => 'WebGUI::Operation::Page',
'moveTreePageRight' => 'WebGUI::Operation::Page',
'richEditPageTree' => 'WebGUI::Operation::Page',
'editProfile' => 'WebGUI::Operation::Profile',
'editProfileSave' => 'WebGUI::Operation::Profile',
'viewProfile' => 'WebGUI::Operation::Profile',

View file

@ -1,665 +0,0 @@
package WebGUI::Operation::Collateral;
#-------------------------------------------------------------------
# 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
#-------------------------------------------------------------------
# test for ImageMagick. if it's not installed set $hasImageMagick to 0,
# if it is installed it will be set to 1
my $hasImageMagick=1;
eval " use Image::Magick; "; $hasImageMagick=0 if $@;
use strict;
use WebGUI::Collateral;
use WebGUI::CollateralFolder;
use WebGUI::DateTime;
use WebGUI::Grouping;
use WebGUI::HTMLForm;
use WebGUI::Icon;
use WebGUI::Id;
use WebGUI::International;
use WebGUI::Operation::Shared;
use WebGUI::Paginator;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use Tie::IxHash;
use WebGUI::URL;
use WebGUI::HTML;
#-------------------------------------------------------------------
sub _submenu {
my (%menu);
tie %menu, 'Tie::IxHash';
$menu{WebGUI::URL::page('op=editCollateralFolder&fid=new')} = WebGUI::International::get(758);
$menu{WebGUI::URL::page('op=editCollateral&cid=new&type=image')} = WebGUI::International::get(761);
$menu{WebGUI::URL::page('op=editCollateral&cid=new&type=file')} = WebGUI::International::get(762);
$menu{WebGUI::URL::page('op=editCollateral&cid=new&type=snippet')} = WebGUI::International::get(763);
if ($session{form}{op} eq "editCollateral" || $session{form}{op} eq "deleteCollateral") {
$menu{WebGUI::URL::page('op=editCollateral&cid='.$session{form}{cid})} = WebGUI::International::get(764);
$menu{WebGUI::URL::page('op=deleteCollateral&cid='.$session{form}{cid})} = WebGUI::International::get(765);
}
$menu{WebGUI::URL::page('op=editCollateralFolder')} = WebGUI::International::get(759);
if (WebGUI::Grouping::isInGroup(3)) {
$menu{WebGUI::URL::page('op=emptyCollateralFolder')} = WebGUI::International::get(980);
# $menu{WebGUI::URL::page('op=deleteCollateralFolder')} = WebGUI::International::get(760);
}
$menu{WebGUI::URL::page('op=listCollateral')} = WebGUI::International::get(766);
return menuWrapper($_[0],\%menu);
}
#-------------------------------------------------------------------
sub www_deleteCollateral {
my $collateral = WebGUI::Collateral->new($session{form}{cid});
return WebGUI::Privilege::insufficient unless ($collateral->get("userId") == $session{user}{userId} || WebGUI::Grouping::isInGroup(3));
my $output = '<h1>'.WebGUI::International::get(42).'</h1>';
$output .= WebGUI::International::get(774).'<p/><div align="center">';
$output .= '<a href="'.WebGUI::URL::page('op=deleteCollateralConfirm&cid='.$session{form}{cid}).'">'
.WebGUI::International::get(44).'</a>';
$output .= '&nbsp;&nbsp;&nbsp;&nbsp;';
$output .= '<a href="'.WebGUI::URL::page('op=listCollateral').'">'.WebGUI::International::get(45).'</a>';
$output .= '</div>';
return _submenu($output);
}
#-------------------------------------------------------------------
sub www_deleteCollateralConfirm {
my $collateral = WebGUI::Collateral->new($session{form}{cid});
return WebGUI::Privilege::insufficient unless ($collateral->get("userId") == $session{user}{userId} || WebGUI::Grouping::isInGroup(3));
$collateral->delete;
WebGUI::Session::deleteScratch("collateralPageNumber");
return www_listCollateral();
}
#-------------------------------------------------------------------
sub www_deleteCollateralFile {
my $collateral = WebGUI::Collateral->new($session{form}{cid});
return WebGUI::Privilege::insufficient unless ($collateral->get("userId") == $session{user}{userId} || WebGUI::Grouping::isInGroup(3));
$collateral->deleteFile;
return www_editCollateral($collateral);
}
#-------------------------------------------------------------------
sub www_deleteCollateralFolder {
return WebGUI::Privilege::insufficient unless (WebGUI::Grouping::isInGroup(3));
return WebGUI::Privilege::vitalComponent() if ($session{scratch}{collateralFolderId} eq "0" || $session{scratch}{collateralFolderId} eq "");
my $output = '<h1>'.WebGUI::International::get(42).'</h1>';
$output .= WebGUI::International::get(775).'<p/><div align="center">';
$output .= '<a href="'.WebGUI::URL::page('op=deleteCollateralFolderConfirm').'">'
.WebGUI::International::get(44).'</a>';
$output .= '&nbsp;&nbsp;&nbsp;&nbsp;';
$output .= '<a href="'.WebGUI::URL::page('op=listCollateral').'">'.WebGUI::International::get(45).'</a>';
$output .= '</div>';
return _submenu($output);
}
#-------------------------------------------------------------------
sub www_deleteCollateralFolderConfirm {
return WebGUI::Privilege::insufficient unless (WebGUI::Grouping::isInGroup(3));
return WebGUI::Privilege::vitalComponent() if ($session{scratch}{collateralFolderId} eq "0" || $session{scratch}{collateralFolderId} eq "");
my $folders = WebGUI::CollateralFolder->getTree({-minimumFields => 1});
if (my $deadFolder = $folders->{$session{scratch}{collateralFolderId}}) {
my $parentId = $deadFolder->get("parentId");
$deadFolder->recursiveDelete();
WebGUI::Session::setScratch("collateralFolderId",$parentId);
}
return www_listCollateral();
}
#-------------------------------------------------------------------
sub www_emptyCollateralFolder {
return WebGUI::Privilege::insufficient unless (WebGUI::Grouping::isInGroup(3));
my $output = '<h1>'.WebGUI::International::get(42).'</h1>';
$output .= WebGUI::International::get(979).'<p/><div align="center">';
$output .= '<a href="'.WebGUI::URL::page('op=emptyCollateralFolderConfirm').'">'
.WebGUI::International::get(44).'</a>';
$output .= '&nbsp;&nbsp;&nbsp;&nbsp;';
$output .= '<a href="'.WebGUI::URL::page('op=listCollateral').'">'.WebGUI::International::get(45).'</a>';
$output .= '</div>';
return _submenu($output);
}
#-------------------------------------------------------------------
sub www_emptyCollateralFolderConfirm {
return WebGUI::Privilege::insufficient unless (WebGUI::Grouping::isInGroup(3));
my @collateralIds = WebGUI::SQL->buildArray("select collateralId from collateral where collateralFolderId=".quote($session{scratch}{collateralFolderId}));
WebGUI::Collateral->multiDelete(@collateralIds);
return www_listCollateral();
}
#-------------------------------------------------------------------
sub www_editCollateral {
return WebGUI::Privilege::insufficient unless (WebGUI::Grouping::isInGroup(4));
my ($canEdit, $file, $folderId, $output, $f, $collateral, $image, $error, $x, $y);
if ($session{form}{cid} eq "new") {
$collateral->{collateralType} = $session{form}{type};
$collateral->{collateralId} = "new";
$collateral->{username} = $session{user}{username};
$collateral->{userId} = $session{user}{userId};
$collateral->{parameters} = 'border="0"' if ($session{form}{type} eq "image");
$collateral->{thumbnailSize} = $session{setting}{thumbnailSize};
} else {
my $c = $_[1] || WebGUI::Collateral->new($session{form}{cid});
$collateral = $c->get;
}
$canEdit = ($collateral->{userId} == $session{user}{userId} || WebGUI::Grouping::isInGroup(3));
$folderId = $session{scratch}{collateralFolderId} || 0;
$f = WebGUI::HTMLForm->new;
$f->hidden("op","editCollateralSave");
$f->hidden("collateralType",$collateral->{collateralType});
$f->hidden("cid",$collateral->{collateralId});
$f->hidden("userId", $collateral->{userId});
$f->hidden("userName", $collateral->{userName});
$f->readOnly(
-label=>WebGUI::International::get(767),
-value=>$collateral->{collateralId}
);
$f->readOnly(
-label=>WebGUI::International::get(388),
-value=>epochToHuman($collateral->{dateUploaded},"%z")
);
$f->readOnly(
-label=>WebGUI::International::get(387),
-value=>$collateral->{username}
);
if ($canEdit) {
$f->text(
-name=>"name",
-value=>$collateral->{name},
-label=>WebGUI::International::get(768)
);
$f->selectList(
-name=>"collateralFolderId",
-value=>[$folderId],
-label=>WebGUI::International::get(769),
-options=>WebGUI::SQL->buildHashRef("select collateralFolderId,name from collateralFolder order by name")
);
} else {
$f->readOnly(
-label=>WebGUI::International::get(768),
-value=>$collateral->{name}
);
}
if ($collateral->{collateralType} eq "snippet") {
$output .= '<h1>'.WebGUI::International::get(770).'</h1>';
if ($canEdit) {
$f->textarea(
-name=>"parameters",
-value=>$collateral->{parameters},
-label=>WebGUI::International::get(771)
);
} else {
$f->readOnly(
-value=>$collateral->{parameters},
-label=>WebGUI::International::get(771)
);
}
} elsif ($collateral->{collateralType} eq "file") {
$output .= '<h1>'.WebGUI::International::get(772).'</h1>';
if ($canEdit) {
if ($collateral->{filename} ne "") {
$f->readOnly(
-value=>'<a href="'.WebGUI::URL::page('op=deleteCollateralFile&cid='
.$collateral->{collateralId}).'">'.WebGUI::International::get(391).'</a>',
-label=>WebGUI::International::get(773)
);
} else {
$f->file(
-name=>"filename",
-label=>WebGUI::International::get(773)
);
}
}
$file = WebGUI::Attachment->new($collateral->{filename},"images",$collateral->{collateralId});
if ($file->getFilename ne "") {
$f->readOnly(
-value=>'<a href="'.$file->getURL.'"><img src="'.$file->getIcon.'" border="0" align="middle" /> '
.$file->getFilename.'</a>'
);
}
} else {
$output .= helpIcon("image add/edit");
$output .= '<h1>'.WebGUI::International::get(382).'</h1>';
if ($canEdit) {
if ($collateral->{filename} ne "") {
$f->readOnly(
-value=>'<a href="'.WebGUI::URL::page('op=deleteCollateralFile&cid='
.$collateral->{collateralId}).'">'.WebGUI::International::get(391).'</a>',
-label=>WebGUI::International::get(384)
);
} else {
$f->file(
-name=>"filename",
-label=>WebGUI::International::get(384)
);
}
}
$file = WebGUI::Attachment->new($collateral->{filename},"images",$collateral->{collateralId});
if ($file->getFilename ne "") {
$f->readOnly(
-value=>'<a href="'.$file->getURL.'"><img src="'.$file->getThumbnail.'" border="0" /></a>'
);
if ($hasImageMagick) {
$image = Image::Magick->new;
$error = $image->Read($file->getPath);
($x, $y) = $image->Get('width','height');
$f->readOnly(
-value=>$error ? "Error reading image: $error" : "$x x $y",
-label=>"Image dimensions"
);
}
}
if ($canEdit) {
$f->textarea(
-name=>"parameters",
-value=>$collateral->{parameters},
-label=>WebGUI::International::get(385)
);
} else {
$f->readOnly(
-label=>WebGUI::International::get(385),
-value=>$collateral->{parameters}
);
}
if ($canEdit && $collateral->{collateralType} eq 'image') {
$f->text(
-name=>"thumbnailSize",
-value=>$collateral->{thumbnailSize},
-label=>"Thumbnail size"
);
}
}
$f->submit if ($canEdit);
$output .= $f->print;
return _submenu($output);
}
#-------------------------------------------------------------------
sub www_editCollateralSave {
return WebGUI::Privilege::insufficient unless (WebGUI::Grouping::isInGroup(4));
WebGUI::Session::setScratch("collateralFolderId",$session{form}{collateralFolderId});
my ($test, $file, $addFile);
my $collateral = WebGUI::Collateral->new($session{form}{cid});
$session{form}{thumbnailSize} ||= $session{setting}{thumbnailSize};
if ($session{form}{cid} eq "new") {
$session{form}{cid} = $collateral->get("collateralId");
} elsif ($collateral->get("thumbnailSize") != $session{form}{thumbnailSize}) {
$collateral->createThumbnail($session{form}{thumbnailSize});
}
$collateral->save("filename", $session{form}{thumbnailSize});
$session{form}{name} = "untitled" if ($session{form}{name} eq "");
while (($test) = WebGUI::SQL->quickArray("select name from collateral
where name=".quote($session{form}{name})." and collateralId<>".quote($collateral->get("collateralId")))) {
if ($session{form}{name} =~ /(.*)(\d+$)/) {
$session{form}{name} = $1.($2+1);
} elsif ($test ne "") {
$session{form}{name} .= "2";
}
}
$collateral->set($session{form});
$session{form}{collateralType} = "";
return www_listCollateral();
}
#-------------------------------------------------------------------
sub www_editCollateralFolder {
return WebGUI::Privilege::insufficient unless (WebGUI::Grouping::isInGroup(4));
my ($output, $f, $folder, $folderId, $constraint);
$output .= '<h1>'.WebGUI::International::get(776).'</h1>';
if ($session{form}{fid} eq "new") {
$folder->{collateralFolderId} = "new";
$folder->{parentId} = $session{scratch}{collateralFolderId} || 0;
} else {
$folderId = $session{scratch}{collateralFolderId} || 0;
$folder = WebGUI::SQL->quickHashRef("select * from collateralFolder where collateralFolderId=".quote($folderId));
$constraint = "where collateralFolderId<>".quote($folder->{collateralFolderId});
}
$f = WebGUI::HTMLForm->new;
$f->hidden("op","editCollateralFolderSave");
$f->hidden("fid",$session{form}{fid});
$f->readOnly(
-value=>$folder->{collateralFolderId},
-label=>WebGUI::International::get(777)
);
if ($folder->{collateralFolderId} eq "0") {
$f->hidden("parentId",0);
} else {
$f->selectList(
-name=>"parentId",
-value=>[$folder->{parentId}],
-label=>WebGUI::International::get(769),
-options=>WebGUI::SQL->buildHashRef("select collateralFolderId,name from collateralFolder
$constraint order by name")
);
}
$f->text(
-value=>$folder->{name},
-name=>"name",
-label=>WebGUI::International::get(768)
);
$f->textarea(
-value=>$folder->{description},
-name=>"description",
-label=>WebGUI::International::get(778)
);
$f->submit;
$output .= $f->print;
return _submenu($output);
}
#-------------------------------------------------------------------
sub www_editCollateralFolderSave {
return WebGUI::Privilege::insufficient unless (WebGUI::Grouping::isInGroup(4));
if ($session{form}{fid} eq "new") {
$session{form}{fid} = WebGUI::Id::generate();
WebGUI::Session::setScratch("collateralFolderId",$session{form}{fid});
WebGUI::SQL->write("insert into collateralFolder (collateralFolderId) values (".quote($session{form}{fid}).")");
}
my $folderId = $session{scratch}{collateralFolderId} || 0;
$session{form}{name} = "untitled" if ($session{form}{name} eq "");
while (my ($test) = WebGUI::SQL->quickArray("select name from collateralFolder
where name=".quote($session{form}{name})." and collateralFolderId<>".quote($folderId))) {
if ($session{form}{name} =~ /(.*)(\d+$)/) {
$session{form}{name} = $1.($2+1);
} elsif ($test ne "") {
$session{form}{name} .= "2";
}
}
WebGUI::SQL->write("update collateralFolder set parentId=".quote($session{form}{parentId}).", name=".quote($session{form}{name})
.", description=".quote($session{form}{description})
." where collateralFolderId=".quote($folderId));
return www_listCollateral();
}
#-------------------------------------------------------------------
sub www_listCollateral {
return WebGUI::Privilege::insufficient unless (WebGUI::Grouping::isInGroup(4));
my (%type, %user, $f, $row, $data, $sth, $url, $output, $parent, $p, $thumbnail, $file, $page, $constraints, $folderId);
tie %type, 'Tie::IxHash';
tie %user, 'Tie::IxHash';
%type = (
'-delete-'=>WebGUI::International::get(782),
image=>WebGUI::International::get(779),
file=>WebGUI::International::get(780),
snippet=>WebGUI::International::get(781)
);
%user = (
'-delete-'=>WebGUI::International::get(782),
%{WebGUI::SQL->buildHashRef("select distinct(userId), username from collateral order by username")}
);
WebGUI::Session::setScratch("keyword",$session{form}{keyword});
WebGUI::Session::setScratch("collateralUser",$session{form}{collateralUser});
WebGUI::Session::setScratch("collateralType",$session{form}{collateralType});
WebGUI::Session::setScratch("collateralPageNumber",$session{form}{pn});
WebGUI::Session::setScratch("collateralFolderId",$session{form}{fid});
$folderId = $session{scratch}{collateralFolderId} || 0;
$constraints = "collateralFolderId=".quote($folderId);
$constraints .= " and userId=".quote($session{scratch}{collateralUser}) if ($session{scratch}{collateralUser});
$constraints .= " and collateralType=".quote($session{scratch}{collateralType}) if ($session{scratch}{collateralType});
$constraints .= " and name like ".quote('%'.$session{scratch}{keyword}.'%') if ($session{scratch}{keyword});
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=listCollateral'),"",$session{scratch}{collateralPageNumber});
$p->setDataByQuery("select collateralId, name, filename, collateralType, dateUploaded, username, parameters
from collateral where $constraints order by name");
$page = $p->getPageData;
$output = helpIcon("collateral manage");
$output .= '<h1>'.WebGUI::International::get(757).'</h1>';
$f = WebGUI::HTMLForm->new(1);
$f->hidden("op","listCollateral");
$f->hidden("pn",1);
$f->text(
-name=>"keyword",
-value=>$session{scratch}{keyword},
-size=>15
);
$f->selectList(
-name=>"collateralUser",
-value=>[$session{scratch}{collateralUser}],
-options=>\%user
);
$f->selectList(
-name=>"collateralType",
-value=>[$session{scratch}{collateralType}],
-options=>\%type
);
$f->submit(WebGUI::International::get(170));
$output .= '<div align="center">'.$f->print.'</div>';
$output .= '<table align="center" border="1" cellpadding="2" cellspacing="0">';
$output .= '<tr><td class="tableHeader">'.WebGUI::International::get(768).'</td><td class="tableHeader">'
.WebGUI::International::get(783).'</td><td class="tableHeader">'.WebGUI::International::get(387)
.'</td><td class="tableHeader">'.WebGUI::International::get(388).'</td><td class="tableHeader">'
.WebGUI::International::get(784).'</td></tr>';
if ($folderId) {
($parent) = WebGUI::SQL->quickArray("select parentId from collateralFolder where collateralFolderId=".quote($folderId));
$output .= '<tr><td colspan="5" class="tableData"><a href="'.WebGUI::URL::page('op=listCollateral&fid='
.$parent.'&pn=1')
.'"><img src="'.$session{config}{extrasURL}.'/smallAttachment.gif" border="0">'
.'&nbsp;'.WebGUI::International::get(542).'</a></td></tr>';
}
$sth = WebGUI::SQL->read("select collateralFolderId, name, description from collateralFolder
where parentId=".quote($folderId)." order by name");
while ($data = $sth->hashRef) {
$output .= '<tr><td class="tableData"><a href="'.WebGUI::URL::page('op=listCollateral&fid='
.$data->{collateralFolderId}.'&pn=1')
.'"><img src="'.$session{config}{extrasURL}.'/smallAttachment.gif" border="0">'
.'&nbsp;'.$data->{name}.'</a></td><td class="tableData" colspan="4">'.$data->{description}.'</td></tr>';
}
$sth->finish;
foreach $row (@$page) {
$url = WebGUI::URL::page('op=editCollateral&cid='.$row->{collateralId}.'&fid='.$folderId);
$output .= '<tr>';
$output .= '<td class="tableData"><a href="'.$url.'">'.$row->{name}.'</a></td>';
$output .= '<td class="tableData">'.$type{$row->{collateralType}}.'</td>';
$output .= '<td class="tableData">'.$row->{username}.'</td>';
$output .= '<td class="tableData">'.epochToHuman($row->{dateUploaded},"%z").'</td>';
if ($row->{filename} ne "" && $row->{collateralType} eq "image") {
$file = WebGUI::Attachment->new($row->{filename},"images",$row->{collateralId});
$thumbnail = '<a href="'.$url.'"><img src="'.$file->getThumbnail.'" border="0" /></a>';
} elsif ($row->{filename} ne "" && $row->{collateralType} eq "file") {
$file = WebGUI::Attachment->new($row->{filename},"images",$row->{collateralId});
$thumbnail = '<a href="'.$url.'"><img src="'.$file->getIcon.'" border="0" /></a>';
} elsif ($row->{collateralType} eq "snippet") {
$thumbnail = WebGUI::HTML::filter($row->{parameters},'all');
$thumbnail =~ s/(\n[^\n]\r?|\r[^\r]\n?)/\&crarr;/gs;
$thumbnail =~ s/\s{2,}//g;
$thumbnail =~ s/\s*\&crarr;+\s*/\&crarr;/g;
$thumbnail =~ s/^(\&crarr;)+//;
my $crCount = $thumbnail =~ m/\&crarr;/g;
$thumbnail = substr($thumbnail,0,$session{setting}{snippetsPreviewLength}+$crCount*6);
$thumbnail .= '...' if (length($row->{parameters}) > $session{setting}{snippetsPreviewLength});
} else {
$thumbnail = "";
}
$output .= '<td class="tableData">'.$thumbnail.'</td>';
$output .= "</tr>\n";
}
$output .= '</table>';
$output .= $p->getBarTraditional;
return _submenu($output);
}
#-------------------------------------------------------------------
sub _htmlAreaCreateTree {
my ($output);
my ($name, $description, $url, $image, $indent, $target, $delete) = @_;
if($delete) {
$delete = qq/<a href="javascript:deleteCollateral('$delete')" title="delete $name">/;
$delete .= deleteIcon()."</a>";
}
$target = ' target="'.$target.'" ' if ($target);
$output .= '<tr><td align="left" valign="bottom" width="100%">';
$output .= ('<img src="'.$session{config}{extrasURL}.'/tinymce/images/indent.gif" width="17" heigth="17">') x$indent;
$output .= '<img src="'.$session{config}{extrasURL}.'/tinymce/images/'.$image.'" align="bottom" alt="'.$name.'">';
$output .= '<a title="'.$description.'" href="'.$url.'" '.$target.'><b>'.$name.'</b></a></td>';
$output .= '<td class="delete" align="right" valign="bottom">'.$delete.'</td></tr>';
return $output;
}
#-------------------------------------------------------------------
sub www_htmlArealistCollateral {
my (@parents, $sth, $data, $indent);
$session{page}{makePrintable}=1; $session{page}{printableStyleId}=10;
return "<b>Only Content Managers are allowed to use WebGUI Collateral</b>" unless (WebGUI::Grouping::isInGroup(4));
my $output = '<table border="0" cellspacing="0" cellpadding="0" width="100%">';
my $folderId = $session{form}{fid} || 0;
my $parent = $folderId;
# push parent folders in array so it can be reversed
unshift(@parents, $parent);
until($parent eq '0') {
($parent) = WebGUI::SQL->quickArray("select parentId from collateralFolder where collateralFolderId=".quote($parent));
unshift(@parents, $parent);
}
# Build tree for opened parent folders
foreach $parent (@parents) {
my ($name, $description) = WebGUI::SQL->quickArray("select name, description from
collateralFolder where collateralFolderId=".quote($parent));
my ($itemsInFolder) = WebGUI::SQL->quickArray("select count(*) from collateral where collateralFolderId = ".quote($parent));
my ($foldersInFolder)=WebGUI::SQL->quickArray("select count(*) from collateralFolder where parentId=".quote($parent));
my $delete = "fid=$parent" unless ($itemsInFolder + $foldersInFolder);
$output .= _htmlAreaCreateTree($name, $description,
WebGUI::URL::page('op=htmlArealistCollateral&fid='.$parent), "opened.gif",
$indent++,"" ,$delete);
}
# Extend tree with closed folders in current folder
$sth = WebGUI::SQL->read("select collateralFolderId, name, description from collateralFolder
where parentId=".quote($folderId)." and collateralFolderId <> '0' order by name");
while ($data = $sth->hashRef) {
my ($itemsInFolder) = WebGUI::SQL->quickArray("select count(*) from collateral where
collateralFolderId = ".quote($data->{collateralFolderId}));
my $delete = 'fid='.$data->{collateralFolderId} unless $itemsInFolder;
$output .= _htmlAreaCreateTree($data->{name}, $data->{description},
WebGUI::URL::page('op=htmlArealistCollateral&fid='.$data->{collateralFolderId}),
"closed.gif", $indent, "", $delete);
}
# Extend tree with images in current folder
$sth = WebGUI::SQL->read("select collateralId, name, filename from collateral where collateralType = 'image' ".
"and collateralFolderId = ".quote($folderId));
while ($data = $sth->hashRef) {
$data->{filename} =~ /\.([^\.]+)$/; # Get extension
my $fileType = $1.'.gif';
$output .= _htmlAreaCreateTree($data->{filename}, $data->{name},
WebGUI::URL::page('op=htmlAreaviewCollateral&cid='.$data->{collateralId}),
$fileType, $indent, "viewer", 'cid='.$data->{collateralId}.'&fid='.$folderId);
}
$output .= '</table>';
$output .= '<script language="javascript">'."\n".'actionComplete("","'.$folderId.'","","");';
$output .= "\n</script>\n";
$sth->finish;
return $output;
}
#-------------------------------------------------------------------
sub www_htmlAreaviewCollateral {
my($output, $collateral, $file, $x, $y, $image, $error);
$session{page}{makePrintable}=1; $session{page}{printableStyleId}=10;
$output .= '<table align="center" border="0" cellspacing="0" cellpadding="2" width="100%" height="100%">';
if($session{form}{cid} eq "" || ! WebGUI::Grouping::isInGroup(4)) {
$output .= '<tr><td align="center" valign="middle" width="100%" height="100%">';
$output .= '<p align="center"><br><img src="'.$session{config}{extrasURL}.'/tinymce/images/icon.gif"
border="0"></p>';
$output .= '<P align=center><STRONG>WebGUI Image Manager<BR>for TinyMCE</STRONG></P>';
$output .= '</td></tr></table>';
} else {
my $c = WebGUI::Collateral->new($session{form}{cid});
$collateral = $c->get;
$file = WebGUI::Attachment->new($collateral->{filename},"images",$collateral->{collateralId});
$output .= '<tr><td class="label" align="center" valign="middle" width="100%">';
$output .= '<b>'.$file->getFilename.'</b><br>';
if ($hasImageMagick) {
$image = Image::Magick->new;
$error = $image->Read($file->getPath);
($x, $y) = $image->Get('width','height');
$output .= $error ? "Error reading image: $error" : "<i>($x &#215; $y)</i>";
}
$output .= '</td></tr><tr><td align="center" valign="middle" width="100%" height="100%">';
$output .= '<img src="'.$file->getThumbnail.'" border="0">';
$output .= '</td></tr></table>';
$output .= '<script language="javascript">';
$output .= "\nvar src = '".$file->getURL."';\n";
$output .= "if(src.length > 0) {
var manager=window.parent;
if(manager)
manager.document.getElementById('txtFileName').value = src;
}
</script>\n";
}
return $output;
}
#-------------------------------------------------------------------
sub www_htmlAreaUpload {
$session{page}{makePrintable}=1; $session{page}{printableStyleId}=10;
return "<b>Only Content Managers are allowed to use WebGUI Collateral</b>" unless (WebGUI::Grouping::isInGroup(4));
return www_htmlArealistCollateral() if ($session{form}{image} eq "");
my($test, $file);
$session{form}{fid} = $session{form}{collateralFolderId} = $session{form}{path};
my $collateral = WebGUI::Collateral->new("new");
$session{form}{thumbnailSize} ||= $session{setting}{thumbnailSize};
$session{form}{cid} = $collateral->get("collateralId");
$collateral->save("image", $session{form}{thumbnailSize});
$session{form}{name} = "untitled" if ($session{form}{name} eq "");
while (($test) = WebGUI::SQL->quickArray("select name from collateral
where name=".quote($session{form}{name})." and collateralId<>".quote($collateral->get("collateralId")))) {
if ($session{form}{name} =~ /(.*)(\d+$)/) {
$session{form}{name} = $1.($2+1);
} elsif ($test ne "") {
$session{form}{name} .= "2";
}
}
$collateral->set($session{form});
$session{form}{collateralType} = "";
return www_htmlArealistCollateral();
}
#-------------------------------------------------------------------
sub www_htmlAreaDelete {
$session{page}{makePrintable}=1; $session{page}{printableStyleId}=10;
return "<b>Only Content Managers are allowed to use WebGUI Collateral</b>" unless (WebGUI::Grouping::isInGroup(4));
if($session{form}{cid}) { # Delete Image
my $collateral = WebGUI::Collateral->new($session{form}{cid});
$collateral->delete;
} elsif($session{form}{fid} and not($session{form}{cid})) {
return WebGUI::Privilege::vitalComponent() unless ($session{form}{fid} > 999);
my ($parent) = WebGUI::SQL->quickArray("select parentId from collateralFolder where collateralFolderId=".quote($session{form}{fid}));
WebGUI::SQL->write("delete from collateralFolder where collateralFolderId=".quote($session{form}{fid}));
$session{form}{fid}=$parent;
}
return www_htmlArealistCollateral();
}
#-------------------------------------------------------------------
sub www_htmlAreaCreateFolder {
$session{page}{makePrintable}=1; $session{page}{printableStyleId}=10;
return "<b>Only Content Managers are allowed to use WebGUI Collateral</b>" unless (WebGUI::Grouping::isInGroup(4));
$session{form}{fid} = WebGUI::Id::generate();
WebGUI::Session::setScratch("collateralFolderId",$session{form}{fid});
WebGUI::SQL->write("insert into collateralFolder (collateralFolderId) values (".quote($session{form}{fid}).")");
my $folderId = $session{scratch}{collateralFolderId} || 0;
$session{form}{name} = $session{form}{folder};
$session{form}{name} = "untitled" if ($session{form}{name} eq "");
while (my ($test) = WebGUI::SQL->quickArray("select name from collateralFolder
where name=".quote($session{form}{name})." and collateralFolderId<>".quote($folderId))) {
if ($session{form}{name} =~ /(.*)(\d+$)/) {
$session{form}{name} = $1.($2+1);
} elsif ($test ne "") {
$session{form}{name} .= "2";
}
}
WebGUI::SQL->write("update collateralFolder set parentId=".quote($session{form}{path}).", name=".quote($session{form}{name})
.", description=".quote($session{form}{description})." where collateralFolderId=".quote($folderId));
$session{form}{fid} = $session{form}{path};
return www_htmlArealistCollateral();
}
1;

View file

@ -1,61 +0,0 @@
package WebGUI::Operation::Root;
#-------------------------------------------------------------------
# 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::Grouping;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Operation::Shared;
use WebGUI::Paginator;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::URL;
#-------------------------------------------------------------------
sub _submenu {
my (%menu);
tie %menu, 'Tie::IxHash';
$menu{WebGUI::URL::page('op=editPage&npp=0')} = WebGUI::International::get(409);
return menuWrapper($_[0],\%menu);
}
#-------------------------------------------------------------------
sub www_listRoots {
return WebGUI::Privilege::adminOnly() unless(WebGUI::Grouping::isInGroup(3));
my ($output, $p, $sth, %data, @row, $i);
$output = helpIcon("root manage");
$output .= '<h1>'.WebGUI::International::get(408).'</h1>';
$sth = WebGUI::SQL->read("select * from page where title<>'Reserved' and parentId='0' order by title");
while (%data = $sth->hash) {
$row[$i] = '<tr><td valign="top" class="tableData">'
.deleteIcon('op=deletePageConfirm',$data{urlizedTitle},WebGUI::International::get(101))
.editIcon('op=editPage',$data{urlizedTitle})
.cutIcon('op=cutPage',$data{urlizedTitle})
.'</td>';
$row[$i] .= '<td valign="top" class="tableData"><a href="'.WebGUI::URL::gateway($data{urlizedTitle}).'">'.$data{title}.'</a></td>';
$row[$i] .= '<td valign="top" class="tableData">'.$data{urlizedTitle}.'</td></tr>';
$i++;
}
$sth->finish;
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=listRoots'));
$p->setDataByArrayRef(\@row);
$output .= '<table border=1 cellpadding=3 cellspacing=0 align="center">';
$output .= $p->getPage;
$output .= '</table>';
$output .= $p->getBarTraditional;
return _submenu($output);
}
1;

View file

@ -115,11 +115,6 @@ sub www_editSettings {
-label=>$i18n->get(946),
-value=>$session{setting}{sharedTrash}
);
$tabform->getTab("ui")->integer(
-name=>"snippetsPreviewLength",
-label=>$i18n->get(888),
-value=>$session{setting}{snippetsPreviewLength}
);
$tabform->getTab("ui")->integer(
-name=>"textAreaRows",
-label=>$i18n->get(463),

View file

@ -1,481 +0,0 @@
package WebGUI::Persistent;
=head1 LEGAL
-------------------------------------------------------------------
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
-------------------------------------------------------------------
=cut
use strict;
use warnings;
use WebGUI::SQL;
use WebGUI::Persistent::Query::Select;
use WebGUI::Persistent::Query::Delete;
use WebGUI::Persistent::Query::Update;
use WebGUI::Persistent::Query::Insert;
use WebGUI::ErrorHandler;
our %classData = ();
=head1 NAME
Package WebGUI::Persistent
=head1 DESCRIPTION
An abstract base class for objects stored in the database.
This class provides simple get() and set() methods that interact with the
database.
=head1 SYNOPSIS
package MyClass;
use WebGUI::Persistent;
our @ISA = qw(WebGUI::Persistent);
sub classSettings {
{
properties => {
A => { key => 1 },
B => { defaultValue => 5},
C => { quote => 1 , defaultValue => "hello world"},
D => { },
},
table => 'myTable'
}
}
1;
.
.
.
use MyClass;
# create a new instance
my $obj = MyClass->new( -properties => {B => 3} );
# commit it to the database
$obj->set();
# find out what id it has
my $id = $obj->get('A');
This would leave a row in the table:
+---+---+-------------+------+
| A | B | C | D |
+---+---+-------------+------+
| 1 | 3 | hello world | NULL |
+---+---+-------------+------+
Rows can be retrieved from the database individually:
my $sameObj = MyClass->new(A => $id);
Or multiple rows can be fetched:
my @objs = MyClass->multiNew(-where => ["A > 5"], B => 3);
Rows can also be deleted from the database individually or many at once.
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
# Provides access to various stored classData.
sub classData {
my ($self) = @_;
my $class = ref($self) || $self;
return $classData{$class} ||= {};
}
#-------------------------------------------------------------------
=head2 classSettings
This class method must be overridden to return a hash reference with one or
more of the following keys.
sub classSettings {
{
properties => {
A => { key => 1 },
B => { defaultValue => 5},
C => { quote => 1 , defaultValue => "hello world"},
D => { },
},
table => 'myTable'
}
}
=head3 properties
This should be a hash reference keyed by the field names of the table that
this class refers to (and should be able to be manipulated with this classes
get() and set() methods). The values of the hash reference should be hash
references containing settings for each field.
=head3 * defaultValue
The default value for this field (optional).
=head3 * key
Should be true for the primary key column (one field must be set in this way).
=head3 * quote
Should be true for fields that need to be quoted in database queries.
=head3 table
This must be set to the name of the table that this class represents.
=cut
sub classSettings {
WebGUI::ErrorHandler::fatalError("classSettings() must be overridden");
}
#-------------------------------------------------------------------
=head2 delete
An instance method to delete the currently instantiated row.
=cut
sub delete {
my ($self) = @_;
my $delete = WebGUI::Persistent::Query::Delete->new(
table => $self->table(),
where => { $self->keyColumn() => $self->get($self->keyColumn()) }
);
WebGUI::SQL->write($delete->buildQuery());
}
#-------------------------------------------------------------------
=head2 get( $propertyName )
Returns the value of a field.
=cut
sub get {
my ($self,$propertyName) = @_;
if ($propertyName) {
if (exists($self->{_property}{$propertyName})) {
return $self->{_property}{$propertyName};
} elsif ($self->properties->{$propertyName}) {
WebGUI::ErrorHandler::warn(
ref($self)." $propertyName not retrieved from database"
);
}
}
return $self->{_property};
}
#-------------------------------------------------------------------
=head2 keyColumn
Returns the name of the column that is the primary key for this table.
See classSettings() for details on how to set this value.
=cut
sub keyColumn {
my ($class) = @_;
unless ($class->classData->{keyColumn}) {
my $properties = $class->properties();
foreach my $key (keys %$properties) {
next unless $properties->{$key}{key};
$class->classData->{keyColumn} = $key;
}
}
return $class->classData->{keyColumn};
}
#-------------------------------------------------------------------
sub _mergeWhere {
my ($class,$where,$p) = @_;
$where ||= [];
if (%$p) {
push @$where,$p if ref($where) eq 'ARRAY';
$where = [$where,$p] if ref($where) eq 'HASH';
}
return $where;
}
#-------------------------------------------------------------------
=head2 minimumFields
Returns an array reference to the minimum subset of fields that maybe
selected from the database. This list defaults to the keyColum().
=cut
sub minimumFields {
my ($class) = @_;
unless ($class->classData->{minimumFields}) {
$class->classData->{minimumFields} = [$class->keyColumn()]
}
return $class->classData->{minimumFields};
}
#-------------------------------------------------------------------
=head2 multiDelete( -where => @whereClauses, %p )
=head3 -where
See multiNew().
=cut
sub multiDelete {
my $class = shift;
my ($where,%p) = $class->_pluck([qw(-where)],@_);
my $delete = WebGUI::Persistent::Query::Delete->new(
table => $class->table(),
properties => $class->properties(),
where => $class->_mergeWhere($where,\%p)
);
my $query = $delete->buildQuery();
WebGUI::SQL->write($query);
}
#-------------------------------------------------------------------
=head2 multiNew( %p )
Returns a list of objects matching the query arguments.
Unrecognised parameters are combined to form the where clause:
MyClass->multiNew(A => [1,2], B => 3);
Additional, more complicated parameters maybe passed using the -where option.
=head3 -where
If provided -where must be an array reference, which is evaluated to generate
an Sql where clause using the properties in classSettings. Any left over named
parameters to this method are built into the where clause.
For a class with settings as defined in the sysnopsis above the following
argument to -where would be evaluated as:
-where => [{A => [1,2]},[{B => 3,C => 'hello'}],"D = (B * 3)"]
Evaluates to:
A in (1,2) AND (B = 3 OR C = 'hello') AND D = (B * 3)
=head3 -fields
This maybe an array reference of fields to be selected from the database,
otherwise, all fields in properties are selected unless the -minimumFields
option is true.
=head3 -minimumFields
If true the minimum fields are selected from the database.
=cut
sub multiNew {
my $class = shift;
my ($where,$fields,$minimumFields,%p)
= $class->_pluck([qw(-where -fields -minimumFields)],@_);
$minimumFields = $class->minimumFields if $minimumFields;
my (@objs);
my $select = WebGUI::Persistent::Query::Select->new(
table => $class->table(),
properties => $class->properties(),
where => $class->_mergeWhere($where,\%p),
fields => $minimumFields ? $minimumFields : $fields
);
my $query = $select->buildQuery();
my $sth = WebGUI::SQL->read($query);
while (my $hash = $sth->hashRef()) {
push @objs, $class->new(-properties => $hash);
}
return @objs;
}
#-------------------------------------------------------------------
=head2 new
=head3 -properties
If a hash reference of property names to values is provided to this method,
then the database is not queried. This is mainly used for creating new rows
by calling set afterwards (if not specified the value of the key column is
set to 'new', so that when set() is called, and insert takes place).
=head3 -where
See multiNew().
=head3 -fields
See multiNew().
=head3 -minimumFields
See multiNew().
=head3 -noSet
If true this stops the set() method from doing writing to the database.
=cut
sub new {
my $class = shift;
my ($properties,$where,$fields,$minimumFields,$noSet,%p)
= $class->_pluck(
[qw(-properties -where -fields -minimumFields -noSet)],@_
);
$minimumFields = $class->minimumFields if $minimumFields;
if ($properties) {
my $classProperties = $class->properties();
foreach my $propertyName (keys %$classProperties) {
next if exists $properties->{$propertyName};
$properties->{$propertyName}
= $classProperties->{$propertyName}{defaultValue};
}
unless (defined($properties->{$class->keyColumn()})) {
$properties->{$class->keyColumn()} = 'new';
}
return bless {_property => $properties,_noSet => $noSet}, $class;
} else {
$where = $class->_mergeWhere($where,\%p);
my $select = WebGUI::Persistent::Query::Select->new(
table => $class->table(),
properties => $class->properties(),
where => $where,
fields => $minimumFields ? $minimumFields : $fields
);
my $query = $select->buildQuery();
my $hash = WebGUI::SQL->quickHashRef($query);
return undef unless defined %$hash;
return bless {_property => $hash,_noSet => $noSet}, $class;
}
}
#-------------------------------------------------------------------
sub _pluck {
my ($class,$p,%q) = @_;
return ((map {delete($q{$_})} @$p),%q);
}
#-------------------------------------------------------------------
=head2 properties
Returns a cached hash reference containing the "properties" defined in
classSettings()
=cut
sub properties {
my ($class) = @_;
unless ($class->classData->{properties}) {
$class->classData->{properties} = $class->classSettings->{properties};
}
return $class->classData->{properties}
}
#-------------------------------------------------------------------
=head2 set( [ \%p ] )
This method optionally takes a hash reference of property to value and updates
the object and database:
$obj->set({ B => 9, D => 60 });
If no arguments are provided then the object's current state is written to the
database.
$obj->set();
=cut
sub set {
my ($self,$properties) = @_;
$properties ||= {};
foreach my $propertyName (keys %$properties) {
$self->{_property}{$propertyName} = $properties->{$propertyName};
}
return if $self->{_noSet};
if ($self->get($self->keyColumn()) ne 'new') {
my $update = WebGUI::Persistent::Query::Update->new(
table => $self->table(),
where => { $self->keyColumn => $self->get($self->keyColumn()) },
data => $properties,
properties => $self->properties()
);
WebGUI::SQL->write($update->buildQuery());
} else {
$self->{_property}{$self->keyColumn()} = getNextId($self->keyColumn());
my $insert = WebGUI::Persistent::Query::Insert->new(
table => $self->table(),
data => $self->{_property},
properties => $self->properties()
);
WebGUI::SQL->write($insert->buildQuery());
}
}
#-------------------------------------------------------------------
=head2 table
Returns the table name set in classSettings().
=cut
sub table {
my ($class) = @_;
unless ($class->classData->{table}) {
unless ($class->classSettings->{table}) {
WebGUI::ErrorHandler::fatalError("table() must be overridden");
}
$class->classData->{table} = $class->classSettings->{table};
}
return $class->classData->{table}
}
1;

View file

@ -1,234 +0,0 @@
package WebGUI::Persistent::Query;
=head1 LEGAL
-------------------------------------------------------------------
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
-------------------------------------------------------------------
=cut
use strict;
use warnings;
use WebGUI::SQL ();
use WebGUI::ErrorHandler;
=head1 NAME
Package WebGUI::Persistent::Query
=head1 DESCRIPTION
An abstract base class for objects that build queries, providing funtionality
for building the where clause. See WebGUI::Persistent::Query::Select for more
details.
=head1 SYNOPSIS
use WebGUI::Persistent::Query;
our @ISA = qw(WebGUI::Persistent::Query);
sub buildQuery {
# build the query...
.
.
.
}
=head1 METHODS
#-------------------------------------------------------------------
=head2 buildQuery
Build the query from the properties. This method must be overridden by
subclasses
=cut
sub buildQuery {
WebGUI::ErrorHandler::fatalError("buildQuery() must be overridden");
}
;
#-------------------------------------------------------------------
=head2 buildWhere
Build the where clause for this query.
=cut
sub buildWhere {
my ($self) = @_;
my @clauses;
if (my $where = $self->parseWhereArgs(@{$self->{_where}})) {
return "WHERE $where";
}
return undef;
}
#-------------------------------------------------------------------
=head2 buildWhereElement( $name, @values )
Builds an element of a where clause.
=cut
sub buildWhereElement {
my ($self,$name,@vals) = @_;
@vals = @{$vals[0]} if ref($vals[0]);
return undef unless @vals;
return "$name = ".$self->quote($name,@vals) if (@vals == 1);
return "$name IN (".join(',',map {$self->quote($name,$_)} @vals).")";
}
#-------------------------------------------------------------------
=head2 new( %p )
=head3 properties
A hashref of field name to a hash reference of property settings.
Currently used settings are:
=head3 * quote
If true values for this field are automatically quoted.
=head3 table
The name of the table to query.
=head3 where
A hash reference or array reference of arguments to build a where clause from.
See parseWhereArgs for details.
=cut
sub new {
my ($class,%p) = @_;
$p{where} ||= [];
$p{where} = [$p{where}] unless ref($p{where}) eq 'ARRAY';
my $self = bless {
_where => $p{where},
_properties => $p{properties},
_table => $p{table},
}, $class;
return $self;
}
#-------------------------------------------------------------------
sub _parsePart {
my ($self,$part,$or,$no_bracket) = @_;
return $part unless ref($part);
if (ref($part) eq 'ARRAY') {
my @parts;
foreach my $sub_part (@$part) {
$sub_part = $self->_parsePart($sub_part,!$or);
push @parts,$sub_part if $sub_part;
}
if (@parts) {
my $ret_val = join(($or ? ' OR ' : ' AND '),@parts);
return ($no_bracket ? $ret_val : "($ret_val)");
}
} elsif (ref($part) eq 'HASH') {
my @parts;
foreach my $key (keys %$part) {
my $clause = $self->buildWhereElement($key,$part->{$key});
push @parts,$clause if $clause;
}
return $self->_parsePart(\@parts,!$or,1);
}
return '';
}
#-------------------------------------------------------------------
=head2 parseWhereArgs( @argumentList)
Recursivley parses a list of where arguments joining them with "AND" or "OR". Arguments
may take a number of forms:
=head3 * scalar
("A = 1") is left unchanged.
=head3 * array reference
An array reference causes the joining argument to switch from 'AND' to 'OR'
(or visa-versa) for its contents:
([ "A = 1","C = 2" ])
becomes:
"(A = 1 OR C = 2)"
=head3 * hash reference
These are a convienent way of being able to dynamically build up complex
queries gradually.
({ A => 1 , C => 2 })
becomes:
"A = 1 AND C = 2"
This routine is flexiable enough to be able to parse arguments of the form:
({A => [1,2]},[{B => 3,C => 4}],{D => 5})
becomes:
"A in (1,2) AND (B = 3 OR C = 4) AND D = 5"
=cut
sub parseWhereArgs {
my ($self,@where_arg_list) = @_;
my @where_parts;
foreach my $where_part (@where_arg_list) {
my $part = $self->_parsePart($where_part,1,0);
push @where_parts,$part if $part;
}
return $self->_parsePart(\@where_parts,0,1);
}
#-------------------------------------------------------------------
=head2 quote( $propertyName, $propertyVaule )
Returns a quoted value for inclusion in a query, by refering to the properties
supplied to new().
=cut
sub quote {
my ($self,$propertyName,$propertyValue) = @_;
return 'NULL' unless defined($propertyValue);
if ($self->{_properties}{$propertyName}{quote}) {
return WebGUI::SQL::quote($propertyValue);
}
return $propertyValue;
}
1;

View file

@ -1,87 +0,0 @@
package WebGUI::Persistent::Query::Delete;
=head1 LEGAL
-------------------------------------------------------------------
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
-------------------------------------------------------------------
=cut
use strict;
use warnings;
use WebGUI::Persistent::Query;
our @ISA = qw(WebGUI::Persistent::Query);
=head1 NAME
Package WebGUI::Persistent::Query::Delete
=head1 DESCRIPTION
This class allows reliable dynamic building of Sql delete queries.
=head1 SYNOPSIS
my $query = WebGUI::Persistent::Query::Delete->new(
table => 'myTable',
where => [A => [1,2],[{C => 'hello',B => 1}]]
);
$query->buildQuery();
Returns:
DELETE FROM myTable
WHERE A IN (1,2) AND (C = 'hello' OR B = 1)
=cut
#-------------------------------------------------------------------
=head2 buildQuery
=cut
sub buildQuery {
my ($self,%p) = @_;
my $query = 'DELETE FROM '.$self->{_table};
if (my $where = $self->buildWhere()) {
$query .= " $where";
}
return $query;
}
=head2 new( %p )
=head3 properties
A hashref of field name to a hash reference of property settings.
Currently used settings are:
=head3 * quote
If true values for this field are automatically quoted.
=head3 table
The name of the table to query.
=head3 where
A hash reference or array reference of arguments to build a where clause from.
See parseWhereArgs for details.
=cut
1;

View file

@ -1,107 +0,0 @@
package WebGUI::Persistent::Query::Insert;
=head1 LEGAL
-------------------------------------------------------------------
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
-------------------------------------------------------------------
=cut
use strict;
use warnings;
use WebGUI::Persistent::Query::Insert;
our @ISA = qw(WebGUI::Persistent::Query);
=head1 NAME
Package WebGUI::Persistent::Query::Insert
=head1 DESCRIPTION
This class allows reliable dynamic building of Sql insert queries.
=head1 SYNOPSIS
my $query = WebGUI::Persistent::Query::Insert->new(
table => 'myTable',
data => {
A => 1,
B => 2,
C => 'hello',
D => 'world'
},
properties => {
A => { },
B => { },
C => { quote => 1 },
D => { quote => 1 },
}
);
$query->buildQuery();
Returns:
INSERT INTO myTable (A,B,C,D) VALUES (1,2,'hello','world');
=cut
#-------------------------------------------------------------------
sub buildFieldValues {
my ($self) = @_;
my @fields = keys %{$self->{_data}};
my @values = map { $self->quote($_,$self->{_data}{$_})} @fields;
return "(".join(', ',@fields).") VALUES (".join(', ',@values).")";
}
#-------------------------------------------------------------------
=head2 buildQuery
=cut
sub buildQuery {
my ($self) = @_;
return join(' ','INSERT INTO',$self->{_table},$self->buildFieldValues());
}
#-------------------------------------------------------------------
=head2 new( %p )
=head3 data
A hash reference of field name to value.
=head3 properties
=head3 * quote
If true values for this field are automatically quoted.
=head3 table
The name of the table to query.
=cut
sub new {
my ($class,%p) = @_;
my $self = $class->SUPER::new(%p);
$self->{_data} = $p{data} || {};
return $self;
}
1;

View file

@ -1,165 +0,0 @@
package WebGUI::Persistent::Query::Select;
=head1 LEGAL
-------------------------------------------------------------------
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
-------------------------------------------------------------------
=cut
use strict;
use warnings;
use WebGUI::Persistent::Query;
=head1 NAME
Package WebGUI::Persistent::Query::Select
=head1 DESCRIPTION
This class allows reliable dynamic building of Sql select queries.
=head1 SYNOPSIS
my $query = WebGUI::Persistent::Query::Select->new(
where => [A => [1,2],[{C => 'hello',B => 1}]],
table => 'myTable',
limit => 1,
groupBy => 'D',
properties => {
A => { },
B => { },
C => { quote => 1 },
D => { quote => 1 },
}
);
$query->buildQuery();
Returns:
SELECT A,B,C,D
FROM myTable
WHERE A IN (1,2) AND (C = 'hello' OR B = 1) LIMIT 1 GROUP BY D
=cut
our @ISA = qw(WebGUI::Persistent::Query);
#-------------------------------------------------------------------
sub buildFrom { "FROM ".$_[0]->{_table} }
#-------------------------------------------------------------------
sub buildGroupBy {
my ($self) = @_;
return '' unless $self->{_groupBy} && @{$self->{_groupBy}};
return 'GROUP BY '.join(',',@{$self->{_groupBy}});
}
#-------------------------------------------------------------------
sub buildLimit { $_[0]->{_limit} ? "LIMIT ".$_[0]->{_limit} : '' }
#-------------------------------------------------------------------
sub buildOrderBy {
my ($self) = @_;
return '' unless $self->{_orderBy} && @{$self->{_orderBy}};
return 'ORDER BY '.join(',',@{$self->{_orderBy}});
}
#-------------------------------------------------------------------
=head2 buildQuery
=cut
sub buildQuery {
my ($self) = @_;
my @clauses = ('SELECT',
$self->buildSelectFields(),
$self->buildFrom());
if (my $where = $self->buildWhere()) {
push @clauses,$where;
}
if (my $group_by = $self->buildGroupBy()) {
push @clauses,$group_by;
}
if (my $order_by = $self->buildOrderBy()) {
push @clauses,$order_by;
}
if (my $limit = $self->buildLimit()) {
push @clauses,$limit;
}
return join(' ',@clauses);
}
#-------------------------------------------------------------------
sub buildSelectFields {
my ($self) = @_;
return join(', ',@{$self->{_fields}}) if @{$self->{_fields}};
return join(', ',keys %{$self->{_properties}}) if %{$self->{_properties}};
return '*';
}
#-------------------------------------------------------------------
=head2 new( %p )
=head3 fields
An array reference of field names (optional).
=head3 groupBy
An array reference of fields to group results by
=head3 limit
A scalar limit.
=head3 orderBy
An array reference of fields to order results by
=head3 properties
=head3 * quote
If true values for this field are automatically quoted.
=head3 table
The name of the table to query.
=head3 where
A hash reference or array reference of arguments to build a where clause from.
See WebGUI::Persistent::Query::parseWhereArgs for details.
=cut
sub new {
my ($class,%p) = @_;
my $self = $class->SUPER::new(%p);
$self->{_fields} = $p{fields} || [];
$self->{_limit} = $p{limit};
$self->{_group_by} = $p{groupBy};
$self->{_order_by} = $p{orderBy};
return $self;
}
1;

View file

@ -1,110 +0,0 @@
package WebGUI::Persistent::Query::Update;
=head1 LEGAL
-------------------------------------------------------------------
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
-------------------------------------------------------------------
=cut
use strict;
use warnings;
use WebGUI::Persistent::Query;
our @ISA = qw(WebGUI::Persistent::Query);
=head1 NAME
Package WebGUI::Persistent::Query::Update
=head1 DESCRIPTION
This class allows reliable dynamic building of Sql update queries.
=head1 SYNOPSIS
my $query = WebGUI::Persistent::Query::Update->new(
table => 'myTable',
where => [A => [1,2],[{C => 'hello',B => 1}]],
data => {
A => 1,
B => 2,
C => 'hello',
D => 'world'
},
properties => {
A => { },
B => { },
C => { quote => 1 },
D => { quote => 1 },
}
);
$query->buildQuery();
Returns:
UPDATE myTable SET A = 1, B = 2, C = 'hello' C = 'world'
WHERE A IN (1,2) AND (C = 'hello' OR B = 1)
=cut
=head2 buildQuery
=cut
sub buildQuery {
my ($self) = @_;
my @clauses = ('UPDATE',$self->{_table},$self->buildSet());
if (my $where = $self->buildWhere()) {
push @clauses,$where;
}
return join(' ',@clauses);
}
sub buildSet {
my ($self) = @_;
'SET '.join(', ',map {
"$_ = ". $self->quote($_,$self->{_data}{$_})
} keys %{$self->{_data}});
}
=head2 new( %p )
=head3 data
A hash reference of field name to value.
=head3 properties
=head3 * quote
If true values for this field are automatically quoted.
=head3 table
=head3 where
A hash reference or array reference of arguments to build a where clause from.
See WebGUI::Persistent::Query::parseWhereArgs for details.
=cut
sub new {
my ($class,%p) = @_;
my $self = $class->SUPER::new(%p);
$self->{_data} = $p{data} || {};
return $self;
}
1;

View file

@ -1,638 +0,0 @@
package WebGUI::Persistent::Tree;
=head1 LEGAL
-------------------------------------------------------------------
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
-------------------------------------------------------------------
=cut
use strict;
use warnings;
use Tree::DAG_Node;
use WebGUI::Persistent;
use WebGUI::SQL ();
use WebGUI::Persistent::Query::Update;
our @ISA = qw(WebGUI::Persistent Tree::DAG_Node);
=head1 NAME
Package WebGUI::Persistent
=head1 DESCRIPTION
An abstract base class for objects stored in the database, that represent tree
structures.
This class inherits from both WebGUI::Persistent (to provide get() and set()
methods), and from Tree::DAG_Node (to provide tree manipulation methods).
=head1 SYNOPSIS
package MyTreeClass;
use WebGUI::Persistent::Tree;
our @ISA = qw(WebGUI::Persistent::Tree);
sub classSettings {
{
properties => {
A => { key => 1 },
B => { defaultValue => 5},
C => { quote => 1 , defaultValue => "hello world"},
parentId => { defaultValue => 0 },
sequenceNumber => { defaultValue => 1 }
},
table => 'myTreeTable'
}
}
1;
.
.
.
use MyTreeClass;
my $nodes = $class->getTree({-minmumFields});
print join("\n",@{$nodes->{0}->draw_ascii_tree()});
=head1 METHODS
#-------------------------------------------------------------------
=head2 buildTree( \@objs, [ \%nodes ] )
Given an array reference of objects this method will attempt to build them
into a tree.
=cut
sub buildTree {
my ($class,$objs,$nodes) = @_;
$nodes ||= {};
my %parentToChild = ();
my $keyColumn = $class->keyColumn();
foreach my $obj (grep {$_} @$objs) {
$nodes->{$obj->get($keyColumn)} = $obj;
$obj->{daughters} ||= [];
next if ($obj->get('parentId') eq $obj->get($keyColumn));
push @{ $parentToChild{$obj->get('parentId')} }, $obj;
}
foreach my $parentId (keys %parentToChild) {
if (my $parent = $nodes->{$parentId}) {
$parent->add_daughters($class->sortSiblings($parentToChild{$parentId}));
}
}
return $nodes;
}
#-------------------------------------------------------------------
=head2 canDown
Returns tree if this object can be moved down within the current tree.
=cut
sub canDown { $_[0]->right_sister }
#-------------------------------------------------------------------
=head2 canLeft
Returns tree if this object can be moved left within the current tree.
=cut
sub canLeft { $_[0]->mother ? 1 : 0 }
#-------------------------------------------------------------------
=head2 canRight
Returns tree if this object can be moved right within the current tree.
=cut
sub canRight { $_[0]->left_sister }
#-------------------------------------------------------------------
=head2 canUp
Returns tree if this object can be moved up within the current tree.
=cut
sub canUp { $_[0]->left_sister }
#-------------------------------------------------------------------
=head2 classSettings
This class method must be overridden to return a hash reference with one or
more of the following keys.
=head3 useDummyRoot
This should be set to true for classes that don't store their root node in
the database.
=head3 properties
This should be a hash reference keyed by the field names of the table that
this class refers to (and should be able to be manipulated with this classes
get() and set() methods). The values of the hash reference should be hash
references containing settings for each field.
=head3 * defaultValue
The default value for this field (optional).
=head3 * key
Should be true for the primary key column (one field must be set in this way).
=head3 * quote
Should be true for fields that need to be quoted in database queries.
=cut
#-------------------------------------------------------------------
=head2 dummyRoot
This creates a dummy root object for classes that do not store their root in
the database.
=cut
sub dummyRoot {
$_[0]->new(
-properties => { pageId => 0 },
-noSet => 1
);
}
#-------------------------------------------------------------------
=head2 getTree ( [ \%p, $maxDepth, \%nodes ] )
This method has varying behaviour depending on the context from which it is
called.
In instance context rows from the table will be recursivley selected using the
current object as the root, and then the tree will be built:
$self->getTree();
In class context, the all rows are selected from the table, and then the tree
is built.
$class->getTree();
In all cases a hashref is returned.
{ keyColumnValue => WebGUI::Persistent::Tree object }
If defined $maxDepth maybe used to limit the depth of the recursion.
If %p is defined, the arguments are passed directly to the new or multiNew
methods, this allows multiple trees to be easily stored in one table:
$class->getTree({treeId => 4});
$nodes can be a hash reference to objects that have already been obtained from
the database.
=cut
sub getTree {
my ($self,$p,$maxDepth,$nodes) = @_;
my $class = ref($self) || $self;
$nodes ||= {};
$p ||={};
unless (ref($self)) {
if ($class->useDummyRoot()) {
$nodes->{0} = $self = $class->dummyRoot();
}
if (!defined($maxDepth)) {
return $class->buildTree([$class->multiNew(%$p)],$nodes);
} elsif (!ref($self)) {
$self = $class->new(%$p,$class->keyColumn() => 0);
}
}
$nodes->{$self->get($class->keyColumn())} ||= $self;
return $nodes if (defined($maxDepth) && --$maxDepth < 0);
my @objs = $class->multiNew(
parentId => $self->get($class->keyColumn()),%$p
);
if (@objs) {
$self->buildTree(\@objs,$nodes);
return $nodes if (defined($maxDepth) && !$maxDepth) ;
$_->getTree($p,$maxDepth,$nodes) foreach @objs;
}
return $nodes;
}
#-------------------------------------------------------------------
=head2 grandmotherChildrenAndSelf( $keyColumnId )
Using the given $keyColumnId this method fetches the grandmother, children,
and the object refered to by the $keyColumnId.
Returns a list of objects.
=cut
sub grandmotherChildrenAndSelf {
my ($class,$keyColumnId) = @_;
return undef unless defined($keyColumnId);
my $self = $class->new(-minimumFields=>1,$class->keyColumn() => $keyColumnId);
return undef unless $self;
return ($self,$class->motherSelfAndSisters($self->get('parentId')));
}
#-------------------------------------------------------------------
=head2 minimumFields
The minimumFields for Trees must also include the parentId, and the
sequenceNumber.
See WebGUI::Persistent.
=cut
sub minimumFields {
my ($class) = @_;
unless ($class->classData->{minimumFields}) {
my $fields = $class->SUPER::minimumFields();
push @$fields, 'parentId';
push @$fields, 'sequenceNumber' if ($class->properties->{sequenceNumber});
}
return $class->classData->{minimumFields};
}
#-------------------------------------------------------------------
sub name {
my $self = shift;
return $self->keyColumn().':'.$self->get($self->keyColumn());
}
#-------------------------------------------------------------------
# Avoid a bug in Tree::DAG_Node.
# When a new node is created and has no daughters. This sometimes causes
# problems for Tree::DAG_Node::walk_down()
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
$self->{daughters} ||= [] if $self;
$self->attributes({});
return $self;
}
#-------------------------------------------------------------------
=head2 motherSelfAndSisters( $keyColumnId )
Given the $keyColumnId, this method fetches the related mother and sisters.
Returns a list of objects.
=cut
sub motherSelfAndSisters {
my ($class,$keyColumnId) = @_;
return undef unless defined($keyColumnId);
my $self = $class->new(-minimumFields=>1,$class->keyColumn() => $keyColumnId);
return undef unless $self;
my $parentId = $self->get('parentId');
my @objs = $class->multiNew(
-minimumFields => 1,
-where => [
[{
parentId => $parentId,
$class->keyColumn() => $parentId,
}],
$class->keyColumn()." != $keyColumnId",
]
);
if ($class->useDummyRoot() && $parentId eq '0') {
push @objs, $class->dummyRoot();
}
return ($self,@objs);
}
#-------------------------------------------------------------------
=head2 moveDown( [ $keyColumnId ] )
In class context:
$class->moveDown($keyColumnId);
The required parent, sister and child objects are fetched from the database,
and the tree is built and manipulated.This class' inheritance from
WebGUI::Persistent takes care of any database work.
In instance context:
$self->moveDown();
The current object is assumed to be in a pre-built tree, and so the tree is
simply manipulated. This class' inheritance from WebGUI::Persistent takes care
of any database work.
=cut
sub moveDown {
my ($self,$keyColumnId) = @_;
my $class = ref($self) || $self;
return unless $class->properties->{sequenceNumber};
unless (ref($self)) {
my $nodes = $class->buildTree([$class->motherSelfAndSisters($keyColumnId)]);
$self = $nodes->{$keyColumnId};
}
return unless ($self && $self->canDown());
my $right = $self->right_sister;
$self->swapSisters($right);
}
#-------------------------------------------------------------------
=head2 moveLeft( [ $keyColumnId ] )
In class context:
$class->moveLeft($keyColumnId);
The required parent, sister and child objects are fetched from the database,
and the tree is built and manipulated.This class' inheritance from
WebGUI::Persistent takes care of any database work.
In instance context:
$self->moveLeft();
The current object is assumed to be in a pre-built tree, and so the tree is
simply manipulated. This class' inheritance from WebGUI::Persistent takes care
of any database work.
=cut
sub moveLeft {
my ($self,$keyColumnId) = @_;
my $class = ref($self) || $self;
unless (ref($self)) {
my $nodes = $class->buildTree([$class->grandmotherChildrenAndSelf($keyColumnId)]);
$self = $nodes->{$keyColumnId};
}
return unless ($self && $self->canLeft());
my $sister = $self->mother;
# Close up hole left by imminent move
map {
$_->set({sequenceNumber => $_->get('sequenceNumber') - 1 })
} $self->right_sisters();
$self->unlink_from_mother;
$sister->add_right_sister($self);
my $newSequenceNumber = $sister->get('sequenceNumber') + 1;
map {
$_->set({sequenceNumber => $_->get('sequenceNumber') + 1 })
} $self->right_sisters();
$self->set({
parentId => $sister->get('parentId'),
sequenceNumber => $newSequenceNumber
});
}
#-------------------------------------------------------------------
=head2 moveRight( [ $keyColumnId ] )
In class context:
$class->moveRight($keyColumnId);
The required parent, sister and child objects are fetched from the database,
and the tree is built and manipulated.This class' inheritance from
WebGUI::Persistent takes care of any database work.
In instance context:
$self->moveRight();
The current object is assumed to be in a pre-built tree, and so the tree is
simply manipulated. This class' inheritance from WebGUI::Persistent takes care
of any database work.
=cut
sub moveRight {
my ($self,$keyColumnId) = @_;
my $class = ref($self) || $self;
unless (ref($self)) {
my @objs = $class->motherSelfAndSisters($keyColumnId);
my $nodes = $class->buildTree(\@objs);
$self = $nodes->{$keyColumnId};
}
return unless ($self && $self->canRight());
my $keyColumn = $class->keyColumn();
my $mother = $self->left_sister;
$mother->getTree({-minimumFields => 1},1);
# Close up hole left by imminent move
map {
$_->set({sequenceNumber => $_->get('sequenceNumber') -1 })
} $self->right_sisters();
# Add as right-most daughter of current left-sister
$self->unlink_from_mother;
$mother->add_daughter($self);
my $newSequenceNumber = 1;
if (my $sister = $self->left_sister()) {
$newSequenceNumber = $sister->get('sequenceNumber') + 1;
}
$self->set({
parentId => $mother ? $mother->get($keyColumn) : 0,
sequenceNumber => $newSequenceNumber
});
}
#-------------------------------------------------------------------
=head2 moveUp( [ $keyColumnId ] )
In class context:
$class->moveUp($keyColumnId);
The required parent, sister and child objects are fetched from the database,
and the tree is built and manipulated.This class' inheritance from
WebGUI::Persistent takes care of any database work.
In instance context:
$self->moveUp();
The current object is assumed to be in a pre-built tree, and so the tree is
simply manipulated. This class' inheritance from WebGUI::Persistent takes care
of any database work.
=cut
sub moveUp {
my ($self,$keyColumnId) = @_;
my $class = ref($self) || $self;
return unless $class->properties->{sequenceNumber};
unless (ref($self)) {
my $nodes = $class->buildTree([$class->motherSelfAndSisters($keyColumnId)]);
$self = $nodes->{$keyColumnId};
}
return unless ($self && $self->canUp());
my $left = $self->left_sister;
$self->swapSisters($left);
}
#-------------------------------------------------------------------
=head2 recursiveDelete
Deletes this element, and all subsequent elements in the tree. The C<getTree>
method must have been called to build the tree.
=cut
sub recursiveDelete {
my ($self) = @_;
my @ids;
$self->walk_down({callback => sub {push @ids, $_[0]->get($_[0]->keyColumn())}});
$self->multiDelete(collateralFolderId => \@ids) if @ids;
return @ids;
}
#-------------------------------------------------------------------
=head2 pedigree
=cut
sub pedigree {
my $node = shift;
my @flexMenu = ($node->left_sisters,$node,$node->daughters,$node->right_sisters);
while(defined($node = $node->{'mother'} ) && ref($node)) {
@flexMenu = ($node->left_sisters,$node,@flexMenu,$node->right_sisters);
}
return @flexMenu;
}
#-------------------------------------------------------------------
=head2 self_and_ancestors
=cut
sub self_and_ancestors {
my $node = shift;
return ($node, $node->ancestors);
}
#-------------------------------------------------------------------
=head2 sortSiblings( \@siblings )
Sorts an array of objects according to sequenceNumber
=cut
sub sortSiblings {
my ($class,$siblings) = @_;
return @$siblings unless $class->properties->{sequenceNumber};
return sort {
($a->get('sequenceNumber') <=> $b->get('sequenceNumber'))
} @$siblings;
}
#-------------------------------------------------------------------
=head2 swapSisters( $sister )
Swaps two sisters over (they must be in a built tree), and updates their
sequenc numbers.
=cut
sub swapSisters {
my $self = shift;
my ($other) = @_;
my @daughters = $self->self_and_sisters;
my $a = $self ->my_daughter_index;
my $b = $other->my_daughter_index;
@daughters[$a, $b] = ($other, $self);
$self->mother->set_daughters(@daughters);
my $tmp = $self->get('sequenceNumber');
$self->set({sequenceNumber => $other->get('sequenceNumber')});
$other->set({sequenceNumber => $tmp});
}
=head2 useDummyRoot
Returns true if useDummyRoot is set in classSettings().
=cut
sub useDummyRoot {
my ($class) = @_;
unless ($class->classData->{useDummyRoot}) {
$class->classData->{useDummyRoot} = $class->classSettings->{useDummyRoot};
}
return $class->classData->{useDummyRoot}
}
1;

View file

@ -81,11 +81,6 @@ our $I18N = {
lastUpdated => 1031514049
},
'767' => {
message => q|Collateral Id|,
lastUpdated => 1036892929
},
'798' => {
message => q|Page Title|,
lastUpdated => 1036978688
@ -485,11 +480,6 @@ The URL of the web site for this theme's designer. If you are in the business of
lastUpdated => 1056151382
},
'833' => {
message => q|File, Add/Edit|,
lastUpdated => 1038871497
},
'139' => {
message => q|No|,
lastUpdated => 1031514049
@ -545,11 +535,6 @@ The URL of the web site for this theme's designer. If you are in the business of
lastUpdated => 1050430737
},
'758' => {
message => q|Add a folder.|,
lastUpdated => 1036892705
},
'783' => {
message => q|Type|,
lastUpdated => 1036954378
@ -590,29 +575,6 @@ The URL of the web site for this theme's designer. If you are in the business of
lastUpdated => 1031514049
},
'834' => {
message => q|You can upload any kind of file to the repository to be used later.
<p/>
<b>Name</b><br/>
Give this file a unique name that you can use to retrieve it later.
<p/>
<b>Organize in Folder</b><br/>
Which collateral folder should hold this file?
<p/>
<b>File</b><br/>
Select a file from your hard drive to upload.
<p/>|,
lastUpdated => 1038871497
},
'772' => {
message => q|Edit File|,
lastUpdated => 1036893140
},
'993' => {
message => q|DSN|,
lastUpdated => 1056151382
@ -636,11 +598,6 @@ Select a file from your hard drive to upload.
lastUpdated => 1031514049
},
'388' => {
message => q|Upload Date|,
lastUpdated => 1031514049
},
'364' => {
message => q|Search|,
lastUpdated => 1031514049
@ -1105,11 +1062,6 @@ The description of this forum as passed by the calling object.
lastUpdated => 1035246389
},
'778' => {
message => q|Folder Description|,
lastUpdated => 1036906132
},
'685' => {
message => q|Template, Delete|,
lastUpdated => 1038791020
@ -1276,11 +1228,6 @@ How should this user be notified when they get a new WebGUI message?
lastUpdated => 1060433963
},
'835' => {
message => q|Snippet, Add/Edit|,
lastUpdated => 1038871744
},
'430' => {
message => q|Last Page View|,
lastUpdated => 1031514049
@ -1426,16 +1373,6 @@ How should this user be notified when they get a new WebGUI message?
lastUpdated => 1044705162
},
'765' => {
message => q|Delete this collateral item.|,
lastUpdated => 1036892866
},
'784' => {
message => q|Thumbnail|,
lastUpdated => 1036954393
},
'312' => {
message => q|Allow business information?|,
lastUpdated => 1031514049
@ -1483,11 +1420,6 @@ As with any delete operation, you are prompted to be sure you wish to proceed wi
lastUpdated => 1031514049
},
'762' => {
message => q|Add a file.|,
lastUpdated => 1036892774
},
'638' => {
message => q|Templates are used to affect how content is laid out in WebGUI. There are many templates that come with WebGUI, and using the template management system, you can add your own templates to the system to ensure that your site looks <b>exactly</b> how you want it to look.
|,
@ -1579,11 +1511,6 @@ As with any delete operation, you are prompted to be sure you wish to proceed wi
lastUpdated => 1031514049
},
'773' => {
message => q|File|,
lastUpdated => 1036893165
},
'813' => {
message => q|Groups In This Group|,
lastUpdated => 1037583186
@ -1599,11 +1526,6 @@ As with any delete operation, you are prompted to be sure you wish to proceed wi
lastUpdated => 1031514049
},
'759' => {
message => q|Edit this folder.|,
lastUpdated => 1036892731
},
'851' => {
message => q|Edit this template.|,
lastUpdated => 1039926394
@ -1674,16 +1596,6 @@ As with any delete operation, you are prompted to be sure you wish to proceed wi
lastUpdated => 1066034603
},
'916' => {
message => q|Snippet|,
lastUpdated => 1050232301
},
'386' => {
message => q|Edit Image|,
lastUpdated => 1031514049
},
'796' => {
message => q|View page statistics.|,
lastUpdated => 1036978043
@ -1898,11 +1810,6 @@ The user id of the currently logged in user.
lastUpdated => 1031514049
},
'775' => {
message => q|Are you certain you wish to delete this folder and move its contents to it's parent folder?|,
lastUpdated => 1036903002
},
'582' => {
message => q|Leave Blank|,
lastUpdated => 1031514049
@ -1938,11 +1845,6 @@ The user id of the currently logged in user.
lastUpdated => 1031514049
},
'888' => {
message => q|Snippet Preview Length|,
lastUpdated => 1045312362
},
'1011' => {
message => q|Code|,
lastUpdated => 1060433339
@ -1984,9 +1886,9 @@ The user id of the currently logged in user.
},
'932' => {
message => q|Themes are a mechanism to quickly install new styles, templates, and collateral into a WebGUI site. They are also great for moving those same items from one site to another.
message => q|Themes are a mechanism to quickly install new styles, templates, and assets into a WebGUI site. They are also great for moving those same items from one site to another.
<p>
<b>TIP:</b> When building a theme, be sure to name the components (styles, templates collateral) in the theme with some name that is unique to the theme. This is useful so that your users can find the components in your theme, as well as to avoid name conflicts.|,
<b>TIP:</b> When building a theme, be sure to name the components (styles, templates, assets) in the theme with some name that is unique to the theme. This is useful so that your users can find the components in your theme, as well as to avoid name conflicts.|,
lastUpdated => 1070027889
},
@ -1995,21 +1897,11 @@ The user id of the currently logged in user.
lastUpdated => 1031514049
},
'764' => {
message => q|Edit this collateral item.|,
lastUpdated => 1036892856
},
'349' => {
message => q|Latest version available|,
lastUpdated => 1031514049
},
'769' => {
message => q|Organize in Folder|,
lastUpdated => 1036893015
},
'983' => {
message => q|Edit this database link.|,
lastUpdated => 1056151382
@ -2317,11 +2209,6 @@ A message stating that the user is receiving the message because they subscribed
context => q|Title of the login history viewer for the admin console.|
},
'542' => {
message => q|Previous..|,
lastUpdated => 1031514049
},
'369' => {
message => q|Expire Date|,
lastUpdated => 1031514049
@ -2788,11 +2675,6 @@ The Groups page displays all groups that you are allowed to edit. The form on t
lastUpdated => 1031514049
},
'766' => {
message => q|Back to collateral list.|,
lastUpdated => 1036892898
},
'1077' => {
message => q|The function you are attempting to call is not available for this authentication module|,
lastUpdated => 1067951805
@ -2860,11 +2742,6 @@ One package that many people create is a Page/Article package. It is often the c
lastUpdated => 1052850265
},
'979' => {
message => q|Are you certain you wish to delete all items in this folder? They cannot be recovered once deleted. Items in sub-folders will not be removed.|,
lastUpdated => 1055908341
},
'1005' => {
message => q|SQL Query|,
lastUpdated => 1057208065
@ -2915,11 +2792,6 @@ One package that many people create is a Page/Article package. It is often the c
lastUpdated => 1031514049
},
'387' => {
message => q|Uploaded By|,
lastUpdated => 1031514049
},
'245' => {
message => q|Date|,
lastUpdated => 1031514049
@ -3067,21 +2939,11 @@ Loops come with special condition variables of their own. They are __FIRST__, __
lastUpdated => 1066580782
},
'757' => {
message => q|Manage Collateral|,
lastUpdated => 1036892669
},
'951' => {
message => q|Are you certain that you wish to empty the clipboard to the trash?|,
lastUpdated => 1052850265
},
'782' => {
message => q|Any|,
lastUpdated => 1036913053
},
'85' => {
message => q|Description|,
lastUpdated => 1031514049
@ -3113,105 +2975,6 @@ Loops come with special condition variables of their own. They are __FIRST__, __
lastUpdated => 1035872437
},
'832' => {
message => q|The collateral management system has several macros for its specific purpose.
<p/>
<b>&#94;File();</b><br/>
&#94;File(<i>collateralFileName</i>);<BR>
&#94;File(<i>collateralFileName</i>,<i>templateName</i>);<BR>
This macro builds a quick link to a file in the Collateral Manager. It creates an icon for the file and outputs the files' name. Then it links them both to the file for downloading. The following variables are available for use in the template:
<p/>
<b>file.url</b><br/>
The URL to the file.
<p/>
<b>file.icon</b><br/>
The file's icon.
<p/>
<b>file.name</b><br/>
The name of the file.
<p/>
<b>file.size</b><br/>
The size of the file.
<p/>
<b>file.thumbnail</b><br/>
The file's thumbnail.
<p/>
An optional second parameter, a template name, allows a custom template
from the Macro/File template namespace to be used instead of the default.
If a template with that name is not found, then the default is used.<br>
<p/>
<b>&#94;I();</b><br/>
This macro retrieves an image from the collateral management system along with an HTML image tag so that you can quickly display an image from the repository in your content.
<p/>
<i>Example:</i> &#94;I("logo");
<p/>
<b>&#94;i();</b><br/>
This macro retrieves the URL for any file in the collateral management system.
<p/>
<i>Example:</i> &#94;i("status report");
<p/>
<b>&#94;RandomImage();</b><br/>
This macro takes the name of a collateral folder as a parameter. If the folder name is omitted, then the root folder will be used. The macro then randomly chooses an image in the folder and returns it in much the same way the &#94;I(); macro works.
<p />
<i>Example:</i> &#94;RandomImage("site headers");
<p />
<b>&#94;RandomSnippet();</b><br/>
This macro takes the name of a collateral folder as a parameter. If the folder name is omitted, then the root folder will be used. The macro then randomly chooses a snippet from the folder and returns it in much the same way the &#94;Snippet(); macro works.
<p />
<i>Example:</i> &#94;RandomSnippet("quips");
<p />
<b>&#94;SI();</b><br/>
The Scaled Image macro allows images to be found in the collateral and scaled (on the server-side), either maintaining the original aspect ratio or an entirely new ratio of your design.
<p>
It takes four parameters. The first is the image name or optionally the collateral id. The second is the width. Set the width to "0" to maintain aspect ratio by height. The third is height. Set the height to "0" to maintain aspect ratio by width. The fourth parameter allows you to specify additional parameters to the image.
<p />
<i>Examples:</i><br>
Retrieving an image by name (no scaling)<br>
^SI(myimage);
<p>
Retrieving an image by collateralId (no scaling)<br>
^SI(8ucfhA1Joswj59UFIubr1Q);
<p>
Scaling by width, maintaining aspect ratio<br>
^SI(8ucfhA1Joswj59UFIubr1Q,25);
<p>
Scaling by height, maintaining aspect ratio<br>
^SI(8ucfhA1Joswj59UFIubr1Q,0,25);
<p>
Playing with the aspect ratio<br>
^SI(8ucfhA1Joswj59UFIubr1Q,148,25);
<p>
Using parameters<br>
^SI(8ucfhA1Joswj59UFIubr1Q,0,0,'border="0"');
<p />
<b>&#94;Snippet();</b><br/>
&#94;Snippet(<i>snippet name</i>);<br/>
This macro retrieves the contents of a snippet in the collateral management system and inserts it into the page. You can optionally specify up to 9 additional parameters that will be replace these special characters in the snippet: ^1; ^2; ^3; ^4; ^5; ^6; ^7; ^8; ^9;
<p />
<i>Example:</i> &#94;Snippet("flash code");
<p />
<b>&#94;Thumbnail();</b><br/>
&#94;Thumbnail(<i>image name</i>);<br/>
This macro retrieves the URL for the thumbnail of any image in the collateral management system.
<p/>
<i>Example:</i> &#94;Thumbnail("logo");
<p/>
|,
lastUpdated => 1101886126,
},
'736' => {
message => q|7 Expert|,
lastUpdated => 1033836692
@ -3222,11 +2985,6 @@ This macro retrieves the URL for the thumbnail of any image in the collateral ma
lastUpdated => 1031514049
},
'781' => {
message => q|Snippet|,
lastUpdated => 1036912954
},
'828' => {
message => q|Most wobjects have templates that allow you to change the layout of the wobject's user interface. Those wobjects that do have templates all have a common set of template variables that you can use for layout, as well as their own custom variables. The following is a list of the common template variables shared among all wobjects.
<p/>
@ -3512,11 +3270,6 @@ The translated label for the link to the home page or the text that you supply t
lastUpdated => 1031514049
},
'409' => {
message => q|Add a new root.|,
lastUpdated => 1031514049
},
'642' => {
message => q|Page, Add/Edit|,
lastUpdated => 1078569027
@ -3898,11 +3651,6 @@ Large sites using external group data will be making many calls to the external
lastUpdated => 1053278089
},
'776' => {
message => q|Edit Folder|,
lastUpdated => 1036905944
},
'894' => {
message => q|Allow discussion?|,
lastUpdated => 1031514049
@ -3934,11 +3682,6 @@ Large sites using external group data will be making many calls to the external
lastUpdated => 1052850265
},
'385' => {
message => q|Parameters|,
lastUpdated => 1031514049
},
'502' => {
message => q|Are you certain you wish to delete this template and set all pages using this template to the default template?|,
lastUpdated => 1031514049
@ -4472,11 +4215,6 @@ The description of this forum as passed by the calling object.
lastUpdated => 1038889471
},
'831' => {
message => q|Collateral Macros|,
lastUpdated => 1050441851
},
'552' => {
message => q|Pending|,
lastUpdated => 1031514049
@ -4497,11 +4235,6 @@ The description of this forum as passed by the calling object.
lastUpdated => 1044705137
},
'780' => {
message => q|File|,
lastUpdated => 1036912946
},
'433' => {
message => q|User Agent|,
lastUpdated => 1031514049
@ -4616,15 +4349,6 @@ div.tabs {
lastUpdated => 1046067380
},
'786' => {
message => q|WebGUI's collateral management system allows you to upload files and text to a central repository for use elsewhere in your site.
<p/>
You can organize collateral into different folders, but names must be unique, even if they are in different folders or of different types. If you attempt to use a name that is already in use, WebGUI will rename the file for you by appending and/or incrementing a number to the end of the name.
<p/>
|,
lastUpdated => 1099512407
},
'440' => {
message => q|Contact Information|,
lastUpdated => 1031514049
@ -4846,11 +4570,6 @@ A list of links to the 10 nearest in the paginator relative to the current page.
lastUpdated => 1031514049
},
'774' => {
message => q|Are you certain you wish to delete this collateral? It cannot be recovered once deleted.|,
lastUpdated => 1036902945
},
'229' => {
message => q|Subject|,
lastUpdated => 1031514049
@ -4871,11 +4590,6 @@ A list of links to the 10 nearest in the paginator relative to the current page.
lastUpdated => 1031514049
},
'770' => {
message => q|Edit Snippet|,
lastUpdated => 1036893050
},
'68' => {
message => q|The account information you supplied is invalid. Either the account does not exist or the username/password combination was incorrect.|,
lastUpdated => 1031514049
@ -4896,28 +4610,6 @@ A list of links to the 10 nearest in the paginator relative to the current page.
lastUpdated => 1031514049
},
'838' => {
message => q|Folders are used to organize collateral, much the same way you'd use folders on your hard drive or in a file cabinet. Unlike files on your hard drive, collateral names must be unique, even if they are in different folders.
<p/>
<b>Organize in Folder</b><br/>
Folders can be inside of other folders. In which folder would you like to put this folder?
<p/>
<b>Name</b><br/>
Give this folder a name so you can recognize what's in it.
<p/>
<b>Description</b><br/>
Describe the folder so that you remember why you created it and what it's supposed to contain.
<p/>|,
lastUpdated => 1094406796
},
'761' => {
message => q|Add an image.|,
lastUpdated => 1036892765
},
'576' => {
message => q|Delete|,
lastUpdated => 1031514049
@ -5083,11 +4775,6 @@ The headings of columns on things like message boards and user contributions.
lastUpdated => 1078243385
},
'777' => {
message => q|Folder Id|,
lastUpdated => 1036905972
},
'464' => {
message => q|Text Area Columns|,
lastUpdated => 1031514049
@ -5208,28 +4895,6 @@ As with any delete operation, you are prompted to be sure you wish to proceed wi
lastUpdated => 1046637952
},
'384' => {
message => q|File|,
lastUpdated => 1031514049
},
'836' => {
message => q|Snippets are bits of text that may be reused on your site. Thinks like java scripts, style sheets, flash animations, or even slogans are all great snippets. Best of all, if you need to change the text, you can change it in only one location.
<p/>
<b>Name</b><br/>
Give your snippet a unique name that you can use later to retrieve it.
<p/>
<b>Organize in Folder</b><br/>
Which collateral folder should contain this snippet?
<p/>
<b>Snippet</b><br/>
Start typing! Or better yet, copy the snippet from some other electronic document and paste it here.
<p/>|,
lastUpdated => 1101775475,
},
'942' => {
message => q|Radio List|,
lastUpdated => 1051464141
@ -5260,11 +4925,6 @@ Start typing! Or better yet, copy the snippet from some other electronic documen
lastUpdated => 1031514049
},
'785' => {
message => q|Collateral, Manage|,
lastUpdated => 1050430118
},
'125' => {
message => q|Company Name|,
lastUpdated => 1031514049
@ -5320,11 +4980,6 @@ Start typing! Or better yet, copy the snippet from some other electronic documen
lastUpdated => 1031514049
},
'779' => {
message => q|Image|,
lastUpdated => 1036912938
},
'551' => {
message => q|Notice|,
lastUpdated => 1031514049
@ -5477,11 +5132,6 @@ Macros always begin with a caret (&#94;) and follow with at least one other char
lastUpdated => 1031514049
},
'771' => {
message => q|Snippet|,
lastUpdated => 1036893079
},
'435' => {
message => q|Session Signature|,
lastUpdated => 1031514049
@ -5532,11 +5182,6 @@ Macros always begin with a caret (&#94;) and follow with at least one other char
lastUpdated => 1031514049
},
'760' => {
message => q|Delete this folder.|,
lastUpdated => 1036892740
},
'1046' => {
message => q|Archived|,
lastUpdated => 1066406723
@ -5929,11 +5574,6 @@ Privileges and styles assigned to pages in the package will not be copied when t
lastUpdated => 1031514049
},
'670' => {
message => q|Image, Add/Edit|,
lastUpdated => 1038871530
},
'929' => {
message => q|Import!|,
lastUpdated => 1050265357
@ -5970,37 +5610,6 @@ Privileges and styles assigned to pages in the package will not be copied when t
context => q|Title of the user manager for the admin console.|
},
'625' => {
message => q|Upload any images that you'll possibly use in more than one location on your site. Image collateral differ from regular file collateral in that thumbnails can be displayed instead of icons and additional parameters can be added to the HTML tag when they are displayed.
<p/>
<b>Name</b><br>
The label that this image will be referenced by to include it into pages.
<p>
<b>Organize In Folder</b><br/>
Which collateral folder should this image be placed in.
<p/>
<b>File</b><br>
Select a file from your local drive to upload to the server.
<p>
<b>Parameters</b><br>
Add any HTML &lt;img&gt; parameters that you wish to act as the defaults for this image.
<p>
<i>Example:</i><br>
align="right"<br>
alt="This is an image"<br>
<p/>
<b>Thumbnail Size</b><br>
How big (in pixels) should the thumbnail for this image be?
<p/>|,
lastUpdated => 1096524176
},
'304' => {
message => q|Language|,
lastUpdated => 1031514049
@ -6056,11 +5665,6 @@ How big (in pixels) should the thumbnail for this image be?
lastUpdated => 1047842270
},
'763' => {
message => q|Add a snippet.|,
lastUpdated => 1036892785
},
'70' => {
message => q|Error|,
lastUpdated => 1031514049
@ -6184,11 +5788,6 @@ You can move an existing forum to another Message Board. If set to 'No Change' t
lastUpdated => 1101775516,
},
'793' => {
message => q|Pieces of Collateral|,
lastUpdated => 1036971785
},
'88' => {
message => q|Users In Group|,
lastUpdated => 1031514049
@ -6474,11 +6073,6 @@ A randomly generated number. This is often used on images (such as banner ads) t
lastUpdated => 1031514049
},
'408' => {
message => q|Manage Roots|,
lastUpdated => 1031514049
},
'528' => {
message => q|Template Name|,
lastUpdated => 1031514049
@ -6777,8 +6371,6 @@ The primary URL of your company. This will appear on all automated emails sent f
<P><B>Thumbnail Size</B><BR>When images are uploaded to your system, they will automatically have thumbnails generated at the size specified here (unless overridden on a case-by-case basis). Thumbnail size is measured in pixels.
<P><B>Snippet Preview Length</B><BR>How many characters of a snippet should be displayed in the collateral management system main listing.
<B>Text Area Rows</B>, <B>Text Area Columns</B> and <B>Text Box Size</B> allow the size of
forms that WebGUI generates to be customized on a site-by-site basis.