Various changes not checked in previously because source forge was down.

This commit is contained in:
JT Smith 2002-11-18 00:12:33 +00:00
parent a06ad50cac
commit 8966e401c3
8 changed files with 298 additions and 46 deletions

View file

@ -160,8 +160,12 @@ sub checkList {
extras=>$_[0]->{extras},
checked=>$checked
});
$output .= ${$_[0]->{options}}{$key}.'    ';
$output .= '<br>' if ($_[0]->{vertical});
$output .= ${$_[0]->{options}}{$key};
if ($_[0]->{vertical}) {
$output .= "<br />\n";
} else {
$output .= " &nbsp; &nbsp;\n";
}
}
return $output;
}
@ -946,12 +950,6 @@ sub radio {
sub radioList {
my ($output, $key, $checked);
foreach $key (keys %{$_[0]->{options}}) {
$output .= '<input type="radio" name="'.$_[0]->{name}.'" value="'.$key.'"';
if ($_[0]->{value} eq $key) {
$checked = 1;
} else {
$checked = 0;
}
$output .= radio({
name=>$_[0]->{name},
value=>$key,
@ -959,8 +957,11 @@ sub radioList {
extras=>$_[0]->{extras}
});
$output .= ' '.$_[0]->{options}->{$key};
$output .= ' &nbsp; &nbsp;';
$output .= '<br>' if ($_[0]->{vertical});
if ($_[0]->{vertical}) {
$output .= "<br />\n";
} else {
$output .= " &nbsp; &nbsp;\n";
}
}
return $output;
}

View file

@ -1302,7 +1302,7 @@ sub radioList {
my ($name, $options, $label, $value, $vertical, $extras, $subtext, $uiLevel) =
rearrange([qw(name options label value vertical extras subtext uiLevel)], @p);
if (_uiLevelChecksOut($uiLevel)) {
$output = WebGUI::Form::checkList({
$output = WebGUI::Form::radioList({
"name"=>$name,
"options"=>$options,
"value"=>$value,

View file

@ -54,6 +54,10 @@ sub _submenu {
my (%menu);
tie %menu, 'Tie::IxHash';
%menu = %{$_[1]};
if ($session{form}{op} ne "viewHelp" && $session{form}{op} ne "viewHelpIndex") {
$menu{WebGUI::URL::page('op=editHelp&hid=new')} = "Add new help.";
$menu{WebGUI::URL::page('op=exportHelp')} = "Export help.";
}
if (($session{form}{op} eq "editHelp" && $session{form}{hid} ne "new") || $session{form}{op} eq "deleteHelp") {
$menu{WebGUI::URL::page('op=editHelpIndex&hid='.$session{form}{hid})} = "Edit this help.";
$menu{WebGUI::URL::page('op=deleteHelpIndex&hid='.$session{form}{hid})} = "Delete this help.";
@ -68,7 +72,7 @@ sub www_deleteHelp {
my $output = '<h1>Confirm</h1>Are you sure? Deleting help is never a good idea. <a href="'
.WebGUI::URL::page("op=deleteHelpConfirm&hid=".$session{form}{hid}."&namespace=".$session{form}{namespace})
.'">Yes</a> / <a href="'.WebGUI::URL::page("op=manageHelp").'">No</a><p>';
return _submen($output);
return _submenu($output,{});
}
#-------------------------------------------------------------------
@ -130,7 +134,7 @@ sub www_editHelp {
$f->select("seeAlso",\%data,"See Also",\@seeAlso,8,1);
$f->submit;
$output .= $f->print;
return _submenu($output);
return _submenu($output,{});
}
#-------------------------------------------------------------------
@ -194,10 +198,7 @@ sub www_manageHelp {
$output .= 'This interface is for WebGUI developers only. If you\'re not a developer, leave this alone. Also,
this interface works <b>ONLY</b> under MySQL and is not supported by Plain Black under any
circumstances.<p>';
$output .= '<a href="'.WebGUI::URL::page('op=editHelp&hid=new').'">Add new help.</a>';
$output .= ' &middot; ';
$output .= '<a href="'.WebGUI::URL::page('op=exportHelp').'">Export help.</a>';
$output .= '<p><table class="tableData">';
$output .= '<table class="tableData">';
$sth = WebGUI::SQL->read("select help.helpId,help.namespace,international.message from help,international
where help.titleId=international.internationalId and help.namespace=international.namespace
and international.languageId=1 order by international.message");
@ -212,7 +213,7 @@ sub www_manageHelp {
}
$sth->finish;
$output .= '</table>';
return _submenu($output);
return _submenu($output,{});
}
#-------------------------------------------------------------------

View file

@ -12,6 +12,7 @@ package WebGUI::Operation::Trash;
use Exporter;
use strict qw(vars subs);
use Tie::CPHash;
use WebGUI::Icon;
use WebGUI::Privilege;
use WebGUI::Session;
@ -23,11 +24,15 @@ our @EXPORT = qw(&www_purgeTrash &www_purgeTrashConfirm);
#-------------------------------------------------------------------
sub _purgeWobjects {
my ($b, $wobjectId, $namespace, $w, $cmd);
$b = WebGUI::SQL->read("select wobjectId, namespace from wobject where pageId=$_[0]");
while (($wobjectId,$namespace) = $b->array) {
$cmd = "WebGUI::Wobject::".$namespace;
$w = $cmd->new({wobjectId=>$wobjectId,namespace=>$namespace});
my (%properties, $base, $extended, $b, $wobjectId, $namespace, $w, $cmd);
tie %properties, 'Tie::CPHash';
$b = WebGUI::SQL->read("select * from wobject where pageId=$_[0]");
while ($base = $b->hashRef) {
$extended = WebGUI::SQL->quickHashRef("select * from ".$base->{namespace}."
where wobjectId=".$base->{wobjectId});
%properties = (%{$base}, %{$extended});
$cmd = "WebGUI::Wobject::".$properties{namespace};
$w = $cmd->new(\%properties);
$w->purge;
}
$b->finish;

View file

@ -20,6 +20,7 @@ use strict;
use Tie::IxHash;
use WebGUI::ErrorHandler;
use WebGUI::Session;
use WebGUI::Utility;
our @ISA = qw(Exporter);
our @EXPORT = qw(&quote &getNextId);
@ -45,8 +46,10 @@ our @EXPORT = qw(&quote &getNextId);
%hash = WebGUI::SQL->buildHash($sql);
$hashRef = WebGUI::SQL->buildHashRef($sql);
@arr = WebGUI::SQL->quickArray($sql);
$text = WebGUI::SQL->quickCSV($sql);
%hash = WebGUI::SQL->quickHash($sql);
$hashRef = WebGUI::SQL->quickHashRef($sql);
$text = WebGUI::SQL->quickTab($sql);
WebGUI::SQL->write($sql);
@ -336,6 +339,37 @@ sub quickArray {
}
#-------------------------------------------------------------------
=head2 quickCSV ( sql [, dbh ] )
Executes a query and returns a comma delimited text blob with column
headers.
=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 quickTab {
my ($sth, $output, @data);
$sth = WebGUI::SQL->new($_[1],$_[2]);
$output = join(",",$sth->getColumnNames)."\n";
while (@data = $sth->array) {
makeArrayCommaSafe(\@data);
$output .= join(",",@data)."\n";
}
$sth->finish;
return $output;
}
#-------------------------------------------------------------------
=head2 quickHash ( sql [, dbh ] )
@ -393,6 +427,36 @@ sub quickHashRef {
#-------------------------------------------------------------------
=head2 quickTab ( sql [, dbh ] )
Executes a query and returns a tab delimited text blob with column
headers.
=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 quickTab {
my ($sth, $output, @data);
$sth = WebGUI::SQL->new($_[1],$_[2]);
$output = join("\t",$sth->getColumnNames)."\n";
while (@data = $sth->array) {
makeArrayTabSafe(\@data);
$output .= join("\t",@data)."\n";
}
$sth->finish;
return $output;
}
#-------------------------------------------------------------------
=head2 quote ( string )
Returns a string quoted and ready for insert into the database.

View file

@ -15,7 +15,8 @@ use strict;
use Tie::IxHash;
our @ISA = qw(Exporter);
our @EXPORT = qw(&commify &randomizeArray &sortHashDescending &sortHash &isIn &randint &round);
our @EXPORT = qw(&makeTabSafe &makeArrayTabSafe &randomizeHash &commify &randomizeArray
&sortHashDescending &sortHash &isIn &makeCommaSafe &makeArrayCommaSafe &randint &round);
#-------------------------------------------------------------------
sub commify {
@ -45,6 +46,42 @@ sub isIn {
}
}
#-------------------------------------------------------------------
sub makeArrayCommaSafe {
my ($array) = $_[0];
my ($i);
for ($i = @$array; --$i;) {
$$array[$i] = makeCommaSafe($$array[$i]);
}
}
#-------------------------------------------------------------------
sub makeArrayTabSafe {
my ($array) = $_[0];
my ($i);
for ($i = @$array; --$i;) {
$$array[$i] = makeTabSafe($$array[$i]);
}
}
#-------------------------------------------------------------------
sub makeCommaSafe {
my ($text) = $_[0];
$text =~ s/\n/ /g;
$text =~ s/\r/ /g;
$text =~ s/,/;/g;
return $text;
}
#-------------------------------------------------------------------
sub makeTabSafe {
my ($text) = $_[0];
$text =~ s/\n/ /g;
$text =~ s/\r/ /g;
$text =~ s/\t/ /g;
return $text;
}
#-------------------------------------------------------------------
sub randint {
my ($low, $high) = @_;
@ -67,6 +104,21 @@ sub randomizeArray {
}
}
#-------------------------------------------------------------------
sub randomizeHash {
my ($hash, $key, @keys, %temp);
$hash = $_[0];
foreach $key (keys %{$_[0]}) {
push(@keys,$key);
}
randomizeArray(\@keys);
tie %temp, 'Tie::IxHash';
foreach $key (@keys) {
$temp{$key} = $hash->{$key};
}
return \%temp;
}
#-------------------------------------------------------------------
sub round {
return sprintf("%.0f", $_[0]);

View file

@ -376,7 +376,7 @@ sub inDateRange {
#-------------------------------------------------------------------
=head2 moveCollateralDown ( tableName, idName, id )
=head2 moveCollateralDown ( tableName, idName, id [ , setName, setValue ] )
Moves a collateral data item down one position. This assumes that the
collateral data table has a column called "wobjectId" that identifies
@ -396,25 +396,41 @@ sub inDateRange {
An integer that uniquely identifies this collateral data item.
=item setName
By default this method assumes that the collateral will have a
wobject id in the table. However, since there is not always a wobject
id to separate one data set from another, you may specify another
field to do that.
=item setValue
The value of the column defined by "setName" to select a data set
from.
=cut
### NOTE: There is a redundant use of wobjectId in some of these statements on purpose to support
### two different types of collateral data.
sub moveCollateralDown {
my ($id, $seq);
($seq) = WebGUI::SQL->quickArray("select sequenceNumber from $_[1] where $_[2]=$_[3] and wobjectId=".$_[0]->get("wobjectId"));
($id) = WebGUI::SQL->quickArray("select $_[2] from $_[1] where wobjectId=".$_[0]->get("wobjectId")
." and sequenceNumber=$seq+1 group by wobjectId");
my ($id, $seq, $setName, $setValue);
$setName = $_[4] || "wobjectId";
$setValue = $_[5] || $_[0]->get($setName);
($seq) = WebGUI::SQL->quickArray("select sequenceNumber from $_[1] where $_[2]=$_[3] and $setName=".quote($setValue));
($id) = WebGUI::SQL->quickArray("select $_[2] from $_[1] where $setName=".quote($setValue)
." and sequenceNumber=$seq+1 group by $setName");
if ($id ne "") {
WebGUI::SQL->write("update $_[1] set sequenceNumber=sequenceNumber+1 where $_[2]=$_[3] and wobjectId=".$_[0]->get("wobjectId"));
WebGUI::SQL->write("update $_[1] set sequenceNumber=sequenceNumber-1 where $_[2]=$id and wobjectId=".$_[0]->get("wobjectId"));
WebGUI::SQL->write("update $_[1] set sequenceNumber=sequenceNumber+1 where $_[2]=$_[3] and $setName="
.quote($setValue));
WebGUI::SQL->write("update $_[1] set sequenceNumber=sequenceNumber-1 where $_[2]=$id and $setName="
.quote($setValue));
}
}
#-------------------------------------------------------------------
=head2 moveCollateralUp ( tableName, idName, id )
=head2 moveCollateralUp ( tableName, idName, id [ , setName, setValue ] )
Moves a collateral data item up one position. This assumes that the
collateral data table has a column called "wobjectId" that identifies
@ -434,19 +450,35 @@ sub moveCollateralDown {
An integer that uniquely identifies this collateral data item.
=item setName
By default this method assumes that the collateral will have a
wobject id in the table. However, since there is not always a wobject
id to separate one data set from another, you may specify another
field to do that.
=item setValue
The value of the column defined by "setName" to select a data set
from.
=cut
### NOTE: There is a redundant use of wobjectId in some of these statements on purpose to support
### two different types of collateral data.
sub moveCollateralUp {
my ($id, $seq);
($seq) = WebGUI::SQL->quickArray("select sequenceNumber from $_[1] where $_[2]=$_[3] and wobjectId=".$_[0]->get("wobjectId"));
($id) = WebGUI::SQL->quickArray("select $_[2] from $_[1] where wobjectId=".$_[0]->get("wobjectId")
." and sequenceNumber=$seq-1 group by wobjectId");
my ($id, $seq, $setValue, $setName);
$setName = $_[4] || "wobjectId";
$setValue = $_[5] || $_[0]->get($setName);
($seq) = WebGUI::SQL->quickArray("select sequenceNumber from $_[1] where $_[2]=$_[3] and $setName=".quote($setValue));
($id) = WebGUI::SQL->quickArray("select $_[2] from $_[1] where $setName=".quote($setValue)
." and sequenceNumber=$seq-1 group by $setValue");
if ($id ne "") {
WebGUI::SQL->write("update $_[1] set sequenceNumber=sequenceNumber-1 where $_[2]=$_[3] and wobjectId=".$_[0]->get("wobjectId"));
WebGUI::SQL->write("update $_[1] set sequenceNumber=sequenceNumber+1 where $_[2]=$id and wobjectId=".$_[0]->get("wobjectId"));
WebGUI::SQL->write("update $_[1] set sequenceNumber=sequenceNumber-1 where $_[2]=$_[3] and $setName="
.quote($setValue));
WebGUI::SQL->write("update $_[1] set sequenceNumber=sequenceNumber+1 where $_[2]=$id and $setName="
.quote($setValue));
}
}
@ -547,7 +579,7 @@ sub purge {
#-------------------------------------------------------------------
=head2 reorderCollateral ( tableName, keyName )
=head2 reorderCollateral ( tableName, keyName [ , setName, setValue ] )
Resequences collateral data. Typically useful after deleting a
collateral item to remove the gap created by the deletion.
@ -560,14 +592,27 @@ sub purge {
The key column name used to determine which data needs sorting within the table.
=item setName
Defaults to "wobjectId". This is used to define which data set to
reorder.
=item setValue
Used to define which data set to reorder. Defaults to the wobjectId
for this instance. Defaults to the value of "setName" in the wobject
properties.
=cut
sub reorderCollateral {
my ($sth, $i, $id);
my ($sth, $i, $id, $setName, $setValue);
$i = 0;
$sth = WebGUI::SQL->read("select $_[2] from $_[1] where wobjectId=".$_[0]->get("wobjectId")." order by sequenceNumber");
$setName = $_[3] || "wobjectId";
$setValue = $_[4] || $_[0]->get($setName);
$sth = WebGUI::SQL->read("select $_[2] from $_[1] where $setName=".quote($setValue)." order by sequenceNumber");
while (($id) = $sth->array) {
WebGUI::SQL->write("update $_[1] set sequenceNumber=$i where wobjectId=".$_[0]->get("wobjectId")." and $_[2]=$id");
WebGUI::SQL->write("update $_[1] set sequenceNumber=$i where $setName=".quote($setValue)." and $_[2]=$id");
$i++;
}
$sth->finish;
@ -647,7 +692,7 @@ sub set {
#-----------------------------------------------------------------
=head2 setCollateral ( tableName, keyName, properties [ , useSequenceNumber, useWobjectId ] )
=head2 setCollateral ( tableName, keyName, properties [ , useSequenceNumber, useWobjectId, setName, setValue ] )
Performs and insert/update of collateral data for any wobject's
collateral data. Returns the primary key value for that row of
@ -682,20 +727,37 @@ sub set {
upon creation of a new row. Note that this means the table better
have a wobjectId column. Defaults to "1".
=item setName
If this collateral data set is not grouped by wobjectId, but by another
column then specify that column here. The useSequenceNumber parameter
will then use this column name instead of wobjectId to generate
the sequenceNumber.
=item setValue
If you've specified a setName you may also set a value for that set.
Defaults to the value for this id from the wobject properties.
=item
=cut
sub setCollateral {
my ($key, $sql, $seq, $dbkeys, $dbvalues, $counter);
my ($class, $table, $keyName, $properties, $useSequence, $useWobjectId) = @_;
my ($class, $table, $keyName, $properties, $useSequence, $useWobjectId, $setName, $setValue) = @_;
$counter = 0;
$setName = $setName || "wobjectId";
$setValue = $setValue || $_[0]->get($setName);
if ($properties->{$keyName} eq "new" || $properties->{$keyName} eq "") {
$properties->{$keyName} = getNextId($keyName);
$sql = "insert into $table (";
$dbkeys = "";
$dbvalues = "";
unless ($useSequence eq "0") {
($seq) = WebGUI::SQL->quickArray("select max(sequenceNumber) from $table
where wobjectId=".$_[0]->get("wobjectId"));
where $setName=".quote($setValue));
$properties->{sequenceNumber} = $seq+1;
}
unless ($useWobjectId eq "0") {