Ignore:
Timestamp:
Jun 11, 2007, 3:23:11 AM (14 years ago)
Author:
kake
Message:

Add intercept_redirect parameter to Openguides->display_node - used with the return_output parameter for testing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/OpenGuides.pm

    r1056 r1064  
    164164                      );
    165165
    166 If C<version> is omitted then the latest version will be displayed.
     166If C<version> is omitted then it will assume you want the latest version.
     167
     168Note that if you pass the C<return_output> parameter, and your node is a
     169redirecting node, this method will fake the redirect and return the output
     170that will actually end up in the user's browser.  If instead you want to see
     171the HTTP headers that will be printed in order to perform the redirect, pass
     172the C<intercept_redirect> parameter as well.  The C<intercept_redirect>
     173parameter has no effect if the node isn't a redirect, or if the
     174C<return_output> parameter is omitted.
     175
     176(At the moment, C<return_tt_vars> acts as if the C<intercept_redirect>
     177parameter was passed.)
    167178
    168179=cut
     
    171182    my ($self, %args) = @_;
    172183    my $return_output = $args{return_output} || 0;
     184    my $intercept_redirect = $args{intercept_redirect};
    173185    my $version = $args{version};
    174186    my $id = $args{id} || $self->config->home_name;
     
    277289        } elsif ( $wiki->node_exists($redirect) && $redirect ne $id && $redirect ne $oldid ) {
    278290            # Avoid loops by not generating redirects to the same node or the previous node.
    279             my $output = $self->redirect_to_node($redirect, $id);
    280             return $output if $return_output;
    281             print $output;
     291            if ( $return_output ) {
     292                if ( $intercept_redirect ) {
     293                    return $self->redirect_to_node( $redirect, $id );
     294                } else {
     295                    return $self->display_node( id            => $redirect,
     296                                                oldid         => $id,
     297                                                return_output => 1,
     298                                              );
     299                }
     300            }
     301            print $self->redirect_to_node( $redirect, $id );
    282302            return 0;
    283303        }
Note: See TracChangeset for help on using the changeset viewer.