Changeset 3947


Ignore:
Timestamp:
05/20/09 17:25:22 (3 years ago)
Author:
OlivierRaginel
Message:

Item1518: perltidy'd

Location:
trunk
Files:
233 edited

Legend:

Unmodified
Added
Removed
  • trunk/BehaviourContrib/lib/Foswiki/Contrib/BehaviourContrib.pm

    r3944 r3947  
    2828    my $base = '%PUBURLPATH%/%SYSTEMWEB%/BehaviourContrib'; 
    2929    my $USE_SRC = 
    30       Foswiki::Func::getPreferencesValue('BEHAVIOURCONTRIB_DEBUG') ? 
    31           '_src' : ''; 
     30      Foswiki::Func::getPreferencesValue('BEHAVIOURCONTRIB_DEBUG') 
     31      ? '_src' 
     32      : ''; 
    3233    my $head = <<HERE; 
    3334<script type='text/javascript' src='$base/behaviour$USE_SRC.js'></script> 
  • trunk/EditTablePlugin/lib/Foswiki/Plugins/EditTablePlugin.pm

    r3498 r3947  
    2626our $RELEASE = '4.23'; 
    2727 
    28 our $pluginName   = 'EditTablePlugin'; 
    29 our $ENCODE_START = '--EditTableEncodeStart--'; 
    30 our $ENCODE_END   = '--EditTableEncodeEnd--'; 
    31 our $ASSET_URL    = '%PUBURL%/%SYSTEMWEB%/EditTablePlugin'; 
     28our $pluginName        = 'EditTablePlugin'; 
     29our $ENCODE_START      = '--EditTableEncodeStart--'; 
     30our $ENCODE_END        = '--EditTableEncodeEnd--'; 
     31our $ASSET_URL         = '%PUBURL%/%SYSTEMWEB%/EditTablePlugin'; 
    3232our $NO_PREFS_IN_TOPIC = 1; 
    33 our $SHORTDESCRIPTION = 'Edit tables using edit fields, date pickers and drop down boxes'; 
     33our $SHORTDESCRIPTION = 
     34  'Edit tables using edit fields, date pickers and drop down boxes'; 
    3435our $web; 
    3536our $topic; 
     
    6061    $usesJavascriptInterface = 
    6162      Foswiki::Func::getPreferencesFlag('EDITTABLEPLUGIN_JAVASCRIPTINTERFACE') 
    62           || 1; 
     63      || 1; 
    6364    $viewModeHeaderDone = 0; 
    6465    $editModeHeaderDone = 0; 
  • trunk/EditTablePlugin/lib/Foswiki/Plugins/EditTablePlugin/Core.pm

    r3761 r3947  
    171171    # Item1458 ignore all saving unless it happened using POST method. 
    172172    $doSave = 0 
    173       if ( $query && $query->method() && uc($query->method()) ne 'POST' ); 
     173      if ( $query && $query->method() && uc( $query->method() ) ne 'POST' ); 
    174174 
    175175    if ($Foswiki::Plugins::EditTablePlugin::debug) { 
     
    529529        # to TABLE for exactly this purpose. Please to not remove this 
    530530        # feature again. 
    531         if ( $doEdit && !$doSave && ( $paramTableNr == $tableNr ) && 
    532            ( $editTableTag !~ /%TABLE{.*?disableallsort="on".*?}%/ ) ) { 
     531        if (   $doEdit 
     532            && !$doSave 
     533            && ( $paramTableNr == $tableNr ) 
     534            && ( $editTableTag !~ /%TABLE{.*?disableallsort="on".*?}%/ ) ) 
     535        { 
    533536            $editTableTag =~ s/(%TABLE{.*?)(}%)/$1 disableallsort="on"$2/; 
    534         }        
    535          
     537        } 
     538 
    536539        # The Data::parseText merges a TABLE and EDITTABLE to one line 
    537540        # We split it again to make editing easier for the user 
     
    644647    $prefEDIT_BUTTON = 
    645648      Foswiki::Func::getPreferencesValue("\U$pluginName\E_EDIT_BUTTON") 
    646       ||  '%MAKETEXT{"Edit this table"}%, %ATTACHURL%/edittable.gif'; 
     649      || '%MAKETEXT{"Edit this table"}%, %ATTACHURL%/edittable.gif'; 
    647650 
    648651    $prefSAVE_BUTTON = 
     
    661664        "\U$pluginName\E_DELETE_LAST_ROW_BUTTON") 
    662665      || '%MAKETEXT{"Delete last row"}%'; 
    663        
     666 
    664667    $prefCANCEL_BUTTON = 
    665668      Foswiki::Func::getPreferencesValue("\U$pluginName\E_CANCEL_BUTTON") 
    666669      || '%MAKETEXT{"Cancel"}%'; 
    667        
     670 
    668671    $prefMESSAGE_INCLUDED_TOPIC_DOES_NOT_EXIST = 
    669672      Foswiki::Func::getPreferencesValue( 
     
    767770    my $iTopic = Foswiki::Func::extractNameValuePair( $theArgs, 'include' ); 
    768771    if ($iTopic) { 
    769         ($inWeb, $iTopic) = Foswiki::Func::normalizeWebTopicName($inWeb, $iTopic); 
    770  
    771         unless (Foswiki::Func::topicExists( $inWeb, $iTopic )) { 
     772        ( $inWeb, $iTopic ) = 
     773          Foswiki::Func::normalizeWebTopicName( $inWeb, $iTopic ); 
     774 
     775        unless ( Foswiki::Func::topicExists( $inWeb, $iTopic ) ) { 
    772776            $warningMessage = $prefMESSAGE_INCLUDED_TOPIC_DOES_NOT_EXIST; 
    773         } else { 
     777        } 
     778        else { 
    774779 
    775780            my $text = Foswiki::Func::readTopicText( $inWeb, $iTopic ); 
  • trunk/EditTablePlugin/test/unit/EditTablePlugin/EditTablePluginTests.pm

    r3790 r3947  
    975975    my ( $meta, $newtext ) = Foswiki::Func::readTopic( $webName, $topicName ); 
    976976 
    977     # Expected is that saving causes the TABLE and EDITTABLE tags to be saved on two lines. 
     977# Expected is that saving causes the TABLE and EDITTABLE tags to be saved on two lines. 
    978978    my $expected = <<NEWEXPECTED; 
    979979%TABLE{columnwidths="80,80,50,110,150,50,50,50,50,50,70,70,50" dataalign="left,left,center,left,left,center,center,center,center,center,center,right,right,center" headeralign="center" headerrows="1" footerrows="1" headerislabel="on"}% 
  • trunk/InterwikiPlugin/lib/Foswiki/Plugins/InterwikiPlugin.pm

    r3455 r3947  
    3838use strict; 
    3939 
    40 use Foswiki::Func ();       # The plugins API 
     40use Foswiki::Func    ();    # The plugins API 
    4141use Foswiki::Plugins ();    # For the API version 
    4242 
    43 our $VERSION = '$Rev$'; 
    44 our $RELEASE = '15 Apr 2009'; 
     43our $VERSION           = '$Rev$'; 
     44our $RELEASE           = '15 Apr 2009'; 
    4545our $NO_PREFS_IN_TOPIC = 1; 
    46 our $SHORTDESCRIPTION = 'Link ExternalSite:Page text to external sites based on aliases defined in a rules topic'; 
     46our $SHORTDESCRIPTION = 
     47'Link ExternalSite:Page text to external sites based on aliases defined in a rules topic'; 
    4748 
    4849our $interLinkFormat; 
     
    7576      || '<a class="interwikiLink" href="$url" title="$tooltip"><noautolink>$label</noautolink></a>'; 
    7677 
    77     my ($interWeb, $interTopic) = 
    78       Foswiki::Func::normalizeWebTopicName( 
    79           $installWeb, 
    80           Foswiki::Func::getPreferencesValue('INTERWIKIPLUGIN_RULESTOPIC') 
    81               || 'InterWikis' ); 
     78    my ( $interWeb, $interTopic ) = Foswiki::Func::normalizeWebTopicName( 
     79        $installWeb, 
     80        Foswiki::Func::getPreferencesValue('INTERWIKIPLUGIN_RULESTOPIC') 
     81          || 'InterWikis' 
     82    ); 
    8283 
    8384    my $text = Foswiki::Func::readTopicText( $interWeb, $interTopic, undef, 1 ); 
  • trunk/MailerContrib/lib/Foswiki/Contrib/MailerContrib.pm

    r3944 r3947  
    1818use CGI qw(-any); 
    1919 
    20 use Foswiki (); 
    21 use Foswiki::Plugins (); 
    22 use Foswiki::Time (); 
    23 use Foswiki::Func (); 
     20use Foswiki                                    (); 
     21use Foswiki::Plugins                           (); 
     22use Foswiki::Time                              (); 
     23use Foswiki::Func                              (); 
    2424use Foswiki::Contrib::MailerContrib::WebNotify (); 
    25 use Foswiki::Contrib::MailerContrib::Change (); 
    26 use Foswiki::Contrib::MailerContrib::UpData (); 
     25use Foswiki::Contrib::MailerContrib::Change    (); 
     26use Foswiki::Contrib::MailerContrib::UpData    (); 
    2727 
    2828our $VERSION = '$Rev$'; 
  • trunk/PreferencesPlugin/lib/Foswiki/Plugins/PreferencesPlugin.pm

    r3945 r3947  
    2626use strict; 
    2727 
    28 use Foswiki::Func ();    # The plugins API 
    29 use Foswiki::Plugins (); # For the API version 
     28use Foswiki::Func    ();    # The plugins API 
     29use Foswiki::Plugins ();    # For the API version 
    3030 
    3131use vars qw( @shelter ); 
     
    3333our $VERSION = '$Rev$'; 
    3434our $RELEASE = '19 Apr 2009'; 
    35 our $SHORTDESCRIPTION = 'Allows editing of preferences using fields predefined in a form'; 
     35our $SHORTDESCRIPTION = 
     36  'Allows editing of preferences using fields predefined in a form'; 
    3637our $NO_PREFS_IN_TOPIC = 1; 
    3738 
     
    3940 
    4041# Markers used during form generation 
    41 my $START_MARKER  = $MARKER.'STARTPREF'.$MARKER; 
    42 my $END_MARKER    = $MARKER.'ENDPREF'.$MARKER; 
     42my $START_MARKER = $MARKER . 'STARTPREF' . $MARKER; 
     43my $END_MARKER   = $MARKER . 'ENDPREF' . $MARKER; 
    4344 
    4445sub initPlugin { 
     46 
    4547    # check for Plugins.pm versions 
    46     if( $Foswiki::Plugins::VERSION < 1.026 ) { 
    47         Foswiki::Func::writeWarning( 'Version mismatch between PreferencesPlugin and Plugins.pm' ); 
     48    if ( $Foswiki::Plugins::VERSION < 1.026 ) { 
     49        Foswiki::Func::writeWarning( 
     50            'Version mismatch between PreferencesPlugin and Plugins.pm'); 
    4851        return 0; 
    4952    } 
     
    5659    ### my ( $text, $topic, $web ) = @_; 
    5760    my $topic = $_[1]; 
    58     my $web = $_[2]; 
     61    my $web   = $_[2]; 
    5962    return unless ( $_[0] =~ m/%EDITPREFERENCES(?:{(.*?)})?%/ ); 
    6063 
     
    6265    require Foswiki::Attrs; 
    6366    my $formDef; 
    64     my $attrs = new Foswiki::Attrs( $1 ); 
    65     if( defined( $attrs->{_DEFAULT} )) { 
    66         my( $formWeb, $form ) = Foswiki::Func::normalizeWebTopicName( 
    67             $web, $attrs->{_DEFAULT} ); 
     67    my $attrs = new Foswiki::Attrs($1); 
     68    if ( defined( $attrs->{_DEFAULT} ) ) { 
     69        my ( $formWeb, $form ) = 
     70          Foswiki::Func::normalizeWebTopicName( $web, $attrs->{_DEFAULT} ); 
    6871 
    6972        # SMELL: Unpublished API. No choice, though :-( 
     
    7578    my $query = Foswiki::Func::getCgiQuery(); 
    7679 
    77     my $action = lc( $query->param( 'prefsaction' )); 
    78     $query->Delete( 'prefsaction' ); 
     80    my $action = lc( $query->param('prefsaction') ); 
     81    $query->Delete('prefsaction'); 
    7982    $action =~ s/\s.*$//; 
    8083 
     
    8386 
    8487        # Replace setting values by form fields but not inside comments Item4816 
    85         my $outtext = ''; 
     88        my $outtext       = ''; 
    8689        my $insidecomment = 0; 
    87         foreach my $token ( split/(<!--|-->)/, $_[0] ) { 
     90        foreach my $token ( split /(<!--|-->)/, $_[0] ) { 
    8891            if ( $token =~ /<!--/ ) { 
    8992                $insidecomment++; 
    90             } elsif ( $token =~ /-->/ ) { 
     93            } 
     94            elsif ( $token =~ /-->/ ) { 
    9195                $insidecomment-- if ( $insidecomment > 0 ); 
    92             } elsif ( !$insidecomment ) { 
    93                 $token =~ s(^((?:\t|   )+\*\s(Set|Local)\s*)(\w+)\s*\=(.*$(\n[ \t]+[^\s*].*$)*)) 
     96            } 
     97            elsif ( !$insidecomment ) { 
     98                $token =~ 
     99s(^((?:\t|   )+\*\s(Set|Local)\s*)(\w+)\s*\=(.*$(\n[ \t]+[^\s*].*$)*)) 
    94100                           ($1._generateEditField($web, $topic, $3, $4, $formDef))gem; 
    95101            } 
     
    100106        $_[0] =~ s/%EDITPREFERENCES({.*?})?%/ 
    101107          _generateControlButtons($web, $topic)/ge; 
    102         my $viewUrl = Foswiki::Func::getScriptUrl( 
    103             $web, $topic, 'viewauth' ); 
     108        my $viewUrl = Foswiki::Func::getScriptUrl( $web, $topic, 'viewauth' ); 
    104109        my $startForm = CGI::start_form( 
    105             -name => 'editpreferences', 
     110            -name   => 'editpreferences', 
    106111            -method => 'post', 
    107             -action => $viewUrl ); 
     112            -action => $viewUrl 
     113        ); 
    108114        $startForm =~ s/\s+$//s; 
    109115        my $endForm = CGI::end_form(); 
    110116        $endForm =~ s/\s+$//s; 
    111         $_[0] =~ s/^(.*?)$START_MARKER(.*)$END_MARKER(.*?)$/$1$startForm$2$endForm$3/s; 
     117        $_[0] =~ 
     118          s/^(.*?)$START_MARKER(.*)$END_MARKER(.*?)$/$1$startForm$2$endForm$3/s; 
    112119        $_[0] =~ s/$START_MARKER|$END_MARKER//gs; 
    113120    } 
    114121 
    115     if( $action eq 'cancel' ) { 
     122    if ( $action eq 'cancel' ) { 
    116123        Foswiki::Func::setTopicEditLock( $web, $topic, 0 ); 
    117124 
    118     } elsif( $action eq 'save' ) { 
     125    } 
     126    elsif ( $action eq 'save' ) { 
    119127 
    120128        # Make sure the request came from POST 
    121         if ( $query && $query->method() && uc($query->method()) ne 'POST' ) { 
     129        if ( $query && $query->method() && uc( $query->method() ) ne 'POST' ) { 
     130 
    122131            # silently ignore it if the request didn't come from a POST 
    123         } else { 
    124             my( $meta, $text ) = Foswiki::Func::readTopic( $web, $topic ); 
     132        } 
     133        else { 
     134            my ( $meta, $text ) = Foswiki::Func::readTopic( $web, $topic ); 
     135 
    125136            # SMELL: unchecked implicit untaint of value? 
    126137            $text =~ s(^((?:\t|   )+\*\s(Set|Local)\s)(\w+)\s\=\s(.*)$) 
     
    129140        } 
    130141        Foswiki::Func::setTopicEditLock( $web, $topic, 0 ); 
     142 
    131143        # Finish with a redirect so that the *new* values are seen 
    132144        my $viewUrl = Foswiki::Func::getScriptUrl( $web, $topic, 'view' ); 
     
    134146        return; 
    135147    } 
     148 
    136149    # implicit action="view", or drop through from "save" or "cancel" 
    137150    $_[0] =~ s/%EDITPREFERENCES({.*?})?%/_generateEditButton($web, $topic)/ge; 
     
    148161# Pluck the default value of a named field from a form definition 
    149162sub _getField { 
    150     my( $formDef, $name ) = @_; 
    151     foreach my $f ( @{$formDef->{fields}} ) { 
    152         if( $f->{name} eq $name ) { 
     163    my ( $formDef, $name ) = @_; 
     164    foreach my $f ( @{ $formDef->{fields} } ) { 
     165        if ( $f->{name} eq $name ) { 
    153166            return $f; 
    154167        } 
     
    161174# extra edit types defined in other plugins. 
    162175sub _generateEditField { 
    163     my( $web, $topic, $name, $value, $formDef ) = @_; 
     176    my ( $web, $topic, $name, $value, $formDef ) = @_; 
    164177    $value =~ s/^\s*(.*?)\s*$/$1/ge; 
    165178 
    166     my ($extras, $html); 
    167  
    168     if( $formDef ) { 
     179    my ( $extras, $html ); 
     180 
     181    if ($formDef) { 
    169182        my $fieldDef; 
    170         if (defined(&Foswiki::Form::getField)) { 
     183        if ( defined(&Foswiki::Form::getField) ) { 
     184 
    171185            # TWiki 4.2 and later 
    172             $fieldDef = $formDef->getField( $name ); 
    173         } else { 
     186            $fieldDef = $formDef->getField($name); 
     187        } 
     188        else { 
     189 
    174190            # TWiki < 4.2 
    175191            $fieldDef = _getField( $formDef, $name ); 
    176192        } 
    177         if ( $fieldDef ) { 
    178             if( defined(&Foswiki::Form::renderFieldForEdit)) { 
     193        if ($fieldDef) { 
     194            if ( defined(&Foswiki::Form::renderFieldForEdit) ) { 
     195 
    179196                # TWiki < 4.2 SMELL: use of unpublished core function 
    180197                ( $extras, $html ) = 
    181                   $formDef->renderFieldForEdit( $fieldDef, $web, $topic, $value); 
    182             } else { 
     198                  $formDef->renderFieldForEdit( $fieldDef, $web, $topic, 
     199                    $value ); 
     200            } 
     201            else { 
     202 
    183203                # TWiki 4.2 and later SMELL: use of unpublished core function 
    184204                ( $extras, $html ) = 
     
    187207        } 
    188208    } 
    189     unless( $html ) { 
     209    unless ($html) { 
     210 
    190211        # No form definition, default to text field. 
    191         $html = CGI::textfield( -class=>'foswikiAlert foswikiInputField', 
    192                                 -name => $name, 
    193                                 -size => 80, -value => $value ); 
     212        $html = CGI::textfield( 
     213            -class => 'foswikiAlert foswikiInputField', 
     214            -name  => $name, 
     215            -size  => 80, 
     216            -value => $value 
     217        ); 
    194218    } 
    195219 
    196220    push( @shelter, $html ); 
    197221 
    198     return $START_MARKER. 
    199       CGI::span({class=>'foswikiAlert', 
    200                  style=>'font-weight:bold;'}, 
    201                 $name . ' = SHELTER' . $MARKER . $#shelter).$END_MARKER; 
     222    return $START_MARKER 
     223      . CGI::span( 
     224        { 
     225            class => 'foswikiAlert', 
     226            style => 'font-weight:bold;' 
     227        }, 
     228        $name . ' = SHELTER' . $MARKER . $#shelter 
     229      ) . $END_MARKER; 
    202230} 
    203231 
    204232# Generate the button that replaces the EDITPREFERENCES tag in view mode 
    205233sub _generateEditButton { 
    206     my( $web, $topic ) = @_; 
    207  
    208     my $viewUrl = Foswiki::Func::getScriptUrl( 
    209         $web, $topic, 'viewauth' ); 
     234    my ( $web, $topic ) = @_; 
     235 
     236    my $viewUrl = Foswiki::Func::getScriptUrl( $web, $topic, 'viewauth' ); 
    210237    my $text = CGI::start_form( 
    211         -name => 'editpreferences', 
     238        -name   => 'editpreferences', 
    212239        -method => 'post', 
    213         -action => $viewUrl ); 
    214     $text .= CGI::input({ 
    215         type => 'hidden', 
    216         name => 'prefsaction', 
    217         value => 'edit'}); 
    218     $text .= CGI::submit(-name => 'edit', 
    219                          -value=>'Edit Preferences', 
    220                          -class=>'foswikiButton'); 
     240        -action => $viewUrl 
     241    ); 
     242    $text .= CGI::input( 
     243        { 
     244            type  => 'hidden', 
     245            name  => 'prefsaction', 
     246            value => 'edit' 
     247        } 
     248    ); 
     249    $text .= CGI::submit( 
     250        -name  => 'edit', 
     251        -value => 'Edit Preferences', 
     252        -class => 'foswikiButton' 
     253    ); 
    221254    $text .= CGI::end_form(); 
    222255    $text =~ s/\n//sg; 
     
    226259# Generate the buttons that replace the EDITPREFERENCES tag in edit mode 
    227260sub _generateControlButtons { 
    228     my( $web, $topic ) = @_; 
    229  
    230     my $text = $START_MARKER.CGI::submit(-name=>'prefsaction', 
    231                                          -value=>'Save new settings', 
    232                                          -class=>'foswikiSubmit', 
    233                                          -accesskey=>'s'); 
     261    my ( $web, $topic ) = @_; 
     262 
     263    my $text = $START_MARKER 
     264      . CGI::submit( 
     265        -name      => 'prefsaction', 
     266        -value     => 'Save new settings', 
     267        -class     => 'foswikiSubmit', 
     268        -accesskey => 's' 
     269      ); 
    234270    $text .= '&nbsp;'; 
    235     $text .= CGI::submit(-name=>'prefsaction', -value=>'Cancel', 
    236                          -class=>'foswikiButtonCancel', 
    237                          -accesskey=>'c').$END_MARKER; 
     271    $text .= CGI::submit( 
     272        -name      => 'prefsaction', 
     273        -value     => 'Cancel', 
     274        -class     => 'foswikiButtonCancel', 
     275        -accesskey => 'c' 
     276    ) . $END_MARKER; 
    238277    return $text; 
    239278} 
     
    243282# Set statement. 
    244283sub _saveSet { 
    245     my( $query, $web, $topic, $name, $value, $formDef ) = @_; 
    246  
    247     my $newValue = $query->param( $name ) || $value; 
    248  
    249     if( $formDef ) { 
     284    my ( $query, $web, $topic, $name, $value, $formDef ) = @_; 
     285 
     286    my $newValue = $query->param($name) || $value; 
     287 
     288    if ($formDef) { 
    250289        my $fieldDef = _getField( $formDef, $name ); 
    251290        my $type = $fieldDef->{type} || ''; 
    252         if( $type && $type =~ /^checkbox/ ) { 
    253             my $val = ''; 
     291        if ( $type && $type =~ /^checkbox/ ) { 
     292            my $val  = ''; 
    254293            my $vals = $fieldDef->{value}; 
    255             foreach my $item ( @$vals ) { 
    256                 my $cvalue = $query->param( $name.$item ); 
    257                 if( defined( $cvalue ) ) { 
    258                     if( ! $val ) { 
     294            foreach my $item (@$vals) { 
     295                my $cvalue = $query->param( $name . $item ); 
     296                if ( defined($cvalue) ) { 
     297                    if ( !$val ) { 
    259298                        $val = ''; 
    260                     } else { 
    261                         $val .= ', ' if( $cvalue ); 
    262299                    } 
    263                     $val .= $item if( $cvalue ); 
     300                    else { 
     301                        $val .= ', ' if ($cvalue); 
     302                    } 
     303                    $val .= $item if ($cvalue); 
    264304                } 
    265305            } 
     
    267307        } 
    268308    } 
     309 
    269310    # if no form def, it's just treated as text 
    270311 
    271     return $name.' = '.$newValue; 
     312    return $name . ' = ' . $newValue; 
    272313} 
    273314 
  • trunk/RenderListPlugin/lib/Foswiki/Plugins/RenderListPlugin.pm

    r3944 r3947  
    1212# This program is distributed in the hope that it will be useful, 
    1313# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   
     14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
    1515# 
    1616# As per the GPL, removal of this notice is prohibited. 
    1717# ========================= 
    1818 
    19  
    20 # ========================= 
    21 package Foswiki::Plugins::RenderListPlugin;    # change the package name and $pluginName!!! 
     19# ========================= 
     20package Foswiki::Plugins::RenderListPlugin 
     21  ;    # change the package name and $pluginName!!! 
    2222 
    2323use strict; 
     
    2525# ========================= 
    2626use vars qw( 
    27         $web $topic $user $installWeb 
    28         $pubUrl $attachUrl 
    29     ); 
    30  
    31 our $VERSION = '$Rev: 16234 $'; 
    32 our $RELEASE = '2.1'; 
    33 our $pluginName = 'RenderListPlugin';  # Name of this Plugin 
     27  $web $topic $user $installWeb 
     28  $pubUrl $attachUrl 
     29); 
     30 
     31our $VERSION           = '$Rev: 16234 $'; 
     32our $RELEASE           = '2.1'; 
     33our $pluginName        = 'RenderListPlugin';    # Name of this Plugin 
    3434our $NO_PREFS_IN_TOPIC = 1; 
    3535our $SHORTDESCRIPTION = 'Render bullet lists in a variety of formats'; 
     
    3737our %defaultThemes = ( 
    3838    THREAD => 'tree, 1', 
    39     HOME   => 'icon, 1, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/home.gif', 
    40     ORG    => 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/home.gif', 
    41     GROUP  => 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/group.gif', 
    42     EMAIL  => 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/email.gif', 
    43     TREND  => 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/trend.gif', 
    44     FILE   => 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/file.gif', 
     39    HOME => 
     40'icon, 1, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/home.gif', 
     41    ORG => 
     42'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/home.gif', 
     43    GROUP => 
     44'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/group.gif', 
     45    EMAIL => 
     46'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/email.gif', 
     47    TREND => 
     48'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/trend.gif', 
     49    FILE => 
     50'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/file.gif', 
    4551); 
    4652 
    4753# ========================= 
    48 sub initPlugin 
    49 { 
     54sub initPlugin { 
    5055    ( $topic, $web, $user, $installWeb ) = @_; 
    5156 
    5257    # check for Plugins.pm versions 
    53     if( $Foswiki::Plugins::VERSION < 1 ) { 
    54         Foswiki::Func::writeWarning( "Version mismatch between $pluginName and Plugins.pm" ); 
     58    if ( $Foswiki::Plugins::VERSION < 1 ) { 
     59        Foswiki::Func::writeWarning( 
     60            "Version mismatch between $pluginName and Plugins.pm"); 
    5561        return 0; 
    5662    } 
    5763 
    5864    # one time initialization 
    59     $pubUrl = Foswiki::Func::getUrlHost() . Foswiki::Func::getPubUrlPath(); 
     65    $pubUrl    = Foswiki::Func::getUrlHost() . Foswiki::Func::getPubUrlPath(); 
    6066    $attachUrl = "$pubUrl/$installWeb/$pluginName"; 
    6167 
     
    6571 
    6672# ========================= 
    67 sub startRenderingHandler 
    68 { 
     73sub startRenderingHandler { 
    6974### my ( $text, $web ) = @_;   # do not uncomment, use $_[0], $_[1] instead 
    7075 
     
    7378    # Render here, not in commonTagsHandler so that lists produced by 
    7479    # Plugins, TOC and SEARCH can be rendered 
    75     if ($_[0] =~/%RENDERLIST/o ) { 
    76         unless ($_[0] =~ s/%RENDERLIST{(.*?)}%(([\n\r]+[^ ]{3}[^\n\r]*)*?)(([\n\r]+ {3}[^\n\r]*)+)/&handleRenderList($1, $2, $4)/ges ) { 
     80    if ( $_[0] =~ /%RENDERLIST/o ) { 
     81        unless ( $_[0] =~ 
     82s/%RENDERLIST{(.*?)}%(([\n\r]+[^ ]{3}[^\n\r]*)*?)(([\n\r]+ {3}[^\n\r]*)+)/&handleRenderList($1, $2, $4)/ges 
     83          ) 
     84        { 
     85 
    7786            # Cairo compatibility fallback 
    78             $_[0] =~ s/%RENDERLIST{(.*?)}%(([\n\r]+[^\t]{1}[^\n\r]*)*?)(([\n\r]+\t[^\n\r]*)+)/&handleRenderList($1, $2, $4)/ges; 
    79         } 
    80     } 
    81 } 
    82  
    83 # ========================= 
    84 sub handleRenderList 
    85 { 
     87            $_[0] =~ 
     88s/%RENDERLIST{(.*?)}%(([\n\r]+[^\t]{1}[^\n\r]*)*?)(([\n\r]+\t[^\n\r]*)+)/&handleRenderList($1, $2, $4)/ges; 
     89        } 
     90    } 
     91} 
     92 
     93# ========================= 
     94sub handleRenderList { 
    8695    my ( $theAttr, $thePre, $theList ) = @_; 
    8796 
    8897    $theAttr =~ s/ {3}/\t/gs; 
    89     $thePre =~ s/ {3}/\t/gs; 
     98    $thePre  =~ s/ {3}/\t/gs; 
    9099    $theList =~ s/ {3}/\t/gs; 
    91100 
    92101    my $focus = &Foswiki::Func::extractNameValuePair( $theAttr, "focus" ); 
    93102    my $depth = &Foswiki::Func::extractNameValuePair( $theAttr, "depth" ); 
    94     my $theme = &Foswiki::Func::extractNameValuePair( $theAttr, "theme" ) || 
    95                 &Foswiki::Func::extractNameValuePair( $theAttr ); 
    96     $theme = uc($theme || ''); 
    97     if (defined $defaultThemes{$theme}) { 
     103    my $theme = &Foswiki::Func::extractNameValuePair( $theAttr, "theme" ) 
     104      || &Foswiki::Func::extractNameValuePair($theAttr); 
     105    $theme = uc( $theme || '' ); 
     106    if ( defined $defaultThemes{$theme} ) { 
    98107        $theme = $defaultThemes{$theme}; 
    99     } else { 
     108    } 
     109    else { 
    100110        $theme = "RENDERLISTPLUGIN_${theme}_THEME"; 
    101         $theme = &Foswiki::Func::getPreferencesValue( $theme ) 
     111        $theme = &Foswiki::Func::getPreferencesValue($theme) 
    102112          || "unrecognized theme type"; 
    103113    } 
    104114    my ( $type, $params ) = split( /, */, $theme, 2 ); 
    105     $type = lc( $type ); 
    106  
    107     if( $type eq "tree" || $type eq "icon" ) { 
    108         return $thePre . renderIconList( $type, $params, $focus, $depth, $theList ); 
    109     } else { 
     115    $type = lc($type); 
     116 
     117    if ( $type eq "tree" || $type eq "icon" ) { 
     118        return $thePre 
     119          . renderIconList( $type, $params, $focus, $depth, $theList ); 
     120    } 
     121    else { 
    110122        return "$thePre$theList"; 
    111123    } 
     
    113125 
    114126# ========================= 
    115 sub renderIconList 
    116 { 
     127sub renderIconList { 
    117128    my ( $theType, $theParams, $theFocus, $theDepth, $theText ) = @_; 
    118129 
    119130    $theText =~ s/^[\n\r]*//os; 
    120     my @tree = (); 
    121     my $level = 0; 
    122     my $type = ""; 
    123     my $text = ""; 
     131    my @tree       = (); 
     132    my $level      = 0; 
     133    my $type       = ""; 
     134    my $text       = ""; 
    124135    my $focusIndex = -1; 
    125     foreach( split ( /[\n\r]+/, $theText ) ) { 
     136    foreach ( split( /[\n\r]+/, $theText ) ) { 
    126137        m/^(\t+)(.) *(.*)/; 
    127         $level = length( $1 ); 
    128         $type = $2; 
    129         $text = $3; 
    130         if( ( $theFocus ) && ( $focusIndex < 0 ) && ( $text =~ /$theFocus/ ) ) { 
    131             $focusIndex = scalar( @tree ); 
     138        $level = length($1); 
     139        $type  = $2; 
     140        $text  = $3; 
     141        if ( ($theFocus) && ( $focusIndex < 0 ) && ( $text =~ /$theFocus/ ) ) { 
     142            $focusIndex = scalar(@tree); 
    132143        } 
    133144        push( @tree, { level => $level, type => $type, text => $text } ); 
     
    135146 
    136147    # reduce tree to relatives around focus 
    137     if( $focusIndex >= 0 ) { 
     148    if ( $focusIndex >= 0 ) { 
     149 
    138150        # splice tree into before, current node and after parts 
    139151        my @after = splice( @tree, $focusIndex + 1 ); 
    140         my $nref = pop( @tree ); 
     152        my $nref = pop(@tree); 
    141153 
    142154        # highlight node with focus and remove links 
    143155        $text = $nref->{'text'}; 
    144         $text =~ s/^([^\-]*)\[\[.*?\]\[(.*?)\]\]/$1$2/o;  # remove [[...][...]] link 
    145         $text =~ s/^([^\-]*)\[\[(.*?)\]\]/$1$2/o;         # remove [[...]] link 
    146         $text = "<b> $text </b>"; # bold focus text 
     156        $text =~ 
     157          s/^([^\-]*)\[\[.*?\]\[(.*?)\]\]/$1$2/o;    # remove [[...][...]] link 
     158        $text =~ s/^([^\-]*)\[\[(.*?)\]\]/$1$2/o;    # remove [[...]] link 
     159        $text = "<b> $text </b>";                    # bold focus text 
    147160        $nref->{'text'} = $text; 
    148161 
    149162        # remove uncles and siblings below current node 
    150163        $level = $nref->{'level'}; 
    151         for( my $i = 0; $i < scalar( @after ); $i++ ) { 
    152             if( ( $after[$i]->{'level'} < $level ) 
    153              || ( $after[$i]->{'level'} <= $level &&  $after[$i]->{'type'} ne " " ) ) { 
     164        for ( my $i = 0 ; $i < scalar(@after) ; $i++ ) { 
     165            if ( 
     166                ( $after[$i]->{'level'} < $level ) 
     167                || (   $after[$i]->{'level'} <= $level 
     168                    && $after[$i]->{'type'} ne " " ) 
     169              ) 
     170            { 
    154171                splice( @after, $i ); 
    155172                last; 
     
    159176        # remove uncles and siblings above current node 
    160177        my @before = (); 
    161         for( my $i = scalar( @tree ) - 1; $i >= 0; $i-- ) { 
    162             if( $tree[$i]->{'level'} < $level ) { 
     178        for ( my $i = scalar(@tree) - 1 ; $i >= 0 ; $i-- ) { 
     179            if ( $tree[$i]->{'level'} < $level ) { 
    163180                push( @before, $tree[$i] ); 
    164181                $level = $tree[$i]->{'level'}; 
    165182            } 
    166183        } 
    167         @tree = reverse( @before ); 
    168         $focusIndex = scalar( @tree ); 
     184        @tree       = reverse(@before); 
     185        $focusIndex = scalar(@tree); 
    169186        push( @tree, $nref ); 
    170187        push( @tree, @after ); 
     
    173190    # limit depth of tree 
    174191    my $depth = $theDepth; 
    175     unless( $depth =~ s/.*?([0-9]+).*/$1/o ) { 
     192    unless ( $depth =~ s/.*?([0-9]+).*/$1/o ) { 
    176193        $depth = 0; 
    177194    } 
    178     if( $theFocus ) { 
    179         if( $theDepth eq "" ) { 
     195    if ($theFocus) { 
     196        if ( $theDepth eq "" ) { 
    180197            $depth = $focusIndex + 3; 
    181         } else { 
     198        } 
     199        else { 
    182200            $depth += $focusIndex + 1; 
    183201        } 
    184202    } 
    185     if( $depth > 0 ) { 
     203    if ( $depth > 0 ) { 
    186204        my @tmp = (); 
    187         foreach my $ref ( @tree ) { 
    188             push( @tmp, $ref ) if( $ref->{'level'} <= $depth ); 
     205        foreach my $ref (@tree) { 
     206            push( @tmp, $ref ) if ( $ref->{'level'} <= $depth ); 
    189207        } 
    190208        @tree = @tmp; 
     
    198216    $theParams =~ s/%SYSTEMWEB%/$Foswiki::cfg{SystemWebName}/geo; 
    199217    my ( $showLead, $width, $height, $iconSp, $iconT, $iconI, $iconL, $iconImg ) 
    200        = split( /, */, $theParams ); 
    201     $width   = 16 unless( $width ); 
    202     $height  = 16 unless( $height ); 
    203     $iconSp  = "empty.gif"   unless( $iconSp ); 
    204     $iconSp  = fixImageTag( $iconSp, $width, $height ); 
    205     $iconT   = "dot_udr.gif" unless( $iconT ); 
    206     $iconT   = fixImageTag( $iconT, $width, $height ); 
    207     $iconI   = "dot_ud.gif"  unless( $iconI ); 
    208     $iconI   = fixImageTag( $iconI, $width, $height ); 
    209     $iconL   = "dot_ur.gif"  unless( $iconL ); 
    210     $iconL   = fixImageTag( $iconL, $width, $height ); 
    211     $iconImg = "home.gif"    unless( $iconImg ); 
     218      = split( /, */, $theParams ); 
     219    $width  = 16          unless ($width); 
     220    $height = 16          unless ($height); 
     221    $iconSp = "empty.gif" unless ($iconSp); 
     222    $iconSp = fixImageTag( $iconSp, $width, $height ); 
     223    $iconT = "dot_udr.gif" unless ($iconT); 
     224    $iconT = fixImageTag( $iconT, $width, $height ); 
     225    $iconI = "dot_ud.gif" unless ($iconI); 
     226    $iconI = fixImageTag( $iconI, $width, $height ); 
     227    $iconL = "dot_ur.gif" unless ($iconL); 
     228    $iconL = fixImageTag( $iconL, $width, $height ); 
     229    $iconImg = "home.gif" unless ($iconImg); 
    212230    $iconImg = fixImageTag( $iconImg, $width, $height ); 
    213231 
    214232    $text = ""; 
    215233    my $start = 0; 
    216     $start = 1 unless( $showLead ); 
     234    $start = 1 unless ($showLead); 
    217235    my @listIcon = (); 
    218     for( my $i = 0; $i < scalar( @tree ); $i++ ) { 
    219         $text .= '<table border="0" cellspacing="0" cellpadding="0"><tr>' . "\n"; 
     236    for ( my $i = 0 ; $i < scalar(@tree) ; $i++ ) { 
     237        $text .= 
     238          '<table border="0" cellspacing="0" cellpadding="0"><tr>' . "\n"; 
    220239        $level = $tree[$i]->{'level'}; 
    221         for( my $l = $start; $l < $level; $l++ ) { 
    222             if( $l == $level - 1 ) { 
     240        for ( my $l = $start ; $l < $level ; $l++ ) { 
     241            if ( $l == $level - 1 ) { 
    223242                $listIcon[$l] = $iconSp; 
    224                 for( my $x = $i + 1; $x < scalar( @tree ); $x++ ) { 
    225                    last if( $tree[$x]->{'level'} < $level ); 
    226                    if( $tree[$x]->{'level'} <= $level && $tree[$x]->{'type'} ne " " ) { 
    227                        $listIcon[$l] = $iconI; 
    228                        last; 
    229                    } 
     243                for ( my $x = $i + 1 ; $x < scalar(@tree) ; $x++ ) { 
     244                    last if ( $tree[$x]->{'level'} < $level ); 
     245                    if (   $tree[$x]->{'level'} <= $level 
     246                        && $tree[$x]->{'type'} ne " " ) 
     247                    { 
     248                        $listIcon[$l] = $iconI; 
     249                        last; 
     250                    } 
    230251                } 
    231                 if( $tree[$i]->{'type'} eq " " ) { 
    232                    $text .= "<td valign=\"top\">$listIcon[$l]</td>\n"; 
    233                 } elsif( $listIcon[$l] eq $iconSp ) { 
    234                    $text .= "<td valign=\"top\">$iconL</td>\n"; 
    235                 } else { 
    236                    $text .= "<td valign=\"top\">$iconT</td>\n"; 
     252                if ( $tree[$i]->{'type'} eq " " ) { 
     253                    $text .= "<td valign=\"top\">$listIcon[$l]</td>\n"; 
    237254                } 
    238             } else { 
    239                 $text .= "<td valign=\"top\">" . ($listIcon[$l] || '') . "</td>\n"; 
    240             } 
    241         } 
    242         if( $theType eq "icon" ) { 
     255                elsif ( $listIcon[$l] eq $iconSp ) { 
     256                    $text .= "<td valign=\"top\">$iconL</td>\n"; 
     257                } 
     258                else { 
     259                    $text .= "<td valign=\"top\">$iconT</td>\n"; 
     260                } 
     261            } 
     262            else { 
     263                $text .= 
     264                  "<td valign=\"top\">" . ( $listIcon[$l] || '' ) . "</td>\n"; 
     265            } 
     266        } 
     267        if ( $theType eq "icon" ) { 
     268 
    243269            # icon theme type 
    244             if( $tree[$i]->{'type'} eq " " ) { 
     270            if ( $tree[$i]->{'type'} eq " " ) { 
     271 
    245272                # continuation line 
    246273                $text .= "<td valign=\"top\">$iconSp</td>\n"; 
    247             } elsif( $tree[$i]->{'text'} =~ /^\s*(<b>)?\s*((icon\:)?<img[^>]+>|icon\:[^\s]+)\s*(.*)/ ) { 
     274            } 
     275            elsif ( $tree[$i]->{'text'} =~ 
     276                /^\s*(<b>)?\s*((icon\:)?<img[^>]+>|icon\:[^\s]+)\s*(.*)/ ) 
     277            { 
     278 
    248279                # specific icon 
    249280                $tree[$i]->{'text'} = $4; 
    250                 $tree[$i]->{'text'} = "$1 $4" if( $1 ); 
     281                $tree[$i]->{'text'} = "$1 $4" if ($1); 
    251282                my $icon = $2; 
    252283                $icon =~ s/^icon\://o; 
    253284                $icon = fixImageTag( $icon, $width, $height ); 
    254285                $text .= "<td valign=\"top\">$icon</td>\n"; 
    255             } else { 
     286            } 
     287            else { 
     288 
    256289                # default icon 
    257290                $text .= "<td valign=\"top\">$iconImg</td>\n"; 
    258291            } 
    259             $text .= "<td valign=\"top\"><nobr>&nbsp; $tree[$i]->{'text'} </nobr></td>\n"; 
    260  
    261         } else { 
     292            $text .= 
     293"<td valign=\"top\"><nobr>&nbsp; $tree[$i]->{'text'} </nobr></td>\n"; 
     294 
     295        } 
     296        else { 
     297 
    262298            # tree theme type 
    263             if( $tree[$i]->{'text'} =~ /^\s*(<b>)?\s*((icon\:)?<img[^>]+>|icon\:[^\s]+)\s*(.*)/ ) { 
     299            if ( $tree[$i]->{'text'} =~ 
     300                /^\s*(<b>)?\s*((icon\:)?<img[^>]+>|icon\:[^\s]+)\s*(.*)/ ) 
     301            { 
     302 
    264303                # specific icon 
    265304                $tree[$i]->{'text'} = $4; 
    266                 $tree[$i]->{'text'} = "$1 $4" if( $1 ); 
     305                $tree[$i]->{'text'} = "$1 $4" if ($1); 
    267306                my $icon = $2; 
    268307                $icon =~ s/^icon\://o; 
    269308                $icon = fixImageTag( $icon, $width, $height ); 
    270309                $text .= "<td valign=\"top\">$icon</td>\n"; 
    271                 $text .= "<td valign=\"top\"><nobr>&nbsp; $tree[$i]->{'text'} </nobr></td>\n"; 
    272             } else { 
    273                 $text .= "<td valign=\"top\"><nobr> $tree[$i]->{'text'} </nobr></td>\n"; 
     310                $text .= 
     311"<td valign=\"top\"><nobr>&nbsp; $tree[$i]->{'text'} </nobr></td>\n"; 
     312            } 
     313            else { 
     314                $text .= 
     315"<td valign=\"top\"><nobr> $tree[$i]->{'text'} </nobr></td>\n"; 
    274316            } 
    275317        } 
     
    280322 
    281323# ========================= 
    282 sub fixImageTag 
    283 { 
     324sub fixImageTag { 
    284325    my ( $theIcon, $theWidth, $theHeight ) = @_; 
    285326 
    286     if( $theIcon !~ /^<img/i ) { 
    287         $theIcon .= '.gif' if( $theIcon !~ /\.(png|gif|jpeg|jpg)$/i ); 
    288         $theIcon = "$attachUrl/$theIcon" if( $theIcon !~ /^(\/|https?\:)/ ); 
    289         $theIcon = "<img src=\"$theIcon\" width=\"$theWidth\" height=\"$theHeight\"" 
    290                  . " alt=\"\" border=\"0\" />"; 
     327    if ( $theIcon !~ /^<img/i ) { 
     328        $theIcon .= '.gif' if ( $theIcon !~ /\.(png|gif|jpeg|jpg)$/i ); 
     329        $theIcon = "$attachUrl/$theIcon" if ( $theIcon !~ /^(\/|https?\:)/ ); 
     330        $theIcon = 
     331            "<img src=\"$theIcon\" width=\"$theWidth\" height=\"$theHeight\"" 
     332          . " alt=\"\" border=\"0\" />"; 
    291333    } 
    292334    return $theIcon; 
  • trunk/SlideShowPlugin/lib/Foswiki/Plugins/SlideShowPlugin.pm

    r3944 r3947  
    2929our $VERSION = '$Rev$'; 
    3030our $RELEASE = '31 Mar 2009'; 
    31 our $SHORTDESCRIPTION = 'Create web based presentations based on topics with headings'; 
     31our $SHORTDESCRIPTION = 
     32  'Create web based presentations based on topics with headings'; 
    3233our $NO_PREFS_IN_TOPIC = 1; 
    3334 
  • trunk/SmiliesPlugin/lib/Foswiki/Plugins/SmiliesPlugin.pm

    r3447 r3947  
    3030  $smiliesPubUrl $allPattern $smiliesFormat ); 
    3131 
    32 our $VERSION = '$Rev$'; 
    33 our $RELEASE = '03 Apr 2009'; 
     32our $VERSION           = '$Rev$'; 
     33our $RELEASE           = '03 Apr 2009'; 
    3434our $NO_PREFS_IN_TOPIC = 1; 
    35 our $SHORTDESCRIPTION = 'Render smilies like :-) as icons'; 
     35our $SHORTDESCRIPTION  = 'Render smilies like :-) as icons'; 
    3636 
    3737sub initPlugin { 
  • trunk/SpreadSheetPlugin/lib/Foswiki/Plugins/SpreadSheetPlugin.pm

    r3944 r3947  
    2727use strict; 
    2828 
    29  
    3029# ========================= 
    3130use vars qw( 
    32         $web $topic $user $installWeb $debug $skipInclude $doInit 
    33     ); 
     31  $web $topic $user $installWeb $debug $skipInclude $doInit 
     32); 
    3433 
    35 our $VERSION = '$Rev: 13748 $'; 
    36 our $RELEASE = '11 May 2009'; 
     34our $VERSION           = '$Rev: 13748 $'; 
     35our $RELEASE           = '11 May 2009'; 
    3736our $NO_PREFS_IN_TOPIC = 1; 
    38 our $SHORTDESCRIPTION = 'Add spreadsheet calculations like "$SUM($ABOVE())" to Foswiki tables and other topic text'; 
     37our $SHORTDESCRIPTION = 
     38'Add spreadsheet calculations like "$SUM($ABOVE())" to Foswiki tables and other topic text'; 
    3939 
    4040$doInit = 0; 
    4141 
    4242# ========================= 
    43 sub initPlugin 
    44 { 
     43sub initPlugin { 
    4544    ( $topic, $web, $user, $installWeb ) = @_; 
    4645 
    4746    # check for Plugins.pm versions 
    48     if( $Foswiki::Plugins::VERSION < 1 ) { 
    49         Foswiki::Func::writeWarning( "Version mismatch between SpreadSheetPlugin and Plugins.pm" ); 
     47    if ( $Foswiki::Plugins::VERSION < 1 ) { 
     48        Foswiki::Func::writeWarning( 
     49            "Version mismatch between SpreadSheetPlugin and Plugins.pm"); 
    5050        return 0; 
    5151    } 
    5252 
    5353    # Get plugin debug flag 
    54     $debug = Foswiki::Func::getPreferencesFlag( "SPREADSHEETPLUGIN_DEBUG" ) || 0; 
     54    $debug = Foswiki::Func::getPreferencesFlag("SPREADSHEETPLUGIN_DEBUG") || 0; 
    5555 
    5656    # Flag to skip calc if in include 
    57     $skipInclude = Foswiki::Func::getPreferencesFlag( "SPREADSHEETPLUGIN_SKIPINCLUDE" ) || 1; 
     57    $skipInclude = 
     58      Foswiki::Func::getPreferencesFlag("SPREADSHEETPLUGIN_SKIPINCLUDE") || 1; 
    5859 
    5960    # Plugin correctly initialized 
    60     Foswiki::Func::writeDebug( "- Foswiki::Plugins::SpreadSheetPlugin::initPlugin( $web.$topic ) is OK" ) if $debug; 
     61    Foswiki::Func::writeDebug( 
     62        "- Foswiki::Plugins::SpreadSheetPlugin::initPlugin( $web.$topic ) is OK" 
     63    ) if $debug; 
    6164    $doInit = 1; 
    6265    return 1; 
     
    6467 
    6568# ========================= 
    66 sub commonTagsHandler 
    67 { 
     69sub commonTagsHandler { 
    6870### my ( $text, $topic, $web ) = @_;   # do not uncomment, use $_[0], $_[1]... instead 
    6971 
    70     Foswiki::Func::writeDebug( "- SpreadSheetPlugin::commonTagsHandler( $_[2].$_[1] )" ) if $debug; 
     72    Foswiki::Func::writeDebug( 
     73        "- SpreadSheetPlugin::commonTagsHandler( $_[2].$_[1] )") 
     74      if $debug; 
    7175 
    72     if( ( $_[3] ) && ( $skipInclude ) ) { 
     76    if ( ( $_[3] ) && ($skipInclude) ) { 
     77 
    7378        # bail out, handler called from an %INCLUDE{}% 
    7479        return; 
    7580    } 
    76     unless( $_[0] =~ /%CALC\{.*?\}%/ ) { 
     81    unless ( $_[0] =~ /%CALC\{.*?\}%/ ) { 
     82 
    7783        # nothing to do 
    7884        return; 
     
    8187    require Foswiki::Plugins::SpreadSheetPlugin::Calc; 
    8288 
    83     if( $doInit ) { 
     89    if ($doInit) { 
    8490        $doInit = 0; 
    8591        Foswiki::Plugins::SpreadSheetPlugin::Calc::init( $web, $topic, $debug ); 
    8692    } 
    87     Foswiki::Plugins::SpreadSheetPlugin::Calc::CALC( @_ ); 
     93    Foswiki::Plugins::SpreadSheetPlugin::Calc::CALC(@_); 
    8894} 
    8995 
  • trunk/SpreadSheetPlugin/lib/Foswiki/Plugins/SpreadSheetPlugin/Calc.pm

    r3887 r3947  
    3131use Time::Local; 
    3232 
    33  
    3433# ========================= 
    3534use vars qw( 
    36         $web $topic $debug $dontSpaceRE 
    37         $renderingWeb @tableMatrix $cPos $rPos $escToken 
    38         %varStore @monArr @wdayArr %mon2num 
    39     ); 
    40  
    41 $escToken = "\0"; 
    42 %varStore = (); 
     35  $web $topic $debug $dontSpaceRE 
     36  $renderingWeb @tableMatrix $cPos $rPos $escToken 
     37  %varStore @monArr @wdayArr %mon2num 
     38); 
     39 
     40$escToken    = "\0"; 
     41%varStore    = (); 
    4342$dontSpaceRE = ""; 
    44 @monArr = ( "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ); 
    45 @wdayArr = ( "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ); 
    46 { my $count = 0; 
    47   %mon2num = map { $_ => $count++ } @monArr; 
    48 } 
    49  
    50  
    51 # ========================= 
    52 sub init 
     43@monArr      = ( 
     44    "Jan", "Feb", "Mar", "Apr", "May", "Jun", 
     45    "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" 
     46); 
     47@wdayArr = ( 
     48    "Sunday",   "Monday", "Tuesday", "Wednesday", 
     49    "Thursday", "Friday", "Saturday" 
     50); 
    5351{ 
     52    my $count = 0; 
     53    %mon2num = map { $_ => $count++ } @monArr; 
     54} 
     55 
     56# ========================= 
     57sub init { 
    5458    ( $web, $topic, $debug ) = @_; 
    5559 
    5660    # initialize variables, once per page view 
    57     %varStore = (); 
     61    %varStore    = (); 
    5862    $dontSpaceRE = ""; 
    5963 
    6064    # Module initialized 
    61     Foswiki::Func::writeDebug( "- Foswiki::Plugins::SpreadSheetPlugin::Calc::init( $web.$topic )" ) if $debug; 
     65    Foswiki::Func::writeDebug( 
     66        "- Foswiki::Plugins::SpreadSheetPlugin::Calc::init( $web.$topic )") 
     67      if $debug; 
    6268    return 1; 
    6369} 
    6470 
    6571# ========================= 
    66 sub CALC 
    67 { 
     72sub CALC { 
    6873### my ( $text, $topic, $web ) = @_;   # do not uncomment, use $_[0], $_[1]... instead 
    6974 
    70     Foswiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::CALC( $_[2].$_[1] )" ) if $debug; 
     75    Foswiki::Func::writeDebug("- SpreadSheetPlugin::Calc::CALC( $_[2].$_[1] )") 
     76      if $debug; 
    7177 
    7278    @tableMatrix = (); 
    73     $cPos = -1; 
    74     $rPos = -1; 
    75     $web = $_[2]; 
    76  
    77     my @result = (); 
    78     my $insidePRE = 0; 
     79    $cPos        = -1; 
     80    $rPos        = -1; 
     81    $web         = $_[2]; 
     82 
     83    my @result      = (); 
     84    my $insidePRE   = 0; 
    7985    my $insideTABLE = 0; 
    80     my $line = ""; 
    81     my $before = ""; 
    82     my $cell = ""; 
    83     my @row = (); 
     86    my $line        = ""; 
     87    my $before      = ""; 
     88    my $cell        = ""; 
     89    my @row         = (); 
    8490 
    8591    $_[0] =~ s/\r//go; 
    86     $_[0] =~ s/\\\n//go;  # Join lines ending in "\" 
    87     foreach( split( /\n/, $_[0] ) ) { 
     92    $_[0] =~ s/\\\n//go;    # Join lines ending in "\" 
     93    foreach ( split( /\n/, $_[0] ) ) { 
    8894 
    8995        # change state: 
     
    9399        m|</verbatim>|i && ( $insidePRE = 0 ); 
    94100 
    95         if( ! ( $insidePRE ) ) { 
    96  
    97             if( /^\s*\|.*\|\s*$/ ) { 
     101        if ( !($insidePRE) ) { 
     102 
     103            if (/^\s*\|.*\|\s*$/) { 
     104 
    98105                # inside | table | 
    99                 if( ! $insideTABLE ) { 
     106                if ( !$insideTABLE ) { 
    100107                    $insideTABLE = 1; 
    101                     @tableMatrix = ();  # reset table matrix 
    102                     $cPos = -1; 
    103                     $rPos = -1; 
     108                    @tableMatrix = ();    # reset table matrix 
     109                    $cPos        = -1; 
     110                    $rPos        = -1; 
    104111                } 
    105112                $line = $_; 
    106113                $line =~ s/^(\s*\|)(.*)\|\s*$/$2/o; 
    107114                $before = $1; 
    108                 @row  = split( /\|/o, $line, -1 ); 
    109                 push( @tableMatrix, [ @row ] ); 
     115                @row = split( /\|/o, $line, -1 ); 
     116                push( @tableMatrix, [@row] ); 
    110117                $rPos++; 
    111118                $line = "$before"; 
    112                 for( $cPos = 0; $cPos < @row; $cPos++ ) { 
     119 
     120                for ( $cPos = 0 ; $cPos < @row ; $cPos++ ) { 
    113121                    $cell = $row[$cPos]; 
    114122                    $cell =~ s/%CALC\{(.*?)\}%/&doCalc($1)/geo; 
     
    117125                s/.*/$line/o; 
    118126 
    119             } else { 
     127            } 
     128            else { 
     129 
    120130                # outside | table | 
    121                 if( $insideTABLE ) { 
     131                if ($insideTABLE) { 
    122132                    $insideTABLE = 0; 
    123133                } 
     
    131141 
    132142# ========================= 
    133 sub doCalc 
    134 { 
    135     my( $theAttributes ) = @_; 
    136     my $text = &Foswiki::Func::extractNameValuePair( $theAttributes ); 
     143sub doCalc { 
     144    my ($theAttributes) = @_; 
     145    my $text = &Foswiki::Func::extractNameValuePair($theAttributes); 
    137146 
    138147    # Add nesting level to parenthesis, 
     
    142151    $text = doFunc( "MAIN", $text ); 
    143152 
    144     if( ( $rPos >= 0 ) && ( $cPos >= 0 ) ) { 
     153    if ( ( $rPos >= 0 ) && ( $cPos >= 0 ) ) { 
     154 
    145155        # update cell in table matrix 
    146156        $tableMatrix[$rPos][$cPos] = $text; 
     
    151161 
    152162# ========================= 
    153 sub addNestingLevel 
    154 { 
    155   my( $theParen, $theLevelRef ) = @_; 
    156  
    157   my $result = ""; 
    158   if( $theParen eq "(" ) { 
    159     $$theLevelRef++; 
    160     $result = "$escToken$$theLevelRef$theParen"; 
    161   } else { 
    162     $result = "$escToken$$theLevelRef$theParen"; 
    163     $$theLevelRef--; 
    164   } 
    165   return $result; 
    166 } 
    167  
    168 # ========================= 
    169 sub doFunc 
    170 { 
    171     my( $theFunc, $theAttr ) = @_; 
    172  
    173     $theAttr = "" unless( defined $theAttr ); 
    174     Foswiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::doFunc: $theFunc( $theAttr ) start" ) if $debug; 
    175  
    176     unless( $theFunc =~ /^(IF|LISTIF|LISTMAP|NOEXEC)$/ ) { 
     163sub addNestingLevel { 
     164    my ( $theParen, $theLevelRef ) = @_; 
     165 
     166    my $result = ""; 
     167    if ( $theParen eq "(" ) { 
     168        $$theLevelRef++; 
     169        $result = "$escToken$$theLevelRef$theParen"; 
     170    } 
     171    else { 
     172        $result = "$escToken$$theLevelRef$theParen"; 
     173        $$theLevelRef--; 
     174    } 
     175    return $result; 
     176} 
     177 
     178# ========================= 
     179sub doFunc { 
     180    my ( $theFunc, $theAttr ) = @_; 
     181 
     182    $theAttr = "" unless ( defined $theAttr ); 
     183    Foswiki::Func::writeDebug( 
     184        "- SpreadSheetPlugin::Calc::doFunc: $theFunc( $theAttr ) start") 
     185      if $debug; 
     186 
     187    unless ( $theFunc =~ /^(IF|LISTIF|LISTMAP|NOEXEC)$/ ) { 
     188 
    177189        # Handle functions recursively 
    178         $theAttr =~ s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 
     190        $theAttr =~ 
     191          s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 
     192 
    179193        # Clean up unbalanced mess 
    180194        $theAttr =~ s/$escToken\-*[0-9]+([\(\)])/$1/go; 
    181195    } 
     196 
    182197    # else: delay the function handler to after parsing the parameters, 
    183198    # in which case handling functions and cleaning up needs to be done later 
    184199 
    185200    my $result = ""; 
    186     my $i = 0; 
    187     if( $theFunc eq "MAIN" ) { 
     201    my $i      = 0; 
     202    if ( $theFunc eq "MAIN" ) { 
    188203        $result = $theAttr; 
    189204 
    190     } elsif( $theFunc eq "EXEC" ) { 
     205    } 
     206    elsif ( $theFunc eq "EXEC" ) { 
     207 
    191208        # add nesting level escapes 
    192209        my $level = 0; 
    193210        $result = $theAttr; 
    194211        $result =~ s/([\(\)])/addNestingLevel($1, \$level)/geo; 
    195         # execute functions in attribute recursively and clean up unbalanced parenthesis 
    196         $result =~ s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 
     212 
     213# execute functions in attribute recursively and clean up unbalanced parenthesis 
     214        $result =~ 
     215          s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 
    197216        $result =~ s/$escToken\-*[0-9]+([\(\)])/$1/go; 
    198217 
    199     } elsif( $theFunc eq "NOEXEC" ) { 
     218    } 
     219    elsif ( $theFunc eq "NOEXEC" ) { 
    200220        $result = $theAttr; 
    201221 
    202     } elsif( $theFunc eq "T" ) { 
     222    } 
     223    elsif ( $theFunc eq "T" ) { 
    203224        $result = ""; 
    204         my @arr = getTableRange( "$theAttr..$theAttr" ); 
    205         if( @arr ) { 
     225        my @arr = getTableRange("$theAttr..$theAttr"); 
     226        if (@arr) { 
    206227            $result = $arr[0]; 
    207228        } 
    208229 
    209     } elsif( $theFunc eq "TRIM" ) { 
     230    } 
     231    elsif ( $theFunc eq "TRIM" ) { 
    210232        $result = $theAttr || ""; 
    211233        $result =~ s/^\s*//o; 
     
    213235        $result =~ s/\s+/ /go; 
    214236 
    215     } elsif( $theFunc eq "FORMAT" ) { 
    216         # Format FORMAT(TYPE, precision, value) returns formatted value -- JimStraus - 05 Jan 2003 
    217         my( $format, $res, $value )  = split( /,\s*/, $theAttr ); 
    218         $format =~ s/^\s*(.*?)\s*$/$1/; #Strip leading and trailing spaces 
    219         $res =~ s/^\s*(.*?)\s*$/$1/; 
    220         $value =~ s/^\s*(.*?)\s*$/$1/; 
    221         if( $format eq "DOLLAR" ) { 
     237    } 
     238    elsif ( $theFunc eq "FORMAT" ) { 
     239 
     240# Format FORMAT(TYPE, precision, value) returns formatted value -- JimStraus - 05 Jan 2003 
     241        my ( $format, $res, $value ) = split( /,\s*/, $theAttr ); 
     242        $format =~ s/^\s*(.*?)\s*$/$1/;    #Strip leading and trailing spaces 
     243        $res    =~ s/^\s*(.*?)\s*$/$1/; 
     244        $value  =~ s/^\s*(.*?)\s*$/$1/; 
     245        if ( $format eq "DOLLAR" ) { 
    222246            my $neg = 1 if $value < 0; 
    223247            $value = abs($value); 
    224             $result = sprintf("%0.${res}f", $value); 
     248            $result = sprintf( "%0.${res}f", $value ); 
    225249            my $temp = reverse $result; 
    226250            $temp =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; 
    227             $result = "\$" . (scalar reverse $temp); 
    228             $result = "(".$result.")" if $neg; 
    229         } elsif( $format eq "COMMA" ) { 
    230             $result = sprintf("%0.${res}f", $value); 
     251            $result = "\$" . ( scalar reverse $temp ); 
     252            $result = "(" . $result . ")" if $neg; 
     253        } 
     254        elsif ( $format eq "COMMA" ) { 
     255            $result = sprintf( "%0.${res}f", $value ); 
    231256            my $temp = reverse $result; 
    232257            $temp =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; 
    233258            $result = scalar reverse $temp; 
    234         } elsif( $format eq "PERCENT" ) { 
    235             $result = sprintf("%0.${res}f%%", $value * 100); 
    236         } elsif( $format eq "NUMBER" ) { 
    237             $result = sprintf("%0.${res}f", $value); 
    238         } elsif( $format eq "K" ) { 
    239             $result = sprintf("%0.${res}f K", $value / 1024); 
    240         } elsif( $format eq "KB" ) { 
    241             $result = sprintf("%0.${res}f KB", $value / 1024); 
    242         } elsif ($format eq "MB") { 
    243             $result = sprintf("%0.${res}f MB", $value / (1024 * 1024)); 
    244         } elsif( $format =~ /^KBMB/ ) { 
     259        } 
     260        elsif ( $format eq "PERCENT" ) { 
     261            $result = sprintf( "%0.${res}f%%", $value * 100 ); 
     262        } 
     263        elsif ( $format eq "NUMBER" ) { 
     264            $result = sprintf( "%0.${res}f", $value ); 
     265        } 
     266        elsif ( $format eq "K" ) { 
     267            $result = sprintf( "%0.${res}f K", $value / 1024 ); 
     268        } 
     269        elsif ( $format eq "KB" ) { 
     270            $result = sprintf( "%0.${res}f KB", $value / 1024 ); 
     271        } 
     272        elsif ( $format eq "MB" ) { 
     273            $result = sprintf( "%0.${res}f MB", $value / ( 1024 * 1024 ) ); 
     274        } 
     275        elsif ( $format =~ /^KBMB/ ) { 
    245276            $value /= 1024; 
    246277            my @lbls = ( "MB", "GB", "TB", "PB", "EB", "ZB" ); 
    247278            my $lbl = "KB"; 
    248             while( $value >= 1024 && @lbls ) { 
     279            while ( $value >= 1024 && @lbls ) { 
    249280                $value /= 1024; 
    250281                $lbl = shift @lbls; 
    251282            } 
    252             $result = sprintf("%0.${res}f", $value) . " $lbl"; 
    253         } else { 
     283            $result = sprintf( "%0.${res}f", $value ) . " $lbl"; 
     284        } 
     285        else { 
     286 
    254287            # FORMAT not recognized, just return value 
    255288            $result = $value; 
    256289        } 
    257290 
    258     } elsif( $theFunc eq "EMPTY" ) { 
     291    } 
     292    elsif ( $theFunc eq "EMPTY" ) { 
    259293        $result = 1; 
    260         $result = 0 if( length( $theAttr ) > 0 ); 
    261  
    262     } elsif( $theFunc eq "EXACT" ) { 
     294        $result = 0 if ( length($theAttr) > 0 ); 
     295 
     296    } 
     297    elsif ( $theFunc eq "EXACT" ) { 
    263298        $result = 0; 
    264         my( $str1, $str2 ) = split( /,\s*/, $theAttr, 2 ); 
    265         $str1 = "" unless( $str1 ); 
    266         $str2 = "" unless( $str2 ); 
    267         $str1 =~ s/^\s*(.*?)\s*$/$1/o; # cut leading and trailing spaces 
     299        my ( $str1, $str2 ) = split( /,\s*/, $theAttr, 2 ); 
     300        $str1 = "" unless ($str1); 
     301        $str2 = "" unless ($str2); 
     302        $str1 =~ s/^\s*(.*?)\s*$/$1/o;    # cut leading and trailing spaces 
    268303        $str2 =~ s/^\s*(.*?)\s*$/$1/o; 
    269         $result = 1 if( $str1 eq $str2 ); 
    270  
    271     } elsif( $theFunc eq "RAND" ) { 
    272         my $max = _getNumber( $theAttr ); 
    273         $max = 1 if( $max <= 0 ); 
    274         $result = rand( $max ); 
    275  
    276     } elsif( $theFunc eq "VALUE" ) { 
    277         $result = _getNumber( $theAttr ); 
    278  
    279     } elsif( $theFunc =~ /^(EVAL|INT)$/ ) { 
    280         $result = safeEvalPerl( $theAttr ); 
    281         unless( $result =~ /^ERROR/ ) { 
    282             $result = int( _getNumber( $result ) ) if( $theFunc eq "INT" ); 
    283         } 
    284  
    285     } elsif( $theFunc eq "ROUND" ) { 
     304        $result = 1 if ( $str1 eq $str2 ); 
     305 
     306    } 
     307    elsif ( $theFunc eq "RAND" ) { 
     308        my $max = _getNumber($theAttr); 
     309        $max = 1 if ( $max <= 0 ); 
     310        $result = rand($max); 
     311 
     312    } 
     313    elsif ( $theFunc eq "VALUE" ) { 
     314        $result = _getNumber($theAttr); 
     315 
     316    } 
     317    elsif ( $theFunc =~ /^(EVAL|INT)$/ ) { 
     318        $result = safeEvalPerl($theAttr); 
     319        unless ( $result =~ /^ERROR/ ) { 
     320            $result = int( _getNumber($result) ) if ( $theFunc eq "INT" ); 
     321        } 
     322 
     323    } 
     324    elsif ( $theFunc eq "ROUND" ) { 
     325 
    286326        # ROUND(num, digits) 
    287         my( $num, $digits ) = split( /,\s*/, $theAttr, 2 ); 
    288         $result = safeEvalPerl( $num ); 
    289         unless( $result =~ /^ERROR/ ) { 
    290             $result = _getNumber( $result ); 
    291             if( ( $digits ) && ( $digits =~ s/^.*?(\-?[0-9]+).*$/$1/o ) && ( $digits ) ) { 
     327        my ( $num, $digits ) = split( /,\s*/, $theAttr, 2 ); 
     328        $result = safeEvalPerl($num); 
     329        unless ( $result =~ /^ERROR/ ) { 
     330            $result = _getNumber($result); 
     331            if (   ($digits) 
     332                && ( $digits =~ s/^.*?(\-?[0-9]+).*$/$1/o ) 
     333                && ($digits) ) 
     334            { 
    292335                my $factor = 10**$digits; 
    293336                $result *= $factor; 
    294337                ( $result >= 0 ) ? ( $result += 0.5 ) : ( $result -= 0.5 ); 
    295                 $result = int( $result ); 
     338                $result = int($result); 
    296339                $result /= $factor; 
    297             } else { 
     340            } 
     341            else { 
    298342                ( $result >= 0 ) ? ( $result += 0.5 ) : ( $result -= 0.5 ); 
    299                 $result = int( $result ); 
    300             } 
    301         } 
    302  
    303     } elsif( $theFunc eq "MOD" ) { 
     343                $result = int($result); 
     344            } 
     345        } 
     346 
     347    } 
     348    elsif ( $theFunc eq "MOD" ) { 
    304349        $result = 0; 
    305         my( $num1, $num2 ) = split( /,\s*/, $theAttr, 2 ); 
    306         $num1 = _getNumber( $num1 ); 
    307         $num2 = _getNumber( $num2 ); 
    308         if( $num1 && $num2 ) { 
     350        my ( $num1, $num2 ) = split( /,\s*/, $theAttr, 2 ); 
     351        $num1 = _getNumber($num1); 
     352        $num2 = _getNumber($num2); 
     353        if ( $num1 && $num2 ) { 
    309354            $result = $num1 % $num2; 
    310355        } 
    311356 
    312     } elsif( $theFunc eq "ODD" ) { 
    313         $result = _getNumber( $theAttr ) % 2; 
    314  
    315     } elsif( $theFunc eq "EVEN" ) { 
    316         $result = ( _getNumber( $theAttr ) + 1 ) % 2; 
    317  
    318     } elsif( $theFunc eq "AND" ) { 
     357    } 
     358    elsif ( $theFunc eq "ODD" ) { 
     359        $result = _getNumber($theAttr) % 2; 
     360 
     361    } 
     362    elsif ( $theFunc eq "EVEN" ) { 
     363        $result = ( _getNumber($theAttr) + 1 ) % 2; 
     364 
     365    } 
     366    elsif ( $theFunc eq "AND" ) { 
    319367        $result = 0; 
    320         my @arr = getListAsInteger( $theAttr ); 
    321         foreach $i( @arr ) { 
    322             unless( $i ) { 
     368        my @arr = getListAsInteger($theAttr); 
     369        foreach $i (@arr) { 
     370            unless ($i) { 
    323371                $result = 0; 
    324372                last; 
     
    327375        } 
    328376 
    329     } elsif( $theFunc eq "OR" ) { 
     377    } 
     378    elsif ( $theFunc eq "OR" ) { 
    330379        $result = 0; 
    331         my @arr = getListAsInteger( $theAttr ); 
    332         foreach $i( @arr ) { 
    333             if( $i ) { 
     380        my @arr = getListAsInteger($theAttr); 
     381        foreach $i (@arr) { 
     382            if ($i) { 
    334383                $result = 1; 
    335384                last; 
     
    337386        } 
    338387 
    339     } elsif( $theFunc eq "NOT" ) { 
     388    } 
     389    elsif ( $theFunc eq "NOT" ) { 
    340390        $result = 1; 
    341         $result = 0 if( _getNumber( $theAttr ) ); 
    342  
    343     } elsif( $theFunc eq "ABS" ) { 
    344         $result = abs( _getNumber( $theAttr ) ); 
    345  
    346     } elsif( $theFunc eq "SIGN" ) { 
    347         $i = _getNumber( $theAttr ); 
    348         $result =  0; 
    349         $result =  1 if( $i > 0 ); 
    350         $result = -1 if( $i < 0 ); 
    351  
    352     } elsif( $theFunc eq "LN" ) { 
    353         $result = log(_getNumber( $theAttr ) ); 
    354  
    355     } elsif( $theFunc eq "LOG" ) { 
    356         my( $num, $base ) = split( /,\s*/, $theAttr, 2 ); 
    357         $num = _getNumber( $num ); 
    358         $base = _getNumber( $base ); 
    359         $base = 10 if( $base <= 0 ); 
    360         $result = log( $num ) / log( $base ); 
    361  
    362     } elsif( $theFunc eq "EXP" ) { 
    363         $result = exp( _getNumber( $theAttr ) ); 
    364  
    365     } elsif( $theFunc eq "PI" ) { 
     391        $result = 0 if ( _getNumber($theAttr) ); 
     392 
     393    } 
     394    elsif ( $theFunc eq "ABS" ) { 
     395        $result = abs( _getNumber($theAttr) ); 
     396 
     397    } 
     398    elsif ( $theFunc eq "SIGN" ) { 
     399        $i      = _getNumber($theAttr); 
     400        $result = 0; 
     401        $result = 1 if ( $i > 0 ); 
     402        $result = -1 if ( $i < 0 ); 
     403 
     404    } 
     405    elsif ( $theFunc eq "LN" ) { 
     406        $result = log( _getNumber($theAttr) ); 
     407 
     408    } 
     409    elsif ( $theFunc eq "LOG" ) { 
     410        my ( $num, $base ) = split( /,\s*/, $theAttr, 2 ); 
     411        $num    = _getNumber($num); 
     412        $base   = _getNumber($base); 
     413        $base   = 10 if ( $base <= 0 ); 
     414        $result = log($num) / log($base); 
     415 
     416    } 
     417    elsif ( $theFunc eq "EXP" ) { 
     418        $result = exp( _getNumber($theAttr) ); 
     419 
     420    } 
     421    elsif ( $theFunc eq "PI" ) { 
    366422        $result = 3.1415926535897932384; 
    367423 
    368     } elsif( $theFunc eq "SQRT" ) { 
    369         $result = sqrt( _getNumber( $theAttr ) ); 
    370  
    371     } elsif( $theFunc eq "IF" ) { 
     424    } 
     425    elsif ( $theFunc eq "SQRT" ) { 
     426        $result = sqrt( _getNumber($theAttr) ); 
     427 
     428    } 
     429    elsif ( $theFunc eq "IF" ) { 
     430 
    372431        # IF(condition, value if true, value if false) 
    373         my( $condition, $str1, $str2 ) = _properSplit( $theAttr, 3 ); 
    374         # with delay, handle functions in condition recursively and clean up unbalanced parenthesis 
    375         $condition =~ s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 
     432        my ( $condition, $str1, $str2 ) = _properSplit( $theAttr, 3 ); 
     433 
     434# with delay, handle functions in condition recursively and clean up unbalanced parenthesis 
     435        $condition =~ 
     436          s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 
    376437        $condition =~ s/$escToken\-*[0-9]+([\(\)])/$1/go; 
    377438        $condition =~ s/^\s*(.*?)\s*$/$1/o; 
    378         $result = safeEvalPerl( $condition ); 
    379         unless( $result =~ /^ERROR/ ) { 
    380             if( $result ) { 
     439        $result = safeEvalPerl($condition); 
     440        unless ( $result =~ /^ERROR/ ) { 
     441            if ($result) { 
    381442                $result = $str1; 
    382             } else { 
     443            } 
     444            else { 
    383445                $result = $str2; 
    384446            } 
    385             $result = "" unless( defined( $result ) ); 
    386             # with delay, handle functions in result recursively and clean up unbalanced parenthesis 
    387             $result =~ s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 
     447            $result = "" unless ( defined($result) ); 
     448 
     449# with delay, handle functions in result recursively and clean up unbalanced parenthesis 
     450            $result =~ 
     451s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 
    388452            $result =~ s/$escToken\-*[0-9]+([\(\)])/$1/go; 
    389453 
    390         } # else return error message 
    391  
    392     } elsif( $theFunc eq "UPPER" ) { 
    393         $result = uc( $theAttr ); 
    394  
    395     } elsif( $theFunc eq "LOWER" ) { 
    396         $result = lc( $theAttr ); 
    397  
    398     } elsif( $theFunc eq "PROPER" ) { 
     454        }    # else return error message 
     455 
     456    } 
     457    elsif ( $theFunc eq "UPPER" ) { 
     458        $result = uc($theAttr); 
     459 
     460    } 
     461    elsif ( $theFunc eq "LOWER" ) { 
     462        $result = lc($theAttr); 
     463 
     464    } 
     465    elsif ( $theFunc eq "PROPER" ) { 
     466 
    399467        # FIXME: I18N 
    400         $result = lc( $theAttr ); 
     468        $result = lc($theAttr); 
    401469        $result =~ s/(^|[^a-z])([a-z])/$1 . uc($2)/geo; 
    402470 
    403     } elsif( $theFunc eq "PROPERSPACE" ) { 
    404         $result = _properSpace( $theAttr ); 
    405  
    406     } elsif( $theFunc eq "CHAR" ) { 
    407         if( $theAttr =~ /([0-9]+)/ ) { 
     471    } 
     472    elsif ( $theFunc eq "PROPERSPACE" ) { 
     473        $result = _properSpace($theAttr); 
     474 
     475    } 
     476    elsif ( $theFunc eq "CHAR" ) { 
     477        if ( $theAttr =~ /([0-9]+)/ ) { 
    408478            $i = $1; 
    409         } else { 
     479        } 
     480        else { 
    410481            $i = 0; 
    411482        } 
    412483        $i = 255 if $i > 255; 
    413         $i = 0 if $i < 0; 
    414         $result = chr( $i ); 
    415  
    416     } elsif( $theFunc eq "REPEAT" ) { 
    417         my( $str, $num ) = split( /,\s*/, $theAttr, 2 ); 
    418         $str = "" unless( defined( $str ) ); 
    419         $num = _getNumber( $num ); 
     484        $i = 0   if $i < 0; 
     485        $result = chr($i); 
     486 
     487    } 
     488    elsif ( $theFunc eq "REPEAT" ) { 
     489        my ( $str, $num ) = split( /,\s*/, $theAttr, 2 ); 
     490        $str    = "" unless ( defined($str) ); 
     491        $num    = _getNumber($num); 
    420492        $result = "$str" x $num; 
    421493 
    422     } elsif( $theFunc eq "CODE" ) { 
    423         $result = ord( $theAttr ); 
    424  
    425     } elsif( $theFunc eq "LENGTH" ) { 
    426         $result = length( $theAttr ); 
    427  
    428     } elsif( $theFunc eq "ROW" ) { 
     494    } 
     495    elsif ( $theFunc eq "CODE" ) { 
     496        $result = ord($theAttr); 
     497 
     498    } 
     499    elsif ( $theFunc eq "LENGTH" ) { 
     500        $result = length($theAttr); 
     501 
     502    } 
     503    elsif ( $theFunc eq "ROW" ) { 
    429504        $i = $theAttr || 0; 
    430505        $result = $rPos + $i + 1; 
    431506 
    432     } elsif( $theFunc eq "COLUMN" ) { 
     507    } 
     508    elsif ( $theFunc eq "COLUMN" ) { 
    433509        $i = $theAttr || 0; 
    434510        $result = $cPos + $i + 1; 
    435511 
    436     } elsif( $theFunc eq "LEFT" ) { 
    437         $i = $rPos + 1; 
     512    } 
     513    elsif ( $theFunc eq "LEFT" ) { 
     514        $i      = $rPos + 1; 
    438515        $result = "R$i:C0..R$i:C$cPos"; 
    439516 
    440     } elsif( $theFunc eq "ABOVE" ) { 
    441         $i = $cPos + 1; 
     517    } 
     518    elsif ( $theFunc eq "ABOVE" ) { 
     519        $i      = $cPos + 1; 
    442520        $result = "R0:C$i..R$rPos:C$i"; 
    443521 
    444     } elsif( $theFunc eq "RIGHT" ) { 
    445         $i = $rPos + 1; 
     522    } 
     523    elsif ( $theFunc eq "RIGHT" ) { 
     524        $i      = $rPos + 1; 
    446525        $result = "R$i:C$cPos..R$i:C32000"; 
    447526 
    448     } elsif( $theFunc eq "DEF" ) { 
     527    } 
     528    elsif ( $theFunc eq "DEF" ) { 
     529 
    449530        # Format DEF(list) returns first defined cell 
    450531        # Added by MF 26/3/2002, fixed by PeterThoeny 
    451         my @arr = getList( $theAttr ); 
    452         foreach my $cell ( @arr ) { 
    453             if( $cell ) { 
     532        my @arr = getList($theAttr); 
     533        foreach my $cell (@arr) { 
     534            if ($cell) { 
    454535                $cell =~ s/^\s*(.*?)\s*$/$1/o; 
    455                 if( $cell ) { 
     536                if ($cell) { 
    456537                    $result = $cell; 
    457538                    last; 
     
    460541        } 
    461542 
    462     } elsif( $theFunc eq "MAX" ) { 
     543    } 
     544    elsif ( $theFunc eq "MAX" ) { 
    463545        my @arr = sort { $a <=> $b } 
    464                   grep { /./ } 
    465                   grep { defined $_ } 
    466                   getListAsFloat( $theAttr ); 
     546          grep { /./ } 
     547          grep { defined $_ } getListAsFloat($theAttr); 
    467548        $result = $arr[$#arr]; 
    468549 
    469     } elsif( $theFunc eq "MIN" ) { 
     550    } 
     551    elsif ( $theFunc eq "MIN" ) { 
    470552        my @arr = sort { $a <=> $b } 
    471                   grep { /./ } 
    472                   grep { defined $_ } 
    473                   getListAsFloat( $theAttr ); 
     553          grep { /./ } 
     554          grep { defined $_ } getListAsFloat($theAttr); 
    474555        $result = $arr[0]; 
    475556 
    476     } elsif( $theFunc eq "SUM" ) { 
     557    } 
     558    elsif ( $theFunc eq "SUM" ) { 
    477559        $result = 0; 
    478         my @arr = getListAsFloat( $theAttr ); 
    479         foreach $i ( @arr ) { 
    480             $result += $i  if defined $i; 
    481         } 
    482  
    483     } elsif( $theFunc eq "SUMPRODUCT" ) { 
     560        my @arr = getListAsFloat($theAttr); 
     561        foreach $i (@arr) { 
     562            $result += $i if defined $i; 
     563        } 
     564 
     565    } 
     566    elsif ( $theFunc eq "SUMPRODUCT" ) { 
    484567        $result = 0; 
    485568        my @arr; 
    486569        my @lol = split( /,\s*/, $theAttr ); 
    487570        my $size = 32000; 
    488         for $i (0 .. $#lol ) { 
    489             @arr = getListAsFloat( $lol[$i] ); 
    490             $lol[$i] = [ @arr ];                # store reference to array 
    491             $size = @arr if( @arr < $size );    # remember smallest array 
    492         } 
    493         if( ( $size > 0 ) && ( $size < 32000 ) ) { 
    494             my $y; my $prod; my $val; 
     571        for $i ( 0 .. $#lol ) { 
     572            @arr     = getListAsFloat( $lol[$i] ); 
     573            $lol[$i] = [@arr];                       # store reference to array 
     574            $size    = @arr if ( @arr < $size );     # remember smallest array 
     575        } 
     576        if ( ( $size > 0 ) && ( $size < 32000 ) ) { 
     577            my $y; 
     578            my $prod; 
     579            my $val; 
    495580            $size--; 
    496             for $y (0 .. $size ) { 
     581            for $y ( 0 .. $size ) { 
    497582                $prod = 1; 
    498                 for $i (0 .. $#lol ) { 
     583                for $i ( 0 .. $#lol ) { 
    499584                    $val = $lol[$i][$y]; 
    500                     if( defined $val ) { 
     585                    if ( defined $val ) { 
    501586                        $prod *= $val; 
    502                     } else { 
    503                         $prod = 0;   # don't count empty cells 
     587                    } 
     588                    else { 
     589                        $prod = 0;    # don't count empty cells 
    504590                    } 
    505591                } 
     
    508594        } 
    509595 
    510     } elsif( $theFunc =~ /^(SUMDAYS|DURATION)$/ ) { 
     596    } 
     597    elsif ( $theFunc =~ /^(SUMDAYS|DURATION)$/ ) { 
     598 
    511599        # DURATION is undocumented, is for SvenDowideit 
    512600        # contributed by SvenDowideit - 07 Mar 2003; modified by PTh 
    513601        $result = 0; 
    514         my @arr = getListAsDays( $theAttr ); 
    515         foreach $i ( @arr ) { 
    516             $result += $i  if defined $i; 
    517         } 
    518  
    519     } elsif( $theFunc eq "WORKINGDAYS" ) { 
    520         my( $num1, $num2 ) = split( /,\s*/, $theAttr, 2 ); 
    521         $result = _workingDays( _getNumber( $num1 ), _getNumber( $num2 ) ); 
    522  
    523     } elsif( $theFunc =~ /^(MULT|PRODUCT)$/ ) {   # MULT is deprecated, no not remove 
     602        my @arr = getListAsDays($theAttr); 
     603        foreach $i (@arr) { 
     604            $result += $i if defined $i; 
     605        } 
     606 
     607    } 
     608    elsif ( $theFunc eq "WORKINGDAYS" ) { 
     609        my ( $num1, $num2 ) = split( /,\s*/, $theAttr, 2 ); 
     610        $result = _workingDays( _getNumber($num1), _getNumber($num2) ); 
     611 
     612    } 
     613    elsif ( $theFunc =~ /^(MULT|PRODUCT)$/ ) 
     614    {    # MULT is deprecated, no not remove 
    524615        $result = 0; 
    525         my @arr = getListAsFloat( $theAttr ); 
     616        my @arr = getListAsFloat($theAttr); 
    526617        $result = 1; 
    527         foreach $i ( @arr ) { 
    528             $result *= $i  if defined $i; 
    529         } 
    530  
    531     } elsif( $theFunc =~ /^(AVERAGE|MEAN)$/ ) { 
     618        foreach $i (@arr) { 
     619            $result *= $i if defined $i; 
     620        } 
     621 
     622    } 
     623    elsif ( $theFunc =~ /^(AVERAGE|MEAN)$/ ) { 
    532624        $result = 0; 
    533625        my $items = 0; 
    534         my @arr = getListAsFloat( $theAttr ); 
    535         foreach $i ( @arr ) { 
    536             if( defined $i ) { 
     626        my @arr   = getListAsFloat($theAttr); 
     627        foreach $i (@arr) { 
     628            if ( defined $i ) { 
    537629                $result += $i; 
    538630                $items++; 
    539631            } 
    540632        } 
    541         if( $items > 0 ) { 
     633        if ( $items > 0 ) { 
    542634            $result = $result / $items; 
    543635        } 
    544636 
    545     } elsif( $theFunc eq "MEDIAN" ) { 
    546         my @arr = sort { $a <=> $b } grep { defined $_ } getListAsFloat( $theAttr ); 
     637    } 
     638    elsif ( $theFunc eq "MEDIAN" ) { 
     639        my @arr = 
     640          sort { $a <=> $b } grep { defined $_ } getListAsFloat($theAttr); 
    547641        $i = @arr; 
    548         if( ( $i % 2 ) > 0 ) { 
    549             $result = $arr[$i/2]; 
    550         } elsif( $i ) { 
     642        if ( ( $i % 2 ) > 0 ) { 
     643            $result = $arr[ $i / 2 ]; 
     644        } 
     645        elsif ($i) { 
    551646            $i /= 2; 
    552             $result = ( $arr[$i] + $arr[$i-1] ) / 2; 
    553         } 
    554  
    555     } elsif( $theFunc eq "PERCENTILE" ) { 
    556         my( $percentile, $set ) = split( /,\s*/, $theAttr, 2 ); 
    557         my @arr = sort { $a <=> $b } grep { defined $_ } getListAsFloat( $set ); 
     647            $result = ( $arr[$i] + $arr[ $i - 1 ] ) / 2; 
     648        } 
     649 
     650    } 
     651    elsif ( $theFunc eq "PERCENTILE" ) { 
     652        my ( $percentile, $set ) = split( /,\s*/, $theAttr, 2 ); 
     653        my @arr = sort { $a <=> $b } grep { defined $_ } getListAsFloat($set); 
    558654        $result = 0; 
    559655 
    560         my $size = scalar( @arr ); 
    561         if( $size > 0 ) { 
     656        my $size = scalar(@arr); 
     657        if ( $size > 0 ) { 
    562658            $i = $percentile / 100 * ( $size + 1 ); 
    563             my $iInt = int( $i ); 
    564             if( $i <= 1 ) { 
     659            my $iInt = int($i); 
     660            if ( $i <= 1 ) { 
    565661                $result = $arr[0]; 
    566             } elsif( $i >= $size ) { 
    567                 $result = $arr[$size-1]; 
    568             } elsif( $i == $iInt ) { 
    569                 $result = $arr[$i-1]; 
    570             } else { 
     662            } 
     663            elsif ( $i >= $size ) { 
     664                $result = $arr[ $size - 1 ]; 
     665            } 
     666            elsif ( $i == $iInt ) { 
     667                $result = $arr[ $i - 1 ]; 
     668            } 
     669            else { 
     670 
    571671                # interpolate beween neighbors # Example: $i = 7.25 
    572                 my $r1 = $iInt + 1 - $i;       # 0.75 = 7 + 1 - 7.25 
    573                 my $r2 = 1 - $r1;              # 0.25 = 1 - 0.75 
    574                 my $x1 = $arr[$iInt-1]; 
     672                my $r1 = $iInt + 1 - $i;      # 0.75 = 7 + 1 - 7.25 
     673                my $r2 = 1 - $r1;             # 0.25 = 1 - 0.75 
     674                my $x1 = $arr[ $iInt - 1 ]; 
    575675                my $x2 = $arr[$iInt]; 
    576                 $result = ($r1 * $x1) + ($r2 * $x2); 
    577             } 
    578         } 
    579  
    580     } elsif( $theFunc eq "COUNTSTR" ) { 
    581         $result = 0;  # count any string 
    582         $i = 0;       # count string equal second attr 
     676                $result = ( $r1 * $x1 ) + ( $r2 * $x2 ); 
     677            } 
     678        } 
     679 
     680    } 
     681    elsif ( $theFunc eq "COUNTSTR" ) { 
     682        $result = 0;                          # count any string 
     683        $i      = 0;                          # count string equal second attr 
    583684        my $list = $theAttr; 
    584         my $str = ""; 
    585         if( $theAttr =~ /^(.*),\s*(.*?)$/ ) {  # greedy match for last comma 
     685        my $str  = ""; 
     686        if ( $theAttr =~ /^(.*),\s*(.*?)$/ ) {    # greedy match for last comma 
    586687            $list = $1; 
    587             $str = $2; 
     688            $str  = $2; 
    588689        } 
    589690        $str =~ s/\s*$//o; 
    590         my @arr = getList( $list ); 
    591         foreach my $cell ( @arr ) { 
    592             if( defined $cell ) { 
     691        my @arr = getList($list); 
     692        foreach my $cell (@arr) { 
     693            if ( defined $cell ) { 
    593694                $cell =~ s/^\s*(.*?)\s*$/$1/o; 
    594                 $result++ if( $cell ); 
    595                 $i++ if( $cell eq $str ); 
    596             } 
    597         } 
    598         $result = $i if( $str ); 
    599  
    600     } elsif( $theFunc eq "COUNTITEMS" ) { 
     695                $result++ if ($cell); 
     696                $i++ if ( $cell eq $str ); 
     697            } 
     698        } 
     699        $result = $i if ($str); 
     700 
     701    } 
     702    elsif ( $theFunc eq "COUNTITEMS" ) { 
    601703        $result = ""; 
    602         my @arr = getList( $theAttr ); 
     704        my @arr   = getList($theAttr); 
    603705        my %items = (); 
    604         my $key = ""; 
    605         foreach $key ( @arr ) { 
    606             $key =~ s/^\s*(.*?)\s*$/$1/o if( $key ); 
    607             if( $key ) { 
    608                 if( exists( $items{ $key } ) ) { 
    609                     $items{ $key }++; 
    610                 } else { 
    611                     $items{ $key } = 1; 
     706        my $key   = ""; 
     707        foreach $key (@arr) { 
     708            $key =~ s/^\s*(.*?)\s*$/$1/o if ($key); 
     709            if ($key) { 
     710                if ( exists( $items{$key} ) ) { 
     711                    $items{$key}++; 
     712                } 
     713                else { 
     714                    $items{$key} = 1; 
    612715                } 
    613716            } 
     
    618721        $result =~ s|<br /> $||o; 
    619722 
    620     } elsif( $theFunc =~ /^(FIND|SEARCH)$/ ) { 
    621         my( $searchString, $string, $pos ) = split( /,\s*/, $theAttr, 3 ); 
    622         $string = '' unless ( defined $string ); 
    623         $searchString = '' unless (defined $searchString ); 
    624         $result = 0; 
     723    } 
     724    elsif ( $theFunc =~ /^(FIND|SEARCH)$/ ) { 
     725        my ( $searchString, $string, $pos ) = split( /,\s*/, $theAttr, 3 ); 
     726        $string       = '' unless ( defined $string ); 
     727        $searchString = '' unless ( defined $searchString ); 
     728        $result       = 0; 
    625729        $pos--; 
    626         $pos = 0 if( $pos < 0 ); 
    627         $searchString = quotemeta( $searchString ) if( $theFunc eq "FIND" ); 
    628         pos( $string ) = $pos if( $pos ); 
    629         # using zero width lookahead '(?=...)' to keep pos at the beginning of match 
    630         if( $searchString ne '' && eval '$string =~ m/(?=$searchString)/g' ) { 
    631             $result = pos( $string ) + 1; 
    632         } 
    633  
    634     } elsif( $theFunc eq "REPLACE" ) { 
    635         my( $string, $start, $num, $replace ) = split ( /,\s*/, $theAttr, 4 ); 
     730        $pos = 0 if ( $pos < 0 ); 
     731        $searchString = quotemeta($searchString) if ( $theFunc eq "FIND" ); 
     732        pos($string) = $pos if ($pos); 
     733 
     734    # using zero width lookahead '(?=...)' to keep pos at the beginning of match 
     735        if ( $searchString ne '' && eval '$string =~ m/(?=$searchString)/g' ) { 
     736            $result = pos($string) + 1; 
     737        } 
     738 
     739    } 
     740    elsif ( $theFunc eq "REPLACE" ) { 
     741        my ( $string, $start, $num, $replace ) = split( /,\s*/, $theAttr, 4 ); 
    636742        $string = "" unless ( defined $string ); 
    637743        $result = $string; 
    638         $start-- unless ($start < 1); 
    639         $num = 0 unless( $num ); 
    640         $replace = "" unless( defined $replace ); 
     744        $start-- unless ( $start < 1 ); 
     745        $num     = 0  unless ($num); 
     746        $replace = "" unless ( defined $replace ); 
    641747        eval 'substr( $string, $start, $num, $replace )'; 
    642748        $result = $string; 
    643749 
    644     } elsif( $theFunc eq "SUBSTITUTE" ) { 
    645         my( $string, $from, $to, $inst, $options ) = split( /,\s*/, $theAttr ); 
     750    } 
     751    elsif ( $theFunc eq "SUBSTITUTE" ) { 
     752        my ( $string, $from, $to, $inst, $options ) = split( /,\s*/, $theAttr ); 
    646753        $string = "" unless ( defined $string ); 
    647754        $result = $string; 
    648         $from = "" unless( defined $from );         
    649         $from = quotemeta( $from ) unless( $options && $options =~ /r/i); 
    650         $to = "" unless( defined $to ); 
     755        $from   = "" unless ( defined $from ); 
     756        $from   = quotemeta($from) unless ( $options && $options =~ /r/i ); 
     757        $to     = "" unless ( defined $to ); 
    651758 
    652759        # Note that the number 0 is valid string. An empty string as well as 0 
    653760        # are valid return values 
    654761        if ( $string ne "" && $from ne "" ) { 
    655             if( $inst ) { 
     762            if ($inst) { 
     763 
    656764                # replace Nth instance 
    657765                my $count = 0; 
    658                 if( eval '$string =~ s/($from)/if( ++$count == $inst ) { $to; } else { $1; }/gex;' ) { 
     766                if ( 
     767                    eval 
     768'$string =~ s/($from)/if( ++$count == $inst ) { $to; } else { $1; }/gex;' 
     769                  ) 
     770                { 
    659771                    $result = $string; 
    660772                } 
    661             } else { 
     773            } 
     774            else { 
     775 
    662776                # global replace 
    663                 if( eval '$string =~ s/$from/$to/g' ) { 
     777                if ( eval '$string =~ s/$from/$to/g' ) { 
    664778                    $result = $string; 
    665779                } 
    666780            } 
    667         }     
    668  
    669     } elsif( $theFunc =~ /^(MIDSTRING|SUBSTRING)$/ ) { 
    670         my( $string, $start, $num ) = split ( /,\s*/, $theAttr, 3 ); 
     781        } 
     782 
     783    } 
     784    elsif ( $theFunc =~ /^(MIDSTRING|SUBSTRING)$/ ) { 
     785        my ( $string, $start, $num ) = split( /,\s*/, $theAttr, 3 ); 
    671786        $result = ''; 
    672         if( $start && $num ) { 
    673             $start-- unless ($start < 1); 
     787        if ( $start && $num ) { 
     788            $start-- unless ( $start < 1 ); 
    674789            eval '$result = substr( $string, $start, $num )'; 
    675790        } 
    676791 
    677     } elsif( $theFunc =~ /^(LEFTSTRING)$/ ) { 
    678         my( $string, $num ) = split ( /,\s*/, $theAttr, 2 ); 
     792    } 
     793    elsif ( $theFunc =~ /^(LEFTSTRING)$/ ) { 
     794        my ( $string, $num ) = split( /,\s*/, $theAttr, 2 ); 
    679795        $string = "" unless ( defined $string ); 
    680         $num = 1 if( !defined $num ); 
     796        $num = 1 if ( !defined $num ); 
    681797        eval '$result = substr( $string, 0, $num )'; 
    682          
    683     } elsif( $theFunc =~ /^(RIGHTSTRING)$/ ) { 
    684         my( $string, $num ) = split ( /,\s*/, $theAttr, 2 ); 
     798 
     799    } 
     800    elsif ( $theFunc =~ /^(RIGHTSTRING)$/ ) { 
     801        my ( $string, $num ) = split( /,\s*/, $theAttr, 2 ); 
    685802        $string = "" unless ( defined $string ); 
    686         $num = 1 if( !defined $num ); 
    687         $num = 0 if( $num < 0); 
    688         my $start = length( $string ) - $num; 
    689         $start = 0 if $start <0; 
     803        $num = 1 if ( !defined $num ); 
     804        $num = 0 if ( $num < 0 ); 
     805        my $start = length($string) - $num; 
     806        $start = 0 if $start < 0; 
    690807        eval '$result = substr( $string, $start, $num )'; 
    691808 
    692     } elsif( $theFunc eq "INSERTSTRING" ) { 
    693         my( $string, $start, $new ) = split ( /,\s*/, $theAttr, 3 ); 
     809    } 
     810    elsif ( $theFunc eq "INSERTSTRING" ) { 
     811        my ( $string, $start, $new ) = split( /,\s*/, $theAttr, 3 ); 
    694812        $string = "" unless ( defined $string ); 
    695         $start = _getNumber( $start ); 
     813        $start = _getNumber($start); 
    696814        eval 'substr( $string, $start, 0, $new )'; 
    697815        $result = $string; 
    698816 
    699     } elsif( $theFunc eq "TRANSLATE" ) { 
     817    } 
     818    elsif ( $theFunc eq "TRANSLATE" ) { 
    700819        $result = $theAttr; 
    701         # greedy match for comma separated parameters (in case first parameter has embedded commas) 
    702         if( $theAttr =~ /^(.*)\,\s*(.+)\,\s*(.+)$/ ) { 
     820 
     821# greedy match for comma separated parameters (in case first parameter has embedded commas) 
     822        if ( $theAttr =~ /^(.*)\,\s*(.+)\,\s*(.+)$/ ) { 
    703823            my $string = $1; 
    704             my $from = $2; 
    705             my $to   = $3; 
    706             $from =~ s/\$comma/,/g;  $from =~ s/\$sp/ /g;  $from = quotemeta( $from ); 
    707             $to   =~ s/\$comma/,/g;  $to   =~ s/\$sp/ /g;  $to   = quotemeta( $to ); 
    708             $from =~ s/([a-zA-Z0-9])\\\-([a-zA-Z0-9])/$1\-$2/g; # fix quotemeta (allow only ranges) 
    709             $to   =~ s/([a-zA-Z0-9])\\\-([a-zA-Z0-9])/$1\-$2/g; 
     824            my $from   = $2; 
     825            my $to     = $3; 
     826            $from =~ s/\$comma/,/g; 
     827            $from =~ s/\$sp/ /g; 
     828            $from = quotemeta($from); 
     829            $to =~ s/\$comma/,/g; 
     830            $to =~ s/\$sp/ /g; 
     831            $to = quotemeta($to); 
     832            $from =~ s/([a-zA-Z0-9])\\\-([a-zA-Z0-9])/$1\-$2/g 
     833              ;    # fix quotemeta (allow only ranges) 
     834            $to =~ s/([a-zA-Z0-9])\\\-([a-zA-Z0-9])/$1\-$2/g; 
    710835            $result = $string; 
    711             if( $string && eval "\$string =~ tr/$from/$to/" ) { 
     836 
     837            if ( $string && eval "\$string =~ tr/$from/$to/" ) { 
    712838                $result = $string; 
    713839            } 
    714840        } 
    715841 
    716     } elsif ( $theFunc eq "TIME" ) { 
     842    } 
     843    elsif ( $theFunc eq "TIME" ) { 
    717844        $result = $theAttr; 
    718845        $result =~ s/^\s+//o; 
    719846        $result =~ s/\s+$//o; 
    720         if( $result ) { 
    721             $result = _date2serial( $result ); 
    722         } else { 
     847        if ($result) { 
     848            $result = _date2serial($result); 
     849        } 
     850        else { 
    723851            $result = time(); 
    724852        } 
    725853 
    726     } elsif ( $theFunc eq "TODAY" ) { 
    727         $result = _date2serial( _serial2date( time(), '$year/$month/$day GMT', 1 ) ); 
    728  
    729     } elsif( $theFunc =~ /^(FORMATTIME|FORMATGMTIME)$/ ) { 
    730         my( $time, $str ) = split( /,\s*/, $theAttr, 2 ); 
    731         if( $time =~ /([0-9]+)/ ) { 
     854    } 
     855    elsif ( $theFunc eq "TODAY" ) { 
     856        $result = 
     857          _date2serial( _serial2date( time(), '$year/$month/$day GMT', 1 ) ); 
     858 
     859    } 
     860    elsif ( $theFunc =~ /^(FORMATTIME|FORMATGMTIME)$/ ) { 
     861        my ( $time, $str ) = split( /,\s*/, $theAttr, 2 ); 
     862        if ( $time =~ /([0-9]+)/ ) { 
    732863            $time = $1; 
    733         } else { 
     864        } 
     865        else { 
    734866            $time = time(); 
    735867        } 
    736868        my $isGmt = 0; 
    737         $isGmt = 1 if( ( $str =~ m/ gmt/i ) || ( $theFunc eq "FORMATGMTIME" ) ); 
     869        $isGmt = 1 
     870          if ( ( $str =~ m/ gmt/i ) || ( $theFunc eq "FORMATGMTIME" ) ); 
    738871        $result = _serial2date( $time, $str, $isGmt ); 
    739872 
    740     } elsif( $theFunc eq "FORMATTIMEDIFF" ) { 
    741         my( $scale, $prec, $time ) = split( /,\s*/, $theAttr, 3 ); 
    742         $scale = "" unless( $scale ); 
    743         $prec = int( _getNumber( $prec ) - 1 ); 
    744         $prec = 0 if( $prec < 0 ); 
    745         $time = _getNumber( $time ); 
    746         $time = 0 if( $time < 0 ); 
    747         my @unit  = ( 0, 0, 0, 0, 0, 0 ); # sec, min, hours, days, month, years 
    748         my @factor = ( 1, 60, 60, 24, 30.4166, 12 ); # sec, min, hours, days, month, years 
    749         my @singular = ( 'second',  'minute',  'hour',  'day',  'month', 'year' ); 
    750         my @plural =   ( 'seconds', 'minutes', 'hours', 'days', 'month', 'years' ); 
     873    } 
     874    elsif ( $theFunc eq "FORMATTIMEDIFF" ) { 
     875        my ( $scale, $prec, $time ) = split( /,\s*/, $theAttr, 3 ); 
     876        $scale = "" unless ($scale); 
     877        $prec  = int( _getNumber($prec) - 1 ); 
     878        $prec  = 0 if ( $prec < 0 ); 
     879        $time  = _getNumber($time); 
     880        $time  = 0 if ( $time < 0 ); 
     881        my @unit = ( 0, 0, 0, 0, 0, 0 );   # sec, min, hours, days, month, years 
     882        my @factor = 
     883          ( 1, 60, 60, 24, 30.4166, 12 );  # sec, min, hours, days, month, years 
     884        my @singular = ( 'second', 'minute', 'hour', 'day', 'month', 'year' ); 
     885        my @plural = 
     886          ( 'seconds', 'minutes', 'hours', 'days', 'month', 'years' ); 
    751887        my $min = 0; 
    752888        my $max = $prec; 
    753         if( $scale =~ /^min/i ) { 
     889 
     890        if ( $scale =~ /^min/i ) { 
    754891            $min = 1; 
    755892            $unit[1] = $time; 
    756         } elsif( $scale =~ /^hou/i ) { 
     893        } 
     894        elsif ( $scale =~ /^hou/i ) { 
    757895            $min = 2; 
    758896            $unit[2] = $time; 
    759         } elsif( $scale =~ /^day/i ) { 
     897        } 
     898        elsif ( $scale =~ /^day/i ) { 
    760899            $min = 3; 
    761900            $unit[3] = $time; 
    762         } elsif( $scale =~ /^mon/i ) { 
     901        } 
     902        elsif ( $scale =~ /^mon/i ) { 
    763903            $min = 4; 
    764904            $unit[4] = $time; 
    765         } elsif( $scale =~ /^yea/i ) { 
     905        } 
     906        elsif ( $scale =~ /^yea/i ) { 
    766907            $min = 5; 
    767908            $unit[5] = $time; 
    768         } else { 
     909        } 
     910        else { 
    769911            $unit[0] = $time; 
    770912        } 
    771         my @arr = (); 
    772         my $i = 0; 
     913        my @arr  = (); 
     914        my $i    = 0; 
    773915        my $val1 = 0; 
    774916        my $val2 = 0; 
    775         for( $i = $min; $i < 5; $i++ ) { 
     917        for ( $i = $min ; $i < 5 ; $i++ ) { 
    776918            $val1 = $unit[$i]; 
    777             $val2 = $unit[$i+1] = int($val1 / $factor[$i+1]); 
    778             $val1 = $unit[$i] = $val1 - int($val2 * $factor[$i+1]); 
    779              
    780             push( @arr, "$val1 $singular[$i]" ) if( $val1 == 1 ); 
    781             push( @arr, "$val1 $plural[$i]" )   if( $val1 > 1 ); 
    782         } 
    783         push( @arr, "$val2 $singular[$i]" ) if( $val2 == 1 ); 
    784         push( @arr, "$val2 $plural[$i]" )   if( $val2 > 1 ); 
    785         push( @arr, "0 $plural[$min]" )   unless( @arr ); 
    786         my @reverse = reverse( @arr ); 
    787         $#reverse = $prec if( @reverse > $prec ); 
     919            $val2 = $unit[ $i + 1 ] = int( $val1 / $factor[ $i + 1 ] ); 
     920            $val1 = $unit[$i] = $val1 - int( $val2 * $factor[ $i + 1 ] ); 
     921 
     922            push( @arr, "$val1 $singular[$i]" ) if ( $val1 == 1 ); 
     923            push( @arr, "$val1 $plural[$i]" )   if ( $val1 > 1 ); 
     924        } 
     925        push( @arr, "$val2 $singular[$i]" ) if ( $val2 == 1 ); 
     926        push( @arr, "$val2 $plural[$i]" )   if ( $val2 > 1 ); 
     927        push( @arr, "0 $plural[$min]" ) unless (@arr); 
     928        my @reverse = reverse(@arr); 
     929        $#reverse = $prec if ( @reverse > $prec ); 
    788930        $result = join( ', ', @reverse ); 
    789931        $result =~ s/(.+)\, /$1 and /; 
    790932 
    791     } elsif( $theFunc eq "TIMEADD" ) { 
    792        my( $time, $value, $scale ) = split( /,\s*/, $theAttr, 3 ); 
    793        $time = 0 unless( $time ); 
    794        $value = 0 unless( $value ); 
    795        $scale = "" unless( $scale ); 
    796        $time =~ s/.*?([0-9]+).*/$1/o || 0; 
    797        $value =~ s/.*?(\-?[0-9\.]+).*/$1/o || 0; 
    798        $value *= 60            if( $scale =~ /^min/i ); 
    799        $value *= 3600          if( $scale =~ /^hou/i ); 
    800        $value *= 3600*24       if( $scale =~ /^day/i ); 
    801        $value *= 3600*24*7     if( $scale =~ /^week/i ); 
    802        $value *= 3600*24*30.42 if( $scale =~ /^mon/i );  # FIXME: exact calc 
    803        $value *= 3600*24*365   if( $scale =~ /^year/i ); # FIXME: exact calc 
    804        $result = int( $time + $value ); 
    805  
    806     } elsif( $theFunc eq "TIMEDIFF" ) { 
    807        my( $time1, $time2, $scale ) = split( /,\s*/, $theAttr, 3 ); 
    808        $scale ||= ''; 
    809        $time1 = 0 unless( $time1 ); 
    810        $time2 = 0 unless( $time2 ); 
    811        $time1 =~ s/.*?([0-9]+).*/$1/o || 0; 
    812        $time2 =~ s/.*?([0-9]+).*/$1/o || 0; 
    813        $result = $time2 - $time1; 
    814        $result /= 60            if( $scale =~ /^min/i ); 
    815        $result /= 3600          if( $scale =~ /^hou/i ); 
    816        $result /= 3600*24       if( $scale =~ /^day/i ); 
    817        $result /= 3600*24*7     if( $scale =~ /^week/i ); 
    818        $result /= 3600*24*30.42 if( $scale =~ /^mon/i );  # FIXME: exact calc 
    819        $result /= 3600*24*365   if( $scale =~ /^year/i ); # FIXME: exact calc 
    820  
    821     } elsif( $theFunc eq "SET" ) { 
    822        my( $name, $value ) = split( /,\s*/, $theAttr, 2 ); 
    823        $name =~ s/[^a-zA-Z0-9\_]//go; 
    824        if( $name && defined( $value ) ) { 
    825            $value =~ s/\s*$//o; 
    826            $varStore{ $name } = $value; 
    827        } 
    828  
    829     } elsif( $theFunc eq "SETIFEMPTY" ) { 
    830        my( $name, $value ) = split( /,\s*/, $theAttr, 2 ); 
    831        $name =~ s/[^a-zA-Z0-9\_]//go; 
    832        if( $name && defined( $value ) && ! $varStore{ $name } ) { 
    833            $value =~ s/\s*$//o; 
    834            $varStore{ $name } = $value; 
    835        } 
    836  
    837     } elsif( $theFunc eq "SETM" ) { 
    838        my( $name, $value ) = split( /,\s*/, $theAttr, 2 ); 
    839        $name =~ s/[^a-zA-Z0-9\_]//go; 
    840        if( $name ) { 
    841            my $old = $varStore{ $name }; 
    842            $old = "" unless( defined( $old ) ); 
    843            $value = safeEvalPerl( "$old $value" ); 
    844            $varStore{ $name } = $value; 
    845        } 
    846  
    847     } elsif( $theFunc eq "GET" ) { 
    848        my $name = $theAttr; 
    849        $name =~ s/[^a-zA-Z0-9\_]//go; 
    850        $result = $varStore{ $name } if( $name ); 
    851        $result = "" unless( defined( $result ) ); 
    852  
    853     } elsif( $theFunc eq "LIST" ) { 
    854         my @arr = getList( $theAttr ); 
    855         $result = _listToDelimitedString( @arr ); 
    856  
    857     } elsif( $theFunc eq "LISTITEM" ) { 
    858         my( $index, $str ) = _properSplit( $theAttr, 2 ); 
    859         $index = _getNumber( $index ); 
    860         $str = "" unless( defined( $str ) ); 
    861         my @arr = getList( $str ); 
     933    } 
     934    elsif ( $theFunc eq "TIMEADD" ) { 
     935        my ( $time, $value, $scale ) = split( /,\s*/, $theAttr, 3 ); 
     936        $time  = 0  unless ($time); 
     937        $value = 0  unless ($value); 
     938        $scale = "" unless ($scale); 
     939        $time  =~ s/.*?([0-9]+).*/$1/o      || 0; 
     940        $value =~ s/.*?(\-?[0-9\.]+).*/$1/o || 0; 
     941        $value *= 60            if ( $scale =~ /^min/i ); 
     942        $value *= 3600          if ( $scale =~ /^hou/i ); 
     943        $value *= 3600 * 24     if ( $scale =~ /^day/i ); 
     944        $value *= 3600 * 24 * 7 if ( $scale =~ /^week/i ); 
     945        $value *= 3600 * 24 * 30.42 
     946          if ( $scale =~ /^mon/i );    # FIXME: exact calc 
     947        $value *= 3600 * 24 * 365 if ( $scale =~ /^year/i ); # FIXME: exact calc 
     948        $result = int( $time + $value ); 
     949 
     950    } 
     951    elsif ( $theFunc eq "TIMEDIFF" ) { 
     952        my ( $time1, $time2, $scale ) = split( /,\s*/, $theAttr, 3 ); 
     953        $scale ||= ''; 
     954        $time1 = 0 unless ($time1); 
     955        $time2 = 0 unless ($time2); 
     956        $time1 =~ s/.*?([0-9]+).*/$1/o || 0; 
     957        $time2 =~ s/.*?([0-9]+).*/$1/o || 0; 
     958        $result = $time2 - $time1; 
     959        $result /= 60            if ( $scale =~ /^min/i ); 
     960        $result /= 3600          if ( $scale =~ /^hou/i ); 
     961        $result /= 3600 * 24     if ( $scale =~ /^day/i ); 
     962        $result /= 3600 * 24 * 7 if ( $scale =~ /^week/i ); 
     963        $result /= 3600 * 24 * 30.42 
     964          if ( $scale =~ /^mon/i );    # FIXME: exact calc 
     965        $result /= 3600 * 24 * 365 
     966          if ( $scale =~ /^year/i );    # FIXME: exact calc 
     967 
     968    } 
     969    elsif ( $theFunc eq "SET" ) { 
     970        my ( $name, $value ) = split( /,\s*/, $theAttr, 2 ); 
     971        $name =~ s/[^a-zA-Z0-9\_]//go; 
     972        if ( $name && defined($value) ) { 
     973            $value =~ s/\s*$//o; 
     974            $varStore{$name} = $value; 
     975        } 
     976 
     977    } 
     978    elsif ( $theFunc eq "SETIFEMPTY" ) { 
     979        my ( $name, $value ) = split( /,\s*/, $theAttr, 2 ); 
     980        $name =~ s/[^a-zA-Z0-9\_]//go; 
     981        if ( $name && defined($value) && !$varStore{$name} ) { 
     982            $value =~ s/\s*$//o; 
     983            $varStore{$name} = $value; 
     984        } 
     985 
     986    } 
     987    elsif ( $theFunc eq "SETM" ) { 
     988        my ( $name, $value ) = split( /,\s*/, $theAttr, 2 ); 
     989        $name =~ s/[^a-zA-Z0-9\_]//go; 
     990        if ($name) { 
     991            my $old = $varStore{$name}; 
     992            $old             = "" unless ( defined($old) ); 
     993            $value           = safeEvalPerl("$old $value"); 
     994            $varStore{$name} = $value; 
     995        } 
     996 
     997    } 
     998    elsif ( $theFunc eq "GET" ) { 
     999        my $name = $theAttr; 
     1000        $name =~ s/[^a-zA-Z0-9\_]//go; 
     1001        $result = $varStore{$name} if ($name); 
     1002        $result = "" unless ( defined($result) ); 
     1003 
     1004    } 
     1005    elsif ( $theFunc eq "LIST" ) { 
     1006        my @arr = getList($theAttr); 
     1007        $result = _listToDelimitedString(@arr); 
     1008 
     1009    } 
     1010    elsif ( $theFunc eq "LISTITEM" ) { 
     1011        my ( $index, $str ) = _properSplit( $theAttr, 2 ); 
     1012        $index = _getNumber($index); 
     1013        $str = "" unless ( defined($str) ); 
     1014        my @arr  = getList($str); 
    8621015        my $size = scalar @arr; 
    863         if( $index && $size ) { 
    864             $index-- if( $index > 0 );                 # documented index starts at 1 
    865             $index = $size + $index if( $index < 0 );  # start from back if negative 
    866             $result = $arr[$index] if( ( $index >= 0 ) && ( $index < $size ) ); 
    867         } 
    868  
    869     } elsif( $theFunc eq "LISTJOIN" ) { 
    870         my( $sep, $str ) = _properSplit( $theAttr, 2 ); 
    871         $str = "" unless( defined( $str ) ); 
    872         $result = _listToDelimitedString( getList( $str ) ); 
    873         $sep = ", " unless( $sep ); 
    874         $sep =~ s/\$comma/,/go; 
    875         $sep =~ s/\$sp/ /go; 
    876         $sep =~ s/\$n/\n/go; 
     1016        if ( $index && $size ) { 
     1017            $index-- if ( $index > 0 );    # documented index starts at 1 
     1018            $index = $size + $index 
     1019              if ( $index < 0 );           # start from back if negative 
     1020            $result = $arr[$index] if ( ( $index >= 0 ) && ( $index < $size ) ); 
     1021        } 
     1022 
     1023    } 
     1024    elsif ( $theFunc eq "LISTJOIN" ) { 
     1025        my ( $sep, $str ) = _properSplit( $theAttr, 2 ); 
     1026        $str    = "" unless ( defined($str) ); 
     1027        $result = _listToDelimitedString( getList($str) ); 
     1028        $sep    = ", " unless ($sep); 
     1029        $sep    =~ s/\$comma/,/go; 
     1030        $sep    =~ s/\$sp/ /go; 
     1031        $sep    =~ s/\$n/\n/go; 
    8771032        $result =~ s/, /$sep/go; 
    8781033 
    879     } elsif( $theFunc eq "LISTSIZE" ) { 
    880         my @arr = getList( $theAttr ); 
     1034    } 
     1035    elsif ( $theFunc eq "LISTSIZE" ) { 
     1036        my @arr = getList($theAttr); 
    8811037        $result = scalar @arr; 
    8821038 
    883     } elsif( $theFunc eq "LISTSORT" ) { 
     1039    } 
     1040    elsif ( $theFunc eq "LISTSORT" ) { 
    8841041        my $isNumeric = 1; 
    885         my @arr = map { 
     1042        my @arr       = map { 
    8861043            s/^\s*//o; 
    8871044            s/\s*$//o; 
    888             $isNumeric = 0 unless( $_ =~ /^[\+\-]?[0-9\.]+$/ ); 
     1045            $isNumeric = 0 unless ( $_ =~ /^[\+\-]?[0-9\.]+$/ ); 
    8891046            $_ 
    890         } getList( $theAttr ); 
    891         if( $isNumeric ) { 
     1047        } getList($theAttr); 
     1048        if ($isNumeric) { 
    8921049            @arr = sort { $a <=> $b } @arr; 
    893         } else { 
     1050        } 
     1051        else { 
    8941052            @arr = sort @arr; 
    8951053        } 
    896         $result = _listToDelimitedString( @arr ); 
    897  
    898     } elsif( $theFunc eq "LISTSHUFFLE" ) { 
    899         my @arr = getList( $theAttr ); 
     1054        $result = _listToDelimitedString(@arr); 
     1055 
     1056    } 
     1057    elsif ( $theFunc eq "LISTSHUFFLE" ) { 
     1058        my @arr  = getList($theAttr); 
    9001059        my $size = scalar @arr; 
    901         if( $size > 1 ) { 
    902             for( $i = $size; $i--; ) { 
     1060        if ( $size > 1 ) { 
     1061            for ( $i = $size ; $i-- ; ) { 
    9031062                my $j = int( rand( $i + 1 ) ); 
    904                 next if( $i == $j ); 
    905                 @arr[$i, $j] = @arr[$j, $i]; 
    906             } 
    907         } 
    908         $result = _listToDelimitedString( @arr ); 
    909  
    910     } elsif( $theFunc eq "LISTRAND" ) { 
    911         my @arr = getList( $theAttr ); 
     1063                next if ( $i == $j ); 
     1064                @arr[ $i, $j ] = @arr[ $j, $i ]; 
     1065            } 
     1066        } 
     1067        $result = _listToDelimitedString(@arr); 
     1068 
     1069    } 
     1070    elsif ( $theFunc eq "LISTRAND" ) { 
     1071        my @arr  = getList($theAttr); 
    9121072        my $size = scalar @arr; 
    913         if( $size > 1 ) { 
    914             $i = int( rand( $size - 1 ) + 0.5 ); 
     1073        if ( $size > 1 ) { 
     1074            $i      = int( rand( $size - 1 ) + 0.5 ); 
    9151075            $result = $arr[$i]; 
    916         } elsif( $size == 1 ) { 
     1076        } 
     1077        elsif ( $size == 1 ) { 
    9171078            $result = $arr[0]; 
    9181079        } 
    9191080 
    920     } elsif( $theFunc eq "LISTREVERSE" ) { 
    921         my @arr = reverse getList( $theAttr ); 
    922         $result = _listToDelimitedString( @arr ); 
    923  
    924     } elsif( $theFunc eq "LISTTRUNCATE" ) { 
    925         my( $index, $str ) = _properSplit( $theAttr, 2 ); 
    926         $index = int( _getNumber( $index ) ); 
    927         $str = "" unless( defined( $str ) ); 
    928         my @arr = getList( $str ); 
     1081    } 
     1082    elsif ( $theFunc eq "LISTREVERSE" ) { 
     1083        my @arr = reverse getList($theAttr); 
     1084        $result = _listToDelimitedString(@arr); 
     1085 
     1086    } 
     1087    elsif ( $theFunc eq "LISTTRUNCATE" ) { 
     1088        my ( $index, $str ) = _properSplit( $theAttr, 2 ); 
     1089        $index = int( _getNumber($index) ); 
     1090        $str = "" unless ( defined($str) ); 
     1091        my @arr  = getList($str); 
    9291092        my $size = scalar @arr; 
    930         if( $index > 0 ) { 
    931             $index = $size if( $index > $size ); 
    932             $#arr = $index - 1; 
    933             $result = _listToDelimitedString( @arr ); 
    934         } elsif( $index < 0 ) { 
    935             $index = - $size if( $index < - $size ); 
     1093        if ( $index > 0 ) { 
     1094            $index  = $size if ( $index > $size ); 
     1095            $#arr   = $index - 1; 
     1096            $result = _listToDelimitedString(@arr); 
     1097        } 
     1098        elsif ( $index < 0 ) { 
     1099            $index = -$size if ( $index < -$size ); 
    9361100            splice( @arr, 0, $size + $index ); 
    937             $result = _listToDelimitedString( @arr ); 
    938         } #else result = ''; 
    939  
    940     } elsif( $theFunc eq "LISTUNIQUE" ) { 
     1101            $result = _listToDelimitedString(@arr); 
     1102        }    #else result = ''; 
     1103 
     1104    } 
     1105    elsif ( $theFunc eq "LISTUNIQUE" ) { 
    9411106        my %seen = (); 
    942         my @arr = grep { ! $seen{$_} ++ } getList( $theAttr ); 
    943         $result = _listToDelimitedString( @arr ); 
    944  
    945     } elsif( $theFunc eq "LISTMAP" ) { 
     1107        my @arr = grep { !$seen{$_}++ } getList($theAttr); 
     1108        $result = _listToDelimitedString(@arr); 
     1109 
     1110    } 
     1111    elsif ( $theFunc eq "LISTMAP" ) { 
     1112 
    9461113        # LISTMAP(action, item 1, item 2, ...) 
    947         my( $action, $str ) = _properSplit( $theAttr, 2 ); 
    948         $action = "" unless( defined( $action ) ); 
    949         $str = "" unless( defined( $str ) ); 
    950         # with delay, handle functions in result recursively and clean up unbalanced parenthesis 
    951         $str =~ s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 
     1114        my ( $action, $str ) = _properSplit( $theAttr, 2 ); 
     1115        $action = "" unless ( defined($action) ); 
     1116        $str    = "" unless ( defined($str) ); 
     1117 
     1118# with delay, handle functions in result recursively and clean up unbalanced parenthesis 
     1119        $str =~ 
     1120          s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 
    9521121        $str =~ s/$escToken\-*[0-9]+([\(\)])/$1/go; 
    9531122        my $item = ""; 
    9541123        $i = 0; 
    955         my @arr = 
    956             map { 
    957                $item = $_; 
    958                $_ = $action; 
    959                $i++; 
    960                s/\$index/$i/go; 
    961                $_ .= $item unless( s/\$item/$item/go ); 
    962                s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 
    963                s/$escToken\-*[0-9]+([\(\)])/$1/go; 
    964                $_ 
    965             } getList( $str ); 
    966         $result = _listToDelimitedString( @arr ); 
    967  
    968     } elsif( $theFunc eq "LISTIF" ) { 
     1124        my @arr = map { 
     1125            $item = $_; 
     1126            $_    = $action; 
     1127            $i++; 
     1128            s/\$index/$i/go; 
     1129            $_ .= $item unless (s/\$item/$item/go); 
     1130s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 
     1131            s/$escToken\-*[0-9]+([\(\)])/$1/go; 
     1132            $_ 
     1133        } getList($str); 
     1134        $result = _listToDelimitedString(@arr); 
     1135 
     1136    } 
     1137    elsif ( $theFunc eq "LISTIF" ) { 
     1138 
    9691139        # LISTIF(cmd, item 1, item 2, ...) 
    970         my( $cmd, $str ) = _properSplit( $theAttr, 2 ); 
    971         $cmd = "" unless( defined( $cmd ) ); 
     1140        my ( $cmd, $str ) = _properSplit( $theAttr, 2 ); 
     1141        $cmd = "" unless ( defined($cmd) ); 
    9721142        $cmd =~ s/^\s*(.*?)\s*$/$1/o; 
    973         $str = "" unless( defined( $str ) ); 
    974         # with delay, handle functions in result recursively and clean up unbalanced parenthesis 
    975         $str =~ s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 
     1143        $str = "" unless ( defined($str) ); 
     1144 
     1145# with delay, handle functions in result recursively and clean up unbalanced parenthesis 
     1146        $str =~ 
     1147          s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 
    9761148        $str =~ s/$escToken\-*[0-9]+([\(\)])/$1/go; 
    9771149        my $item = ""; 
     
    9791151        $i = 0; 
    9801152        my @arr = 
    981             grep { ! /^FOSWIKI_GREP_REMOVE$/ } 
    982             map { 
    983                 $item = $_; 
    984                 $_ = $cmd; 
    985                 $i++; 
    986                 s/\$index/$i/go; 
    987                 s/\$item/$item/go; 
    988                 s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 
    989                 s/$escToken\-*[0-9]+([\(\)])/$1/go; 
    990                 $eval = safeEvalPerl( $_ ); 
    991                 if( $eval =~ /^ERROR/ ) { 
    992                     $_ = $eval; 
    993                 } elsif( $eval ) { 
    994                     $_ = $item; 
    995                 } else { 
    996                     $_ = "FOSWIKI_GREP_REMOVE"; 
    997                 } 
    998             } getList( $str ); 
    999         $result = _listToDelimitedString( @arr ); 
    1000  
    1001     } elsif ( $theFunc eq "NOP" ) { 
     1153          grep { !/^FOSWIKI_GREP_REMOVE$/ } 
     1154          map { 
     1155            $item = $_; 
     1156            $_    = $cmd; 
     1157            $i++; 
     1158            s/\$index/$i/go; 
     1159            s/\$item/$item/go; 
     1160s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 
     1161            s/$escToken\-*[0-9]+([\(\)])/$1/go; 
     1162            $eval = safeEvalPerl($_); 
     1163            if ( $eval =~ /^ERROR/ ) { 
     1164                $_ = $eval; 
     1165            } 
     1166            elsif ($eval) { 
     1167                $_ = $item; 
     1168            } 
     1169            else { 
     1170                $_ = "FOSWIKI_GREP_REMOVE"; 
     1171            } 
     1172          } getList($str); 
     1173        $result = _listToDelimitedString(@arr); 
     1174 
     1175    } 
     1176    elsif ( $theFunc eq "NOP" ) { 
     1177 
    10021178        # pass everything through, this will allow plugins to defy plugin order 
    10031179        # for example the %SEARCH{}% variable 
     
    10051181        $result = $theAttr; 
    10061182 
    1007     } elsif ( $theFunc eq "EXISTS" ) { 
     1183    } 
     1184    elsif ( $theFunc eq "EXISTS" ) { 
    10081185        $result = Foswiki::Func::topicExists( $web, $theAttr ); 
    1009         $result = 0 unless( $result ); 
    1010     } 
    1011  
    1012     Foswiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::doFunc: $theFunc( $theAttr ) returns: $result" ) if $debug; 
     1186        $result = 0 unless ($result); 
     1187    } 
     1188 
     1189    Foswiki::Func::writeDebug( 
     1190"- SpreadSheetPlugin::Calc::doFunc: $theFunc( $theAttr ) returns: $result" 
     1191    ) if $debug; 
    10131192    return $result; 
    10141193} 
    10151194 
    10161195# ========================= 
    1017 sub _listToDelimitedString 
    1018 { 
     1196sub _listToDelimitedString { 
    10191197    my @arr = map { s/^\s*//o; s/\s*$//o; $_ } @_; 
    10201198    my $text = join( ", ", @arr ); 
     
    10231201 
    10241202# ========================= 
    1025 sub _properSplit 
    1026 { 
    1027     my( $theAttr, $theLevel ) = @_; 
     1203sub _properSplit { 
     1204    my ( $theAttr, $theLevel ) = @_; 
    10281205 
    10291206    # escape commas inside functions 
    1030     $theAttr =~ s/(\$[A-Z]+$escToken([0-9]+)\(.*?$escToken\2\))/_escapeCommas($1)/geo; 
     1207    $theAttr =~ 
     1208      s/(\$[A-Z]+$escToken([0-9]+)\(.*?$escToken\2\))/_escapeCommas($1)/geo; 
     1209 
    10311210    # split at commas and restore commas inside functions 
    1032     my @arr = map{ s/<$escToken>/\,/go; $_ } split( /,\s*/, $theAttr, $theLevel ); 
     1211    my @arr = 
     1212      map { s/<$escToken>/\,/go; $_ } split( /,\s*/, $theAttr, $theLevel ); 
    10331213    return @arr; 
    10341214} 
    10351215 
    10361216# ========================= 
    1037 sub _escapeCommas 
    1038 { 
    1039     my( $theText ) = @_; 
     1217sub _escapeCommas { 
     1218    my ($theText) = @_; 
    10401219    $theText =~ s/\,/<$escToken>/go; 
    10411220    return $theText; 
     
    10431222 
    10441223# ========================= 
    1045 sub _getNumber 
    1046 { 
    1047     my( $theText ) = @_; 
    1048     return 0 unless( $theText ); 
    1049     $theText =~ s/([0-9])\,(?=[0-9]{3})/$1/go;          # "1,234,567" ==> "1234567" 
    1050     if( $theText =~ /[0-9]e/i ) {                       # "1.5e-3"    ==> "0.0015" 
     1224sub _getNumber { 
     1225    my ($theText) = @_; 
     1226    return 0 unless ($theText); 
     1227    $theText =~ s/([0-9])\,(?=[0-9]{3})/$1/go;    # "1,234,567" ==> "1234567" 
     1228    if ( $theText =~ /[0-9]e/i ) {                # "1.5e-3"    ==> "0.0015" 
    10511229        $theText = sprintf "%.20f", $theText; 
    10521230        $theText =~ s/0+$//; 
    10531231    } 
    1054     unless( $theText =~ s/^.*?(\-?[0-9\.]+).*$/$1/o ) { # "xy-1.23zz" ==> "-1.23" 
     1232    unless ( $theText =~ s/^.*?(\-?[0-9\.]+).*$/$1/o ) 
     1233    {                                             # "xy-1.23zz" ==> "-1.23" 
    10551234        $theText = 0; 
    10561235    } 
    1057     $theText =~ s/^(\-?)0+([0-9])/$1$2/o;               # "-0009.12"  ==> "-9.12" 
    1058     $theText =~ s/^(\-?)\./${1}0\./o;                   # "-.25"      ==> "-0.25" 
    1059     $theText =~ s/^\-0$/0/o;                            # "-0"        ==> "0" 
    1060     $theText =~ s/\.$//o;                               # "123."      ==> "123" 
     1236    $theText =~ s/^(\-?)0+([0-9])/$1$2/o;         # "-0009.12"  ==> "-9.12" 
     1237    $theText =~ s/^(\-?)\./${1}0\./o;             # "-.25"      ==> "-0.25" 
     1238    $theText =~ s/^\-0$/0/o;                      # "-0"        ==> "0" 
     1239    $theText =~ s/\.$//o;                         # "123."      ==> "123" 
    10611240    return $theText; 
    10621241} 
    10631242 
    10641243# ========================= 
    1065 sub safeEvalPerl 
    1066 { 
    1067     my( $theText ) = @_; 
     1244sub safeEvalPerl { 
     1245    my ($theText) = @_; 
     1246 
    10681247    # Allow only simple math with operators - + * / % ( ) 
    1069     $theText =~ s/\%\s*[^\-\+\*\/0-9\.\(\)]+//go; # defuse %hash but keep modulus 
    1070     # keep only numbers and operators (shh... don't tell anyone, we support comparison operators) 
     1248    $theText =~ 
     1249      s/\%\s*[^\-\+\*\/0-9\.\(\)]+//go;    # defuse %hash but keep modulus 
     1250     # keep only numbers and operators (shh... don't tell anyone, we support comparison operators) 
    10711251    $theText =~ s/[^\!\<\=\>\-\+\*\/\%0-9e\.\(\)]*//go; 
    1072     $theText =~ s/(^|[^0-9])e/$1/go;  # remove "e"-s unless in expression such as "123e-4" 
     1252    $theText =~ 
     1253      s/(^|[^0-9])e/$1/go;  # remove "e"-s unless in expression such as "123e-4" 
    10731254    $theText =~ /(.*)/; 
    1074     $theText = $1;  # untainted variable 
    1075     return "" unless( $theText ); 
    1076     local $SIG{__DIE__} = sub { Foswiki::Func::writeDebug($_[0]); warn $_[0] }; 
     1255    $theText = $1;          # untainted variable 
     1256    return "" unless ($theText); 
     1257    local $SIG{__DIE__} = 
     1258      sub { Foswiki::Func::writeDebug( $_[0] ); warn $_[0] }; 
    10771259    my $result = eval $theText; 
    1078     if( $@ ) { 
     1260 
     1261    if ($@) { 
    10791262        $result = $@; 
    10801263        $result =~ s/[\n\r]//go; 
    1081         $result =~ s/\[[^\]]+.*view.*?\:\s?//o;                   # Cut "[Mon Mar 15 23:31:39 2004] view: " 
    1082         $result =~ s/\s?at \(eval.*?\)\sline\s?[0-9]*\.?\s?//go;  # Cut "at (eval 51) line 2." 
     1264        $result =~ 
     1265          s/\[[^\]]+.*view.*?\:\s?//o; # Cut "[Mon Mar 15 23:31:39 2004] view: " 
     1266        $result =~ s/\s?at \(eval.*?\)\sline\s?[0-9]*\.?\s?//go 
     1267          ;                            # Cut "at (eval 51) line 2." 
    10831268        $result = "ERROR: $result"; 
    10841269 
    1085     } else { 
    1086         $result = 0 unless( $result );  # logical false is "0" 
     1270    } 
     1271    else { 
     1272        $result = 0 unless ($result);    # logical false is "0" 
    10871273    } 
    10881274    return $result; 
     
    10901276 
    10911277# ========================= 
    1092 sub getListAsInteger 
    1093 { 
    1094     my( $theAttr ) = @_; 
    1095  
    1096     my $val = 0; 
    1097     my @list = getList( $theAttr ); 
    1098     (my $baz = "foo") =~ s/foo//;  # reset search vars. defensive coding 
    1099     for my $i (0 .. $#list ) { 
     1278sub getListAsInteger { 
     1279    my ($theAttr) = @_; 
     1280 
     1281    my $val  = 0; 
     1282    my @list = getList($theAttr); 
     1283    ( my $baz = "foo" ) =~ s/foo//;      # reset search vars. defensive coding 
     1284    for my $i ( 0 .. $#list ) { 
    11001285        $val = $list[$i]; 
     1286 
    11011287        # search first integer pattern, skip over HTML tags 
    1102         if( $val =~ /^\s*(?:<[^>]*>)*([\-\+]*[0-9]+).*/o ) { 
    1103             $list[$i] = $1;  # untainted variable, possibly undef 
    1104         } else { 
     1288        if ( $val =~ /^\s*(?:<[^>]*>)*([\-\+]*[0-9]+).*/o ) { 
     1289            $list[$i] = $1;              # untainted variable, possibly undef 
     1290        } 
     1291        else { 
    11051292            $list[$i] = undef; 
    11061293        } 
     
    11101297 
    11111298# ========================= 
    1112 sub getListAsFloat 
    1113 { 
    1114     my( $theAttr ) = @_; 
    1115  
    1116     my $val = 0; 
    1117     my @list = getList( $theAttr ); 
    1118     (my $baz = "foo") =~ s/foo//;  # reset search vars. defensive coding 
    1119     for my $i (0 .. $#list ) { 
     1299sub getListAsFloat { 
     1300    my ($theAttr) = @_; 
     1301 
     1302    my $val  = 0; 
     1303    my @list = getList($theAttr); 
     1304    ( my $baz = "foo" ) =~ s/foo//;    # reset search vars. defensive coding 
     1305    for my $i ( 0 .. $#list ) { 
    11201306        $val = $list[$i] || ""; 
     1307 
    11211308        # search first float pattern, skip over HTML tags 
    1122         if( $val =~ /^\s*(?:<[^>]*>)*\$?([\-\+]*[0-9\.]+).*/o ) { 
    1123             $list[$i] = $1;  # untainted variable, possibly undef 
    1124         } else { 
     1309        if ( $val =~ /^\s*(?:<[^>]*>)*\$?([\-\+]*[0-9\.]+).*/o ) { 
     1310            $list[$i] = $1;            # untainted variable, possibly undef 
     1311        } 
     1312        else { 
    11251313            $list[$i] = undef; 
    11261314        } 
     
    11301318 
    11311319# ========================= 
    1132 sub getListAsDays 
    1133 { 
    1134     my( $theAttr ) = @_; 
     1320sub getListAsDays { 
     1321    my ($theAttr) = @_; 
    11351322 
    11361323    # contributed by by SvenDowideit - 07 Mar 2003; modified by PTh 
    11371324    my $val = 0; 
    1138     my @arr = getList( $theAttr ); 
    1139     (my $baz = "foo") =~ s/foo//;  # reset search vars. defensive coding 
    1140     for my $i (0 .. $#arr ) { 
     1325    my @arr = getList($theAttr); 
     1326    ( my $baz = "foo" ) =~ s/foo//;    # reset search vars. defensive coding 
     1327    for my $i ( 0 .. $#arr ) { 
    11411328        $val = $arr[$i] || ""; 
     1329 
    11421330        # search first float pattern 
    1143         if( $val =~ /^\s*([\-\+]*[0-9\.]+)\s*d/oi ) { 
    1144             $arr[$i] = $1;      # untainted variable, possibly undef 
    1145         } elsif( $val =~ /^\s*([\-\+]*[0-9\.]+)\s*w/oi ) { 
    1146             $arr[$i] = 5 * $1;  # untainted variable, possibly undef 
    1147         } elsif( $val =~ /^\s*([\-\+]*[0-9\.]+)\s*h/oi ) { 
    1148             $arr[$i] = $1 / 8;  # untainted variable, possibly undef 
    1149         } elsif( $val =~ /^\s*([\-\+]*[0-9\.]+)/o ) { 
    1150             $arr[$i] = $1;      # untainted variable, possibly undef 
    1151         } else { 
     1331        if ( $val =~ /^\s*([\-\+]*[0-9\.]+)\s*d/oi ) { 
     1332            $arr[$i] = $1;             # untainted variable, possibly undef 
     1333        } 
     1334        elsif ( $val =~ /^\s*([\-\+]*[0-9\.]+)\s*w/oi ) { 
     1335            $arr[$i] = 5 * $1;         # untainted variable, possibly undef 
     1336        } 
     1337        elsif ( $val =~ /^\s*([\-\+]*[0-9\.]+)\s*h/oi ) { 
     1338            $arr[$i] = $1 / 8;         # untainted variable, possibly undef 
     1339        } 
     1340        elsif ( $val =~ /^\s*([\-\+]*[0-9\.]+)/o ) { 
     1341            $arr[$i] = $1;             # untainted variable, possibly undef 
     1342        } 
     1343        else { 
    11521344            $arr[$i] = undef; 
    11531345        } 
     
    11571349 
    11581350# ========================= 
    1159 sub getList 
    1160 { 
    1161     my( $theAttr ) = @_; 
     1351sub getList { 
     1352    my ($theAttr) = @_; 
    11621353 
    11631354    my @list = (); 
    1164     foreach( split( /,\s*/, $theAttr ) ) { 
    1165         if( m/\s*R([0-9]+)\:C([0-9]+)\s*\.\.+\s*R([0-9]+)\:C([0-9]+)/ ) { 
     1355    foreach ( split( /,\s*/, $theAttr ) ) { 
     1356        if (m/\s*R([0-9]+)\:C([0-9]+)\s*\.\.+\s*R([0-9]+)\:C([0-9]+)/) { 
     1357 
    11661358            # table range 
    1167             push( @list, getTableRange( $_ ) ); 
    1168         } else { 
     1359            push( @list, getTableRange($_) ); 
     1360        } 
     1361        else { 
     1362 
    11691363            # list item 
    1170             $list[$#list+1] = $_; 
     1364            $list[ $#list + 1 ] = $_; 
    11711365        } 
    11721366    } 
     
    11751369 
    11761370# ========================= 
    1177 sub getTableRange 
    1178 { 
    1179     my( $theAttr ) = @_; 
     1371sub getTableRange { 
     1372    my ($theAttr) = @_; 
    11801373 
    11811374    my @arr = (); 
    1182     if( $rPos < 0 ) { 
     1375    if ( $rPos < 0 ) { 
    11831376        return @arr; 
    11841377    } 
    11851378 
    1186     Foswiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::getTableRange( $theAttr )" ) if $debug; 
    1187     unless( $theAttr =~ /\s*R([0-9]+)\:C([0-9]+)\s*\.\.+\s*R([0-9]+)\:C([0-9]+)/ ) { 
     1379    Foswiki::Func::writeDebug( 
     1380        "- SpreadSheetPlugin::Calc::getTableRange( $theAttr )") 
     1381      if $debug; 
     1382    unless ( 
     1383        $theAttr =~ /\s*R([0-9]+)\:C([0-9]+)\s*\.\.+\s*R([0-9]+)\:C([0-9]+)/ ) 
     1384    { 
    11881385        return @arr; 
    11891386    } 
     
    11921389    my $r2 = $3 - 1; 
    11931390    my $c2 = $4 - 1; 
    1194     my $r = 0; 
    1195     my $c = 0; 
    1196     if( $c1 < 0    ) { $c1 = 0; } 
    1197     if( $c2 < 0    ) { $c2 = 0; } 
    1198     if( $c2 < $c1  ) { $c = $c1; $c1 = $c2; $c2 = $c; } 
    1199     if( $r1 > $rPos ) { $r1 = $rPos; } 
    1200     if( $r1 < 0     ) { $r1 = 0; } 
    1201     if( $r2 > $rPos ) { $r2 = $rPos; } 
    1202     if( $r2 < 0     ) { $r2 = 0; } 
    1203     if( $r2 < $r1  ) { $r = $r1; $r1 = $r2; $r2 = $r; } 
     1391    my $r  = 0; 
     1392    my $c  = 0; 
     1393    if ( $c1 < 0 ) { $c1 = 0; } 
     1394    if ( $c2 < 0 ) { $c2 = 0; } 
     1395    if ( $c2 < $c1 ) { $c = $c1; $c1 = $c2; $c2 = $c; } 
     1396    if ( $r1 > $rPos ) { $r1 = $rPos; } 
     1397    if ( $r1 < 0 )    { $r1 = 0; } 
     1398    if ( $r2 > $rPos ) { $r2 = $rPos; } 
     1399    if ( $r2 < 0 )    { $r2 = 0; } 
     1400    if ( $r2 < $r1 ) { $r = $r1; $r1 = $r2; $r2 = $r; } 
    12041401 
    12051402    my $pRow = (); 
     
    12071404        $pRow = $tableMatrix[$r]; 
    12081405        for $c ( $c1 .. $c2 ) { 
    1209             if( $c < @$pRow ) { 
     1406            if ( $c < @$pRow ) { 
    12101407                push( @arr, $$pRow[$c] ); 
    12111408            } 
    12121409        } 
    12131410    } 
    1214     Foswiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::getTableRange() returns @arr" ) if $debug; 
     1411    Foswiki::Func::writeDebug( 
     1412        "- SpreadSheetPlugin::Calc::getTableRange() returns @arr") 
     1413      if $debug; 
    12151414    return @arr; 
    12161415} 
    12171416 
    12181417# ========================= 
    1219 sub _date2serial 
    1220 { 
    1221     my ( $theText ) = @_; 
    1222  
    1223     my $sec = 0; my $min = 0; my $hour = 0; my $day = 1; my $mon = 0; my $year = 0; 
    1224  
    1225     if( $theText =~ m|([0-9]{1,2})[-\s/]+([A-Z][a-z][a-z])[-\s/]+([0-9]{4})[-\s/]+([0-9]{1,2}):([0-9]{1,2})| ) { 
    1226         # "31 Dec 2003 - 23:59", "31-Dec-2003 - 23:59", "31 Dec 2003 - 23:59 - any suffix" 
    1227         $day = $1; $mon = $mon2num{$2} || 0; $year = $3 - 1900; $hour = $4; $min = $5; 
    1228     } elsif( $theText =~ m|([0-9]{1,2})[-\s/]+([A-Z][a-z][a-z])[-\s/]+([0-9]{2,4})| ) { 
     1418sub _date2serial { 
     1419    my ($theText) = @_; 
     1420 
     1421    my $sec  = 0; 
     1422    my $min  = 0; 
     1423    my $hour = 0; 
     1424    my $day  = 1; 
     1425    my $mon  = 0; 
     1426    my $year = 0; 
     1427 
     1428    if ( $theText =~ 
     1429m|([0-9]{1,2})[-\s/]+([A-Z][a-z][a-z])[-\s/]+([0-9]{4})[-\s/]+([0-9]{1,2}):([0-9]{1,2})| 
     1430      ) 
     1431    { 
     1432 
     1433# "31 Dec 2003 - 23:59", "31-Dec-2003 - 23:59", "31 Dec 2003 - 23:59 - any suffix" 
     1434        $day  = $1; 
     1435        $mon  = $mon2num{$2} || 0; 
     1436        $year = $3 - 1900; 
     1437        $hour = $4; 
     1438        $min  = $5; 
     1439    } 
     1440    elsif ( 
     1441        $theText =~ m|([0-9]{1,2})[-\s/]+([A-Z][a-z][a-z])[-\s/]+([0-9]{2,4})| ) 
     1442    { 
     1443 
    12291444        # "31 Dec 2003", "31 Dec 03", "31-Dec-2003", "31/Dec/2003" 
    1230         $day = $1; $mon = $mon2num{$2} || 0; $year = $3; 
    1231         $year += 100 if( $year < 80 );      # "05"   --> "105" (leave "99" as is) 
    1232         $year -= 1900 if( $year >= 1900 );  # "2005" --> "105" 
    1233     } elsif( $theText =~ m|([0-9]{4})[-/\.]([0-9]{1,2})[-/\.]([0-9]{1,2})[-/\.\,\s]+([0-9]{1,2})[-\:/\.]([0-9]{1,2})[-\:/\.]([0-9]{1,2})| ) { 
     1445        $day  = $1; 
     1446        $mon  = $mon2num{$2} || 0; 
     1447        $year = $3; 
     1448        $year += 100 if ( $year < 80 );    # "05"   --> "105" (leave "99" as is) 
     1449        $year -= 1900 if ( $year >= 1900 );    # "2005" --> "105" 
     1450    } 
     1451    elsif ( $theText =~ 
     1452m|([0-9]{4})[-/\.]([0-9]{1,2})[-/\.]([0-9]{1,2})[-/\.\,\s]+([0-9]{1,2})[-\:/\.]([0-9]{1,2})[-\:/\.]([0-9]{1,2})| 
     1453      ) 
     1454    { 
     1455 
    12341456        # "2003/12/31 23:59:59", "2003-12-31-23-59-59", "2003.12.31.23.59.59" 
    1235         $year = $1 - 1900; $mon = $2 - 1; $day = $3; $hour = $4; $min = $5; $sec = $6; 
    1236     } elsif( $theText =~ m|([0-9]{4})[-/\.]([0-9]{1,2})[-/\.]([0-9]{1,2})[-/\.\,\s]+([0-9]{1,2})[-\:/\.]([0-9]{1,2})| ) { 
     1457        $year = $1 - 1900; 
     1458        $mon  = $2 - 1; 
     1459        $day  = $3; 
     1460        $hour = $4; 
     1461        $min  = $5; 
     1462        $sec  = $6; 
     1463    } 
     1464    elsif ( $theText =~ 
     1465m|([0-9]{4})[-/\.]([0-9]{1,2})[-/\.]([0-9]{1,2})[-/\.\,\s]+([0-9]{1,2})[-\:/\.]([0-9]{1,2})| 
     1466      ) 
     1467    { 
     1468 
    12371469        # "2003/12/31 23:59", "2003-12-31-23-59", "2003.12.31.23.59" 
    1238         $year = $1 - 1900; $mon = $2 - 1; $day = $3; $hour = $4; $min = $5; 
    1239     } elsif( $theText =~ m|([0-9]{4})[-/]([0-9]{1,2})[-/]([0-9]{1,2})| ) { 
     1470        $year = $1 - 1900; 
     1471        $mon  = $2 - 1; 
     1472        $day  = $3; 
     1473        $hour = $4; 
     1474        $min  = $5; 
     1475    } 
     1476    elsif ( $theText =~ m|([0-9]{4})[-/]([0-9]{1,2})[-/]([0-9]{1,2})| ) { 
     1477 
    12401478        # "2003/12/31", "2003-12-31" 
    1241         $year = $1 - 1900; $mon = $2 - 1; $day = $3; 
    1242     } elsif( $theText =~ m|([0-9]{1,2})[-/]([0-9]{1,2})[-/]([0-9]{2,4})| ) { 
    1243         # "12/31/2003", "12/31/03", "12-31-2003" 
    1244         # (shh, don't tell anyone that we support ambiguous American dates, my boss asked me to) 
    1245         $year = $3; $mon = $1 - 1; $day = $2; 
    1246         $year += 100 if( $year < 80 );      # "05"   --> "105" (leave "99" as is) 
    1247         $year -= 1900 if( $year >= 1900 );  # "2005" --> "105" 
    1248     } else { 
     1479        $year = $1 - 1900; 
     1480        $mon  = $2 - 1; 
     1481        $day  = $3; 
     1482    } 
     1483    elsif ( $theText =~ m|([0-9]{1,2})[-/]([0-9]{1,2})[-/]([0-9]{2,4})| ) { 
     1484 
     1485# "12/31/2003", "12/31/03", "12-31-2003" 
     1486# (shh, don't tell anyone that we support ambiguous American dates, my boss asked me to) 
     1487        $year = $3; 
     1488        $mon  = $1 - 1; 
     1489        $day  = $2; 
     1490        $year += 100 if ( $year < 80 );    # "05"   --> "105" (leave "99" as is) 
     1491        $year -= 1900 if ( $year >= 1900 );    # "2005" --> "105" 
     1492    } 
     1493    else { 
     1494 
    12491495        # unsupported format 
    12501496        return 0; 
    12511497    } 
    1252     if( ( $sec > 60 ) || ( $min > 59 ) || ( $hour > 23 ) || ( $day < 1 ) || ( $day > 31 ) || ( $mon > 11 ) ) { 
     1498    if (   ( $sec > 60 ) 
     1499        || ( $min > 59 ) 
     1500        || ( $hour > 23 ) 
     1501        || ( $day < 1 ) 
     1502        || ( $day > 31 ) 
     1503        || ( $mon > 11 ) ) 
     1504    { 
     1505 
    12531506        # unsupported, out of range 
    12541507        return 0; 
     
    12611514    # intended. Especially the function WORKINGDAYS suffer from this. 
    12621515    # and it also causes surprises with respect to daylight saving time 
    1263     my $timeislocal = Foswiki::Func::getPreferencesFlag( "SPREADSHEETPLUGIN_TIMEISLOCAL" ) || 0; 
     1516    my $timeislocal = 
     1517      Foswiki::Func::getPreferencesFlag("SPREADSHEETPLUGIN_TIMEISLOCAL") || 0; 
    12641518    $timeislocal = Foswiki::Func::isTrue($timeislocal); 
    12651519 
    1266     if( $theText =~ /local/i ) { 
     1520    if ( $theText =~ /local/i ) { 
    12671521        return timelocal( $sec, $min, $hour, $day, $mon, $year ); 
    1268     } elsif( $theText =~ /gmt/i ) {   
     1522    } 
     1523    elsif ( $theText =~ /gmt/i ) { 
    12691524        return timegm( $sec, $min, $hour, $day, $mon, $year ); 
    1270     } elsif( $timeislocal ) { 
     1525    } 
     1526    elsif ($timeislocal) { 
    12711527        return timelocal( $sec, $min, $hour, $day, $mon, $year ); 
    1272     } else { 
     1528    } 
     1529    else { 
    12731530        return timegm( $sec, $min, $hour, $day, $mon, $year ); 
    12741531    } 
     
    12761533 
    12771534# ========================= 
    1278 sub _serial2date 
    1279 { 
     1535sub _serial2date { 
    12801536    my ( $theTime, $theStr, $isGmt ) = @_; 
    12811537 
    1282     my( $sec, $min, $hour, $day, $mon, $year, $wday, $yday ) = localtime( $theTime ); 
    1283     (   $sec, $min, $hour, $day, $mon, $year, $wday, $yday ) = gmtime( $theTime ) if( $isGmt ); 
     1538    my ( $sec, $min, $hour, $day, $mon, $year, $wday, $yday ) = 
     1539      localtime($theTime); 
     1540    ( $sec, $min, $hour, $day, $mon, $year, $wday, $yday ) = gmtime($theTime) 
     1541      if ($isGmt); 
    12841542 
    12851543    $theStr =~ s/\$sec[o]?[n]?[d]?[s]?/sprintf("%.2u",$sec)/geoi; 
     
    13001558 
    13011559# ========================= 
    1302 sub _properSpace 
    1303 { 
    1304     my ( $theStr ) = @_; 
     1560sub _properSpace { 
     1561    my ($theStr) = @_; 
    13051562 
    13061563    # FIXME: I18N 
    13071564 
    1308     unless( $dontSpaceRE ) { 
    1309         $dontSpaceRE = &Foswiki::Func::getPreferencesValue( "DONTSPACE" ) || 
    1310                        &Foswiki::Func::getPreferencesValue( "SPREADSHEETPLUGIN_DONTSPACE" ) || 
    1311                        "CodeWarrior, MacDonald, McIntosh, RedHat, SuSE"; 
     1565    unless ($dontSpaceRE) { 
     1566        $dontSpaceRE = 
     1567             &Foswiki::Func::getPreferencesValue("DONTSPACE") 
     1568          || &Foswiki::Func::getPreferencesValue("SPREADSHEETPLUGIN_DONTSPACE") 
     1569          || "CodeWarrior, MacDonald, McIntosh, RedHat, SuSE"; 
    13121570        $dontSpaceRE =~ s/[^a-zA-Z0-9\,\s]//go; 
    1313         $dontSpaceRE = "(" . join( "|", split( /[\,\s]+/, $dontSpaceRE ) ) . ")"; 
     1571        $dontSpaceRE = 
     1572          "(" . join( "|", split( /[\,\s]+/, $dontSpaceRE ) ) . ")"; 
     1573 
    13141574        # Example: "(RedHat|McIntosh)" 
    13151575    } 
    1316     $theStr =~ s/$dontSpaceRE/_spaceWikiWord( $1, "<DONT_SPACE>" )/geo;  # e.g. "Mc<DONT_SPACE>Intosh" 
    1317     $theStr =~ s/(^|[\s\(]|\]\[)([a-zA-Z0-9]+)/$1 . _spaceWikiWord( $2, " " )/geo; 
    1318     $theStr =~ s/<DONT_SPACE>//go;  # remove "<DONT_SPACE>" marker 
     1576    $theStr =~ s/$dontSpaceRE/_spaceWikiWord( $1, "<DONT_SPACE>" )/geo 
     1577      ;    # e.g. "Mc<DONT_SPACE>Intosh" 
     1578    $theStr =~ 
     1579      s/(^|[\s\(]|\]\[)([a-zA-Z0-9]+)/$1 . _spaceWikiWord( $2, " " )/geo; 
     1580    $theStr =~ s/<DONT_SPACE>//go;    # remove "<DONT_SPACE>" marker 
    13191581 
    13201582    return $theStr; 
     
    13221584 
    13231585# ========================= 
    1324 sub _spaceWikiWord 
    1325 { 
     1586sub _spaceWikiWord { 
    13261587    my ( $theStr, $theSpacer ) = @_; 
    13271588 
     
    13331594 
    13341595# ========================= 
    1335 sub _workingDays 
    1336 { 
     1596sub _workingDays { 
    13371597    my ( $start, $end ) = @_; 
    13381598 
    13391599    # Calculate working days between two times. 
    1340     # Times are standard system times (secs since 1970).  
     1600    # Times are standard system times (secs since 1970). 
    13411601    # Working days are Monday through Friday (sorry, Israel!) 
    13421602    # A day has 60 * 60 * 24 = 86400 sec 
    13431603 
    13441604    # We allow the two dates to be swapped around 
    1345     ($start, $end) = ($end, $start) if ( $start > $end ); 
     1605    ( $start, $end ) = ( $end, $start ) if ( $start > $end ); 
    13461606    use integer; 
    13471607    my $elapsed_days = int( ( $end - $start ) / 86400 ); 
    1348     my $whole_weeks = int( $elapsed_days / 7 ); 
    1349     my $extra_days = $elapsed_days - ( $whole_weeks * 7 ); 
    1350     my $work_days = $elapsed_days - ($whole_weeks * 2); 
    1351   
    1352     for ( my $i = 0; $i < $extra_days; $i++ ) { 
    1353         my $tempwday = (gmtime( $end - $i * 86400))[6]; 
     1608    my $whole_weeks  = int( $elapsed_days / 7 ); 
     1609    my $extra_days   = $elapsed_days - ( $whole_weeks * 7 ); 
     1610    my $work_days    = $elapsed_days - ( $whole_weeks * 2 ); 
     1611 
     1612    for ( my $i = 0 ; $i < $extra_days ; $i++ ) { 
     1613        my $tempwday = ( gmtime( $end - $i * 86400 ) )[6]; 
    13541614        if ( $tempwday == 6 || $tempwday == 0 ) { 
    13551615            $work_days--; 
  • trunk/TablePlugin/lib/Foswiki/Plugins/TablePlugin.pm

    r3457 r3947  
    2727package Foswiki::Plugins::TablePlugin; 
    2828 
    29 use Foswiki::Func ();    # The plugins API 
    30 use Foswiki::Plugins (); # For the API version 
     29use Foswiki::Func    ();    # The plugins API 
     30use Foswiki::Plugins ();    # For the API version 
    3131 
    3232use vars qw( $topic $installWeb $initialised ); 
     
    3434our $VERSION = '$Rev$'; 
    3535our $RELEASE = '1.038'; 
    36 our $SHORTDESCRIPTION = 'Control attributes of tables and sorting of table columns'; 
     36our $SHORTDESCRIPTION = 
     37  'Control attributes of tables and sorting of table columns'; 
    3738our $NO_PREFS_IN_TOPIC = 1; 
    3839 
    3940sub initPlugin { 
    40     my( $web, $user ); 
     41    my ( $web, $user ); 
    4142    ( $topic, $web, $user, $installWeb ) = @_; 
    4243 
    4344    # check for Plugins.pm versions 
    44     if( $Foswiki::Plugins::VERSION < 1.026 ) { 
    45         Foswiki::Func::writeWarning( 'Version mismatch between TablePlugin and Plugins.pm' ); 
     45    if ( $Foswiki::Plugins::VERSION < 1.026 ) { 
     46        Foswiki::Func::writeWarning( 
     47            'Version mismatch between TablePlugin and Plugins.pm'); 
    4648        return 0; 
    4749    } 
     
    5860    ### my ( $text, $removed ) = @_; 
    5961 
    60     my $sort = Foswiki::Func::getPreferencesValue( 'TABLEPLUGIN_SORT' ) 
     62    my $sort = Foswiki::Func::getPreferencesValue('TABLEPLUGIN_SORT') 
    6163      || 'all'; 
    62     return unless ($sort && $sort =~ /^(all|attachments)$/) || 
    63       $_[0] =~ /%TABLE{.*?}%/; 
     64    return 
     65      unless ( $sort && $sort =~ /^(all|attachments)$/ ) 
     66      || $_[0] =~ /%TABLE{.*?}%/; 
    6467 
    6568    # on-demand inclusion 
    6669    require Foswiki::Plugins::TablePlugin::Core; 
    67     Foswiki::Plugins::TablePlugin::Core::handler( @_ ); 
     70    Foswiki::Plugins::TablePlugin::Core::handler(@_); 
    6871} 
    6972 
  • trunk/TablePlugin/lib/Foswiki/Plugins/TablePlugin/Core.pm

    r3457 r3947  
    17261726        $pluginAttrs = 
    17271727          Foswiki::Func::getPreferencesValue('TABLEPLUGIN_TABLEATTRIBUTES') 
    1728               || 'tableborder="1" cellpadding="0" cellspacing="0" valign="top" headercolor="#ffffff" headerbg="#687684" headerbgsorted="#334455" databg="#ffffff,#edf4f9" databgsorted="#f1f7fc,#ddebf6" tablerules="rows"'; 
     1728          || 'tableborder="1" cellpadding="0" cellspacing="0" valign="top" headercolor="#ffffff" headerbg="#687684" headerbgsorted="#334455" databg="#ffffff,#edf4f9" databgsorted="#f1f7fc,#ddebf6" tablerules="rows"'; 
    17291729        $prefsAttrs = Foswiki::Func::getPreferencesValue('TABLEATTRIBUTES'); 
    17301730        _setDefaults(); 
  • trunk/TinyMCEPlugin/lib/Foswiki/Plugins/TinyMCEPlugin.pm

    r3777 r3947  
    2626# allow other extensions to override them. 
    2727# PLEASE ENSURE THE PLUGIN TOPIC EXAMPLES ARE KEPT IN SYNCH! 
    28 our $defaultINIT       = <<'HERE'; 
     28our $defaultINIT = <<'HERE'; 
    2929mode:"textareas", 
    3030editor_selector : "foswikiWysiwygEdit", 
     
    7676content_css : "%PUBURLPATH%/%SYSTEMWEB%/TinyMCEPlugin/wysiwyg%IF{"$TINYMCEPLUGIN_DEBUG" then="_src"}%.css,%PUBURLPATH%/%SYSTEMWEB%/SkinTemplates/base.css,%FOSWIKI_STYLE_URL%,%FOSWIKI_COLORS_URL%" 
    7777HERE 
    78 our %defaultINIT_BROWSER     = ( 
    79     MSIE => 'paste_auto_cleanup_on_paste : true', 
    80     OPERA => '', 
    81     GECKO => 'gecko_spellcheck : true', 
     78our %defaultINIT_BROWSER = ( 
     79    MSIE   => 'paste_auto_cleanup_on_paste : true', 
     80    OPERA  => '', 
     81    GECKO  => 'gecko_spellcheck : true', 
    8282    SAFARI => '', 
    83    ); 
     83); 
    8484 
    8585use Foswiki::Func (); 
     
    180180    } 
    181181    if ($extras) { 
    182         $extras = Foswiki::Func::getPreferencesValue( 
    183             'TINYMCEPLUGIN_INIT_' . $extras ) || $defaultINIT_BROWSER{$extras}; 
     182        $extras = 
     183          Foswiki::Func::getPreferencesValue( 'TINYMCEPLUGIN_INIT_' . $extras ) 
     184          || $defaultINIT_BROWSER{$extras}; 
    184185        if ( defined $extras ) { 
    185186            $init = join( ',', ( split( ',', $init ), split( ',', $extras ) ) ); 
  • trunk/TwistyPlugin/lib/Foswiki/Plugins/TwistyPlugin.pm

    r3449 r3947  
    2626 
    2727use Foswiki::Func (); 
    28 use CGI::Cookie (); 
     28use CGI::Cookie   (); 
    2929use strict; 
    3030 
    31 use vars 
    32   qw( @modes $doneHeader $doneDefaults $twistyCount 
     31use vars qw( @modes $doneHeader $doneDefaults $twistyCount 
    3332  $prefMode $prefShowLink $prefHideLink $prefRemember); 
    3433 
     
    3635 
    3736our $RELEASE = '1.5.2'; 
    38 our $SHORTDESCRIPTION = 'Twisty section Javascript library to open/close content dynamically'; 
     37our $SHORTDESCRIPTION = 
     38  'Twisty section Javascript library to open/close content dynamically'; 
    3939our $NO_PREFS_IN_TOPIC = 1; 
    4040 
     
    100100    # Untaint is required if use locale is on 
    101101    Foswiki::Func::loadTemplate( 
    102         Foswiki::Sandbox::untaintUnchecked(lc($pluginName)) ); 
     102        Foswiki::Sandbox::untaintUnchecked( lc($pluginName) ) ); 
    103103    my $header = Foswiki::Func::expandTemplate('twisty:header'); 
    104104    Foswiki::Func::addToHEAD( $pluginName, $header ); 
     
    248248      ? '<img src="' . $imgleft . '" border="0" alt="" />' 
    249249      : ''; 
    250      
     250 
    251251    my $imgLinkTag = 
    252252        '<a href="#">' 
    253253      . $imgLeftTag 
    254       . '<span class="foswikiLinkLabel foswikiUnvisited' . $linkClass . '">' 
     254      . '<span class="foswikiLinkLabel foswikiUnvisited' 
     255      . $linkClass . '">' 
    255256      . $link 
    256257      . '</span>' 
  • trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin.pm

    r3945 r3947  
    3030use Encode (); 
    3131 
    32 use Foswiki::Func ();       # The plugins API 
    33 use Foswiki::Plugins ();    # For the API version 
     32use Foswiki::Func                              ();    # The plugins API 
     33use Foswiki::Plugins                           ();    # For the API version 
    3434use Foswiki::Plugins::WysiwygPlugin::Constants (); 
    3535 
     
    771771    my ( $session, $plugin, $verb, $response ) = @_; 
    772772    my $query = Foswiki::Func::getCgiQuery(); 
     773 
    773774    # Item1458 ignore uploads not using POST 
    774     if ($query && $query->method() && uc($query->method()) ne 'POST') { 
    775         returnRESTResult($response, 405, "Method not Allowed"); 
     775    if ( $query && $query->method() && uc( $query->method() ) ne 'POST' ) { 
     776        returnRESTResult( $response, 405, "Method not Allowed" ); 
    776777        return; 
    777778    } 
  • trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML.pm

    r3897 r3947  
    224224 
    225225sub _default { 
    226         my ( $this, $event, $text ) = @_; 
     226    my ( $this, $event, $text ) = @_; 
     227 
    227228    # Unexpected $event event from HTML::Parser; text contains '$text' 
    228         ASSERT(0); 
     229    ASSERT(0); 
    229230} 
    230231 
  • trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm

    r3945 r3947  
    446446# If this node has the specified class, insert a new "span" node with that 
    447447# class between this node and all of this node's children. 
    448 sub _moveClassToSpan 
    449 { 
    450     my $this = shift; 
     448sub _moveClassToSpan { 
     449    my $this  = shift; 
    451450    my $class = shift; 
    452451 
    453     if ( $this->{tag} and  
    454          lc($this->{tag}) ne 'span' and 
    455          $this->_removeClass($class) ) { 
    456           
    457         my $newspan = new Foswiki::Plugins::WysiwygPlugin::HTML2TML::Node( $this->{context}, 'span', { class => $class } ); 
     452    if (    $this->{tag} 
     453        and lc( $this->{tag} ) ne 'span' 
     454        and $this->_removeClass($class) ) 
     455    { 
     456 
     457        my $newspan = 
     458          new Foswiki::Plugins::WysiwygPlugin::HTML2TML::Node( $this->{context}, 
     459            'span', { class => $class } ); 
    458460        my $kid = $this->{head}; 
    459461        while ($kid) { 
  • trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/WC.pm

    r3944 r3947  
    4343use strict; 
    4444 
    45 our ( $NO_TML, $NO_HTML, $NO_BLOCK_TML, $NOP_ALL, $BLOCK_TML, $BR2NL, 
    46       $CHECKn, $CHECKw, $CHECKs, $CHECK1, $CHECK2, $NBSP, $NBBR, $TAB, $PON, $POFF, $WS, 
    47       $VERY_CLEAN, $PROTECTED, $KEEP_ENTITIES, $KEEP_WS ); 
     45our ( 
     46    $NO_TML,    $NO_HTML,    $NO_BLOCK_TML, $NOP_ALL, 
     47    $BLOCK_TML, $BR2NL,      $CHECKn,       $CHECKw, 
     48    $CHECKs,    $CHECK1,     $CHECK2,       $NBSP, 
     49    $NBBR,      $TAB,        $PON,          $POFF, 
     50    $WS,        $VERY_CLEAN, $PROTECTED,    $KEEP_ENTITIES, 
     51    $KEEP_WS 
     52); 
    4853 
    4954$NO_HTML       = 1 << 0; 
  • trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm

    r3896 r3947  
    788788        } 
    789789 
    790         $cell = ' '.$cell if $cell =~ /^(?:\*|==?|__?)[^\s]/; 
    791         $cell = $cell.' ' if $cell =~ /[^\s](?:\*|==?|__?)$/; 
    792  
    793         push( @tr, { fn => $fn, attr => $attr, text => $cell } );  
     790        $cell = ' ' . $cell if $cell =~ /^(?:\*|==?|__?)[^\s]/; 
     791        $cell = $cell . ' ' if $cell =~ /[^\s](?:\*|==?|__?)$/; 
     792 
     793        push( @tr, { fn => $fn, attr => $attr, text => $cell } ); 
    794794    } 
    795795 
  • trunk/WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm

    r3944 r3947  
    3939my $HTML2TML  = 1 << 1;    # test html => finaltml (default tml) 
    4040my $ROUNDTRIP = 1 << 2;    # test tml => => finaltml 
    41 # Note: ROUNDTRIP is *not* the same as the combination of  
     41 
     42# Note: ROUNDTRIP is *not* the same as the combination of 
    4243# HTML2TML and TML2HTML. The HTML and TML comparisons are both 
    4344# somewhat "flexible". This is necessry because, for example, 
    4445# the nature of whitespace in the TML may change. 
    45 # ROUNDTRIP tests are intended to isolate gradual degradation  
     46# ROUNDTRIP tests are intended to isolate gradual degradation 
    4647# of the TML, where TML -> HTML -> not quite TML -> HTML 
    4748# -> even worse TML, ad nauseum 
     
    6263 
    6364# Each testcase is a subhash with fields as follows: 
    64 # exec => $TML2HTML to test TML -> HTML, $HTML2TML to test HTML -> TML,  
     65# exec => $TML2HTML to test TML -> HTML, $HTML2TML to test HTML -> TML, 
    6566#   $ROUNDTRIP to test TML-> ->TML, all other bits are ignored. 
    66 #   They may be OR'd togoether to perform multiple tests.  
    67 #   For example: $TML2HTML | $HTML2TML to test both  
     67#   They may be OR'd togoether to perform multiple tests. 
     68#   For example: $TML2HTML | $HTML2TML to test both 
    6869#   TML -> HTML and HTML -> TML 
    6970# name => identifier (used to compose the testcase function name) 
     
    169170</p> 
    170171BLAH 
    171         tml  => '=Code=' 
     172        tml => '=Code=' 
    172173    }, 
    173174    { 
     
    178179    }, 
    179180    { 
    180         exec => $TML2HTML |  $HTML2TML, 
     181        exec => $TML2HTML | $HTML2TML, 
    181182        name => 'bToFromHtml', 
    182183        html => '<p><b>Bold</b></p>', 
     
    184185    }, 
    185186    { 
    186         exec => $TML2HTML |  $HTML2TML, 
     187        exec => $TML2HTML | $HTML2TML, 
    187188        name => 'strongCodeToFromHtml', 
    188189        html => <<'BLAH', 
     
    191192</p> 
    192193BLAH 
    193         tml  => '==Code==' 
     194        tml => '==Code==' 
    194195    }, 
    195196    { 
     
    201202</p> 
    202203BLAH 
    203         tml  => '==Code==' 
     204        tml => '==Code==' 
    204205    }, 
    205206    { 
     
    211212</p> 
    212213BLAH 
    213         tml  => '==Code==' 
     214        tml => '==Code==' 
    214215    }, 
    215216    { 
     
    221222</p> 
    222223BLAH 
    223         tml  => '==Code==' 
     224        tml => '==Code==' 
    224225    }, 
    225226    { 
     
    260261</table> 
    261262BLAH 
    262         tml  => <<'BLAH', 
     263        tml => <<'BLAH', 
    263264| =Code= | 
    264265| =code= at start | 
  • trunk/core/lib/Assert.pm

    r3945 r3947  
    1919 
    2020use Exporter; 
    21 our @ISA = ( 'Exporter' ); 
     21our @ISA = ('Exporter'); 
    2222 
    2323our %EXPORT_TAGS = ( 
    24     NDEBUG => ['ASSERT', 'UNTAINTED', 'TAINT', 'DEBUG'], 
    25     DEBUG  => ['ASSERT', 'UNTAINTED', 'TAINT', 'DEBUG'], 
     24    NDEBUG => [ 'ASSERT', 'UNTAINTED', 'TAINT', 'DEBUG' ], 
     25    DEBUG  => [ 'ASSERT', 'UNTAINTED', 'TAINT', 'DEBUG' ], 
    2626); 
    2727 
    2828our $VERSION = '$Rev$'; 
    29 our $DIRTY = $ENV{PATH}; # Used in TAINT 
     29our $DIRTY   = $ENV{PATH};    # Used in TAINT 
    3030 
    3131Exporter::export_tags(qw(NDEBUG DEBUG)); 
    3232 
    3333# constant.pm, alas, adds too much load time (yes, I benchmarked it) 
    34 sub ASSERTS_ON  { 1 }    # CONSTANT 
    35 sub ASSERTS_OFF { 0 }    # CONSTANT 
     34sub ASSERTS_ON  { 1 }         # CONSTANT 
     35sub ASSERTS_OFF { 0 }         # CONSTANT 
    3636 
    3737sub noop { return $_[0] } 
     
    4848    else { 
    4949        my $caller = caller; 
    50         *{ $caller . '::ASSERT' }    = \&noop; 
    51         *{ $caller . '::TAINT' }     = \&noop; 
    52         *{ $caller . '::DEBUG' }     = \&ASSERTS_OFF; 
     50        *{ $caller . '::ASSERT' } = \&noop; 
     51        *{ $caller . '::TAINT' }  = \&noop; 
     52        *{ $caller . '::DEBUG' }  = \&ASSERTS_OFF; 
    5353    } 
    5454    use strict 'refs'; 
     
    7676# Taint the datum passed and return the tainted value 
    7777sub TAINT($) { 
    78     return substr($_[0].$DIRTY, 0, length($_[0])); 
     78    return substr( $_[0] . $DIRTY, 0, length( $_[0] ) ); 
    7979} 
    8080 
  • trunk/core/lib/Foswiki.pm

    r3945 r3947  
    4646use Assert; 
    4747use Error qw( :try ); 
    48 use Monitor     (); 
    49 use Fcntl;          # File control constants e.g. O_EXCL 
    50 use CGI         (); # Always required to get html generation tags; 
    51 use Digest::MD5 (); # For passthru and validation 
     48use Monitor (); 
     49use Fcntl;    # File control constants e.g. O_EXCL 
     50use CGI         ();    # Always required to get html generation tags; 
     51use Digest::MD5 ();    # For passthru and validation 
    5252 
    5353# Components that all requests need 
     
    639639        my $cgis = $this->getCGISession(); 
    640640        if ( $cgis && $contentType eq 'text/html' ) { 
     641 
    641642            # Don't expire the validation key through login, or when 
    642643            # endpoint is an error. 
    643644            Foswiki::Validation::expireValidationKeys($cgis) 
    644                 unless ($this->{request}->action() eq 'login' 
    645                           or ( $ENV{REDIRECT_STATUS} || 0 ) >= 400); 
     645              unless ( $this->{request}->action() eq 'login' 
     646                or ( $ENV{REDIRECT_STATUS} || 0 ) >= 400 ); 
     647 
    646648            # Inject validation key in HTML forms 
    647649            $text =~ s/(<form[^>]*method=['"]POST['"][^>]*>)/ 
     
    945947    my $F; 
    946948    sysopen( $F, "$passthruFilename", O_RDWR | O_EXCL | O_CREAT, 0600 ) 
    947       || die 'Unable to open '.$Foswiki::cfg{WorkingDir} 
    948         .'/tmp for write; check the setting of {WorkingDir} in configure,' 
    949           .' and check file permissions: '.$!; 
     949      || die 'Unable to open ' 
     950      . $Foswiki::cfg{WorkingDir} 
     951      . '/tmp for write; check the setting of {WorkingDir} in configure,' 
     952      . ' and check file permissions: ' 
     953      . $!; 
    950954    $query->save($F); 
    951955    close($F); 
  • trunk/core/lib/Foswiki/AccessControlException.pm

    r3944 r3947  
    4848 
    4949use Error (); 
    50 our @ISA = ( 'Error' ); # base class 
    51  
     50our @ISA = ('Error');    # base class 
    5251 
    5352our $VERSION = '$Rev$'; 
  • trunk/core/lib/Foswiki/AggregateIterator.pm

    r3944 r3947  
    1414 
    1515use Foswiki::Iterator (); 
    16 our @ISA = ( 'Foswiki::Iterator' ); 
     16our @ISA = ('Foswiki::Iterator'); 
    1717 
    1818=begin TML 
  • trunk/core/lib/Foswiki/Attach.pm

    r3440 r3947  
    271271        # the link checkbox, Foswiki will generate the width and height 
    272272        # img parameters, speeding up the page rendering. 
    273         my $stream = $topicObject->openAttachment($attName, '<'); 
     273        my $stream = $topicObject->openAttachment( $attName, '<' ); 
    274274        my ( $nx, $ny ) = _imgsize( $stream, $attName ); 
    275275        $stream->close(); 
  • trunk/core/lib/Foswiki/Compatibility.pm

    r3944 r3947  
    387387# of anchor name generator 
    388388sub makeCompatibleAnchors { 
    389     my ( $text ) = @_; 
     389    my ($text) = @_; 
    390390    my @anchors; 
    391391 
     
    393393    # target. 
    394394    my $badAnchor = _makeBadAnchorName( $text, 0 ); 
    395     push(@anchors, $badAnchor), 
    396  
    397     # There's an even older algorithm we have to allow for 
    398     my $worseAnchor = _makeBadAnchorName( $text, 1 ); 
    399     if ($worseAnchor ne $badAnchor) { 
    400         push(@anchors, $worseAnchor ), 
     395    push( @anchors, $badAnchor ), 
     396 
     397      # There's an even older algorithm we have to allow for 
     398      my $worseAnchor = _makeBadAnchorName( $text, 1 ); 
     399    if ( $worseAnchor ne $badAnchor ) { 
     400        push( @anchors, $worseAnchor ),; 
    401401    } 
    402402 
     
    433433    $anchorName =~ s/&#?[a-zA-Z0-9]+;//g;       # remove HTML entities 
    434434    $anchorName =~ s/&//g;                      # remove & 
    435     # filter TOC excludes if not at beginning 
     435         # filter TOC excludes if not at beginning 
    436436    $anchorName =~ s/^(.+?)\s*$Foswiki::regex{headerPatternNoTOC}.*/$1/o; 
    437437 
     
    442442    # anything else than English alphanum characters in anchors 
    443443    # So we convert anything non A-Za-z0-9_ to underscores 
    444     # and limit the number consecutive of underscores to 1  
    445     # This means that pure non-English anchors will become A, A_AN1, A_AN2, ...  
     444    # and limit the number consecutive of underscores to 1 
     445    # This means that pure non-English anchors will become A, A_AN1, A_AN2, ... 
    446446    # We accept anchors starting with 0-9. It is non RFC but it works and it 
    447447    # is very important for compatibility 
    448448    $anchorName =~ s/[^A-Za-z0-9]+/_/g; 
    449     $anchorName =~ s/__+/_/g;   # remove excessive '_' chars  
    450      
     449    $anchorName =~ s/__+/_/g;             # remove excessive '_' chars 
     450 
    451451    if ( !$compatibilityMode ) { 
    452         $anchorName =~ s/^[\s#_]+//;    # no leading space nor '#', '_' 
    453     } 
    454      
    455     $anchorName =~ s/^$/A/;             # prevent empty anchor 
     452        $anchorName =~ s/^[\s#_]+//;      # no leading space nor '#', '_' 
     453    } 
     454 
     455    $anchorName =~ s/^$/A/;               # prevent empty anchor 
    456456 
    457457    # limit to 32 chars 
    458458    $anchorName =~ s/^(.{32})(.*)$/$1/; 
    459459    if ( !$compatibilityMode ) { 
    460         $anchorName =~ s/[\s_]+$//;     # no trailing space, nor '_' 
     460        $anchorName =~ s/[\s_]+$//;       # no trailing space, nor '_' 
    461461    } 
    462462    return $anchorName; 
  • trunk/core/lib/Foswiki/Configure/Checker.pm

    r3946 r3947  
    66 
    77use Foswiki::Configure::UI (); 
    8 our @ISA = ( 'Foswiki::Configure::UI' ); 
     8our @ISA = ('Foswiki::Configure::UI'); 
    99 
    1010use File::Spec (); 
    11 use CGI (); 
     11use CGI        (); 
    1212 
    1313sub guessed { 
     
    308308    else { 
    309309        my $version = `$prog -V` || ''; 
    310         if ($version !~ /Can't exec/ 
    311               # "Can't exec" has been observed on some systems, 
    312               # despite perlop saying `` returns undef if the prog 
    313               # can't be run. See Foswikitask:Item1011 
    314               && $version =~ /(\d+(\.\d+)+)/ ) { 
     310        if ( 
     311            $version !~ /Can't exec/ 
     312 
     313            # "Can't exec" has been observed on some systems, 
     314            # despite perlop saying `` returns undef if the prog 
     315            # can't be run. See Foswikitask:Item1011 
     316            && $version =~ /(\d+(\.\d+)+)/ 
     317          ) 
     318        { 
    315319            $version = $1; 
    316320        } 
  • trunk/core/lib/Foswiki/Configure/Checkers/AuthScripts.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/BasicSanity.pm

    r3945 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub new { 
     
    2929    $this->{LocalSiteDotCfg} = Foswiki::findFileOnPath('LocalSite.cfg'); 
    3030    unless ( $this->{LocalSiteDotCfg} ) { 
    31         $this->{LocalSiteDotCfg} = Foswiki::findFileOnPath('Foswiki.spec') || ''; 
     31        $this->{LocalSiteDotCfg} = Foswiki::findFileOnPath('Foswiki.spec') 
     32          || ''; 
    3233        $this->{LocalSiteDotCfg} =~ s/Foswiki\.spec/LocalSite.cfg/; 
    3334    } 
     
    6869HERE 
    6970        } 
    70         elsif ( (my $mess = $this->checkCfg(\%Foswiki::cfg)) ) { 
     71        elsif ( ( my $mess = $this->checkCfg( \%Foswiki::cfg ) ) ) { 
    7172            $result .= <<HERE; 
    7273The existing configuration file 
     
    173174 
    174175sub checkCfg { 
    175     my ($this, $entry, $keys) = @_; 
     176    my ( $this, $entry, $keys ) = @_; 
    176177    $keys ||= ''; 
    177178    my $mess = ''; 
    178179 
    179     if (ref($entry) eq 'HASH') { 
    180         foreach my $el (keys %$entry) { 
    181             $mess .= $this->checkCfg($entry->{$el}, "$keys\{$el}"); 
    182         } 
    183     } 
    184     elsif (ref($entry) eq 'ARRAY') { 
    185         foreach my $i (0..scalar(@$entry)) { 
    186             $mess .= $this->checkCfg($entry->[$i], "$keys\[$i]") 
     180    if ( ref($entry) eq 'HASH' ) { 
     181        foreach my $el ( keys %$entry ) { 
     182            $mess .= $this->checkCfg( $entry->{$el}, "$keys\{$el}" ); 
     183        } 
     184    } 
     185    elsif ( ref($entry) eq 'ARRAY' ) { 
     186        foreach my $i ( 0 .. scalar(@$entry) ) { 
     187            $mess .= $this->checkCfg( $entry->[$i], "$keys\[$i]" ); 
    187188        } 
    188189    } 
    189190    else { 
    190         if (defined $entry && $entry =~ /NOT SET/) { 
     191        if ( defined $entry && $entry =~ /NOT SET/ ) { 
    191192            $mess .= 
    192               "<div>\$Foswiki::cfg::$keys has been guessed and may be incorrect</div>"; 
     193"<div>\$Foswiki::cfg::$keys has been guessed and may be incorrect</div>"; 
    193194        } 
    194195    } 
  • trunk/core/lib/Foswiki/Configure/Checkers/CGISetup.pm

    r3946 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99use File::Spec (); 
     
    126126    else { 
    127127        $mess = 
    128           'Foswiki.pm (Version: <strong>' . $Foswiki::VERSION . '</strong>) found'; 
     128            'Foswiki.pm (Version: <strong>' 
     129          . $Foswiki::VERSION 
     130          . '</strong>) found'; 
    129131    } 
    130132    $block .= $this->setting( 'Foswiki module in @INC path', $mess ); 
  • trunk/core/lib/Foswiki/Configure/Checkers/ConfigurationLogName.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88use Foswiki::Configure::Load (); 
    99 
     
    1212 
    1313    if (   $Foswiki::cfg{ConfigurationLogName} 
    14         && $Foswiki::cfg{ConfigurationLogName}!~/^NOT SET/ ) 
     14        && $Foswiki::cfg{ConfigurationLogName} !~ /^NOT SET/ ) 
    1515    { 
    1616        my $logFile = $Foswiki::cfg{ConfigurationLogName} || ""; 
     
    2222    } 
    2323    else { 
    24         $Foswiki::cfg{ConfigurationLogName} =~ s/^NOT SET/$Foswiki::cfg{DataDir}/g; 
     24        $Foswiki::cfg{ConfigurationLogName} =~ 
     25          s/^NOT SET/$Foswiki::cfg{DataDir}/g; 
    2526        return $this->guessed(0); 
    2627    } 
  • trunk/core/lib/Foswiki/Configure/Checkers/DataDir.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/DebugFileName.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99use Foswiki::Configure::Load (); 
     
    1313 
    1414    if (   $Foswiki::cfg{DebugFileName} 
    15         && $Foswiki::cfg{DebugFileName}!~/^NOT SET/ ) 
     15        && $Foswiki::cfg{DebugFileName} !~ /^NOT SET/ ) 
    1616    { 
    1717        my $logFile = $Foswiki::cfg{DebugFileName} || ""; 
  • trunk/core/lib/Foswiki/Configure/Checkers/DefaultUrlHost.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/DispScriptUrlPath.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/Environment.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub ui { 
  • trunk/core/lib/Foswiki/Configure/Checkers/Htpasswd/Encoding.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/Htpasswd/FileName.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/LocalesDir.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/LogFileName.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99use Foswiki::Configure::Load (); 
     
    1313 
    1414    if (   $Foswiki::cfg{LogFileName} 
    15         && $Foswiki::cfg{LogFileName}!~/^NOT SET/ ) 
     15        && $Foswiki::cfg{LogFileName} !~ /^NOT SET/ ) 
    1616    { 
    1717        my $logFile = $Foswiki::cfg{LogFileName} || ""; 
  • trunk/core/lib/Foswiki/Configure/Checkers/LoginManager.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/LoginNameFilterIn.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { return shift->checkRE('{LoginNameFilterIn}'); } 
  • trunk/core/lib/Foswiki/Configure/Checkers/LowerNational.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/MailProgram.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/MimeTypesFileName.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/MinPasswordLength.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/NameFilter.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { return shift->checkRE('{NameFilter}'); } 
  • trunk/core/lib/Foswiki/Configure/Checkers/OS.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/PubDir.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/PubUrlPath.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
    1010    my $this = shift; 
    1111 
    12     unless ( $Foswiki::cfg{PubUrlPath} && $Foswiki::cfg{PubUrlPath} ne 'NOT SET' ) { 
     12    unless ( $Foswiki::cfg{PubUrlPath} 
     13        && $Foswiki::cfg{PubUrlPath} ne 'NOT SET' ) 
     14    { 
    1315        my $guess = $Foswiki::cfg{ScriptUrlPath}; 
    1416        $guess =~ s/bin$/pub/; 
  • trunk/core/lib/Foswiki/Configure/Checkers/RCS/EgrepCmd.pm

    r3944 r3947  
    22package Foswiki::Configure::Checkers::RCS::EgrepCmd; 
    33use Foswiki::Configure::Checker (); 
    4 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     4our @ISA = ('Foswiki::Configure::Checker'); 
    55 
    66use strict; 
  • trunk/core/lib/Foswiki/Configure/Checkers/RCS/ExtOption.pm

    r3944 r3947  
    22package Foswiki::Configure::Checkers::RCS::ExtOption; 
    33use Foswiki::Configure::Checker (); 
    4 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     4our @ISA = ('Foswiki::Configure::Checker'); 
    55 
    66use strict; 
  • trunk/core/lib/Foswiki/Configure/Checkers/RCS/FgrepCmd.pm

    r3944 r3947  
    22package Foswiki::Configure::Checkers::RCS::FgrepCmd; 
    33use Foswiki::Configure::Checker (); 
    4 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     4our @ISA = ('Foswiki::Configure::Checker'); 
    55 
    66use strict; 
  • trunk/core/lib/Foswiki/Configure/Checkers/RCS/SearchAlgorithm.pm

    r3944 r3947  
    22package Foswiki::Configure::Checkers::RCS::SearchAlgorithm; 
    33use Foswiki::Configure::Checker (); 
    4 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     4our @ISA = ('Foswiki::Configure::Checker'); 
    55 
    66use strict; 
  • trunk/core/lib/Foswiki/Configure/Checkers/RCS/asciiFileSuffixes.pm

    r3944 r3947  
    22package Foswiki::Configure::Checkers::RCS::asciiFileSuffixes; 
    33use Foswiki::Configure::Checker (); 
    4 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     4our @ISA = ('Foswiki::Configure::Checker'); 
    55 
    66use strict; 
  • trunk/core/lib/Foswiki/Configure/Checkers/RCS/ciCmd.pm

    r3944 r3947  
    22package Foswiki::Configure::Checkers::RCS::ciCmd; 
    33use Foswiki::Configure::Checker (); 
    4 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     4our @ISA = ('Foswiki::Configure::Checker'); 
    55 
    66use strict; 
  • trunk/core/lib/Foswiki/Configure/Checkers/RCS/ciDateCmd.pm

    r3944 r3947  
    22package Foswiki::Configure::Checkers::RCS::ciDateCmd; 
    33use Foswiki::Configure::Checker (); 
    4 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     4our @ISA = ('Foswiki::Configure::Checker'); 
    55 
    66use strict; 
  • trunk/core/lib/Foswiki/Configure/Checkers/RCS/coCmd.pm

    r3944 r3947  
    22package Foswiki::Configure::Checkers::RCS::coCmd; 
    33use Foswiki::Configure::Checker (); 
    4 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     4our @ISA = ('Foswiki::Configure::Checker'); 
    55 
    66use strict; 
  • trunk/core/lib/Foswiki/Configure/Checkers/RCS/delRevCmd.pm

    r3944 r3947  
    22package Foswiki::Configure::Checkers::RCS::delRevCmd; 
    33use Foswiki::Configure::Checker (); 
    4 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     4our @ISA = ('Foswiki::Configure::Checker'); 
    55 
    66use strict; 
  • trunk/core/lib/Foswiki/Configure/Checkers/RCS/diffCmd.pm

    r3944 r3947  
    22package Foswiki::Configure::Checkers::RCS::diffCmd; 
    33use Foswiki::Configure::Checker (); 
    4 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     4our @ISA = ('Foswiki::Configure::Checker'); 
    55 
    66use strict; 
  • trunk/core/lib/Foswiki/Configure/Checkers/RCS/histCmd.pm

    r3944 r3947  
    22package Foswiki::Configure::Checkers::RCS::histCmd; 
    33use Foswiki::Configure::Checker (); 
    4 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     4our @ISA = ('Foswiki::Configure::Checker'); 
    55 
    66use strict; 
  • trunk/core/lib/Foswiki/Configure/Checkers/RCS/infoCmd.pm

    r3944 r3947  
    22package Foswiki::Configure::Checkers::RCS::infoCmd; 
    33use Foswiki::Configure::Checker (); 
    4 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     4our @ISA = ('Foswiki::Configure::Checker'); 
    55 
    66use strict; 
  • trunk/core/lib/Foswiki/Configure/Checkers/RCS/initBinaryCmd.pm

    r3944 r3947  
    22package Foswiki::Configure::Checkers::RCS::initBinaryCmd; 
    33use Foswiki::Configure::Checker (); 
    4 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     4our @ISA = ('Foswiki::Configure::Checker'); 
    55 
    66use strict; 
  • trunk/core/lib/Foswiki/Configure/Checkers/RCS/initTextCmd.pm

    r3944 r3947  
    22package Foswiki::Configure::Checkers::RCS::initTextCmd; 
    33use Foswiki::Configure::Checker (); 
    4 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     4our @ISA = ('Foswiki::Configure::Checker'); 
    55 
    66use strict; 
  • trunk/core/lib/Foswiki/Configure/Checkers/RCS/lockCmd.pm

    r3944 r3947  
    22package Foswiki::Configure::Checkers::RCS::lockCmd; 
    33use Foswiki::Configure::Checker (); 
    4 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     4our @ISA = ('Foswiki::Configure::Checker'); 
    55 
    66use strict; 
  • trunk/core/lib/Foswiki/Configure/Checkers/RCS/rlogDateCmd.pm

    r3944 r3947  
    22package Foswiki::Configure::Checkers::RCS::rlogDateCmd; 
    33use Foswiki::Configure::Checker (); 
    4 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     4our @ISA = ('Foswiki::Configure::Checker'); 
    55 
    66use strict; 
  • trunk/core/lib/Foswiki/Configure/Checkers/RCS/tmpBinaryCmd.pm

    r3944 r3947  
    22package Foswiki::Configure::Checkers::RCS::tmpBinaryCmd; 
    33use Foswiki::Configure::Checker (); 
    4 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     4our @ISA = ('Foswiki::Configure::Checker'); 
    55 
    66use strict; 
  • trunk/core/lib/Foswiki/Configure/Checkers/RCS/unlockCmd.pm

    r3944 r3947  
    22package Foswiki::Configure::Checkers::RCS::unlockCmd; 
    33use Foswiki::Configure::Checker (); 
    4 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     4our @ISA = ('Foswiki::Configure::Checker'); 
    55 
    66use strict; 
  • trunk/core/lib/Foswiki/Configure/Checkers/Register/AllowLoginName.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/Register/NeedVerification.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
    1010    my $this = shift; 
    1111 
    12     if ( $Foswiki::cfg{Register}{NeedVerification} and !$Foswiki::cfg{EnableEmail} ) 
     12    if ( $Foswiki::cfg{Register}{NeedVerification} 
     13        and !$Foswiki::cfg{EnableEmail} ) 
    1314    { 
    1415        return $this->WARN( 
  • trunk/core/lib/Foswiki/Configure/Checkers/RegistrationApprovals.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/SafeEnvPath.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99# Unix or Linux, Windows ActiveState Perl, using PERL5SHELL set to cygwin shell 
  • trunk/core/lib/Foswiki/Configure/Checkers/ScriptSuffix.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
     
    1212    # SMELL: should check to see what the extension on _this_ script 
    1313    # is, and generate a helpful message 
    14     if ( defined $Foswiki::cfg{ScriptSuffix} && $Foswiki::cfg{ScriptSuffix} ne '' ) 
     14    if ( defined $Foswiki::cfg{ScriptSuffix} 
     15        && $Foswiki::cfg{ScriptSuffix} ne '' ) 
    1516    { 
    1617        if ( !$Foswiki::query->path_info() =~ /$Foswiki::cfg{ScriptSuffix}$/ ) { 
  • trunk/core/lib/Foswiki/Configure/Checkers/ScriptUrlPath.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/Sessions/ExpireAfter.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/Site/CharSet.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
     
    1717        $Foswiki::cfg{Site}{CharSet} =~ s/^utf8$/utf-8/i; 
    1818        $Foswiki::cfg{Site}{CharSet} =~ s/^eucjp$/euc-jp/i; 
    19         $Foswiki::cfg{Site}{CharSet} = lc( $Foswiki::cfg{Site}{CharSet}); 
     19        $Foswiki::cfg{Site}{CharSet} = lc( $Foswiki::cfg{Site}{CharSet} ); 
    2020    } 
    2121    return ''; 
  • trunk/core/lib/Foswiki/Configure/Checkers/Site/Locale.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99my @required = ( 
  • trunk/core/lib/Foswiki/Configure/Checkers/StoreImpl.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/TemplateDir.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/UploadFilter.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { return shift->checkRE('{UploadFilter}'); } 
  • trunk/core/lib/Foswiki/Configure/Checkers/UpperNational.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
  • trunk/core/lib/Foswiki/Configure/Checkers/UseClientSessions.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99my @modules = ( 
  • trunk/core/lib/Foswiki/Configure/Checkers/UseLocale.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99my @required = ( 
  • trunk/core/lib/Foswiki/Configure/Checkers/WarningFileName.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99use Foswiki::Configure::Load (); 
     
    1313 
    1414    if (   $Foswiki::cfg{WarningFileName} 
    15         && $Foswiki::cfg{WarningFileName}!~/^NOT SET/ ) 
     15        && $Foswiki::cfg{WarningFileName} !~ /^NOT SET/ ) 
    1616    { 
    1717        my $logFile = $Foswiki::cfg{WarningFileName} || ""; 
  • trunk/core/lib/Foswiki/Configure/Checkers/WebMasterEmail.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
     
    1515        ); 
    1616    } 
     17 
    1718    #    $regex{emailAddrRegex} ... 
    1819    if ( $Foswiki::cfg{WebMasterEmail} !~ 
  • trunk/core/lib/Foswiki/Configure/Checkers/WorkingDir.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Checker (); 
    7 our @ISA = ( 'Foswiki::Configure::Checker' ); 
     7our @ISA = ('Foswiki::Configure::Checker'); 
    88 
    99sub check { 
     
    1616        mkdir("$Foswiki::cfg{WorkingDir}") 
    1717          || return $this->ERROR( 
    18             "$Foswiki::cfg{WorkingDir} does not exist, and I can't create it: $!" 
     18"$Foswiki::cfg{WorkingDir} does not exist, and I can't create it: $!" 
    1919          ); 
    2020        $mess .= $this->NOTE("Created $Foswiki::cfg{WorkingDir}"); 
     
    4747        } 
    4848        else { 
    49             $mess .= $this->NOTE("Created $Foswiki::cfg{WorkingDir}/work_areas"); 
     49            $mess .= 
     50              $this->NOTE("Created $Foswiki::cfg{WorkingDir}/work_areas"); 
    5051        } 
    5152    } 
  • trunk/core/lib/Foswiki/Configure/FINDEXTENSIONS.pm

    r3944 r3947  
    88 
    99use Foswiki::Configure::Pluggable (); 
    10 our @ISA = ( 'Foswiki::Configure::Pluggable' ); 
     10our @ISA = ('Foswiki::Configure::Pluggable'); 
    1111 
    12 use Foswiki::Configure::Type (); 
     12use Foswiki::Configure::Type  (); 
    1313use Foswiki::Configure::Value (); 
    1414 
  • trunk/core/lib/Foswiki/Configure/FoswikiCfg.pm

    r3946 r3947  
    5151use Data::Dumper (); 
    5252 
    53 use Foswiki::Configure::Section (); 
    54 use Foswiki::Configure::Value (); 
     53use Foswiki::Configure::Section   (); 
     54use Foswiki::Configure::Value     (); 
    5555use Foswiki::Configure::Pluggable (); 
    56 use Foswiki::Configure::Item (); 
     56use Foswiki::Configure::Item      (); 
    5757 
    5858# Used in saving, when we need a callback. Otherwise the methods here are 
     
    113113    # parse. They are expanded to section blocks at the end. 
    114114    package SectionMarker; 
    115     @SectionMarker::ISA = ( 'Foswiki::Configure::Item' ); 
     115    @SectionMarker::ISA = ('Foswiki::Configure::Item'); 
    116116 
    117117    sub new { 
  • trunk/core/lib/Foswiki/Configure/LANGUAGES.pm

    r3944 r3947  
    66 
    77use Foswiki::Configure::Pluggable (); 
    8 our @ISA = ( 'Foswiki::Configure::Pluggable' ); 
     8our @ISA = ('Foswiki::Configure::Pluggable'); 
    99 
    1010sub new { 
  • trunk/core/lib/Foswiki/Configure/Load.pm

    r3944 r3947  
    147147    push( @errors, $@ ) if ($@); 
    148148    foreach my $dir (@INC) { 
    149         my $root; # SMELL: Not used 
     149        my $root;    # SMELL: Not used 
    150150        _loadDefaultsFrom( "$dir/Foswiki/Plugins", $root, \%read, \@errors ); 
    151151        _loadDefaultsFrom( "$dir/Foswiki/Contrib", $root, \%read, \@errors ); 
  • trunk/core/lib/Foswiki/Configure/PLUGINS.pm

    r3944 r3947  
    77 
    88use Foswiki::Configure::Pluggable (); 
    9 our @ISA = ( 'Foswiki::Configure::Pluggable' ); 
     9our @ISA = ('Foswiki::Configure::Pluggable'); 
    1010 
    1111use Foswiki::Configure::Pluggable (); 
    12 use Foswiki::Configure::Type (); 
    13 use Foswiki::Configure::Value (); 
     12use Foswiki::Configure::Type      (); 
     13use Foswiki::Configure::Value     (); 
    1414 
    1515my $scanner = Foswiki::Configure::Type::load('SELECTCLASS'); 
     
    3131        $modules{$simple} = $module; 
    3232    } 
    33     foreach my $module ( sort { lc( $a ) cmp lc( $b ) } keys %modules ) { 
     33    foreach my $module ( sort { lc($a) cmp lc($b) } keys %modules ) { 
    3434        $this->addChild( 
    3535            new Foswiki::Configure::Value( 
  • trunk/core/lib/Foswiki/Configure/Pluggable.pm

    r3944 r3947  
    1313 
    1414use Foswiki::Configure::Section (); 
    15 our @ISA = ( 'Foswiki::Configure::Section' ); 
     15our @ISA = ('Foswiki::Configure::Section'); 
    1616 
    1717sub load { 
  • trunk/core/lib/Foswiki/Configure/Root.pm

    r3944 r3947  
    88 
    99use Foswiki::Configure::Section (); 
    10 our @ISA = ( 'Foswiki::Configure::Section' ); 
     10our @ISA = ('Foswiki::Configure::Section'); 
    1111 
    1212sub new { 
  • trunk/core/lib/Foswiki/Configure/Section.pm

    r3945 r3947  
    66 
    77use Foswiki::Configure::Item (); 
    8 our @ISA = ( 'Foswiki::Configure::Item' ); 
     8our @ISA = ('Foswiki::Configure::Item'); 
    99 
    1010sub new { 
  • trunk/core/lib/Foswiki/Configure/Types/BOOLEAN.pm

    r3944 r3947  
    66 
    77use Foswiki::Configure::Type (); 
    8 our @ISA = ( 'Foswiki::Configure::Type' ); 
     8our @ISA = ('Foswiki::Configure::Type'); 
    99 
    1010sub prompt { 
  • trunk/core/lib/Foswiki/Configure/Types/COMMAND.pm

    r3944 r3947  
    66 
    77use Foswiki::Configure::Types::STRING (); 
    8 our @ISA = ( 'Foswiki::Configure::Types::STRING' ); 
     8our @ISA = ('Foswiki::Configure::Types::STRING'); 
    99 
    10101; 
  • trunk/core/lib/Foswiki/Configure/Types/LANGUAGE.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Types::BOOLEAN (); 
    7 our @ISA = ( 'Foswiki::Configure::Types::BOOLEAN' ); 
     7our @ISA = ('Foswiki::Configure::Types::BOOLEAN'); 
    88 
    99# When any language changes, delete the cache 
  • trunk/core/lib/Foswiki/Configure/Types/NUMBER.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Type (); 
    7 our @ISA = ( 'Foswiki::Configure::Type' ); 
     7our @ISA = ('Foswiki::Configure::Type'); 
    88 
    99sub prompt { 
  • trunk/core/lib/Foswiki/Configure/Types/OCTAL.pm

    r3944 r3947  
    66 
    77use Foswiki::Configure::Types::NUMBER (); 
    8 our @ISA = ( 'Foswiki::Configure::Types::NUMBER' ); 
     8our @ISA = ('Foswiki::Configure::Types::NUMBER'); 
    99 
    1010sub prompt { 
  • trunk/core/lib/Foswiki/Configure/Types/PASSWORD.pm

    r3944 r3947  
    66 
    77use Foswiki::Configure::Types::STRING (); 
    8 our @ISA = ( 'Foswiki::Configure::Types::STRING' ); 
     8our @ISA = ('Foswiki::Configure::Types::STRING'); 
    99 
    1010sub prompt { 
     
    2525        -default      => $value, 
    2626        -autocomplete => 'off', 
    27         -class   => 'foswikiInputField', 
     27        -class        => 'foswikiInputField', 
    2828    ); 
    2929} 
  • trunk/core/lib/Foswiki/Configure/Types/PATH.pm

    r3944 r3947  
    66 
    77use Foswiki::Configure::Types::STRING (); 
    8 our @ISA = ( 'Foswiki::Configure::Types::STRING' ); 
     8our @ISA = ('Foswiki::Configure::Types::STRING'); 
    99 
    10101; 
  • trunk/core/lib/Foswiki/Configure/Types/PERL.pm

    r3944 r3947  
    1616 
    1717use Foswiki::Configure::Type (); 
    18 our @ISA = ( 'Foswiki::Configure::Type' ); 
     18our @ISA = ('Foswiki::Configure::Type'); 
    1919 
    2020use Data::Dumper (); 
     
    6464sub string2value { 
    6565    my ( $this, $val ) = @_; 
    66      
    67     $val =~ s/^[[:space:]]+(.*?)$/$1/s; # strip at start 
    68     $val =~ s/^(.*?)[[:space:]]+$/$1/s; # strip at end 
    69      
     66 
     67    $val =~ s/^[[:space:]]+(.*?)$/$1/s;    # strip at start 
     68    $val =~ s/^(.*?)[[:space:]]+$/$1/s;    # strip at end 
     69 
    7070    my $s; 
    7171    if ( $s = _rvalue($val) ) { 
     
    7575"Could not parse text to a data structure (at: $s)\nPlease go back and check if the text has the correct syntax."; 
    7676    } 
    77     $val =~ /(.*)/s;    # parsed, so safe to untaint 
     77    $val =~ /(.*)/s;                       # parsed, so safe to untaint 
    7878    return eval $1; 
    7979} 
  • trunk/core/lib/Foswiki/Configure/Types/REGEX.pm

    r3944 r3947  
    55 
    66use Foswiki::Configure::Types::STRING (); 
    7 our @ISA = ( 'Foswiki::Configure::Types::STRING' ); 
     7our @ISA = ('Foswiki::Configure::Types::STRING'); 
    88 
    99sub prompt { 
  • trunk/core/lib/Foswiki/Configure/Types/SELECT.pm

    r3944 r3947  
    66 
    77use Foswiki::Configure::Type (); 
    8 our @ISA = ( 'Foswiki::Configure::Type' ); 
     8our @ISA = ('Foswiki::Configure::Type'); 
    99 
    1010sub prompt { 
     
    2222        } 
    2323    } 
    24     return CGI::Select( { name => $id, size => 1, class => 'foswikiSelect' }, $sopts ); 
     24    return CGI::Select( { name => $id, size => 1, class => 'foswikiSelect' }, 
     25        $sopts ); 
    2526} 
    2627 
  • trunk/core/lib/Foswiki/Configure/Types/SELECTCLASS.pm

    r3944 r3947  
    66 
    77use Foswiki::Configure::Types::SELECT (); 
    8 our @ISA = ( 'Foswiki::Configure::Types::SELECT' ); 
     8our @ISA = ('Foswiki::Configure::Types::SELECT'); 
    99 
    1010# generate an input field for SELECTCLASS types 
     
    4848        foreach my $place (@$places) { 
    4949            if ( opendir( DIR, $place ) ) { 
     50 
    5051                #next if ($place =~ /^\..*/); 
    5152                foreach my $subplace ( readdir DIR ) { 
    5253                    next unless $subplace =~ $pathel; 
     54 
    5355                    #next if ($subplace =~ /^\..*/); 
    5456                    push( @newplaces, $place . '/' . $1 ); 
     
    6769            foreach my $file ( readdir DIR ) { 
    6870                next unless $file =~ $leaf; 
    69                 next if ($file =~ /^\..*/); 
     71                next if ( $file =~ /^\..*/ ); 
    7072                $file =~ /^(.*)\.pm$/; 
    7173                my $module = "$place/$1"; 
  • trunk/core/lib/Foswiki/Configure/Types/STRING.pm

    r3944 r3947  
    66 
    77use Foswiki::Configure::Type (); 
    8 our @ISA = ( 'Foswiki::Configure::Type' ); 
     8our @ISA = ('Foswiki::Configure::Type'); 
    99 
    10101; 
  • trunk/core/lib/Foswiki/Configure/Types/UNKNOWN.pm

    r3944 r3947  
    99 
    1010use Foswiki::Configure::Type (); 
    11 our @ISA = ( 'Foswiki::Configure::Type' ); 
     11our @ISA = ('Foswiki::Configure::Type'); 
    1212 
    1313sub new { 
  • trunk/core/lib/Foswiki/Configure/Types/URL.pm

    r3944 r3947  
    66 
    77use Foswiki::Configure::Type (); 
    8 our @ISA = ( 'Foswiki::Configure::Type' ); 
     8our @ISA = ('Foswiki::Configure::Type'); 
    99 
    1010sub new { 
  • trunk/core/lib/Foswiki/Configure/Types/URLPATH.pm

    r3944 r3947  
    66 
    77use Foswiki::Configure::Types::STRING (); 
    8 our @ISA = ( 'Foswiki::Configure::Types::STRING' ); 
     8our @ISA = ('Foswiki::Configure::Types::STRING'); 
    99 
    10101; 
  • trunk/core/lib/Foswiki/Configure/UI.pm

    r3945 r3947  
    1313use strict; 
    1414use File::Spec (); 
    15 use FindBin (); 
     15use FindBin    (); 
    1616 
    1717our $totwarnings; 
  • trunk/core/lib/Foswiki/Configure/UIs/AUTH.pm

    r3944 r3947  
    66 
    77use Foswiki::Configure::UI (); 
    8 our @ISA = ( 'Foswiki::Configure::UI' ); 
     8our @ISA = ('Foswiki::Configure::UI'); 
    99 
    1010my %nonos = ( 
     
    2222    $scriptName =~ s/.*[\/\\]//;    # Fix for Item3511, on Win XP 
    2323 
    24     $output .= CGI::start_form( { name => 'twiki_configure', action => $scriptName, method => 'post' } ); 
     24    $output .= CGI::start_form( 
     25        { name => 'twiki_configure', action => $scriptName, method => 'post' } 
     26    ); 
    2527 
    2628    # Pass URL params through, except those below 
     
    4143        CGI::h3( CGI::strong("Your Password:") ) 
    4244          . CGI::p( 
    43                 CGI::password_field( -name=>'cfgAccess', -size =>20, -maxlength=>80, -class => 'foswikiInputField' )  
     45            CGI::password_field( 
     46                -name      => 'cfgAccess', 
     47                -size      => 20, 
     48                -maxlength => 80, 
     49                -class     => 'foswikiInputField' 
     50              ) 
    4451              . '&nbsp;' 
    4552              . CGI::submit( 
     
    107114            { class => 'foswikiFormStep' }, 
    108115            CGI::strong('New Password:') 
    109               . CGI::p( CGI::password_field( -name=>'newCfgP', -size=>20, -maxlength=>80, -class => 'foswikiInputField' ) ) 
     116              . CGI::p( 
     117                CGI::password_field( 
     118                    -name      => 'newCfgP', 
     119                    -size      => 20, 
     120                    -maxlength => 80, 
     121                    -class     => 'foswikiInputField' 
     122                ) 
     123              ) 
    110124        ); 
    111125        $output .= CGI::div( 
    112126            { class => 'foswikiFormStep' }, 
    113127            CGI::strong('Confirm Password:') 
    114               . CGI::p( CGI::password_field( -name=>'confCfgP', size=>20, -maxlength=>80, -class => 'foswikiInputField' ) ) 
     128              . CGI::p( 
     129                CGI::password_field( 
     130                    -name      => 'confCfgP', 
     131                    size       => 20, 
     132                    -maxlength => 80, 
     133                    -class     => 'foswikiInputField' 
     134                ) 
     135              ) 
    115136        ); 
    116137        $submitStr = 'Change Password and ' . $submitStr; 
  • trunk/core/lib/Foswiki/Configure/UIs/EXTEND.pm

    r3944 r3947  
    66 
    77use Foswiki::Configure::UI (); 
    8 our @ISA = ( 'Foswiki::Configure::UI' ); 
     8our @ISA = ('Foswiki::Configure::UI'); 
    99use File::Temp (); 
    1010use File::Copy (); 
    1111use File::Spec (); 
    12 use Cwd (); 
     12use Cwd        (); 
    1313 
    1414sub ui { 
     
    151151        # will just hang :-( 
    152152        chdir( $this->{root} ); 
    153         unshift( @ARGV, '-a' ); # don't prompt 
    154         unshift(@ARGV, '-d'); # yes, you can download 
    155         # Note: -r not passed to the script, so it will _not_ try to 
    156         # re-use existing archives found on disc to resolve dependencies. 
     153        unshift( @ARGV, '-a' );    # don't prompt 
     154        unshift( @ARGV, '-d' );    # yes, you can download 
     155             # Note: -r not passed to the script, so it will _not_ try to 
     156             # re-use existing archives found on disc to resolve dependencies. 
    157157        print "<pre>\n"; 
    158158        eval { 
     
    160160            do $installScript; 
    161161            use warnings 'redefine'; 
    162             die $@ if $@;            # propagate 
     162            die $@ if $@;    # propagate 
    163163        }; 
    164164        print "</pre>\n"; 
     
    218218    elsif ( $file =~ s#^locale/#$Foswiki::cfg{LocalesDir}/# ) { 
    219219    } 
    220     elsif ( $file =~ s#^(bin/\w+)$#$this->{root}$1$Foswiki::cfg{ScriptSuffix}# ) { 
     220    elsif ( $file =~ s#^(bin/\w+)$#$this->{root}$1$Foswiki::cfg{ScriptSuffix}# ) 
     221    { 
    221222 
    222223        #This makes a couple of bad assumptions 
     
    241242    if ( opendir( $d, "$dir$path" ) ) { 
    242243        foreach my $f ( grep { !/^\.*$/ } readdir $d ) { 
     244 
    243245            # Someone might upload a package that contains 
    244246            # a filename which, when passed to File::Copy, does something 
     
    246248            # SMELL: potential problem with unicode chars in file names? (yes) 
    247249            # TODO: should really compare to MANIFEST 
    248             if ($f =~ /^([-\w.,]+)$/) { 
     250            if ( $f =~ /^([-\w.,]+)$/ ) { 
    249251                $f = $1; 
    250252                if ( -d "$dir$path/$f" ) { 
     
    255257                    push( @names, "$path$f" ); 
    256258                } 
    257             } else { 
    258                 print "WARNING: skipping possibly unsafe file (not able to show it for the same reason :( )<br />\n"; 
     259            } 
     260            else { 
     261                print 
     262"WARNING: skipping possibly unsafe file (not able to show it for the same reason :( )<br />\n"; 
    259263            } 
    260264        } 
     
    305309        my @members = $zip->members(); 
    306310        foreach my $member (@members) { 
    307             my $file   = $member->fileName(); 
     311            my $file = $member->fileName(); 
    308312            $file =~ /(.*)/; 
    309             $file = $1; #yes, we must untaint 
     313            $file = $1;    #yes, we must untaint 
    310314            my $target = $file; 
    311             my $err    = $zip->extractMember( $file, $target ); 
     315            my $err = $zip->extractMember( $file, $target ); 
    312316            if ($err) { 
    313317                print "Failed to extract '$file' from zip file ", 
  • trunk/core/lib/Foswiki/Configure/UIs/EXTENSIONS.pm

    r3945 r3947  
    44 
    55use Foswiki::Configure::UI (); 
    6 our @ISA = ( 'Foswiki::Configure::UI' ); 
     6our @ISA = ('Foswiki::Configure::UI'); 
    77 
    88use Foswiki::Configure::Type (); 
     
    129129 
    130130                        # Unexpanded, assume pseudo-installed 
    131                         $link = ''; 
    132                         $text = 'pseudo-installed'; 
     131                        $link            = ''; 
     132                        $text            = 'pseudo-installed'; 
    133133                        $ext->{cssclass} = 'pseudoinstalled'; 
    134134                    } 
     
    143143                        $text = 'Re-install'; 
    144144                        $ext->{cssclass} = 'reinstall'; 
    145                         if ( $ext->{version} =~ /^\s*v?(\d+)\.(\d+)(?:\.(\d+))?/ ) 
     145                        if ( $ext->{version} =~ 
     146                            /^\s*v?(\d+)\.(\d+)(?:\.(\d+))?/ ) 
    146147                        { 
    147148 
    148149                            # Compatible version number 
    149                             my $arev = ( $1 * 1000 + $2 ) * 1000 + ($3 || 0); 
     150                            my $arev = ( $1 * 1000 + $2 ) * 1000 + ( $3 || 0 ); 
    150151                            if ( $arev > $irev ) { 
    151152                                $text = 'Upgrade'; 
     
    168169                        } 
    169170                    } 
    170                     elsif ( $ext->{installedVersion} =~ 
    171                         /(\d{4})-(\d\d)-(\d\d)/ ) { 
     171                    elsif ( 
     172                        $ext->{installedVersion} =~ /(\d{4})-(\d\d)-(\d\d)/ ) 
     173                    { 
     174 
    172175                        # ISO date 
    173176                        my $idate = d2n( $3, $2, $1 ); 
    174177                        $text = 'Re-install'; 
    175178                        $ext->{cssclass} = 'reinstall'; 
    176                         if ( $ext->{version} =~  /(\d{4})-(\d\d)-(\d\d)/ ) { 
     179                        if ( $ext->{version} =~ /(\d{4})-(\d\d)-(\d\d)/ ) { 
    177180                            my $adate = d2n( $3, $2, $1 ); 
    178181                            if ( $adate > $idate ) { 
     
    183186                    } 
    184187                    elsif ( $ext->{installedVersion} =~ 
    185                         /(\d{1,2}) ($MNAME) (\d{4})/ ) { 
     188                        /(\d{1,2}) ($MNAME) (\d{4})/ ) 
     189                    { 
    186190 
    187191                        # dd Mmm yyyy date 
    188                         my $idate = d2n( $1, $N2M{lc($2)}, $3 ); 
     192                        my $idate = d2n( $1, $N2M{ lc($2) }, $3 ); 
    189193                        $text = 'Re-install'; 
    190194                        $ext->{cssclass} = 'reinstall'; 
    191                         if ( $ext->{version} =~ 
    192                                /(\d{1,2}) ($MNAME) (\d{4})/ ) { 
    193                             my $adate = d2n( $1, $N2M{lc($2)}, $3 ); 
     195                        if ( $ext->{version} =~ /(\d{1,2}) ($MNAME) (\d{4})/ ) { 
     196                            my $adate = d2n( $1, $N2M{ lc($2) }, $3 ); 
    194197                            if ( $adate > $idate ) { 
    195198                                $text = 'Upgrade'; 
     
    206209            else { 
    207210                $text = $ext->{$f} || '-'; 
    208                 $text =~ s/!(\w+)/$1/go; # remove ! escape syntax from text 
     211                $text =~ s/!(\w+)/$1/go;    # remove ! escape syntax from text 
    209212                if ( $f eq 'topic' ) { 
    210213                    my $link = $ext->{data} . $ext->{topic}; 
    211214                    $text = CGI::a( { href => $link }, $text ); 
    212215                } 
     216 
    213217=pod 
    214218                elsif ($f eq 'image' 
     
    219223                } 
    220224=cut 
     225 
    221226            } 
    222227            my %opts = ( valign => 'top' ); 
     
    229234        if ( $ext->{installedVersion} ) { 
    230235            push @classes, 'installed'; 
    231             push( @classes, $ext->{cssclass} ) if ($ext->{cssclass});  
     236            push( @classes, $ext->{cssclass} ) if ( $ext->{cssclass} ); 
    232237            push @classes, 'twikiExtension' 
    233238              if $ext->{installedVersion} =~ /\(TWiki\)/; 
  • trunk/core/lib/Foswiki/Configure/UIs/FINDEXTENSIONS.pm

    r3944 r3947  
    66 
    77use Foswiki::Configure::UIs::Section (); 
    8 our @ISA = ( 'Foswiki::Configure::UIs::Section' ); 
     8our @ISA = ('Foswiki::Configure::UIs::Section'); 
    99use Foswiki::Configure::Type (); 
    1010 
     
    2020    my $bad = 0; 
    2121    foreach my $module 
    22       qw(Foswiki::Configure::UIs::EXTEND Foswiki::Configure::UIs::FINDEXTENSIONS) { 
     22      qw(Foswiki::Configure::UIs::EXTEND Foswiki::Configure::UIs::FINDEXTENSIONS) 
     23    { 
    2324        eval "require $module"; 
    2425        if ($@) { 
  • trunk/core/lib/Foswiki/Configure/UIs/LANGUAGES.pm

    r3944 r3947  
    44 
    55use Foswiki::Configure::UIs::Section (); 
    6 our @ISA = ( 'Foswiki::Configure::UIs::Section' ); 
     6our @ISA = ('Foswiki::Configure::UIs::Section'); 
    77 
    881; 
  • trunk/core/lib/Foswiki/Configure/UIs/PLUGINS.pm

    r3944 r3947  
    66 
    77use Foswiki::Configure::UIs::Section (); 
    8 our @ISA = ( 'Foswiki::Configure::UIs::Section' ); 
     8our @ISA = ('Foswiki::Configure::UIs::Section'); 
    99 
    10101; 
  • trunk/core/lib/Foswiki/Configure/UIs/PasswordProtected.pm

    r3944 r3947  
    99 
    1010use Foswiki::Configure::UI (); 
    11 our @ISA = ( 'Foswiki::Configure::UI' ); 
     11our @ISA = ('Foswiki::Configure::UI'); 
    1212 
    1313use Foswiki::Configure::Type (); 
     
    1818 
    1919    if ( $Foswiki::query->param('newCfgP') ) { 
    20         if ( $Foswiki::query->param('newCfgP') eq $Foswiki::query->param('confCfgP') 
    21           ) 
     20        if ( $Foswiki::query->param('newCfgP') eq 
     21            $Foswiki::query->param('confCfgP') ) 
    2222        { 
    2323            $this->{updates}{'{Password}'} = 
  • trunk/core/lib/Foswiki/Configure/UIs/Root.pm

    r3944 r3947  
    88 
    99use Foswiki::Configure::UIs::Section (); 
    10 our @ISA = ( 'Foswiki::Configure::UIs::Section' ); 
     10our @ISA = ('Foswiki::Configure::UIs::Section'); 
    1111 
    1212# Visit the nodes in a tree of configuration items, and generate 
  • trunk/core/lib/Foswiki/Configure/UIs/Section.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Configure::UI (); 
    14 our @ISA = ( 'Foswiki::Configure::UI' ); 
     14our @ISA = ('Foswiki::Configure::UI'); 
    1515 
    1616# depth == 1 is the root 
     
    6060                onclick => 'foldBlock("' . $id . '"); return false;' 
    6161            }, 
    62             '<span class="blockLinkIndicator"></span>' . $section->{headline} . $mess 
     62            '<span class="blockLinkIndicator"></span>' 
     63              . $section->{headline} 
     64              . $mess 
    6365        ); 
    6466 
  • trunk/core/lib/Foswiki/Configure/UIs/TAGS.pm

    r3944 r3947  
    66 
    77use Foswiki::Configure::UI (); 
    8 our @ISA = ( 'Foswiki::Configure::UI' ); 
     8our @ISA = ('Foswiki::Configure::UI'); 
    99 
    10 use Foswiki::Configure::Type (); 
     10use Foswiki::Configure::Type  (); 
    1111use Foswiki::Configure::Value (); 
    1212 
  • trunk/core/lib/Foswiki/Configure/UIs/UPDATE.pm

    r3944 r3947  
    66 
    77use Foswiki::Configure::UI (); 
    8 our @ISA = ( 'Foswiki::Configure::UI' ); 
     8our @ISA = ('Foswiki::Configure::UI'); 
    99 
    1010use Foswiki::Configure::FoswikiCfg (); 
     
    2828 
    2929    if ( $this->{log} && defined( $Foswiki::cfg{ConfigurationLogName} ) ) { 
    30         # configuration variable may be coming from POST, and might thus 
    31         # be tainted, we must be able to trust that the adminstrator has 
    32         # input a proper path and therefore untaint rigourously 
    33         # NOTE: this assumes configure is properly hardened through the web 
    34         # server as instructed in the fine manual! 
    35         $Foswiki::cfg{ConfigurationLogName} =~ /^(.*)$/; 
    36         $Foswiki::cfg{ConfigurationLogName} = $1; 
     30 
     31        # configuration variable may be coming from POST, and might thus 
     32        # be tainted, we must be able to trust that the adminstrator has 
     33        # input a proper path and therefore untaint rigourously 
     34        # NOTE: this assumes configure is properly hardened through the web 
     35        # server as instructed in the fine manual! 
     36        $Foswiki::cfg{ConfigurationLogName} =~ /^(.*)$/; 
     37        $Foswiki::cfg{ConfigurationLogName} = $1; 
    3738        if ( open( F, '>>', $Foswiki::cfg{ConfigurationLogName} ) ) { 
    3839            print F $this->{log}; 
  • trunk/core/lib/Foswiki/Configure/UIs/Value.pm

    r3944 r3947  
    66 
    77use Foswiki::Configure::UI (); 
    8 our @ISA = ( 'Foswiki::Configure::UI' ); 
     8our @ISA = ('Foswiki::Configure::UI'); 
    99 
    1010# Generates the appropriate HTML for getting a value to configure the 
  • trunk/core/lib/Foswiki/Configure/Value.pm

    r3945 r3947  
    66 
    77use Foswiki::Configure::Item (); 
    8 our @ISA = ( 'Foswiki::Configure::Item' ); 
     8our @ISA = ('Foswiki::Configure::Item'); 
    99 
    1010use Foswiki::Configure::Type (); 
  • trunk/core/lib/Foswiki/Engine.pm

    r3507 r3947  
    149149    my ( $param, $value, %params, @plist ); 
    150150    foreach my $pair (@pairs) { 
    151         ( $param, $value ) = split('=', $pair, 2); 
     151        ( $param, $value ) = split( '=', $pair, 2 ); 
     152 
    152153        # url decode 
    153154        if ( defined $value ) { 
     
    318319    my ( $this, $res, $req ) = @_; 
    319320    $this->finalizeCookies($res); 
    320     if ( $req && $req->method() && uc($req->method()) eq 'HEAD' ) { 
     321    if ( $req && $req->method() && uc( $req->method() ) eq 'HEAD' ) { 
    321322        $res->body(''); 
    322323        $res->deleteHeader('Content-Length'); 
  • trunk/core/lib/Foswiki/Engine/CGI.pm

    r3944 r3947  
    1616 
    1717use Foswiki::Engine (); 
    18 our @ISA = ( 'Foswiki::Engine' ); 
     18our @ISA = ('Foswiki::Engine'); 
    1919 
    2020use Assert; 
    21 use Foswiki::Request (); 
     21use Foswiki::Request         (); 
    2222use Foswiki::Request::Upload (); 
    23 use Foswiki::Response (); 
     23use Foswiki::Response        (); 
    2424 
    2525sub run { 
  • trunk/core/lib/Foswiki/Engine/CLI.pm

    r3944 r3947  
    1818 
    1919use Foswiki::Engine (); 
    20 our @ISA = ( 'Foswiki::Engine' ); 
     20our @ISA = ('Foswiki::Engine'); 
    2121 
    22 use Foswiki::Request (); 
     22use Foswiki::Request         (); 
    2323use Foswiki::Request::Upload (); 
    24 use Foswiki::Response (); 
     24use Foswiki::Response        (); 
    2525 
    2626sub run { 
  • trunk/core/lib/Foswiki/EngineException.pm

    r3944 r3947  
    1717 
    1818use Error (); 
    19 our @ISA = ( 'Error' ); 
     19our @ISA = ('Error'); 
    2020 
    2121=begin TML 
  • trunk/core/lib/Foswiki/Form.pm

    r3945 r3947  
    3333 
    3434use Foswiki::Meta (); 
    35 our @ISA = ( 'Foswiki::Meta' ); 
     35our @ISA = ('Foswiki::Meta'); 
    3636 
    3737use Assert; 
    3838use Error qw( :try ); 
    3939 
    40 use Foswiki::Form::FieldDefinition (); 
     40use Foswiki::Form::FieldDefinition     (); 
    4141use Foswiki::Form::ListFieldDefinition (); 
    4242 
  • trunk/core/lib/Foswiki/Form/Checkbox.pm

    r3944 r3947  
    55 
    66use Foswiki::Form::ListFieldDefinition (); 
    7 our @ISA = ( 'Foswiki::Form::ListFieldDefinition' ); 
     7our @ISA = ('Foswiki::Form::ListFieldDefinition'); 
    88 
    99sub new { 
  • trunk/core/lib/Foswiki/Form/Label.pm

    r3944 r3947  
    55 
    66use Foswiki::Form::FieldDefinition (); 
    7 our @ISA = ( 'Foswiki::Form::FieldDefinition' ); 
     7our @ISA = ('Foswiki::Form::FieldDefinition'); 
    88 
    99sub isEditable { 
  • trunk/core/lib/Foswiki/Form/ListFieldDefinition.pm

    r3944 r3947  
    1616 
    1717use Foswiki::Form::FieldDefinition (); 
    18 our @ISA = ( 'Foswiki::Form::FieldDefinition' ); 
     18our @ISA = ('Foswiki::Form::FieldDefinition'); 
    1919 
    2020=begin TML 
  • trunk/core/lib/Foswiki/Form/Radio.pm

    r3944 r3947  
    55 
    66use Foswiki::Form::ListFieldDefinition (); 
    7 our @ISA = ( 'Foswiki::Form::ListFieldDefinition' ); 
     7our @ISA = ('Foswiki::Form::ListFieldDefinition'); 
    88 
    99sub new { 
     
    2626    foreach my $item ( @{ $this->getOptions() } ) { 
    2727        $attrs{$item} = { 
    28             class => $this->cssClasses( 'foswikiRadioButton' ), 
     28            class => $this->cssClasses('foswikiRadioButton'), 
    2929            label => $topicObject->expandMacros($item) 
    3030        }; 
  • trunk/core/lib/Foswiki/Form/Select.pm

    r3944 r3947  
    44 
    55use Foswiki::Form::ListFieldDefinition (); 
    6 our @ISA = ( 'Foswiki::Form::ListFieldDefinition' ); 
     6our @ISA = ('Foswiki::Form::ListFieldDefinition'); 
    77 
    88use Assert; 
  • trunk/core/lib/Foswiki/Form/Text.pm

    r3944 r3947  
    55 
    66use Foswiki::Form::FieldDefinition (); 
    7 our @ISA = ( 'Foswiki::Form::FieldDefinition' ); 
     7our @ISA = ('Foswiki::Form::FieldDefinition'); 
    88 
    99sub new { 
  • trunk/core/lib/Foswiki/Form/Textarea.pm

    r3944 r3947  
    55 
    66use Foswiki::Form::FieldDefinition (); 
    7 our @ISA = ( 'Foswiki::Form::FieldDefinition' ); 
     7our @ISA = ('Foswiki::Form::FieldDefinition'); 
    88 
    99sub new { 
     
    4444        '', 
    4545        CGI::textarea( 
    46             -class   => $this->cssClasses( 'foswikiTextarea' ), 
     46            -class   => $this->cssClasses('foswikiTextarea'), 
    4747            -cols    => $this->{cols}, 
    4848            -rows    => $this->{rows}, 
  • trunk/core/lib/Foswiki/Func.pm

    r3946 r3947  
    5353use Assert; 
    5454 
    55 use Foswiki (); 
     55use Foswiki          (); 
    5656use Foswiki::Plugins (); 
    57 use Foswiki::Meta (); 
     57use Foswiki::Meta    (); 
    5858 
    5959=begin TML 
     
    10431043sub getListOfWebs { 
    10441044    my $filter = shift; 
    1045     my $web = shift; 
     1045    my $web    = shift; 
    10461046    ASSERT($Foswiki::Plugins::SESSION) if DEBUG; 
    10471047    require Foswiki::WebFilter; 
    10481048    my $f = new Foswiki::WebFilter($filter); 
    1049     return $Foswiki::Plugins::SESSION->deepWebList($f, $web); 
     1049    return $Foswiki::Plugins::SESSION->deepWebList( $f, $web ); 
    10501050} 
    10511051 
     
    16311631 
    16321632sub getAttachmentList { 
    1633     my ($web, $topic) = @_; 
     1633    my ( $web, $topic ) = @_; 
    16341634    ( $web, $topic ) = 
    16351635      $Foswiki::Plugins::SESSION->normalizeWebTopicName( $web, $topic ); 
    1636     my $topicObject = Foswiki::Meta->new( 
    1637         $Foswiki::Plugins::SESSION, $web, $topic ); 
     1636    my $topicObject = 
     1637      Foswiki::Meta->new( $Foswiki::Plugins::SESSION, $web, $topic ); 
    16381638    my $it = $topicObject->eachAttachment(); 
    16391639    return sort $it->all(); 
     
    16571657    ( $web, $topic ) = 
    16581658      $Foswiki::Plugins::SESSION->normalizeWebTopicName( $web, $topic ); 
    1659     my $topicObject = Foswiki::Meta->new( 
    1660         $Foswiki::Plugins::SESSION, $web, $topic ); 
    1661     return $topicObject->hasAttachment( $attachment ); 
     1659    my $topicObject = 
     1660      Foswiki::Meta->new( $Foswiki::Plugins::SESSION, $web, $topic ); 
     1661    return $topicObject->hasAttachment($attachment); 
    16621662} 
    16631663 
     
    23102310            $Foswiki::Plugins::SESSION = $record; 
    23112311            return $result; 
    2312         }, %options 
     2312        }, 
     2313        %options 
    23132314    ); 
    23142315} 
  • trunk/core/lib/Foswiki/I18N.pm

    r3946 r3947  
    9393              . "\nInstall the module or turn off {UserInterfaceInternationalisation}" 
    9494        ); 
    95     } else { 
    96         @Foswiki::I18N::ISA = ( 'Locale::Maketext' ); 
     95    } 
     96    else { 
     97        @Foswiki::I18N::ISA = ('Locale::Maketext'); 
    9798    } 
    9899 
  • trunk/core/lib/Foswiki/I18N/Extract.pm

    r3945 r3947  
    2020    if ($@) { 
    2121        $initError = $@; 
    22     } else { 
    23         @Foswiki::I18N::Extract::ISA = ( 'Locale::Maketext::Extract' ); 
     22    } 
     23    else { 
     24        @Foswiki::I18N::Extract::ISA = ('Locale::Maketext::Extract'); 
    2425    } 
    2526} 
     
    4142    my $session = shift; 
    4243 
    43     if (defined $initError) { 
     44    if ( defined $initError ) { 
    4445        $session->logger->log( 'warning', $initError ) if $session; 
    4546        return; 
  • trunk/core/lib/Foswiki/I18N/Fallback.pm

    r3944 r3947  
    88 
    99use Foswiki::I18N (); 
    10 our @ISA = ( 'Foswiki::I18N' ); 
     10our @ISA = ('Foswiki::I18N'); 
    1111 
    1212sub new { 
  • trunk/core/lib/Foswiki/If/Node.pm

    r3944 r3947  
    1414 
    1515use Foswiki::Query::Node (); 
    16 our @ISA = ( 'Foswiki::Query::Node' ); 
     16our @ISA = ('Foswiki::Query::Node'); 
    1717 
    1818use Foswiki::Infix::Node (); 
  • trunk/core/lib/Foswiki/If/OP_allows.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::BinaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::BinaryOP' ); 
     14our @ISA = ('Foswiki::Query::BinaryOP'); 
    1515 
    1616use Assert; 
  • trunk/core/lib/Foswiki/If/OP_context.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::UnaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::UnaryOP' ); 
     14our @ISA = ('Foswiki::Query::UnaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/If/OP_defined.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::UnaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::UnaryOP' ); 
     14our @ISA = ('Foswiki::Query::UnaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/If/OP_dollar.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::UnaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::UnaryOP' ); 
     14our @ISA = ('Foswiki::Query::UnaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/If/OP_ingroup.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::BinaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::BinaryOP' ); 
     14our @ISA = ('Foswiki::Query::BinaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/If/OP_isempty.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::UnaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::UnaryOP' ); 
     14our @ISA = ('Foswiki::Query::UnaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/If/OP_istopic.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::UnaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::UnaryOP' ); 
     14our @ISA = ('Foswiki::Query::UnaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/If/OP_isweb.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::UnaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::UnaryOP' ); 
     14our @ISA = ('Foswiki::Query::UnaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/If/Parser.pm

    r3944 r3947  
    1414 
    1515use Foswiki::Query::Parser (); 
    16 our @ISA = ( 'Foswiki::Query::Parser' ); 
     16our @ISA = ('Foswiki::Query::Parser'); 
    1717 
    1818use Assert; 
  • trunk/core/lib/Foswiki/IncludeHandlers/http.pm

    r3665 r3947  
    3838            my $topicObject = 
    3939              Foswiki::Meta->new( $session, $incWeb, $incTopic ); 
    40             unless ( $topicObject->hasAttachment( $incAtt ) ) 
    41             { 
     40            unless ( $topicObject->hasAttachment($incAtt) ) { 
    4241                return $session->_includeWarning( $control->{warn}, 
    4342                    'bad_attachment', $url ); 
     
    5352                } 
    5453            } 
    55             my $fh = $topicObject->openAttachment($incAtt, '<'); 
     54            my $fh = $topicObject->openAttachment( $incAtt, '<' ); 
    5655            local $/; 
    5756            $text = <$fh>; 
  • trunk/core/lib/Foswiki/Infix/Error.pm

    r3944 r3947  
    1313 
    1414use Error (); 
    15 our @ISA = ( 'Error' ); 
     15our @ISA = ('Error'); 
    1616 
    1717sub new { 
  • trunk/core/lib/Foswiki/Infix/Parser.pm

    r3440 r3947  
    1818use Error qw( :try ); 
    1919use Foswiki::Infix::Error (); 
    20 use Foswiki::Infix::Node (); 
     20use Foswiki::Infix::Node  (); 
    2121 
    2222# Set to 1 for debug 
  • trunk/core/lib/Foswiki/Iterator.pm

    r3300 r3947  
    5555sub next { ASSERT('Pure virtual function called') if DEBUG; } 
    5656 
    57  
    5857=begin TML 
    5958 
  • trunk/core/lib/Foswiki/Iterator/FilterIterator.pm

    r3945 r3947  
    1515 
    1616use Foswiki::Iterator (); 
    17 our @ISA = ( 'Foswiki::Iterator' ); 
     17our @ISA = ('Foswiki::Iterator'); 
    1818 
    1919=begin TML 
     
    6767    my ($this) = @_; 
    6868 
    69     return unless ($this->{iterator}->reset()); 
    70     $this->{next} = undef; 
     69    return unless ( $this->{iterator}->reset() ); 
     70    $this->{next}    = undef; 
    7171    $this->{pending} = 0; 
    7272 
  • trunk/core/lib/Foswiki/Iterator/ProcessIterator.pm

    r3944 r3947  
    1616 
    1717use Foswiki::Iterator (); 
    18 our @ISA = ( 'Foswiki::Iterator' ); 
     18our @ISA = ('Foswiki::Iterator'); 
    1919 
    2020=begin TML 
  • trunk/core/lib/Foswiki/LineIterator.pm

    r3944 r3947  
    1515 
    1616use Foswiki::Iterator (); 
    17 our @ISA = ( 'Foswiki::Iterator' ); 
     17our @ISA = ('Foswiki::Iterator'); 
    1818 
    1919=begin TML 
  • trunk/core/lib/Foswiki/ListIterator.pm

    r3944 r3947  
    1414 
    1515use Foswiki::Iterator (); 
    16 our @ISA = ( 'Foswiki::Iterator' ); 
     16our @ISA = ('Foswiki::Iterator'); 
    1717 
    1818use Assert; 
     
    3131    my ( $class, $list ) = @_; 
    3232 
    33     ASSERT(!defined($list) || UNIVERSAL::isa( $list, 'ARRAY' )) if DEBUG; 
     33    ASSERT( !defined($list) || UNIVERSAL::isa( $list, 'ARRAY' ) ) if DEBUG; 
    3434 
    3535    my $this = bless( 
     
    164164sub reset { 
    165165    my ($this) = @_; 
    166     $this->{next} = undef; 
     166    $this->{next}  = undef; 
    167167    $this->{index} = 0; 
    168168 
  • trunk/core/lib/Foswiki/Logger/PlainFile.pm

    r3944 r3947  
    66 
    77use Foswiki::Logger (); 
    8 our @ISA = ( 'Foswiki::Logger' ); 
     8our @ISA = ('Foswiki::Logger'); 
    99 
    1010=begin TML 
     
    2727=cut 
    2828 
    29 use Foswiki::Time (); 
     29use Foswiki::Time         (); 
    3030use Foswiki::ListIterator (); 
    3131 
     
    7979    package Foswiki::Logger::EventIterator; 
    8080    require Foswiki::LineIterator; 
    81     @Foswiki::Logger::EventIterator::ISA = ( 'Foswiki::LineIterator' ); 
     81    @Foswiki::Logger::EventIterator::ISA = ('Foswiki::LineIterator'); 
    8282 
    8383    sub new { 
  • trunk/core/lib/Foswiki/LoginManager.pm

    r3945 r3947  
    10061006 
    10071007sub isValidLoginName { 
    1008     my ($this, $name) = @_; 
     1008    my ( $this, $name ) = @_; 
     1009 
    10091010    # this function was erroneously marked as static 
    1010     ASSERT(! ref($name) ) if DEBUG; 
     1011    ASSERT( !ref($name) ) if DEBUG; 
    10111012    return $name =~ /$Foswiki::cfg{LoginNameFilterIn}/; 
    10121013} 
  • trunk/core/lib/Foswiki/LoginManager/ApacheLogin.pm

    r3945 r3947  
    2626 
    2727use Foswiki::LoginManager (); 
    28 our @ISA = ( 'Foswiki::LoginManager' ); 
     28our @ISA = ('Foswiki::LoginManager'); 
    2929 
    3030=begin TML 
  • trunk/core/lib/Foswiki/LoginManager/Session.pm

    r3944 r3947  
    2020 
    2121use CGI::Session (); 
    22 our @ISA = ( 'CGI::Session' ); 
     22our @ISA = ('CGI::Session'); 
    2323 
    2424*VERSION = \$CGI::Session::VERSION; 
  • trunk/core/lib/Foswiki/LoginManager/TemplateLogin.pm

    r3945 r3947  
    2121 
    2222use Foswiki::LoginManager (); 
    23 our @ISA = ( 'Foswiki::LoginManager' ); 
     23our @ISA = ('Foswiki::LoginManager'); 
    2424 
    2525=begin TML 
  • trunk/core/lib/Foswiki/Meta.pm

    r3945 r3947  
    138138    $this->{_web}   = $web; 
    139139    $this->{_topic} = $topic; 
     140 
    140141    #$this->{_text}  = undef;    # topics only 
    141142 
     
    233234    return '' unless $path; 
    234235    return $path unless $this->{_topic}; 
    235     $path .= '.'.$this->{_topic}; 
     236    $path .= '.' . $this->{_topic}; 
    236237    return $path; 
    237238} 
     
    251252    my $scope; 
    252253 
    253     unless ($this->{_web} || $this->{_topic}) { 
     254    unless ( $this->{_web} || $this->{_topic} ) { 
    254255        return $this->{_session}->{prefs}->getPreference($key); 
    255256    } 
     257 
    256258    # make sure the preferences are parsed and cached 
    257259    unless ( $this->{_preferences} ) { 
     
    293295=cut 
    294296 
    295 sub existsInStore{ 
     297sub existsInStore { 
    296298    my $this = shift; 
    297299    if ( defined $this->{_topic} ) { 
    298         return $this->{_session}->{store}->topicExists( 
    299             $this->{_web}, $this->{_topic} ); 
     300        return $this->{_session}->{store} 
     301          ->topicExists( $this->{_web}, $this->{_topic} ); 
    300302    } 
    301303    elsif ( defined $this->{_web} ) { 
    302304        return $this->{_session}->{store}->webExists( $this->{_web} ); 
    303     } else { 
    304         return 1; # the root always exists 
     305    } 
     306    else { 
     307        return 1;    # the root always exists 
    305308    } 
    306309} 
     
    361364            my $topic = $it->next(); 
    362365            next unless ( $templateWeb =~ /^_/ || $topic =~ /^Web/ ); 
    363             my $topicObject = Foswiki::Meta->load( 
    364                 $this->{_session}, $templateWeb, $topic ); 
     366            my $topicObject = 
     367              Foswiki::Meta->load( $this->{_session}, $templateWeb, $topic ); 
    365368            $topicObject->saveAs( $this->{_web}, $topic ); 
    366369        } 
     
    389392            $Foswiki::cfg{WebPrefsTopicName} ); 
    390393        my $text = $prefsTopicObject->text; 
    391         foreach my $key (keys %$opts) { 
     394        foreach my $key ( keys %$opts ) { 
    392395            $text =~ 
    393396              s/($Foswiki::regex{setRegex}$key\s*=).*?$/$1 $opts->{$key}/gm 
    394                 if defined $opts->{$key}; 
     397              if defined $opts->{$key}; 
    395398        } 
    396399        $prefsTopicObject->text($text); 
     
    483486    my ($this) = @_; 
    484487    ASSERT( !$this->{_topic} ) if DEBUG; 
    485     if (!$this->{_web}) { 
     488    if ( !$this->{_web} ) { 
     489 
    486490        # Root 
    487491        require Foswiki::ListIterator; 
    488         return new Foswiki::ListIterator([]); 
    489     } 
    490     return $this->{_session}->{store}->eachTopic( $this ); 
     492        return new Foswiki::ListIterator( [] ); 
     493    } 
     494    return $this->{_session}->{store}->eachTopic($this); 
    491495} 
    492496 
     
    507511    my ($this) = @_; 
    508512    ASSERT( $this->{_topic} ) if DEBUG; 
    509     ASSERT( $this->{_web} ) if DEBUG; 
    510     return $this->{_session}->{store}->eachAttachment( $this ); 
     513    ASSERT( $this->{_web} )   if DEBUG; 
     514    return $this->{_session}->{store}->eachAttachment($this); 
    511515} 
    512516 
     
    582586    $this->{FILEATTACHMENT} = []; 
    583587    $this->{_loadedRev} = $this->{_session}->{store}->readTopic( $this, $rev ); 
    584     #SMELL: removed see getLoadedRevision - should remove any non-numeric rev's (like the $rev stuff from svn) 
     588 
     589#SMELL: removed see getLoadedRevision - should remove any non-numeric rev's (like the $rev stuff from svn) 
    585590    $this->{_preferences}->finish() if defined $this->{_preferences}; 
    586591    $this->{_preferences} = undef; 
     
    606611    else { 
    607612 
    608         # Lazy load 
    609         #SMELL: will reload repeatedly if there is no topic text - ie if the topic is all META 
     613# Lazy load 
     614#SMELL: will reload repeatedly if there is no topic text - ie if the topic is all META 
    610615        $this->reload() unless defined( $this->{_text} ); 
    611616    } 
     
    11751180    undef $reason; 
    11761181 
    1177     print STDERR "Check $mode access $cUID to ".$this->getPath()."\n" 
     1182    print STDERR "Check $mode access $cUID to " . $this->getPath() . "\n" 
    11781183      if MONITOR_ACLS; 
    11791184 
     
    14031408 
    14041409sub _atomicLock { 
    1405     my ($this, $cUID) = @_; 
     1410    my ( $this, $cUID ) = @_; 
    14061411    if ( $this->{_topic} ) { 
    14071412 
    14081413        # Topic 
    1409         $this->{_session}->{store}->lockTopic($this, $cUID); 
     1414        $this->{_session}->{store}->lockTopic( $this, $cUID ); 
    14101415    } 
    14111416    else { 
     
    14291434 
    14301435sub _atomicUnlock { 
    1431     my ($this, $cUID) = @_; 
     1436    my ( $this, $cUID ) = @_; 
    14321437    if ( $this->{_topic} ) { 
    1433         $this->{_session}->{store}->unlockTopic($this, $cUID); 
     1438        $this->{_session}->{store}->unlockTopic( $this, $cUID ); 
    14341439    } 
    14351440    else { 
     
    15311536 
    15321537sub deleteMostRecentRevision { 
    1533     my ($this, %opts) = @_; 
     1538    my ( $this, %opts ) = @_; 
    15341539    my $rev; 
    15351540    my $cUID = $opts{user} || $this->{_session}->{user}; 
     
    15371542    $this->_atomicLock($cUID); 
    15381543    try { 
    1539         $rev = $this->{_session}->{store}->delRev($this, $cUID); 
     1544        $rev = $this->{_session}->{store}->delRev( $this, $cUID ); 
    15401545    } 
    15411546    finally { 
     
    15871592        $extra .= Foswiki::Time::formatTime( $info->{date}, '$rcs', 'gmtime' ); 
    15881593        $extra .= ' minor' if ( $opts{minor} ); 
    1589         $this->{_session}->writeLog( 
    1590             $opts{forcedate} ? 'cmd' : 'save', 
    1591             $this->getPath(), 
    1592             $extra, $cUID 
    1593         ); 
     1594        $this->{_session}->writeLog( $opts{forcedate} ? 'cmd' : 'save', 
     1595            $this->getPath(), $extra, $cUID ); 
    15941596    } 
    15951597} 
     
    16611663 
    16621664    if ( $attachment 
    1663            && !$store->attachmentExists( $this, $attachment ) ) { 
     1665        && !$store->attachmentExists( $this, $attachment ) ) 
     1666    { 
    16641667        throw Error::Simple( 'No such attachment ' 
    16651668              . $this->{_web} . '.' 
     
    17761779 
    17771780sub onTick { 
    1778     my ($this, $time) = @_; 
    1779  
    1780     if (!$this->{_topic}) { 
     1781    my ( $this, $time ) = @_; 
     1782 
     1783    if ( !$this->{_topic} ) { 
    17811784        my $it = $this->eachWeb(); 
    1782         while ($it->hasNext()) { 
     1785        while ( $it->hasNext() ) { 
    17831786            my $web = $it->next(); 
    1784             $web = $this->getPath()."/$web" if $this->getPath(); 
    1785             my $m = new Foswiki::Meta($this->{_session}, $web); 
     1787            $web = $this->getPath() . "/$web" if $this->getPath(); 
     1788            my $m = new Foswiki::Meta( $this->{_session}, $web ); 
    17861789            $m->onTick($time); 
    17871790        } 
    17881791        $it = $this->eachTopic(); 
    1789         while ($it->hasNext()) { 
     1792        while ( $it->hasNext() ) { 
    17901793            my $topic = $it->next(); 
    1791             my $topicObject = new Foswiki::Meta( 
    1792                 $this->{_session}, $this->getPath(), $topic); 
     1794            my $topicObject = 
     1795              new Foswiki::Meta( $this->{_session}, $this->getPath(), $topic ); 
    17931796            $topicObject->onTick($time); 
    17941797        } 
     1798 
    17951799        # Clean up spurious leases that may have been left behind 
    17961800        # during cancelled topic creation 
    1797         $this->{_session}->{store} 
    1798           ->removeSpuriousLeases( $this->getPath() ); 
    1799     } else { 
     1801        $this->{_session}->{store}->removeSpuriousLeases( $this->getPath() ); 
     1802    } 
     1803    else { 
    18001804        my $lease = $this->getLease(); 
    1801         if( $lease && $lease->{expires} < $time) { 
     1805        if ( $lease && $lease->{expires} < $time ) { 
    18021806            $this->clearLease(); 
    18031807        } 
     
    18691873        $action = 'upload'; 
    18701874 
    1871         $attrs  = { 
     1875        $attrs = { 
    18721876            name        => $opts{name}, 
    18731877            attachment  => $opts{name}, 
     
    18791883 
    18801884        if ( $plugins->haveHandlerFor('beforeAttachmentSaveHandler') ) { 
     1885 
    18811886            # SMELL: the attachment handler requires a file on disc 
    18821887            # Because of the way CGI works, the stream is actually attached 
     
    19001905        try { 
    19011906            $this->{_session}->{store} 
    1902               ->saveAttachment( 
    1903                   $this, $opts{name}, $opts{stream}, 
    1904                   $opts{author} || $this->{_session}->{user}); 
    1905         } catch Error with { 
     1907              ->saveAttachment( $this, $opts{name}, $opts{stream}, 
     1908                $opts{author} || $this->{_session}->{user} ); 
     1909        } 
     1910        catch Error with { 
    19061911            $error = shift; 
    19071912        }; 
     
    19091914        my $fileVersion = $this->getMaxRevNo( $opts{name} ); 
    19101915        $attrs->{version} = $fileVersion; 
    1911         $attrs->{path} = $opts{filepath} if ( defined( $opts{filepath} ) ); 
    1912         $attrs->{size} = $opts{filesize} if ( defined( $opts{filesize} ) ); 
    1913         $attrs->{date} = $opts{filedate} if ( defined( $opts{filedate} ) ); 
     1916        $attrs->{path}    = $opts{filepath} if ( defined( $opts{filepath} ) ); 
     1917        $attrs->{size}    = $opts{filesize} if ( defined( $opts{filesize} ) ); 
     1918        $attrs->{date}    = $opts{filedate} if ( defined( $opts{filedate} ) ); 
    19141919 
    19151920        if ( $plugins->haveHandlerFor('afterAttachmentSaveHandler') ) { 
    19161921            $plugins->dispatch( 'afterAttachmentSaveHandler', $attrs, 
    1917                                 $this->{_topic}, $this->{_web}, 
    1918                                 $error ? $error->{-text} : undef ); 
     1922                $this->{_topic}, $this->{_web}, 
     1923                $error ? $error->{-text} : undef ); 
    19191924        } 
    19201925    } 
     
    19941999 
    19952000sub testAttachment { 
    1996     my ($this, $attachment, $test) = @_; 
    1997  
    1998     $test =~ /(\w)/; $test = $1; 
    1999     if ($test eq 'r') { 
     2001    my ( $this, $attachment, $test ) = @_; 
     2002 
     2003    $test =~ /(\w)/; 
     2004    $test = $1; 
     2005    if ( $test eq 'r' ) { 
    20002006        return $this->haveAccess('VIEW'); 
    2001     } elsif ($test eq 'w') { 
     2007    } 
     2008    elsif ( $test eq 'w' ) { 
    20022009        return $this->haveAccess('CHANGE'); 
    20032010    } 
    20042011 
    2005     return return $this->{_session}->{store} 
    2006       ->testAttachment($this, $attachment, $test); 
     2012    return 
     2013      return $this->{_session}->{store} 
     2014      ->testAttachment( $this, $attachment, $test ); 
    20072015} 
    20082016 
     
    20322040 
    20332041sub openAttachment { 
    2034     my ($this, $attachment, $mode, @opts) = @_; 
     2042    my ( $this, $attachment, $mode, @opts ) = @_; 
    20352043 
    20362044    return $this->{_session}->{store} 
    2037       ->openAttachment($this, $attachment, $mode, @opts); 
     2045      ->openAttachment( $this, $attachment, $mode, @opts ); 
    20382046 
    20392047} 
     
    20632071    try { 
    20642072        $this->{_session}->{store} 
    2065           ->moveAttachment( $this, $name, $to, $newName, $cUID); 
     2073          ->moveAttachment( $this, $name, $to, $newName, $cUID ); 
    20662074        $this->reload(); 
    20672075        $to->reload(); 
    2068     } finally { 
     2076    } 
     2077    finally { 
    20692078        $to->_atomicUnlock($cUID); 
    20702079        $this->_atomicUnlock($cUID); 
  • trunk/core/lib/Foswiki/Net/UserCredAgent.pm

    r3944 r3947  
    99 
    1010use LWP::UserAgent (); 
    11 our @ISA = ( 'LWP::UserAgent' ); 
     11our @ISA = ('LWP::UserAgent'); 
    1212 
    1313sub new { 
  • trunk/core/lib/Foswiki/OopsException.pm

    r3944 r3947  
    8888 
    8989use Error (); 
    90 our @ISA = ( 'Error' ); 
     90our @ISA = ('Error'); 
    9191 
    9292use Assert; 
  • trunk/core/lib/Foswiki/Prefs.pm

    r3877 r3947  
    464464        next 
    465465          unless defined $stack->backAtLevel(-2)->getLocal($k) 
    466               && !$stack->finalizedBefore($k, -2); 
     466              && !$stack->finalizedBefore( $k, -2 ); 
    467467        my $val = 
    468468          Foswiki::entityEncode( $stack->backAtLevel(-2)->getLocal($k) ); 
  • trunk/core/lib/Foswiki/Prefs/BaseBackend.pm

    r3805 r3947  
    2424 
    2525sub new { 
    26     my ($proto, $values) = @_; 
     26    my ( $proto, $values ) = @_; 
    2727    my $class = ref($proto) || $proto; 
    2828 
     
    111111 
    112112sub cleanupInsertValue { 
    113     my ($this, $value_ref) = @_; 
    114      
    115     $$value_ref =~ tr/\r//d;                 # Delete \r 
    116     $$value_ref =~ tr/\t/ /;                 # replace TAB by space 
    117     $$value_ref =~ s/([^\\])\\n/$1\n/g;      # replace \n by new line 
    118     $$value_ref =~ s/([^\\])\\\\n/$1\\n/g;   # replace \\n by \n 
    119     $$value_ref =~ tr/`//d;                  # filter out dangerous chars 
     113    my ( $this, $value_ref ) = @_; 
     114 
     115    $$value_ref =~ tr/\r//d;                  # Delete \r 
     116    $$value_ref =~ tr/\t/ /;                  # replace TAB by space 
     117    $$value_ref =~ s/([^\\])\\n/$1\n/g;       # replace \n by new line 
     118    $$value_ref =~ s/([^\\])\\\\n/$1\\n/g;    # replace \\n by \n 
     119    $$value_ref =~ tr/`//d;                   # filter out dangerous chars 
    120120} 
    121121 
  • trunk/core/lib/Foswiki/Prefs/HASH.pm

    r3945 r3947  
    2121 
    2222sub new { 
    23     my ($proto, $values) = @_; 
     23    my ( $proto, $values ) = @_; 
    2424 
    2525    my $this = $proto->SUPER::new(); 
    26     while (my ($key, $value) = each %$values) { 
    27         $this->insert('Set', $key, $value); 
     26    while ( my ( $key, $value ) = each %$values ) { 
     27        $this->insert( 'Set', $key, $value ); 
    2828    } 
    2929 
     
    4343 
    4444sub get { 
    45     my ($this, $key) = @_; 
     45    my ( $this, $key ) = @_; 
    4646    return $this->{$key}; 
    4747} 
     
    5454    my ( $this, $type, $key, $value ) = @_; 
    5555 
    56     $this->cleanupInsertValue(\$value); 
     56    $this->cleanupInsertValue( \$value ); 
    5757    $this->{$key} = $value; 
    5858    return 1; 
  • trunk/core/lib/Foswiki/Prefs/Parser.pm

    r3440 r3947  
    7474        # PREFERENCE_<pref title> but that's all I can work out :-( 
    7575        # I can't find any clues in Codev either. 
    76         if (defined($field->{title})) { 
     76        if ( defined( $field->{title} ) ) { 
    7777            $prefs->insert( $type, 'PREFERENCE_' . $field->{title}, $value ); 
    7878        } 
  • trunk/core/lib/Foswiki/Prefs/Stack.pm

    r3945 r3947  
    312312    foreach my $p ( keys %{ $this->{'map'} } ) { 
    313313        $this->{'map'}{$p} &= $mask; 
    314          
     314 
    315315        while ( length( $this->{'map'}{$p} ) > 0 
    316316            && ord( substr( $this->{'map'}{$p}, -1 ) ) == 0 ) 
     
    318318            substr( $this->{'map'}{$p}, -1 ) = ''; 
    319319        } 
    320          
     320 
    321321        delete $this->{'map'}{$p} if length( $this->{'map'}{$p} ) == 0; 
    322322    } 
  • trunk/core/lib/Foswiki/Prefs/TopicRAM.pm

    r3944 r3947  
    7979    my ( $this, $type, $key, $value ) = @_; 
    8080 
    81     $this->cleanupInsertValue(\$value); 
     81    $this->cleanupInsertValue( \$value ); 
    8282 
    8383    my $index = $type eq 'Set' ? 'values' : 'local'; 
  • trunk/core/lib/Foswiki/Prefs/Web.pm

    r3877 r3947  
    2929    my $proto = shift; 
    3030    my $class = ref($proto) || $proto; 
    31     my ($stack, $level) = @_; 
    32     my $this  = { 
     31    my ( $stack, $level ) = @_; 
     32    my $this = { 
    3333        stack => $stack, 
    3434        level => $level, 
     
    9393 
    9494sub cloneStack { 
    95     my ($this, $level) = @_; 
     95    my ( $this, $level ) = @_; 
    9696    return $this->{stack}->clone($level); 
    9797} 
     
    106106 
    107107sub get { 
    108     my ($this, $key) = @_; 
     108    my ( $this, $key ) = @_; 
    109109    $this->{stack}->getPreference( $key, $this->{level} ); 
    110110} 
  • trunk/core/lib/Foswiki/Query/Node.pm

    r3944 r3947  
    2727 
    2828use Foswiki::Infix::Node (); 
    29 our @ISA = ( 'Foswiki::Infix::Node' ); 
     29our @ISA = ('Foswiki::Infix::Node'); 
    3030 
    3131# 1 for debug 
  • trunk/core/lib/Foswiki/Query/OP_and.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::BinaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::BinaryOP' ); 
     14our @ISA = ('Foswiki::Query::BinaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/Query/OP_d2n.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::UnaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::UnaryOP' ); 
     14our @ISA = ('Foswiki::Query::UnaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/Query/OP_dot.pm

    r3945 r3947  
    1212 
    1313use Foswiki::Query::BinaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::BinaryOP' ); 
     14our @ISA = ('Foswiki::Query::BinaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/Query/OP_eq.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::BinaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::BinaryOP' ); 
     14our @ISA = ('Foswiki::Query::BinaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/Query/OP_gt.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::BinaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::BinaryOP' ); 
     14our @ISA = ('Foswiki::Query::BinaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/Query/OP_gte.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::BinaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::BinaryOP' ); 
     14our @ISA = ('Foswiki::Query::BinaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/Query/OP_lc.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::UnaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::UnaryOP' ); 
     14our @ISA = ('Foswiki::Query::UnaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/Query/OP_length.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::UnaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::UnaryOP' ); 
     14our @ISA = ('Foswiki::Query::UnaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/Query/OP_like.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::BinaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::BinaryOP' ); 
     14our @ISA = ('Foswiki::Query::BinaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/Query/OP_lt.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::BinaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::BinaryOP' ); 
     14our @ISA = ('Foswiki::Query::BinaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/Query/OP_lte.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::BinaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::BinaryOP' ); 
     14our @ISA = ('Foswiki::Query::BinaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/Query/OP_ne.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::BinaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::BinaryOP' ); 
     14our @ISA = ('Foswiki::Query::BinaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/Query/OP_not.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::UnaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::UnaryOP' ); 
     14our @ISA = ('Foswiki::Query::UnaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/Query/OP_ob.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::UnaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::UnaryOP' ); 
     14our @ISA = ('Foswiki::Query::UnaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/Query/OP_or.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::BinaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::BinaryOP' ); 
     14our @ISA = ('Foswiki::Query::BinaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/Query/OP_ref.pm

    r3945 r3947  
    1313 
    1414use Foswiki::Query::BinaryOP (); 
    15 our @ISA = ( 'Foswiki::Query::BinaryOP' ); 
     15our @ISA = ('Foswiki::Query::BinaryOP'); 
    1616 
    1717sub new { 
  • trunk/core/lib/Foswiki/Query/OP_uc.pm

    r3944 r3947  
    1212 
    1313use Foswiki::Query::UnaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::UnaryOP' ); 
     14our @ISA = ('Foswiki::Query::UnaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/Query/OP_where.pm

    r3945 r3947  
    1212 
    1313use Foswiki::Query::BinaryOP (); 
    14 our @ISA = ( 'Foswiki::Query::BinaryOP' ); 
     14our @ISA = ('Foswiki::Query::BinaryOP'); 
    1515 
    1616sub new { 
  • trunk/core/lib/Foswiki/Query/Parser.pm

    r3944 r3947  
    1515 
    1616use Foswiki::Infix::Parser (); 
    17 our @ISA = ( 'Foswiki::Infix::Parser' ); 
     17our @ISA = ('Foswiki::Infix::Parser'); 
    1818 
    1919use Foswiki::Query::Node (); 
  • trunk/core/lib/Foswiki/Render.pm

    r3618 r3947  
    137137        $text =~ s/\$web/$pWeb/g; 
    138138        $text =~ s/\$topic/$pTopic/g; 
    139         if( ! $depth or $currentDepth == $depth ) { 
     139 
     140        if ( !$depth or $currentDepth == $depth ) { 
    140141            unshift( @stack, $text ); 
    141142        } 
     
    336337    $row =~ s/\t/   /g;    # change tabs to space 
    337338    $row =~ s/\s*$//;      # remove trailing spaces 
    338                               # calc COLSPAN 
     339                           # calc COLSPAN 
    339340    $row =~ s/(\|\|+)/ 
    340341      'colspan'.$Foswiki::TranslationToken.length($1).'|'/ge; 
     
    397398    $text =~ s/$Foswiki::regex{headerPatternNoTOC}//o; 
    398399 
    399     my $html = '<nop><h' . $level . '>' 
    400       . $this->_makeAnchorTarget( $topicObject, $text ) 
    401         . ' ' . $text . ' </h' . $level . '>'; 
     400    my $html = 
     401        '<nop><h'  
     402      . $level . '>' 
     403      . $this->_makeAnchorTarget( $topicObject, $text ) . ' ' 
     404      . $text . ' </h' 
     405      . $level . '>'; 
    402406 
    403407    return $html; 
     
    406410# Make an anchor that can be used as the target of links. 
    407411sub _makeAnchorTarget { 
    408     my ($this, $topicObject, $text) = @_; 
    409  
    410     my $goodAnchor = $this->_makeAnchorName( $text ); 
    411     my $html = CGI::a( { 
    412         name => $this->_makeAnchorNameUnique($topicObject, $goodAnchor), 
    413     }, '' ); 
    414  
    415     if ($Foswiki::cfg{RequireCompatibleAnchors}) { 
     412    my ( $this, $topicObject, $text ) = @_; 
     413 
     414    my $goodAnchor = $this->_makeAnchorName($text); 
     415    my $html       = CGI::a( 
     416        { name => $this->_makeAnchorNameUnique( $topicObject, $goodAnchor ), }, 
     417        '' 
     418    ); 
     419 
     420    if ( $Foswiki::cfg{RequireCompatibleAnchors} ) { 
     421 
    416422        # Add in extra anchors compatible with old formats, as required 
    417423        require Foswiki::Compatibility; 
    418         my @extras = Foswiki::Compatibility::makeCompatibleAnchors( $text ); 
    419         foreach my $extra ( @extras ) { 
    420             next if ($extra eq $goodAnchor); 
    421             $html .= CGI::a( { 
    422                 name => $this->_makeAnchorNameUnique( $topicObject, $extra ), 
    423             }, '' ); 
     424        my @extras = Foswiki::Compatibility::makeCompatibleAnchors($text); 
     425        foreach my $extra (@extras) { 
     426            next if ( $extra eq $goodAnchor ); 
     427            $html .= CGI::a( 
     428                { 
     429                    name => 
     430                      $this->_makeAnchorNameUnique( $topicObject, $extra ), 
     431                }, 
     432                '' 
     433            ); 
    424434        } 
    425435    } 
     
    441451 
    442452    if ( $text =~ /^$Foswiki::regex{anchorRegex}$/ ) { 
     453 
    443454        # accept, already valid -- just remove leading # 
    444455        return substr( $text, 1 ); 
     
    447458    # $anchorName is a *byte* string. If it contains any wide characters 
    448459    # the encoding algorithm will not work. 
    449     ASSERT($text !~ /[^\x00-\xFF]/) if DEBUG; 
     460    ASSERT( $text !~ /[^\x00-\xFF]/ ) if DEBUG; 
    450461 
    451462    # use _ as an escape character to escape any byte outside the 
     
    454465 
    455466    # Ensure the anchor always starts with an [A-Za-z] 
    456     $text = 'A'.$text; 
     467    $text = 'A' . $text; 
    457468 
    458469    return $text; 
     
    534545 
    535546sub internalLink { 
    536     my ( $this, $web, $topic, $linkText, $anchor, $linkIfAbsent, 
    537         $keepWebPrefix, $hasExplicitLinkLabel ) 
     547    my ( $this, $web, $topic, $linkText, $anchor, $linkIfAbsent, $keepWebPrefix, 
     548        $hasExplicitLinkLabel ) 
    538549      = @_; 
    539550 
     
    583594sub _renderWikiWord { 
    584595    my ( $this, $web, $topic, $linkText, $anchor, $linkIfAbsent, 
    585         $keepWebPrefix ) 
    586       = @_; 
     596        $keepWebPrefix ) = @_; 
    587597    my $session = $this->{session}; 
    588598    my $topicExists = $session->topicExists( $web, $topic ); 
     
    635645    my $href = $this->{session}->getScriptUrl( 0, 'view', $web, $topic ); 
    636646    if ($anchor) { 
    637         $anchor = $this->_makeAnchorName( $anchor ); 
     647        $anchor = $this->_makeAnchorName($anchor); 
     648 
    638649        # No point in trying to make it unique; just aim at the first 
    639650        # occurrence 
    640         $href   = $href.'#'.Foswiki::urlEncode($anchor); 
     651        $href = $href . '#' . Foswiki::urlEncode($anchor); 
    641652    } 
    642653    my $cssClassName = "$currentTopic$currentWebHome"; 
     
    865876    my $formField = $params->{_DEFAULT}; 
    866877    return '' unless defined $formField; 
    867     my $altText   = $params->{alttext}; 
    868     my $default   = $params->{default}; 
    869     my $rev       = $params->{rev} || ''; 
    870     my $format    = $params->{format}; 
    871  
    872     unless (defined $format) { 
     878    my $altText = $params->{alttext}; 
     879    my $default = $params->{default}; 
     880    my $rev     = $params->{rev} || ''; 
     881    my $format  = $params->{format}; 
     882 
     883    unless ( defined $format ) { 
    873884        $format = '$value'; 
    874885    } 
     
    876887    # SMELL: this local creation of a cache looks very suspicious. Suspect 
    877888    # this may have been a one-off optimisation. 
    878     my $formTopicObject = $this->{ffCache}{ $topicObject->getPath().$rev }; 
     889    my $formTopicObject = $this->{ffCache}{ $topicObject->getPath() . $rev }; 
    879890    unless ($formTopicObject) { 
    880         $formTopicObject = Foswiki::Meta->load( 
    881             $this->{session}, $topicObject->web, $topicObject->topic, $rev ); 
     891        $formTopicObject = 
     892          Foswiki::Meta->load( $this->{session}, $topicObject->web, 
     893            $topicObject->topic, $rev ); 
    882894        unless ( $formTopicObject->haveAccess('VIEW') ) { 
    883895 
    884896            # Access violation, create dummy meta with empty text, so 
    885897            # it looks like it was already loaded. 
    886             $formTopicObject = Foswiki::Meta->new( 
    887                 $this->{session}, $topicObject->web, $topicObject->topic, '' ); 
    888         } 
    889         $this->{ffCache}{ $formTopicObject->getPath().$rev } = 
     898            $formTopicObject = 
     899              Foswiki::Meta->new( $this->{session}, $topicObject->web, 
     900                $topicObject->topic, '' ); 
     901        } 
     902        $this->{ffCache}{ $formTopicObject->getPath() . $rev } = 
    890903          $formTopicObject; 
    891904    } 
     
    10781091    # the 'relabeling' of anchor names if the same topic is processed 
    10791092    # more than once, cf. explanation in expandMacros() 
    1080     $this->_clearAnchorNames( $topicObject ); 
     1093    $this->_clearAnchorNames($topicObject); 
    10811094 
    10821095    # '#WikiName' anchors. Don't attempt to make these unique; renaming 
     
    17981811    # special characters 
    17991812    $matchWeb =~ s#[./]#$REMARKER#g; 
    1800     $matchWeb = quotemeta( $matchWeb ); 
     1813    $matchWeb = quotemeta($matchWeb); 
     1814 
    18011815    # $REMARKER is escaped by quotemeta so we need to match the escape 
    18021816    $matchWeb =~ s#\\$REMARKER#[./]#go; 
     
    20582072    # targets to normal rendering. 
    20592073 
    2060  
    20612074    # clear the set of unique anchornames in order to inhibit 
    20622075    # the 'relabeling' of anchor names if the same topic is processed 
    20632076    # more than once, cf. explanation in expandMacros() 
    2064     $this->_clearAnchorNames( $topicObject ); 
     2077    $this->_clearAnchorNames($topicObject); 
    20652078 
    20662079    # NB: While we're processing $text line by line here, 
     
    20692082    # regex{headerPatternDa}. We have to adhere to this 
    20702083    # order here as well. 
    2071     my @regexps = ( 
    2072         $Foswiki::regex{headerPatternHt}, 
    2073         $Foswiki::regex{headerPatternDa} 
    2074     ); 
    2075     my @lines    = split( /\r?\n/, $text ); 
     2084    my @regexps = 
     2085      ( $Foswiki::regex{headerPatternHt}, $Foswiki::regex{headerPatternDa} ); 
     2086    my @lines = split( /\r?\n/, $text ); 
    20762087    my @targets; 
    20772088    my $lineno = 0; 
     
    20802091        for my $i ( 0 .. $#regexps ) { 
    20812092            if ( $line =~ m/$regexps[$i]/ ) { 
     2093 
    20822094                # c.f. _makeAnchorHeading 
    20832095                my ( $level, $text ) = ( $1, $2 ); 
     
    20862098                my $atext = $text; 
    20872099                $text =~ s/\s*$Foswiki::regex{headerPatternNoTOC}.*//o; 
     2100 
    20882101                # Ignore empty headings 
    20892102                next unless $text; 
    20902103 
    20912104                # $i == 1 is $Foswiki::regex{headerPatternDa} 
    2092                 $level = length( $level ) if ( $i == 1 ); 
     2105                $level = length($level) if ( $i == 1 ); 
    20932106                if ( ( $level >= $minDepth ) && ( $level <= $maxDepth ) ) { 
    2094                     my $anchor = $this->_makeAnchorNameUnique( 
    2095                         $topicObject, $this->_makeAnchorName( $atext )); 
     2107                    my $anchor = 
     2108                      $this->_makeAnchorNameUnique( $topicObject, 
     2109                        $this->_makeAnchorName($atext) ); 
    20962110                    my $target = { 
    20972111                        anchor => $anchor, 
     
    20992113                        level  => $level, 
    21002114                    }; 
    2101                     push(@targets, $target); 
     2115                    push( @targets, $target ); 
    21022116 
    21032117                    next LINE; 
     
    21072121    } 
    21082122 
    2109     foreach my $a ( @targets ) { 
     2123    foreach my $a (@targets) { 
    21102124        my $text = $a->{text}; 
    21112125        $highest = $a->{level} if ( $a->{level} < $highest ); 
     
    21712185# C'est la vie. 
    21722186sub _clearAnchorNames { 
    2173     my ($this, $topicObject) = @_; 
    2174     $this->{_anchorNames}{$topicObject->getPath()} = (); 
     2187    my ( $this, $topicObject ) = @_; 
     2188    $this->{_anchorNames}{ $topicObject->getPath() } = (); 
    21752189} 
    21762190 
     
    21822196# is rendered. 
    21832197sub _makeAnchorNameUnique { 
    2184     my ($this, $topicObject, $anchorName) = @_; 
    2185     my $cnt    = 1; 
    2186     my $suffix = ''; 
     2198    my ( $this, $topicObject, $anchorName ) = @_; 
     2199    my $cnt     = 1; 
     2200    my $suffix  = ''; 
    21872201    my $context = $topicObject->getPath(); 
    21882202    $this->{_anchorNames}{$context} ||= (); 
    2189     while ( exists $this->{_anchorNames}{$context}{$anchorName.$suffix} ) { 
     2203    while ( exists $this->{_anchorNames}{$context}{ $anchorName . $suffix } ) { 
    21902204 
    21912205        # $anchorName.$suffix must _always_ be 'compatible', or things 
  • trunk/core/lib/Foswiki/Request.pm

    r3945 r3947  
    5757 
    5858use CGI (); 
    59 our @ISA = ( 'CGI' ); 
     59our @ISA = ('CGI'); 
    6060 
    6161use Assert; 
    62 use Error (); 
     62use Error    (); 
    6363use IO::File (); 
    6464use CGI::Util qw(rearrange); 
  • trunk/core/lib/Foswiki/Sandbox.pm

    r3945 r3947  
    6060    $EMULATED_SAFE_PIPE_OPEN = 1; 
    6161 
    62     # Detect ActiveState and Strawberry perl.   (Cygwin perl returns "cygwin" for $^O) 
     62# Detect ActiveState and Strawberry perl.   (Cygwin perl returns "cygwin" for $^O) 
    6363    if ( $^O eq 'MSWin32' ) { 
    6464        $REAL_SAFE_PIPE_OPEN     = 0; 
  • trunk/core/lib/Foswiki/Search.pm

    r3945 r3947  
    1414use Error qw( :try ); 
    1515 
    16 use Foswiki (); 
    17 use Foswiki::Sandbox (); 
    18 use Foswiki::Render ();    # SMELL: expensive 
    19 use Foswiki::Search::InfoCache (); 
    20 use Foswiki::ListIterator (); 
     16use Foswiki                           (); 
     17use Foswiki::Sandbox                  (); 
     18use Foswiki::Render                   ();    # SMELL: expensive 
     19use Foswiki::Search::InfoCache        (); 
     20use Foswiki::ListIterator             (); 
    2121use Foswiki::Iterator::FilterIterator (); 
    2222 
     
    112112 
    113113    # E.g. "Web*, FooBar" ==> "^(Web.*|FooBar)$" 
    114     $options->{excludeTopics} = _makeTopicPattern($options->{excludeTopics}) 
    115                 if ($options->{excludeTopics}); 
     114    $options->{excludeTopics} = _makeTopicPattern( $options->{excludeTopics} ) 
     115      if ( $options->{excludeTopics} ); 
    116116 
    117117    my $topicFilter; 
    118118    my $it; 
    119     if ($options->{includeTopics}) { 
    120         # E.g. "Bug*, *Patch" ==> "^(Bug.*|.*Patch)$" 
    121         $options->{includeTopics} = _makeTopicPattern($options->{includeTopics}); 
     119    if ( $options->{includeTopics} ) { 
     120 
     121        # E.g. "Bug*, *Patch" ==> "^(Bug.*|.*Patch)$" 
     122        $options->{includeTopics} = 
     123          _makeTopicPattern( $options->{includeTopics} ); 
    122124 
    123125        # limit search to topic list 
     
    136138            #TODO: erm, what about non-case senstive? 
    137139            my @list = 
    138             grep( $this->{session}->topicExists( $webObject->web, $_ ), 
     140              grep( $this->{session}->topicExists( $webObject->web, $_ ), 
    139141                split( /\|/, $topics ) ); 
    140             $it = new Foswiki::ListIterator(\@list); 
     142            $it = new Foswiki::ListIterator( \@list ); 
    141143        } 
    142144        elsif ( !$options->{casesensitive} ) { 
     
    148150    } 
    149151 
    150     $it = $webObject->eachTopic() unless (defined($it)); 
    151  
    152     my $filterIter = new Foswiki::Iterator::FilterIterator($it, sub { 
    153                     my $item = shift; 
    154                     #my $data = shift; 
    155                     return unless !$topicFilter || $item =~ /$topicFilter/; 
    156  
    157                     # exclude topics, Codev.ExcludeWebTopicsFromSearch 
    158                     if ( $options->{casesensitive} && $options->{excludeTopics} ) { 
    159                         return if $item =~ /$options->{excludeTopics}/i; 
    160                     } 
    161                     elsif ($options->{excludeTopics}) { 
    162                         return if $item =~ /$options->{excludeTopics}/; 
    163                    } 
    164                     return 1; 
    165                 }); 
     152    $it = $webObject->eachTopic() unless ( defined($it) ); 
     153 
     154    my $filterIter = new Foswiki::Iterator::FilterIterator( 
     155        $it, 
     156        sub { 
     157            my $item = shift; 
     158 
     159            #my $data = shift; 
     160            return unless !$topicFilter || $item =~ /$topicFilter/; 
     161 
     162            # exclude topics, Codev.ExcludeWebTopicsFromSearch 
     163            if ( $options->{casesensitive} && $options->{excludeTopics} ) { 
     164                return if $item =~ /$options->{excludeTopics}/i; 
     165            } 
     166            elsif ( $options->{excludeTopics} ) { 
     167                return if $item =~ /$options->{excludeTopics}/; 
     168            } 
     169            return 1; 
     170        } 
     171    ); 
    166172    return $filterIter; 
    167173 
    168 #    my @topicList = (); 
    169 #    while ( $filterIter->hasNext() ) { 
    170 #        my $tn = $filterIter->next(); 
    171 #        push( @topicList, $tn ); 
    172 #    } 
    173 #    return @topicList; 
     174    #    my @topicList = (); 
     175    #    while ( $filterIter->hasNext() ) { 
     176    #        my $tn = $filterIter->next(); 
     177    #        push( @topicList, $tn ); 
     178    #    } 
     179    #    return @topicList; 
    174180} 
    175181 
    176182#convert a comma separated list of webs into the list we'll process 
    177183sub _getListOfWebs { 
    178     my ($this, $webName, $recurse, $searchAllFlag) = @_; 
     184    my ( $this, $webName, $recurse, $searchAllFlag ) = @_; 
    179185    my $session = $this->{session}; 
    180186 
     
    320326      1 - Foswiki::isTrue( ( $params{zeroresults} || 'on' ), $nonoise ); 
    321327    my $noTotal = Foswiki::isTrue( $params{nototal}, $nonoise ); 
    322     my $newLine      = $params{newline} || ''; 
    323     my $sortOrder    = $params{order}    || ''; 
    324     my $revSort      = Foswiki::isTrue( $params{reverse} ); 
    325     my $scope        = $params{scope}    || ''; 
     328    my $newLine   = $params{newline} || ''; 
     329    my $sortOrder = $params{order}   || ''; 
     330    my $revSort   = Foswiki::isTrue( $params{reverse} ); 
     331    my $scope     = $params{scope}   || ''; 
    326332    my $searchString = defined $params{search} ? $params{search} : ''; 
    327333    my $separator    = $params{separator}; 
    328334    my $template     = $params{template} || ''; 
    329     my $topic        = $params{topic}    || ''; 
    330     my $type         = $params{type}     || ''; 
     335    my $topic        = $params{topic} || ''; 
     336    my $type         = $params{type} || ''; 
    331337 
    332338    my $wordBoundaries = 0; 
     
    369375    my $searchAllFlag = ( $webName =~ /(^|[\,\s])(all|on)([\,\s]|$)/i ); 
    370376 
    371     my @webs = $this->_getListOfWebs($webName, $recurse, $searchAllFlag); 
     377    my @webs = $this->_getListOfWebs( $webName, $recurse, $searchAllFlag ); 
     378 
    372379    #to help later processing (formatResults) 
    373380    $params{numberOfWebs} = scalar(@webs); 
     
    453460        } 
    454461        else { 
     462 
    455463            # don't render; will be done later 
    456464            $searchResult .= $tmplSearch; 
     
    468476 
    469477#TODO: actually want to pass the entire SEARCH params - so that each search backend can optimise if it suites its impl 
    470         my $options = { 
    471             casesensitive  => $caseSensitive, 
    472             wordboundaries => $wordBoundaries, 
    473             includeTopics  => $topic, 
    474             excludeTopics  => $excludeTopic, 
    475             scope          => $scope, 
    476             type           => $type, 
    477         }; 
     478    my $options = { 
     479        casesensitive  => $caseSensitive, 
     480        wordboundaries => $wordBoundaries, 
     481        includeTopics  => $topic, 
     482        excludeTopics  => $excludeTopic, 
     483        scope          => $scope, 
     484        type           => $type, 
     485    }; 
    478486 
    479487    if ( length($searchString) == 0 ) { 
     488 
    480489        #default search should return no results 
    481490        $searchString = '1 = 2'; 
    482         #shortcircuit the search 
    483         #FIXME: this breaks the per-web summary output that is hidden in the foreach 
     491 
     492    #shortcircuit the search 
     493    #FIXME: this breaks the per-web summary output that is hidden in the foreach 
    484494        @webs = (); 
    485495    } 
    486496 
    487497    my $theParser; 
    488     if ($type eq 'query') { 
     498    if ( $type eq 'query' ) { 
    489499        unless ( defined($queryParser) ) { 
    490500            require Foswiki::Query::Parser; 
     
    492502        } 
    493503        $theParser = $queryParser; 
    494     } else { 
     504    } 
     505    else { 
    495506        unless ( defined($searchParser) ) { 
    496507            require Foswiki::Search::Parser; 
     
    501512    my $error = ''; 
    502513    try { 
    503         $query = $theParser->parse($searchString, $options); 
     514        $query = $theParser->parse( $searchString, $options ); 
    504515    } 
    505516    catch Foswiki::Infix::Error with { 
     
    511522 
    512523    #TODO: 
    513     unless ($type eq 'query') 
    514     { 
    515         #shorcircuit the search foreach below for a zero result search 
    516         #FIXME: this breaks the per-web summary output that is hidden in the foreach 
    517         @webs = () unless scalar(@{$query->{tokens}});    #default 
     524    unless ( $type eq 'query' ) { 
     525 
     526    #shorcircuit the search foreach below for a zero result search 
     527    #FIXME: this breaks the per-web summary output that is hidden in the foreach 
     528        @webs = () unless scalar( @{ $query->{tokens} } );    #default 
    518529    } 
    519530 
     
    544555        my $inputTopicSet = _getTopicList( $this, $webObject, $options ); 
    545556 
    546         next if ( $noEmpty && !$inputTopicSet->hasNext() );    # Nothing to show for this web 
     557        next 
     558          if ( $noEmpty && !$inputTopicSet->hasNext() ) 
     559          ;    # Nothing to show for this web 
    547560 
    548561        my $infoCache = $webObject->query( $query, $inputTopicSet, $options ); 
    549         $this->sortResults($web, $infoCache, %params); 
    550         my ($web_ttopics, $web_searchResult) = $this->formatResults($tmplTable, $tmplNumber, $webObject, $query, $infoCache, %params); 
     562        $this->sortResults( $web, $infoCache, %params ); 
     563        my ( $web_ttopics, $web_searchResult ) = $this->formatResults( 
     564            $tmplTable, $tmplNumber, $webObject, 
     565            $query,     $infoCache,  %params 
     566        ); 
    551567        $ttopics += $web_ttopics; 
    552568        $searchResult .= $web_searchResult; 
     
    592608 
    593609=cut 
     610 
    594611sub sortResults { 
    595     my ($this, $web, $infoCache, %params) = @_; 
     612    my ( $this, $web, $infoCache, %params ) = @_; 
    596613    my $session = $this->{session}; 
    597614 
    598     my $sortOrder   = $params{order}        || ''; 
    599     my $revSort     = Foswiki::isTrue( $params{reverse} ); 
    600     my $date        = $params{date}        || ''; 
    601     my $limit       = $params{limit}        || ''; 
     615    my $sortOrder = $params{order} || ''; 
     616    my $revSort   = Foswiki::isTrue( $params{reverse} ); 
     617    my $date      = $params{date} || ''; 
     618    my $limit     = $params{limit} || ''; 
    602619 
    603620    #SMELL: duplicated code - removeme 
    604621    # Limit search results 
    605622    if ( $limit =~ /(^\d+$)/o ) { 
     623 
    606624        # only digits, all else is the same as 
    607625        # an empty string.  "+10" won't work. 
     
    609627    } 
    610628    else { 
     629 
    611630        # change 'all' to 0, then to big number 
    612631        $limit = 0; 
    613632    } 
    614633    $limit = 32000 unless ($limit); 
    615  
    616634 
    617635    # sort the topic list by date, author or topic name, and cache the 
    618636    # info extracted to do the sorting 
    619637    if ( $sortOrder eq 'modified' ) { 
     638 
    620639        # For performance: 
    621640        #   * sort by approx time (to get a rough list) 
     
    626645        # time is taken from topic instead of dir list. 
    627646        my $slack = 10; 
    628         if ( $limit + 2 * $slack < scalar(@{$infoCache->{list}}) ) { 
     647        if ( $limit + 2 * $slack < scalar( @{ $infoCache->{list} } ) ) { 
    629648 
    630649            # sort by approx latest rev time 
     
    633652              sort { $a->[0] <=> $b->[0] } 
    634653              map  { [ $session->getApproxRevTime( $web, $_ ), $_ ] } 
    635               @{$infoCache->{list}}; 
     654              @{ $infoCache->{list} }; 
    636655            @tmpList = reverse(@tmpList) if ($revSort); 
    637656 
    638657            # then shorten list and build the hashes for date and author 
    639658            my $idx = $limit + $slack; 
    640             @{$infoCache->{list}} = (); 
     659            @{ $infoCache->{list} } = (); 
    641660            foreach (@tmpList) { 
    642                 push( @{$infoCache->{list}}, $_ ); 
     661                push( @{ $infoCache->{list} }, $_ ); 
    643662                $idx -= 1; 
    644663                last if $idx <= 0; 
     
    657676    } 
    658677    else { 
     678 
    659679        # simple sort, see Codev.SchwartzianTransformMisused 
    660680        # note no extraction of topic info here, as not needed 
    661681        # for the sort. Instead it will be read lazily, later on. 
    662682        if ($revSort) { 
    663             @{$infoCache->{list}} = sort { $b cmp $a } @{$infoCache->{list}}; 
     683            @{ $infoCache->{list} } = 
     684              sort { $b cmp $a } @{ $infoCache->{list} }; 
    664685        } 
    665686        else { 
    666             @{$infoCache->{list}} = sort { $a cmp $b } @{$infoCache->{list}}; 
     687            @{ $infoCache->{list} } = 
     688              sort { $a cmp $b } @{ $infoCache->{list} }; 
    667689        } 
    668690    } 
     
    672694        my @ends       = Foswiki::Time::parseInterval($date); 
    673695        my @resultList = (); 
    674         foreach my $topic (@{$infoCache->{list}}) { 
     696        foreach my $topic ( @{ $infoCache->{list} } ) { 
     697 
    675698            # if date falls out of interval: exclude topic from result 
    676699            my $topicdate = $session->getApproxRevTime( $web, $topic ); 
     
    678701              unless ( $topicdate < $ends[0] || $topicdate > $ends[1] ); 
    679702        } 
    680         @{$infoCache->{list}} = @resultList; 
     703        @{ $infoCache->{list} } = @resultList; 
    681704    } 
    682705} 
     
    688711 
    689712=cut 
    690 sub formatResults{ 
    691     my ($this, $tmplTable, $tmplNumber, $webObject, $query, $infoCache, %params) = @_; 
    692     my $session = $this->{session}; 
    693     my $users = $session->{users}; 
    694     my $web = $webObject->web; 
     713 
     714sub formatResults { 
     715    my ( $this, $tmplTable, $tmplNumber, $webObject, $query, $infoCache, 
     716        %params ) 
     717      = @_; 
     718    my $session            = $this->{session}; 
     719    my $users              = $session->{users}; 
     720    my $web                = $webObject->web; 
    695721    my $thisWebNoSearchAll = $webObject->getPreference('NOSEARCHALL') || ''; 
    696  
    697722 
    698723    my $callback      = $params{_callback}; 
     
    709734    my $inline        = $params{inline}; 
    710735    my $limit         = $params{limit} || ''; 
     736 
    711737    # Limit search results 
    712738    if ( $limit =~ /(^\d+$)/o ) { 
     739 
    713740        # only digits, all else is the same as 
    714741        # an empty string.  "+10" won't work. 
     
    716743    } 
    717744    else { 
     745 
    718746        # change 'all' to 0, then to big number 
    719747        $limit = 0; 
     
    721749    $limit = 32000 unless ($limit); 
    722750 
    723     my $doMultiple    = Foswiki::isTrue( $params{multiple} ); 
    724     my $nonoise       = Foswiki::isTrue( $params{nonoise} ); 
    725     my $noEmpty       = Foswiki::isTrue( $params{noempty}, $nonoise ); 
     751    my $doMultiple = Foswiki::isTrue( $params{multiple} ); 
     752    my $nonoise    = Foswiki::isTrue( $params{nonoise} ); 
     753    my $noEmpty    = Foswiki::isTrue( $params{noempty}, $nonoise ); 
    726754 
    727755    # Note: a defined header/footer overrides noheader/nofooter 
    728756    # To maintain Cairo compatibility we ommit default header/footer if the 
    729757    # now deprecated option 'inline' is used combined with 'format' 
    730     my $noHeader = !defined($header) 
    731       && Foswiki::isTrue( $params{noheader}, $nonoise ) 
     758    my $noHeader = 
     759      !defined($header) && Foswiki::isTrue( $params{noheader}, $nonoise ) 
    732760      || ( !$header && $format && $inline ); 
    733761 
    734     my $noFooter = !defined($footer) 
    735       && Foswiki::isTrue( $params{nofooter}, $nonoise ) 
     762    my $noFooter = 
     763      !defined($footer) && Foswiki::isTrue( $params{nofooter}, $nonoise ) 
    736764      || ( !$footer && $format && $inline ); 
    737765 
     
    751779    my $type         = $params{type}     || ''; 
    752780 
    753     my $ttopics = 0; 
     781    my $ttopics      = 0; 
    754782    my $searchResult = ''; 
    755783 
     
    760788    if ( defined $header ) { 
    761789        $beforeText = Foswiki::expandStandardEscapes($header); 
    762         $beforeText =~ s/\$web/$web/gos;    # expand name of web 
    763         $beforeText =~ s/([^\n])$/$1\n/os;  # add new line at end 
     790        $beforeText =~ s/\$web/$web/gos;      # expand name of web 
     791        $beforeText =~ s/([^\n])$/$1\n/os;    # add new line at end 
    764792    } 
    765793 
    766794    if ( defined $footer ) { 
    767795        $afterText = Foswiki::expandStandardEscapes($footer); 
    768         $afterText =~ s/\$web/$web/gos;    # expand name of web 
    769         $afterText =~ s/([^\n])$/$1\n/os;  # add new line at end 
     796        $afterText =~ s/\$web/$web/gos;       # expand name of web 
     797        $afterText =~ s/([^\n])$/$1\n/os;     # add new line at end 
    770798    } 
    771799 
    772800    # output the list of topics in $web 
    773     my $ntopics    = 0; # number of topics in current web 
    774     my $nhits      = 0; # number of hits (if multiple=on) in current web 
     801    my $ntopics    = 0;         # number of topics in current web 
     802    my $nhits      = 0;         # number of hits (if multiple=on) in current web 
    775803    my $headerDone = $noHeader; 
    776     while ($infoCache->hasNext()) { 
    777         my $topic = $infoCache->next(); 
     804    while ( $infoCache->hasNext() ) { 
     805        my $topic          = $infoCache->next(); 
    778806        my $forceRendering = 0; 
    779807        my $info           = $infoCache->get($topic); 
     
    782810        require Foswiki::Time; 
    783811        my $revDate = Foswiki::Time::formatTime($epochSecs); 
    784         my $isoDate = 
    785           Foswiki::Time::formatTime( $epochSecs, '$iso', 'gmtime' ); 
     812        my $isoDate = Foswiki::Time::formatTime( $epochSecs, '$iso', 'gmtime' ); 
    786813 
    787814        my $ru     = $info->{editby} || 'UnknownUser'; 
     
    790817        my $cUID = $users->getCanonicalUserID($ru); 
    791818        if ( !$cUID ) { 
     819 
    792820            # Not a login name or a wiki name. Is it a valid cUID? 
    793821            my $ln = $users->getLoginName($ru); 
     
    807835            if ($doExpandVars) { 
    808836                if ( $web eq $baseWeb && $topic eq $baseTopic ) { 
     837 
    809838                    # primitive way to prevent recursion 
    810839                    $text =~ s/%SEARCH/%<nop>SEARCH/g; 
     
    816845        my @multipleHitLines = (); 
    817846        if ($doMultiple) { 
     847 
    818848            #TODO: i wonder if this shoudl be a HoistRE.. 
    819             my @tokens = @{$query->{tokens}}; 
    820             my $pattern = $tokens[$#tokens];   # last token in an AND search 
     849            my @tokens  = @{ $query->{tokens} }; 
     850            my $pattern = $tokens[$#tokens];       # last token in an AND search 
    821851            $pattern = quotemeta($pattern) if ( $type ne 'regex' ); 
    822852            unless ($text) { 
     
    931961                  s/\$count\((.*?\s*\.\*)\)/_countPattern( $text, $1 )/ges; 
    932962 
    933 # FIXME: Allow all regex characters but escape them 
    934 # Note: The RE requires a .* at the end of a pattern to avoid false positives 
    935 # in pattern matching 
     963   # FIXME: Allow all regex characters but escape them 
     964   # Note: The RE requires a .* at the end of a pattern to avoid false positives 
     965   # in pattern matching 
    936966                $out =~ 
    937 s/\$pattern\((.*?\s*\.\*)\)/_extractPattern( $text, $1 )/ges; 
     967                  s/\$pattern\((.*?\s*\.\*)\)/_extractPattern( $text, $1 )/ges; 
    938968                $out =~ s/\r?\n/$newLine/gos if ($newLine); 
    939969                if ( defined($separator) ) { 
     
    9821012            } 
    9831013 
    984          #don't expand if a format is specified - it breaks tables and stuff 
     1014            #don't expand if a format is specified - it breaks tables and stuff 
    9851015            unless ($format) { 
    9861016                $out = $webObject->renderTML($out); 
     
    10411071        } 
    10421072    } 
    1043     return ($ttopics, $searchResult); 
     1073    return ( $ttopics, $searchResult ); 
    10441074} 
    10451075 
  • trunk/core/lib/Foswiki/Search/InfoCache.pm

    r3944 r3947  
    44 
    55use Foswiki::ListIterator (); 
    6 our @ISA = ( 'Foswiki::ListIterator' ); 
     6our @ISA = ('Foswiki::ListIterator'); 
    77 
    88=begin TML 
     
    4242    my ( $class, $session, $defaultWeb, $topicList ) = @_; 
    4343    my $this = $class->SUPER::new($topicList); 
    44     $this->{_session} = $session; 
     44    $this->{_session}    = $session; 
    4545    $this->{_defaultWeb} = $defaultWeb; 
    4646 
    4747    return $this; 
    4848} 
     49 
    4950sub isImmutable { 
    5051    my $this = shift; 
    51     return ($this->{index} != 0); 
    52 } 
     52    return ( $this->{index} != 0 ); 
     53} 
     54 
    5355sub addTopics { 
    5456    my ( $this, $defaultWeb, @list ) = @_; 
    55     ASSERT(!$this->isImmutable());    #cannot modify list once its being used as an iterator. 
    56  
    57     if (defined($defaultWeb) && ($defaultWeb ne $this->{_defaultWeb})) { 
     57    ASSERT( !$this->isImmutable() ) 
     58      ;    #cannot modify list once its being used as an iterator. 
     59 
     60    if ( defined($defaultWeb) && ( $defaultWeb ne $this->{_defaultWeb} ) ) { 
    5861        foreach my $t (@list) { 
    59             my ($web, $topic) = Foswiki::Func::normalizeTopic($defaultWeb, $t); 
    60             push(@{$this->{list}}, "$web.$topic"); 
    61         } 
    62     } else { 
     62            my ( $web, $topic ) = 
     63              Foswiki::Func::normalizeTopic( $defaultWeb, $t ); 
     64            push( @{ $this->{list} }, "$web.$topic" ); 
     65        } 
     66    } 
     67    else { 
     68 
    6369        #TODO: what if the list is an arrayref? 
    64         push(@{$this->{list}}, @list); 
    65     } 
    66 } 
    67  
     70        push( @{ $this->{list} }, @list ); 
     71    } 
     72} 
    6873 
    6974######OLD methods 
     
    7782 
    7883        $info->{tom} = 
    79           Foswiki::Meta->load( $this->{_session}, $this->{_defaultWeb}, $topic ); 
     84          Foswiki::Meta->load( $this->{_session}, $this->{_defaultWeb}, 
     85            $topic ); 
    8086 
    8187        # SMELL: why do this here? Smells of a hack, as AFAICT it is done 
     
    109115        unless ($ri) { 
    110116            my $tmp = 
    111               Foswiki::Meta->load( $this->{_session}, $this->{_defaultWeb}, $topic, 
    112                 1 ); 
     117              Foswiki::Meta->load( $this->{_session}, $this->{_defaultWeb}, 
     118                $topic, 1 ); 
    113119            $info->{rev1info} = $ri = $tmp->getRevisionInfo(); 
    114120        } 
     
    140146    ASSERT($sortfield); 
    141147 
    142     ASSERT(!$this->isImmutable());    #cannot modify list once its being used as an iterator. 
     148    ASSERT( !$this->isImmutable() ) 
     149      ;    #cannot modify list once its being used as an iterator. 
    143150 
    144151    # populate the cache for each topic 
    145     foreach my $topic (@{$this->{list}}) { 
     152    foreach my $topic ( @{ $this->{list} } ) { 
    146153        if ( $sortfield =~ /^creat/ ) { 
    147154 
     
    164171    } 
    165172    if ($revSort) { 
    166         @{$this->{list}} = map { $_->[1] } 
     173        @{ $this->{list} } = map { $_->[1] } 
    167174          sort { _compare( $b->[0], $a->[0] ) } 
    168           map { [ $this->{$_}->{$sortfield}, $_ ] } @{$this->{list}}; 
     175          map { [ $this->{$_}->{$sortfield}, $_ ] } @{ $this->{list} }; 
    169176    } 
    170177    else { 
    171         @{$this->{list}} = map { $_->[1] } 
     178        @{ $this->{list} } = map { $_->[1] } 
    172179          sort { _compare( $a->[0], $b->[0] ) } 
    173           map { [ $this->{$_}->{$sortfield}, $_ ] } @{$this->{list}}; 
     180          map { [ $this->{$_}->{$sortfield}, $_ ] } @{ $this->{list} }; 
    174181    } 
    175182} 
  • trunk/core/lib/Foswiki/Search/Node.pm

    r3944 r3947  
    1919 
    2020use Foswiki::Infix::Node (); 
    21 our @ISA = ( 'Foswiki::Infix::Node' ); 
     21our @ISA = ('Foswiki::Infix::Node'); 
    2222 
    2323=begin TML 
     
    3131sub new { 
    3232    my ( $class, $search, $tokens, $options ) = @_; 
    33     my $this = bless( { tokens => $tokens, search => $search, options => $options }, $class ); 
     33    my $this = 
     34      bless( { tokens => $tokens, search => $search, options => $options }, 
     35        $class ); 
    3436    return $this; 
    3537} 
    36  
    3738 
    38391; 
  • trunk/core/lib/Foswiki/Search/Parser.pm

    r3944 r3947  
    1919 
    2020use Foswiki::Infix::Parser (); 
    21 our @ISA = ( 'Foswiki::Infix::Parser' ); 
     21our @ISA = ('Foswiki::Infix::Parser'); 
    2222 
    2323use Foswiki::Search::Node (); 
     
    4242    my $this = shift; 
    4343 
    44     return if ($this->{initialised}); 
     44    return if ( $this->{initialised} ); 
    4545 
    4646    # Build pattern of stop words 
     
    111111    } 
    112112 
    113     my $result = new Foswiki::Search::Node($searchString, \@tokens, $options ); 
     113    my $result = new Foswiki::Search::Node( $searchString, \@tokens, $options ); 
    114114    return $result; 
    115115} 
  • trunk/core/lib/Foswiki/Store/QueryAlgorithms/BruteForce.pm

    r3874 r3947  
    2323 
    2424use Foswiki::Search::Node (); 
    25 use Foswiki::Meta (); 
     25use Foswiki::Meta         (); 
    2626use Foswiki::Search::InfoCache; 
    27  
    2827 
    2928sub query { 
     
    3231    my $topicSet = $inputTopicSet; 
    3332 
    34 #TODO: howto ask iterator for list length? 
    35 #    if ( scalar(@$topics) > 6 ) { 
    36         require Foswiki::Query::HoistREs; 
    37         my @filter = Foswiki::Query::HoistREs::hoist($query); 
    38         if (scalar(@filter)) { 
    39             my $searchOptions = { 
    40                         type                => 'regex', 
    41                         casesensitive       => 1, 
    42                         files_without_match => 1, 
    43                     }; 
    44             my $searchQuery = new Foswiki::Search::Node($query->toString(), \@filter, $searchOptions); 
    45             $topicSet = $store->searchInWebMetaData($searchQuery, $web, $topicSet, $searchOptions); 
    46         } else { 
    47             #print STDERR "WARNING: couldn't hoistREs on ".$query->toString(); 
    48         } 
    49 #    } 
     33    #TODO: howto ask iterator for list length? 
     34    #    if ( scalar(@$topics) > 6 ) { 
     35    require Foswiki::Query::HoistREs; 
     36    my @filter = Foswiki::Query::HoistREs::hoist($query); 
     37    if ( scalar(@filter) ) { 
     38        my $searchOptions = { 
     39            type                => 'regex', 
     40            casesensitive       => 1, 
     41            files_without_match => 1, 
     42        }; 
     43        my $searchQuery = 
     44          new Foswiki::Search::Node( $query->toString(), \@filter, 
     45            $searchOptions ); 
     46        $topicSet = 
     47          $store->searchInWebMetaData( $searchQuery, $web, $topicSet, 
     48            $searchOptions ); 
     49    } 
     50    else { 
     51 
     52        #print STDERR "WARNING: couldn't hoistREs on ".$query->toString(); 
     53    } 
     54 
     55    #    } 
    5056 
    5157    my %matches; 
     
    5460        my $topic = $topicSet->next(); 
    5561        my $meta = 
    56           Foswiki::Meta->new( $store->{session}, $web, $topic);#, <FILE> ); 
    57         #this 'lazy load will become useful when @$topics becomes an infoCache 
     62          Foswiki::Meta->new( $store->{session}, $web, $topic );    #, <FILE> ); 
     63           #this 'lazy load will become useful when @$topics becomes an infoCache 
    5864        $meta->reload() unless ( $meta->getLoadedRev() ); 
    5965        next unless ( $meta->getLoadedRev() ); 
     
    6672 
    6773    my @topics = keys(%matches); 
    68     my $resultTopicSet = new Foswiki::Search::InfoCache( $Foswiki::Plugins::SESSION, $web, \@topics); 
     74    my $resultTopicSet = 
     75      new Foswiki::Search::InfoCache( $Foswiki::Plugins::SESSION, $web, 
     76        \@topics ); 
    6977    return $resultTopicSet; 
    7078} 
  • trunk/core/lib/Foswiki/Store/RcsLite.pm

    r3944 r3947  
    2121 
    2222use Foswiki::Store::VCStore (); 
    23 our @ISA = ( 'Foswiki::Store::VCStore' ); 
     23our @ISA = ('Foswiki::Store::VCStore'); 
    2424 
    2525# This constructor is required to hide the =Foswiki::Store::RcsLiteHandler= 
  • trunk/core/lib/Foswiki/Store/RcsLiteHandler.pm

    r3944 r3947  
    8888 
    8989use Foswiki::Store::VCHandler (); 
    90 our @ISA = ( 'Foswiki::Store::VCHandler' ); 
     90our @ISA = ('Foswiki::Store::VCHandler'); 
    9191 
    9292use Assert; 
    9393use Error qw( :try ); 
    9494 
    95 use FileHandle (); 
     95use FileHandle       (); 
    9696use Foswiki::Store   (); 
    9797use Foswiki::Sandbox (); 
  • trunk/core/lib/Foswiki/Store/RcsWrap.pm

    r3944 r3947  
    2121 
    2222use Foswiki::Store::VCStore (); 
    23 our @ISA = ( 'Foswiki::Store::VCStore' ); 
     23our @ISA = ('Foswiki::Store::VCStore'); 
    2424 
    2525# This constructor is required to hide the =Foswiki::Store::RcsWrapHandler= 
  • trunk/core/lib/Foswiki/Store/RcsWrapHandler.pm

    r3945 r3947  
    2020 
    2121use Foswiki::Store::VCHandler (); 
    22 our @ISA = ( 'Foswiki::Store::VCHandler' ); 
     22our @ISA = ('Foswiki::Store::VCHandler'); 
    2323 
    2424use File::Copy (); 
     
    108108    my ( $this, $text, $comment, $user, $date ) = @_; 
    109109    $this->init(); 
     110 
    110111    #print STDERR "Wrap: Forced save at $date $this->{file}\n" if $date; 
    111112 
    112     unless ( -e $this->{rcsFile} ) {# 
    113         # SMELL: what is this for? 
     113    unless ( -e $this->{rcsFile} ) {    # 
     114                                        # SMELL: what is this for? 
    114115        _lock($this); 
    115116        _ci( $this, $comment, $user, $date ); 
  • trunk/core/lib/Foswiki/Store/SearchAlgorithms/Forking.pm

    r3874 r3947  
    66use Assert; 
    77use Foswiki::Search::InfoCache; 
    8  
    98 
    109=begin TML 
     
    7776    my $sDir = $Foswiki::cfg{DataDir} . '/' . $web . '/'; 
    7877 
    79 #    while (my @set = splice( @take, 0, $maxTopicsInSet )) { 
    80 #        @set = map { "$sDir/$_.txt" } @set; 
     78    #    while (my @set = splice( @take, 0, $maxTopicsInSet )) { 
     79    #        @set = map { "$sDir/$_.txt" } @set; 
    8180    my @set; 
    8281    $inputTopicSet->reset(); 
    8382    while ( $inputTopicSet->hasNext() ) { 
    8483        my $tn = $inputTopicSet->next(); 
    85         push(@set, "$sDir/$tn.txt"); 
    86         if (($#set >= $maxTopicsInSet)      #replace with character count.. 
    87             || !($inputTopicSet->hasNext())) { 
     84        push( @set, "$sDir/$tn.txt" ); 
     85        if ( 
     86            ( $#set >= $maxTopicsInSet )    #replace with character count.. 
     87            || !( $inputTopicSet->hasNext() ) 
     88          ) 
     89        { 
    8890            my ( $m, $exit ) = Foswiki::Sandbox->sysCommand( 
    8991                $program, 
     
    9294            ); 
    9395            @set = (); 
     96 
    9497            # man grep: "Normally, exit status is 0 if selected lines are found 
    9598            # and 1 otherwise. But the exit status is 2 if an error occurred, 
     
    97100            # line is found." 
    98101            if ( $exit > 1 ) { 
    99                 #TODO: need to work out a way to alert the admin there is a problem, without 
    100                 #      filling up the log files with repeated SEARCH's 
    101  
    102                 # NOTE: we ignore the error, because grep returns an error if it comes across a broken file link 
    103                 #       or a file it does not have permission to open, so throwing here gives wrong search results. 
    104                 # throw Error::Simple("$program Grep for '$searchString' returned error") 
     102 
     103    #TODO: need to work out a way to alert the admin there is a problem, without 
     104    #      filling up the log files with repeated SEARCH's 
     105 
     106# NOTE: we ignore the error, because grep returns an error if it comes across a broken file link 
     107#       or a file it does not have permission to open, so throwing here gives wrong search results. 
     108# throw Error::Simple("$program Grep for '$searchString' returned error") 
    105109            } 
    106110            $matches .= $m; 
     
    121125this is the new way - 
    122126=cut 
     127 
    123128sub query { 
    124129    my ( $query, $web, $inputTopicSet, $store, $options ) = @_; 
    125     ASSERT(scalar(@{$query->{tokens}}) > 0) if DEBUG; 
     130    ASSERT( scalar( @{ $query->{tokens} } ) > 0 ) if DEBUG; 
    126131 
    127132    # default scope is 'text' 
    128     $options->{'scope'} = 'text' unless ( defined($options->{'scope'}) && $options->{'scope'} =~ /^(topic|all)$/ ); 
     133    $options->{'scope'} = 'text' 
     134      unless ( defined( $options->{'scope'} ) 
     135        && $options->{'scope'} =~ /^(topic|all)$/ ); 
    129136 
    130137    my $topicSet = $inputTopicSet; 
    131     ASSERT(UNIVERSAL::isa( $topicSet, 'Foswiki::Iterator' )) if DEBUG; 
     138    ASSERT( UNIVERSAL::isa( $topicSet, 'Foswiki::Iterator' ) ) if DEBUG; 
    132139 
    133140    my %completeMatch; 
    134141 
    135142#print STDERR "######## Forking search ($web) tokens ".scalar(@{$query->{tokens}})." : ".join(',', @{$query->{tokens}})."\n"; 
    136     # AND search - search once for each token, ANDing result together 
    137     foreach my $token (@{$query->{tokens}}) { 
     143# AND search - search once for each token, ANDing result together 
     144    foreach my $token ( @{ $query->{tokens} } ) { 
    138145 
    139146        # flag for AND NOT search 
     
    153160 
    154161                # FIXME I18N 
    155                 $qtoken = quotemeta($qtoken) if ( $options->{'type'} ne 'regex' ); 
     162                $qtoken = quotemeta($qtoken) 
     163                  if ( $options->{'type'} ne 'regex' ); 
    156164                if ( $options->{'casesensitive'} ) { 
    157165 
     
    161169                } 
    162170                else { 
     171 
    163172                    #push(@scopeTopicList, $topic) if ( $topic =~ /$qtoken/i ); 
    164173                    $topicMatches{$topic} = 1 if ( $topic =~ /$qtoken/i ); 
     
    183192            while ( $topicSet->hasNext() ) { 
    184193                my $topic = $topicSet->next(); 
     194 
    185195                #push( @scopeTextList, $topic ) 
    186196                if ( $topicMatches{$topic} ) { 
     197 
    187198                    #remove this match 
    188199                    delete $completeMatch{$topic}; 
    189200                } 
    190201            } 
    191         } else { 
     202        } 
     203        else { 
     204 
    192205            #TODO: the sad thing about this is we lose info 
    193206            %completeMatch = %topicMatches; 
    194207        } 
     208 
    195209        # reduced topic list for next token 
    196210        @scopeTextList = keys(%completeMatch); 
    197         $topicSet = new Foswiki::Search::InfoCache( $Foswiki::Plugins::SESSION, $web, \@scopeTextList); 
     211        $topicSet = 
     212          new Foswiki::Search::InfoCache( $Foswiki::Plugins::SESSION, $web, 
     213            \@scopeTextList ); 
    198214    } 
    199215 
    200216    return $topicSet; 
     217 
    201218    #return \%completeMatch; 
    202219} 
  • trunk/core/lib/Foswiki/Store/SearchAlgorithms/PurePerl.pm

    r3874 r3947  
    66use Assert; 
    77use Foswiki::Search::InfoCache; 
    8  
    98 
    109=begin TML 
     
    7675this is the new way - 
    7776=cut 
     77 
    7878sub query { 
    7979    my ( $query, $web, $inputTopicSet, $store, $options ) = @_; 
    80     ASSERT(scalar(@{$query->{tokens}}) > 0) if DEBUG; 
     80    ASSERT( scalar( @{ $query->{tokens} } ) > 0 ) if DEBUG; 
    8181 
    8282    # default scope is 'text' 
    83     $options->{'scope'} = 'text' unless ( defined($options->{'scope'}) && $options->{'scope'} =~ /^(topic|all)$/ ); 
     83    $options->{'scope'} = 'text' 
     84      unless ( defined( $options->{'scope'} ) 
     85        && $options->{'scope'} =~ /^(topic|all)$/ ); 
    8486 
    8587    my $topicSet = $inputTopicSet; 
    86     ASSERT(UNIVERSAL::isa( $topicSet, 'Foswiki::Iterator' )) if DEBUG; 
     88    ASSERT( UNIVERSAL::isa( $topicSet, 'Foswiki::Iterator' ) ) if DEBUG; 
    8789 
    8890    my %completeMatch; 
    8991 
    9092#print STDERR "######## Forking search ($web) tokens ".scalar(@{$query->{tokens}})." : ".join(',', @{$query->{tokens}})."\n"; 
    91     # AND search - search once for each token, ANDing result together 
    92     foreach my $token (@{$query->{tokens}}) { 
     93# AND search - search once for each token, ANDing result together 
     94    foreach my $token ( @{ $query->{tokens} } ) { 
    9395 
    9496        # flag for AND NOT search 
     
    108110 
    109111                # FIXME I18N 
    110                 $qtoken = quotemeta($qtoken) if ( $options->{'type'} ne 'regex' ); 
     112                $qtoken = quotemeta($qtoken) 
     113                  if ( $options->{'type'} ne 'regex' ); 
    111114                if ( $options->{'casesensitive'} ) { 
    112115 
     
    116119                } 
    117120                else { 
     121 
    118122                    #push(@scopeTopicList, $topic) if ( $topic =~ /$qtoken/i ); 
    119123                    $topicMatches{$topic} = 1 if ( $topic =~ /$qtoken/i ); 
     
    138142            while ( $topicSet->hasNext() ) { 
    139143                my $topic = $topicSet->next(); 
     144 
    140145                #push( @scopeTextList, $topic ) 
    141146                if ( $topicMatches{$topic} ) { 
     147 
    142148                    #remove this match 
    143149                    delete $completeMatch{$topic}; 
    144150                } 
    145151            } 
    146         } else { 
     152        } 
     153        else { 
     154 
    147155            #TODO: the sad thing about this is we lose info 
    148156            %completeMatch = %topicMatches; 
    149157        } 
     158 
    150159        # reduced topic list for next token 
    151160        @scopeTextList = keys(%completeMatch); 
    152         $topicSet = new Foswiki::Search::InfoCache( $Foswiki::Plugins::SESSION, $web, \@scopeTextList); 
     161        $topicSet = 
     162          new Foswiki::Search::InfoCache( $Foswiki::Plugins::SESSION, $web, 
     163            \@scopeTextList ); 
    153164    } 
    154165 
    155166    return $topicSet; 
    156 #    return \%completeMatch; 
     167 
     168    #    return \%completeMatch; 
    157169} 
    158170 
  • trunk/core/lib/Foswiki/Store/VCHandler.pm

    r3946 r3947  
    6161 
    6262            $this->{file} = 
    63                 $Foswiki::cfg{PubDir} . '/' 
     63                $Foswiki::cfg{PubDir} . '/'  
    6464              . $web . '/' 
    6565              . $this->{topic} . '/' 
    6666              . $attachment; 
    6767            $this->{rcsFile} = 
    68                 $Foswiki::cfg{PubDir} . '/' 
    69               . $web . '/' 
     68                $Foswiki::cfg{PubDir} . '/'  
     69              . $web . '/'  
    7070              . $topic 
    7171              . $rcsSubDir . '/' 
     
    7777              $Foswiki::cfg{DataDir} . '/' . $web . '/' . $topic . '.txt'; 
    7878            $this->{rcsFile} = 
    79                 $Foswiki::cfg{DataDir} . '/' 
     79                $Foswiki::cfg{DataDir} . '/'  
    8080              . $web 
    8181              . $rcsSubDir . '/' 
     
    198198sub getLatestRevision { 
    199199    my $this = shift; 
     200 
    200201#SMELL: why is this assumption made rather than delegating to the impl? ($this->getRevision();) 
    201202    return readFile( $this, $this->{file} ); 
     
    332333 
    333334    no strict 'refs'; 
    334     return &{ $this->{searchFn} }( $searchString, $web, $inputTopicSet, $store, $options, $Foswiki::sandbox ); 
     335    return &{ $this->{searchFn} }( 
     336        $searchString, $web, $inputTopicSet, $store, $options, $Foswiki::sandbox 
     337    ); 
    335338    use strict 'refs'; 
    336339} 
     
    356359 
    357360    my $engine; 
    358     if ($options->{type} eq 'query') { 
     361    if ( $options->{type} eq 'query' ) { 
    359362        unless ( $this->{queryFn} ) { 
    360363            eval "require $Foswiki::cfg{RCS}{QueryAlgorithm}"; 
    361364            die 
    362     "Bad {RCS}{QueryAlgorithm}; suggest you run configure and select a different algorithm\n$@" 
     365"Bad {RCS}{QueryAlgorithm}; suggest you run configure and select a different algorithm\n$@" 
    363366              if $@; 
    364367            $this->{queryFn} = $Foswiki::cfg{RCS}{QueryAlgorithm} . '::query'; 
    365368        } 
    366369        $engine = $this->{queryFn}; 
    367     } else { 
     370    } 
     371    else { 
    368372        unless ( $this->{searchQueryFn} ) { 
    369373            eval "require $Foswiki::cfg{RCS}{SearchAlgorithm}"; 
    370374            die 
    371     "Bad {RCS}{SearchAlgorithm}; suggest you run configure and select a different algorithm\n$@" 
     375"Bad {RCS}{SearchAlgorithm}; suggest you run configure and select a different algorithm\n$@" 
    372376              if $@; 
    373             $this->{searchQueryFn} = $Foswiki::cfg{RCS}{SearchAlgorithm} . '::query'; 
     377            $this->{searchQueryFn} = 
     378              $Foswiki::cfg{RCS}{SearchAlgorithm} . '::query'; 
    374379        } 
    375380        $engine = $this->{searchQueryFn}; 
     
    377382 
    378383    no strict 'refs'; 
    379     return &{ $engine }( $query, $web, $inputTopicSet, $store, $options ); 
     384    return &{$engine}( $query, $web, $inputTopicSet, $store, $options ); 
    380385    use strict 'refs'; 
    381386} 
     
    764769 
    765770sub test { 
    766     my ($this, $test) = @_; 
     771    my ( $this, $test ) = @_; 
    767772    return eval "-$test '$this->{file}'"; 
    768773} 
     
    916921            elsif ( !unlink($entry) && -e $entry ) { 
    917922                if ( $Foswiki::cfg{OS} ne 'WINDOWS' ) { 
    918                     throw Error::Simple( 'VCHandler: Failed to delete file ' 
     923                    throw Error::Simple( 'VCHandler: Failed to delete file '  
    919924                          . $entry . ': ' 
    920925                          . $! ); 
     
    946951 
    947952{ 
     953 
    948954    # Package that ties a filehandle to a memory string for reading 
    949955    package Foswiki::Store::_MemoryFile; 
    950956 
    951957    sub TIEHANDLE { 
    952         my ($class, $data) = @_; 
    953         return bless({data => $data, size => length($data), ptr => 0}, $class); 
     958        my ( $class, $data ) = @_; 
     959        return 
     960          bless( { data => $data, size => length($data), ptr => 0 }, $class ); 
    954961    } 
    955962 
     
    957964        my $this = shift; 
    958965        my ( undef, $len, $offset ) = @_; 
    959         if ($this->{size} - $this->{ptr} < $len) { 
     966        if ( $this->{size} - $this->{ptr} < $len ) { 
    960967            $len = $this->{size} - $this->{ptr}; 
    961968        } 
    962969        return 0 unless $len; 
    963         $_[0] = substr($this->{data}, $this->{ptr}, $len); 
     970        $_[0] = substr( $this->{data}, $this->{ptr}, $len ); 
    964971        $this->{ptr} += $len; 
    965972        return $len; 
     
    969976        my $this = shift; 
    970977        return if $this->{ptr} == $this->{size}; 
    971         return substr($this->{data}, $this->{ptr}) if !defined $/; 
     978        return substr( $this->{data}, $this->{ptr} ) if !defined $/; 
    972979        my $start = $this->{ptr}; 
    973         while ($this->{ptr} < $this->{size} 
    974                  && substr($this->{data}, $this->{ptr}, 1) ne $/) { 
     980        while ( $this->{ptr} < $this->{size} 
     981            && substr( $this->{data}, $this->{ptr}, 1 ) ne $/ ) 
     982        { 
    975983            $this->{ptr}++; 
    976984        } 
    977985        $this->{ptr}++ if $this->{ptr} < $this->{size}; 
    978         return substr($this->{data}, $start, $this->{ptr} - $start); 
     986        return substr( $this->{data}, $start, $this->{ptr} - $start ); 
    979987    } 
    980988 
     
    10071015 
    10081016sub openStream { 
    1009     my ($this, $mode, %opts) = @_; 
     1017    my ( $this, $mode, %opts ) = @_; 
    10101018    my $stream; 
    1011     if ($mode eq '<' && $opts{version}) { 
     1019    if ( $mode eq '<' && $opts{version} ) { 
     1020 
    10121021        # Bulk load the revision and tie a filehandle 
    10131022        require Symbol; 
    1014         $stream = Symbol::gensym; # create an anonymous glob 
    1015         tie(*$stream, 'Foswiki::Store::_MemoryFile', 
    1016             $this->getRevision($opts{version})); 
    1017     } else { 
    1018         if ($mode =~ />/) { 
    1019             mkPathTo($this->{file}); 
    1020         } 
    1021         unless ( open( $stream, $mode, $this->{file} )) { 
     1023        $stream = Symbol::gensym;    # create an anonymous glob 
     1024        tie( *$stream, 'Foswiki::Store::_MemoryFile', 
     1025            $this->getRevision( $opts{version} ) ); 
     1026    } 
     1027    else { 
     1028        if ( $mode =~ />/ ) { 
     1029            mkPathTo( $this->{file} ); 
     1030        } 
     1031        unless ( open( $stream, $mode, $this->{file} ) ) { 
    10221032            throw Error::Simple( 
    10231033                'VCHandler: stream open ' . $this->{file} . ' failed: ' . $! ); 
     
    10741084    my ( $this, $attachmentsKnownInMeta ) = @_; 
    10751085 
    1076     my %filesListedInPub = $this->_getAttachmentStats(); 
     1086    my %filesListedInPub  = $this->_getAttachmentStats(); 
    10771087    my %filesListedInMeta = (); 
    10781088 
     
    11021112    # Do not change this from array to hash, you would lose the 
    11031113    # proper attachment sequence 
    1104     my @deindexedBecauseMetaDoesnotIndexAttachments = 
    1105       values(%filesListedInPub); 
     1114    my @deindexedBecauseMetaDoesnotIndexAttachments = values(%filesListedInPub); 
    11061115 
    11071116    return @deindexedBecauseMetaDoesnotIndexAttachments; 
     
    11181127sub getAttachmentList { 
    11191128    my $this = shift; 
    1120     my $dir = "$Foswiki::cfg{PubDir}/$this->{web}/$this->{topic}"; 
     1129    my $dir  = "$Foswiki::cfg{PubDir}/$this->{web}/$this->{topic}"; 
    11211130    opendir DIR, $dir || return (); 
    11221131    my @files = grep { !/^[.*_]/ && !/,v$/ } readdir(DIR); 
     
    11281137# for any given web, topic 
    11291138sub _getAttachmentStats { 
    1130     my $this = shift; 
     1139    my $this           = shift; 
    11311140    my %attachmentList = (); 
    1132     my $dir = "$Foswiki::cfg{PubDir}/$this->{web}/$this->{topic}"; 
    1133     foreach my $attachment ($this->getAttachmentList()) { 
     1141    my $dir            = "$Foswiki::cfg{PubDir}/$this->{web}/$this->{topic}"; 
     1142    foreach my $attachment ( $this->getAttachmentList() ) { 
    11341143        my @stat = stat( $dir . "/" . $attachment ); 
    11351144        $attachmentList{$attachment} = 
  • trunk/core/lib/Foswiki/Store/VCStore.pm

    r3944 r3947  
    3232 
    3333use Foswiki::Store (); 
    34 our @ISA = ( 'Foswiki::Store' ); 
     34our @ISA = ('Foswiki::Store'); 
    3535 
    3636use Assert; 
     
    115115    # Use the potentially more risky topic version number for speed 
    116116    my $gotRev; 
    117     my $ri = $topicObject->get( 'TOPICINFO' ); 
    118     if (defined($ri)) { 
     117    my $ri = $topicObject->get('TOPICINFO'); 
     118    if ( defined($ri) ) { 
    119119        $gotRev = $ri->{version}; 
    120     } else { 
     120    } 
     121    else { 
     122 
    121123        # SMELL: Risky. In most cases, I reckon this is going to be OK. 
    122124        # Alt kick down to to the handler to get the real deal? 
     
    129131    # Add attachments that are new from reading the pub directory. 
    130132    # Only check the currently requested topic. 
    131     if ( $Foswiki::cfg{AutoAttachPubFiles} 
    132            && $topicObject->web eq $this->{session}->{webName} 
    133              && $topicObject->topic eq $this->{session}->{topicName} ) 
     133    if (   $Foswiki::cfg{AutoAttachPubFiles} 
     134        && $topicObject->web  eq $this->{session}->{webName} 
     135        && $topicObject->topic eq $this->{session}->{topicName} ) 
    134136    { 
    135137 
     
    139141        my @validAttachmentsFound; 
    140142        foreach my $foundAttachment (@attachmentsFoundInPub) { 
     143 
    141144            # test if the attachment filename would need sanitizing, 
    142145            # if so, ignore it. 
     
    167170# Documented in Foswiki::Store 
    168171sub moveAttachment { 
    169     my ( 
    170         $this,           $oldTopicObject, $oldAttachment, 
    171         $newTopicObject, $newAttachment, $cUID 
    172     ) = @_; 
    173  
    174     ASSERT($oldTopicObject->isa('Foswiki::Meta')) if DEBUG; 
    175     ASSERT($newTopicObject->isa('Foswiki::Meta')) if DEBUG; 
    176     ASSERT($oldAttachment) if DEBUG; 
    177     ASSERT($newAttachment) if DEBUG; 
    178     ASSERT($cUID) if DEBUG; 
     172    my ( $this, $oldTopicObject, $oldAttachment, $newTopicObject, 
     173        $newAttachment, $cUID ) 
     174      = @_; 
     175 
     176    ASSERT( $oldTopicObject->isa('Foswiki::Meta') ) if DEBUG; 
     177    ASSERT( $newTopicObject->isa('Foswiki::Meta') ) if DEBUG; 
     178    ASSERT($oldAttachment)                          if DEBUG; 
     179    ASSERT($newAttachment)                          if DEBUG; 
     180    ASSERT($cUID)                                   if DEBUG; 
    179181 
    180182    my $handler = 
    181183      $this->getHandler( $oldTopicObject->web, $oldTopicObject->topic, 
    182184        $oldAttachment ); 
    183     if ($handler->storedDataExists()) { 
     185    if ( $handler->storedDataExists() ) { 
    184186        $handler->moveAttachment( $newTopicObject->web, $newTopicObject->topic, 
    185                                   $newAttachment ); 
     187            $newAttachment ); 
    186188    } 
    187189 
     
    220222sub attachmentExists { 
    221223    my ( $this, $topicObject, $att ) = @_; 
    222     my $handler = $this->getHandler( 
    223         $topicObject->web, $topicObject->topic, $att ); 
     224    my $handler = 
     225      $this->getHandler( $topicObject->web, $topicObject->topic, $att ); 
    224226    return 1 if $handler->storedDataExists(); 
     227 
    225228    # Filestore denies knowledge of it; check the meta 
    226229    $topicObject->reload() unless $topicObject->getLoadedRev(); 
     
    259262# Documented in Foswiki::Store 
    260263sub testAttachment { 
    261     my ($this, $topicObject, $attachment, $test) = @_; 
    262     my $handler = $this->getHandler( 
    263         $topicObject->web, $topicObject->topic, $attachment); 
    264     return $handler->test( $test ); 
     264    my ( $this, $topicObject, $attachment, $test ) = @_; 
     265    my $handler = 
     266      $this->getHandler( $topicObject->web, $topicObject->topic, $attachment ); 
     267    return $handler->test($test); 
    265268} 
    266269 
     
    271274    my $handler = 
    272275      $this->getHandler( $topicObject->web, $topicObject->topic, $att ); 
    273     return $handler->openStream($mode, @opts); 
     276    return $handler->openStream( $mode, @opts ); 
    274277} 
    275278 
     
    327330sub saveAttachment { 
    328331    my ( $this, $topicObject, $name, $stream, $author ) = @_; 
    329     ASSERT($topicObject->isa('Foswiki::Meta')) if DEBUG; 
    330     ASSERT(defined $name) if DEBUG; 
    331     ASSERT(defined $stream) if DEBUG; 
    332     ASSERT(defined $author) if DEBUG; 
     332    ASSERT( $topicObject->isa('Foswiki::Meta') ) if DEBUG; 
     333    ASSERT( defined $name )                      if DEBUG; 
     334    ASSERT( defined $stream )                    if DEBUG; 
     335    ASSERT( defined $author )                    if DEBUG; 
    333336    my $handler = 
    334337      $this->getHandler( $topicObject->web, $topicObject->topic, $name ); 
     
    342345sub saveTopic { 
    343346    my ( $this, $topicObject, $cUID, $options ) = @_; 
    344     ASSERT($topicObject->isa('Foswiki::Meta')) if DEBUG; 
     347    ASSERT( $topicObject->isa('Foswiki::Meta') ) if DEBUG; 
    345348    ASSERT($cUID) if DEBUG; 
    346349 
     
    370373    $topicObject->setRevisionInfo( 
    371374        { 
    372             date    => $options->{forcedate} || time(), 
     375            date => $options->{forcedate} || time(), 
    373376            author  => $cUID, 
    374377            version => $nextRev 
     
    376379    ); 
    377380 
    378     $handler->addRevisionFromText( 
    379         $topicObject->getEmbeddedStoreForm(), 
     381    $handler->addRevisionFromText( $topicObject->getEmbeddedStoreForm(), 
    380382        'save topic', $cUID, $options->{forcedate} ); 
    381383 
     
    392394sub repRev { 
    393395    my ( $this, $topicObject, $cUID, %options ) = @_; 
    394     ASSERT( $topicObject->isa( 'Foswiki::Meta' ) ) if DEBUG; 
     396    ASSERT( $topicObject->isa('Foswiki::Meta') ) if DEBUG; 
    395397    ASSERT($cUID) if DEBUG; 
    396398 
     
    410412 
    411413        # use defaults (current time, current user) 
    412         $info->{date} = time(); 
     414        $info->{date}   = time(); 
    413415        $info->{author} = $cUID; 
    414416    } 
     
    428430sub delRev { 
    429431    my ( $this, $topicObject, $cUID ) = @_; 
    430     ASSERT( $topicObject->isa('Foswiki::Meta')) if DEBUG; 
     432    ASSERT( $topicObject->isa('Foswiki::Meta') ) if DEBUG; 
    431433    ASSERT($cUID) if DEBUG; 
    432434 
     
    441443 
    442444    # restore last topic from repository 
    443     $handler->restoreLatestRevision( $cUID ); 
     445    $handler->restoreLatestRevision($cUID); 
    444446 
    445447    return $rev; 
     
    451453sub lockTopic { 
    452454    my ( $this, $topicObject, $cUID ) = @_; 
    453     ASSERT($topicObject->isa('Foswiki::Meta')) if DEBUG; 
     455    ASSERT( $topicObject->isa('Foswiki::Meta') ) if DEBUG; 
    454456    ASSERT($cUID) if DEBUG; 
    455457    my $handler = $this->getHandler( $topicObject->web, $topicObject->topic ); 
     
    530532# Documented in Foswiki::Store 
    531533sub eachAttachment { 
    532     my ($this, $topicObject) = @_; 
     534    my ( $this, $topicObject ) = @_; 
    533535 
    534536    my $handler = $this->getHandler( $topicObject->web, $topicObject->topic ); 
    535537    my @list = $handler->getAttachmentList(); 
    536538    require Foswiki::ListIterator; 
    537     return new Foswiki::ListIterator(\@list); 
     539    return new Foswiki::ListIterator( \@list ); 
    538540} 
    539541 
     
    542544    my ( $this, $webObject ) = @_; 
    543545 
    544     my $handler = $this->getHandler($webObject->web); 
     546    my $handler = $this->getHandler( $webObject->web ); 
    545547    my @list    = $handler->getTopicNames(); 
    546548 
     
    552554sub eachWeb { 
    553555    my ( $this, $webObject, $all ) = @_; 
     556 
    554557    # Undocumented; this fn actually accepts a web name as well. This is 
    555558    # to make the recursion more efficient. 
    556559    my $web = ref($webObject) ? $webObject->web : $webObject; 
    557560 
    558     my $handler = $this->getHandler( $web ); 
    559     my @list = $handler->getWebNames(); 
     561    my $handler = $this->getHandler($web); 
     562    my @list    = $handler->getWebNames(); 
    560563    if ($all) { 
    561564        my $root = $web ? "$web/" : ''; 
     
    595598    my ( $this, $query, $web, $inputTopicSet, $options ) = @_; 
    596599    ASSERT($query); 
    597     ASSERT( UNIVERSAL::isa( $query, 'Foswiki::Query::Node' ) || UNIVERSAL::isa( $query, 'Foswiki::Search::Node' ) ); 
     600    ASSERT(  UNIVERSAL::isa( $query, 'Foswiki::Query::Node' ) 
     601          || UNIVERSAL::isa( $query, 'Foswiki::Search::Node' ) ); 
    598602 
    599603    my $handler = $this->getHandler($web); 
    600     return $handler->searchInWebMetaData( $query, $web, $inputTopicSet, $this, $options ); 
     604    return $handler->searchInWebMetaData( $query, $web, $inputTopicSet, $this, 
     605        $options ); 
    601606} 
    602607 
     
    605610    my ( $this, $searchString, $web, $topics, $options ) = @_; 
    606611 
    607     my $handler = $this->getHandler($web); 
     612    my $handler       = $this->getHandler($web); 
    608613    my $inputTopicSet = new Foswiki::ListIterator($topics); 
    609614 
    610     return $handler->searchInWebContent( $searchString, $web, $inputTopicSet, $this, $options ); 
     615    return $handler->searchInWebContent( $searchString, $web, $inputTopicSet, 
     616        $this, $options ); 
    611617} 
    612618 
  • trunk/core/lib/Foswiki/Time.pm

    r3440 r3947  
    126126        $tzadj = -Time::Local::timelocal( 0, 0, 0, 1, 0, 70 ); 
    127127    } 
     128 
    128129    # try "31 Dec 2001 - 23:59"  (Foswiki date) 
    129130    # or "31 Dec 2001" 
  • trunk/core/lib/Foswiki/UI.pm

    r3946 r3947  
    2929 
    3030    $Foswiki::cfg{SwitchBoard}{attach} = { 
    31         package => 'Foswiki::UI::Attach', 
     31        package  => 'Foswiki::UI::Attach', 
    3232        function => 'attach', 
    33         context => { attach => 1 }, 
     33        context  => { attach => 1 }, 
    3434    }; 
    3535    $Foswiki::cfg{SwitchBoard}{changes} = { 
    36         package => 'Foswiki::UI::Changes', 
     36        package  => 'Foswiki::UI::Changes', 
    3737        function => 'changes', 
    38         context => { changes => 1 }, 
     38        context  => { changes => 1 }, 
    3939    }; 
    4040    $Foswiki::cfg{SwitchBoard}{edit} = { 
    41         package => 'Foswiki::UI::Edit', 
     41        package  => 'Foswiki::UI::Edit', 
    4242        function => 'edit', 
    43         context => { edit => 1 }, 
     43        context  => { edit => 1 }, 
    4444    }; 
    4545    $Foswiki::cfg{SwitchBoard}{login} = { 
    46         package => undef, 
     46        package  => undef, 
    4747        function => 'logon', 
    48         context => { ( login => 1, logon => 1 ) }, 
     48        context  => { ( login => 1, logon => 1 ) }, 
    4949    }; 
    5050    $Foswiki::cfg{SwitchBoard}{logon} = { 
    51         package => undef, 
     51        package  => undef, 
    5252        function => 'logon', 
    53         context => { ( login => 1, logon => 1 ) }, 
     53        context  => { ( login => 1, logon => 1 ) }, 
    5454    }; 
    5555    $Foswiki::cfg{SwitchBoard}{manage} = { 
    56         package => 'Foswiki::UI::Manage', 
     56        package  => 'Foswiki::UI::Manage', 
    5757        function => 'manage', 
    58         context => { manage => 1 }, 
    59         allow => { POST => 1 }, 
     58        context  => { manage => 1 }, 
     59        allow    => { POST => 1 }, 
    6060    }; 
    6161    $Foswiki::cfg{SwitchBoard}{oops} = { 
    62         package => 'Foswiki::UI::Oops', 
     62        package  => 'Foswiki::UI::Oops', 
    6363        function => 'oops_cgi', 
    64         context => { oops => 1 }, 
     64        context  => { oops => 1 }, 
    6565    }; 
    6666    $Foswiki::cfg{SwitchBoard}{preview} = { 
    67         package => 'Foswiki::UI::Preview', 
     67        package  => 'Foswiki::UI::Preview', 
    6868        function => 'preview', 
    69         context => { preview => 1 }, 
     69        context  => { preview => 1 }, 
    7070    }; 
    7171    $Foswiki::cfg{SwitchBoard}{rdiffauth} = { 
    72         package => 'Foswiki::UI::RDiff', 
     72        package  => 'Foswiki::UI::RDiff', 
    7373        function => 'diff', 
    74         context => { diff => 1 }, 
     74        context  => { diff => 1 }, 
    7575    }; 
    7676    $Foswiki::cfg{SwitchBoard}{rdiff} = { 
    77         package => 'Foswiki::UI::RDiff', 
     77        package  => 'Foswiki::UI::RDiff', 
    7878        function => 'diff', 
    79         context => { diff => 1 }, 
     79        context  => { diff => 1 }, 
    8080    }; 
    8181    $Foswiki::cfg{SwitchBoard}{register} = { 
    82         package => 'Foswiki::UI::Register', 
     82        package  => 'Foswiki::UI::Register', 
    8383        function => 'register_cgi', 
    84         context => { register => 1 }, 
     84        context  => { register => 1 }, 
     85 
    8586        # method verify must allow GET; protect in Foswiki::UI::Register 
    8687        #allow => { POST => 1 }, 
    8788    }; 
    8889    $Foswiki::cfg{SwitchBoard}{rename} = { 
    89         package => 'Foswiki::UI::Rename', 
     90        package  => 'Foswiki::UI::Rename', 
    9091        function => 'rename', 
    91         context => { rename => 1 }, 
     92        context  => { rename => 1 }, 
     93 
    9294        # Rename is 2 stage; protect in Foswiki::UI::Rename 
    9395        #allow => { POST => 1 }, 
    9496    }; 
    9597    $Foswiki::cfg{SwitchBoard}{resetpasswd} = { 
    96         package => 'Foswiki::UI::Passwords', 
     98        package  => 'Foswiki::UI::Passwords', 
    9799        function => 'resetPassword', 
    98         context => { resetpasswd => 1 }, 
    99         allow => { POST => 1 }, 
     100        context  => { resetpasswd => 1 }, 
     101        allow    => { POST => 1 }, 
    100102    }; 
    101103    $Foswiki::cfg{SwitchBoard}{rest} = { 
    102         package => 'Foswiki::UI::Rest', 
     104        package  => 'Foswiki::UI::Rest', 
    103105        function => 'rest', 
    104         context => { rest => 1 }, 
     106        context  => { rest => 1 }, 
    105107    }; 
    106108    $Foswiki::cfg{SwitchBoard}{save} = { 
    107         package => 'Foswiki::UI::Save', 
     109        package  => 'Foswiki::UI::Save', 
    108110        function => 'save', 
    109         context => { save => 1 }, 
    110         allow => { POST => 1 }, 
     111        context  => { save => 1 }, 
     112        allow    => { POST => 1 }, 
    111113    }; 
    112114    $Foswiki::cfg{SwitchBoard}{search} = { 
    113         package => 'Foswiki::UI::Search', 
     115        package  => 'Foswiki::UI::Search', 
    114116        function => 'search', 
    115         context => { search => 1 }, 
     117        context  => { search => 1 }, 
    116118    }; 
    117119    $Foswiki::cfg{SwitchBoard}{statistics} = { 
    118         package => 'Foswiki::UI::Statistics', 
     120        package  => 'Foswiki::UI::Statistics', 
    119121        function => 'statistics', 
    120         context => { statistics => 1 }, 
     122        context  => { statistics => 1 }, 
    121123    }; 
    122124    $Foswiki::cfg{SwitchBoard}{upload} = { 
    123         package => 'Foswiki::UI::Upload', 
     125        package  => 'Foswiki::UI::Upload', 
    124126        function => 'upload', 
    125         context => { upload => 1 }, 
    126         allow => { POST => 1 }, 
     127        context  => { upload => 1 }, 
     128        allow    => { POST => 1 }, 
    127129    }; 
    128130    $Foswiki::cfg{SwitchBoard}{viewauth} = { 
    129         package => 'Foswiki::UI::View', 
     131        package  => 'Foswiki::UI::View', 
    130132        function => 'view', 
    131         context => { view => 1 }, 
     133        context  => { view => 1 }, 
    132134    }; 
    133135    $Foswiki::cfg{SwitchBoard}{viewfile} = { 
    134         package => 'Foswiki::UI::Viewfile', 
     136        package  => 'Foswiki::UI::Viewfile', 
    135137        function => 'viewfile', 
    136         context => { viewfile => 1 }, 
     138        context  => { viewfile => 1 }, 
    137139    }; 
    138140    $Foswiki::cfg{SwitchBoard}{view} = { 
    139         package => 'Foswiki::UI::View', 
     141        package  => 'Foswiki::UI::View', 
    140142        function => 'view', 
    141         context => { view => 1 }, 
     143        context  => { view => 1 }, 
    142144    }; 
    143145} 
     
    192194    } 
    193195 
    194     if (ref($dispatcher) eq 'ARRAY') { 
     196    if ( ref($dispatcher) eq 'ARRAY' ) { 
     197 
    195198        # Old-style array entry in switchboard from a plugin 
    196199        my @array = @$dispatcher; 
     
    202205    } 
    203206 
    204     if ( $dispatcher->{package} && !$isInitialized{$dispatcher->{package}} ) { 
     207    if ( $dispatcher->{package} && !$isInitialized{ $dispatcher->{package} } ) { 
    205208        eval qq(use $dispatcher->{package}); 
    206209        die $@ if $@; 
    207         $isInitialized{$dispatcher->{package}} = 1; 
     210        $isInitialized{ $dispatcher->{package} } = 1; 
    208211    } 
    209212 
     
    245248        } 
    246249    } 
     250 
    247251    #print STDERR "INCOMING ".$req->method()." ".$req->url." -> ".$sub."\n"; 
    248252    #require Data::Dumper; 
     
    250254    if ( UNIVERSAL::isa( $Foswiki::engine, 'Foswiki::Engine::CLI' ) ) { 
    251255        $dispatcher->{context}->{command_line} = 1; 
    252     } elsif ( defined $req->method() 
    253               && ( 
    254                 ( defined $dispatcher->{allow} 
    255                   && !$dispatcher->{allow}->{uc($req->method())} ) 
    256                 || 
    257                 ( defined $dispatcher->{deny} 
    258                   && $dispatcher->{deny}->{uc($req->method())} ) 
    259               ) 
    260             ) { 
     256    } 
     257    elsif ( 
     258        defined $req->method() 
     259        && ( 
     260            ( 
     261                defined $dispatcher->{allow} 
     262                && !$dispatcher->{allow}->{ uc( $req->method() ) } 
     263            ) 
     264            || ( defined $dispatcher->{deny} 
     265                && $dispatcher->{deny}->{ uc( $req->method() ) } ) 
     266        ) 
     267      ) 
     268    { 
    261269        $res = new Foswiki::Response(); 
    262270        $res->header( -type => 'text/html', -status => '405' ); 
    263         $res->print('Bad Request: '.uc($req->method()).' denied for ' 
    264                       .$req->action()); 
     271        $res->print( 'Bad Request: ' 
     272              . uc( $req->method() ) 
     273              . ' denied for ' 
     274              . $req->action() ); 
    265275        return $res; 
    266276    } 
    267     $res = _execute( $req, \&$sub, %{$dispatcher->{context}} ); 
     277    $res = _execute( $req, \&$sub, %{ $dispatcher->{context} } ); 
    268278    return $res; 
    269279} 
     
    298308        catch Foswiki::ValidationException with { 
    299309            my $query = $session->{request}; 
     310 
    300311            # Redirect with passthrough so we don't lose the 
    301312            # original query params. We use the login script for 
    302313            # validation because it already has the correct criteria 
    303314            # in httpd.conf for Apache login. 
    304             my $url     = $session->getScriptUrl( 
    305                 0, 'login', $session->{webName}, $session->{topicName} ); 
    306             $query->param( -name => 'action', 
    307                            -value => 'validate' ); 
    308             $query->param( -name => 'origurl', 
    309                            -value => $session->{request}->uri ); 
     315            my $url = 
     316              $session->getScriptUrl( 0, 'login', $session->{webName}, 
     317                $session->{topicName} ); 
     318            $query->param( 
     319                -name  => 'action', 
     320                -value => 'validate' 
     321            ); 
     322            $query->param( 
     323                -name  => 'origurl', 
     324                -value => $session->{request}->uri 
     325            ); 
    310326            $session->redirect( $url, 1 );    # with passthrough 
    311327        } 
     
    395411sub logon { 
    396412    my $session = shift; 
    397     if (($session->{request}->param('action') ||'') eq 'validate' 
    398           # Force login if not recognisably authenticated 
    399           && $session->inContext('authenticated')) { 
    400         Foswiki::Validation::validate( $session ); 
    401     } else { 
    402         $session->{users}->{loginManager}->login( 
    403             $session->{request}, $session ); 
     413    if ( 
     414        ( $session->{request}->param('action') || '' ) eq 'validate' 
     415 
     416        # Force login if not recognisably authenticated 
     417        && $session->inContext('authenticated') 
     418      ) 
     419    { 
     420        Foswiki::Validation::validate($session); 
     421    } 
     422    else { 
     423        $session->{users}->{loginManager} 
     424          ->login( $session->{request}, $session ); 
    404425    } 
    405426} 
     
    496517    # Check the nonce before we do anything else 
    497518    my $nonce = $session->{request}->param('validation_key'); 
    498     if (!defined($nonce) || !Foswiki::Validation::isValidNonce( 
    499         $session->getCGISession(), $nonce)) { 
     519    if ( !defined($nonce) 
     520        || !Foswiki::Validation::isValidNonce( $session->getCGISession(), 
     521            $nonce ) ) 
     522    { 
    500523        throw Foswiki::ValidationException(); 
    501524    } 
    502     if (defined($nonce)) { 
     525    if ( defined($nonce) ) { 
     526 
    503527        # Expire the nonce. If the user tries to use it again, they will 
    504528        # be prompted. 
    505         Foswiki::Validation::expireValidationKeys( 
    506             $session->getCGISession(), $nonce ); 
     529        Foswiki::Validation::expireValidationKeys( $session->getCGISession(), 
     530            $nonce ); 
    507531    } 
    508532} 
  • trunk/core/lib/Foswiki/UI/ChangeForm.pm

    r3440 r3947  
    6262        my ( $formWeb, $formTopic ) = 
    6363          $session->normalizeWebTopicName( $topicObject->web, $form ); 
    64         my $formLabelContent = 
    65           '&nbsp;' 
    66           . ( $session->topicExists( $formWeb, $formTopic ) 
     64        my $formLabelContent = '&nbsp;' 
     65          . ( 
     66            $session->topicExists( $formWeb, $formTopic ) 
    6767            ? '[[' . $formWeb . '.' . $formTopic . '][' . $form . ']]' 
    68             : $form ); 
     68            : $form 
     69          ); 
    6970        $formList .= CGI::label( { for => $formElemId }, $formLabelContent ); 
    7071    } 
  • trunk/core/lib/Foswiki/UI/Changes.pm

    r3440 r3947  
    88use Error qw( :try ); 
    99 
    10 use Foswiki (); 
    11 use Foswiki::UI (); 
     10use Foswiki       (); 
     11use Foswiki::UI   (); 
    1212use Foswiki::Time (); 
    1313 
  • trunk/core/lib/Foswiki/UI/Edit.pm

    r3440 r3947  
    1414use Error qw( :try ); 
    1515 
    16 use Foswiki (); 
    17 use Foswiki::UI (); 
     16use Foswiki                (); 
     17use Foswiki::UI            (); 
    1818use Foswiki::OopsException (); 
    1919 
  • trunk/core/lib/Foswiki/UI/Manage.pm

    r3820 r3947  
    1717use Error qw( :try ); 
    1818 
    19 use Foswiki (); 
    20 use Foswiki::UI (); 
     19use Foswiki                (); 
     20use Foswiki::UI            (); 
    2121use Foswiki::OopsException (); 
    22 use Foswiki::Sandbox (); 
     22use Foswiki::Sandbox       (); 
    2323 
    2424=begin TML 
     
    168168    } 
    169169 
    170     Foswiki::UI::checkValidationKey( 
    171         $session, 'createweb', $session->{webName}, $session->{topicName} ); 
     170    Foswiki::UI::checkValidationKey( $session, 'createweb', $session->{webName}, 
     171        $session->{topicName} ); 
    172172 
    173173    # Get options from the form (only those options that are already 
    174174    # set in the template WebPreferences topic are changed, so we can 
    175175    # just copy everything) 
    176     my $me = $session->{users}->getWikiName($cUID); 
     176    my $me   = $session->{users}->getWikiName($cUID); 
    177177    my $opts = { 
    178178 
     
    181181        ALLOWTOPICCHANGE => $me, 
    182182        ALLOWTOPICRENAME => 'nobody', 
    183         ALLOWWEBCHANGE => $me, 
    184         ALLOWWEBRENAME => $me, 
     183        ALLOWWEBCHANGE   => $me, 
     184        ALLOWWEBRENAME   => $me, 
    185185    }; 
    186186    foreach my $p ( $query->param() ) { 
     
    374374 
    375375    $newTopicObject->remove('PREFERENCE');    # delete previous settings 
    376     # Note: $Foswiki::regex{setVarRegex} cannot be used as it requires 
    377     # use in code that parses multiline settings line by line. 
     376        # Note: $Foswiki::regex{setVarRegex} cannot be used as it requires 
     377        # use in code that parses multiline settings line by line. 
    378378    $settings =~ 
    379       s(^(?:\t|   )+\*\s+(Set|Local)\s+($Foswiki::regex{tagNameRegex})\s*=\s*?(.*)$) 
     379s(^(?:\t|   )+\*\s+(Set|Local)\s+($Foswiki::regex{tagNameRegex})\s*=\s*?(.*)$) 
    380380        (_parsePreferenceValue($newTopicObject, $1, $2, $3))mgeo; 
    381  
    382381 
    383382    my $saveOpts = {}; 
     
    393392            && $info->{author} ne $session->{user} ) 
    394393        { 
    395             my $currTopicObject = Foswiki::Meta->load( 
    396                 $session, $web, $topic ); 
     394            my $currTopicObject = Foswiki::Meta->load( $session, $web, $topic ); 
    397395            $newTopicObject->merge($currTopicObject); 
    398396        } 
  • trunk/core/lib/Foswiki/UI/Passwords.pm

    r3440 r3947  
    1414use Error qw( :try ); 
    1515 
    16 use Foswiki (); 
     16use Foswiki                (); 
    1717use Foswiki::OopsException (); 
    18 use Foswiki::Sandbox (); 
     18use Foswiki::Sandbox       (); 
    1919 
    2020=begin TML 
  • trunk/core/lib/Foswiki/UI/Preview.pm

    r3440 r3947  
    66use Error qw( :try ); 
    77 
    8 use Foswiki (); 
    9 use Foswiki::UI::Save (); 
     8use Foswiki                (); 
     9use Foswiki::UI::Save      (); 
    1010use Foswiki::OopsException (); 
    1111 
  • trunk/core/lib/Foswiki/UI/RDiff.pm

    r3721 r3947  
    1515use Error qw( :try ); 
    1616 
    17 use Foswiki (); 
     17use Foswiki     (); 
    1818use Foswiki::UI (); 
    1919 
     
    475475    } 
    476476    my $revHigh = $query->param('rev1'); 
    477     my $revLow = $query->param('rev2'); 
     477    my $revLow  = $query->param('rev2'); 
    478478 
    479479    my $skin = $session->getSkin(); 
     
    491491    if ( $diffType eq 'last' ) { 
    492492        $revHigh = $maxrev; 
    493         $revLow = $maxrev - 1; 
     493        $revLow  = $maxrev - 1; 
    494494    } 
    495495 
     
    514514    # do one or more diffs 
    515515    $difftmpl = $topicObject->expandMacros($difftmpl); 
    516     my $rHigh            = $revHigh; 
    517     my $rLow             = $revLow; 
     516    my $rHigh          = $revHigh; 
     517    my $rLow           = $revLow; 
    518518    my $isMultipleDiff = 0; 
    519519 
    520520    if ( ( $diffType eq 'history' ) && ( $rHigh > $rLow + 1 ) ) { 
    521         $rLow            = $rHigh - 1; 
     521        $rLow           = $rHigh - 1; 
    522522        $isMultipleDiff = 1; 
    523523    } 
     
    528528 
    529529        # Load the revs being diffed 
    530         $topicObject{$rHigh} = Foswiki::Meta->load( 
    531             $session, $topicObject->web, $topicObject->topic, $rHigh ) 
     530        $topicObject{$rHigh} = 
     531          Foswiki::Meta->load( $session, $topicObject->web, $topicObject->topic, 
     532            $rHigh ) 
    532533          unless $topicObject{$rHigh}; 
    533         ASSERT($topicObject{$rHigh}->getLoadedRev() == $rHigh, $topicObject{$rHigh}->getLoadedRev()." == $rHigh") if DEBUG; 
    534  
    535         $topicObject{$rLow} = Foswiki::Meta->load( 
    536             $session, $topicObject->web, $topicObject->topic, $rLow ) 
     534        ASSERT( 
     535            $topicObject{$rHigh}->getLoadedRev() == $rHigh, 
     536            $topicObject{$rHigh}->getLoadedRev() . " == $rHigh" 
     537        ) if DEBUG; 
     538 
     539        $topicObject{$rLow} = 
     540          Foswiki::Meta->load( $session, $topicObject->web, $topicObject->topic, 
     541            $rLow ) 
    537542          unless $topicObject{$rLow}; 
    538         ASSERT($topicObject{$rLow}->getLoadedRev() == $rLow, $topicObject{$rLow}->getLoadedRev()." == $rLow") if DEBUG; 
     543        ASSERT( 
     544            $topicObject{$rLow}->getLoadedRev() == $rLow, 
     545            $topicObject{$rLow}->getLoadedRev() . " == $rLow" 
     546        ) if DEBUG; 
    539547 
    540548        my $diff = $difftmpl; 
     
    550558        } 
    551559        else { 
    552             $rInfo = $session->renderer->renderRevisionInfo( $topicObject, $rHigh, 
     560            $rInfo = 
     561              $session->renderer->renderRevisionInfo( $topicObject, $rHigh, 
    553562                '$date - $wikiusername' ); 
    554             $rInfo2 = $session->renderer->renderRevisionInfo( $topicObject, $rHigh, 
     563            $rInfo2 = 
     564              $session->renderer->renderRevisionInfo( $topicObject, $rHigh, 
    555565                '$rev ($date - $time) - $wikiusername' ); 
    556566        } 
     
    593603        $page .= $diff; 
    594604        $rHigh = $rHigh - 1; 
    595         $rLow = $rLow - 1; 
    596         $rLow = 1 if ( $rLow < 1 ); 
     605        $rLow  = $rLow - 1; 
     606        $rLow  = 1 if ( $rLow < 1 ); 
    597607    } while ( $diffType eq 'history' && ( $rHigh > $revLow || $rHigh == 1 ) ); 
    598608 
  • trunk/core/lib/Foswiki/UI/Register.pm

    r3946 r3947  
    1515use Error qw( :try ); 
    1616 
    17 use Foswiki (); 
     17use Foswiki                (); 
    1818use Foswiki::OopsException (); 
    19 use Foswiki::Sandbox (); 
     19use Foswiki::Sandbox       (); 
    2020 
    2121# Keys from the user data that should *not* be included in 
     
    5555    my $action = $query->param('action') || ''; 
    5656 
    57     if ( $action ne 'verify' && $query && $query->method() && 
    58                                 uc($query->method()) ne 'POST') { 
    59         throw Foswiki::OopsException( 
    60             'attention', 
    61             web   => $session->{webName}, 
    62             topic => $session->{topicName}, 
    63             def   => 'post_method_only', 
    64             params => [ 'upload' ] 
     57    if (   $action ne 'verify' 
     58        && $query 
     59        && $query->method() 
     60        && uc( $query->method() ) ne 'POST' ) 
     61    { 
     62        throw Foswiki::OopsException( 
     63            'attention', 
     64            web    => $session->{webName}, 
     65            topic  => $session->{topicName}, 
     66            def    => 'post_method_only', 
     67            params => ['upload'] 
    6568        ); 
    6669    } 
     
    386389    my $file = _codeFile( $data->{VerificationCode} ); 
    387390    my $F; 
    388     open( $F, '>', $file ) or throw Error::Simple( 'Failed to open file: ' . $! ); 
     391    open( $F, '>', $file ) 
     392      or throw Error::Simple( 'Failed to open file: ' . $! ); 
    389393    print $F '# Verification code', "\n"; 
    390394 
  • trunk/core/lib/Foswiki/UI/Rename.pm

    r3945 r3947  
    7272    my ( $session, $oldWeb, $oldTopic ) = @_; 
    7373 
    74     my $query         = $session->{cgiQuery}; 
    75     my $newTopic      = $query->param('newtopic')      || ''; 
    76     my $newWeb        = $query->param('newweb')        || ''; 
     74    my $query    = $session->{cgiQuery}; 
     75    my $newTopic = $query->param('newtopic') || ''; 
     76    my $newWeb   = $query->param('newweb') || ''; 
    7777 
    7878    # Validate the new web name 
     
    136136    } 
    137137 
    138     my $attachment = $query->param('attachment'); 
     138    my $attachment    = $query->param('attachment'); 
    139139    my $newAttachment = $query->param('newattachment'); 
    140140 
     
    179179                    return Foswiki::Sandbox::sanitizeAttachmentName($att); 
    180180                } 
    181                ); 
     181            ); 
    182182        } 
    183183 
     
    232232 
    233233    # Has user selected new name yet? 
    234     if ( !$newTopic || ($attachment && !$newAttachment) || $confirm ) { 
     234    if ( !$newTopic || ( $attachment && !$newAttachment ) || $confirm ) { 
    235235        $newAttachment ||= $attachment; 
    236236 
     
    238238        Foswiki::UI::checkAccess( $session, 'VIEW', $old ); 
    239239 
    240         _newTopicOrAttachmentScreen( 
    241             $session, $old, $new, $attachment, $newAttachment, $confirm ); 
     240        _newTopicOrAttachmentScreen( $session, $old, $new, $attachment, 
     241            $newAttachment, $confirm ); 
    242242        return; 
    243243 
    244244    } 
    245245 
    246     return if ($query && $query->method() 
    247                        && uc($query->method()) ne 'POST'); 
    248  
    249     Foswiki::UI::checkValidationKey( 
    250         $session, 'rename', $session->{webName}, $session->{topicName} ); 
     246    return 
     247      if ( $query 
     248        && $query->method() 
     249        && uc( $query->method() ) ne 'POST' ); 
     250 
     251    Foswiki::UI::checkValidationKey( $session, 'rename', $session->{webName}, 
     252        $session->{topicName} ); 
    251253 
    252254    # Update references in referring pages - not applicable to attachments. 
     
    258260    } 
    259261 
    260     _moveTopicOrAttachment( 
    261         $session, $old, $new, $attachment, $newAttachment, $refs ); 
     262    _moveTopicOrAttachment( $session, $old, $new, $attachment, $newAttachment, 
     263        $refs ); 
    262264 
    263265    my $new_url; 
     
    293295            } 
    294296            else { 
     297 
    295298                # No parent topic, redirect to home topic 
    296299                $new_url = 
     
    334337    # If the user is not allowed to rename anything in the current 
    335338    # web - stop here 
    336     Foswiki::UI::checkAccess( $session, 'RENAME', $oldWebObject); 
     339    Foswiki::UI::checkAccess( $session, 'RENAME', $oldWebObject ); 
    337340 
    338341    my $newParentWeb = $query->param('newparentweb') || ''; 
     
    389392    # This also ensures we check root webs for ALLOWROOTRENAME and 
    390393    # DENYROOTRENAME 
    391     my $oldParentWebObject = new Foswiki::Meta( 
    392         $session, $oldParentWeb || undef ); 
     394    my $oldParentWebObject = 
     395      new Foswiki::Meta( $session, $oldParentWeb || undef ); 
    393396    Foswiki::UI::checkAccess( $session, 'RENAME', $oldParentWebObject ); 
    394397 
     
    401404    my $newTopic; 
    402405    my $lockFailure = ''; 
    403     my $confirm     = $query->param('confirm') || ''; 
     406    my $confirm = $query->param('confirm') || ''; 
    404407 
    405408    Foswiki::UI::checkWebExists( $session, $oldWeb, 
     
    473476                $info->{modify}{$ref}{summary} = $refs{$ref}; 
    474477                $info->{modify}{$ref}{access} = 
    475                   $topicObject->haveAccess( 'CHANGE' ); 
     478                  $topicObject->haveAccess('CHANGE'); 
    476479                if ( !$info->{modify}{$ref}{access} ) { 
    477480                    $info->{modify}{$ref}{accessReason} = 
     
    491494            require Foswiki::WebFilter; 
    492495            next unless $Foswiki::WebFilter::public->ok( $session, $subweb ); 
    493             _leaseContents( $session, $info, 
    494                             $oldWebObject->web . '/' . $subweb, $confirm ); 
     496            _leaseContents( $session, $info, $oldWebObject->web . '/' . $subweb, 
     497                $confirm ); 
    495498        } 
    496499 
     
    593596    } 
    594597 
    595     Foswiki::UI::checkValidationKey( 
    596         $session, 'rename', $session->{webName}, $session->{topicName} ); 
     598    Foswiki::UI::checkValidationKey( $session, 'rename', $session->{webName}, 
     599        $session->{topicName} ); 
    597600 
    598601    my $newWebObject = Foswiki::Meta->new( $session, $newWeb ); 
     
    636639    # also remove lease on all referring topics 
    637640    foreach my $ref (@$refs) { 
    638         my @path = split( /[.\/]/, $ref ); 
     641        my @path        = split( /[.\/]/, $ref ); 
    639642        my $webTopic    = pop(@path); 
    640643        my $webIter     = join( '/', @path ); 
     
    735738    if ($attachment) { 
    736739        try { 
    737             $from->moveAttachment( 
    738                 $attachment, $to, new_name => $toattachment ); 
     740            $from->moveAttachment( $attachment, $to, 
     741                new_name => $toattachment ); 
    739742        } 
    740743        catch Error::Simple with { 
     
    831834    my $repl     = $newTopic; 
    832835 
    833     my $newWeb = $args->{newWeb}; 
    834     my $oldWeb = $args->{oldWeb}; 
     836    my $newWeb  = $args->{newWeb}; 
     837    my $oldWeb  = $args->{oldWeb}; 
    835838    my $sameWeb = ( $oldWeb eq $newWeb ); 
    836839 
     
    874877    ASSERT( defined $args->{oldWeb} ) if DEBUG; 
    875878    ASSERT( defined $args->{newWeb} ) if DEBUG; 
    876     ASSERT( $text !~ /$MARKER/ ) if DEBUG; 
     879    ASSERT( $text !~ /$MARKER/ )      if DEBUG; 
    877880 
    878881    my $newWeb = $args->{newWeb}; 
     
    904907 
    905908    my $renderer  = $session->renderer; 
    906     my $webObject = Foswiki::Meta->new( $session, $from->web()); 
     909    my $webObject = Foswiki::Meta->new( $session, $from->web() ); 
    907910    my $it        = $webObject->eachTopic(); 
    908911    my $oldTopic  = $from->topic(); 
     
    911914 
    912915        # exclude this topic from the list 
    913         topics    => [ grep { !/^$oldTopic$/ } $it->all() ], 
    914  
    915         inWeb     => $from->web, 
    916         inTopic   => $from->topic, 
    917  
    918         oldWeb    => $from->web, 
     916        topics => [ grep { !/^$oldTopic$/ } $it->all() ], 
     917 
     918        inWeb   => $from->web, 
     919        inTopic => $from->topic, 
     920 
     921        oldWeb => $from->web, 
     922 
    919923        #oldTopic => will be filled in by _replaceInternalRefs 
    920924 
    921         newWeb    => $from->web, 
     925        newWeb => $from->web, 
     926 
    922927        #newTopic => will be filled in by _replaceInternalRefs 
    923928    }; 
     
    938943    # Ok, let's look for links to topics in the 
    939944    # new web and remove their web qualifiers 
    940     $webObject = Foswiki::Meta->new( $session, $to->web()); 
     945    $webObject = Foswiki::Meta->new( $session, $to->web() ); 
    941946    $it = $webObject->eachTopic(); 
    942947 
     
    947952        fullPaths => 0, 
    948953 
    949         inWeb     => $to->web, 
    950         inTopic   => $to->topic, 
    951  
    952         oldWeb    => $to->web, 
     954        inWeb   => $to->web, 
     955        inTopic => $to->topic, 
     956 
     957        oldWeb => $to->web, 
     958 
    953959        #oldTopic => will be filled in by _replaceInternalRefs 
    954960 
    955         newWeb    => $to->web, 
     961        newWeb => $to->web, 
     962 
    956963        #newTopic => will be filled in by _replaceInternalRefs 
    957964    }; 
     
    990997# Display screen so user can decide on new web, topic, attachment names. 
    991998sub _newTopicOrAttachmentScreen { 
    992     my ( $session, $from, $to, $attachment, $toattachment, 
    993          $confirm, $doAllowNonWikiWord ) = @_; 
     999    my ( $session, $from, $to, $attachment, $toattachment, $confirm, 
     1000        $doAllowNonWikiWord ) 
     1001      = @_; 
    9941002 
    9951003    my $query          = $session->{cgiQuery}; 
     
    10181026 
    10191027    if ( $to->web eq $Foswiki::cfg{TrashWebName} ) { 
     1028 
    10201029        # Deleting an attachment or a topic 
    1021         if ( $attachment ) { 
     1030        if ($attachment) { 
     1031 
    10221032            # Trashing an attachment; look for a non-conflicting name in the 
    10231033            # trash web 
    10241034            my $base = $toattachment || $attachment; 
    1025             my $ext  = ''; 
    1026             if ($base =~ s/^(.*)(\..*?)$/$1_/) { 
     1035            my $ext = ''; 
     1036            if ( $base =~ s/^(.*)(\..*?)$/$1_/ ) { 
    10271037                $ext = $2; 
    10281038            } 
    1029             my $n    = 1; 
    1030             while ( $to->hasAttachment( $toattachment )) { 
     1039            my $n = 1; 
     1040            while ( $to->hasAttachment($toattachment) ) { 
    10311041                $toattachment = $base . $n . $ext; 
    10321042                $n++; 
    10331043            } 
    10341044 
    1035         } else { 
     1045        } 
     1046        else { 
     1047 
    10361048            # Trashing a topic; look for a non-conflicting name in the 
    10371049            # trash web 
     
    12561268    $tmpl =~ s/%LOCAL_SEARCH%/$search/go; 
    12571269 
    1258     my $fromWebHome = new Foswiki::Meta( 
    1259         $session, $from->web, $Foswiki::cfg{HomeTopicName}); 
     1270    my $fromWebHome = 
     1271      new Foswiki::Meta( $session, $from->web, $Foswiki::cfg{HomeTopicName} ); 
    12601272    $tmpl = $fromWebHome->expandMacros($tmpl); 
    12611273    $tmpl = $fromWebHome->renderTML($tmpl); 
     
    12751287 
    12761288        # Check validity of web and topic 
    1277         $itemWeb = Foswiki::Sandbox::untaint( 
    1278             $itemWeb, \&Foswiki::Sandbox::validateWebName); 
    1279         $itemTopic = Foswiki::Sandbox::untaint( 
    1280             $itemTopic, \&Foswiki::Sandbox::validateTopicName); 
     1289        $itemWeb = Foswiki::Sandbox::untaint( $itemWeb, 
     1290            \&Foswiki::Sandbox::validateWebName ); 
     1291        $itemTopic = Foswiki::Sandbox::untaint( $itemTopic, 
     1292            \&Foswiki::Sandbox::validateTopicName ); 
    12811293 
    12821294        # Skip web.topic that fails validation 
    1283         next unless ($itemWeb && $itemTopic); 
    1284  
    1285         ASSERT($itemWeb !~ /\./) if DEBUG; # cos we will split on . later 
     1295        next unless ( $itemWeb && $itemTopic ); 
     1296 
     1297        ASSERT( $itemWeb !~ /\./ ) if DEBUG;    # cos we will split on . later 
    12861298        push @result, "$itemWeb.$itemTopic"; 
    12871299    } 
     
    13131325    my %results; 
    13141326    foreach my $searchWeb (@webs) { 
    1315         my $interWeb = ($searchWeb ne $om->web()); 
     1327        my $interWeb = ( $searchWeb ne $om->web() ); 
    13161328        next if ( $allWebs && !$interWeb ); 
    13171329 
     
    13191331        my $searchString = Foswiki::Render::getReferenceRE( 
    13201332            $om->web(), $om->topic(), 
    1321             grep    => 1, 
     1333            grep     => 1, 
    13221334            interweb => $interWeb 
    13231335        ); 
     
    13251337          . Foswiki::Render::getReferenceRE( 
    13261338            $om->web(), $om->topic(), 
    1327             grep    => 1, 
     1339            grep     => 1, 
    13281340            interweb => $interWeb, 
    1329             url     => 1 
     1341            url      => 1 
    13301342          ); 
    13311343        my @topicList = (); 
     
    13741386 
    13751387    foreach my $item (@$refs) { 
    1376         my ( $itemWeb, $itemTopic ) = split(/\./, $item, 2); 
     1388        my ( $itemWeb, $itemTopic ) = split( /\./, $item, 2 ); 
    13771389 
    13781390        if ( $session->topicExists( $itemWeb, $itemTopic ) ) { 
  • trunk/core/lib/Foswiki/UI/Rest.pm

    r3941 r3947  
    7676        # SMELL: excess brackets in RE? 
    7777        unless ( $topic =~ /((?:.*[\.\/])+)(.*)/ ) { 
    78             $res->header( -type   => 'text/html', -status => '400' ); 
     78            $res->header( -type => 'text/html', -status => '400' ); 
    7979            $err = 'ERROR: (400) Invalid REST invocation' 
    8080              . " - Invalid topic parameter $topic\n"; 
    81             $res->print( $err ); 
     81            $res->print($err); 
    8282            throw Foswiki::EngineException( 400, $err, $res ); 
    8383        } 
     
    9494    my $login = $req->param('username'); 
    9595    if ($login) { 
    96         my $pass  = $req->param('password'); 
     96        my $pass = $req->param('password'); 
    9797        my $validation = $session->{users}->checkPassword( $login, $pass ); 
    9898        unless ($validation) { 
    99             $res->header( -type   => 'text/html', -status => '401' ); 
     99            $res->header( -type => 'text/html', -status => '401' ); 
    100100            $err = "ERROR: (401) Can't login as $login"; 
    101101            $res->print($err); 
     
    112112    try { 
    113113        $session->{users}->{loginManager}->checkAccess(); 
    114     } catch Error with { 
    115         my $e   = shift; 
    116         $res->header( -type   => 'text/html', -status => '401' ); 
     114    } 
     115    catch Error with { 
     116        my $e = shift; 
     117        $res->header( -type => 'text/html', -status => '401' ); 
    117118        $err = "ERROR: (401) $e"; 
    118119        $res->print($err); 
     
    127128    unless ( $pathInfo =~ m#/(.*?)[./]([^/]*)# ) { 
    128129 
    129         $res->header( -type   => 'text/html', -status => '400' ); 
     130        $res->header( -type => 'text/html', -status => '400' ); 
    130131        $err = "ERROR: (400) Invalid REST invocation - $pathInfo is malformed"; 
    131132        $res->print($err); 
     
    139140 
    140141    # Check we have this handler 
    141     unless ( $record ) { 
    142         $res->header( -type   => 'text/html', -status => '404' ); 
    143         $err = 'ERROR: (404) Invalid REST invocation - ' 
    144           .$pathInfo.' does not refer to a known handler'; 
     142    unless ($record) { 
     143        $res->header( -type => 'text/html', -status => '404' ); 
     144        $err = 
     145            'ERROR: (404) Invalid REST invocation - ' 
     146          . $pathInfo 
     147          . ' does not refer to a known handler'; 
    145148        $res->print($err); 
    146149        throw Foswiki::EngineException( 404, $err, $res ); 
     
    148151 
    149152    # Check the method is allowed 
    150     if ($record->{http_allow} && defined $req->method()) { 
    151         my %allowed = map { $_ => 1 } split (/[,\s]+/, $record->{http_allow}); 
    152         unless ($allowed{uc($req->method())}) { 
     153    if ( $record->{http_allow} && defined $req->method() ) { 
     154        my %allowed = map { $_ => 1 } split( /[,\s]+/, $record->{http_allow} ); 
     155        unless ( $allowed{ uc( $req->method() ) } ) { 
    153156            $res->header( -type => 'text/html', -status => '405' ); 
    154             $err = 'ERROR: (405) Bad Request: '.uc($req->method()).' denied'; 
     157            $err = 
     158              'ERROR: (405) Bad Request: ' . uc( $req->method() ) . ' denied'; 
    155159            $res->print($err); 
    156160            throw Foswiki::EngineException( 404, $err, $res ); 
     
    159163 
    160164    # Check someone is logged in 
    161     if ($record->{authenticate}) { 
     165    if ( $record->{authenticate} ) { 
    162166        unless ( $session->inContext('authenticated') 
    163                    || $Foswiki::cfg{LoginManager} eq 'none' ) { 
    164             $res->header( -type   => 'text/html', -status => '401' ); 
     167            || $Foswiki::cfg{LoginManager} eq 'none' ) 
     168        { 
     169            $res->header( -type => 'text/html', -status => '401' ); 
    165170            $err = "ERROR: (401) $pathInfo requires you to be logged in"; 
    166171            $res->print($err); 
     
    170175 
    171176    # Validate the request 
    172     if ($record->{validate}) { 
     177    if ( $record->{validate} ) { 
    173178        my $nonce = $req->param('validation_key'); 
    174         if (!defined($nonce) || !Foswiki::Validation::isValidNonce( 
    175             $session->getCGISession(), $nonce)) { 
    176             $res->header( -type   => 'text/html', -status => '401' ); 
     179        if ( 
     180            !defined($nonce) 
     181            || !Foswiki::Validation::isValidNonce( 
     182                $session->getCGISession(), $nonce 
     183            ) 
     184          ) 
     185        { 
     186            $res->header( -type => 'text/html', -status => '401' ); 
    177187            $err = "ERROR: (403) Invalid validation code"; 
    178188            $res->print($err); 
    179189            throw Foswiki::EngineException( 401, $err, $res ); 
    180190        } 
     191 
    181192        # SMELL: Note we don't expire the validation code. If we expired it, 
    182193        # then subsequent requests using the same code would have to be 
     
    197208    } 
    198209    elsif ($result) { 
     210 
    199211        # If the handler doesn't want to handle all the details of the 
    200212        # response, they can return a page here and get it 200'd 
    201213        $session->writeCompletePage($result); 
    202214    } 
     215 
    203216    # Otherwise it's assumed that the handler dealt with the response. 
    204217} 
  • trunk/core/lib/Foswiki/UI/Save.pm

    r3925 r3947  
    1616use Assert; 
    1717 
    18 use Foswiki (); 
    19 use Foswiki::UI (); 
    20 use Foswiki::Meta (); 
     18use Foswiki                (); 
     19use Foswiki::UI            (); 
     20use Foswiki::Meta          (); 
    2121use Foswiki::OopsException (); 
    2222 
     
    432432        } 
    433433        my $viewURL = $session->getScriptUrl( 1, 'view', $w, $t ); 
    434         $session->redirect($session->redirectto($viewURL), undef, 1 ); 
     434        $session->redirect( $session->redirectto($viewURL), undef, 1 ); 
    435435 
    436436        return; 
     
    438438 
    439439    # Do this *before* we do any query parameter rewriting 
    440     Foswiki::UI::checkValidationKey($session, 'save', $web, $topic); 
     440    Foswiki::UI::checkValidationKey( $session, 'save', $web, $topic ); 
    441441 
    442442    my $editaction = lc( $query->param('editaction') ) || ''; 
     
    489489 
    490490        # drop through 
    491     } else { 
     491    } 
     492    else { 
     493 
    492494      # redirect to topic view or any other redirectto specified as an url param 
    493       $redirecturl = $session->redirectto($session->getScriptUrl( 1, 'view', $web, $topic )); 
     495        $redirecturl = 
     496          $session->redirectto( 
     497            $session->getScriptUrl( 1, 'view', $web, $topic ) ); 
    494498    } 
    495499 
     
    523527        ); 
    524528    } 
    525  
    526529 
    527530    if ( $adminCmd eq 'delRev' ) { 
  • trunk/core/lib/Foswiki/UI/Statistics.pm

    r3440 r3947  
    225225        while ( !$logFileUserName && scalar(@$line) ) { 
    226226            $logFileUserName = shift @$line; 
     227 
    227228            # Use Func::getCanonicalUserID because it accepts login, 
    228229            # wikiname or web.wikiname 
  • trunk/core/lib/Foswiki/UI/Upload.pm

    r3440 r3947  
    1515use Error qw( :try ); 
    1616 
    17 use Foswiki (); 
    18 use Foswiki::UI (); 
    19 use Foswiki::Sandbox (); 
     17use Foswiki                (); 
     18use Foswiki::UI            (); 
     19use Foswiki::Sandbox       (); 
    2020use Foswiki::OopsException (); 
    2121 
  • trunk/core/lib/Foswiki/UI/View.pm

    r3440 r3947  
    1616use Assert; 
    1717 
    18 use Foswiki (); 
    19 use Foswiki::UI (); 
    20 use Foswiki::Sandbox (); 
     18use Foswiki                (); 
     19use Foswiki::UI            (); 
     20use Foswiki::Sandbox       (); 
    2121use Foswiki::OopsException (); 
    22 use Foswiki::Store (); 
     22use Foswiki::Store         (); 
    2323 
    2424=begin TML 
     
    330330    my $page; 
    331331 
    332     if ($query->param('xml')) { 
     332    if ( $query->param('xml') ) { 
    333333        require Foswiki::TOM; 
    334334        $page = Foswiki::TOM->new->TML2TOM($text); 
  • trunk/core/lib/Foswiki/UI/Viewfile.pm

    r3469 r3947  
    140140    my $fh = $topicObject->openAttachment( $fileName, '<', version => $rev ); 
    141141 
    142     my $type   = _suffixToMimeType($fileName); 
    143     my $dispo  = 'inline;filename=' . $fileName; 
     142    my $type  = _suffixToMimeType($fileName); 
     143    my $dispo = 'inline;filename=' . $fileName; 
    144144 
    145145    #re-set to 200, in case this was a 404 or other redirect 
     
    148148      ->header( -type => $type, qq(Content-Disposition="$dispo") ); 
    149149    local $/; 
     150 
    150151    # SMELL: Maybe could be less memory hungry if we could 
    151152    # set the response body to the file handle. 
  • trunk/core/lib/Foswiki/Users.pm

    r3945 r3947  
    6868 
    6969BEGIN { 
     70 
    7071    # no point calling rand() without this 
    7172    # See Camel-3 pp 800.  "Do not call =srand()= multiple times in your 
     
    409410    my ( $this, $identifier ) = @_; 
    410411    my $cUID; 
     412 
    411413    # Someone we already know? 
    412414 
  • trunk/core/lib/Foswiki/Users/ApacheHtpasswdUser.pm

    r3944 r3947  
    44 
    55use Foswiki::Users::Password (); 
    6 our @ISA = ( 'Foswiki::Users::Password' ); 
     6our @ISA = ('Foswiki::Users::Password'); 
    77 
    88use Apache::Htpasswd (); 
  • trunk/core/lib/Foswiki/Users/BaseUserMapping.pm

    r3944 r3947  
    2929 
    3030use Foswiki::UserMapping (); 
    31 our @ISA = ( 'Foswiki::UserMapping' ); 
     31our @ISA = ('Foswiki::UserMapping'); 
    3232 
    3333use Assert; 
  • trunk/core/lib/Foswiki/Users/HtPasswdUser.pm

    r3946 r3947  
    1616 
    1717use Foswiki::Users::Password (); 
    18 our @ISA = ( 'Foswiki::Users::Password' ); 
     18our @ISA = ('Foswiki::Users::Password'); 
    1919 
    2020use Assert; 
     
    174174 
    175175    if ( $Foswiki::cfg{Htpasswd}{Encoding} eq 'sha1' ) { 
    176         my $encodedPassword = 
    177           '{SHA}' . Digest::SHA::sha1_base64( $passwd ); 
     176        my $encodedPassword = '{SHA}' . Digest::SHA::sha1_base64($passwd); 
    178177 
    179178        # don't use chomp, it relies on $/ 
  • trunk/core/lib/Foswiki/Validation.pm

    r3941 r3947  
    77 
    88use Digest::MD5 (); 
    9 use Foswiki (); 
     9use Foswiki     (); 
    1010 
    1111=begin TML 
     
    5252    my $nonce = $digester->b64digest(); 
    5353    $actions->{$nonce} = time() + $Foswiki::cfg{LeaseLength}; 
    54     #print STDERR time.": ADD $nonce ".join('; ', map { "$_=$actions->{$_}" } keys %$actions)."\n"; 
     54 
     55#print STDERR time.": ADD $nonce ".join('; ', map { "$_=$actions->{$_}" } keys %$actions)."\n"; 
    5556    $cgis->param( 'VALID_ACTIONS', $actions ); 
    56     return $form.CGI::hidden(-name => 'validation_key', -value=>$nonce); 
     57    return $form . CGI::hidden( -name => 'validation_key', -value => $nonce ); 
    5758} 
    5859 
     
    8384 
    8485sub expireValidationKeys { 
    85     my ($cgis, $key) = @_; 
     86    my ( $cgis, $key ) = @_; 
    8687    my $actions = $cgis->param('VALID_ACTIONS'); 
    8788    if ($actions) { 
    88         if (defined $key && exists $actions->{$key}) { 
    89             $actions->{$key} = 0; # force-expire this key 
     89        if ( defined $key && exists $actions->{$key} ) { 
     90            $actions->{$key} = 0;    # force-expire this key 
    9091        } 
    9192        my $deaths = 0; 
    92         my $now = time(); 
    93         while (my ($nonce, $time) = each %$actions) { 
    94             if ($time < $now) { 
     93        my $now    = time(); 
     94        while ( my ( $nonce, $time ) = each %$actions ) { 
     95            if ( $time < $now ) { 
     96 
    9597                #print STDERR time.": EXPIRE $nonce $time\n"; 
    9698                delete $actions->{$nonce}; 
     
    99101        } 
    100102        if ($deaths) { 
    101             $cgis->param('VALID_ACTIONS', $actions); 
     103            $cgis->param( 'VALID_ACTIONS', $actions ); 
    102104        } 
    103105    } 
     
    115117 
    116118sub validate { 
    117     my ( $session ) = @_; 
    118     my $query   = $session->{request}; 
    119     my $web     = $session->{webName}; 
    120     my $topic   = $session->{topicName}; 
     119    my ($session) = @_; 
     120    my $query     = $session->{request}; 
     121    my $web       = $session->{webName}; 
     122    my $topic     = $session->{topicName}; 
    121123 
    122124    my $origurl = $query->param('origurl'); 
    123     $query->delete( 'origurl' ); 
     125    $query->delete('origurl'); 
    124126 
    125127    my $tmpl = 
    126128      $session->templates->readTemplate( 'validate', $session->getSkin() ); 
    127129 
    128     if ($query->param('response')) { 
     130    if ( $query->param('response') ) { 
    129131        my $url; 
    130         if ($query->param('response') eq 'OK') { 
     132        if ( $query->param('response') eq 'OK' ) { 
    131133            if ( !$origurl || $origurl eq $query->url() ) { 
    132134                $url = $session->getScriptUrl( 0, 'view', $web, $topic ); 
     
    134136            else { 
    135137                $url = $origurl; 
     138 
    136139                # SMELL: do we ever need this? 
    137                 ASSERT($url !~ /#/) if DEBUG; 
     140                ASSERT( $url !~ /#/ ) if DEBUG; 
     141 
    138142                # Unpack params encoded in the origurl and restore them 
    139143                # to the query. If they were left in the query string they 
     
    153157        } 
    154158        else { 
     159 
    155160            #print STDERR "REJECTED; redirect to GET view\n"; 
    156161            # Validation failed; redirect to view (302) 
     
    158163            $session->redirect( $url, 0 );    # no passthrough 
    159164        } 
    160     } else { 
     165    } 
     166    else { 
     167 
    161168        #print STDERR "PROMPT VALIDATE\n"; 
    162169        # prompt for user verification 
     
    164171 
    165172        $session->{prefs}->setSessionPreferences( 
    166             ORIGURL => Foswiki::_encode( 'entity', $origurl || '' ), 
    167            ); 
     173            ORIGURL => Foswiki::_encode( 'entity', $origurl || '' ), ); 
    168174 
    169175        my $topicObject = Foswiki::Meta->new( $session, $web, $topic ); 
  • trunk/core/lib/Foswiki/ValidationException.pm

    r3944 r3947  
    1313 
    1414use Error (); 
    15 our @ISA = ( 'Error' ); # base class 
     15our @ISA = ('Error');    # base class 
    1616 
    1717=begin TML 
Note: See TracChangeset for help on using the changeset viewer.