r12604 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r12603‎ | r12604 | r12605 >
Date:12:25, 11 January 2006
Author:magnus_manske
Status:old
Tags:
Comment:
Slowly moving more stuff from index.php to Wiki.php
Modified paths:
  • /trunk/phase3/includes/Wiki.php (modified) (history)
  • /trunk/phase3/index.php (modified) (history)

Diff [purge]

Index: trunk/phase3/index.php
@@ -119,6 +119,9 @@
120120
121121 wfProfileIn( 'main-action' );
122122
 123+require_once( "includes/Wiki.php" ) ;
 124+$mediaWiki = new MediaWiki() ;
 125+
123126 if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) {
124127 require_once( 'includes/SpecialSearch.php' );
125128 $wgTitle = Title::makeTitle( NS_SPECIAL, 'Search' );
@@ -146,13 +149,11 @@
147150 /* redirect to canonical url, make it a 301 to allow caching */
148151 $wgOut->setSquidMaxage( 1200 );
149152 $wgOut->redirect( $wgTitle->getFullURL(), '301');
150 -} else if ( NS_SPECIAL == $wgTitle->getNamespace() ) {
151 - # actions that need to be made when we have a special pages
152 - SpecialPage::executePath( $wgTitle );
 153+} else if ( $mediaWiki->initializeSpecialCases( $wgTitle ) ) {
 154+ # Do nothing, everything was already done by $mediaWiki
 155+
153156 } else {
154157
155 - require_once( "includes/Wiki.php" ) ;
156 - $mediaWiki = new MediaWiki() ;
157158
158159 $wgArticle =& $mediaWiki->initializeArticle( $wgTitle, $wgRequest, $action );
159160
Index: trunk/phase3/includes/Wiki.php
@@ -18,7 +18,25 @@
1919 }
2020 return $default;
2121 }
 22+
 23+ /**
 24+ * Initialize the object to be known as $wgArticle for special cases
 25+ */
 26+ function initializeSpecialCases ( &$title ) {
 27+ if ( NS_SPECIAL == $title->getNamespace() ) {
 28+ # actions that need to be made when we have a special pages
 29+ SpecialPage::executePath( $title );
 30+ } else {
 31+ /* No match to special cases */
 32+ return false;
 33+ }
 34+ /* Did match a special case */
 35+ return true;
 36+ }
2237
 38+ /**
 39+ * Initialize the object to be known as $wgArticle for "standard" actions
 40+ */
2341 function initializeArticle( &$title, $request, $action ) {
2442 if( NS_MEDIA == $title->getNamespace() ) {
2543 $title = Title::makeTitle( NS_IMAGE, $title->getDBkey() );
@@ -26,7 +44,7 @@
2745
2846 $ns = $title->getNamespace();
2947
30 - // Namespace might change when using redirects
 48+ /* Namespace might change when using redirects */
3149 $article = new Article( $title );
3250 if( $action == 'view' && !$request->getVal( 'oldid' ) ) {
3351 $rTitle = Title::newFromRedirect( $article->fetchContent() );
@@ -38,7 +56,7 @@
3957 }
4058 }
4159
42 - // Categories and images are handled by a different class
 60+ /* Categories and images are handled by a different class */
4361 if( $ns == NS_IMAGE ) {
4462 $b4 = $title->getPrefixedText();
4563 unset( $article );
@@ -56,6 +74,9 @@
5775 return $article;
5876 }
5977
 78+ /**
 79+ * Perform one of the "standard" actions
 80+ */
6081 function performAction( $action, &$output, &$article, &$title, &$user, &$request ) {
6182 switch( $action ) {
6283 case 'view':

Status & tagging log