added folder

This commit is contained in:
JT Smith 2005-01-29 16:32:11 +00:00
parent 3156da1999
commit 7d1225d702
8 changed files with 208 additions and 8 deletions

View file

@ -8,6 +8,7 @@
attached.
- Added AssetProxy macro, which replaces the Navigation, I, Snippet, and File
macros.
- Added Folder asset type.
- Added the RandomAssetProxy macro, which replaces the RandomImage and
RandomSnippet macros.
- Renamed the i macro to FileUrl.

View file

@ -668,7 +668,6 @@ $conf->set("paymentPlugins"=>"ITransact");
$conf->set("macros"=>$macros);
$conf->set("assets"=>[
'WebGUI::Asset::Wobject::Navigation',
'WebGUI::Asset::Wobject::Layout',
'WebGUI::Asset::Wobject::Poll',
'WebGUI::Asset::Wobject::Article',
'WebGUI::Asset::Wobject::DataForm',
@ -685,6 +684,10 @@ $conf->set("assets"=>[
'WebGUI::Asset::File::Image',
'WebGUI::Asset::Snippet'
]);
$conf->set("assetContainers"=>[
'WebGUI::Asset::Wobject::Folder',
'WebGUI::Asset::Wobject::Layout'
]);
$conf->write;
@ -1215,12 +1218,14 @@ sub getNewId {
'Auth/WebGUI/Create' => {
'1' => 'PBtmpl0000000000000011'
},
'Folder' => {
'15' => 'PBtmpl0000000000000078'
},
'Layout' => {
'6' => 'PBtmpl0000000000000131',
'3' => 'PBtmpl0000000000000109',
'7' => 'PBtmpl0000000000000135',
'2' => 'PBtmpl0000000000000094',
'15' => 'PBtmpl0000000000000078',
'1' => 'PBtmpl0000000000000054',
'4' => 'PBtmpl0000000000000118',
'5' => 'PBtmpl0000000000000125'

View file

@ -94,6 +94,11 @@ create table Layout (
contentPositions text
);
create table Folder (
assetId varchar(22) not null primary key,
templateId varchar(22) not null
);
create table FileAsset (
assetId varchar(22) not null primary key,
storageId varchar(22) not null,
@ -216,7 +221,7 @@ INSERT INTO template VALUES ('1','Default Page','<a href=\"<tmpl_var assetId>\">
INSERT INTO template VALUES ('1','File','<tmpl_if session.var.adminOn>\r\n<p><tmpl_var controls></p>\r\n</tmpl_if>\r\n<a href=\"<tmpl_var fileUrl>\"><img src=\"<tmpl_var fileIcon>\" alt=\"<tmpl_var title>\" border=\"0\" /><tmpl_var filename></a>','FileAsset',1,1);
INSERT INTO template VALUES ('2','Image','<tmpl_if session.var.adminOn>\r\n<p><tmpl_var controls></p>\r\n</tmpl_if>\r\n<img src=\"<tmpl_var fileUrl>\" <tmpl_var parameters> />','ImageAsset',1,1);
INSERT INTO template VALUES ('15','File Folder','<a href=\"<tmpl_var assetId>\"></a>\r\n<tmpl_if showAdmin>\r\n<p><tmpl_var controls></p>\r\n</tmpl_if>\r\n\r\n<tmpl_if displayTitle>\r\n <h1><tmpl_var title></h1>\r\n</tmpl_if>\r\n\r\n<tmpl_if description>\r\n <p><tmpl_var description></p>\r\n</tmpl_if>\r\n\r\n\r\n<tmpl_if sublayout_loop>\r\n<div style=\"clear: both;\">&nbsp;</div>\r\n</tmpl_if>\r\n\r\n<tmpl_loop sublayout_loop>\r\n <div style=\"float: left; width: 180px; text-align: center;\">\r\n <a href=\"<tmpl_var url>\"><img src=\"<tmpl_var session.config.extrasURL>/assets/folder.gif\" border=\"0\" alt=\"Folder\" /><br /><tmpl_var title></a> \r\n </div>\r\n</tmpl_loop>\r\n\r\n<tmpl_if sublayout_loop>\r\n<div style=\"clear: both;\">&nbsp;</div>\r\n</tmpl_if>\r\n\r\n\r\n<div style=\"clear: both;\">&nbsp;</div>\r\n\r\n<tmpl_loop position1_loop>\r\n <div style=\"float: left; width: 180px; text-align: center;\">\r\n <tmpl_var content>\r\n </div>\r\n</tmpl_loop>\r\n\r\n<div style=\"clear: both;\">&nbsp;</div>\r\n','page',1,1);
INSERT INTO template VALUES ('15','File Folder','<a name=\"<tmpl_var assetId>\"></a><tmpl_if session.var.adminOn>\r\n <p><tmpl_var controls></p>\r\n</tmpl_if>\r\n\r\n<tmpl_if displayTitle>\r\n <h1><tmpl_var title></h1>\r\n</tmpl_if>\r\n\r\n<tmpl_if description>\r\n <p><tmpl_var description></p>\r\n</tmpl_if>\r\n\r\n<table width=\"100%\" cellpadding=\"3\" cellspacing=\"0\" class=\"content\">\r\n<tmpl_loop subfolder_loop>\r\n<tr>\r\n <td class=\"tableData\"><a href=\"<tmpl_var url>\"><img src=\"<tmpl_var icon.small>\" border=\"0\" alt=\"<tmpl_var title>\"></a></td>\r\n <td colspan=\"4\" class=\"tableData\"><a href=\"<tmpl_var url>\"><tmpl_var title></td>\r\n</tr>\r\n</tmpl_loop>\r\n<tmpl_loop file_loop>\r\n<tr>\r\n <td class=\"tableData\"><a href=\"<tmpl_var url>\"><img src=\"<tmpl_var icon.small>\" border=\"0\" alt=\"<tmpl_var title>\"></a></td>\r\n <td class=\"tableData\"><a href=\"<tmpl_var url>\"><tmpl_var title></td>\r\n <td class=\"tableData\"><tmpl_var type></td>\r\n <td class=\"tableData\">^D(\"%z %Z\",<tmpl_var date.epoch>);</td>\r\n <td class=\"tableData\"><tmpl_var size></td>\r\n</tr>\r\n</tmpl_loop>\r\n\r\n</table>', 'Folder',1,1);
alter table HttpProxy add column cookieJarStorageId varchar(22);

View file

@ -2,7 +2,6 @@ assets = WebGUI::Asset::File::Image, \
WebGUI::Asset::File, \
WebGUI::Asset::Snippet, \
WebGUI::Asset::Redirect, \
WebGUI::Asset::Wobject::Layout, \
WebGUI::Asset::Wobject::USS, \
WebGUI::Asset::Wobject::Poll, \
WebGUI::Asset::Wobject::SyndicatedContent, \
@ -14,6 +13,9 @@ assets = WebGUI::Asset::File::Image, \
WebGUI::Asset::Wobject::Survey, \
WebGUI::Asset::FilePile
assetContainers = WebGUI::Asset::Wobject::Layout, \
WebGUI::Asset::Wobject::Folder
sitename = www.example.com, example.com
dsn = DBI:mysql:www_example_com

View file

@ -666,7 +666,7 @@ sub getAssetAdderLinks {
WebGUI::ErrorHandler::warn("Couldn't get the name of ".$class." because ".$@);
} else {
my $url = $self->getUrl("func=add&class=".$class);
$url .= "&".$addToUrl if ($addToUrl);
$url = WebGUI::URL::append($url,$addToUrl) if ($addToUrl);
push(@links, {
label=>$label,
url=>$url
@ -2245,7 +2245,6 @@ Saves and updates history. If canEdit, returns www_manageAssets() if a new Asset
sub www_editSave {
my $self = shift;
WebGUI::ErrorHandler::warn("got here");
return $self->getAdminConsole->render(WebGUI::Privilege::insufficient()) unless $self->canEdit;
my $object;
if ($session{form}{assetId} eq "new") {

View file

@ -116,7 +116,7 @@ sub definition {
},
namespace=>{
fieldType=>'combo',
defaultValue=>'style'
defaultValue=>undef
}
}
});
@ -192,7 +192,7 @@ Specify the namespace to build the list for.
sub getList {
my $class = shift;
my $namespace = shift;
return WebGUI::SQL->buildHashRef("select asset.assetId,asset.title from template left join asset on asset.assetId=template.assetId where template.namespace=".quote($namespace)." and template.showInForms=1 order by asset.title",WebGUI::SQL->getSlave);
return WebGUI::SQL->buildHashRef("select asset.assetId,asset.title from template left join asset on asset.assetId=template.assetId where template.namespace=".quote($namespace)." and template.showInForms=1 and state='published' order by asset.title",WebGUI::SQL->getSlave);
}

View file

@ -0,0 +1,183 @@
package WebGUI::Asset::Wobject::Folder;
=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 WebGUI::Asset::Wobject;
use WebGUI::Icon;
use WebGUI::Session;
use WebGUI::Utility;
our @ISA = qw(WebGUI::Asset::Wobject);
=head1 NAME
Package WebGUI::Asset::Wobject::Folder
=head1 DESCRIPTION
Display a list of assets and sub folders just like in an operating system filesystem.
=head1 SYNOPSIS
use WebGUI::Asset::Wobject::Folder;
=head1 METHODS
These methods are available from this class:
=cut
#-------------------------------------------------------------------
=head2 definition ( definition )
Defines the properties of this asset.
=head3 definition
A hash reference passed in from a subclass definition.
=cut
sub definition {
my $class = shift;
my $definition = shift;
push(@{$definition}, {
tableName=>'Folder',
className=>'WebGUI::Asset::Wobject::Folder',
properties=>{
templateId =>{
fieldType=>"template",
defaultValue=>'PBtmpl0000000000000054'
}
}
});
return $class->SUPER::definition($definition);
}
#-------------------------------------------------------------------
=head2 getEditForm ()
Returns the TabForm object that will be used in generating the edit page for this asset.
=cut
sub getEditForm {
my $self = shift;
my $tabform = $self->SUPER::getEditForm();
$tabform->getTab("display")->template(
-value=>$self->getValue('templateId'),
-namespace=>"Folder"
);
#if ($self->get("assetId") eq "new") {
# $tabform->getTab("properties")->whatNext(
# -options=>{
# gotoNewPage=>WebGUI::International::get(823),
# backToPage=>WebGUI::International::get(847)
# },
# );
# }
return $tabform;
}
#-------------------------------------------------------------------
sub getIcon {
my $self = shift;
my $small = shift;
return $session{config}{extrasURL}.'/assets/small/folder.gif' if ($small);
return $session{config}{extrasURL}.'/assets/folder.gif';
}
#-------------------------------------------------------------------
=head2 getName ()
Returns the displayable name of this asset.
=cut
sub getName {
return "Folder";
}
#-------------------------------------------------------------------
=head2 getUiLevel ()
Returns the UI level of this asset.
=cut
sub getUiLevel {
return 5;
}
#-------------------------------------------------------------------
sub view {
my $self = shift;
my $children = $self->getLineage( ["children"], { returnObjects=>1 });
my %vars;
foreach my $child (@{$children}) {
if (ref $child eq "WebGUI::Asset::Wobject::Folder") {
push(@{$vars{"subfolder_loop"}}, {
id => $child->getId,
url => $child->getUrl,
title => $child->get("title")
});
} else {
my $isImage = (ref $child =~ /^WebGUI::Asset::File::Image/);
my $thumbnail = $child->getThumbnailUrl if ($isImage);
my $isFile = (ref $child =~ /^WebGUI::Asset::File/);
my $file = $child->getFileUrl if ($isFile);
push(@{$vars{"file_loop"}},{
id=>$child->getId,
title=>$child->get("title"),
size=>WebGUI::Utility::formatBytes($child->get("assetSize")),
"date.epoch"=>$child->get("dateStamp"),
"icon.small"=>$child->getIcon(1),
"icon.big"=>$child->getIcon,
type=>$child->getName,
url=>$child->getUrl,
isImage=>$isImage,
isImage=>$isFile,
"thumbnail.url"=>$thumbnail,
"file.url"=>$file
});
}
}
return $self->processTemplate(\%vars,$self->get("templateId"));
}
sub www_edit {
my $self = shift;
return $self->getAdminConsole->render(WebGUI::Privilege::insufficient()) unless $self->canEdit;
return $self->getAdminConsole->render($self->getEditForm->print,"Edit Folder");
}
1;

View file

@ -20,6 +20,11 @@ our $I18N = {
context => q|The name of the properties tab on the edit page.|
},
'make package' => {
message => q|Make package?|,
lastUpdated => 1099344172,
},
'asset id' => {
message => q|Asset ID|,
lastUpdated => 1099344172,