Purging of scaled images when thumbnail is regenerated. Depends on visiting the page...
[mediawiki.git] / wiki.phtml
blob34580967802e17c26b2b61eb662c4b09970fb58f
1 <?php
2 # Main wiki script; see design.doc
4 $wgRequestTime = microtime();
6 unset( $IP );
7 ini_set( "allow_url_fopen", 0 ); # For security...
8 include_once( "./LocalSettings.php" );
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" );
14 include_once( "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, $curid;
24 # Placeholders in case of DB error
25 $wgTitle = Title::newFromText( wfMsg( "badtitle" ) );
26 $wgArticle = new Article($wgTitle);
28 $action = strtolower( trim( $action ) );
29 if ( "" == $action ) { $action = "view"; }
30 if ( "yes" == $printable ) { $wgOut->setPrintable(); }
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 );
40 wfProfileOut( "main-misc-setup" );
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         }
70         wfQuery("BEGIN", DB_WRITE);
71         switch( $action ) {
72                 case "view":
73                 case "watch":
74                 case "unwatch":
75                 case "delete":
76                 case "revert":
77                 case "rollback":
78                 case "protect":
79                 case "unprotect":
80                         $wgArticle->$action();
81                         break;
82                 case "print":
83                         $wgArticle->view();
84                         break;
85                 case "edit":
86                 case "submit":
87                         if( !$wgCommandLineMode && !isset( $_COOKIE[ini_get("session.name")] ) ) {
88                                 User::SetupSession();
89                         }
90                         include_once( "EditPage.php" );
91                         $editor = new EditPage( $wgArticle );
92                         $editor->$action();
93                         break;
94                 case "history":
95                         include_once( "PageHistory.php" );
96                         $history = new PageHistory( $wgArticle );
97                         $history->history();
98                         break;
99                 default:
100                         $wgOut->errorpage( "nosuchaction", "nosuchactiontext" );
101         }
102         wfQuery("COMMIT", DB_WRITE);
105 $wgOut->output();
106 foreach ( $wgDeferredUpdateList as $up ) { $up->doUpdate(); }
107 logProfilingData();
108 wfDebug( "Request ended normally\n" );