Index: trunk/phase3/index.php |
— | — | @@ -119,6 +119,9 @@ |
120 | 120 | |
121 | 121 | wfProfileIn( 'main-action' ); |
122 | 122 | |
| 123 | +require_once( "includes/Wiki.php" ) ; |
| 124 | +$mediaWiki = new MediaWiki() ; |
| 125 | + |
123 | 126 | if( !$wgDisableInternalSearch && !is_null( $search ) && $search !== '' ) { |
124 | 127 | require_once( 'includes/SpecialSearch.php' ); |
125 | 128 | $wgTitle = Title::makeTitle( NS_SPECIAL, 'Search' ); |
— | — | @@ -146,13 +149,11 @@ |
147 | 150 | /* redirect to canonical url, make it a 301 to allow caching */ |
148 | 151 | $wgOut->setSquidMaxage( 1200 ); |
149 | 152 | $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 | + |
153 | 156 | } else { |
154 | 157 | |
155 | | - require_once( "includes/Wiki.php" ) ; |
156 | | - $mediaWiki = new MediaWiki() ; |
157 | 158 | |
158 | 159 | $wgArticle =& $mediaWiki->initializeArticle( $wgTitle, $wgRequest, $action ); |
159 | 160 | |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -18,7 +18,25 @@ |
19 | 19 | } |
20 | 20 | return $default; |
21 | 21 | } |
| 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 | + } |
22 | 37 | |
| 38 | + /** |
| 39 | + * Initialize the object to be known as $wgArticle for "standard" actions |
| 40 | + */ |
23 | 41 | function initializeArticle( &$title, $request, $action ) { |
24 | 42 | if( NS_MEDIA == $title->getNamespace() ) { |
25 | 43 | $title = Title::makeTitle( NS_IMAGE, $title->getDBkey() ); |
— | — | @@ -26,7 +44,7 @@ |
27 | 45 | |
28 | 46 | $ns = $title->getNamespace(); |
29 | 47 | |
30 | | - // Namespace might change when using redirects |
| 48 | + /* Namespace might change when using redirects */ |
31 | 49 | $article = new Article( $title ); |
32 | 50 | if( $action == 'view' && !$request->getVal( 'oldid' ) ) { |
33 | 51 | $rTitle = Title::newFromRedirect( $article->fetchContent() ); |
— | — | @@ -38,7 +56,7 @@ |
39 | 57 | } |
40 | 58 | } |
41 | 59 | |
42 | | - // Categories and images are handled by a different class |
| 60 | + /* Categories and images are handled by a different class */ |
43 | 61 | if( $ns == NS_IMAGE ) { |
44 | 62 | $b4 = $title->getPrefixedText(); |
45 | 63 | unset( $article ); |
— | — | @@ -56,6 +74,9 @@ |
57 | 75 | return $article; |
58 | 76 | } |
59 | 77 | |
| 78 | + /** |
| 79 | + * Perform one of the "standard" actions |
| 80 | + */ |
60 | 81 | function performAction( $action, &$output, &$article, &$title, &$user, &$request ) { |
61 | 82 | switch( $action ) { |
62 | 83 | case 'view': |