diff --git a/lib/WebGUI/Operation/Help.pm b/lib/WebGUI/Operation/Help.pm
index 805ed68f6..aec667c9d 100644
--- a/lib/WebGUI/Operation/Help.pm
+++ b/lib/WebGUI/Operation/Help.pm
@@ -23,242 +23,232 @@ use WebGUI::SQL;
use WebGUI::URL;
use WebGUI::Utility;
-our @ISA = qw(Exporter);
-our @EXPORT = qw(&www_viewHelp &www_viewHelpIndex &www_manageHelp &www_editHelp &www_editHelpSave
- &www_exportHelp &www_deleteHelp &www_deleteHelpConfirm);
+our @ISA = qw(Exporter);
+our @EXPORT = qw(&www_viewHelp &www_viewHelpIndex &www_manageHelp &www_editHelp &www_editHelpSave
+&www_exportHelp &www_deleteHelp &www_deleteHelpConfirm);
#-------------------------------------------------------------------
sub _helpLink {
- return ''.$_[2].'';
+ return '' . $_[ 2 ] . '';
}
#-------------------------------------------------------------------
sub _seeAlso {
- my ($item, $seeAlso, @items, $namespace, $helpId, $titleId, $output);
- $seeAlso = $_[0];
- $seeAlso =~ s/\n//g; #removes line feeds
- $seeAlso =~ s/\r//g; #removes carriage returns
- $seeAlso =~ s/ //g; #removes spaces
- @items = split(/;/,$seeAlso);
- foreach $item (@items) {
- ($helpId,$namespace) = split(/,/,$item);
- ($titleId) = WebGUI::SQL->quickArray("select titleId from help where helpId=$helpId
- and namespace='$namespace'");
- $output .= '
' . _helpLink( $helpId, $namespace, WebGUI::International::get( $titleId, $namespace ) );
}
return $output;
}
#-------------------------------------------------------------------
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.";
+ tie my %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.";
+ 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.';
}
- $menu{WebGUI::URL::page('op=viewHelpIndex')} = WebGUI::International::get(13);
- return menuWrapper($_[0],\%menu);
+ $menu{ WebGUI::URL::page( 'op=viewHelpIndex' ) } = WebGUI::International::get( 13 );
+ return menuWrapper( $_[ 0 ], \%menu );
}
#-------------------------------------------------------------------
sub www_deleteHelp {
- return "" unless (WebGUI::Privilege::isInGroup(3));
+ return '' unless WebGUI::Privilege::isInGroup( 3 );
my $output = 'Confirm
Are you sure? Deleting help is never a good idea. Yes / No';
- return _submenu($output,{});
+ . WebGUI::URL::page( 'op=deleteHelpConfirm&hid=' . $session{ form }{ hid } . '&namespace=' . $session{ form }{ namespace } )
+ . '">Yes / No
';
+ return _submenu( $output, {} );
}
#-------------------------------------------------------------------
sub www_deleteHelpConfirm {
- return "" unless (WebGUI::Privilege::isInGroup(3));
- my ($titleId, $bodyId) = WebGUI::SQL->quickArray("select titleId,bodyId from help where helpId=".$session{form}{hid}."
- and namespace=".quote($session{form}{namespace}));
- WebGUI::SQL->write("delete from international where internationalId=$titleId
- and namespace=".quote($session{form}{namespace}));
- WebGUI::SQL->write("delete from international where internationalId=$bodyId
- and namespace=".quote($session{form}{namespace}));
- WebGUI::SQL->write("delete from help where helpId=".$session{form}{hid}."
- and namespace=".quote($session{form}{namespace}));
+ return '' unless WebGUI::Privilege::isInGroup( 3 );
+ my ( $titleId, $bodyId ) = WebGUI::SQL->quickArray(
+ 'select titleId,bodyId from help where helpId='
+ . $session{ form }{ hid } . ' and namespace='
+ . quote( $session{ form }{ namespace } )
+ );
+ WebGUI::SQL->write( "delete from international where internationalId=$titleId
+ and namespace=" . quote( $session{ form }{ namespace } ) );
+ WebGUI::SQL->write( "delete from international where internationalId=$bodyId
+ 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();
}
#-------------------------------------------------------------------
sub www_editHelp {
- return "" unless (WebGUI::Privilege::isInGroup(3));
- my ($output, $f, %data, %help, @seeAlso);
- tie %data, 'Tie::IxHash';
- tie %help, 'Tie::CPHash';
- if ($session{form}{hid} ne "new") {
- %help = WebGUI::SQL->quickHash("select * from help where
- helpId=$session{form}{hid} and namespace=".quote($session{form}{namespace}));
- $help{title} = WebGUI::International::get($help{titleId},$help{namespace});
- $help{body} = WebGUI::International::get($help{bodyId},$help{namespace});
- $help{seeAlso} =~ s/\n//g;
- $help{seeAlso} =~ s/\r//g;
- $help{seeAlso} =~ s/ //g;
- @seeAlso = split(/;/,$help{seeAlso});
- } else {
- $help{titleId} = "new";
- $help{bodyId} = "new";
- $help{namespace} = "WebGUI";
+ return '' unless WebGUI::Privilege::isInGroup( 3 );
+
+ tie my %help, 'Tie::CPHash';
+ my @seeAlso;
+
+ if ( $session{ form }{ hid } ne 'new' ) {
+ %help = WebGUI::SQL->quickHash( "select * from help where
+ helpId=$session{form}{hid} and namespace=" . quote( $session{ form }{ namespace } ) );
+ $help{ title } = WebGUI::International::get( $help{ titleId }, $help{ namespace } );
+ $help{ body } = WebGUI::International::get( $help{ bodyId }, $help{ namespace } );
+ $help{ seeAlso } =~ tr/\n\r //d;
+ @seeAlso = split /;/, $help{ seeAlso };
}
- $output = '
Edit Help
';
- $f = WebGUI::HTMLForm->new();
- $f->hidden("op","editHelpSave");
- $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");
+ else {
+ $help{ titleId } = 'new';
+ $help{ bodyId } = 'new';
+ $help{ namespace } = 'WebGUI';
}
- $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);
- %data = WebGUI::SQL->buildHash("select concat(help.helpId,',',help.namespace),
+
+ my $output = 'Edit Help
';
+ my $f = WebGUI::HTMLForm->new();
+ $f->hidden( 'op', 'editHelpSave' );
+ $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 } );
+ $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,')')
from help,international where help.titleId=international.internationalId
- and help.namespace=international.namespace and international.languageId=1 order by international.message");
- $f->select("seeAlso",\%data,"See Also",\@seeAlso,8,1);
+ and help.namespace=international.namespace and international.languageId=1 order by international.message] );
+ $f->select( 'seeAlso', \%data, 'See Also', \@seeAlso, 8, 1 );
$f->submit;
$output .= $f->print;
- return _submenu($output,{});
+ return _submenu( $output, {} );
}
#-------------------------------------------------------------------
sub www_editHelpSave {
- return "" unless (WebGUI::Privilege::isInGroup(3));
- my (@seeAlso);
- if ($session{form}{hid} eq "new") {
- if ($session{form}{namespace_new} ne "") {
- $session{form}{namespace} = $session{form}{namespace_new};
+ return '' unless WebGUI::Privilege::isInGroup( 3 );
+ if ( $session{ form }{ hid } eq '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
- where namespace=".quote($session{form}{namespace}));
- $session{form}{titleId}++;
- $session{form}{bodyId} = $session{form}{titleId}+1;
- ($session{form}{hid}) = WebGUI::SQL->quickArray("select max(helpId) from help
- where namespace=".quote($session{form}{namespace}));
- $session{form}{hid}++;
- WebGUI::SQL->write("insert into international (internationalId,languageId,namespace) values
- ($session{form}{titleId},1,".quote($session{form}{namespace}).")");
- WebGUI::SQL->write("insert into international (internationalId,languageId,namespace) values
- ($session{form}{bodyId},1,".quote($session{form}{namespace}).")");
- WebGUI::SQL->write("insert into help (helpId,namespace,titleId,bodyId) values
- ($session{form}{hid},".quote($session{form}{namespace}).",$session{form}{titleId},
- $session{form}{bodyId})");
+ ( $session{ form }{ titleId } ) = WebGUI::SQL->quickArray( 'select max(internationalId) from international
+ where namespace=' . quote( $session{ form }{ namespace } ) );
+ $session{ form }{ titleId }++;
+ $session{ form }{ bodyId } = $session{ form }{ titleId } + 1;
+ ( $session{ form }{ hid } ) = WebGUI::SQL->quickArray( 'select max(helpId) from help
+ where namespace=' . quote( $session{ form }{ namespace } ) );
+ $session{ form }{ hid }++;
+ WebGUI::SQL->write( "insert into international (internationalId,languageId,namespace) values
+ ($session{form}{titleId},1," . quote( $session{ form }{ namespace } ) . ')' );
+ WebGUI::SQL->write( "insert into international (internationalId,languageId,namespace) values
+ ($session{form}{bodyId},1," . quote( $session{ form }{ namespace } ) . ')' );
+ WebGUI::SQL->write( "insert into help (helpId,namespace,titleId,bodyId) values
+ ($session{form}{hid}," . quote( $session{ form }{ namespace } ) . ",$session{form}{titleId},
+ $session{form}{bodyId})" );
}
- @seeAlso = $session{cgi}->param('seeAlso');
- if ($seeAlso[0] ne "") {
- $session{form}{seeAlso} = join(";",@seeAlso);
- $session{form}{seeAlso} .= ';';
+ my @seeAlso = $session{ cgi }->param( 'seeAlso' );
+ if ( $seeAlso[ 0 ] ne '' ) {
+ $session{ form }{ seeAlso } = join( ';', @seeAlso ) . ';';
}
- 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}));
- 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}));
- WebGUI::SQL->write("update help set seeAlso=".quote($session{form}{seeAlso})."
- where helpId=$session{form}{hid} and namespace=".quote($session{form}{namespace}));
+ 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 } ) );
+ 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 } ) );
+ WebGUI::SQL->write( 'update help set seeAlso=' . quote( $session{ form }{ seeAlso } ) . "
+ where helpId=$session{form}{hid} and namespace=" . quote( $session{ form }{ namespace } ) );
return www_manageHelp();
}
#-------------------------------------------------------------------
sub www_exportHelp {
- return "" unless (WebGUI::Privilege::isInGroup(3));
- my ($export, $output, %help, $sth);
- $export = "#export of WebGUI ".$WebGUI::VERSION." help system.\n\n";
- $sth = WebGUI::SQL->read("select * from help");
- while (%help = $sth->hash) {
- $export .= "delete from help where helpId=$help{helpId} and namespace=".quote($help{namespace}).";\n";
- $export .= "insert into help (helpId,namespace,titleId,bodyId,seeAlso) values ($help{helpId}, "
- .quote($help{namespace}).", $help{titleId}, $help{bodyId}, ".quote($help{seeAlso}).");\n";
+ return '' unless WebGUI::Privilege::isInGroup( 3 );
+ my $export = '#export of WebGUI ' . $WebGUI::VERSION . " help system.\n\n";
+ my $sth = WebGUI::SQL->read( 'select * from help' );
+ while ( my %help = $sth->hash ) {
+ $export .= "delete from help where helpId=$help{helpId} and namespace=" . quote( $help{ namespace } ) . ";\n"
+ . "insert into help (helpId,namespace,titleId,bodyId,seeAlso) values ($help{helpId}, "
+ . quote( $help{ namespace } ) . ", $help{titleId}, $help{bodyId}, " . quote( $help{ seeAlso } ) . ");\n";
}
$sth->finish;
- $session{header}{mimetype} = 'text/plain';
+ $session{ header }{ mimetype } = 'text/plain';
return $export;
}
#-------------------------------------------------------------------
sub www_manageHelp {
- my ($sth, @help, $output);
- return "" unless (WebGUI::Privilege::isInGroup(3));
- $output = 'Manage Help
';
- $output .= 'This interface is for WebGUI developers only. If you\'re not a developer, leave this alone. Also,
- this interface works ONLY under MySQL and is not supported by Plain Black under any
- circumstances.';
- $output .= '
';
- $sth = WebGUI::SQL->read("select help.helpId,help.namespace,international.message from help,international
+ return '' unless WebGUI::Privilege::isInGroup( 3 );
+ my $output = 'Manage Help
'
+ . 'This interface is for WebGUI developers only. If you\'re not a developer, leave this alone. Also,
+ this interface works ONLY under MySQL and is not supported by Plain Black under any circumstances.'
+ . '
';
+ my $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");
- while (@help = $sth->array) {
+ and international.languageId=1 order by international.message' );
+ while ( my @help = $sth->array ) {
$output .= '| '
- .deleteIcon("op=deleteHelp&hid=".$help[0]."&namespace=".$help[1])
- .editIcon("op=editHelp&hid=".$help[0]."&namespace=".$help[1])
- .' | '
- .''._helpLink($help[0],$help[1],$help[2]).' | '
- .''.$help[0].'/'.$help[1].' | '
- .'
';
+ . deleteIcon( 'op=deleteHelp&hid=' . $help[ 0 ] . '&namespace=' . $help[ 1 ] )
+ . editIcon( 'op=editHelp&hid=' . $help[ 0 ] . '&namespace=' . $help[ 1 ] )
+ . ''
+ . '' . _helpLink( @help[ 0, 1, 2 ] ) . ' | '
+ . '' . $help[ 0 ] . '/' . $help[ 1 ] . ' | '
+ . '';
}
- $sth->finish;
- $output .= '
';
- return _submenu($output,{});
+ $sth->finish;
+ $output .= '
';
+ return _submenu( $output, {} );
}
#-------------------------------------------------------------------
sub www_viewHelp {
- my ($output, %help, $namespace);
- $namespace = $session{form}{namespace} || "WebGUI";
- tie %help, 'Tie::CPHash';
- %help = WebGUI::SQL->quickHash("select * from help where helpId=$session{form}{hid} and namespace='$namespace'");
- $output = ''.WebGUI::International::get(93).': '.WebGUI::International::get($help{titleId},$help{namespace}).'
';
- $output .= WebGUI::International::get($help{bodyId},$help{namespace});
- $output .= ''.WebGUI::International::get(94).':';
- return $output;
+ my $namespace = $session{ form }{ namespace } || 'WebGUI';
+ tie my %help, 'Tie::CPHash';
+ %help = WebGUI::SQL->quickHash( "select * from help where helpId=$session{form}{hid} and namespace='$namespace'" );
+ my $output = '' . WebGUI::International::get( 93 ) . ': ' . WebGUI::International::get( $help{ titleId }, $help{ namespace } ) . '
';
+ $output .= WebGUI::International::get( $help{ bodyId }, $help{ namespace } );
+ $output .= '
' . WebGUI::International::get( 94 ) . ':';
+ return $output;
}
#-------------------------------------------------------------------
sub www_viewHelpIndex {
- my ($sth, %help, $output, $key, %index, $title, $seeAlso, %sortedIndex, $i, $midpoint);
- tie %help, 'Tie::CPHash';
- tie %sortedIndex, 'Tie::IxHash';
- $output = ''.WebGUI::International::get(95).'
';
- $sth = WebGUI::SQL->read("select helpId,namespace,titleId,seeAlso from help");
- while (%help = $sth->hash) {
- $title = WebGUI::International::get($help{titleId},$help{namespace});
- $index{$title} = _helpLink($help{helpId},$help{namespace},$title);
- $seeAlso = _seeAlso($help{seeAlso});
- if ($seeAlso ne "") {
- $index{$title} .= '';
+ my $sth = WebGUI::SQL->read( 'select helpId,namespace,titleId,seeAlso from help' );
+ tie my %help, 'Tie::CPHash';
+ my %index;
+ while ( %help = $sth->hash ) {
+ my $title = WebGUI::International::get( $help{ titleId }, $help{ namespace } );
+ $index{ $title } = _helpLink( $help{ helpId }, $help{ namespace }, $title );
+ my $seeAlso = _seeAlso( $help{ seeAlso } );
+ if ( $seeAlso ne '' ) {
+ $index{ $title } .= '';
}
- $i++;
}
- $midpoint = round($i/2);
$sth->finish;
- foreach $key (sort {$a cmp $b} keys %index) {
- $sortedIndex{$key}=$index{$key};
- }
- $i = 0;
- $output .= '';
- foreach $key (keys %sortedIndex) {
- if ($i == $midpoint) {
+ my $output = '' . WebGUI::International::get( 95 ) . ''
+ . '| ';
+ my $i = 0;
+ my $midpoint = round( keys( %index ) / 2 );
+ for my $key ( sort keys %index ) {
+ if ( $i++ == $midpoint ) {
$output .= ' | ';
}
- $output .= $sortedIndex{$key}.' ';
- $i++;
+ $output .= $index{ $key } . ' ';
}
$output .= ' | ';
return $output;
|