From da73d9192f1512ea7b79a0ca4797926f22b21e76 Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Wed, 11 Jan 2006 12:25:41 +0000 Subject: [PATCH] Slowly moving more stuff from index.php to Wiki.php --- includes/Wiki.php | 25 +++++++++++++++++++++++-- index.php | 11 ++++++----- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/includes/Wiki.php b/includes/Wiki.php index 81acc7be76..32ace29074 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -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': diff --git a/index.php b/index.php index c535ae7b85..5500eb5537 100644 --- 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 ); -- 2.20.1