Index: trunk/phase3/index.php |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | require_once( './includes/Defines.php' ); |
29 | 29 | |
30 | 30 | if( !file_exists( 'LocalSettings.php' ) ) { |
31 | | - $IP = "." ; |
| 31 | + $IP = "."; |
32 | 32 | require_once( 'includes/DefaultSettings.php' ); # used for printing the version |
33 | 33 | ?> |
34 | 34 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
— | — | @@ -71,6 +71,11 @@ |
72 | 72 | require_once( './LocalSettings.php' ); |
73 | 73 | require_once( 'includes/Setup.php' ); |
74 | 74 | |
| 75 | + |
| 76 | +# Initialize MediaWiki base class |
| 77 | +require_once( "includes/Wiki.php" ); |
| 78 | +$mediaWiki = new MediaWiki(); |
| 79 | + |
75 | 80 | wfProfileIn( 'main-misc-setup' ); |
76 | 81 | OutputPage::setEncodings(); # Not really used yet |
77 | 82 | |
— | — | @@ -78,31 +83,13 @@ |
79 | 84 | $action = $wgRequest->getVal( 'action', 'view' ); |
80 | 85 | $title = $wgRequest->getVal( 'title' ); |
81 | 86 | |
82 | | -if ($wgRequest->getVal( 'printable' ) == 'yes') { |
83 | | - $wgOut->setPrintable(); |
| 87 | +$wgTitle = $mediaWiki->checkInitialQueries( $title,$action,$wgOut, $wgRequest, $wgContLang ); |
| 88 | +if ($wgTitle == NULL) { |
| 89 | + unset( $wgTitle ); |
84 | 90 | } |
85 | 91 | |
86 | | -if ( '' == $title && 'delete' != $action ) { |
87 | | - $wgTitle = Title::newFromText( wfMsgForContent( 'mainpage' ) ); |
88 | | -} elseif ( $curid = $wgRequest->getInt( 'curid' ) ) { |
89 | | - # URLs like this are generated by RC, because rc_title isn't always accurate |
90 | | - $wgTitle = Title::newFromID( $curid ); |
91 | | -} else { |
92 | | - $wgTitle = Title::newFromURL( $title ); |
93 | | - /* check variant links so that interwiki links don't have to worry about |
94 | | - the possible different language variants |
95 | | - */ |
96 | | - if( count($wgContLang->getVariants()) > 1 && !is_null($wgTitle) && $wgTitle->getArticleID() == 0 ) |
97 | | - $wgContLang->findVariantLink( $title, $wgTitle ); |
98 | | - |
99 | | -} |
100 | 92 | wfProfileOut( 'main-misc-setup' ); |
101 | 93 | |
102 | | - |
103 | | -# Initialize MediaWiki base class |
104 | | -require_once( "includes/Wiki.php" ); |
105 | | -$mediaWiki = new MediaWiki(); |
106 | | - |
107 | 94 | # Setting global variables in mediaWiki |
108 | 95 | $mediaWiki->setVal( "Server", $wgServer ); |
109 | 96 | $mediaWiki->setVal( "DisableInternalSearch", $wgDisableInternalSearch ); |
— | — | @@ -115,7 +102,7 @@ |
116 | 103 | $mediaWiki->setVal( "DisabledActions", $wgDisabledActions ); |
117 | 104 | |
118 | 105 | $wgArticle = $mediaWiki->initialize ( $wgTitle, $wgOut, $wgUser, $wgRequest ); |
119 | | -$mediaWiki->finalCleanup ( $wgDeferredUpdateList , $wgLoadBalancer , $wgOut ) ; |
| 106 | +$mediaWiki->finalCleanup ( $wgDeferredUpdateList, $wgLoadBalancer, $wgOut ); |
120 | 107 | |
121 | 108 | # Not sure when $wgPostCommitUpdateList gets set, so I keep this separate from finalCleanup |
122 | 109 | $mediaWiki->doUpdates( $wgPostCommitUpdateList ); |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -40,9 +40,9 @@ |
41 | 41 | * Initialization of ... everything |
42 | 42 | @return Article either the object to become $wgArticle, or NULL |
43 | 43 | */ |
44 | | - function initialize ( &$title, &$output, &$user, $request ) { |
| 44 | + function initialize ( &$title, &$output, &$user, $request) { |
45 | 45 | wfProfileIn( 'MediaWiki::initialize' ); |
46 | | - $this->preliminaryChecks ( $title , $output , $request ) ; |
| 46 | + $this->preliminaryChecks ( $title, $output, $request ) ; |
47 | 47 | $article = NULL; |
48 | 48 | if ( !$this->initializeSpecialCases( $title, $output, $request ) ) { |
49 | 49 | $article = $this->initializeArticle( $title, $request ); |
— | — | @@ -52,8 +52,40 @@ |
53 | 53 | return $article; |
54 | 54 | } |
55 | 55 | |
56 | | - function preliminaryChecks ( &$title , &$output , $request ) { |
| 56 | + /** |
| 57 | + * Checks some initial queries |
| 58 | + * Note that $title here is *not* a Title object, but a string! |
| 59 | + */ |
| 60 | + function checkInitialQueries( $title,$action,&$output,$request, $lang) { |
| 61 | + if ($request->getVal( 'printable' ) == 'yes') { |
| 62 | + $output->setPrintable(); |
| 63 | + } |
| 64 | + |
| 65 | + $ret = NULL ; |
| 66 | + |
| 67 | + |
| 68 | + if ( '' == $title && 'delete' != $action ) { |
| 69 | + $ret = Title::newFromText( wfMsgForContent( 'mainpage' ) ); |
| 70 | + } elseif ( $curid = $request->getInt( 'curid' ) ) { |
| 71 | + # URLs like this are generated by RC, because rc_title isn't always accurate |
| 72 | + $ret = Title::newFromID( $curid ); |
| 73 | + } else { |
| 74 | + $ret = Title::newFromURL( $title ); |
| 75 | + /* check variant links so that interwiki links don't have to worry about |
| 76 | + the possible different language variants |
| 77 | + */ |
| 78 | + if( count($lang->getVariants()) > 1 && !is_null($ret) && $ret->getArticleID() == 0 ) |
| 79 | + $lang->findVariantLink( $title, $ret ); |
| 80 | + |
| 81 | + } |
| 82 | + return $ret ; |
| 83 | + } |
57 | 84 | |
| 85 | + /** |
| 86 | + * Checks for search query and anon-cannot-read case |
| 87 | + */ |
| 88 | + function preliminaryChecks ( &$title, &$output, $request ) { |
| 89 | + |
58 | 90 | # Debug statement for user levels |
59 | 91 | // print_r($wgUser); |
60 | 92 | |
— | — | @@ -174,7 +206,7 @@ |
175 | 207 | /** |
176 | 208 | * Cleaning up by doing deferred updates, calling loadbalancer and doing the output |
177 | 209 | */ |
178 | | - function finalCleanup ( &$deferredUpdates , &$loadBalancer , &$output ) { |
| 210 | + function finalCleanup ( &$deferredUpdates, &$loadBalancer, &$output ) { |
179 | 211 | wfProfileIn( 'MediaWiki::finalCleanup' ); |
180 | 212 | $this->doUpdates( $deferredUpdates ); |
181 | 213 | $loadBalancer->saveMasterPos(); |