* Initialization of ... everything
@return Article either the object to become $wgArticle, or NULL
*/
- function initialize ( &$title, &$output, &$user, $request ) {
+ function initialize ( &$title, &$output, &$user, $request) {
wfProfileIn( 'MediaWiki::initialize' );
- $this->preliminaryChecks ( $title , $output , $request ) ;
+ $this->preliminaryChecks ( $title, $output, $request ) ;
$article = NULL;
if ( !$this->initializeSpecialCases( $title, $output, $request ) ) {
$article = $this->initializeArticle( $title, $request );
return $article;
}
- function preliminaryChecks ( &$title , &$output , $request ) {
+ /**
+ * Checks some initial queries
+ * Note that $title here is *not* a Title object, but a string!
+ */
+ function checkInitialQueries( $title,$action,&$output,$request, $lang) {
+ if ($request->getVal( 'printable' ) == 'yes') {
+ $output->setPrintable();
+ }
+
+ $ret = NULL ;
+
+
+ if ( '' == $title && 'delete' != $action ) {
+ $ret = Title::newFromText( wfMsgForContent( 'mainpage' ) );
+ } elseif ( $curid = $request->getInt( 'curid' ) ) {
+ # URLs like this are generated by RC, because rc_title isn't always accurate
+ $ret = Title::newFromID( $curid );
+ } else {
+ $ret = Title::newFromURL( $title );
+ /* check variant links so that interwiki links don't have to worry about
+ the possible different language variants
+ */
+ if( count($lang->getVariants()) > 1 && !is_null($ret) && $ret->getArticleID() == 0 )
+ $lang->findVariantLink( $title, $ret );
+
+ }
+ return $ret ;
+ }
+
+ /**
+ * Checks for search query and anon-cannot-read case
+ */
+ function preliminaryChecks ( &$title, &$output, $request ) {
# Debug statement for user levels
// print_r($wgUser);
/**
* Cleaning up by doing deferred updates, calling loadbalancer and doing the output
*/
- function finalCleanup ( &$deferredUpdates , &$loadBalancer , &$output ) {
+ function finalCleanup ( &$deferredUpdates, &$loadBalancer, &$output ) {
wfProfileIn( 'MediaWiki::finalCleanup' );
$this->doUpdates( $deferredUpdates );
$loadBalancer->saveMasterPos();
require_once( './includes/Defines.php' );
if( !file_exists( 'LocalSettings.php' ) ) {
- $IP = "." ;
+ $IP = ".";
require_once( 'includes/DefaultSettings.php' ); # used for printing the version
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
require_once( './LocalSettings.php' );
require_once( 'includes/Setup.php' );
+
+# Initialize MediaWiki base class
+require_once( "includes/Wiki.php" );
+$mediaWiki = new MediaWiki();
+
wfProfileIn( 'main-misc-setup' );
OutputPage::setEncodings(); # Not really used yet
$action = $wgRequest->getVal( 'action', 'view' );
$title = $wgRequest->getVal( 'title' );
-if ($wgRequest->getVal( 'printable' ) == 'yes') {
- $wgOut->setPrintable();
+$wgTitle = $mediaWiki->checkInitialQueries( $title,$action,$wgOut, $wgRequest, $wgContLang );
+if ($wgTitle == NULL) {
+ unset( $wgTitle );
}
-if ( '' == $title && 'delete' != $action ) {
- $wgTitle = Title::newFromText( wfMsgForContent( 'mainpage' ) );
-} elseif ( $curid = $wgRequest->getInt( 'curid' ) ) {
- # URLs like this are generated by RC, because rc_title isn't always accurate
- $wgTitle = Title::newFromID( $curid );
-} else {
- $wgTitle = Title::newFromURL( $title );
- /* check variant links so that interwiki links don't have to worry about
- the possible different language variants
- */
- if( count($wgContLang->getVariants()) > 1 && !is_null($wgTitle) && $wgTitle->getArticleID() == 0 )
- $wgContLang->findVariantLink( $title, $wgTitle );
-
-}
wfProfileOut( 'main-misc-setup' );
-
-# Initialize MediaWiki base class
-require_once( "includes/Wiki.php" );
-$mediaWiki = new MediaWiki();
-
# Setting global variables in mediaWiki
$mediaWiki->setVal( "Server", $wgServer );
$mediaWiki->setVal( "DisableInternalSearch", $wgDisableInternalSearch );
$mediaWiki->setVal( "DisabledActions", $wgDisabledActions );
$wgArticle = $mediaWiki->initialize ( $wgTitle, $wgOut, $wgUser, $wgRequest );
-$mediaWiki->finalCleanup ( $wgDeferredUpdateList , $wgLoadBalancer , $wgOut ) ;
+$mediaWiki->finalCleanup ( $wgDeferredUpdateList, $wgLoadBalancer, $wgOut );
# Not sure when $wgPostCommitUpdateList gets set, so I keep this separate from finalCleanup
$mediaWiki->doUpdates( $wgPostCommitUpdateList );