Fixed bug causing different search actions on submit-by-return in IE and moz. Changed...
[lhc/web/wiklou.git] / wiki.phtml
1 <?
2 # Main wiki script; see design.doc
3 #
4 $wgRequestTime = microtime();
5
6 unset( $IP );
7 ini_set( "allow_url_fopen", 0 ); # For security...
8 include_once( "./LocalSettings.php" );
9
10 # Windows requires ';' as separator, ':' for Unix
11 $sep = strchr( $include_path = ini_get( "include_path" ), ";" ) ? ";" : ":";
12 ini_set( "include_path", "$IP$sep$include_path" );
13
14 include_once( "Setup.php" );
15
16 wfProfileIn( "main-misc-setup" );
17 OutputPage::setEncodings(); # Not really used yet
18
19 # Query string fields
20 #
21 global $action, $title, $search, $go, $target, $printable;
22 global $returnto, $diff, $oldid, $curid;
23
24 # Placeholders in case of DB error
25 $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
26 $wgArticle = new Article($wgTitle);
27
28 $action = strtolower( trim( $action ) );
29 if ( "" == $action ) { $action = "view"; }
30 if ( "yes" == $printable ) { $wgOut->setPrintable(); }
31
32 if ( "" == $title && "delete" != $action ) {
33 $wgTitle = Title::newFromText( wfMsg( "mainpage" ) );
34 } elseif ( $curid ) {
35 # URLs like this are generated by RC, because rc_title isn't always accurate
36 $wgTitle = Title::newFromID( $curid );
37 } else {
38 $wgTitle = Title::newFromURL( $title );
39 }
40 wfProfileOut( "main-misc-setup" );
41
42 if ( "" != $search ) {
43 if( isset($_REQUEST['fulltext']) ) {
44 wfSearch( $search );
45 } else {
46 wfGo( $search );
47 }
48 } else if( !$wgTitle or $wgTitle->getInterwiki() != "" or $wgTitle->getDBkey() == "" ) {
49 $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
50 $wgOut->errorpage( "badtitle", "badtitletext" );
51 } else if ( ( $action == "view" ) && $wgTitle->getPrefixedDBKey() != $title ) {
52 /* redirect to canonical url */
53 $wgOut->redirect( wfLocalUrl( $wgTitle->getPrefixedURL() ) );
54 } else if ( Namespace::getSpecial() == $wgTitle->getNamespace() ) {
55 wfSpecialPage();
56 } else {
57 if ( Namespace::getMedia() == $wgTitle->getNamespace() ) {
58 $wgTitle = Title::makeTitle( Namespace::getImage(), $wgTitle->getDBkey() );
59 }
60
61 switch( $wgTitle->getNamespace() ) {
62 case 6:
63 include_once( "ImagePage.php" );
64 $wgArticle = new ImagePage( $wgTitle );
65 break;
66 default:
67 $wgArticle = new Article( $wgTitle );
68 }
69
70 switch( $action ) {
71 case "view":
72 case "watch":
73 case "unwatch":
74 case "delete":
75 case "revert":
76 case "rollback":
77 case "protect":
78 case "unprotect":
79 $wgArticle->$action();
80 break;
81 case "print":
82 $wgArticle->view();
83 break;
84 case "edit":
85 case "submit":
86 if( !$wgCommandLineMode && !isset( $_COOKIE[ini_get("session.name")] ) ) {
87 User::SetupSession();
88 }
89 include_once( "EditPage.php" );
90 $editor = new EditPage( $wgArticle );
91 $editor->$action();
92 break;
93 case "history":
94 include_once( "PageHistory.php" );
95 $history = new PageHistory( $wgArticle );
96 $history->history();
97 break;
98 default:
99 $wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
100 }
101 }
102
103 $wgOut->output();
104 foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }
105 logProfilingData();
106 wfDebug( "Request ended normally\n" );
107 ?>