From d9efc105b9a811e35844d25df33fb3ee8ae54a82 Mon Sep 17 00:00:00 2001 From: Magnus Manske Date: Thu, 29 Dec 2005 10:50:06 +0000 Subject: [PATCH] finishing moving of code from inex.php to includes/Wiki.php --- includes/Wiki.php | 98 +++++++++++++++++++++++++++++++++++++++++++++++ index.php | 77 ------------------------------------- 2 files changed, 98 insertions(+), 77 deletions(-) diff --git a/includes/Wiki.php b/includes/Wiki.php index 517a901782..3e591831cf 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -4,6 +4,104 @@ #wiki class class MediaWikiType { + + var $mSearch ; + + /** + * Constuctor + */ + function MediaWikiType () { + OutputPage::setEncodings(); # Not really used yet + + $this->main_setup () ; + $this->check_search () ; + $this->check_user_read () ; + $this->main_action () ; + $this->main_updates () ; + $this->main_cleanup () ; + } + + function check_search () { + global $wgRequest , $wgTitle ; + $this->mSearch = $wgRequest->getText( 'search' ); + if( !is_null( $this->mSearch ) && $this->mSearch !== '' ) { + // Compatibility with old search URLs which didn't use Special:Search + // Do this above the read whitelist check for security... + $wgTitle = Title::makeTitle( NS_SPECIAL, 'Search' ); + } + } + + function check_user_read () { + global $wgTitle , $wgOut ; + # If the user is not logged in, the Namespace:title of the article must be in + # the Read array in order for the user to see it. (We have to check here to + # catch special pages etc. We check again in Article::view()) + if ( !is_null( $wgTitle ) && !$wgTitle->userCanRead() ) { + $wgOut->loginToUse(); + $wgOut->output(); + exit; + } + } + + + function main_setup () { + global $wgRequest , $wgOut , $wgTitle , $wgContLang ; + global $action , $title ; + wfProfileIn( 'main-misc-setup' ); + + # Query string fields + $action = $wgRequest->getVal( 'action', 'view' ); + $title = $wgRequest->getVal( 'title' ); + + if ($wgRequest->getVal( 'printable' ) == 'yes') { + $wgOut->setPrintable(); + } + + 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' ); + } + + function main_updates () { + # Deferred updates aren't really deferred anymore. It's important to report errors to the + # user, and that means doing this before OutputPage::output(). Note that for page saves, + # the client will wait until the script exits anyway before following the redirect. + wfProfileIn( 'main-updates' ); + global $wgDeferredUpdateList ; + foreach ( $wgDeferredUpdateList as $up ) { + $up->doUpdate(); + } + wfProfileOut( 'main-updates' ); + } + + function main_cleanup () { + global $wgLoadBalancer , $wgOut , $wgPostCommitUpdateList ; + wfProfileIn( 'main-cleanup' ); + $wgLoadBalancer->saveMasterPos(); + + # Now commit any transactions, so that unreported errors after output() don't roll back the whole thing + $wgLoadBalancer->commitAll(); + + $wgOut->output(); + + foreach ( $wgPostCommitUpdateList as $up ) { + $up->doUpdate(); + } + + wfProfileOut( 'main-cleanup' ); + } function main_action () { global $wgTitle , $wgArticle , $wgRequest , $wgOut , $wgServer ; diff --git a/index.php b/index.php index 8fff434468..e5ef2eebe6 100644 --- a/index.php +++ b/index.php @@ -64,87 +64,10 @@ if( !file_exists( 'LocalSettings.php' ) ) { require_once( './LocalSettings.php' ); require_once( 'includes/Setup.php' ); -wfProfileIn( 'main-misc-setup' ); -OutputPage::setEncodings(); # Not really used yet - - # The wiki action class require_once ( "includes/Wiki.php" ) ; $wgTheWiki = new MediaWikiType ; - -# Query string fields -$action = $wgRequest->getVal( 'action', 'view' ); -$title = $wgRequest->getVal( 'title' ); - -if ($wgRequest->getVal( 'printable' ) == 'yes') { - $wgOut->setPrintable(); -} - -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' ); - -# Debug statement for user levels -// print_r($wgUser); - -$search = $wgRequest->getText( 'search' ); -if( !is_null( $search ) && $search !== '' ) { - // Compatibility with old search URLs which didn't use Special:Search - // Do this above the read whitelist check for security... - $wgTitle = Title::makeTitle( NS_SPECIAL, 'Search' ); -} - -# If the user is not logged in, the Namespace:title of the article must be in -# the Read array in order for the user to see it. (We have to check here to -# catch special pages etc. We check again in Article::view()) -if ( !is_null( $wgTitle ) && !$wgTitle->userCanRead() ) { - $wgOut->loginToUse(); - $wgOut->output(); - exit; -} - - -$wgTheWiki->mSearch = $search ; -$wgTheWiki->main_action () ; -# $search = $wgTheWiki->mSearch ; # Not needed - - -# Deferred updates aren't really deferred anymore. It's important to report errors to the -# user, and that means doing this before OutputPage::output(). Note that for page saves, -# the client will wait until the script exits anyway before following the redirect. -wfProfileIn( 'main-updates' ); -foreach ( $wgDeferredUpdateList as $up ) { - $up->doUpdate(); -} -wfProfileOut( 'main-updates' ); - -wfProfileIn( 'main-cleanup' ); -$wgLoadBalancer->saveMasterPos(); - -# Now commit any transactions, so that unreported errors after output() don't roll back the whole thing -$wgLoadBalancer->commitAll(); - -$wgOut->output(); - -foreach ( $wgPostCommitUpdateList as $up ) { - $up->doUpdate(); -} - -wfProfileOut( 'main-cleanup' ); - logProfilingData(); $wgLoadBalancer->closeAll(); wfDebug( "Request ended normally\n" ); -- 2.20.1