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

index 0c8633e..1274dbf 100644 (file)
@@ -40,9 +40,9 @@ class MediaWiki {
         * Initialization of ... everything
         @return Article either the object to become $wgArticle, or NULL
         */
-       function initialize ( &$title, &$output, &$user, $request ) {
+       function initialize ( &$title, &$output, &$user, $request) {
                wfProfileIn( 'MediaWiki::initialize' );
-               $this->preliminaryChecks ( $title , $output , $request ) ;
+               $this->preliminaryChecks ( $title, $output, $request ) ;
                $article = NULL;
                if ( !$this->initializeSpecialCases( $title, $output, $request ) ) {
                        $article = $this->initializeArticle( $title, $request );
@@ -52,7 +52,39 @@ class MediaWiki {
                return $article;
        }
        
-       function preliminaryChecks ( &$title , &$output , $request ) {
+       /**
+        * Checks some initial queries
+        * Note that $title here is *not* a Title object, but a string!
+        */
+       function checkInitialQueries( $title,$action,&$output,$request, $lang) {
+               if ($request->getVal( 'printable' ) == 'yes') {
+                       $output->setPrintable();
+               }
+               
+               $ret = NULL ;
+               
+               
+               if ( '' == $title && 'delete' != $action ) {
+                       $ret = Title::newFromText( wfMsgForContent( 'mainpage' ) );
+               } elseif ( $curid = $request->getInt( 'curid' ) ) {
+                       # URLs like this are generated by RC, because rc_title isn't always accurate
+                       $ret = Title::newFromID( $curid );
+               } else {
+                       $ret = Title::newFromURL( $title );
+                       /* check variant links so that interwiki links don't have to worry about
+                          the possible different language variants
+                       */
+                       if( count($lang->getVariants()) > 1 && !is_null($ret) && $ret->getArticleID() == 0 )
+                               $lang->findVariantLink( $title, $ret );
+               
+               }
+               return $ret ;
+       }
+       
+       /**
+        * Checks for search query and anon-cannot-read case
+        */
+       function preliminaryChecks ( &$title, &$output, $request ) {
        
                # Debug statement for user levels
                // print_r($wgUser);
@@ -174,7 +206,7 @@ class MediaWiki {
        /**
         * Cleaning up by doing deferred updates, calling loadbalancer and doing the output
         */
-       function finalCleanup ( &$deferredUpdates , &$loadBalancer , &$output ) {
+       function finalCleanup ( &$deferredUpdates, &$loadBalancer, &$output ) {
                wfProfileIn( 'MediaWiki::finalCleanup' );
                $this->doUpdates( $deferredUpdates );
                $loadBalancer->saveMasterPos();
index 883f42d..2a36bca 100644 (file)
--- a/index.php
+++ b/index.php
@@ -27,7 +27,7 @@ define( 'MEDIAWIKI', true );
 require_once( './includes/Defines.php' );
 
 if( !file_exists( 'LocalSettings.php' ) ) {
-       $IP = "." ;
+       $IP = ".";
        require_once( 'includes/DefaultSettings.php' ); # used for printing the version
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -71,6 +71,11 @@ if( !file_exists( 'LocalSettings.php' ) ) {
 require_once( './LocalSettings.php' );
 require_once( 'includes/Setup.php' );
 
+
+# Initialize MediaWiki base class
+require_once( "includes/Wiki.php" );
+$mediaWiki = new MediaWiki();
+
 wfProfileIn( 'main-misc-setup' );
 OutputPage::setEncodings(); # Not really used yet
 
@@ -78,31 +83,13 @@ OutputPage::setEncodings(); # Not really used yet
 $action = $wgRequest->getVal( 'action', 'view' );
 $title = $wgRequest->getVal( 'title' );
 
-if ($wgRequest->getVal( 'printable' ) == 'yes') {
-       $wgOut->setPrintable();
+$wgTitle = $mediaWiki->checkInitialQueries( $title,$action,$wgOut, $wgRequest, $wgContLang );
+if ($wgTitle == NULL) {
+       unset( $wgTitle );
 }
 
-if ( '' == $title && 'delete' != $action ) {
-       $wgTitle = Title::newFromText( wfMsgForContent( 'mainpage' ) );
-} elseif ( $curid = $wgRequest->getInt( 'curid' ) ) {
-       # URLs like this are generated by RC, because rc_title isn't always accurate
-       $wgTitle = Title::newFromID( $curid );
-} else {
-       $wgTitle = Title::newFromURL( $title );
-       /* check variant links so that interwiki links don't have to worry about
-          the possible different language variants
-       */
-       if( count($wgContLang->getVariants()) > 1 && !is_null($wgTitle) && $wgTitle->getArticleID() == 0 )
-               $wgContLang->findVariantLink( $title, $wgTitle );
-
-}
 wfProfileOut( 'main-misc-setup' );
 
-
-# Initialize MediaWiki base class
-require_once( "includes/Wiki.php" );
-$mediaWiki = new MediaWiki();
-
 # Setting global variables in mediaWiki
 $mediaWiki->setVal( "Server", $wgServer );
 $mediaWiki->setVal( "DisableInternalSearch", $wgDisableInternalSearch );
@@ -115,7 +102,7 @@ $mediaWiki->setVal( "UseExternalEditor", $wgUseExternalEditor );
 $mediaWiki->setVal( "DisabledActions", $wgDisabledActions );
 
 $wgArticle = $mediaWiki->initialize ( $wgTitle, $wgOut, $wgUser, $wgRequest );
-$mediaWiki->finalCleanup ( $wgDeferredUpdateList , $wgLoadBalancer , $wgOut ) ;
+$mediaWiki->finalCleanup ( $wgDeferredUpdateList, $wgLoadBalancer, $wgOut );
 
 # Not sure when $wgPostCommitUpdateList gets set, so I keep this separate from finalCleanup
 $mediaWiki->doUpdates( $wgPostCommitUpdateList );