Slowly moving more stuff from index.php to Wiki.php
authorMagnus Manske <magnusmanske@users.mediawiki.org>
Wed, 11 Jan 2006 12:25:41 +0000 (12:25 +0000)
committerMagnus Manske <magnusmanske@users.mediawiki.org>
Wed, 11 Jan 2006 12:25:41 +0000 (12:25 +0000)
includes/Wiki.php
index.php

index 81acc7b..32ace29 100644 (file)
@@ -18,7 +18,25 @@ class MediaWiki {
                }
                return $default;
        }
+       
+       /**
+        * Initialize the object to be known as $wgArticle for special cases
+        */
+       function initializeSpecialCases ( &$title ) {
+               if ( NS_SPECIAL == $title->getNamespace() ) {
+                       # actions that need to be made when we have a special pages
+                       SpecialPage::executePath( $title );
+               } else {
+                       /* No match to special cases */
+                       return false;
+               }
+               /* Did match a special case */
+               return true;
+       }
 
+       /**
+        * Initialize the object to be known as $wgArticle for "standard" actions
+        */
        function initializeArticle( &$title, $request, $action ) {
                if( NS_MEDIA == $title->getNamespace() ) {
                        $title = Title::makeTitle( NS_IMAGE, $title->getDBkey() );
@@ -26,7 +44,7 @@ class MediaWiki {
        
                $ns = $title->getNamespace();
        
-               // Namespace might change when using redirects
+               /* Namespace might change when using redirects */
                $article = new Article( $title );
                if( $action == 'view' && !$request->getVal( 'oldid' ) ) {
                        $rTitle = Title::newFromRedirect( $article->fetchContent() );
@@ -38,7 +56,7 @@ class MediaWiki {
                                }
                }
 
-               // Categories and images are handled by a different class
+               /* Categories and images are handled by a different class */
                if( $ns == NS_IMAGE ) {
                        $b4 = $title->getPrefixedText();
                        unset( $article );
@@ -56,6 +74,9 @@ class MediaWiki {
                return $article;
        }
 
+       /**
+        * Perform one of the "standard" actions
+        */
        function performAction( $action, &$output, &$article, &$title, &$user, &$request ) {
                switch( $action ) {
                        case 'view':
index c535ae7..5500eb5 100644 (file)
--- a/index.php
+++ b/index.php
@@ -119,6 +119,9 @@ if ( !is_null( $wgTitle ) && !$wgTitle->userCanRead() ) {
 
 wfProfileIn( 'main-action' );
 
+require_once( "includes/Wiki.php" ) ;
+$mediaWiki = new MediaWiki() ;
+
 if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) {
        require_once( 'includes/SpecialSearch.php' );
        $wgTitle = Title::makeTitle( NS_SPECIAL, 'Search' );
@@ -146,13 +149,11 @@ if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) {
        /* redirect to canonical url, make it a 301 to allow caching */
        $wgOut->setSquidMaxage( 1200 );
        $wgOut->redirect( $wgTitle->getFullURL(), '301');
-} else if ( NS_SPECIAL == $wgTitle->getNamespace() ) {
-       # actions that need to be made when we have a special pages
-       SpecialPage::executePath( $wgTitle );
+} else if ( $mediaWiki->initializeSpecialCases( $wgTitle ) ) {
+       # Do nothing, everything was already done by $mediaWiki
+
 } else {
 
-       require_once( "includes/Wiki.php" ) ;
-       $mediaWiki = new MediaWiki() ;
 
        $wgArticle =& $mediaWiki->initializeArticle( $wgTitle, $wgRequest, $action );