From: <de...@de...> - 2010-04-02 18:42:08
|
Author: SopanShewale Date: 2010-04-02 13:41:58 -0500 (Fri, 02 Apr 2010) New Revision: 18421 Trac url: http://develop.twiki.org/trac/changeset/18421 Modified: twiki/trunk/core/bin/configure Log: Item6410: Code Checkin for new proposal: configuration only after authentication - running perltidy on configure Modified: twiki/trunk/core/bin/configure =================================================================== --- twiki/trunk/core/bin/configure 2010-04-02 18:23:36 UTC (rev 18420) +++ twiki/trunk/core/bin/configure 2010-04-02 18:41:58 UTC (rev 18421) @@ -87,7 +87,6 @@ # during this phase will throw a die, which will be picked up # using CGI::Carp fatalsToBrowser - # Warnings are fatal $SIG{'__WARN__'} = sub { die @_ }; @@ -99,7 +98,7 @@ # may have updated many libraries and tweaked TWiki so let us give # him a chance. my $perlversion = $]; -if ($perlversion < 5.006) { +if ( $perlversion < 5.006 ) { print STDERR <<HERE; Your perl version is older than 5.6.0. TWiki has only been successfully tested on Perl 5.6.X and 5.8.X, @@ -113,14 +112,13 @@ use vars qw($WebServer_uid $WebServer_gid); $WebServer_uid = $WebServer_gid = ''; +eval { $WebServer_uid = getlogin() || getpwuid($>) || ''; }; + eval { - $WebServer_uid = getlogin() || getpwuid($>) || ''; + $WebServer_gid = join( ',', map { lc( getgrgid($_) ) } split( ' ', $( ) ); }; +if ($@) { -eval { - $WebServer_gid = join(',', map { lc(getgrgid( $_ )) } split( ' ', $( )); -}; -if( $@ ) { # Try to use Cygwin's 'id' command - may be on the path, since Cygwin # is probably installed to supply ls, egrep, etc - if it isn't, give # up. @@ -137,18 +135,18 @@ eval "use $module"; if ($@) { my $reason = "Failed to load the perl module $module. The module "; + # See if we can find the .pm on @INC my $foundAt = "could not be found. "; my $modpath = $module; - if ($modpath =~ /^([\w:]+)/) { + if ( $modpath =~ /^([\w:]+)/ ) { $modpath =~ s#::#/#g; $modpath .= '.pm'; foreach my $path (@INC) { - if (-e "$path/$modpath") { + if ( -e "$path/$modpath" ) { $foundAt = "was found at $path/$modpath"; - if (!-r $foundAt) { - $foundAt .= - ", but I don't have permission to read it."; + if ( !-r $foundAt ) { + $foundAt .= ", but I don't have permission to read it."; } last; } @@ -181,11 +179,7 @@ } } -foreach my $module ('FindBin', - 'File::Spec', - 'Config', - 'CGI qw(:any)', - ) { +foreach my $module ( 'FindBin', 'File::Spec', 'Config', 'CGI qw(:any)', ) { _loadBasicModule($module); } @@ -202,9 +196,9 @@ chdir($1); my @root = File::Spec->splitdir($1); pop(@root); -my @script = File::Spec->splitdir($0); +my @script = File::Spec->splitdir($0); my $scriptName = pop(@script); -$scriptName =~ s/.*[\/\\]//; # Fix for Item3511, on Win XP +$scriptName =~ s/.*[\/\\]//; # Fix for Item3511, on Win XP # Try to load the LocalLib.cfg optional overload @@ -214,44 +208,36 @@ eval 'require "setlib.cfg"'; if ($@) { + # No joy. Remember the failure so we can report it later. $localLibFailure = $@; + # Stick the root/lib on the path; there's a high probability we'll be # able to find the bits of TWiki::Configure that way. We will report # the setlib error later. - unshift(@INC, File::Spec->catfile(@root, 'lib')); + unshift( @INC, File::Spec->catfile( @root, 'lib' ) ); } # Load all the bits of the configure module that we explicitly use # The loadBasicModule does some extra analysis on errors. foreach my $module ( - 'Cwd', - 'Data::Dumper', - 'File::Copy', - 'File::Temp', - 'TWiki::Configure::Checker', - 'TWiki::Configure::CSS', - 'TWiki::Configure::Item', - 'TWiki::Configure::JS', - 'TWiki::Configure::Load', - 'TWiki::Configure::Pluggable', - 'TWiki::Configure::Root', - 'TWiki::Configure::Section', - 'TWiki::Configure::Type', - 'TWiki::Configure::Types::BOOLEAN', - 'TWiki::Configure::Types::NUMBER', - 'TWiki::Configure::Types::SELECT', - 'TWiki::Configure::Types::STRING', - 'TWiki::Configure::TWikiCfg', - 'TWiki::Configure::UI', - 'TWiki::Configure::UIs::Section', - 'TWiki::Configure::Value', - 'TWiki::Configure::Valuer', - ) { + 'Cwd', 'Data::Dumper', + 'File::Copy', 'File::Temp', + 'TWiki::Configure::Checker', 'TWiki::Configure::CSS', + 'TWiki::Configure::Item', 'TWiki::Configure::JS', + 'TWiki::Configure::Load', 'TWiki::Configure::Pluggable', + 'TWiki::Configure::Root', 'TWiki::Configure::Section', + 'TWiki::Configure::Type', 'TWiki::Configure::Types::BOOLEAN', + 'TWiki::Configure::Types::NUMBER', 'TWiki::Configure::Types::SELECT', + 'TWiki::Configure::Types::STRING', 'TWiki::Configure::TWikiCfg', + 'TWiki::Configure::UI', 'TWiki::Configure::UIs::Section', + 'TWiki::Configure::Value', 'TWiki::Configure::Valuer', + ) +{ _loadBasicModule($module); } -$| = 1; # no buffering on STDOUT +$| = 1; # no buffering on STDOUT ########################################################### # From this point on we shouldn't have any more "fatal" (to configure) @@ -269,11 +255,11 @@ # 'constants' used in TWiki.cfg use vars qw( $TRUE $FALSE ); -$TRUE = 1; +$TRUE = 1; $FALSE = 0; # Remember what we detected previously, for use by Checkers -if( $scriptName =~ /(\.\w+)$/ ) { +if ( $scriptName =~ /(\.\w+)$/ ) { $TWiki::cfg{DETECTED}{ScriptExtension} = $1; } @@ -283,7 +269,7 @@ $file =~ s(::)(/)g; - foreach my $dir ( @INC ) { + foreach my $dir (@INC) { if ( -e "$dir/$file" ) { return "$dir/$file"; } @@ -296,70 +282,80 @@ # but it has to be duplicated because we don't want to deal # with loading TWiki just yet. -unless( $TWiki::cfg{DetailedOS} ) { +unless ( $TWiki::cfg{DetailedOS} ) { $TWiki::cfg{DetailedOS} = $^O; - unless( $TWiki::cfg{DetailedOS} ) { + unless ( $TWiki::cfg{DetailedOS} ) { require Config; $TWiki::cfg{DetailedOS} = $Config::Config{osname}; } } -unless( $TWiki::cfg{OS} ) { - if ($TWiki::cfg{DetailedOS} =~ /darwin/i) { # MacOS X +unless ( $TWiki::cfg{OS} ) { + if ( $TWiki::cfg{DetailedOS} =~ /darwin/i ) { # MacOS X $TWiki::cfg{OS} = 'UNIX'; - } elsif ($TWiki::cfg{DetailedOS} =~ /Win/i) { + } + elsif ( $TWiki::cfg{DetailedOS} =~ /Win/i ) { $TWiki::cfg{OS} = 'WINDOWS'; - } elsif ($TWiki::cfg{DetailedOS} =~ /vms/i) { + } + elsif ( $TWiki::cfg{DetailedOS} =~ /vms/i ) { $TWiki::cfg{OS} = 'VMS'; - } elsif ($TWiki::cfg{DetailedOS} =~ /bsdos/i) { + } + elsif ( $TWiki::cfg{DetailedOS} =~ /bsdos/i ) { $TWiki::cfg{OS} = 'UNIX'; - } elsif ($TWiki::cfg{DetailedOS} =~ /dos/i) { + } + elsif ( $TWiki::cfg{DetailedOS} =~ /dos/i ) { $TWiki::cfg{OS} = 'DOS'; - } elsif ($TWiki::cfg{DetailedOS} =~ /^MacOS$/i) { # MacOS 9 or earlier + } + elsif ( $TWiki::cfg{DetailedOS} =~ /^MacOS$/i ) { # MacOS 9 or earlier $TWiki::cfg{OS} = 'MACINTOSH'; - } elsif ($TWiki::cfg{DetailedOS} =~ /os2/i) { + } + elsif ( $TWiki::cfg{DetailedOS} =~ /os2/i ) { $TWiki::cfg{OS} = 'OS2'; - } else { + } + else { $TWiki::cfg{OS} = 'UNIX'; } } $query = new CGI; -my $url = $query->url(); -my $action = $query->param('action') || 'Configure'; -my $expertsMode = defined($query->param('expert')); -my $confirm = defined($query->param('confirm')) || 0; -my $cfgAccess = $query->param('cfgAccess'); -my $newCfgP = $query->param('newCfgP'); -my $confCfgP = $query->param('confCfgP'); +my $url = $query->url(); +my $action = $query->param('action') || 'Configure'; +my $expertsMode = defined( $query->param('expert') ); +my $confirm = defined( $query->param('confirm') ) || 0; +my $cfgAccess = $query->param('cfgAccess'); +my $newCfgP = $query->param('newCfgP'); +my $confCfgP = $query->param('confCfgP'); - - # Handle serving an image embedded in the configure page, before generating # any other output -if( $action eq 'image' ) { - my $image = $query->param('image' ); - $image =~ /^([-.\w]+)$/; # filter-in +if ( $action eq 'image' ) { + my $image = $query->param('image'); + $image =~ /^([-.\w]+)$/; # filter-in $image = $1; - if( (defined($image)) && - (($image eq 'favicon.ico') || - ($image eq 'T-logo34x26-t.gif') || - ($image eq 'T-logo-140x40-t.gif') || - ($image eq 'warning.gif') || - ($image eq 'info.gif')) ) { + if ( + ( defined($image) ) + && ( ( $image eq 'favicon.ico' ) + || ( $image eq 'T-logo34x26-t.gif' ) + || ( $image eq 'T-logo-140x40-t.gif' ) + || ( $image eq 'warning.gif' ) + || ( $image eq 'info.gif' ) ) + ) + { + #ignore $query->param('type') and set it using our special knowledge my $type = 'image/gif'; - if ($image =~ /.*\.ico$/) { + if ( $image =~ /.*\.ico$/ ) { $type = 'image/x-icon'; } - if (open(my $F, '<', 'logos/'.$image)) { + if ( open( my $F, '<', 'logos/' . $image ) ) { local $/ = undef; + # SMELL: this call is correct, but causes a perl error # on some versions of CGI.pm # print $query->header(-type => $query->param('type')); # So use this instead: - print 'Content-type: '.$type."\n\n"; + print 'Content-type: ' . $type . "\n\n"; print <$F>; close($F); } @@ -368,37 +364,56 @@ } my @meta = ( - CGI::meta({ 'http-equiv'=>'Pragma', content=>'no-cache' }), - CGI::meta({ 'http-equiv'=>'Cache-Control', content=>'no-cache' }), - CGI::meta({ 'http-equiv'=>'Expires', content=>0 }), - CGI::meta({ name=>'robots', content=>'noindex' }), - CGI::Link( { -rel=>'icon', - -href=>$scriptName.'?action=image;image=favicon.ico;type=image/x-icon', - -type=>'image/x-icon' } ), + CGI::meta( { 'http-equiv' => 'Pragma', content => 'no-cache' } ), + CGI::meta( { 'http-equiv' => 'Cache-Control', content => 'no-cache' } ), + CGI::meta( { 'http-equiv' => 'Expires', content => 0 } ), + CGI::meta( { name => 'robots', content => 'noindex' } ), CGI::Link( - { -rel=>'shortcut icon', - -href=>$scriptName.'?action=image;image=favicon.ico;type=image/x-icon', - -type=>'image/x-icon' } ), - CGI::script( { language => 'JavaScript', - type => 'text/javascript' }, TWiki::Configure::JS::js1() ), - CGI::style( { -type=>'text/css' }, TWiki::Configure::CSS::css()), - CGI::script( { language => 'JavaScript', - type => 'text/javascript' }, - TWiki::Configure::JS::js2() ), - ); + { + -rel => 'icon', + -href => $scriptName + . '?action=image;image=favicon.ico;type=image/x-icon', + -type => 'image/x-icon' + } + ), + CGI::Link( + { + -rel => 'shortcut icon', + -href => $scriptName + . '?action=image;image=favicon.ico;type=image/x-icon', + -type => 'image/x-icon' + } + ), + CGI::script( + { + language => 'JavaScript', + type => 'text/javascript' + }, + TWiki::Configure::JS::js1() + ), + CGI::style( { -type => 'text/css' }, TWiki::Configure::CSS::css() ), + CGI::script( + { + language => 'JavaScript', + type => 'text/javascript' + }, + TWiki::Configure::JS::js2() + ), +); # Generate standard page header my $hdr = CGI::start_html( -title => 'TWiki Configuration', - -head => \@meta, - -class => 'patternNoViewPage'); + -head => \@meta, + -class => 'patternNoViewPage' +); # XML header confuses IE, so strip it out. This is fixed in CGI.pm 3.06 # (and IE 7, but who's counting?) -if ($CGI::VERSION < 3.06) { +if ( $CGI::VERSION < 3.06 ) { $hdr =~ s/^<\?xml.*?>//s; } -print CGI::header('text/html'). $hdr; +print CGI::header('text/html') . $hdr; print <<'HERE'; <div id="patternScreen"> @@ -411,35 +426,44 @@ HERE # use this script recursively to serve the icon image -print CGI::img({src=>$scriptName.'?action=image;image=T-logo-140x40-t.gif;type=image/gif', class=>'logo', alt=>'TWiki', width=>'140', height=>'40'}); +print CGI::img( + { + src => $scriptName + . '?action=image;image=T-logo-140x40-t.gif;type=image/gif', + class => 'logo', + alt => 'TWiki', + width => '140', + height => '40' + } +); my $stub = new TWiki::Configure::Item(); + # This call will define $TWiki::defaultCfg by loading .spec files -my $sanityUI = TWiki::Configure::UI::loadChecker('BasicSanity', $stub); -my ($sanityStatement, $badLSC) = $sanityUI->ui(); +my $sanityUI = TWiki::Configure::UI::loadChecker( 'BasicSanity', $stub ); +my ( $sanityStatement, $badLSC ) = $sanityUI->ui(); # This is the dispatcher; $action is the name of the action to perform, # this is concatenated to _action to determine the name of the procedure. # Dispatcher methods return a boolean to indicate whether to generate a # link back to the main page at the end. -if ($sanityUI->insane() || $query->param('abort')) { +if ( $sanityUI->insane() || $query->param('abort') ) { print $sanityStatement; -} else { - - -if (!defined $cfgAccess) { - - my $newPass = $query->param('newCfgP'); - if (!defined($newPass)) { - $action = 'PromptPassword'; - }else {$cfgAccess = $newPass;} } +else { + if ( !defined $cfgAccess ) { + my $newPass = $query->param('newCfgP'); + if ( !defined($newPass) ) { + $action = 'PromptPassword'; + } + else { $cfgAccess = $newPass; } + } $action =~ s/\W//g; - my $method = '_action'.$action; + my $method = '_action' . $action; die "Undefined action $action" unless defined(&$method); @@ -449,9 +473,13 @@ if ($reroute) { print '<div>'; - print CGI::a( { href=>$scriptName.'?t='.time(), - rel => 'nofollow' }, - 'Return to configuration'); + print CGI::a( + { + href => $scriptName . '?t=' . time(), + rel => 'nofollow' + }, + 'Return to configuration' + ); print CGI::br(); print "</div>\n"; } @@ -468,17 +496,17 @@ </div><!--/patternScreen--> HERE -print CGI::end_html(),"\n"; +print CGI::end_html(), "\n"; ########################################################### # End of the main program; the rest is all subs sub _checkLoadUI { - my ($uiname, $root) = @_; - my $ui = TWiki::Configure::UI::loadUI($uiname, $root); + my ( $uiname, $root ) = @_; + my $ui = TWiki::Configure::UI::loadUI( $uiname, $root ); unless ($ui) { print "Could not load $uiname UI. Error was: <pre>$@</pre>"; - if ($@ =~ /Can't locate (\S+)/) { + if ( $@ =~ /Can't locate (\S+)/ ) { print <<HERE You may be able to correct this error by installing the missing $1 module. HERE @@ -489,62 +517,65 @@ # Action invoked by 'Next' button on the main screen sub _actionNext { - my $valuer = new TWiki::Configure::Valuer( - $TWiki::defaultCfg, \%TWiki::cfg); + my $valuer = + new TWiki::Configure::Valuer( $TWiki::defaultCfg, \%TWiki::cfg ); my %updated; - my $modified = $valuer->loadCGIParams($TWiki::query, \%updated); + my $modified = $valuer->loadCGIParams( $TWiki::query, \%updated ); # create the root of the UI my $root = new TWiki::Configure::Root(); my $ui; - if(!TWiki::Configure::UI::authorised()) { + if ( !TWiki::Configure::UI::authorised() ) { - $ui = _checkLoadUI('PromptPASS', $root); + $ui = _checkLoadUI( 'PromptPASS', $root ); return 1 unless $ui; - print $ui->ui(1, 'Configure'); + print $ui->ui( 1, 'Configure' ); return 1; - } #Here i am authenticated user + } #Here i am authenticated user - -#TODO - if authorisation fails - redirect to authentication form - if (!$confirm) { + #TODO - if authorisation fails - redirect to authentication form + if ( !$confirm ) { print CGI::h2('Please confirm the following Changes'); - print CGI::div($modified.' configuration item'. - ($modified==1?' was':'s were').' changed'); + print CGI::div( $modified + . ' configuration item' + . ( $modified == 1 ? ' was' : 's were' ) + . ' changed' ); if ($modified) { - print CGI::div(join(' ', keys %updated)); + print CGI::div( join( ' ', keys %updated ) ); } - $ui = _checkLoadUI('AUTH', $root); + $ui = _checkLoadUI( 'AUTH', $root ); return 1 unless $ui; - $ui->{newCfgP} = - $ui->{newCfgP} = $newCfgP if defined $newCfgP; - $ui->{confCfgP}= $confCfgP if defined $confCfgP; - print $ui->ui(1, 'Save'); - - } else { + $ui->{newCfgP} = $ui->{newCfgP} = $newCfgP if defined $newCfgP; + $ui->{confCfgP} = $confCfgP if defined $confCfgP; + print $ui->ui( 1, 'Save' ); + + } + else { + # Load the specs from the .spec files and generate the UI template - TWiki::Configure::TWikiCfg::load($root, 1); + TWiki::Configure::TWikiCfg::load( $root, 1 ); - $ui = _checkLoadUI('UPDATE', $root); + $ui = _checkLoadUI( 'UPDATE', $root ); return 1 unless $ui; - print $ui->ui($root, $valuer, \%updated); + print $ui->ui( $root, $valuer, \%updated ); } return 1; } + # Action invoked for prompting the Password on the main screen -sub _actionPromptPassword{ +sub _actionPromptPassword { + print $sanityStatement ; ## printing this in any case.. -print $sanityStatement ; ## printing this in any case.. + my $root = new TWiki::Configure::Root(); + my $valuer = + new TWiki::Configure::Valuer( $TWiki::defaultCfg, \%TWiki::cfg ); -my $root = new TWiki::Configure::Root(); -my $valuer = new TWiki::Configure::Valuer( $TWiki::defaultCfg, \%TWiki::cfg); + my %updated; + my $modified = $valuer->loadCGIParams( $TWiki::query, \%updated ); -my %updated; -my $modified = $valuer->loadCGIParams($TWiki::query, \%updated); + print <<HERE; -print <<HERE; - <div class="explanation"> <ul> <li><b>If your TWiki site is already working</b>, continue to @@ -587,60 +618,62 @@ </ul> </div> HERE - my $ui; + my $ui; -if ( $badLSC ge 1 ) { - - # Load the specs from the .spec files and generate the UI template - TWiki::Configure::TWikiCfg::load($root, 1); + if ( $badLSC ge 1 ) { + # Load the specs from the .spec files and generate the UI template + TWiki::Configure::TWikiCfg::load( $root, 1 ); - my $newPass = $query->param('newCfgP'); + my $newPass = $query->param('newCfgP'); if ($newPass) { - if (!TWiki::Configure::UI::authorised()) { - $ui = _checkLoadUI('SetNewPass', $root); - return 1 unless $ui; - print $ui->ui(1, 'Configure'); - }else { - $ui = _checkLoadUI('AUTH', $root); - return 1 unless $ui; - print $ui->ui(1, 'Configure'); - - } + if ( !TWiki::Configure::UI::authorised() ) { + $ui = _checkLoadUI( 'SetNewPass', $root ); + return 1 unless $ui; + print $ui->ui( 1, 'Configure' ); + } + else { + $ui = _checkLoadUI( 'AUTH', $root ); + return 1 unless $ui; + print $ui->ui( 1, 'Configure' ); - }else { - $ui = _checkLoadUI('SetNewPass', $root); - return 1 unless $ui; - print $ui->ui(1, 'Configure'); - } -return 1; + } -} - - ## Password is verified and is correct... + } + else { + $ui = _checkLoadUI( 'SetNewPass', $root ); + return 1 unless $ui; + print $ui->ui( 1, 'Configure' ); + } + return 1; -if(!TWiki::Configure::UI::authorised()) { - ## TODO...Add meaningful line - - $ui = _checkLoadUI('PromptPASS', $root); + } + + ## Password is verified and is correct... + + if ( !TWiki::Configure::UI::authorised() ) { + ## TODO...Add meaningful line + + $ui = _checkLoadUI( 'PromptPASS', $root ); return 1 unless $ui; - print $ui->ui(1, 'Configure'); - }else { + print $ui->ui( 1, 'Configure' ); + } + else { - ## Password is verified and is correct... - - } - return 1; + ## Password is verified and is correct... + + } + return 1; } # Invoked by "find more extensions" button in the Extensions section sub _actionFindMoreExtensions { my $root = new TWiki::Configure::Root(); - print CGI::h1( 'Find TWiki Extensions'); + print CGI::h1('Find TWiki Extensions'); print '<div class="patternContent"><div class="patternTopic">'; - my $ui = _checkLoadUI('EXTENSIONS',$root); + my $ui = _checkLoadUI( 'EXTENSIONS', $root ); return 1 unless $ui; print $ui->ui(); @@ -651,12 +684,13 @@ sub _actionInstallExtension { my $root = new TWiki::Configure::Root(); my $ui; - if (!TWiki::Configure::UI::authorised()) { - $ui = _checkLoadUI('AUTH', $root); + if ( !TWiki::Configure::UI::authorised() ) { + $ui = _checkLoadUI( 'AUTH', $root ); return 1 unless $ui; - print $ui->ui(0, 'Install '.($query->param('extension')||'')); - } else { - $ui = _checkLoadUI('EXTEND', $root); + print $ui->ui( 0, 'Install ' . ( $query->param('extension') || '' ) ); + } + else { + $ui = _checkLoadUI( 'EXTEND', $root ); return 1 unless $ui; print $ui->ui(); } @@ -666,43 +700,43 @@ # This is the default screen sub _actionConfigure { + my $root = new TWiki::Configure::Root(); - my $root = new TWiki::Configure::Root(); - - if(!TWiki::Configure::UI::authorised()) { - my $ui = _checkLoadUI('PromptPASS', $root); + if ( !TWiki::Configure::UI::authorised() ) { + my $ui = _checkLoadUI( 'PromptPASS', $root ); return 1 unless $ui; - print $ui->ui(1, 'Configure'); + print $ui->ui( 1, 'Configure' ); return 1; - } #Here i am authenticate + } #Here i am authenticate - $TWiki::Configure::UI::toterrors = 0; + $TWiki::Configure::UI::toterrors = 0; $TWiki::Configure::UI::totwarnings = 0; - print CGI::h1( 'Configuration'); + print CGI::h1('Configuration'); print $sanityStatement; # The first three sections go without a root my $stub = new TWiki::Configure::Item(); - my $eui = TWiki::Configure::UI::loadChecker('Environment', $stub); + my $eui = TWiki::Configure::UI::loadChecker( 'Environment', $stub ); # See if this platform has special detection or checking requirements # (most don't) $stub = new TWiki::Configure::Item(); - my $osui = TWiki::Configure::UI::loadChecker( - $Config::Config{osname}, $stub); + my $osui = + TWiki::Configure::UI::loadChecker( $Config::Config{osname}, $stub ); $stub = new TWiki::Configure::Item(); - my $cgiui = TWiki::Configure::UI::loadChecker('CGISetup', $stub); + my $cgiui = TWiki::Configure::UI::loadChecker( 'CGISetup', $stub ); # Use a separate root for the _saveable_ sections # my $root = new TWiki::Configure::Root(); - my $valuer = new TWiki::Configure::Valuer( - $TWiki::defaultCfg, \%TWiki::cfg); + my $valuer = + new TWiki::Configure::Valuer( $TWiki::defaultCfg, \%TWiki::cfg ); + # Load the config structures. - TWiki::Configure::TWikiCfg::load($root, !$badLSC); + TWiki::Configure::TWikiCfg::load( $root, !$badLSC ); - if (!$badLSC) { + if ( !$badLSC ) { print <<HERE; <div class="patternContent"> <div class="patternTopic"> @@ -760,11 +794,11 @@ <li>The little <span class='twikiAlert' title="Not here, stupid. In the table below!">δ</span> after an entry means that the current value is <b>not</b> the same as the default value. If you hover the cursor over the <span class='twikiAlert' title="Not here, stupid. In the table below!">δ</span>, a popup will show you what the default value is.</li> <li><b><font color="#f00">EXPERT</font></b> means a setting is for expert use only. You should not fiddle with it unless you know what you are doing, or at least have read all the documentation. HERE - if (!$expertsMode) { + if ( !$expertsMode ) { print <<HERE EXPERT options are hidden unless you click the <form><input type="submit" style="background-color:#eef" value="Yes, I've read all the documentation"/><input type="hidden" name="t" value="@{[time()]}" /><input type="hidden" name="expert" value="1" /></form> button. HERE -} + } print <<HERE; </li> </ul> @@ -772,9 +806,14 @@ </div><!--explanation--> HERE } - print CGI::start_form({ name=>'update', - action=>$scriptName, - method=>"post" }); + print CGI::start_form( + { + name => 'update', + action => $scriptName, + method => "post" + } + ); + # use time to make sure we never allow cacheing print CGI::hidden( 'time', time() ); @@ -803,35 +842,45 @@ ); print $eui->ui(); - print $osui->ui() if $osui; + print $osui->ui() if $osui; print $cgiui->ui() if $cgiui; # Load the UI for the configuration and whack it out - my $ui = _checkLoadUI('Root', $root); + my $ui = _checkLoadUI( 'Root', $root ); return 1 unless $ui; $ui->{experts} = $expertsMode; - print $ui->ui($root, $valuer); + print $ui->ui( $root, $valuer ); print "</div><!-- options -->\n"; - if ($TWiki::Configure::UI::toterrors || - $TWiki::Configure::UI::totwarnings) { - my $mess = 'Total: '.$TWiki::Configure::UI::toterrors.' error'. - ($TWiki::Configure::UI::toterrors==1?'':'s').', '. - $TWiki::Configure::UI::totwarnings.' warning'. - ($TWiki::Configure::UI::totwarnings==1?'':'s'); + if ( $TWiki::Configure::UI::toterrors + || $TWiki::Configure::UI::totwarnings ) + { + my $mess = + 'Total: ' + . $TWiki::Configure::UI::toterrors + . ' error' + . ( $TWiki::Configure::UI::toterrors == 1 ? '' : 's' ) . ', ' + . $TWiki::Configure::UI::totwarnings + . ' warning' + . ( $TWiki::Configure::UI::totwarnings == 1 ? '' : 's' ); print CGI::div($mess); } - print CGI::hidden('cfgAccess', $cfgAccess); - print CGI::hidden('newCfgP', $newCfgP) if defined $newCfgP; - print CGI::hidden('confCfgP', $confCfgP) if defined $confCfgP; - print CGI::p(CGI::submit(-class=>'twikiSubmit', - -name=>'action', - -value=>'Next', - -accesskey=>'N')); + print CGI::hidden( 'cfgAccess', $cfgAccess ); + print CGI::hidden( 'newCfgP', $newCfgP ) if defined $newCfgP; + print CGI::hidden( 'confCfgP', $confCfgP ) if defined $confCfgP; + print CGI::p( + CGI::submit( + -class => 'twikiSubmit', + -name => 'action', + -value => 'Next', + -accesskey => 'N' + ) + ); - print "<a href=\"$TWiki::cfg{ScriptUrlPath}/view$TWiki::cfg{ScriptSuffix}/$TWiki::cfg{SystemWebName}/WebHome\">Cancel and return to TWiki WebHome</a>"; + print +"<a href=\"$TWiki::cfg{ScriptUrlPath}/view$TWiki::cfg{ScriptSuffix}/$TWiki::cfg{SystemWebName}/WebHome\">Cancel and return to TWiki WebHome</a>"; print CGI::end_form(); |