From a2ddb0c68896fec8ca105bcd06f110daa1d68830 Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Tue, 10 Jan 2006 18:41:23 +0000 Subject: [PATCH] Moving image and category detection --- includes/Wiki.php | 14 ++++++++++++++ index.php | 12 ++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/includes/Wiki.php b/includes/Wiki.php index a95e31983a..9deb9ee35b 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -16,6 +16,20 @@ class MediaWiki { return $default ; } + function setCorrectArticleClass ( &$article , &$title , $namespace ) { + // Categories and images are handled by a different class + if ( $namespace == NS_IMAGE ) { + unset($article); + require_once( 'includes/ImagePage.php' ); + return new ImagePage( $title ); + } elseif ( $namespace == NS_CATEGORY ) { + unset($article); + require_once( 'includes/CategoryPage.php' ); + return new CategoryPage( $title ); + } + return $article ; + } + function performAction ( $action , &$output , &$article , &$title , &$user , &$request ) { switch( $action ) { case 'view': diff --git a/index.php b/index.php index 9fb5c76968..3f469de226 100644 --- a/index.php +++ b/index.php @@ -167,20 +167,12 @@ if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) { } } - // Categories and images are handled by a different class - if ( $ns == NS_IMAGE ) { - unset($wgArticle); - require_once( 'includes/ImagePage.php' ); - $wgArticle = new ImagePage( $wgTitle ); - } elseif ( $ns == NS_CATEGORY ) { - unset($wgArticle); - require_once( 'includes/CategoryPage.php' ); - $wgArticle = new CategoryPage( $wgTitle ); - } require_once ( "includes/Wiki.php" ) ; $mediaWiki = new MediaWiki() ; + $wgArticle =& $mediaWiki->setCorrectArticleClass ( $wgArticle , $wgTitle , $ns ) ; + if ( in_array( $action, $wgDisabledActions ) ) { $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' ); } else { -- 2.20.1