WebGUI 3.3.0 release
This commit is contained in:
parent
40bb7fed59
commit
80f7752f32
41 changed files with 1662 additions and 402 deletions
109
docs/create.sql
109
docs/create.sql
File diff suppressed because one or more lines are too long
|
|
@ -13,4 +13,7 @@ Spanish Translation..................Ricardo Markiewicz
|
|||
Portuguese Translation...............Jose Caneira
|
||||
Dutch Translation....................Joeri de Bruin
|
||||
mod_rewrite Support..................Peter Beardsley / Appropriate Solutions, Inc.
|
||||
Oracle testing.......................Richard Caelius
|
||||
Image Manager concept................Frank Dillon
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,12 @@ upgrading from one version to the next, or even between multiple
|
|||
versions. Be sure to heed the warnings contained herein as they will
|
||||
save you many hours of grief.
|
||||
|
||||
3.3.0
|
||||
--------------------------------------------------------------------
|
||||
* You need to get a new Perl module before you upgrade. It is
|
||||
Image::Magick. On some systems you may also need to download
|
||||
and compile the C compliment to it from www.imagemagick.org.
|
||||
|
||||
3.2.1
|
||||
--------------------------------------------------------------------
|
||||
* We released a faulty upgrade script with 3.2.0. If you happened
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ QnD INSTALL INSTRUCTIONS:
|
|||
Tie::CPHash
|
||||
Date::Calc
|
||||
HTML::CalendarMonthSimple
|
||||
Image::Magick
|
||||
|
||||
3. Install Apache (with or without mod_perl) and set up your config.
|
||||
|
||||
|
|
|
|||
|
|
@ -2781,3 +2781,6 @@ CREATE TABLE widget (
|
|||
|
||||
INSERT INTO widget VALUES (-1,4,'SiteMap',0,'Page Not Found',1,'The page you were looking for could not be found on this system. Perhaps it has been deleted or renamed. The following list is a site map of this site. If you don\'t find what you\'re looking for on the site map, you can always start from the <a href=\"^/;\">Home Page</a>.',1,1001744792,3,1013215663,3,'A');
|
||||
|
||||
insert into international values (403,'WebGUI','English','Prefer not to say.');
|
||||
alter table users change column gender gender varchar(6) not null default 'neuter';
|
||||
|
||||
|
|
|
|||
27
docs/upgrades/upgrade_3.2.4-3.3.0.sql
Normal file
27
docs/upgrades/upgrade_3.2.4-3.3.0.sql
Normal file
File diff suppressed because one or more lines are too long
5
etc/some_other_site.conf
Normal file
5
etc/some_other_site.conf
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
dsn = DBI:mysql:some_other_site
|
||||
dbuser = webgui
|
||||
dbpass = password
|
||||
logfile = /data/webgui.log
|
||||
#scripturl = /
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
package WebGUI;
|
||||
our $VERSION = "3.2.4";
|
||||
our $VERSION = "3.3.0";
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2002 Plain Black Software.
|
||||
|
|
@ -148,7 +148,7 @@ sub _loadWidgets {
|
|||
#-------------------------------------------------------------------
|
||||
sub page {
|
||||
my (%contentHash, $cmd, $pageEdit, $widgetType, $functionOutput, @availableWidgets, @widgetList, $sth, $httpHeader, $header, $footer, $content, $operationOutput, $adminBar);
|
||||
WebGUI::Session::open($_[0]);
|
||||
WebGUI::Session::open($_[0],$_[1]);
|
||||
# For some reason we have to pre-cache the templates when running under mod_perl
|
||||
# so that's what we're doing with this next command.
|
||||
WebGUI::Template::loadTemplates();
|
||||
|
|
|
|||
|
|
@ -1,142 +1,344 @@
|
|||
package WebGUI::Attachment;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2002 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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
|
||||
#-------------------------------------------------------------------
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2002 Plain Black Software.
|
||||
-------------------------------------------------------------------
|
||||
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 File::Copy cp;
|
||||
use File::Path;
|
||||
use FileHandle;
|
||||
use Image::Magick;
|
||||
use POSIX;
|
||||
use strict;
|
||||
use WebGUI::ErrorHandler;
|
||||
use WebGUI::Node;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::URL;
|
||||
use WebGUI::Utility;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Attachment
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use WebGUI::Attachment;
|
||||
$attachment = WebGUI::Attachment->new("file.txt","100","20");
|
||||
$attachment->copy("files","10");
|
||||
$attachment->delete;
|
||||
$attachment->deleteNode;
|
||||
$attachment->getFilename;
|
||||
$attachment->getIcon;
|
||||
$attachment->getPath;
|
||||
$attachment->getThumbnail;
|
||||
$attachment->getType;
|
||||
$attachment->getURL;
|
||||
$attachment->save("formImage");
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Package to manipulate WebGUI Attachments.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# eg: copy(filename,oldWidgetId,newWidgetId,oldSubId,newSubId);
|
||||
sub copy {
|
||||
my ($a, $b, $newFile, $oldFile);
|
||||
if ($_[0] ne "") {
|
||||
$oldFile = $session{setting}{attachmentDirectoryLocal}.'/'.$_[1];
|
||||
if ($_[3] ne "") {
|
||||
$oldFile .= '/'.$_[3];
|
||||
sub _createThumbnail {
|
||||
my ($image, $error, $x, $y, $r, $n);
|
||||
if (isIn($_[0]->getType, qw(jpg jpeg gif png tif tiff bmp))) {
|
||||
$image = Image::Magick->new;
|
||||
$error = $image->Read($_[0]->getPath);
|
||||
WebGUI::ErrorHandler::warning($error) if $error;
|
||||
($x, $y) = $image->Get('width','height');
|
||||
$n = $_[1] || $session{setting}{thumbnailSize};
|
||||
$r = $x>$y ? $x / $n : $y / $n;
|
||||
$image->Scale(width=>($x/$r),height=>($y/$r));
|
||||
if (isIn($_[0]->getType, qw(tif tiff bmp))) {
|
||||
$error = $image->Write($_[0]->{_node}->getPath.'/thumb-'.$_[0]->getFilename.'.png');
|
||||
} else {
|
||||
$error = $image->Write($_[0]->{_node}->getPath.'/thumb-'.$_[0]->getFilename);
|
||||
}
|
||||
$oldFile .= '/'.$_[0];
|
||||
$newFile = $session{setting}{attachmentDirectoryLocal}.'/'.$_[2];
|
||||
mkdir ($newFile,0755);
|
||||
if ($_[4] ne "") {
|
||||
$newFile .= '/'.$_[4];
|
||||
mkdir ($newFile,0755);
|
||||
}
|
||||
$newFile .= '/'.$_[0];
|
||||
$a = FileHandle->new($oldFile,"r");
|
||||
$b = FileHandle->new(">".$newFile);
|
||||
binmode($a);
|
||||
binmode($b);
|
||||
cp($a,$b);
|
||||
$a->close;
|
||||
$b->close;
|
||||
WebGUI::ErrorHandler::warning($error) if $error;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub deleteSubmission {
|
||||
my ($dir);
|
||||
$dir = $session{setting}{attachmentDirectoryLocal}.'/'.$_[0].'/'.$_[1];
|
||||
rmtree($dir);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub getType {
|
||||
my ($extension, $icon, %type);
|
||||
$extension = lc($_[0]);
|
||||
$extension =~ s/.*?\.(.*?)$/$1/;
|
||||
if ($extension eq "doc" || $extension eq "dot" || $extension eq "wri") {
|
||||
$icon = $session{setting}{lib}."/fileIcons/doc.gif";
|
||||
} elsif ($extension eq "txt" || $extension eq "log" || $extension eq "config" || $extension eq "conf") {
|
||||
$icon = $session{setting}{lib}."/fileIcons/txt.gif";
|
||||
} elsif ($extension eq "xls" || $extension eq "xlt" || $extension eq "csv") {
|
||||
$icon = $session{setting}{lib}."/fileIcons/xls.gif";
|
||||
} elsif ($extension eq "html" || $extension eq "htm" || $extension eq "xml") {
|
||||
$icon = $session{setting}{lib}."/fileIcons/html.gif";
|
||||
} elsif ($extension eq "ram" || $extension eq "mpeg" || $extension eq "mpg" ||
|
||||
$extension eq "wav" || $extension eq "mp3" || $extension eq "avi") {
|
||||
$icon = $session{setting}{lib}."/fileIcons/html.gif";
|
||||
} elsif ($extension eq "html" || $extension eq "htm" || $extension eq "xml") {
|
||||
$icon = $session{setting}{lib}."/fileIcons/html.gif";
|
||||
} elsif ($extension eq "rar" || $extension eq "tgz" || $extension eq "tar.gz" ||
|
||||
$extension eq "tar" || $extension eq "gz" || $extension eq "Z") {
|
||||
$icon = $session{setting}{lib}."/fileIcons/rar.gif";
|
||||
|
||||
=head2 copy ( newNode [, newNodeSub ] )
|
||||
|
||||
Copies an attachment from one node to another.
|
||||
|
||||
=item newNode
|
||||
|
||||
Define the node to copy the attachment to.
|
||||
|
||||
=item newNodeSub
|
||||
|
||||
If there is a subordinate element on this node define it here.
|
||||
|
||||
=cut
|
||||
|
||||
sub copy {
|
||||
my ($a, $b, $newNode);
|
||||
$newNode = WebGUI::Node->new($_[1],$_[2]);
|
||||
$a = FileHandle->new($_[0]->getPath,"r");
|
||||
$b = FileHandle->new(">".$newNode->getPath.'/'.$_[0]->getFilename);
|
||||
binmode($a);
|
||||
binmode($b);
|
||||
cp($a,$b);
|
||||
$a->close;
|
||||
$b->close;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 delete ( )
|
||||
|
||||
Deletes an attachment from its node.
|
||||
|
||||
=cut
|
||||
|
||||
sub delete {
|
||||
unlink($_[0]->getPath);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 deleteNode ( )
|
||||
|
||||
Deletes deletes this attachment's node (and everything in it).
|
||||
|
||||
=cut
|
||||
|
||||
sub deleteNode {
|
||||
rmtree($_[0]->{_node}->getPath);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getFilename ( )
|
||||
|
||||
Returns the attachment's filename.
|
||||
|
||||
=cut
|
||||
|
||||
sub getFilename {
|
||||
return $_[0]->{_filename};
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getIcon ( )
|
||||
|
||||
Returns the full URL to the file icon for this attachment.
|
||||
|
||||
=cut
|
||||
|
||||
sub getIcon {
|
||||
my ($extension, $icon);
|
||||
$extension = $_[0]->getType;
|
||||
$icon = $session{setting}{lib}."/fileIcons/";
|
||||
if (isIn($extension, qw(doc dot wri))) {
|
||||
$icon .= "doc.gif";
|
||||
} elsif (isIn($extension, qw(txt log config conf))) {
|
||||
$icon .= "txt.gif";
|
||||
} elsif (isIn($extension, qw(xlt csv xls))) {
|
||||
$icon .= "xls.gif";
|
||||
} elsif (isIn($extension, qw(ram mpeg mpg wav mp3 avi))) {
|
||||
$icon .= "wav.gif";
|
||||
} elsif (isIn($extension, qw(html htm xml))) {
|
||||
$icon .= "html.gif";
|
||||
} elsif (isIn($extension, qw(exe com bat pif))) {
|
||||
$icon .= "exe.gif";
|
||||
} elsif (isIn($extension, qw(sit hqx))) {
|
||||
$icon .= "sit.gif";
|
||||
} elsif (isIn($extension, qw(tgz gz tar Z))) {
|
||||
$icon .= "gz.gif";
|
||||
} elsif ($extension eq "rar") {
|
||||
$icon .= "rar.gif";
|
||||
} elsif ($extension eq "mdb") {
|
||||
$icon = $session{setting}{lib}."/fileIcons/mdb.gif";
|
||||
$icon .= "mdb.gif";
|
||||
} elsif ($extension eq "ppt") {
|
||||
$icon = $session{setting}{lib}."/fileIcons/ppt.gif";
|
||||
} elsif ($extension eq "tiff" || $extension eq "tif" || $extension eq "bmp" ||
|
||||
$extension eq "psd" ||$extension eq "psp" || $extension eq "gif" ||
|
||||
$extension eq "jpg" || $extension eq "jpeg") {
|
||||
$icon = $session{setting}{lib}."/fileIcons/psp.gif";
|
||||
$icon .= "ppt.gif";
|
||||
} elsif (isIn($extension, qw(psd eps ai))) {
|
||||
$icon .= "psd.gif";
|
||||
} elsif (isIn($extension, qw(tiff tif bmp psp gif jpg jpeg png))) {
|
||||
$icon .= "psp.gif";
|
||||
} elsif ($extension eq "zip") {
|
||||
$icon = $session{setting}{lib}."/fileIcons/zip.gif";
|
||||
$icon .= "zip.gif";
|
||||
} elsif ($extension eq "mov") {
|
||||
$icon = $session{setting}{lib}."/fileIcons/mov.gif";
|
||||
$icon .= "mov.gif";
|
||||
} elsif ($extension eq "pdf") {
|
||||
$icon = $session{setting}{lib}."/fileIcons/pdf.gif";
|
||||
$icon .= "pdf.gif";
|
||||
} else {
|
||||
$icon = $session{setting}{lib}."/fileIcons/unknown.gif";
|
||||
$icon .= "unknown.gif";
|
||||
}
|
||||
%type = (extension => $extension, icon => $icon);
|
||||
return %type;
|
||||
return $icon;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub purgeWidget {
|
||||
my ($dir);
|
||||
$dir = $session{setting}{attachmentDirectoryLocal}.'/'.$_[0];
|
||||
rmtree($dir);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# eg: save(formVarName,widgetId,optionallySubmissionId);
|
||||
|
||||
=head2 getPath ( )
|
||||
|
||||
Returns a full path to an attachment.
|
||||
|
||||
=cut
|
||||
|
||||
sub getPath {
|
||||
return $_[0]->{_node}->getPath.'/'.$_[0]->getFilename;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getThumbnail ( )
|
||||
|
||||
Returns a full URL to the thumbnail for this attachment. Thumbnails
|
||||
are only created for jpg, gif, png, tif, and bmp so getThumbnail
|
||||
only returns a thumbnail if the file is one of those types.
|
||||
|
||||
=cut
|
||||
|
||||
sub getThumbnail {
|
||||
if (isIn($_[0]->getType, qw(jpg jpeg gif png))) {
|
||||
return $_[0]->{_node}->getURL.'/thumb-'.$_[0]->getFilename;
|
||||
} elsif (isIn($_[0]->getType, qw(tif tiff bmp))) {
|
||||
return $_[0]->{_node}->getURL.'/thumb-'.$_[0]->getFilename.'.png';
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getType ( )
|
||||
|
||||
Returns the extension or type of this attachment.
|
||||
|
||||
=cut
|
||||
|
||||
sub getType {
|
||||
my ($extension);
|
||||
$extension = $_[0]->getFilename;
|
||||
$extension =~ s/.*\.(.*?)$/$1/;
|
||||
return $extension;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getURL ( )
|
||||
|
||||
Returns a full URL to an attachment.
|
||||
|
||||
=cut
|
||||
|
||||
sub getURL {
|
||||
return $_[0]->{_node}->getURL.'/'.$_[0]->getFilename;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( filename, node [, nodeSubordinate ] )
|
||||
|
||||
Constructor.
|
||||
|
||||
=item filename
|
||||
|
||||
What is the filename for this attachment. If you'll be uploading
|
||||
the attachment using the "save" method then you may leave this
|
||||
field blank.
|
||||
|
||||
=item node
|
||||
|
||||
The node where this attachment is (or will be placed).
|
||||
|
||||
=item nodeSubordinate
|
||||
|
||||
The subordinate element of the node where this attachment is (or
|
||||
will be placed).
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my ($class, $filename, $node, $nodeSub) = @_;
|
||||
my $node = WebGUI::Node->new($node, $nodeSub);
|
||||
bless {_node => $node, _filename => $filename}, $class;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 save ( formVariableName [, thumbnailSize ] )
|
||||
|
||||
Grabs an attachment from a form POST and saves it to a node. It
|
||||
then returns the filename of the attachment.
|
||||
|
||||
=item formVariableName
|
||||
|
||||
Provide the form variable name to which the file being uploaded
|
||||
is assigned.
|
||||
|
||||
=item thumbnailSize
|
||||
|
||||
If an image is being uploaded a thumbnail will be generated
|
||||
automatically. By default, WebGUI will create a thumbnail of the
|
||||
size specified in the attachment settings. You can override that
|
||||
size by specifying one here. Size is measured in pixels of the
|
||||
longest side.
|
||||
|
||||
=cut
|
||||
|
||||
sub save {
|
||||
my (%type, $file, $filename, $bytesread, $buffer, $urlizedFilename, $path);
|
||||
$filename = $session{cgi}->upload($_[0]);
|
||||
my ($type, $file, $filename, $bytesread, $buffer, $urlizedFilename, $path);
|
||||
$filename = $session{cgi}->upload($_[1]);
|
||||
if (defined $filename) {
|
||||
if ($filename =~ /([^\/\\]+)$/) {
|
||||
$urlizedFilename = $1;
|
||||
$_[0]->{_filename} = $1;
|
||||
} else {
|
||||
$urlizedFilename = $filename;
|
||||
$_[0]->{_filename} = $filename;
|
||||
}
|
||||
%type = getType($urlizedFilename);
|
||||
if ($type{extension} eq "pl" || $type{extension} eq "perl" || $type{extension} eq "sh" ||
|
||||
$type{extension} eq "cgi" || $type{extension} eq "php" || $type{extension} eq "asp") {
|
||||
$urlizedFilename =~ s/\./\_/g;
|
||||
$urlizedFilename .= ".txt";
|
||||
$type = $_[0]->getType();
|
||||
if (isIn($type, qw(pl perl sh cgi php asp))) {
|
||||
$_[0]->{_filename} =~ s/\./\_/g;
|
||||
$_[0]->{_filename} .= ".txt";
|
||||
}
|
||||
$urlizedFilename = WebGUI::URL::urlize($urlizedFilename);
|
||||
$path = $session{setting}{attachmentDirectoryLocal}."/".$_[1]."/";
|
||||
mkdir ($path,0755);
|
||||
if ($_[2] ne "") {
|
||||
$path = $path.$_[2].'/';
|
||||
mkdir ($path,0755);
|
||||
}
|
||||
$file = FileHandle->new(">".$path.$urlizedFilename);
|
||||
$_[0]->{_filename} = WebGUI::URL::urlize($_[0]->getFilename);
|
||||
$_[0]->{_node}->create();
|
||||
$file = FileHandle->new(">".$_[0]->getPath);
|
||||
if (defined $file) {
|
||||
binmode $file;
|
||||
while ($bytesread=read($filename,$buffer,1024)) {
|
||||
print $file $buffer;
|
||||
}
|
||||
close($file);
|
||||
_createThumbnail($_[0],$_[2]);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
return $urlizedFilename;
|
||||
return $_[0]->getFilename;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,18 +12,19 @@ package WebGUI::Macro::I_imageWithTags;
|
|||
|
||||
use strict;
|
||||
use Tie::CPHash;
|
||||
use WebGUI::Attachment;
|
||||
use WebGUI::Macro;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _replacement {
|
||||
my (@param, $temp, %data);
|
||||
my (@param, $temp, %data, $image);
|
||||
tie %data, 'Tie::CPHash';
|
||||
@param = WebGUI::Macro::getParams($_[0]);
|
||||
%data = WebGUI::SQL->quickHash("select * from images where name='$param[0]'");
|
||||
$temp = '<img src="'.$session{setting}{attachmentDirectoryWeb}.'/images/'.
|
||||
$data{imageId}.'/'.$data{filename}.'" '.$data{parameters}.'>';
|
||||
$image = WebGUI::Attachment->new($data{filename},"images",$data{imageId});
|
||||
$temp = '<img src="'.$image->getURL.'" '.$data{parameters}.'>';
|
||||
return $temp;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,27 +17,47 @@ use WebGUI::Macro::Backslash_pageUrl;
|
|||
use WebGUI::Session;
|
||||
use WebGUI::URL;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _createURL {
|
||||
return '<a href="'.WebGUI::URL::page("op=logout").'">'.$_[0].'</a>';
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _replacement {
|
||||
my ($temp);
|
||||
my ($temp,$boxSize,@param,$text);
|
||||
@param = WebGUI::Macro::getParams($_[0]);
|
||||
$temp = '<div class="loginBox">';
|
||||
if ($session{var}{sessionId}) {
|
||||
$temp .= WebGUI::International::get(48);
|
||||
$temp .= ' <a href="'.WebGUI::URL::page('op=displayAccount').'">'.$session{user}{username}.'</a>.';
|
||||
$temp .= WebGUI::International::get(49);
|
||||
$temp = WebGUI::Macro::Backslash_pageUrl::process($temp);
|
||||
$text = $param[1];
|
||||
if (not defined $text){
|
||||
$temp .= WebGUI::International::get(48);
|
||||
$temp .= ' <a href="'.WebGUI::URL::page('op=displayAccount').
|
||||
'">'.$session{user}{username}.'</a>.';
|
||||
$temp .= WebGUI::International::get(49);
|
||||
$temp = WebGUI::Macro::Backslash_pageUrl::process($temp);
|
||||
} else {
|
||||
$text =~ s/%(.*?)%/_createURL($1)/ge;
|
||||
$temp .= WebGUI::Macro::Backslash_pageUrl::process($text);
|
||||
}
|
||||
} else {
|
||||
$boxSize = $param[0];
|
||||
if (not defined $boxSize) {
|
||||
$boxSize = 12;
|
||||
}
|
||||
if (index(lc($ENV{HTTP_USER_AGENT}),"msie") < 0) {
|
||||
$boxSize = int($boxSize=$boxSize*2/3);
|
||||
}
|
||||
$temp .= '<form method="post" action="'.WebGUI::URL::page().'"> ';
|
||||
$temp .= WebGUI::Form::hidden("op","login").'<span class="formSubtext">';
|
||||
$temp .= WebGUI::International::get(50);
|
||||
$temp .= '<br></span>';
|
||||
$temp .= WebGUI::Form::text("username",12,30).'<span class="formSubtext"><br>';
|
||||
$temp .= WebGUI::Form::text("username",$boxSize,30).'<span class="formSubtext"><br>';
|
||||
$temp .= WebGUI::International::get(51);
|
||||
$temp .= '<br></span>';
|
||||
$temp .= WebGUI::Form::password("identifier",12,30).'<span class="formSubtext"><br></span>';
|
||||
$temp .= WebGUI::Form::password("identifier",$boxSize,30).'<span class="formSubtext"><br></span>';
|
||||
$temp .= WebGUI::Form::submit(WebGUI::International::get(52));
|
||||
$temp .= '</form>';
|
||||
$temp .= '<a href="'.WebGUI::URL::page('op=createAccount').'">Click here to register.</a>';
|
||||
$temp .= '<a href="'.WebGUI::URL::page('op=createAccount').'">'.WebGUI::International::get(407).'</a>';
|
||||
}
|
||||
$temp .= '</div>';
|
||||
return $temp;
|
||||
|
|
@ -47,6 +67,7 @@ sub _replacement {
|
|||
sub process {
|
||||
my ($output, $temp);
|
||||
$output = $_[0];
|
||||
$output =~ s/\^L\((.*?)\)\;/_replacement($1)/ge;
|
||||
$output =~ s/\^L\;/_replacement()/ge;
|
||||
return $output;
|
||||
}
|
||||
|
|
|
|||
40
lib/WebGUI/Macro/Thumbnail.pm
Normal file
40
lib/WebGUI/Macro/Thumbnail.pm
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
package WebGUI::Macro::Thumbnail;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2002 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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::Attachment;
|
||||
use WebGUI::Macro;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _replacement {
|
||||
my (@param, %data, $image);
|
||||
tie %data, 'Tie::CPHash';
|
||||
@param = WebGUI::Macro::getParams($_[0]);
|
||||
%data = WebGUI::SQL->quickHash("select * from images where name='$param[0]'");
|
||||
$image = WebGUI::Attachment->new($data{filename},"images",$data{imageId});
|
||||
return $image->getThumbnail;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my ($output, $temp);
|
||||
$output = $_[0];
|
||||
$output =~ s/\^Thumbnail\((.*?)\)\;/_replacement($1)/ge;
|
||||
return $output;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
|
|
@ -12,18 +12,19 @@ package WebGUI::Macro::i_imageNoTags;
|
|||
|
||||
use strict;
|
||||
use Tie::CPHash;
|
||||
use WebGUI::Attachment;
|
||||
use WebGUI::Macro;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _replacement {
|
||||
my (@param, $temp, %data);
|
||||
my (@param, $image, %data);
|
||||
tie %data, 'Tie::CPHash';
|
||||
@param = WebGUI::Macro::getParams($_[0]);
|
||||
%data = WebGUI::SQL->quickHash("select * from images where name='$param[0]'");
|
||||
$temp = $session{setting}{attachmentDirectoryWeb}.'/images/'.$data{imageId}.'/'.$data{filename};
|
||||
return $temp;
|
||||
$image = WebGUI::Attachment->new($data{filename},"images",$data{imageId});
|
||||
return $image->getURL;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
131
lib/WebGUI/Node.pm
Normal file
131
lib/WebGUI/Node.pm
Normal file
|
|
@ -0,0 +1,131 @@
|
|||
package WebGUI::Node;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2002 Plain Black Software.
|
||||
-------------------------------------------------------------------
|
||||
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 File::Path;
|
||||
use POSIX;
|
||||
use strict;
|
||||
use WebGUI::Session;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Node
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use WebGUI::Node;
|
||||
$node = WebGUI::Node->new("100","20");
|
||||
|
||||
$node->create;
|
||||
$node->delete;
|
||||
$node->getPath;
|
||||
$node->getURL;
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Package to manipulate WebGUI storage nodes. The nodes system is a
|
||||
two-tiered filesystem hash that WebGUI uses to keep attachment
|
||||
data separated. There should be no need for anyone other than
|
||||
Plain Black Software to use this package.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this package:
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 create ( )
|
||||
|
||||
Creates this node on the file system.
|
||||
|
||||
=cut
|
||||
|
||||
sub create {
|
||||
mkdir($session{setting}{attachmentDirectoryLocal}.'/'.$_[0]->{_node1},0755);
|
||||
if ($_[0]->{_node2} ne "") {
|
||||
mkdir($session{setting}{attachmentDirectoryLocal}.'/'.$_[0]->{_node1}.'/'.$_[0]->{_node2},0755);
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 delete ( )
|
||||
|
||||
Deletes this node and its contents (if any) from the filesystem.
|
||||
|
||||
=cut
|
||||
|
||||
sub delete {
|
||||
rmtree($_[0]->getPath);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getPath ( )
|
||||
|
||||
Returns a full path to this node.
|
||||
|
||||
=cut
|
||||
|
||||
sub getPath {
|
||||
my ($path);
|
||||
$path = $session{setting}{attachmentDirectoryLocal}.'/'.$_[0]->{_node1};
|
||||
if ($_[0]->{_node2} ne "") {
|
||||
$path .= '/'.$_[0]->{_node2};
|
||||
}
|
||||
return $path;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getURL ( )
|
||||
|
||||
Returns a full URL to this node.
|
||||
|
||||
=cut
|
||||
|
||||
sub getURL {
|
||||
my ($url);
|
||||
$url = $session{setting}{attachmentDirectoryWeb}.'/'.$_[0]->{_node1};
|
||||
if ($_[0]->{_node2} ne "") {
|
||||
$url .= '/'.$_[0]->{_node2};
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( node1 [, node2 ] )
|
||||
|
||||
Constructor.
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my ($class, $node1, $node2) = @_;
|
||||
bless {_node1 => $node1, _node2 => $node2}, $class;
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
||||
|
|
@ -20,6 +20,7 @@ use WebGUI::ErrorHandler;
|
|||
use WebGUI::Form;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Mail;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Shortcut;
|
||||
|
|
@ -489,7 +490,7 @@ sub www_updateAccount {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_viewMessageLog {
|
||||
my (@data, $output, $sth, @row, $i, $dataRows, $prevNextBar);
|
||||
my (@data, $output, $sth, @row, $i, $p);
|
||||
if (WebGUI::Privilege::isInGroup(2,$session{user}{userId})) {
|
||||
$output = '<h1>'.WebGUI::International::get(159).'</h1>';
|
||||
$sth = WebGUI::SQL->read("select messageLogId,message,url,dateOfEntry from messageLog where userId=$session{user}{userId} order by dateOfEntry desc");
|
||||
|
|
@ -507,16 +508,16 @@ sub www_viewMessageLog {
|
|||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
($dataRows, $prevNextBar) = paginate(50,WebGUI::URL::page('op=viewMessageLog'),\@row);
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=viewMessageLog'),\@row);
|
||||
$output .= '<table width="100%" cellspacing=1 cellpadding=2 border=0>';
|
||||
$output .= '<tr><td class="tableHeader">'.WebGUI::International::get(351).'</td><td class="tableHeader">'.WebGUI::International::get(352).'</td></tr>';
|
||||
if ($dataRows eq "") {
|
||||
if ($p->getPage($session{form}{pn}) eq "") {
|
||||
$output .= '<tr><td rowspan=2 class="tableData">'.WebGUI::International::get(353).'</td></tr>';
|
||||
} else {
|
||||
$output .= $dataRows;
|
||||
$output .= $p->getPage($session{form}{pn});
|
||||
}
|
||||
$output .= '</table>';
|
||||
$output .= $prevNextBar;
|
||||
$output .= $p->getBarSimple($session{form}{pn});
|
||||
$output .= _accountOptions();
|
||||
} else {
|
||||
$output = WebGUI::Privilege::insufficient();
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ our @EXPORT = qw(&www_switchOffAdmin &www_switchOnAdmin);
|
|||
#-------------------------------------------------------------------
|
||||
sub www_switchOffAdmin {
|
||||
if ($session{var}{sessionId}) {
|
||||
WebGUI::SQL->write("update session set adminOn=0 where sessionId='$session{var}{sessionId}'");
|
||||
WebGUI::SQL->write("update userSession set adminOn=0 where sessionId='$session{var}{sessionId}'");
|
||||
WebGUI::Session::refreshSessionVars($session{var}{sessionId});
|
||||
return "";
|
||||
} else {
|
||||
|
|
@ -33,7 +33,7 @@ sub www_switchOffAdmin {
|
|||
#-------------------------------------------------------------------
|
||||
sub www_switchOnAdmin {
|
||||
if ($session{var}{sessionId}) {
|
||||
WebGUI::SQL->write("update session set adminOn=1 where sessionId='$session{var}{sessionId}'");
|
||||
WebGUI::SQL->write("update userSession set adminOn=1 where sessionId='$session{var}{sessionId}'");
|
||||
WebGUI::Session::refreshSessionVars($session{var}{sessionId});
|
||||
return "";
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use Tie::CPHash;
|
|||
use WebGUI::DateTime;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Shortcut;
|
||||
|
|
@ -146,7 +147,7 @@ sub www_editGroupSave {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_listGroups {
|
||||
my ($output, $dataRows, $prevNextBar, $sth, @data, @row, $i);
|
||||
my ($output, $p, $sth, @data, @row, $i);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output = helpLink(10);
|
||||
$output .= '<h1>'.WebGUI::International::get(89).'</h1>';
|
||||
|
|
@ -165,11 +166,11 @@ sub www_listGroups {
|
|||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
($dataRows, $prevNextBar) = paginate(50,WebGUI::URL::page('op=listGroups'),\@row);
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=listGroups'),\@row);
|
||||
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
|
||||
$output .= $dataRows;
|
||||
$output .= $p->getPage($session{form}{pn});
|
||||
$output .= '</table>';
|
||||
$output .= $prevNextBar;
|
||||
$output .= $p->getBarTraditional($session{form}{pn});
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use WebGUI::Attachment;
|
|||
use WebGUI::DateTime;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Shortcut;
|
||||
|
|
@ -56,9 +57,11 @@ sub www_addImageSave {
|
|||
my ($imageId, $file);
|
||||
if (WebGUI::Privilege::isInGroup(4)) {
|
||||
$imageId = getNextId("imageId");
|
||||
$file = WebGUI::Attachment::save("filename","images",$imageId);
|
||||
$file = WebGUI::Attachment->new("newFile","images",$imageId);
|
||||
$file->save("filename");
|
||||
WebGUI::SQL->write("insert into images values ($imageId, ".quote($session{form}{name}).
|
||||
", ".quote($file).", ".quote($session{form}{parameters}).", $session{user}{userId}, ".
|
||||
", ".quote($file->getFilename).", ".quote($session{form}{parameters}).
|
||||
", $session{user}{userId}, ".
|
||||
quote($session{user}{username}).", ".time().")");
|
||||
return www_listImages();
|
||||
} else {
|
||||
|
|
@ -86,8 +89,10 @@ sub www_deleteImage {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteImageConfirm {
|
||||
my ($image);
|
||||
if (WebGUI::Privilege::isInGroup(4)) {
|
||||
WebGUI::Attachment::deleteSubmission("images",$session{form}{iid});
|
||||
$image = WebGUI::Attachment->new("","images",$session{form}{iid});
|
||||
$image->deleteNode;
|
||||
WebGUI::SQL->write("delete from images where imageId=$session{form}{iid}");
|
||||
return www_listImages();
|
||||
} else {
|
||||
|
|
@ -98,7 +103,6 @@ sub www_deleteImageConfirm {
|
|||
#-------------------------------------------------------------------
|
||||
sub www_deleteImageFile {
|
||||
if (WebGUI::Privilege::isInGroup(4)) {
|
||||
WebGUI::Attachment::deleteSubmission("images",$session{form}{iid});
|
||||
WebGUI::SQL->write("update images set filename='' where imageId=$session{form}{iid}");
|
||||
return www_editImage();
|
||||
} else {
|
||||
|
|
@ -108,10 +112,11 @@ sub www_deleteImageFile {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editImage {
|
||||
my ($output, %data);
|
||||
my ($output, %data, $image);
|
||||
tie %data, 'Tie::CPHash';
|
||||
if (WebGUI::Privilege::isInGroup(4)) {
|
||||
%data = WebGUI::SQL->quickHash("select * from images where imageId=$session{form}{iid}");
|
||||
$image = WebGUI::Attachment->new($data{filename},"images",$data{imageId});
|
||||
$output = helpLink(20);
|
||||
$output .= '<h1>'.WebGUI::International::get(382).'</h1>';
|
||||
$output .= formHeader();
|
||||
|
|
@ -135,9 +140,7 @@ sub www_editImage {
|
|||
$output .= formSave();
|
||||
$output .= '</table></form>';
|
||||
if ($data{filename} ne "") {
|
||||
$output .= '<p>'.WebGUI::International::get(390).'<p><img src="'.
|
||||
$session{setting}{attachmentDirectoryWeb}.'/images/'.$session{form}{iid}.
|
||||
'/'.$data{filename}.'">';
|
||||
$output .= '<p>'.WebGUI::International::get(390).'<p><img src="'.$image->getURL.'">';
|
||||
}
|
||||
return $output;
|
||||
} else {
|
||||
|
|
@ -147,15 +150,17 @@ sub www_editImage {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editImageSave {
|
||||
my ($file);
|
||||
my ($file, $sqlAdd);
|
||||
if (WebGUI::Privilege::isInGroup(4)) {
|
||||
$file = WebGUI::Attachment::save("filename","images",$session{form}{iid});
|
||||
if ($file ne "") {
|
||||
$file = ", filename=".quote($file);
|
||||
$file = WebGUI::Attachment->new("","images",$session{form}{iid});
|
||||
$file->save("filename");
|
||||
if ($file->getFilename) {
|
||||
$sqlAdd = ", filename=".quote($file->getFilename);
|
||||
}
|
||||
WebGUI::SQL->write("update images set name=".quote($session{form}{name}).
|
||||
$file.", parameters=".quote($session{form}{parameters}).", userId=$session{user}{userId}, ".
|
||||
" username=".quote($session{user}{username}).", dateUploaded=".time()." where imageId=$session{form}{iid}");
|
||||
$sqlAdd.", parameters=".quote($session{form}{parameters}).", userId=$session{user}{userId}, ".
|
||||
" username=".quote($session{user}{username}).
|
||||
", dateUploaded=".time()." where imageId=$session{form}{iid}");
|
||||
return www_listImages();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
|
|
@ -164,7 +169,7 @@ sub www_editImageSave {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_listImages {
|
||||
my ($output, $sth, %data, @row, $dataRows, $prevNextBar, $i, $search, $isAdmin);
|
||||
my ($output, $sth, %data, @row, $image, $p, $i, $search, $isAdmin);
|
||||
tie %data, 'Tie::CPHash';
|
||||
if (WebGUI::Privilege::isInGroup(4)) {
|
||||
$output = helpLink(26);
|
||||
|
|
@ -173,27 +178,30 @@ sub www_listImages {
|
|||
$output .= '<a href="'.WebGUI::URL::page('op=addImage').'">'.WebGUI::International::get(395).'</a>';
|
||||
$output .= '</td>'.formHeader().'<td align="right">';
|
||||
$output .= WebGUI::Form::hidden("op","listImages");
|
||||
$output .= WebGUI::Form::text("keyword",20,50);
|
||||
$output .= WebGUI::Form::text("keyword",20,50,$session{form}{keyword});
|
||||
$output .= WebGUI::Form::submit(WebGUI::International::get(170));
|
||||
$output .= '</td></form></tr></table><p>';
|
||||
if ($session{form}{keyword} ne "") {
|
||||
$search = " where (name like '%".$session{form}{keyword}.
|
||||
"%' or username like '%".$session{form}{keyword}.
|
||||
"%' or filename like '%".$session{form}{keyword}."%') ";
|
||||
}
|
||||
$isAdmin = WebGUI::Privilege::isInGroup(3);
|
||||
$sth = WebGUI::SQL->read("select * from images $search order by name");
|
||||
while (%data = $sth->hash) {
|
||||
$image = WebGUI::Attachment->new($data{filename},"images",$data{imageId});
|
||||
$row[$i] = '<tr class="tableData"><td>';
|
||||
if ($session{user}{userId} == $data{userId} || $isAdmin) {
|
||||
$row[$i] .= '<a href="'.WebGUI::URL::page('op=deleteImage&iid='.$data{imageId}).
|
||||
'"><img src="'.$session{setting}{lib}.'/delete.gif" border=0></a>';
|
||||
$row[$i] .= '<a href="'.WebGUI::URL::page('op=editImage&iid='.$data{imageId}).
|
||||
'"><img src="'.$session{setting}{lib}.'/edit.gif" border=0></a>';
|
||||
} else {
|
||||
$row[$i] .= '<a href="'.WebGUI::URL::page('op=viewImage&iid='.$data{imageId}).
|
||||
'"><img src="'.$session{setting}{lib}.'/view.gif" border=0></a>';
|
||||
}
|
||||
$row[$i] .= '<a href="'.WebGUI::URL::page('op=viewImage&iid='.$data{imageId}).
|
||||
'"><img src="'.$session{setting}{lib}.'/view.gif" border=0></a>';
|
||||
$row[$i] .= '</td>';
|
||||
$row[$i] .= '<td><a href="'.WebGUI::URL::page('op=viewImage&iid='.$data{imageId}).
|
||||
'"><img src="'.$image->getThumbnail.'" border="0"></a>';
|
||||
$row[$i] .= '<td>'.$data{name}.'</td>';
|
||||
$row[$i] .= '<td>'.$data{username}.'</td>';
|
||||
$row[$i] .= '<td>'.WebGUI::DateTime::epochToHuman($data{dateUploaded},"%M/%D/%y").'</td>';
|
||||
|
|
@ -201,11 +209,11 @@ sub www_listImages {
|
|||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
($dataRows, $prevNextBar) = paginate(50,WebGUI::URL::page('op=listImages'),\@row);
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=listImages'),\@row);
|
||||
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
|
||||
$output .= $dataRows;
|
||||
$output .= $p->getPage($session{form}{pn});
|
||||
$output .= '</table>';
|
||||
$output .= $prevNextBar;
|
||||
$output .= $p->getBarTraditional($session{form}{pn});
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
|
|
@ -214,10 +222,11 @@ sub www_listImages {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_viewImage {
|
||||
my ($output, %data);
|
||||
my ($output, %data, $image);
|
||||
tie %data, 'Tie::CPHash';
|
||||
if (WebGUI::Privilege::isInGroup(4)) {
|
||||
%data = WebGUI::SQL->quickHash("select * from images where imageId=$session{form}{iid}");
|
||||
$image = WebGUI::Attachment->new($data{filename},"images",$data{imageId});
|
||||
$output .= '<h1>'.WebGUI::International::get(396).'</h1>';
|
||||
$output .= '<a href="'.WebGUI::URL::page('op=listImages').'">'.WebGUI::International::get(397).'</a>';
|
||||
$output .= '<table>';
|
||||
|
|
@ -229,8 +238,7 @@ sub www_viewImage {
|
|||
$output .= tableFormRow(WebGUI::International::get(388),
|
||||
WebGUI::DateTime::epochToHuman($data{dateUploaded},"%M/%D/%y"));
|
||||
$output .= '</table>';
|
||||
$output .= '<p><img src="'.$session{setting}{attachmentDirectoryWeb}.'/images/'.$session{form}{iid}.
|
||||
'/'.$data{filename}.'">';
|
||||
$output .= '<p><img src="'.$image->getURL.'">';
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use Exporter;
|
|||
use strict;
|
||||
use Tie::IxHash;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Shortcut;
|
||||
|
|
@ -26,7 +27,7 @@ our @EXPORT = qw(&www_search);
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_search {
|
||||
my ($dataRows, $prevNextBar, $output, %page, @keyword, $pageId, $term, %result, $sth, @data, @row, $i);
|
||||
my ($p, $output, %page, @keyword, $pageId, $term, %result, $sth, @data, @row, $i);
|
||||
tie %result,'Tie::IxHash';
|
||||
$output = formHeader();
|
||||
$output .= WebGUI::Form::hidden("op","search");
|
||||
|
|
@ -69,10 +70,10 @@ sub www_search {
|
|||
}
|
||||
}
|
||||
if ($row[0] ne "") {
|
||||
($dataRows, $prevNextBar) = paginate(20,WebGUI::URL::page('op=search'),\@row);
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=search'),\@row,20);
|
||||
$output .= WebGUI::International::get(365).'<p><ol>';
|
||||
$output .= $dataRows;
|
||||
$output .= '</ol>'.$prevNextBar;
|
||||
$output .= $p->getPage($session{form}{pn});
|
||||
$output .= '</ol>'.$p->getBarTradiational($session{form}{pn});
|
||||
} else {
|
||||
$output .= WebGUI::International::get(366);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,10 +111,16 @@ sub www_editFileSettings {
|
|||
$output .= formHeader();
|
||||
$output .= WebGUI::Form::hidden("op","editFileSettingsSave");
|
||||
$output .= '<table>';
|
||||
$output .= tableFormRow(WebGUI::International::get(129),WebGUI::Form::text("lib",30,255,$session{setting}{lib}));
|
||||
$output .= tableFormRow(WebGUI::International::get(130),WebGUI::Form::text("maxAttachmentSize",30,11,$session{setting}{maxAttachmentSize}));
|
||||
$output .= tableFormRow(WebGUI::International::get(131),WebGUI::Form::text("attachmentDirectoryWeb",30,255,$session{setting}{attachmentDirectoryWeb}));
|
||||
$output .= tableFormRow(WebGUI::International::get(132),WebGUI::Form::text("attachmentDirectoryLocal",30,255,$session{setting}{attachmentDirectoryLocal}));
|
||||
$output .= tableFormRow(WebGUI::International::get(129),
|
||||
WebGUI::Form::text("lib",30,255,$session{setting}{lib}));
|
||||
$output .= tableFormRow(WebGUI::International::get(130),
|
||||
WebGUI::Form::text("maxAttachmentSize",30,11,$session{setting}{maxAttachmentSize}));
|
||||
$output .= tableFormRow(WebGUI::International::get(406),
|
||||
WebGUI::Form::text("thumbnailSize",30,3,$session{setting}{thumbnailSize}));
|
||||
$output .= tableFormRow(WebGUI::International::get(131),
|
||||
WebGUI::Form::text("attachmentDirectoryWeb",30,255,$session{setting}{attachmentDirectoryWeb}));
|
||||
$output .= tableFormRow(WebGUI::International::get(132),
|
||||
WebGUI::Form::text("attachmentDirectoryLocal",30,255,$session{setting}{attachmentDirectoryLocal}));
|
||||
$output .= formSave();
|
||||
$output .= '</table>';
|
||||
$output .= '</form> ';
|
||||
|
|
@ -128,9 +134,14 @@ sub www_editFileSettings {
|
|||
sub www_editFileSettingsSave {
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
WebGUI::SQL->write("update settings set value=".quote($session{form}{lib})." where name='lib'");
|
||||
WebGUI::SQL->write("update settings set value=".quote($session{form}{maxAttachmentSize})." where name='maxAttachmentSize'");
|
||||
WebGUI::SQL->write("update settings set value=".quote($session{form}{attachmentDirectoryWeb})." where name='attachmentDirectoryWeb'");
|
||||
WebGUI::SQL->write("update settings set value=".quote($session{form}{attachmentDirectoryLocal})." where name='attachmentDirectoryLocal'");
|
||||
WebGUI::SQL->write("update settings set value=".
|
||||
quote($session{form}{maxAttachmentSize})." where name='maxAttachmentSize'");
|
||||
WebGUI::SQL->write("update settings set value=".
|
||||
quote($session{form}{thumbnailSize})." where name='thumbnailSize'");
|
||||
WebGUI::SQL->write("update settings set value=".
|
||||
quote($session{form}{attachmentDirectoryWeb})." where name='attachmentDirectoryWeb'");
|
||||
WebGUI::SQL->write("update settings set value=".
|
||||
quote($session{form}{attachmentDirectoryLocal})." where name='attachmentDirectoryLocal'");
|
||||
return www_manageSettings();
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use strict;
|
|||
use Tie::CPHash;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Shortcut;
|
||||
|
|
@ -142,7 +143,7 @@ sub www_editStyleSave {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_listStyles {
|
||||
my ($output, $sth, @data, @row, $i, $prevNextBar, $dataRows);
|
||||
my ($output, $sth, @data, @row, $i, $p);
|
||||
if (WebGUI::Privilege::isInGroup(5)) {
|
||||
$output = helpLink(9);
|
||||
$output .= '<h1>'.WebGUI::International::get(157).'</h1>';
|
||||
|
|
@ -161,11 +162,11 @@ sub www_listStyles {
|
|||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
($dataRows, $prevNextBar) = paginate(50,WebGUI::URL::page('op=listStyles'),\@row);
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=listStyles'),\@row);
|
||||
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
|
||||
$output .= $dataRows;
|
||||
$output .= $p->getPage($session{form}{pn});
|
||||
$output .= '</table>';
|
||||
$output .= $prevNextBar;
|
||||
$output .= $p->getBarTraditional($session{form}{pn});
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use Tie::CPHash;
|
|||
use WebGUI::DateTime;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Shortcut;
|
||||
|
|
@ -67,7 +68,8 @@ sub www_addUser {
|
|||
sub www_addUserSave {
|
||||
my ($output, @groups, $uid, $gid, $encryptedPassword, $expireAfter);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
($uid) = WebGUI::SQL->quickArray("select userId from users where username='$session{form}{username}'");
|
||||
($uid) = WebGUI::SQL->quickArray("select userId from users where username=".
|
||||
quote($session{form}{username}));
|
||||
unless ($uid) {
|
||||
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier});
|
||||
$uid = getNextId("userId");
|
||||
|
|
@ -276,7 +278,8 @@ sub www_editUser {
|
|||
sub www_editUserSave {
|
||||
my ($error, $uid, $encryptedPassword, $passwordStatement);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
($uid) = WebGUI::SQL->quickArray("select userId from users where username='$session{form}{username}'");
|
||||
($uid) = WebGUI::SQL->quickArray("select userId from users where username=".
|
||||
quote($session{form}{username}));
|
||||
if ($uid == $session{form}{uid} || $uid < 1) {
|
||||
if ($session{form}{identifier} ne "password") {
|
||||
$encryptedPassword = Digest::MD5::md5_base64($session{form}{identifier});
|
||||
|
|
@ -311,7 +314,7 @@ sub www_editUserGroupSave {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_listUsers {
|
||||
my ($output, $sth, @data, @row, $dataRows, $prevNextBar, $i, $search);
|
||||
my ($output, $sth, @data, @row, $p, $i, $search);
|
||||
if (WebGUI::Privilege::isInGroup(3)) {
|
||||
$output = helpLink(8);
|
||||
$output .= '<h1>'.WebGUI::International::get(149).'</h1>';
|
||||
|
|
@ -342,11 +345,11 @@ sub www_listUsers {
|
|||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
($dataRows, $prevNextBar) = paginate(50,WebGUI::URL::page('op=listUsers'),\@row);
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page('op=listUsers'),\@row);
|
||||
$output .= '<table border=1 cellpadding=5 cellspacing=0 align="center">';
|
||||
$output .= $dataRows;
|
||||
$output .= $p->getPage($session{form}{pn});
|
||||
$output .= '</table>';
|
||||
$output .= $prevNextBar;
|
||||
$output .= $p->getBarTraditional($session{form}{pn});
|
||||
return $output;
|
||||
} else {
|
||||
return WebGUI::Privilege::adminOnly();
|
||||
|
|
|
|||
410
lib/WebGUI/Paginator.pm
Normal file
410
lib/WebGUI/Paginator.pm
Normal file
|
|
@ -0,0 +1,410 @@
|
|||
package WebGUI::Paginator;
|
||||
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2002 Plain Black Software.
|
||||
-------------------------------------------------------------------
|
||||
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::International;
|
||||
use WebGUI::URL;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::Paginator
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use WebGUI::Paginator;
|
||||
$p = WebGUI::Paginator->new("/index.pl/page_name?this=that",\@row);
|
||||
$p->getBar(2);
|
||||
$p->getBarAdvanced(2);
|
||||
$p->getBarSimple(2);
|
||||
$p->getBarTraditional(2);
|
||||
$p->getFirstPageLink(2);
|
||||
$p->getLastPageLink(2);
|
||||
$p->getNextPageLink(2);
|
||||
$p->getNumberOfPages;
|
||||
$p->getPage(2);
|
||||
$p->getPageLinks(2);
|
||||
$p->getPreviousPageLink(2);
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Package that paginates rows of data for display on the web.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this class:
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _generatePages {
|
||||
my (@page, $row, @rows, $rowRef, $pn, $i, $itemsPerPage);
|
||||
$rowRef = $_[0];
|
||||
@rows = @{$rowRef};
|
||||
$itemsPerPage = $_[1];
|
||||
foreach $row (@rows) {
|
||||
$page[$pn] .= $row;
|
||||
$i++;
|
||||
if ($i >= $itemsPerPage) {
|
||||
$i = 0;
|
||||
$pn++;
|
||||
}
|
||||
}
|
||||
return \@page;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getBar ( [ pageNumber ] )
|
||||
|
||||
Returns the pagination bar including First, Previous, Next, and
|
||||
last links. If there's only one page, nothing is returned.
|
||||
|
||||
=item pageNumber
|
||||
|
||||
The page number you're currently looking at. If omited, page one
|
||||
is assumed.
|
||||
|
||||
=cut
|
||||
|
||||
sub getBar {
|
||||
my ($output);
|
||||
if ($_[0]->getNumberOfPages > 1) {
|
||||
$output = '<div class="pagination">';
|
||||
$output .= $_[0]->getFirstPageLink($_[1]);
|
||||
$output .= ' · ';
|
||||
$output .= $_[0]->getPreviousPageLink($_[1]);
|
||||
$output .= ' · ';
|
||||
$output .= $_[0]->getNextPageLink($_[1]);
|
||||
$output .= ' · ';
|
||||
$output .= $_[0]->getLastPageLink($_[1]);
|
||||
$output .= '</div>';
|
||||
return $output;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getBarAdvanced ( [ pageNumber ] )
|
||||
|
||||
Returns the pagination bar including First, Previous, Page Numbers,
|
||||
Next, and Last links. If there's only one page, nothing is
|
||||
returned.
|
||||
|
||||
=item pageNumber
|
||||
|
||||
The page number you're currently looking at. If omited, page one
|
||||
is assumed.
|
||||
|
||||
=cut
|
||||
|
||||
sub getBarAdvanced {
|
||||
my ($output);
|
||||
if ($_[0]->getNumberOfPages > 1) {
|
||||
$output = '<div class="pagination">';
|
||||
$output .= $_[0]->getFirstPageLink($_[1]);
|
||||
$output .= ' · ';
|
||||
$output .= $_[0]->getPreviousPageLink($_[1]);
|
||||
$output .= ' · ';
|
||||
$output .= $_[0]->getPageLinks($_[1]);
|
||||
$output .= ' · ';
|
||||
$output .= $_[0]->getNextPageLink($_[1]);
|
||||
$output .= ' · ';
|
||||
$output .= $_[0]->getLastPageLink($_[1]);
|
||||
$output .= '</div>';
|
||||
return $output;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getBarSimple ( [ pageNumber ] )
|
||||
|
||||
Returns the pagination bar including only Previous and Next links.
|
||||
If there's only one page, nothing is returned.
|
||||
|
||||
=item pageNumber
|
||||
|
||||
The page number you're currently looking at. If omited, page one
|
||||
is assumed.
|
||||
|
||||
=cut
|
||||
|
||||
sub getBarSimple {
|
||||
my ($output);
|
||||
if ($_[0]->getNumberOfPages > 1) {
|
||||
$output = '<div class="pagination">';
|
||||
$output .= $_[0]->getPreviousPageLink($_[1]);
|
||||
$output .= ' · ';
|
||||
$output .= $_[0]->getNextPageLink($_[1]);
|
||||
$output .= '</div>';
|
||||
return $output;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getBarTraditional ( [ pageNumber ] )
|
||||
|
||||
Returns the pagination bar including Previous, Page Numbers,
|
||||
and Next links. If there's only one page, nothing is
|
||||
returned.
|
||||
|
||||
=item pageNumber
|
||||
|
||||
The page number you're currently looking at. If omited, page one
|
||||
is assumed.
|
||||
|
||||
=cut
|
||||
|
||||
sub getBarTraditional {
|
||||
my ($output);
|
||||
if ($_[0]->getNumberOfPages > 1) {
|
||||
$output = '<div class="pagination">';
|
||||
$output .= $_[0]->getPreviousPageLink($_[1]);
|
||||
$output .= ' · ';
|
||||
$output .= $_[0]->getPageLinks($_[1]);
|
||||
$output .= ' · ';
|
||||
$output .= $_[0]->getNextPageLink($_[1]);
|
||||
$output .= '</div>';
|
||||
return $output;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getFirstPageLink ( [ pageNumber ] )
|
||||
|
||||
Returns a link to the first page's data.
|
||||
|
||||
=item pageNumber
|
||||
|
||||
The page number you're currently looking at. If omited, page one
|
||||
is assumed.
|
||||
|
||||
=cut
|
||||
|
||||
sub getFirstPageLink {
|
||||
my ($text, $pn);
|
||||
$pn = $_[1] || 1;
|
||||
$text = '|<'.WebGUI::International::get(404);
|
||||
if ($pn > 1) {
|
||||
return '<a href="'.
|
||||
WebGUI::URL::append($_[0]->{_url},($_[0]->{_pn}.'=1'))
|
||||
.'">'.$text.'</a>';
|
||||
} else {
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getLastPageLink ( [ pageNumber ] )
|
||||
|
||||
Returns a link to the last page's data.
|
||||
|
||||
=item pageNumber
|
||||
|
||||
The page number you're currently looking at. If omited, page one
|
||||
is assumed.
|
||||
|
||||
=cut
|
||||
|
||||
sub getLastPageLink {
|
||||
my ($text, $pn);
|
||||
$pn = $_[1] || 1;
|
||||
$text = WebGUI::International::get(405).'>|';
|
||||
if ($pn != $_[0]->getNumberOfPages) {
|
||||
return '<a href="'.
|
||||
WebGUI::URL::append($_[0]->{_url},($_[0]->{_pn}.'='.$_[0]->getNumberOfPages))
|
||||
.'">'.$text.'</a>';
|
||||
} else {
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getNextPageLink ( [ pageNumber ] )
|
||||
|
||||
Returns a link to the next page's data.
|
||||
|
||||
=item pageNumber
|
||||
|
||||
The page number you're currently looking at. If omited, page one
|
||||
is assumed.
|
||||
|
||||
=cut
|
||||
|
||||
sub getNextPageLink {
|
||||
my ($text, $pn);
|
||||
$pn = $_[1] || 1;
|
||||
$text = WebGUI::International::get(92).'»';
|
||||
if ($pn < $_[0]->getNumberOfPages) {
|
||||
return '<a href="'.WebGUI::URL::append($_[0]->{_url},($_[0]->{_pn}.'='.($pn+1))).'">'.$text.'</a>';
|
||||
} else {
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getNumberOfPages ( )
|
||||
|
||||
Returns the number of pages in this paginator.
|
||||
|
||||
=cut
|
||||
|
||||
sub getNumberOfPages {
|
||||
return $#{$_[0]->{_pageRef}}+1;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getPage ( [ pageNumber ] )
|
||||
|
||||
Returns the data from the page specified.
|
||||
|
||||
=item pageNumber
|
||||
|
||||
The page number you wish to view. If omitted, page one is assumed.
|
||||
|
||||
=cut
|
||||
|
||||
sub getPage {
|
||||
my ($pn);
|
||||
$pn = $_[1] || 1;
|
||||
return $_[0]->{_pageRef}[$pn-1];
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getPageLinks ( [ pageNumber ] )
|
||||
|
||||
Returns links to all pages in this paginator.
|
||||
|
||||
=item pageNumber
|
||||
|
||||
The page number you're currently looking at. If omited, page one
|
||||
is assumed.
|
||||
|
||||
=cut
|
||||
|
||||
sub getPageLinks {
|
||||
my ($i, $output, $pn);
|
||||
$pn = $_[1] || 1;
|
||||
for ($i=0; $i<$_[0]->getNumberOfPages; $i++) {
|
||||
if ($i+1 == $pn) {
|
||||
$output .= ' '.($i+1).' ';
|
||||
} else {
|
||||
$output .= ' <a href="'.
|
||||
WebGUI::URL::append($_[0]->{_url},($_[0]->{_pn}.'='.($i+1)))
|
||||
.'">'.($i+1).'</a> ';
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getPreviousPageLink ( [ pageNumber ] )
|
||||
|
||||
Returns a link to the previous page's data.
|
||||
|
||||
=item pageNumber
|
||||
|
||||
The page number you're currently looking at. If omitted, page one
|
||||
is assumed.
|
||||
|
||||
=cut
|
||||
|
||||
sub getPreviousPageLink {
|
||||
my ($text, $pn);
|
||||
$pn = $_[1] || 1;
|
||||
$text = '«'.WebGUI::International::get(91);
|
||||
if ($pn > 1) {
|
||||
return '<a href="'.WebGUI::URL::append($_[0]->{_url},($_[0]->{_pn}.'='.($pn-1))).'">'.$text.'</a>';
|
||||
} else {
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( currentURL, rowArrayRef [, paginateAfter, alternateFormVar ] )
|
||||
|
||||
Constructor.
|
||||
|
||||
=item currentURL
|
||||
|
||||
The URL of the current page including attributes. The page number
|
||||
will be appended to this in all links generated by the paginator.
|
||||
|
||||
=item rowArrayRef
|
||||
|
||||
An array reference to all the rows of data for this page.
|
||||
|
||||
=item paginateAfter
|
||||
|
||||
The number of rows to display per page. If left blank it defaults
|
||||
to 50.
|
||||
|
||||
=item alternateFormVar
|
||||
|
||||
By default the paginator uses a form variable of "pn" to denote the
|
||||
page number. If you wish it to use some other variable, then specify
|
||||
it here.
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my ($class, $currentURL, $rowsPerPage, $rowRef, $formVar, $pageRef);
|
||||
$class = shift;
|
||||
$currentURL = shift;
|
||||
$rowRef = shift;
|
||||
$rowsPerPage = shift || 50;
|
||||
$formVar = shift || "pn";
|
||||
$pageRef = _generatePages($rowRef,$rowsPerPage);
|
||||
bless {_url => $currentURL, _rpp => $rowsPerPage, _rowRef => $rowRef,
|
||||
_pn => $formVar, _pageRef => $pageRef}, $class;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
||||
|
|
@ -1,14 +1,18 @@
|
|||
package WebGUI::SQL;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2002 Plain Black Software.
|
||||
#-------------------------------------------------------------------
|
||||
# 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
|
||||
#-------------------------------------------------------------------
|
||||
=head1 LEGAL
|
||||
|
||||
-------------------------------------------------------------------
|
||||
WebGUI is Copyright 2001-2002 Plain Black Software.
|
||||
-------------------------------------------------------------------
|
||||
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 CGI::Carp qw(fatalsToBrowser);
|
||||
use DBI;
|
||||
|
|
@ -21,12 +25,76 @@ use WebGUI::Session;
|
|||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw("e &getNextId);
|
||||
|
||||
=head1 NAME
|
||||
|
||||
Package WebGUI::SQL
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use WebGUI::SQL;
|
||||
$sth = WebGUI::SQL->new($sql);
|
||||
$sth = WebGUI::SQL->read($sql);
|
||||
$sth = WebGUI::SQL->unconditionalRead($sql);
|
||||
$sth->array;
|
||||
$sth->getColumnNames;
|
||||
$sth->hash;
|
||||
$sth->hashRef;
|
||||
$sth->rows;
|
||||
$sth->finish;
|
||||
|
||||
@arr = WebGUI::SQL->buildArray($sql);
|
||||
%hash = WebGUI::SQL->buildHash($sql);
|
||||
@arr = WebGUI::SQL->quickArray($sql);
|
||||
%hash = WebGUI::SQL->quickHash($sql);
|
||||
|
||||
WebGUI::SQL->write($sql);
|
||||
|
||||
$id = getNextId("widgetId");
|
||||
$string = quote($string);
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Package for interfacing with SQL databases. This package
|
||||
implements Perl DBI functionality in a less code-intensive
|
||||
manner and adds some extra functionality.
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
These methods are available from this package:
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 array ( )
|
||||
|
||||
Returns the next row of data as an array.
|
||||
|
||||
=cut
|
||||
|
||||
sub array {
|
||||
return $_[0]->{_sth}->fetchrow_array() or WebGUI::ErrorHandler::fatalError("Couldn't fetch array. ".$_[0]->{_sth}->errstr);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 buildArray ( sql [, dbh ] )
|
||||
|
||||
Builds an array of data from a series of rows.
|
||||
|
||||
=item sql
|
||||
|
||||
An SQL query. The query must select only one column of data.
|
||||
|
||||
=item dbh
|
||||
|
||||
By default this method uses the WebGUI database handler. However,
|
||||
you may choose to pass in your own if you wish.
|
||||
|
||||
=cut
|
||||
|
||||
sub buildArray {
|
||||
my ($sth, $data, @array, $i);
|
||||
$sth = WebGUI::SQL->read($_[1],$_[2]);
|
||||
|
|
@ -39,7 +107,25 @@ sub buildArray {
|
|||
return @array;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 buildHash ( sql [, dbh ] )
|
||||
|
||||
Builds a hash of data from a series of rows.
|
||||
|
||||
=item sql
|
||||
|
||||
An SQL query. The query must select only two columns of data, the
|
||||
first being the key for the hash, the second being the value.
|
||||
|
||||
=item dbh
|
||||
|
||||
By default this method uses the WebGUI database handler. However,
|
||||
you may choose to pass in your own if you wish.
|
||||
|
||||
=cut
|
||||
|
||||
sub buildHash {
|
||||
my ($sth, %hash, @data);
|
||||
tie %hash, "Tie::IxHash";
|
||||
|
|
@ -55,17 +141,48 @@ sub buildHash {
|
|||
return %hash;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 finish ( )
|
||||
|
||||
Ends a query after calling the "new" or "read" methods.
|
||||
|
||||
=cut
|
||||
|
||||
sub finish {
|
||||
return $_[0]->{_sth}->finish;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getColumnNames {
|
||||
|
||||
Returns an array of column names. Use with a "read" method.
|
||||
|
||||
=cut
|
||||
|
||||
sub getColumnNames {
|
||||
return @{$_[0]->{_sth}->{NAME}};
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getNextId ( idName )
|
||||
|
||||
Increments an incrementer of the specified type and returns the
|
||||
value. NOTE: This is not a regular method, but is an exported
|
||||
subroutine.
|
||||
|
||||
=item idName
|
||||
|
||||
Specify the name of one of the incrementers in the incrementer
|
||||
table.
|
||||
|
||||
=cut
|
||||
|
||||
sub getNextId {
|
||||
my ($id);
|
||||
($id) = WebGUI::SQL->quickArray("select nextValue from incrementer where incrementerId='$_[0]'");
|
||||
|
|
@ -73,7 +190,16 @@ sub getNextId {
|
|||
return $id;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 hash
|
||||
|
||||
Returns the next row of data in the form of a hash. Must be
|
||||
executed on a statement handler returned by the "read" method.
|
||||
|
||||
=cut
|
||||
|
||||
sub hash {
|
||||
my ($hashRef);
|
||||
$hashRef = $_[0]->{_sth}->fetchrow_hashref();
|
||||
|
|
@ -84,12 +210,38 @@ sub hash {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 hashRef
|
||||
|
||||
Returns the next row of data in the form of a hash reference. Must
|
||||
be executed on a statement handler returned by the "read" method.
|
||||
|
||||
=cut
|
||||
|
||||
sub hashRef {
|
||||
return $_[0]->{_sth}->fetchrow_hashref() or WebGUI::ErrorHandler::fatalError("Couldn't fetch hashref. ".$_[0]->{_sth}->errstr);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 new ( sql [, dbh ] )
|
||||
|
||||
Constructor. Returns a statement handler.
|
||||
|
||||
=item sql
|
||||
|
||||
An SQL query.
|
||||
|
||||
=item dbh
|
||||
|
||||
By default this method uses the WebGUI database handler. However,
|
||||
you may choose to pass in your own if you wish.
|
||||
|
||||
=cut
|
||||
|
||||
sub new {
|
||||
my ($class, $sql, $dbh, $sth);
|
||||
$class = shift;
|
||||
|
|
@ -100,7 +252,24 @@ sub new {
|
|||
bless ({_sth => $sth}, $class);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 quickArray ( sql [, dbh ] )
|
||||
|
||||
Executes a query and returns a single row of data as an array.
|
||||
|
||||
=item sql
|
||||
|
||||
An SQL query.
|
||||
|
||||
=item dbh
|
||||
|
||||
By default this method uses the WebGUI database handler. However,
|
||||
you may choose to pass in your own if you wish.
|
||||
|
||||
=cut
|
||||
|
||||
sub quickArray {
|
||||
my ($sth, @data);
|
||||
$sth = WebGUI::SQL->new($_[1],$_[2]);
|
||||
|
|
@ -109,7 +278,24 @@ sub quickArray {
|
|||
return @data;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 quickHash ( sql [, dbh ] )
|
||||
|
||||
Executes a query and returns a single row of data as a hash.
|
||||
|
||||
=item sql
|
||||
|
||||
An SQL query.
|
||||
|
||||
=item dbh
|
||||
|
||||
By default this method uses the WebGUI database handler. However,
|
||||
you may choose to pass in your own if you wish.
|
||||
|
||||
=cut
|
||||
|
||||
sub quickHash {
|
||||
my ($sth, $data);
|
||||
$sth = WebGUI::SQL->new($_[1],$_[2]);
|
||||
|
|
@ -120,23 +306,83 @@ sub quickHash {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 quote ( string )
|
||||
|
||||
Returns a string quoted and ready for insert into the database.
|
||||
NOTE: This is not a regular method, but is an exported subroutine.
|
||||
|
||||
=item string
|
||||
|
||||
Any scalar variable that needs to be escaped to be inserted into
|
||||
the database.
|
||||
|
||||
=cut
|
||||
|
||||
sub quote {
|
||||
my $value = $_[0]; #had to add this here cuz Tie::CPHash variables cause problems otherwise.
|
||||
return $WebGUI::Session::session{dbh}->quote($value);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 read ( sql [, dbh ] )
|
||||
|
||||
An alias of the "new" method. Returns a statement handler.
|
||||
|
||||
=item sql
|
||||
|
||||
An SQL query.
|
||||
|
||||
=item dbh
|
||||
|
||||
By default this method uses the WebGUI database handler. However,
|
||||
you may choose to pass in your own if you wish.
|
||||
|
||||
=cut
|
||||
|
||||
sub read {
|
||||
return WebGUI::SQL->new($_[1],$_[2],$_[3]);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 rows ( )
|
||||
|
||||
Returns the number of rows in a statement handler created by the
|
||||
"read" method.
|
||||
|
||||
=cut
|
||||
|
||||
sub rows {
|
||||
return $_[0]->{_sth}->rows;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 unconditionalRead ( sql [, dbh ] )
|
||||
|
||||
An alias of the "read" method except that it will not cause a fatal
|
||||
error in WebGUI if the query is invalid. This is useful for user
|
||||
generated queries such as those in the SQL Report. Returns a
|
||||
statement handler.
|
||||
|
||||
=item sql
|
||||
|
||||
An SQL query.
|
||||
|
||||
=item dbh
|
||||
|
||||
By default this method uses the WebGUI database handler. However,
|
||||
you may choose to pass in your own if you wish.
|
||||
|
||||
=cut
|
||||
|
||||
sub unconditionalRead {
|
||||
my ($sth);
|
||||
$sth = $_[2]->prepare($_[1]);
|
||||
|
|
@ -144,7 +390,26 @@ sub unconditionalRead {
|
|||
bless ({_sth => $sth}, $_[0]);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 write ( sql [, dbh ] )
|
||||
|
||||
A method specifically designed for writing to the database in an
|
||||
efficient manner. Writing can be accomplished using the "new"
|
||||
method, but it is not as efficient.
|
||||
|
||||
=item sql
|
||||
|
||||
An SQL insert or update.
|
||||
|
||||
=item dbh
|
||||
|
||||
By default this method uses the WebGUI database handler. However,
|
||||
you may choose to pass in your own if you wish.
|
||||
|
||||
=cut
|
||||
|
||||
sub write {
|
||||
my ($dbh);
|
||||
$dbh = $_[2] || $WebGUI::Session::session{dbh};
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@ sub _getSessionVars {
|
|||
my (%vars, $uid, $encryptedPassword);
|
||||
tie %vars, 'Tie::CPHash';
|
||||
if ($_[0] ne "") {
|
||||
%vars = WebGUI::SQL->quickHash("select * from session where sessionId='$_[0]'", $_[1]);
|
||||
%vars = WebGUI::SQL->quickHash("select * from userSession where sessionId='$_[0]'", $_[1]);
|
||||
if ($vars{sessionId} ne "") {
|
||||
WebGUI::SQL->write("update session set lastPageView=".time().", lastIP='$ENV{REMOTE_ADDR}', expires=".(time()+$_[2])." where sessionId='$_[0]'",$_[1]);
|
||||
WebGUI::SQL->write("update userSession set lastPageView=".time().", lastIP='$ENV{REMOTE_ADDR}', expires=".(time()+$_[2])." where sessionId='$_[0]'",$_[1]);
|
||||
}
|
||||
}
|
||||
return %vars;
|
||||
|
|
@ -82,7 +82,7 @@ sub close {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub end {
|
||||
WebGUI::SQL->write("delete from session where sessionId='$_[0]'",$session{dbh});
|
||||
WebGUI::SQL->write("delete from userSession where sessionId='$_[0]'",$session{dbh});
|
||||
refreshSessionVars();
|
||||
}
|
||||
|
||||
|
|
@ -103,7 +103,8 @@ sub open {
|
|||
tie %VARS, 'Tie::CPHash';
|
||||
tie %PAGE, 'Tie::CPHash';
|
||||
$CONFIG{webguiRoot} = $_[0];
|
||||
$config = new Data::Config $CONFIG{webguiRoot}.'/etc/WebGUI.conf';
|
||||
$CONFIG{configFile} = $_[1] || "WebGUI.conf";
|
||||
$config = new Data::Config $CONFIG{webguiRoot}.'/etc/'.$CONFIG{configFile};
|
||||
foreach ($config->param) {
|
||||
$CONFIG{$_} = $config->param($_);
|
||||
}
|
||||
|
|
@ -115,6 +116,10 @@ sub open {
|
|||
$CONFIG{scripturl} = $ENV{SCRIPT_NAME};
|
||||
}
|
||||
$dbh = DBI->connect($CONFIG{dsn}, $CONFIG{dbuser}, $CONFIG{dbpass}, { RaiseError => 0, AutoCommit => 1 });
|
||||
if ( $CONFIG{dsn} =~ /Oracle/ ) { # Set Oracle specific attributes
|
||||
$dbh->{LongReadLen} = 512 * 1024;
|
||||
$dbh->{LongTruncOk} = 1;
|
||||
}
|
||||
$query = CGI->new();
|
||||
foreach ($query->param) {
|
||||
$FORM{$_} = $query->param($_);
|
||||
|
|
@ -179,7 +184,7 @@ sub start {
|
|||
tie %user, 'Tie::CPHash';
|
||||
%user = WebGUI::SQL->quickHash("select * from users where userId='$uid'", $session{dbh});
|
||||
if (crypt($user{identifier},"yJ") eq $encryptedPassword) {
|
||||
WebGUI::SQL->write("insert into session values ('$_[0]', ".(time()+$session{setting}{sessionTimeout}).", ".time().", 0, '$ENV{REMOTE_ADDR}', $uid)",$session{dbh});
|
||||
WebGUI::SQL->write("insert into userSession values ('$_[0]', ".(time()+$session{setting}{sessionTimeout}).", ".time().", 0, '$ENV{REMOTE_ADDR}', $uid)",$session{dbh});
|
||||
refreshSessionVars($_[0]);
|
||||
return 1;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -28,17 +28,15 @@ our @EXPORT = qw(&attachmentBox &formHeader &formSave &tableFormRow &helpLink);
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub attachmentBox {
|
||||
my ($output, %fileType, $fileUrl);
|
||||
$fileUrl = $session{setting}{attachmentDirectoryWeb}.'/'.$_[1].'/';
|
||||
if ($_[2] ne "") {
|
||||
$fileUrl .= $_[2].'/';
|
||||
}
|
||||
$fileUrl .= $_[0];
|
||||
%fileType = WebGUI::Attachment::getType($_[0]);
|
||||
my ($output, $attachment);
|
||||
$attachment = WebGUI::Attachment->new($_[0],$_[1],$_[2]);
|
||||
$output = '<p><table cellpadding=3 cellspacing=0 border=1><tr><td class="tableHeader">'.
|
||||
'<a href="'.$fileUrl.'"><img src="'.$session{setting}{lib}.'/attachment.gif" border=0 alt="'.
|
||||
$_[0].'"></a></td><td><a href="'.$fileUrl.'"><img src="'.$fileType{icon}.
|
||||
'" align="middle" width="16" height="16" border="0" alt="'.$_[0].'">'.$_[0].'</a></td></tr></table>';
|
||||
'<a href="'.$attachment->getURL.'"><img src="'.$session{setting}{lib}.
|
||||
'/attachment.gif" border=0 alt="'.
|
||||
$attachment->getFilename.'"></a></td><td><a href="'.$attachment->getURL.
|
||||
'"><img src="'.$attachment->getIcon.
|
||||
'" align="middle" width="16" height="16" border="0" alt="'.$attachment->getFilename
|
||||
.'">'.$attachment->getFilename.'</a></td></tr></table>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,41 +19,27 @@ use WebGUI::SQL;
|
|||
use WebGUI::URL;
|
||||
|
||||
our @ISA = qw(Exporter);
|
||||
our @EXPORT = qw(&sortByColumn &sortHashDescending &sortHash
|
||||
&paginate &randint &round);
|
||||
our @EXPORT = qw(&sortByColumn &sortHashDescending &sortHash &isIn &randint &round);
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub paginate {
|
||||
my ($pn, $i, $dataRows, $prevNextBar, $itemsPerPage, @row, $url);
|
||||
$itemsPerPage = $_[0];
|
||||
$url = $_[1];
|
||||
@row = @{$_[2]};
|
||||
if ($session{form}{pn} < 1) {
|
||||
$pn = 0;
|
||||
} else {
|
||||
$pn = $session{form}{pn};
|
||||
}
|
||||
for ($i=($itemsPerPage*$pn); $i<($itemsPerPage*($pn+1));$i++) {
|
||||
$dataRows .= $row[$i];
|
||||
}
|
||||
if ($#row+1 > $itemsPerPage) {
|
||||
$prevNextBar = '<div class="pagination">';
|
||||
if ($pn > 0) {
|
||||
$prevNextBar .= '<a href="'.WebGUI::URL::append($url,('pn='.($pn-1))).'">«'.
|
||||
WebGUI::International::get(91).'</a>';
|
||||
} else {
|
||||
$prevNextBar .= '«'.WebGUI::International::get(91);
|
||||
}
|
||||
$prevNextBar .= ' · ';
|
||||
if (($pn+1) < (($#row+1)/$itemsPerPage)) {
|
||||
$prevNextBar .= '<a href="'.WebGUI::URL::append($url,('pn='.($pn+1))).'">'.
|
||||
WebGUI::International::get(92).'»</a>';
|
||||
} else {
|
||||
$prevNextBar .= WebGUI::International::get(92).'»';
|
||||
}
|
||||
$prevNextBar .= '</div>';
|
||||
}
|
||||
return ($dataRows, $prevNextBar);
|
||||
sub isIn {
|
||||
my ($i, @a, @b, @isect, %union, %isect, $e);
|
||||
foreach $e (@_) {
|
||||
if ($a[0] eq "") {
|
||||
$a[0] = $e;
|
||||
} else {
|
||||
$b[$i] = $e;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
foreach $e (@a, @b) { $union{$e}++ && $isect{$e}++ }
|
||||
@isect = keys %isect;
|
||||
if (defined @isect) {
|
||||
undef @isect;
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ use DBI;
|
|||
use Exporter;
|
||||
use strict qw(subs vars);
|
||||
use Tie::IxHash;
|
||||
use WebGUI::Attachment;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Node;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Template;
|
||||
|
|
@ -63,9 +63,11 @@ sub getProperties {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub purgeWidget {
|
||||
my ($node);
|
||||
WebGUI::SQL->write("delete from $_[2] where widgetId=$_[0]",$_[1]);
|
||||
WebGUI::SQL->write("delete from widget where widgetId=$_[0]",$_[1]);
|
||||
WebGUI::Attachment::purgeWidget($_[0]);
|
||||
$node = WebGUI::Node->new($_[0]);
|
||||
$node->delete;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -27,14 +27,20 @@ use WebGUI::Widget;
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub duplicate {
|
||||
my (%data, $newWidgetId, $pageId);
|
||||
my (%data, $newWidgetId, $pageId, $file);
|
||||
tie %data, 'Tie::CPHash';
|
||||
%data = getProperties($namespace,$_[0]);
|
||||
$pageId = $_[1] || $data{pageId};
|
||||
$newWidgetId = create($pageId,$namespace,$data{title},$data{displayTitle},$data{description},$data{processMacros},$data{templatePosition});
|
||||
WebGUI::Attachment::copy($data{image},$_[0],$newWidgetId);
|
||||
WebGUI::Attachment::copy($data{attachment},$_[0],$newWidgetId);
|
||||
WebGUI::SQL->write("insert into Article values ($newWidgetId, $data{startDate}, $data{endDate}, ".quote($data{body}).", ".quote($data{image}).", ".quote($data{linkTitle}).", ".quote($data{linkURL}).", ".quote($data{attachment}).", '$data{convertCarriageReturns}', ".quote($data{alignImage}).")");
|
||||
$newWidgetId = create($pageId,$namespace,$data{title},$data{displayTitle},
|
||||
$data{description},$data{processMacros},$data{templatePosition});
|
||||
$file = WebGUI::Attachment->new($data{image},$_[0]);
|
||||
$file->copy($newWidgetId);
|
||||
$file = WebGUI::Attachment->new($data{attachment},$_[0]);
|
||||
$file->copy($newWidgetId);
|
||||
WebGUI::SQL->write("insert into Article values ($newWidgetId, $data{startDate}, $data{endDate}, ".
|
||||
quote($data{body}).", ".quote($data{image}).", ".quote($data{linkTitle}).", ".
|
||||
quote($data{linkURL}).", ".quote($data{attachment}).", '$data{convertCarriageReturns}', ".
|
||||
quote($data{alignImage}).")");
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -92,10 +98,24 @@ sub www_add {
|
|||
sub www_addSave {
|
||||
my ($widgetId, $image, $attachment);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$widgetId = create($session{page}{pageId},$session{form}{widget},$session{form}{title},$session{form}{displayTitle},$session{form}{description},$session{form}{processMacros},$session{form}{templatePosition});
|
||||
$image = WebGUI::Attachment::save("image",$widgetId);
|
||||
$attachment = WebGUI::Attachment::save("attachment",$widgetId);
|
||||
WebGUI::SQL->write("insert into Article values ($widgetId, '".setToEpoch($session{form}{startDate})."', '".setToEpoch($session{form}{endDate})."', ".quote($session{form}{body}).", ".quote($image).", ".quote($session{form}{linkTitle}).", ".quote($session{form}{linkURL}).", ".quote($attachment).", '$session{form}{convertCarriageReturns}', ".quote($session{form}{alignImage}).")");
|
||||
$widgetId = create($session{page}{pageId},$session{form}{widget},
|
||||
$session{form}{title},$session{form}{displayTitle},
|
||||
$session{form}{description},$session{form}{processMacros},
|
||||
$session{form}{templatePosition});
|
||||
$image = WebGUI::Attachment->new("",$widgetId);
|
||||
$image->save("image");
|
||||
$attachment = WebGUI::Attachment->new("",$widgetId);
|
||||
$attachment->save("attachment");
|
||||
WebGUI::SQL->write("insert into Article values ($widgetId, '".
|
||||
setToEpoch($session{form}{startDate})."', '".
|
||||
setToEpoch($session{form}{endDate})."', ".
|
||||
quote($session{form}{body}).", ".
|
||||
quote($image->getFilename).", ".
|
||||
quote($session{form}{linkTitle}).", ".
|
||||
quote($session{form}{linkURL}).", ".
|
||||
quote($attachment->getFilename).
|
||||
", '$session{form}{convertCarriageReturns}', ".
|
||||
quote($session{form}{alignImage}).")");
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
|
|
@ -145,15 +165,22 @@ sub www_edit {
|
|||
$output .= WebGUI::Form::hidden("wid",$session{form}{wid});
|
||||
$output .= WebGUI::Form::hidden("func","editSave");
|
||||
$output .= '<table>';
|
||||
$output .= tableFormRow(WebGUI::International::get(99),WebGUI::Form::text("title",20,128,$data{title}));
|
||||
$output .= tableFormRow(WebGUI::International::get(174),WebGUI::Form::checkbox("displayTitle","1",$data{displayTitle}));
|
||||
$output .= tableFormRow(WebGUI::International::get(175),WebGUI::Form::checkbox("processMacros","1",$data{processMacros}));
|
||||
$output .= tableFormRow(WebGUI::International::get(99),
|
||||
WebGUI::Form::text("title",20,128,$data{title}));
|
||||
$output .= tableFormRow(WebGUI::International::get(174),
|
||||
WebGUI::Form::checkbox("displayTitle","1",$data{displayTitle}));
|
||||
$output .= tableFormRow(WebGUI::International::get(175),
|
||||
WebGUI::Form::checkbox("processMacros","1",$data{processMacros}));
|
||||
%hash = WebGUI::Widget::getPositions();
|
||||
$array[0] = $data{templatePosition};
|
||||
$output .= tableFormRow(WebGUI::International::get(363),WebGUI::Form::selectList("templatePosition",\%hash,\@array));
|
||||
$output .= tableFormRow(WebGUI::International::get(3,$namespace),WebGUI::Form::text("startDate",20,30,epochToSet($data{startDate}),1));
|
||||
$output .= tableFormRow(WebGUI::International::get(4,$namespace),WebGUI::Form::text("endDate",20,30,epochToSet($data{endDate}),1));
|
||||
$output .= tableFormRow(WebGUI::International::get(5,$namespace),WebGUI::Form::textArea("body",$data{body},50,10,1));
|
||||
$output .= tableFormRow(WebGUI::International::get(363),
|
||||
WebGUI::Form::selectList("templatePosition",\%hash,\@array));
|
||||
$output .= tableFormRow(WebGUI::International::get(3,$namespace),
|
||||
WebGUI::Form::text("startDate",20,30,epochToSet($data{startDate}),1));
|
||||
$output .= tableFormRow(WebGUI::International::get(4,$namespace),
|
||||
WebGUI::Form::text("endDate",20,30,epochToSet($data{endDate}),1));
|
||||
$output .= tableFormRow(WebGUI::International::get(5,$namespace),
|
||||
WebGUI::Form::textArea("body",$data{body},50,10,1));
|
||||
if ($data{image} ne "") {
|
||||
$output .= tableFormRow(WebGUI::International::get(6,$namespace),'<a href="'.
|
||||
WebGUI::URL::page('func=deleteImage&wid='.$session{form}{wid})
|
||||
|
|
@ -169,16 +196,21 @@ sub www_edit {
|
|||
$array[0] = $data{alignImage};
|
||||
$output .= tableFormRow(WebGUI::International::get(14,$namespace),
|
||||
WebGUI::Form::selectList("alignImage",\%hash,\@array));
|
||||
$output .= tableFormRow(WebGUI::International::get(7,$namespace),WebGUI::Form::text("linkTitle",20,128,$data{linkTitle}));
|
||||
$output .= tableFormRow(WebGUI::International::get(8,$namespace),WebGUI::Form::text("linkURL",20,2048,$data{linkURL}));
|
||||
$output .= tableFormRow(WebGUI::International::get(7,$namespace),
|
||||
WebGUI::Form::text("linkTitle",20,128,$data{linkTitle}));
|
||||
$output .= tableFormRow(WebGUI::International::get(8,$namespace),
|
||||
WebGUI::Form::text("linkURL",20,2048,$data{linkURL}));
|
||||
if ($data{attachment} ne "") {
|
||||
$output .= tableFormRow(WebGUI::International::get(9,$namespace),'<a href="'.
|
||||
WebGUI::URL::page('func=deleteAttachment&wid='.$session{form}{wid})
|
||||
.'">'.WebGUI::International::get(13,$namespace).'</a>');
|
||||
} else {
|
||||
$output .= tableFormRow(WebGUI::International::get(9,$namespace),WebGUI::Form::file("attachment"));
|
||||
$output .= tableFormRow(WebGUI::International::get(9,$namespace),
|
||||
WebGUI::Form::file("attachment"));
|
||||
}
|
||||
$output .= tableFormRow(WebGUI::International::get(10,$namespace),WebGUI::Form::checkbox("convertCarriageReturns",1,$data{convertCarriageReturns}).' <span style="font-size: 8pt;">'.WebGUI::International::get(11,$namespace).'</span>');
|
||||
$output .= tableFormRow(WebGUI::International::get(10,$namespace),
|
||||
WebGUI::Form::checkbox("convertCarriageReturns",1,$data{convertCarriageReturns}).
|
||||
' <span style="font-size: 8pt;">'.WebGUI::International::get(11,$namespace).'</span>');
|
||||
$output .= formSave();
|
||||
$output .= '</table></form>';
|
||||
return $output;
|
||||
|
|
@ -189,18 +221,27 @@ sub www_edit {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editSave {
|
||||
my ($image, $attachment);
|
||||
my ($sqlAdd, $image, $attachment);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
update();
|
||||
$image = WebGUI::Attachment::save("image",$session{form}{wid});
|
||||
if ($image ne "") {
|
||||
$image = ', image='.quote($image);
|
||||
$image = WebGUI::Attachment->new("",$session{form}{wid});
|
||||
$image->save("image");
|
||||
if ($image->getFilename ne "") {
|
||||
$sqlAdd = ', image='.quote($image->getFilename);
|
||||
}
|
||||
$attachment = WebGUI::Attachment::save("attachment",$session{form}{wid});
|
||||
$attachment = WebGUI::Attachment->new("",$session{form}{wid});
|
||||
$attachment->save("attachment");
|
||||
if ($attachment ne "") {
|
||||
$attachment = ', attachment='.quote($attachment);
|
||||
$sqlAdd .= ', attachment='.quote($attachment->getFilename);
|
||||
}
|
||||
WebGUI::SQL->write("update Article set alignImage=".quote($session{form}{alignImage}).", startDate='".setToEpoch($session{form}{startDate})."', endDate='".setToEpoch($session{form}{endDate})."', convertCarriageReturns='$session{form}{convertCarriageReturns}', body=".quote($session{form}{body}).", linkTitle=".quote($session{form}{linkTitle}).", linkURL=".quote($session{form}{linkURL}).$attachment.$image." where widgetId=$session{form}{wid}");
|
||||
WebGUI::SQL->write("update Article set alignImage=".quote($session{form}{alignImage}).
|
||||
", startDate='".setToEpoch($session{form}{startDate}).
|
||||
"', endDate='".setToEpoch($session{form}{endDate}).
|
||||
"', convertCarriageReturns='$session{form}{convertCarriageReturns}', body=".
|
||||
quote($session{form}{body}).", linkTitle=".
|
||||
quote($session{form}{linkTitle}).", linkURL=".
|
||||
quote($session{form}{linkURL}).$sqlAdd.
|
||||
" where widgetId=$session{form}{wid}");
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
|
|
@ -217,7 +258,8 @@ sub www_view {
|
|||
$output = "<h1>".$data{title}."</h1>";
|
||||
}
|
||||
if ($data{image} ne "") {
|
||||
$image = '<img src="'.$session{setting}{attachmentDirectoryWeb}.'/'.$_[0].'/'.$data{image}.'"';
|
||||
$image = WebGUI::Attachment->new($data{image},$_[0]);
|
||||
$image = '<img src="'.$image->getURL.'"';
|
||||
if ($data{alignImage} ne "center") {
|
||||
$image .= ' align="'.$data{alignImage}.'"';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use WebGUI::DateTime;
|
|||
use WebGUI::Form;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Macro;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Shortcut;
|
||||
|
|
@ -39,7 +40,7 @@ sub _reorderDownloads {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub duplicate {
|
||||
my (%data, $newWidgetId, $pageId, %row, $sth, $newDownloadId);
|
||||
my (%data, $file, $newWidgetId, $pageId, %row, $sth, $newDownloadId);
|
||||
tie %data, 'Tie::CPHash';
|
||||
%data = getProperties($namespace,$_[0]);
|
||||
$pageId = $_[1] || $data{pageId};
|
||||
|
|
@ -56,13 +57,17 @@ sub duplicate {
|
|||
$sth = WebGUI::SQL->read("select * from DownloadManager_file where widgetId=$_[0]");
|
||||
while (%row = $sth->hash) {
|
||||
$newDownloadId = getNextId("downloadId");
|
||||
WebGUI::Attachment::copy($row{downloadFile},$_[0],$newWidgetId,$row{downloadId},$newDownloadId);
|
||||
WebGUI::Attachment::copy($row{alternateVersion1},$_[0],$newWidgetId,$row{downloadId},$newDownloadId);
|
||||
WebGUI::Attachment::copy($row{alternateVersion2},$_[0],$newWidgetId,$row{downloadId},$newDownloadId);
|
||||
$file = WebGUI::Attachment->new($row{downloadFile},$_[0],$row{downloadId});
|
||||
$file->copy($newWidgetId,$newDownloadId);
|
||||
$file = WebGUI::Attachment->new($row{alternateVersion1},$_[0],$row{downloadId});
|
||||
$file->copy($newWidgetId,$newDownloadId);
|
||||
$file = WebGUI::Attachment->new($row{alternateVersion2},$_[0],$row{downloadId});
|
||||
$file->copy($newWidgetId,$newDownloadId);
|
||||
WebGUI::SQL->write("insert into DownloadManager_file values ($newDownloadId, $newWidgetId, ".
|
||||
quote($row{fileTitle}).", ".quote($row{downloadFile}).", $row{groupToView}, ".
|
||||
quote($row{briefSynopsis}).", $row{dateUploaded}, $row{sequenceNumber}, ".
|
||||
quote($row{alternateVersion1}).", ".quote($row{alternateVersion2}).")");
|
||||
quote($row{alternateVersion1}).", ".quote($row{alternateVersion2}).
|
||||
", $row{displayThumbnails})");
|
||||
}
|
||||
$sth->finish;
|
||||
}
|
||||
|
|
@ -114,6 +119,10 @@ sub www_add {
|
|||
WebGUI::International::get(20,$namespace),
|
||||
WebGUI::Form::text("paginateAfter",20,30,50)
|
||||
);
|
||||
$output .= tableFormRow(
|
||||
WebGUI::International::get(21,$namespace),
|
||||
WebGUI::Form::checkbox("displayThumbnails",1,1)
|
||||
);
|
||||
$output .= tableFormRow(
|
||||
WebGUI::International::get(3,$namespace),
|
||||
WebGUI::Form::checkbox("proceed",1,1)
|
||||
|
|
@ -140,7 +149,7 @@ sub www_addSave {
|
|||
$session{form}{processMacros},
|
||||
$session{form}{templatePosition}
|
||||
);
|
||||
WebGUI::SQL->write("insert into DownloadManager values ($widgetId, '$session{form}{paginateAfter}')");
|
||||
WebGUI::SQL->write("insert into DownloadManager values ($widgetId, '$session{form}{paginateAfter}', '$session{form}{displayThumbnails}')");
|
||||
if ($session{form}{proceed} == 1) {
|
||||
$session{form}{wid} = $widgetId;
|
||||
return www_addDownload();
|
||||
|
|
@ -198,21 +207,24 @@ sub www_addDownloadSave {
|
|||
my ($downloadId,$file,$alt1,$alt2,$sequenceNumber);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$downloadId = getNextId("downloadId");
|
||||
$file = WebGUI::Attachment::save("downloadFile",$session{form}{wid},$downloadId);
|
||||
$alt1 = WebGUI::Attachment::save("alternateVersion1",$session{form}{wid},$downloadId);
|
||||
$alt2 = WebGUI::Attachment::save("alternateVersion2",$session{form}{wid},$downloadId);
|
||||
$file = WebGUI::Attachment->new("",$session{form}{wid},$downloadId);
|
||||
$file->save("downloadFile");
|
||||
$alt1 = WebGUI::Attachment->new("",$session{form}{wid},$downloadId);
|
||||
$alt1->save("alternateVersion1");
|
||||
$alt2 = WebGUI::Attachment->new("",$session{form}{wid},$downloadId);
|
||||
$alt2->save("alternateVersion2");
|
||||
($sequenceNumber) = WebGUI::SQL->quickArray("select count(*)+1 from DownloadManager_file where widgetId=$session{form}{wid}");
|
||||
WebGUI::SQL->write("insert into DownloadManager_file values (".
|
||||
$downloadId.
|
||||
", ".$session{form}{wid}.
|
||||
", ".quote($session{form}{fileTitle}).
|
||||
", ".quote($file).
|
||||
", ".quote($file->getFilename).
|
||||
", '$session{form}{groupToView}'".
|
||||
", ".quote($session{form}{briefSynopsis}).
|
||||
", ".time().
|
||||
", ".$sequenceNumber.
|
||||
", ".quote($alt1).
|
||||
", ".quote($alt2).
|
||||
", ".quote($alt1->getFilename).
|
||||
", ".quote($alt2->getFilename).
|
||||
")");
|
||||
return www_edit();
|
||||
} else {
|
||||
|
|
@ -268,8 +280,10 @@ sub www_deleteDownload {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteDownloadConfirm {
|
||||
my ($output);
|
||||
my ($output, $file);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$file = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{did});
|
||||
$file->deleteNode;
|
||||
WebGUI::SQL->write("delete from DownloadManager_file where downloadId=$session{form}{did}");
|
||||
_reorderDownloads($session{form}{wid});
|
||||
return www_edit();
|
||||
|
|
@ -280,19 +294,24 @@ sub www_deleteDownloadConfirm {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_download {
|
||||
my (%download, $url);
|
||||
my (%download, $file);
|
||||
tie %download,'Tie::CPHash';
|
||||
%download = WebGUI::SQL->quickHash("select * from DownloadManager_file where downloadId=$session{form}{did}");
|
||||
if (WebGUI::Privilege::isInGroup($download{groupToView})) {
|
||||
$url = $session{setting}{attachmentDirectoryWeb}."/".$session{form}{wid}."/".$session{form}{did}."/";
|
||||
if ($session{form}{alternateVersion} == 1) {
|
||||
$url .= $download{alternateVersion1};
|
||||
$file = WebGUI::Attachment->new($download{alternateVersion1},
|
||||
$session{form}{wid},
|
||||
$session{form}{did});
|
||||
} elsif ($session{form}{alternateVersion} == 2) {
|
||||
$url .= $download{alternateVersion2};
|
||||
$file = WebGUI::Attachment->new($download{alternateVersion2},
|
||||
$session{form}{wid},
|
||||
$session{form}{did});
|
||||
} else {
|
||||
$url .= $download{downloadFile};
|
||||
$file = WebGUI::Attachment->new($download{downloadFile},
|
||||
$session{form}{wid},
|
||||
$session{form}{did});
|
||||
}
|
||||
$session{header}{redirect} = WebGUI::Session::httpRedirect($url);
|
||||
$session{header}{redirect} = WebGUI::Session::httpRedirect($file->getURL);
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
|
|
@ -339,6 +358,10 @@ sub www_edit {
|
|||
WebGUI::International::get(20,$namespace),
|
||||
WebGUI::Form::text("paginateAfter",20,30,$data{paginateAfter})
|
||||
);
|
||||
$output .= tableFormRow(
|
||||
WebGUI::International::get(21,$namespace),
|
||||
WebGUI::Form::checkbox("displayThumbnails","1",$data{displayThumbnails})
|
||||
);
|
||||
$output .= formSave();
|
||||
$output .= '</table></form>';
|
||||
$output .= '<p><a href="'.WebGUI::URL::page('func=addDownload&wid='.$session{form}{wid})
|
||||
|
|
@ -372,7 +395,7 @@ sub www_edit {
|
|||
sub www_editSave {
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
update();
|
||||
WebGUI::SQL->write("update DownloadManager set paginateAfter='$session{form}{paginateAfter}' where widgetId=$session{form}{wid}");
|
||||
WebGUI::SQL->write("update DownloadManager set paginateAfter='$session{form}{paginateAfter}', displayThumbnails='$session{form}{displayThumbnails}' where widgetId=$session{form}{wid}");
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
|
|
@ -452,25 +475,28 @@ sub www_editDownload {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editDownloadSave {
|
||||
my ($file, $alt1, $alt2);
|
||||
my ($file, $alt1, $alt2, $sqlAdd);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$file = WebGUI::Attachment::save("downloadFile",$session{form}{wid},$session{form}{did});
|
||||
if ($file ne "") {
|
||||
$file = ', downloadFile='.quote($file);
|
||||
$file = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{did});
|
||||
$file->save("downloadFile");
|
||||
if ($file->getFilename ne "") {
|
||||
$sqlAdd = ', downloadFile='.quote($file->getFilename);
|
||||
}
|
||||
$alt1 = WebGUI::Attachment::save("alternateVersion1",$session{form}{wid},$session{form}{did});
|
||||
if ($alt1 ne "") {
|
||||
$alt1 = ', alternateVersion1='.quote($alt1);
|
||||
$alt1 = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{did});
|
||||
$alt1->save("alternateVersion1");
|
||||
if ($alt1->getFilename ne "") {
|
||||
$sqlAdd .= ', alternateVersion1='.quote($alt1->getFilename);
|
||||
}
|
||||
$alt2 = WebGUI::Attachment::save("alternateVersion2",$session{form}{wid},$session{form}{did});
|
||||
if ($alt2 ne "") {
|
||||
$alt2 = ', alternateVersion2='.quote($alt2);
|
||||
$alt2 = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{did});
|
||||
$alt2->save("alternateVersion2");
|
||||
if ($alt2->getFilename ne "") {
|
||||
$sqlAdd = ', alternateVersion2='.quote($alt2->getFilename);
|
||||
}
|
||||
WebGUI::SQL->write("update DownloadManager_file set ".
|
||||
" downloadId=".$session{form}{did}.
|
||||
", widgetId=".$session{form}{wid}.
|
||||
", fileTitle=".quote($session{form}{fileTitle}).
|
||||
$file.$alt1.$alt2.
|
||||
$sqlAdd.
|
||||
", groupToView='$session{form}{groupToView}'".
|
||||
", briefSynopsis=".quote($session{form}{briefSynopsis}).
|
||||
", dateUploaded=".time().
|
||||
|
|
@ -516,7 +542,7 @@ sub www_moveDownloadUp {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my ($url, @row, $i, $dataRows, $search, $prevNextBar, %data, @test, %fileType, $output, $sth,
|
||||
my ($url, @row, $i, $p, $search, %data, @test, $file, $alt1, $alt2, $output, $sth,
|
||||
%download, $flag, $sort, $sortDirection);
|
||||
tie %download, 'Tie::CPHash';
|
||||
tie %data, 'Tie::CPHash';
|
||||
|
|
@ -562,29 +588,38 @@ sub www_view {
|
|||
$sth = WebGUI::SQL->read("select * from DownloadManager_file where widgetId=$_[0] $search $sort $sortDirection");
|
||||
while (%download = $sth->hash) {
|
||||
if (WebGUI::Privilege::isInGroup($download{groupToView})) {
|
||||
%fileType = WebGUI::Attachment::getType($download{downloadFile});
|
||||
$file = WebGUI::Attachment->new($download{downloadFile},
|
||||
$_[0], $download{downloadId});
|
||||
$row[$i] = '<tr><td class="tableData" valign="top">';
|
||||
$row[$i] .= '<a href="'.WebGUI::URL::page('func=download&wid='.$_[0].
|
||||
'&did='.$download{downloadId}).'"><img src="'.$fileType{icon}.
|
||||
'&did='.$download{downloadId}).'"><img src="'.$file->getIcon.
|
||||
'" border=0 width=16 height=16 align="middle">'.
|
||||
$download{fileTitle}.' ('.$fileType{extension}.')</a>';
|
||||
$download{fileTitle}.' ('.$file->getType.')</a>';
|
||||
if ($download{alternateVersion1}) {
|
||||
%fileType = WebGUI::Attachment::getType($download{alternateVersion1});
|
||||
$alt1 = WebGUI::Attachment->new($download{alternateVersion1},
|
||||
$_[0], $download{downloadId});
|
||||
$row[$i] .= ' · <a href="'.WebGUI::URL::page('func=download&wid='.
|
||||
$_[0].'&did='.$download{downloadId}.'&alternateVersion=1')
|
||||
.'"><img src="'.$fileType{icon}.
|
||||
.'"><img src="'.$alt1->getIcon.
|
||||
'" border=0 width=16 height=16 align="middle">('.
|
||||
$fileType{extension}.')</a>';
|
||||
$alt1->getType.')</a>';
|
||||
}
|
||||
if ($download{alternateVersion2}) {
|
||||
%fileType = WebGUI::Attachment::getType($download{alternateVersion2});
|
||||
$alt2 = WebGUI::Attachment->new($download{alternateVersion2},
|
||||
$_[0], $download{downloadId});
|
||||
$row[$i] .= ' · <a href="'.WebGUI::URL::page('func=download&wid='.
|
||||
$_[0].'&did='.$download{downloadId}.'&alternateVersion=2')
|
||||
.'"><img src="'.$fileType{icon}.
|
||||
.'"><img src="'.$alt2->getIcon.
|
||||
'" border=0 width=16 height=16 align="middle">('.
|
||||
$fileType{extension}.')</a>';
|
||||
$alt2->getType.')</a>';
|
||||
}
|
||||
$row[$i] .= '</td><td class="tableData" valign="top">'.$download{briefSynopsis}.'</td>'.
|
||||
$row[$i] .= '</td><td class="tableData" valign="top">';
|
||||
if ($data{displayThumbnails}
|
||||
&& isIn($file->getType, qw(gif jpeg jpg tif tiff png bmp))) {
|
||||
$row[$i] .= '<img src="'.$file->getThumbnail.
|
||||
'" border=0 align="middle" hspace="3">';
|
||||
}
|
||||
$row[$i] .= $download{briefSynopsis}.'</td>'.
|
||||
'<td class="tableData" valign="top">'.
|
||||
epochToHuman($download{dateUploaded},"%M/%D/%y").'</td>'.
|
||||
'</tr>';
|
||||
|
|
@ -597,10 +632,10 @@ sub www_view {
|
|||
$output .= '<tr><td class="tableData" colspan="3">'.
|
||||
WebGUI::International::get(19,$namespace).'</td></tr>';
|
||||
}
|
||||
($dataRows, $prevNextBar) = paginate($data{paginateAfter},$url,\@row);
|
||||
$output .= $dataRows;
|
||||
$p = WebGUI::Paginator->new($url,\@row,$data{paginateAfter});
|
||||
$output .= $p->getPage($session{form}{pn});
|
||||
$output .= '</table>';
|
||||
$output .= $prevNextBar;
|
||||
$output .= $p->getBarTraditional($session{form}{pn});
|
||||
if ($data{processMacros} == 1) {
|
||||
$output = WebGUI::Macro::process($output);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use Tie::CPHash;
|
|||
use WebGUI::DateTime;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Macro;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Shortcut;
|
||||
|
|
@ -304,13 +305,14 @@ sub www_edit {
|
|||
$output .= '<p><a href="'.WebGUI::URL::page('func=addEvent&wid='.$session{form}{wid})
|
||||
.'">Add New Event</a><p>';
|
||||
$output .= '<table border=1 cellpadding=3 cellspacing=0>';
|
||||
$sth = WebGUI::SQL->read("select eventId, name, recurringEventId from EventsCalendar_event where widgetId='$session{form}{wid}' order by startDate");
|
||||
$sth = WebGUI::SQL->read("select eventId, name, recurringEventId, startDate from EventsCalendar_event where widgetId='$session{form}{wid}' order by startDate");
|
||||
while (@event = $sth->array) {
|
||||
$output .= '<tr><td><a href="'.WebGUI::URL::page('func=editEvent&wid='.$session{form}{wid}.
|
||||
'&eid='.$event[0]).'"><img src="'.$session{setting}{lib}.
|
||||
'/edit.gif" border=0></a><a href="'.WebGUI::URL::page('func=deleteEvent&wid='.
|
||||
$session{form}{wid}.'&eid='.$event[0].'&rid='.$event[2]).'"><img src="'.
|
||||
$session{setting}{lib}.'/delete.gif" border=0></a></td><td>'.$event[1].'</td></td>';
|
||||
$session{setting}{lib}.'/delete.gif" border=0></a></td><td>'.
|
||||
epochToHuman($event[3],'%m/%d/%y').'</td><td>'.$event[1].'</td></td>';
|
||||
}
|
||||
$sth->finish;
|
||||
$output .= '</table>';
|
||||
|
|
@ -373,7 +375,7 @@ sub www_editEventSave {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my (%data, %event, $dataRows, $prevNextBar, $output, $sth, $flag, %previous, $junk,
|
||||
my (%data, %event, $p, $output, $sth, $flag, %previous, $junk,
|
||||
@row, $i, $maxDate, $minDate, $nextDate, $first, $last);
|
||||
tie %data, 'Tie::CPHash';
|
||||
tie %event, 'Tie::CPHash';
|
||||
|
|
@ -401,8 +403,10 @@ sub www_view {
|
|||
$i++;
|
||||
$nextDate = addToDate($nextDate,0,1,0);
|
||||
}
|
||||
($dataRows, $prevNextBar) = paginate(1,WebGUI::URL::page(),\@row);
|
||||
$output .= $prevNextBar.$dataRows.$prevNextBar;
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page(),\@row,1);
|
||||
$output .= $p->getBar($session{form}{pn}).
|
||||
$p->getPage($session{form}{pn}).
|
||||
$p->getBarTraditional($session{form}{pn});
|
||||
$session{form}{pn} = "";
|
||||
} else {
|
||||
$sth = WebGUI::SQL->read("select name, description, startDate, endDate from EventsCalendar_event where widgetId='$_[0]' and endDate>".(time()-86400)." order by startDate,endDate");
|
||||
|
|
@ -434,8 +438,8 @@ sub www_view {
|
|||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
($dataRows, $prevNextBar) = paginate($data{paginateAfter},WebGUI::URL::page(),\@row);
|
||||
$output .= $dataRows.$prevNextBar;
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page(),\@row,$data{paginateAfter});
|
||||
$output .= $p->getPage($session{form}{pn}).$p->getBarSimple($session{form}{pn});
|
||||
}
|
||||
if ($data{processMacros}) {
|
||||
$output = WebGUI::Macro::process($output);
|
||||
|
|
|
|||
|
|
@ -26,13 +26,14 @@ use WebGUI::Widget;
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub duplicate {
|
||||
my (%data, $newWidgetId, $pageId);
|
||||
my (%data, $newWidgetId, $pageId, $file);
|
||||
tie %data, 'Tie::CPHash';
|
||||
%data = getProperties($namespace,$_[0]);
|
||||
$pageId = $_[1] || $data{pageId};
|
||||
$newWidgetId = create($pageId,$namespace,$data{title},
|
||||
$data{displayTitle},$data{description},$data{processMacros},$data{templatePosition});
|
||||
WebGUI::Attachment::copy($data{attachment},$_[0],$newWidgetId);
|
||||
$file = WebGUI::Attachment->new($data{attachment},$_[0]);
|
||||
$file->copy($newWidgetId);
|
||||
WebGUI::SQL->write("insert into Item values ($newWidgetId, ".
|
||||
quote($data{description}).", ".quote($data{linkURL}).", ".quote($data{attachment}).")");
|
||||
}
|
||||
|
|
@ -79,7 +80,8 @@ sub www_addSave {
|
|||
my ($widgetId, $attachment);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$widgetId = create($session{page}{pageId},$session{form}{widget},$session{form}{title},$session{form}{displayTitle},$session{form}{description},$session{form}{processMacros},$session{form}{templatePosition});
|
||||
$attachment = WebGUI::Attachment::save("attachment",$widgetId);
|
||||
$attachment = WebGUI::Attachment->new("",$widgetId);
|
||||
$attachment->save("attachment");
|
||||
WebGUI::SQL->write("insert into Item values ($widgetId, ".quote($session{form}{description}).", ".quote($session{form}{linkURL}).", ".quote($attachment).")");
|
||||
return "";
|
||||
} else {
|
||||
|
|
@ -149,14 +151,17 @@ sub www_edit {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editSave {
|
||||
my ($attachment);
|
||||
my ($attachment, $sqlAdd);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
update();
|
||||
$attachment = WebGUI::Attachment::save("attachment",$session{form}{wid});
|
||||
if ($attachment ne "") {
|
||||
$attachment = ', attachment='.quote($attachment);
|
||||
$attachment = WebGUI::Attachment->new("",$session{form}{wid});
|
||||
$attachment->save("attachment");
|
||||
if ($attachment->getFilename ne "") {
|
||||
$sqlAdd = ', attachment='.quote($attachment->getFilename);
|
||||
}
|
||||
WebGUI::SQL->write("update Item set description=".quote($session{form}{description}).", linkURL=".quote($session{form}{linkURL}).$attachment." where widgetId=$session{form}{wid}");
|
||||
WebGUI::SQL->write("update Item set description=".quote($session{form}{description}).
|
||||
", linkURL=".quote($session{form}{linkURL}).
|
||||
$sqlAdd." where widgetId=$session{form}{wid}");
|
||||
return "";
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
|
|
@ -165,7 +170,7 @@ sub www_editSave {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my (%data, @test, $output, %fileType);
|
||||
my (%data, @test, $output, $file);
|
||||
tie %data, 'Tie::CPHash';
|
||||
%data = getProperties($namespace,$_[0]);
|
||||
if (defined %data) {
|
||||
|
|
@ -175,9 +180,8 @@ sub www_view {
|
|||
$output .= '<span class="itemTitle">'.$data{title}.'</span>';
|
||||
}
|
||||
if ($data{attachment} ne "") {
|
||||
%fileType = WebGUI::Attachment::getType($data{attachment});
|
||||
$output .= ' - <a href="'.$session{setting}{attachmentDirectoryWeb}.'/'.$_[0].'/'.
|
||||
$data{attachment}.'"><img src="'.$fileType{icon}.'" border=0 alt="'.
|
||||
$file = WebGUI::Attachment->new($data{attachment},$_[0]);
|
||||
$output .= ' - <a href="'.$file->getURL.'"><img src="'.$file->getIcon.'" border=0 alt="'.
|
||||
$data{attachment}.'" width=16 height=16 border=0 align="middle"></a>';
|
||||
}
|
||||
if ($data{description} ne "") {
|
||||
|
|
@ -193,7 +197,5 @@ sub www_view {
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ use strict;
|
|||
use WebGUI::ErrorHandler;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Macro;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Shortcut;
|
||||
|
|
@ -187,7 +188,7 @@ sub www_editSave {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my (@row, $i, $dataRows, $prevNextBar, $ouch, %data, $output, $sth, $dbh, @result,
|
||||
my (@row, $i, $p, $ouch, %data, $output, $sth, $dbh, @result,
|
||||
@template, $temp, $col);
|
||||
tie %data, 'Tie::CPHash';
|
||||
%data = getProperties($namespace,$_[0]);
|
||||
|
|
@ -239,10 +240,10 @@ sub www_view {
|
|||
$i++;
|
||||
}
|
||||
$sth->finish;
|
||||
($dataRows, $prevNextBar) = paginate($data{paginateAfter},WebGUI::URL::page(),\@row);
|
||||
$output .= $dataRows;
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page(),\@row,$data{paginateAfter});
|
||||
$output .= $p->getPage($session{form}{pn});
|
||||
$output .= $template[2];
|
||||
$output .= $prevNextBar;
|
||||
$output .= $p->getBar($session{form}{pn});
|
||||
} else {
|
||||
$output .= WebGUI::International::get(11,$namespace).'<p>';
|
||||
WebGUI::ErrorHandler::warn("SQLReport [$_[0]] There was a problem with the query.");
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ use WebGUI::International;
|
|||
use WebGUI::Macro;
|
||||
use WebGUI::MessageLog;
|
||||
use WebGUI::Operation;
|
||||
use WebGUI::Paginator;
|
||||
use WebGUI::Privilege;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Shortcut;
|
||||
|
|
@ -30,17 +31,21 @@ use WebGUI::Widget;
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub duplicate {
|
||||
my ($sth, %data, $newWidgetId, @row, $newSubmissionId, $pageId);
|
||||
my ($sth, $file, %data, $newWidgetId, @row, $newSubmissionId, $pageId);
|
||||
tie %data, 'Tie::CPHash';
|
||||
%data = getProperties($namespace,$_[0]);
|
||||
$pageId = $_[1] || $data{pageId};
|
||||
$newWidgetId = create($pageId,$namespace,$data{title},$data{displayTitle},$data{description},$data{processMacros},$data{templatePosition});
|
||||
$newWidgetId = create($pageId,$namespace,$data{title},$data{displayTitle},
|
||||
$data{description},$data{processMacros},$data{templatePosition});
|
||||
WebGUI::SQL->write("insert into UserSubmission values ($newWidgetId, $data{groupToContribute}, '$data{submissionsPerPage}', '$data{defaultStatus}', $data{groupToApprove})");
|
||||
$sth = WebGUI::SQL->read("select * from UserSubmission_submission where widgetId=$_[0]");
|
||||
while (@row = $sth->array) {
|
||||
$newSubmissionId = getNextId("submissionId");
|
||||
WebGUI::Attachment::copy($row[8],$_[0],$newWidgetId,$row[1],$newSubmissionId);
|
||||
WebGUI::SQL->write("insert into UserSubmission_submission values ($newWidgetId, $newSubmissionId, ".quote($row[2]).", $row[3], ".quote($row[4]).", '$row[5]', ".quote($row[6]).", ".quote($row[7]).", ".quote($row[8]).", '$row[9]', '$row[10]')");
|
||||
$file = WebGUI::Attachment->new($row[8],$_[0],$row[1]);
|
||||
$file->copy($newWidgetId,$newSubmissionId);
|
||||
WebGUI::SQL->write("insert into UserSubmission_submission values ($newWidgetId, $newSubmissionId, ".
|
||||
quote($row[2]).", $row[3], ".quote($row[4]).", '$row[5]', ".quote($row[6]).", ".
|
||||
quote($row[7]).", ".quote($row[8]).", '$row[9]', '$row[10]')");
|
||||
}
|
||||
$sth->finish;
|
||||
}
|
||||
|
|
@ -93,7 +98,9 @@ sub www_add {
|
|||
sub www_addSave {
|
||||
my ($widgetId);
|
||||
if (WebGUI::Privilege::canEditPage()) {
|
||||
$widgetId = create($session{page}{pageId},$session{form}{widget},$session{form}{title},$session{form}{displayTitle},$session{form}{description},$session{form}{processMacros},$session{form}{templatePosition});
|
||||
$widgetId = create($session{page}{pageId},$session{form}{widget},$session{form}{title},
|
||||
$session{form}{displayTitle},$session{form}{description},$session{form}{processMacros},
|
||||
$session{form}{templatePosition});
|
||||
WebGUI::SQL->write("insert into UserSubmission values ($widgetId, $session{form}{groupToContribute}, '$session{form}{submissionsPerPage}', '$session{form}{defaultStatus}', $session{form}{groupToApprove})");
|
||||
return "";
|
||||
} else {
|
||||
|
|
@ -146,14 +153,21 @@ sub www_addSubmissionSave {
|
|||
%userSubmission = getProperties($namespace,$session{form}{wid});
|
||||
if (WebGUI::Privilege::isInGroup($userSubmission{groupToContribute},$session{user}{userId})) {
|
||||
$submissionId = getNextId("submissionId");
|
||||
$image = WebGUI::Attachment::save("image",$session{form}{wid},$submissionId);
|
||||
$attachment = WebGUI::Attachment::save("attachment",$session{form}{wid},$submissionId);
|
||||
$image = WebGUI::Attachment->new("",$session{form}{wid},$submissionId);
|
||||
$image->save("image");
|
||||
$attachment = WebGUI::Attachment->new("",$session{form}{wid},$submissionId);
|
||||
$attachment->save("attachment");
|
||||
if ($session{form}{title} ne "") {
|
||||
$title = $session{form}{title};
|
||||
} else {
|
||||
$title = WebGUI::International::get(16,$namespace);
|
||||
}
|
||||
WebGUI::SQL->write("insert into UserSubmission_submission values ($session{form}{wid}, $submissionId, ".quote($title).", ".time().", ".quote($session{user}{username}).", '$session{user}{userId}', ".quote($session{form}{content}).", ".quote($image).", ".quote($attachment).", '$userSubmission{defaultStatus}', '$session{form}{convertCarriageReturns}')");
|
||||
WebGUI::SQL->write("insert into UserSubmission_submission values ($session{form}{wid}, $submissionId, "
|
||||
.quote($title).", ".time().", ".quote($session{user}{username}).
|
||||
", '$session{user}{userId}', ".quote($session{form}{content}).", ".
|
||||
quote($image->getFilename).", ".
|
||||
quote($attachment->getFilename).
|
||||
", '$userSubmission{defaultStatus}', '$session{form}{convertCarriageReturns}')");
|
||||
if ($userSubmission{defaultStatus} ne "Approved") {
|
||||
WebGUI::MessageLog::addEntry('',$userSubmission{groupToApprove},
|
||||
WebGUI::URL::page('func=viewSubmission&wid='.$session{form}{wid}.
|
||||
|
|
@ -233,10 +247,12 @@ sub www_deleteSubmission {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_deleteSubmissionConfirm {
|
||||
my ($output, $owner);
|
||||
my ($output, $owner, $file);
|
||||
($owner) = WebGUI::SQL->quickArray("select userId from UserSubmission_submission where submissionId=$session{form}{sid}");
|
||||
if ($owner == $session{user}{userId}) {
|
||||
WebGUI::SQL->write("delete from UserSubmission_submission where submissionId=$session{form}{sid}");
|
||||
$file = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{sid});
|
||||
$file->deleteNode;
|
||||
return www_addSubmission();
|
||||
} else {
|
||||
return WebGUI::Privilege::insufficient();
|
||||
|
|
@ -347,24 +363,29 @@ sub www_editSubmission {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_editSubmissionSave {
|
||||
my ($owner,%userSubmission,$image,$attachment,$title);
|
||||
my ($sqlAdd,$owner,%userSubmission,$image,$attachment,$title);
|
||||
($owner) = WebGUI::SQL->quickArray("select userId from UserSubmission_submission where submissionId=$session{form}{sid}");
|
||||
if ($owner == $session{user}{userId}) {
|
||||
%userSubmission = getProperties($namespace,$session{form}{wid});
|
||||
$image = WebGUI::Attachment::save("image",$session{form}{wid},$session{form}{sid});
|
||||
if ($image ne "") {
|
||||
$image = 'image='.quote($image).', ';
|
||||
$image = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{sid});
|
||||
$image->save("image");
|
||||
if ($image->getFilename ne "") {
|
||||
$sqlAdd = 'image='.quote($image->getFilename).', ';
|
||||
}
|
||||
$attachment = WebGUI::Attachment::save("attachment",$session{form}{wid},$session{form}{sid});
|
||||
if ($attachment ne "") {
|
||||
$attachment = 'attachment='.quote($attachment).', ';
|
||||
$attachment = WebGUI::Attachment->new("",$session{form}{wid},$session{form}{sid});
|
||||
$attachment->save("attachment");
|
||||
if ($attachment->getFilename ne "") {
|
||||
$sqlAdd .= 'attachment='.quote($attachment->getFilename).', ';
|
||||
}
|
||||
if ($session{form}{title} ne "") {
|
||||
$title = $session{form}{title};
|
||||
} else {
|
||||
$title = WebGUI::International::get(16,$namespace);
|
||||
}
|
||||
WebGUI::SQL->write("update UserSubmission_submission set dateSubmitted=".time().", convertCarriageReturns='$session{form}{convertCarriageReturns}', title=".quote($title).", content=".quote($session{form}{content}).", ".$image.$attachment." status='$userSubmission{defaultStatus}' where submissionId=$session{form}{sid}");
|
||||
WebGUI::SQL->write("update UserSubmission_submission set dateSubmitted=".time().
|
||||
", convertCarriageReturns='$session{form}{convertCarriageReturns}', title=".quote($title).
|
||||
", content=".quote($session{form}{content}).", ".$sqlAdd.
|
||||
" status='$userSubmission{defaultStatus}' where submissionId=$session{form}{sid}");
|
||||
if ($userSubmission{defaultStatus} ne "Approved") {
|
||||
WebGUI::MessageLog::addEntry('',$userSubmission{groupToApprove},
|
||||
WebGUI::URL::page('func=viewSubmission&wid='.$session{form}{wid}.'&sid='.
|
||||
|
|
@ -378,7 +399,7 @@ sub www_editSubmissionSave {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_view {
|
||||
my (%data, @submission, $output, $sth, @row, $i, $dataRows, $prevNextBar);
|
||||
my (%data, @submission, $output, $sth, @row, $i, $p);
|
||||
tie %data, 'Tie::CPHash';
|
||||
%data = getProperties($namespace,$_[0]);
|
||||
if (%data) {
|
||||
|
|
@ -404,19 +425,21 @@ sub www_view {
|
|||
$output .= '<table width="100%" cellpadding=2 cellspacing=1 border=0><tr>'.
|
||||
'<td align="right" class="tableMenu"><a href="'.WebGUI::URL::page('func=addSubmission&wid='.
|
||||
$_[0]).'">'.WebGUI::International::get(20,$namespace).'</a></td></tr></table>';
|
||||
($dataRows, $prevNextBar) = paginate($data{submissionsPerPage},WebGUI::URL::page(),\@row);
|
||||
$p = WebGUI::Paginator->new(WebGUI::URL::page(),\@row,$data{submissionsPerPage});
|
||||
$output .= '<table width="100%" cellspacing=1 cellpadding=2 border=0>';
|
||||
$output .= '<tr><td class="tableHeader">'.WebGUI::International::get(99).'</td><td class="tableHeader">'.WebGUI::International::get(13,$namespace).'</td><td class="tableHeader">'.WebGUI::International::get(21,$namespace).'</td></tr>';
|
||||
$output .= $dataRows;
|
||||
$output .= '<tr><td class="tableHeader">'.WebGUI::International::get(99).
|
||||
'</td><td class="tableHeader">'.WebGUI::International::get(13,$namespace).
|
||||
'</td><td class="tableHeader">'.WebGUI::International::get(21,$namespace).'</td></tr>';
|
||||
$output .= $p->getPage($session{form}{pn});
|
||||
$output .= '</table>';
|
||||
$output .= $prevNextBar;
|
||||
$output .= $p->getBarTraditional($session{form}{pn});
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_viewSubmission {
|
||||
my ($output, %submission);
|
||||
my ($output, %submission, $file);
|
||||
tie %submission, 'Tie::CPHash';
|
||||
%submission = WebGUI::SQL->quickHash("select * from UserSubmission_submission where submissionId=$session{form}{sid}");
|
||||
$output = "<h1>".$submission{title}."</h1>";
|
||||
|
|
@ -448,7 +471,8 @@ sub www_viewSubmission {
|
|||
$output .= '</td</tr><tr><td class="tableData">';
|
||||
#---content
|
||||
if ($submission{image} ne "") {
|
||||
$output .= '<img src="'.$session{setting}{attachmentDirectoryWeb}.'/'.$session{form}{wid}.'/'.$session{form}{sid}.'/'.$submission{image}.'" hspace=3 align="right">';
|
||||
$file = WebGUI::Attachment->new($submission{filename},$session{form}{wid},$session{form}{sid});
|
||||
$output .= '<img src="'.$file->getURL.'" hspace=3 align="right">';
|
||||
}
|
||||
if ($submission{convertCarriageReturns}) {
|
||||
$submission{content} =~ s/\n/\<br\>/g;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ use DBD::mysql ();
|
|||
use Data::Config ();
|
||||
use Date::Calc ();
|
||||
use HTML::CalendarMonthSimple ();
|
||||
use Image::Magick ();
|
||||
use Tie::CPHash ();
|
||||
use Tie::IxHash ();
|
||||
use Net::LDAP ();
|
||||
|
|
|
|||
|
|
@ -202,6 +202,18 @@ if (eval { require HTML::CalendarMonthSimple }) {
|
|||
}
|
||||
}
|
||||
|
||||
print "Image::Magick module.....................";
|
||||
if (eval { require Image::Magick }) {
|
||||
print "OK\n";
|
||||
} else {
|
||||
if ($ARGV[0] eq "--install-modules") {
|
||||
print "Installing...\n";
|
||||
CPAN::Shell->install("Image::Magick");
|
||||
} else {
|
||||
print "Please install.\n";
|
||||
}
|
||||
}
|
||||
|
||||
# this is here to insure they installed correctly.
|
||||
print "WebGUI modules...........................";
|
||||
if (eval { require WebGUI } && eval { require WebGUI::SQL }) {
|
||||
|
|
|
|||
BIN
www/extras/fileIcons/exe.gif
Normal file
BIN
www/extras/fileIcons/exe.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 135 B |
BIN
www/extras/fileIcons/gz.gif
Normal file
BIN
www/extras/fileIcons/gz.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 205 B |
BIN
www/extras/fileIcons/psd.gif
Normal file
BIN
www/extras/fileIcons/psd.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1 KiB |
BIN
www/extras/fileIcons/sit.gif
Normal file
BIN
www/extras/fileIcons/sit.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 174 B |
|
|
@ -11,6 +11,7 @@
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
my $webguiRoot = "..";
|
||||
my $configFile = "WebGUI.conf";
|
||||
|
||||
BEGIN {
|
||||
unshift (@INC, "../lib");
|
||||
|
|
@ -22,5 +23,5 @@ use CGI::Carp qw(fatalsToBrowser);
|
|||
use strict;
|
||||
use WebGUI;
|
||||
|
||||
print WebGUI::page($webguiRoot);
|
||||
print WebGUI::page($webguiRoot,$configFile);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue