damn perltidy

This commit is contained in:
JT Smith 2003-02-06 01:48:03 +00:00
parent 3c0d65ac10
commit c2d20a09db

View file

@ -23,236 +23,245 @@ use WebGUI::SQL;
use WebGUI::URL; use WebGUI::URL;
use WebGUI::Utility; use WebGUI::Utility;
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
our @EXPORT = qw(&www_viewHelp &www_viewHelpIndex &www_manageHelp &www_editHelp &www_editHelpSave our @EXPORT = qw(&www_viewHelp &www_viewHelpIndex &www_manageHelp &www_editHelp &www_editHelpSave
&www_exportHelp &www_deleteHelp &www_deleteHelpConfirm); &www_exportHelp &www_deleteHelp &www_deleteHelpConfirm);
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub _helpLink { sub _helpLink {
return '<a href="' . WebGUI::URL::page( 'op=viewHelp&hid=' . $_[ 0 ] . '&namespace=' . $_[ 1 ] ) . '">' . $_[ 2 ] . '</a>'; return '<a href="'.WebGUI::URL::page('op=viewHelp&hid='.$_[0].'&namespace='.$_[1]).'">'.$_[2].'</a>';
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub _seeAlso { sub _seeAlso {
( my $seeAlso = $_[ 0 ] ) =~ tr/\n\r //d; # removes line feeds, carriage returns and spaces my ($item, $seeAlso, @items, $namespace, $helpId, $titleId, $output);
my $output; $seeAlso = $_[0];
for my $item ( split /;/, $seeAlso ) { $seeAlso =~ s/\n//g; #removes line feeds
my ( $helpId, $namespace ) = split /,/, $item; $seeAlso =~ s/\r//g; #removes carriage returns
my ( $titleId ) = WebGUI::SQL->quickArray( "select titleId from help where helpId=$helpId $seeAlso =~ s/ //g; #removes spaces
and namespace='$namespace'" ); @items = split(/;/,$seeAlso);
$output .= '<li>' . _helpLink( $helpId, $namespace, WebGUI::International::get( $titleId, $namespace ) ); foreach $item (@items) {
($helpId,$namespace) = split(/,/,$item);
($titleId) = WebGUI::SQL->quickArray("select titleId from help where helpId=$helpId
and namespace='$namespace'");
$output .= '<li>'._helpLink($helpId,$namespace,WebGUI::International::get($titleId,$namespace));
} }
return $output; return $output;
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub _submenu { sub _submenu {
tie my %menu, 'Tie::IxHash'; my (%menu);
%menu = %{ $_[ 1 ] }; tie %menu, 'Tie::IxHash';
if ( $session{ form }{ op } ne 'viewHelp' && $session{ form }{ op } ne 'viewHelpIndex' ) { %menu = %{$_[1]};
$menu{ WebGUI::URL::page( 'op=editHelp&hid=new' ) } = 'Add new help.'; if ($session{form}{op} ne "viewHelp" && $session{form}{op} ne "viewHelpIndex") {
$menu{ WebGUI::URL::page( 'op=exportHelp' ) } = 'Export help.'; $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' ) { 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=editHelpIndex&hid='.$session{form}{hid})} = "Edit this help.";
$menu{ WebGUI::URL::page( 'op=deleteHelpIndex&hid=' . $session{ form }{ hid } ) } = 'Delete this help.'; $menu{WebGUI::URL::page('op=deleteHelpIndex&hid='.$session{form}{hid})} = "Delete this help.";
} }
$menu{ WebGUI::URL::page( 'op=viewHelpIndex' ) } = WebGUI::International::get( 13 ); $menu{WebGUI::URL::page('op=viewHelpIndex')} = WebGUI::International::get(13);
return menuWrapper( $_[ 0 ], \%menu ); return menuWrapper($_[0],\%menu);
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_deleteHelp { sub www_deleteHelp {
return '' unless WebGUI::Privilege::isInGroup( 3 ); return "" unless (WebGUI::Privilege::isInGroup(3));
my $output = '<h1>Confirm</h1>Are you sure? Deleting help is never a good idea. <a href="' 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 } ) .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>'; .'">Yes</a> / <a href="'.WebGUI::URL::page("op=manageHelp").'">No</a><p>';
return _submenu( $output, {} ); return _submenu($output,{});
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_deleteHelpConfirm { sub www_deleteHelpConfirm {
return '' unless WebGUI::Privilege::isInGroup( 3 ); return "" unless (WebGUI::Privilege::isInGroup(3));
my ( $titleId, $bodyId ) = WebGUI::SQL->quickArray( my ($titleId, $bodyId) = WebGUI::SQL->quickArray("select titleId,bodyId from help where helpId=".$session{form}{hid}."
'select titleId,bodyId from help where helpId=' and namespace=".quote($session{form}{namespace}));
. $session{ form }{ hid } . ' and namespace=' WebGUI::SQL->write("delete from international where internationalId=$titleId
. quote( $session{ form }{ namespace } ) and namespace=".quote($session{form}{namespace}));
); WebGUI::SQL->write("delete from international where internationalId=$bodyId
WebGUI::SQL->write( "delete from international where internationalId=$titleId and namespace=".quote($session{form}{namespace}));
and namespace=" . quote( $session{ form }{ namespace } ) ); WebGUI::SQL->write("delete from help where helpId=".$session{form}{hid}."
WebGUI::SQL->write( "delete from international where internationalId=$bodyId and namespace=".quote($session{form}{namespace}));
and namespace=" . quote( $session{ form }{ namespace } ) );
WebGUI::SQL->write( 'delete from help where helpId=' . $session{ form }{ hid } . "
and namespace=" . quote( $session{ form }{ namespace } ) );
return www_manageHelp(); return www_manageHelp();
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_editHelp { sub www_editHelp {
return '' unless WebGUI::Privilege::isInGroup( 3 ); return "" unless (WebGUI::Privilege::isInGroup(3));
my ($output, $f, %data, %help, @seeAlso);
tie my %help, 'Tie::CPHash'; tie %data, 'Tie::IxHash';
my @seeAlso; tie %help, 'Tie::CPHash';
if ($session{form}{hid} ne "new") {
if ( $session{ form }{ hid } ne 'new' ) { %help = WebGUI::SQL->quickHash("select * from help where
%help = WebGUI::SQL->quickHash( "select * from help where helpId=$session{form}{hid} and namespace=".quote($session{form}{namespace}));
helpId=$session{form}{hid} and namespace=" . quote( $session{ form }{ namespace } ) ); $help{title} = WebGUI::International::get($help{titleId},$help{namespace});
$help{ title } = WebGUI::International::get( $help{ titleId }, $help{ namespace } ); $help{body} = WebGUI::International::get($help{bodyId},$help{namespace});
$help{ body } = WebGUI::International::get( $help{ bodyId }, $help{ namespace } ); $help{seeAlso} =~ s/\n//g;
$help{ seeAlso } =~ tr/\n\r //d; $help{seeAlso} =~ s/\r//g;
@seeAlso = split /;/, $help{ seeAlso }; $help{seeAlso} =~ s/ //g;
@seeAlso = split(/;/,$help{seeAlso});
} else {
$help{titleId} = "new";
$help{bodyId} = "new";
$help{namespace} = "WebGUI";
} }
else { $output = '<h1>Edit Help</h1>';
$help{ titleId } = 'new'; $f = WebGUI::HTMLForm->new();
$help{ bodyId } = 'new'; $f->hidden("op","editHelpSave");
$help{ namespace } = 'WebGUI'; $f->hidden("hid",$session{form}{hid});
$f->readOnly($session{form}{hid},"Help ID");
if ($session{form}{hid} eq "new") {
%data = WebGUI::SQL->buildHash("select namespace,namespace from help order by namespace");
$f->combo("namespace",\%data,"Namespace",[$help{namespace}]);
} else {
$f->hidden("namespace",$session{form}{namespace});
$f->readOnly($session{form}{namespace},"Namespace");
} }
$f->hidden("titleId",$help{titleId});
my $output = '<h1>Edit Help</h1>'; $f->readOnly($help{titleId},"Title ID");
my $f = WebGUI::HTMLForm->new(); $f->text("title","Title",$help{title});
$f->hidden( 'op', 'editHelpSave' ); $f->hidden("bodyId",$help{bodyId});
$f->hidden( 'hid', $session{ form }{ hid } ); $f->readOnly($help{bodyId},"Body ID");
$f->readOnly( $session{ form }{ hid }, 'Help ID' ); $f->HTMLArea("body","Body",$help{body},'','','',20,60);
if ( $session{ form }{ hid } eq 'new' ) { %data = WebGUI::SQL->buildHash("select concat(help.helpId,',',help.namespace),
%data = WebGUI::SQL->buildHash( 'select namespace,namespace from help order by namespace' );
$f->combo( 'namespace', \%data, 'Namespace', [ $help{ namespace } ] );
}
else {
$f->hidden( 'namespace', $session{ form }{ namespace } );
$f->readOnly( $session{ form }{ namespace }, 'Namespace' );
}
$f->hidden( 'titleId', $help{ titleId } );
$f->readOnly( $help{ titleId }, 'Title ID' );
$f->text( 'title', 'Title', $help{ title } );
$f->hidden( 'bodyId', $help{ bodyId } );
$f->readOnly( $help{ bodyId }, 'Body ID' );
$f->HTMLArea( 'body', 'Body', $help{ body }, '', '', '', 20, 60 );
tie my %data, 'Tie::IxHash';
%data = WebGUI::SQL->buildHash( q[select concat(help.helpId,',',help.namespace),
concat(international.message,' (',help.helpId,'/',help.namespace,')') concat(international.message,' (',help.helpId,'/',help.namespace,')')
from help,international where help.titleId=international.internationalId from help,international where help.titleId=international.internationalId
and help.namespace=international.namespace and international.languageId=1 order by international.message] ); and help.namespace=international.namespace and international.languageId=1 order by international.message");
$f->select( 'seeAlso', \%data, 'See Also', \@seeAlso, 8, 1 ); $f->select("seeAlso",\%data,"See Also",\@seeAlso,8,1);
$f->submit; $f->submit;
$output .= $f->print; $output .= $f->print;
return _submenu( $output, {} ); return _submenu($output,{});
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_editHelpSave { sub www_editHelpSave {
return '' unless WebGUI::Privilege::isInGroup( 3 ); return "" unless (WebGUI::Privilege::isInGroup(3));
if ( $session{ form }{ hid } eq 'new' ) { my (@seeAlso);
if ( $session{ form }{ namespace_new } ne '' ) { if ($session{form}{hid} eq "new") {
$session{ form }{ namespace } = $session{ form }{ namespace_new }; if ($session{form}{namespace_new} ne "") {
$session{form}{namespace} = $session{form}{namespace_new};
} }
( $session{ form }{ titleId } ) = WebGUI::SQL->quickArray( 'select max(internationalId) from international ($session{form}{titleId}) = WebGUI::SQL->quickArray("select max(internationalId) from international
where namespace=' . quote( $session{ form }{ namespace } ) ); where namespace=".quote($session{form}{namespace}));
$session{ form }{ titleId }++; $session{form}{titleId}++;
$session{ form }{ bodyId } = $session{ form }{ titleId } + 1; $session{form}{bodyId} = $session{form}{titleId}+1;
( $session{ form }{ hid } ) = WebGUI::SQL->quickArray( 'select max(helpId) from help ($session{form}{hid}) = WebGUI::SQL->quickArray("select max(helpId) from help
where namespace=' . quote( $session{ form }{ namespace } ) ); where namespace=".quote($session{form}{namespace}));
$session{ form }{ hid }++; $session{form}{hid}++;
WebGUI::SQL->write( "insert into international (internationalId,languageId,namespace) values WebGUI::SQL->write("insert into international (internationalId,languageId,namespace) values
($session{form}{titleId},1," . quote( $session{ form }{ namespace } ) . ')' ); ($session{form}{titleId},1,".quote($session{form}{namespace}).")");
WebGUI::SQL->write( "insert into international (internationalId,languageId,namespace) values WebGUI::SQL->write("insert into international (internationalId,languageId,namespace) values
($session{form}{bodyId},1," . quote( $session{ form }{ namespace } ) . ')' ); ($session{form}{bodyId},1,".quote($session{form}{namespace}).")");
WebGUI::SQL->write( "insert into help (helpId,namespace,titleId,bodyId) values WebGUI::SQL->write("insert into help (helpId,namespace,titleId,bodyId) values
($session{form}{hid}," . quote( $session{ form }{ namespace } ) . ",$session{form}{titleId}, ($session{form}{hid},".quote($session{form}{namespace}).",$session{form}{titleId},
$session{form}{bodyId})" ); $session{form}{bodyId})");
} }
my @seeAlso = $session{ cgi }->param( 'seeAlso' ); @seeAlso = $session{cgi}->param('seeAlso');
if ( $seeAlso[ 0 ] ne '' ) { if ($seeAlso[0] ne "") {
$session{ form }{ seeAlso } = join( ';', @seeAlso ) . ';'; $session{form}{seeAlso} = join(";",@seeAlso);
$session{form}{seeAlso} .= ';';
} }
WebGUI::SQL->write( 'update international set message=' . quote( $session{ form }{ title } ) . ', lastUpdated=' . time() . " WebGUI::SQL->write("update international set message=".quote($session{form}{title}).", lastUpdated=".time()."
where internationalId=$session{form}{titleId} and languageId=1 and namespace=" . quote( $session{ form }{ namespace } ) ); where internationalId=$session{form}{titleId} and languageId=1 and namespace=".quote($session{form}{namespace}));
WebGUI::SQL->write( 'update international set message=' . quote( $session{ form }{ body } ) . ', lastUpdated=' . time() . " WebGUI::SQL->write("update international set message=".quote($session{form}{body}).", lastUpdated=".time()."
where internationalId=$session{form}{bodyId} and languageId=1 and namespace=" . quote( $session{ form }{ namespace } ) ); where internationalId=$session{form}{bodyId} and languageId=1 and namespace=".quote($session{form}{namespace}));
WebGUI::SQL->write( 'update help set seeAlso=' . quote( $session{ form }{ seeAlso } ) . " WebGUI::SQL->write("update help set seeAlso=".quote($session{form}{seeAlso})."
where helpId=$session{form}{hid} and namespace=" . quote( $session{ form }{ namespace } ) ); where helpId=$session{form}{hid} and namespace=".quote($session{form}{namespace}));
return www_manageHelp(); return www_manageHelp();
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_exportHelp { sub www_exportHelp {
return '' unless WebGUI::Privilege::isInGroup( 3 ); return "" unless (WebGUI::Privilege::isInGroup(3));
my $export = '#export of WebGUI ' . $WebGUI::VERSION . " help system.\n\n"; my ($export, $output, %help, $sth);
my $sth = WebGUI::SQL->read( 'select * from help' ); $export = "#export of WebGUI ".$WebGUI::VERSION." help system.\n\n";
while ( my %help = $sth->hash ) { $sth = WebGUI::SQL->read("select * from help");
$export .= "delete from help where helpId=$help{helpId} and namespace=" . quote( $help{ namespace } ) . ";\n" while (%help = $sth->hash) {
. "insert into help (helpId,namespace,titleId,bodyId,seeAlso) values ($help{helpId}, " $export .= "delete from help where helpId=$help{helpId} and namespace=".quote($help{namespace}).";\n";
. quote( $help{ namespace } ) . ", $help{titleId}, $help{bodyId}, " . quote( $help{ seeAlso } ) . ");\n"; $export .= "insert into help (helpId,namespace,titleId,bodyId,seeAlso) values ($help{helpId}, "
.quote($help{namespace}).", $help{titleId}, $help{bodyId}, ".quote($help{seeAlso}).");\n";
} }
$sth->finish; $sth->finish;
$session{ header }{ mimetype } = 'text/plain'; $session{header}{mimetype} = 'text/plain';
return $export; return $export;
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_manageHelp { sub www_manageHelp {
return '' unless WebGUI::Privilege::isInGroup( 3 ); my ($sth, @help, $output);
my $output = '<h1>Manage Help</h1>' return "" unless (WebGUI::Privilege::isInGroup(3));
. 'This interface is for WebGUI developers only. If you\'re not a developer, leave this alone. Also, $output = '<h1>Manage Help</h1>';
this interface works <b>ONLY</b> under MySQL and is not supported by Plain Black under any circumstances.<p>' $output .= 'This interface is for WebGUI developers only. If you\'re not a developer, leave this alone. Also,
. '<table class="tableData">'; this interface works <b>ONLY</b> under MySQL and is not supported by Plain Black under any
my $sth = WebGUI::SQL->read( 'select help.helpId,help.namespace,international.message from help,international circumstances.<p>';
$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 where help.titleId=international.internationalId and help.namespace=international.namespace
and international.languageId=1 order by international.message' ); and international.languageId=1 order by international.message");
while ( my @help = $sth->array ) { while (@help = $sth->array) {
$output .= '<tr><td>' $output .= '<tr><td>'
. deleteIcon( 'op=deleteHelp&hid=' . $help[ 0 ] . '&namespace=' . $help[ 1 ] ) .deleteIcon("op=deleteHelp&hid=".$help[0]."&namespace=".$help[1])
. editIcon( 'op=editHelp&hid=' . $help[ 0 ] . '&namespace=' . $help[ 1 ] ) .editIcon("op=editHelp&hid=".$help[0]."&namespace=".$help[1])
. '</td>' .'</td>'
. '<td>' . _helpLink( @help[ 0, 1, 2 ] ) . '</td>' .'<td>'._helpLink($help[0],$help[1],$help[2]).'</td>'
. '<td>' . $help[ 0 ] . '/' . $help[ 1 ] . '</td>' .'<td>'.$help[0].'/'.$help[1].'</td>'
. '</tr>'; .'</tr>';
} }
$sth->finish; $sth->finish;
$output .= '</table>'; $output .= '</table>';
return _submenu( $output, {} ); return _submenu($output,{});
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_viewHelp { sub www_viewHelp {
my $namespace = $session{ form }{ namespace } || 'WebGUI'; my ($output, %help, $namespace);
tie my %help, 'Tie::CPHash'; $namespace = $session{form}{namespace} || "WebGUI";
%help = WebGUI::SQL->quickHash( "select * from help where helpId=$session{form}{hid} and namespace='$namespace'" ); tie %help, 'Tie::CPHash';
my $output = '<h1>' . WebGUI::International::get( 93 ) . ': ' . WebGUI::International::get( $help{ titleId }, $help{ namespace } ) . '</h1>'; %help = WebGUI::SQL->quickHash("select * from help where helpId=$session{form}{hid} and namespace='$namespace'");
$output .= WebGUI::International::get( $help{ bodyId }, $help{ namespace } ); $output = '<h1>'.WebGUI::International::get(93).': '.WebGUI::International::get($help{titleId},$help{namespace}).'</h1>';
$output .= '<p><b>' . WebGUI::International::get( 94 ) . ':<ul>'; $output .= WebGUI::International::get($help{bodyId},$help{namespace});
$output .= _seeAlso( $help{ seeAlso } ); $output .= '<p><b>'.WebGUI::International::get(94).':<ul>';
$output .= '<li><a href="' . WebGUI::URL::page( 'op=viewHelpIndex' ) . '">' . WebGUI::International::get( 95 ) . '</a></ul>'; $output .= _seeAlso($help{seeAlso});
return $output; $output .= '<li><a href="'.WebGUI::URL::page('op=viewHelpIndex').'">'.WebGUI::International::get(95).'</a></ul>';
return $output;
} }
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_viewHelpIndex { sub www_viewHelpIndex {
my $sth = WebGUI::SQL->read( 'select helpId,namespace,titleId,seeAlso from help' ); my ($sth, %help, $output, $key, %index, $title, $seeAlso, %sortedIndex, $i, $midpoint);
tie my %help, 'Tie::CPHash'; tie %help, 'Tie::CPHash';
my %index; tie %sortedIndex, 'Tie::IxHash';
while ( %help = $sth->hash ) { $output = '<h1>'.WebGUI::International::get(95).'</h1>';
my $title = WebGUI::International::get( $help{ titleId }, $help{ namespace } ); $sth = WebGUI::SQL->read("select helpId,namespace,titleId,seeAlso from help");
$index{ $title } = _helpLink( $help{ helpId }, $help{ namespace }, $title ); while (%help = $sth->hash) {
my $seeAlso = _seeAlso( $help{ seeAlso } ); $title = WebGUI::International::get($help{titleId},$help{namespace});
if ( $seeAlso ne '' ) { $index{$title} = _helpLink($help{helpId},$help{namespace},$title);
$index{ $title } .= '<span style="font-size: 11px"><ul>' . $seeAlso . '</ul></span>'; $seeAlso = _seeAlso($help{seeAlso});
if ($seeAlso ne "") {
$index{$title} .= '<span style="font-size: 11px"><ul>'.$seeAlso.'</ul></span>';
} }
$i++;
} }
$midpoint = round($i/2);
$sth->finish; $sth->finish;
my $output = '<h1>' . WebGUI::International::get( 95 ) . '</h1>' foreach $key (sort {$a cmp $b} keys %index) {
. '<table width="100%"><tr><td width="50%" valign="top" class="content">'; $sortedIndex{$key}=$index{$key};
my $i = 0; }
my $midpoint = round( keys( %index ) / 2 ); $i = 0;
for my $key ( sort keys %index ) { $output .= '<table width="100%"><tr><td width="50%" valign="top" class="content">';
if ( $i++ == $midpoint ) { foreach $key (keys %sortedIndex) {
if ($i == $midpoint) {
$output .= '</td><td width="50%" valign="top" class="content">'; $output .= '</td><td width="50%" valign="top" class="content">';
} }
$output .= $index{ $key } . '<p>'; $output .= $sortedIndex{$key}.'<p>';
$i++;
} }
$output .= '</table>'; $output .= '</table>';
return $output; return $output;
} }
1; 1;