Nov. branch merge. Various features backported from stable, various bug fixes.
[lhc/web/wiklou.git] / wiki.phtml
1 <?
2 # Main wiki script; see design.doc
3 #
4 $wgRequestTime = microtime();
5
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" );
12
13 global $IP;
14 include_once( "./LocalSettings.php" );
15 include_once( "$IP/Setup.php" );
16
17 wfProfileIn( "main-misc-setup" );
18 OutputPage::setEncodings(); # Not really used yet
19
20 # Useful debug output
21 wfDebug( "\nStart request\n" );
22 wfDebug( "$REQUEST_METHOD $REQUEST_URI\n" );
23 $headers = getallheaders();
24 foreach ($headers as $name => $value) {
25 wfDebug( "$name: $value\n" );
26 }
27 wfDebug( "\n" );
28
29 # Query string fields
30 #
31 global $action, $title, $search, $go, $target, $printable;
32 global $returnto, $diff, $oldid;
33
34 $action = strtolower( trim( $action ) );
35 if ( "" == $action ) { $action = "view"; }
36 if ( "yes" == $printable ) { $wgOut->setPrintable(); }
37
38 if ( "" == $title && "delete" != $action ) {
39 $wgTitle = Title::newFromText( wfMsg( "mainpage" ) );
40 } else {
41 $wgTitle = Title::newFromURL( $title );
42 # if( $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" or strncmp($wgTitle->getDBkey(),"_",1) == 0 ) {
43 if( !$wgTitle or $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) {
44 $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
45 $wgOut->errorpage( "badtitle", "badtitletext" );
46 $wgOut->output();
47 exit;
48 }
49 }
50 wfProfileOut( "main-misc-setup" );
51
52 if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {
53 wfSpecialPage();
54 } else if ( "" != $search ) {
55 if($go) {
56 wfGo( $search );
57 } else {
58 wfSearch( $search );
59 }
60 } else {
61 if ( Namespace::getMedia() == $wgTitle->getNamespace() ) {
62 $wgTitle = Title::makeTitle( Namespace::getImage(), $wgTitle->getDBkey() );
63 }
64
65 switch( $wgTitle->getNamespace() ) {
66 case 6:
67 include_once( "$IP/ImagePage.php" );
68 $wgArticle = new ImagePage( $wgTitle );
69 break;
70 default:
71 $wgArticle = new Article( $wgTitle );
72 }
73
74 switch( $action ) {
75 case "view":
76 case "watch":
77 case "unwatch":
78 case "history":
79 case "delete":
80 case "revert":
81 case "rollback":
82 case "protect":
83 case "unprotect":
84 $wgArticle->$action();
85 break;
86 case "print":
87 $wgArticle->view();
88 break;
89 case "edit":
90 case "submit":
91 include_once( "$IP/EditPage.php" );
92 $editor = new EditPage( $wgArticle );
93 $editor->$action();
94 break;
95 default:
96 $wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
97 }
98 }
99
100 $wgOut->output();
101 foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }
102
103 ?>