Misc fixes
[mediawiki.git] / wiki.phtml
blobd79da00f170c68b942d8e1c043474d2e32e30e1a
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" );
12 global $IP;
13 include_once( "./LocalSettings.php" );
14 include_once( "$IP/Setup.php" );
16 wfProfileIn( "main-misc-setup" );
17 OutputPage::setEncodings(); # Not really used yet
19 # Query string fields
21 global $action, $title, $search, $go, $target, $printable;
22 global $returnto, $diff, $oldid;
24 $action = strtolower( trim( $action ) );
25 if ( "" == $action ) { $action = "view"; }
26 if ( "yes" == $printable ) { $wgOut->setPrintable(); }
28 if ( "" == $title && "delete" != $action ) {
29         $wgTitle = Title::newFromText( wfMsg( "mainpage" ) );
30 } else {
31         $wgTitle = Title::newFromURL( $title );
32 #       if( $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" or strncmp($wgTitle->getDBkey(),"_",1) == 0 ) {
33         if( $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) {
34                 $wgOut->errorpage( "badtitle", "badtitletext" );
35                 $wgOut->output();
36                 exit;
37         }
39 wfProfileOut();
40 if ( -1 == $wgTitle->getNamespace() ) {
41         wfSpecialPage();
42 } else if ( "" != $search ) {
43         if($go) {
44         
45                 wfGo ($search);
46         
47         } else {
48         
49                 wfSearch( $search );
50                 
51         }
52                 
53 } else {
54         switch( $wgTitle->getNamespace() ) {
55         case 6:
56                 include_once( "$IP/ImagePage.php" );
57                 $wgArticle = new ImagePage( $wgTitle );
58                 break;
59         default:
60                 $wgArticle = new Article( $wgTitle );
61         }
63         switch( $action ) {
64                 case "view":
65                 case "watch":
66                 case "unwatch":
67                 case "history":
68                 case "delete":
69                 case "revert":
70                 case "rollback":
71                 case "protect":
72                 case "unprotect":
73                         $wgArticle->$action();
74                         break;
75                 case "print":
76                         $wgArticle->view();
77                         break;
78                 case "edit":
79                 case "submit":
80                         include_once( "$IP/EditPage.php" );
81                         $editor = new EditPage( $wgArticle );
82                         $editor->$action();
83                         break;
84                 default:
85                         $wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
86         }
89 $wgOut->output();
90 foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }