Changeset 1057 for trunk/wiki.cgi


Ignore:
Timestamp:
Jun 10, 2007, 4:21:02 PM (14 years ago)
Author:
Dominic Hargreaves
Message:

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

File:
1 edited

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
Note: See TracChangeset for help on using the changeset viewer.