Changeset 1057 for trunk/wiki.cgi

Show
Ignore:
Timestamp:
06/10/07 16:21:02 (18 months ago)
Author:
dom
Message:

If an unknown action is used redirect to action=display, preserving other args (see #102)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/wiki.cgi

    r1034 r1057  
    187187    } elsif ($action eq 'about') { 
    188188        $guide->display_about(format => $format); 
    189     } else { # Default is to display a node. 
     189    } elsif ($action eq 'display') {  
    190190        if ( $format and $format eq "rdf" ) { 
    191191            display_node_rdf( node => $node ); 
     
    221221            } 
    222222        } 
    223     } 
     223    } else {  
     224        # Fallback: redirect to the display page, preserving all vars 
     225        # except for the action, which we override. 
     226        # Note: $q->Vars needs munging if we need to support any 
     227        # multi-valued params 
     228        my $params = $q->Vars; 
     229        $params->{'action'} = 'display'; 
     230        my $redir_target = $script_url . $script_name . '?'; 
     231        my @args = map { "$_=" . $params->{$_} } keys %{$params}; 
     232        $redir_target .= join ';', @args; 
     233         
     234        print $q->redirect( 
     235            -uri => $redir_target, 
     236            -status => 303 
     237        ); 
     238    } 
     239 
    224240}; 
    225241