Added transformation to wfMsg output, allowing tags such as {{SITENAME}} and {{localu...
[lhc/web/wiklou.git] / index.php
index 57875af..9793044 100644 (file)
--- a/index.php
+++ b/index.php
@@ -14,9 +14,9 @@ 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" );
+# PATH_SEPARATOR avaialble only from 4.3.0
+$sep = (DIRECTORY_SEPARATOR == "\\") ? ";" : ":";
+ini_set( "include_path", $IP . $sep . ini_get( "include_path" ) );
 
 include_once( "Setup.php" );
 
@@ -24,9 +24,13 @@ 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" );
+
+if( isset( $_SERVER['PATH_INFO'] ) && $wgUsePathInfo ) {
+       $title = substr( $_SERVER['PATH_INFO'], 1 );
+} else {
+       $title = $wgRequest->getVal( "title" );
+}
 
 # Placeholders in case of DB error
 $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
@@ -34,11 +38,13 @@ $wgArticle = new Article($wgTitle);
 
 $action = strtolower( trim( $action ) );
 if ( "" == $action ) { $action = "view"; }
-if ( "yes" == $printable ) { $wgOut->setPrintable(); }
+if ($wgRequest->getVal( "printable" ) == "yes") {
+       $wgOut->setPrintable();
+}
 
 if ( "" == $title && "delete" != $action ) {
        $wgTitle = Title::newFromText( wfMsg( "mainpage" ) );
-} elseif ( $curid ) {
+} elseif ( $curid = $wgRequest->getInt( 'curid' ) ) {
        # URLs like this are generated by RC, because rc_title isn't always accurate
        $wgTitle = Title::newFromID( $curid );
 } else {
@@ -56,8 +62,8 @@ if ( !$wgUser->getID() && is_array( $wgWhitelistRead ) && $wgTitle) {
        }
 }
 
-if ( "" != $search ) {
-       if( isset($_REQUEST['fulltext']) ) {
+if ( $search = $wgRequest->getText( 'search' ) ) {
+       if( $wgRequest->getVal( 'fulltext' ) ) {
                wfSearch( $search );
        } else {
                wfGo( $search );
@@ -67,16 +73,16 @@ if ( "" != $search ) {
        $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');
+       $wgOut->redirect( $wgTitle->getFullURL(), '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:
+       case NS_IMAGE:
                include_once( "ImagePage.php" );
                $wgArticle = new ImagePage( $wgTitle );
                break;
@@ -87,6 +93,9 @@ if ( "" != $search ) {
        wfQuery("BEGIN", DB_WRITE);
        switch( $action ) {
                case "view":
+                       $wgOut->setSquidMaxage( $wgSquidMaxage );
+                       $wgArticle->$action();
+                       break;
                case "watch":
                case "unwatch":
                case "delete":
@@ -99,9 +108,25 @@ if ( "" != $search ) {
                case "print":
                        $wgArticle->view();
                        break;
+               case "dublincore":
+                       if( !$wgEnableDublinCoreRdf ) {
+                               wfHttpError( 403, "Forbidden", wfMsg( "nodublincore" ) );
+                       } else {
+                               include_once( "Metadata.php" );
+                               wfDublinCoreRdf( $wgArticle );
+                       }
+                       break;
+               case "creativecommons":
+                       if( !$wgEnableCreativeCommonsRdf ) {
+                               wfHttpError( 403, "Forbidden", wfMsg("nocreativecommons") );
+                       } else {
+                               include_once( "Metadata.php" );
+                               wfCreativeCommonsRdf( $wgArticle );
+                       }
+                       break;
                case "edit":
                case "submit":
-                       if( !$wgCommandLineMode && !isset( $_COOKIE[ini_get("session.name")] ) ) {
+                       if( !$wgCommandLineMode && !$wgRequest->checkSessionCookie() ) {
                                User::SetupSession();
                        }
                        include_once( "EditPage.php" );
@@ -109,10 +134,18 @@ if ( "" != $search ) {
                        $editor->$action();
                        break;
                case "history":
+                       if ($_SERVER["REQUEST_URI"] == $wgTitle->getInternalURL('action=history')) {
+                               $wgOut->setSquidMaxage( $wgSquidMaxage );
+                       }
                        include_once( "PageHistory.php" );
                        $history = new PageHistory( $wgArticle );
                        $history->history();
                        break;
+               case "purge":
+                       wfPurgeSquidServers(array($wgTitle->getInternalURL()));
+                       $wgOut->setSquidMaxage( $wgSquidMaxage );
+                       $wgArticle->view();
+                       break;
                default:
                        $wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
        }
@@ -120,6 +153,7 @@ if ( "" != $search ) {
 }
 
 $wgOut->output();
+
 foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }
 logProfilingData();
 wfDebug( "Request ended normally\n" );