moving some more stuff from index.php to Wiki.php
authorMagnus Manske <magnusmanske@users.mediawiki.org>
Tue, 10 Jan 2006 21:20:03 +0000 (21:20 +0000)
committerMagnus Manske <magnusmanske@users.mediawiki.org>
Tue, 10 Jan 2006 21:20:03 +0000 (21:20 +0000)
includes/Wiki.php
index.php

index 9deb9ee..72240dc 100644 (file)
@@ -16,13 +16,31 @@ class MediaWiki {
                return $default ;
        }
 
-       function setCorrectArticleClass ( &$article , &$title , $namespace ) {
+       function initializeArticle ( &$title , $action ) {
+               global $wgRequest ;
+               if ( NS_MEDIA == $title->getNamespace() ) {
+                       $title = Title::makeTitle( NS_IMAGE, $title->getDBkey() );
+               }
+       
+               $ns = $title->getNamespace();
+       
+               // Namespace might change when using redirects
+               $article = new Article( $title );
+               if($action == 'view' && !$wgRequest->getVal( 'oldid' ) ) {
+                       $rTitle = Title::newFromRedirect( $article->fetchContent() );
+                       if($rTitle) {
+                               # Reload from the page pointed to later
+                               $article->mContentLoaded = false;
+                               $ns = $rTitle->getNamespace();
+                       }
+               }
+
                // Categories and images are handled by a different class
-               if ( $namespace == NS_IMAGE ) {
+               if ( $ns == NS_IMAGE ) {
                        unset($article);
                        require_once( 'includes/ImagePage.php' );
                        return new ImagePage( $title );
-               } elseif ( $namespace == NS_CATEGORY ) {
+               } elseif ( $ns == NS_CATEGORY ) {
                        unset($article);
                        require_once( 'includes/CategoryPage.php' );
                        return new CategoryPage( $title );
index 3f469de..8f82ac4 100644 (file)
--- a/index.php
+++ b/index.php
@@ -150,28 +150,12 @@ if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) {
        # actions that need to be made when we have a special pages
        SpecialPage::executePath( $wgTitle );
 } else {
-       if ( NS_MEDIA == $wgTitle->getNamespace() ) {
-               $wgTitle = Title::makeTitle( NS_IMAGE, $wgTitle->getDBkey() );
-       }
-
-       $ns = $wgTitle->getNamespace();
-
-       // Namespace might change when using redirects
-       if($action == 'view' && !$wgRequest->getVal( 'oldid' ) ) {
-               $wgArticle = new Article( $wgTitle );
-               $rTitle = Title::newFromRedirect( $wgArticle->fetchContent() );
-               if($rTitle) {
-                       # Reload from the page pointed to later
-                       $wgArticle->mContentLoaded = false;
-                       $ns = $rTitle->getNamespace();
-               }
-       }
 
 
        require_once ( "includes/Wiki.php" ) ;
        $mediaWiki = new MediaWiki() ;
 
-       $wgArticle =& $mediaWiki->setCorrectArticleClass ( $wgArticle , $wgTitle , $ns ) ;
+       $wgArticle =& $mediaWiki->initializeArticle ( $wgTitle , $action ) ;
 
        if ( in_array( $action, $wgDisabledActions ) ) {
                $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' );