* Redundant script that isn't used by anything
[lhc/web/wiklou.git] / index.php
index 57875af..964770e 100644 (file)
--- a/index.php
+++ b/index.php
 <?php
-# Main wiki script; see design.doc
-#
-$wgRequestTime = microtime();
-
-unset( $IP );
-ini_set( "allow_url_fopen", 0 ); # For security...
-if(!file_exists("LocalSettings.php")) {
-       die( "You'll have to <a href='config/index.php'>set the wiki up</a> first!" );
-}
-include_once( "./LocalSettings.php" );
 
-if( $wgSitename == "MediaWiki" ) {
-       die( "You must set the site name in \$wgSitename before installation.\n\n" );
-}
-
-# Windows requires ';' as separator, ':' for Unix
-$sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ? ";" : ":";
-ini_set( "include_path", "$IP$sep$include_path" );
+# Initialise common code
+require_once( './includes/WebStart.php' );
 
-include_once( "Setup.php" );
+# Initialize MediaWiki base class
+require_once( "includes/Wiki.php" );
+$mediaWiki = new MediaWiki();
 
-wfProfileIn( "main-misc-setup" );
+wfProfileIn( 'main-misc-setup' );
 OutputPage::setEncodings(); # Not really used yet
 
 # Query string fields
-#
-global $action, $title, $search, $go, $target, $printable;
-global $returnto, $diff, $oldid, $curid;
+$action = $wgRequest->getVal( 'action', 'view' );
+$title = $wgRequest->getVal( 'title' );
 
-# Placeholders in case of DB error
-$wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
-$wgArticle = new Article($wgTitle);
-
-$action = strtolower( trim( $action ) );
-if ( "" == $action ) { $action = "view"; }
-if ( "yes" == $printable ) { $wgOut->setPrintable(); }
+#
+# Send Ajax requests to the Ajax dispatcher.
+#
+if ( $wgUseAjax && $action == 'ajax' ) {
+       require_once( $IP . '/includes/AjaxDispatcher.php' );
 
-if ( "" == $title && "delete" != $action ) {
-       $wgTitle = Title::newFromText( wfMsg( "mainpage" ) );
-} elseif ( $curid ) {
-       # URLs like this are generated by RC, because rc_title isn't always accurate
-       $wgTitle = Title::newFromID( $curid );
-} else {
-       $wgTitle = Title::newFromURL( $title );
+       $dispatcher = new AjaxDispatcher();
+       $dispatcher->performAction();
+       $mediaWiki->restInPeace( $wgLoadBalancer );
+       exit;
 }
-wfProfileOut( "main-misc-setup" );
 
-# 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.
-if ( !$wgUser->getID() && is_array( $wgWhitelistRead ) && $wgTitle) {
-       if ( !in_array( $wgLang->getNsText( $wgTitle->getNamespace() ) . ":" . $wgTitle->getDBkey(), $wgWhitelistRead ) ) {
-               $wgOut->loginToUse();
-               $wgOut->output();
-               exit;
-       }
+$wgTitle = $mediaWiki->checkInitialQueries( $title,$action,$wgOut, $wgRequest, $wgContLang );
+if ($wgTitle == NULL) {
+       unset( $wgTitle );
 }
 
-if ( "" != $search ) {
-       if( isset($_REQUEST['fulltext']) ) {
-               wfSearch( $search );
-       } else {
-               wfGo( $search );
-       }
-} else if( !$wgTitle or $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) {
-       $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
-       $wgOut->errorpage( "badtitle", "badtitletext" );
-} else if ( ( $action == "view" ) && $wgTitle->getPrefixedDBKey() != $title ) {
-       /* redirect to canonical url, make it a 301 to allow caching */
-       $wgOut->redirect( wfLocalUrl( $wgTitle->getPrefixedURL() ), '301');
-} else if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {
-       wfSpecialPage();
-} else {
-       if ( Namespace::getMedia() == $wgTitle->getNamespace() ) {
-               $wgTitle = Title::makeTitle( Namespace::getImage(), $wgTitle->getDBkey() );
-       }       
-       
-       switch( $wgTitle->getNamespace() ) {
-       case 6:
-               include_once( "ImagePage.php" );
-               $wgArticle = new ImagePage( $wgTitle );
-               break;
-       default:
-               $wgArticle = new Article( $wgTitle );
-       }
+wfProfileOut( 'main-misc-setup' );
 
-       wfQuery("BEGIN", DB_WRITE);
-       switch( $action ) {
-               case "view":
-               case "watch":
-               case "unwatch":
-               case "delete":
-               case "revert":
-               case "rollback":
-               case "protect":
-               case "unprotect":
-                       $wgArticle->$action();
-                       break;
-               case "print":
-                       $wgArticle->view();
-                       break;
-               case "edit":
-               case "submit":
-                       if( !$wgCommandLineMode && !isset( $_COOKIE[ini_get("session.name")] ) ) {
-                               User::SetupSession();
-                       }
-                       include_once( "EditPage.php" );
-                       $editor = new EditPage( $wgArticle );
-                       $editor->$action();
-                       break;
-               case "history":
-                       include_once( "PageHistory.php" );
-                       $history = new PageHistory( $wgArticle );
-                       $history->history();
-                       break;
-               default:
-                       $wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
-       }
-       wfQuery("COMMIT", DB_WRITE);
-}
+# Setting global variables in mediaWiki
+$mediaWiki->setVal( 'Server', $wgServer );
+$mediaWiki->setVal( 'DisableInternalSearch', $wgDisableInternalSearch );
+$mediaWiki->setVal( 'action', $action );
+$mediaWiki->setVal( 'SquidMaxage', $wgSquidMaxage );
+$mediaWiki->setVal( 'EnableDublinCoreRdf', $wgEnableDublinCoreRdf );
+$mediaWiki->setVal( 'EnableCreativeCommonsRdf', $wgEnableCreativeCommonsRdf );
+$mediaWiki->setVal( 'CommandLineMode', $wgCommandLineMode );
+$mediaWiki->setVal( 'UseExternalEditor', $wgUseExternalEditor );
+$mediaWiki->setVal( 'DisabledActions', $wgDisabledActions );
+
+$wgArticle = $mediaWiki->initialize ( $wgTitle, $wgOut, $wgUser, $wgRequest );
+$mediaWiki->finalCleanup ( $wgDeferredUpdateList, $wgLoadBalancer, $wgOut );
+
+# Not sure when $wgPostCommitUpdateList gets set, so I keep this separate from finalCleanup
+$mediaWiki->doUpdates( $wgPostCommitUpdateList );
 
-$wgOut->output();
-foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }
-logProfilingData();
-wfDebug( "Request ended normally\n" );
+$mediaWiki->restInPeace( $wgLoadBalancer );
 ?>