Moving more stuff
authorMagnus Manske <magnusmanske@users.mediawiki.org>
Wed, 11 Jan 2006 12:56:13 +0000 (12:56 +0000)
committerMagnus Manske <magnusmanske@users.mediawiki.org>
Wed, 11 Jan 2006 12:56:13 +0000 (12:56 +0000)
includes/Wiki.php
index.php

index 32ace29..89c7f6c 100644 (file)
@@ -5,8 +5,16 @@
 
 class MediaWiki {
 
+       var $GET ; # Stores the $_GET variables at time of creation, can be changed
        var $params = array();
        
+       /**
+        * Constructor
+        */
+       function MediaWiki () {
+               $this->GET = $_GET ;
+       }
+       
        function setVal( $key, &$value ) {
                $this->param[strtolower( $key )] = $value;
        }
@@ -22,8 +30,15 @@ class MediaWiki {
        /**
         * Initialize the object to be known as $wgArticle for special cases
         */
-       function initializeSpecialCases ( &$title ) {
-               if ( NS_SPECIAL == $title->getNamespace() ) {
+       function initializeSpecialCases ( &$title , &$output , $action ) {
+               if ( ( $action == 'view' ) &&
+                       (!isset( $this->GET['title'] ) || $title->getPrefixedDBKey() != $this->GET['title'] ) &&
+                       !count( array_diff( array_keys( $this->GET ), array( 'action', 'title' ) ) ) )
+               {
+                       /* Redirect to canonical url, make it a 301 to allow caching */
+                       $output->setSquidMaxage( 1200 );
+                       $output->redirect( $title->getFullURL(), '301');
+               } else if ( NS_SPECIAL == $title->getNamespace() ) {
                        # actions that need to be made when we have a special pages
                        SpecialPage::executePath( $title );
                } else {
index 5500eb5..f66a375 100644 (file)
--- a/index.php
+++ b/index.php
@@ -142,20 +142,13 @@ if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) {
                $wgTitle = Title::newFromText( wfMsgForContent( 'badtitle' ) );
                $wgOut->errorpage( 'badtitle', 'badtitletext' );
        }
-} else if ( ( $action == 'view' ) &&
-       (!isset( $_GET['title'] ) || $wgTitle->getPrefixedDBKey() != $_GET['title'] ) &&
-       !count( array_diff( array_keys( $_GET ), array( 'action', 'title' ) ) ) )
-{
-       /* redirect to canonical url, make it a 301 to allow caching */
-       $wgOut->setSquidMaxage( 1200 );
-       $wgOut->redirect( $wgTitle->getFullURL(), '301');
-} else if ( $mediaWiki->initializeSpecialCases( $wgTitle ) ) {
+} else if ( $mediaWiki->initializeSpecialCases( $wgTitle , $wgOutput , $action ) ) {
        # Do nothing, everything was already done by $mediaWiki
 
 } else {
 
 
-       $wgArticle =& $mediaWiki->initializeArticle( $wgTitle, $wgRequest, $action );
+       $wgArticle = $mediaWiki->initializeArticle( $wgTitle, $wgRequest, $action );
 
        if( in_array( $action, $wgDisabledActions ) ) {
                $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' );