several bug fixes

This commit is contained in:
JT Smith 2004-09-15 21:47:00 +00:00
parent 930368341e
commit 3b7e401e95
5 changed files with 41 additions and 28 deletions

View file

@ -145,7 +145,7 @@ sub copy {
$b = FileHandle->new(">".$newNode->getPath.$session{os}{slash}.'thumb-'.$_[0]->getFilename);
if (defined $b) {
binmode($b);
cp($a,$b);
cp($a,$b) or WebGUI::ErrorHandler::warn("Couldn't copy thumbnail: ".)$newNode->getPath.$session{os}{slash}.'thumb-'.$_[0]->getFilename." :".$!);
$b->close;
}
$a->close;
@ -613,25 +613,29 @@ sub saveFromFilesystem {
}
$_[0]->{_filename} = WebGUI::URL::makeCompliant($_[0]->getFilename);
$_[0]->getNode->create();
$a = FileHandle->new($_[1],"r");
if (defined $a) {
binmode($a);
$b = FileHandle->new(">".$_[0]->getPath);
if (defined $b) {
binmode($b);
cp($a,$b);
$b->close;
$_[0]->createThumbnail($_[2]);
$_[0]->resizeImage($_[3]);
} else {
WebGUI::ErrorHandler::warn("Couldn't open file ".$_[0]->getPath." for writing due to error: ".$!);
$_[0]->{_filename} = "";
}
$a->close;
if (-d $_[1]) {
WebGUI::ErrorHandler::warn($_[1]." is a directory, not a file.");
} else {
WebGUI::ErrorHandler::warn("Couldn't open file ".$_[1]." for reading due to error: ".$!);
$_[0]->{_filename} = "";
}
$a = FileHandle->new($_[1],"r");
if (defined $a) {
binmode($a);
$b = FileHandle->new(">".$_[0]->getPath);
if (defined $b) {
binmode($b);
cp($a,$b) or WebGUI::ErrorHandler::warn("Couldn't copy $_[1] to ".$_[0]->getPath.": $!");;
$b->close;
$_[0]->createThumbnail($_[2]);
$_[0]->resizeImage($_[3]);
} else {
WebGUI::ErrorHandler::warn("Couldn't open file ".$_[0]->getPath." for writing due to error: ".$!);
$_[0]->{_filename} = "";
}
$a->close;
} else {
WebGUI::ErrorHandler::warn("Couldn't open file ".$_[1]." for reading due to error: ".$!);
$_[0]->{_filename} = "";
}
}
} else {
$_[0]->{_filename} = "";
}

View file

@ -376,6 +376,7 @@ The message you wish to write to the log.
sub writeLog {
if (my $log = FileHandle->new(">>".$WebGUI::Session::session{config}{logfile})) {
print $log $_[0];
printf $log '%s:%d (sub %s) ',(caller(2))[1,2,3];
$log->close;
} else {
use CGI;

View file

@ -20,6 +20,7 @@ use WebGUI::Grouping;
use WebGUI::HTMLForm;
use WebGUI::HTTP;
use WebGUI::Icon;
use WebGUI::Id;
use WebGUI::International;
use WebGUI::Node;
use WebGUI::Operation::Shared;
@ -111,7 +112,7 @@ sub www_addThemeComponentSave {
$id =~ /^(.*?)\_(.*)/;
my $type = $1;
$id = $2;
my $componentId = getNextId("themeComponentId");
my $componentId = WebGUI::Id::generate();
WebGUI::SQL->write("insert into themeComponent (themeId,themeComponentId,type,id)
values ($session{form}{themeId}, $componentId, ".quote($type).", ".quote($id).")");
}
@ -245,7 +246,7 @@ sub www_editTheme {
sub www_editThemeSave {
return WebGUI::Privilege::insufficient unless (WebGUI::Grouping::isInGroup(9));
if ($session{form}{themeId} eq "new") {
$session{form}{themeId} = getNextId("themeId");
$session{form}{themeId} = WebGUI::Id::generate();
WebGUI::SQL->write("insert into theme (themeId,webguiVersion,original,versionNumber)
values ($session{form}{themeId},".quote($WebGUI::VERSION).",1,0)");
}
@ -385,17 +386,17 @@ sub www_importThemeSave {
return WebGUI::Privilege::insufficient unless (WebGUI::Grouping::isInGroup(9));
my $propertiesFile = WebGUI::Attachment->new("_theme.properties","temp",$session{form}{extractionPoint});
my $theme = $propertiesFile->getHashref;
my $themeId = getNextId("themeId");
my $themeId = WebGUI::Id::generate();
WebGUI::SQL->write("insert into theme (themeId,name,designer,designerURL,webguiVersion,versionNumber,original) values
($themeId, ".quote($theme->{name}).", ".quote($theme->{designer}).", ".quote($theme->{designerURL})
.", ".quote($theme->{webguiVersion}).", $theme->{versionNumber}, 0)");
my $collateralFolderId = getNextId("collateralFolderId");
my $collateralFolderId = WebGUI::Id::generate();
WebGUI::SQL->write("insert into collateralFolder (collateralFolderId,name,parentId) values ($collateralFolderId,
".quote($theme->{name}).", 0)");
foreach my $key (keys %{$theme->{components}}) {
my $type = $theme->{components}{$key}{type};
if ($type eq "template") {
$theme->{components}{$key}{properties}{$type."Id"} = getNextId($type."Id");
$theme->{components}{$key}{properties}{$type."Id"} = WebGUI::Id::generate();
my (@fields, @values);
foreach my $property (keys %{$theme->{components}{$key}{properties}}) {
push(@fields,$property);
@ -405,7 +406,7 @@ sub www_importThemeSave {
my $id = $theme->{components}{$key}{properties}{$type."Id"};
$id .= "_".$theme->{components}{$key}{properties}{namespace} if ($type eq "template");
WebGUI::SQL->write("insert into themeComponent (themeId,themeComponentId,type,id)
values ($themeId, ".getNextId("themeComponentId").", ".quote($type).", ".quote($id).")");
values ($themeId, ".WebGUI::Id::generate().", ".quote($type).", ".quote($id).")");
} elsif (isIn($type, qw(image file snippet))) {
$theme->{components}{$key}{properties}{collateralFolderId} = $collateralFolderId;
my $c = WebGUI::Collateral->new("new");
@ -413,7 +414,7 @@ sub www_importThemeSave {
$c->saveFromFilesystem($propertiesFile->getNode->getPath.$session{os}{slash}
.$theme->{components}{$key}{properties}{filename});
WebGUI::SQL->write("insert into themeComponent (themeId,themeComponentId,type,id)
values ($themeId, ".getNextId("themeComponentId").", ".quote($type).", "
values ($themeId, ".WebGUI::Id::generate().", ".quote($type).", "
.quote($c->get("collateralId")).")");
}
}

View file

@ -17,6 +17,7 @@ package WebGUI::Page;
use HTML::Template;
use strict;
use Tie::IxHash;
use Tie::CPHash;
use WebGUI::Cache;
use WebGUI::DateTime;
use WebGUI::ErrorHandler;
@ -1417,6 +1418,7 @@ Returns an array of hashrefs containing the page properties of this node and it'
sub self_and_sisters {
my ($self, $sth, %row, @result);
$self = shift;
tie %row,'Tie::CPHash';
$sth = WebGUI::SQL->read(
"select a.*
from page as a,