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 );
# 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' );