Committing Evan's patches (with some modifications), reintroducing class=internal...
[mediawiki.git] / wiki.phtml
blobc286b065bc29054e8634cd02c4e47765ec719bc0
1 <?
2 # Main wiki script; see design.doc
4 $wgRequestTime = microtime();
6 session_cache_limiter( "private, must-revalidate" );
7 session_start();
8 session_register( "wsUserID" );
9 session_register( "wsUserName" );
10 session_register( "wsUserPassword" );
11 session_register( "wsUploadFiles" );
13 unset( $IP );
14 ini_set( "allow_url_fopen", 0 ); # For security...
15 include_once( "./LocalSettings.php" );
17 # Windows requires ';' as separator, ':' for Unix
18 $sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ? ";" : ":";
19 ini_set( "include_path", "$IP$sep$include_path" );
21 include_once( "Setup.php" );
23 wfProfileIn( "main-misc-setup" );
24 OutputPage::setEncodings(); # Not really used yet
26 # Useful debug output
27 wfDebug( "\nStart request\n" );
28 wfDebug( "$REQUEST_METHOD $REQUEST_URI\n" );
29 $headers = getallheaders();
30 foreach ($headers as $name => $value) {
31         wfDebug( "$name: $value\n" );
33 wfDebug( "\n" );
35 # Query string fields
37 global $action, $title, $search, $go, $target, $printable;
38 global $returnto, $diff, $oldid;
40 $action = strtolower( trim( $action ) );
41 if ( "" == $action ) { $action = "view"; }
42 if ( "yes" == $printable ) { $wgOut->setPrintable(); }
44 if ( "" == $title && "delete" != $action ) {
45         $wgTitle = Title::newFromText( wfMsg( "mainpage" ) );
46 } else {
47         $wgTitle = Title::newFromURL( $title );
48 #       if( $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" or strncmp($wgTitle->getDBkey(),"_",1) == 0 ) {
49         if( !$wgTitle or $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) {
50                 $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
51                 $wgOut->errorpage( "badtitle", "badtitletext" );
52                 $wgOut->output();
53                 exit;
54         }
56 wfProfileOut( "main-misc-setup" );
58 if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {
59         wfSpecialPage();
60 } else if ( "" != $search ) {
61         if($go) {
62                 wfGo( $search );
63         } else {
64                 wfSearch( $search );
65         }
66 } else {
67         if ( Namespace::getMedia() == $wgTitle->getNamespace() ) {
68                 $wgTitle = Title::makeTitle( Namespace::getImage(), $wgTitle->getDBkey() );
69         }       
70         
71         switch( $wgTitle->getNamespace() ) {
72         case 6:
73                 include_once( "ImagePage.php" );
74                 $wgArticle = new ImagePage( $wgTitle );
75                 break;
76         default:
77                 $wgArticle = new Article( $wgTitle );
78         }
80         switch( $action ) {
81                 case "view":
82                 case "watch":
83                 case "unwatch":
84                 case "history":
85                 case "delete":
86                 case "revert":
87                 case "rollback":
88                 case "protect":
89                 case "unprotect":
90                         $wgArticle->$action();
91                         break;
92                 case "print":
93                         $wgArticle->view();
94                         break;
95                 case "edit":
96                 case "submit":
97                         include_once( "EditPage.php" );
98                         $editor = new EditPage( $wgArticle );
99                         $editor->$action();
100                         break;
101                 default:
102                         $wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
103         }
106 $wgOut->output();
107 foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }