Index: trunk/phase3/index.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | if ( function_exists ( 'getrusage' ) ) { |
11 | 11 | $wgRUstart = getrusage(); |
12 | 12 | } else { |
13 | | - $wgRUstart = array() ; |
| 13 | + $wgRUstart = array(); |
14 | 14 | } |
15 | 15 | |
16 | 16 | unset( $IP ); |
— | — | @@ -120,29 +120,22 @@ |
121 | 121 | wfProfileIn( 'main-action' ); |
122 | 122 | |
123 | 123 | # Initialize MediaWiki base class |
124 | | -require_once( "includes/Wiki.php" ) ; |
125 | | -$mediaWiki = new MediaWiki() ; |
| 124 | +require_once( "includes/Wiki.php" ); |
| 125 | +$mediaWiki = new MediaWiki(); |
126 | 126 | |
127 | 127 | $mediaWiki->setVal( "Server", $wgServer ); |
128 | 128 | $mediaWiki->setVal( "DisableInternalSearch", $wgDisableInternalSearch ); |
| 129 | +$mediaWiki->setVal( "Search", $search ); |
| 130 | +$mediaWiki->setVal( "action", $action ); |
| 131 | +$mediaWiki->setVal( "SquidMaxage", $wgSquidMaxage ); |
| 132 | +$mediaWiki->setVal( "EnableDublinCoreRdf", $wgEnableDublinCoreRdf ); |
| 133 | +$mediaWiki->setVal( "EnableCreativeCommonsRdf", $wgEnableCreativeCommonsRdf ); |
| 134 | +$mediaWiki->setVal( "CommandLineMode", $wgCommandLineMode ); |
| 135 | +$mediaWiki->setVal( "UseExternalEditor", $wgUseExternalEditor ); |
| 136 | +$mediaWiki->setVal( "DisabledActions", $wgDisabledActions ); |
129 | 137 | |
130 | | -if ( !$mediaWiki->initializeSpecialCases( $wgTitle , $wgOut , $wgRequest , $action , $search ) ) { |
| 138 | +$wgArticle = $mediaWiki->initialize ( $wgTitle, $wgOut, $wgUser, $wgRequest ); |
131 | 139 | |
132 | | - $wgArticle = $mediaWiki->initializeArticle( $wgTitle, $wgRequest, $action ); |
133 | | - |
134 | | - if( in_array( $action, $wgDisabledActions ) ) { |
135 | | - $wgOut->errorpage( 'nosuchaction', 'nosuchactiontext' ); |
136 | | - } else { |
137 | | - $mediaWiki->setVal( "SquidMaxage", $wgSquidMaxage ); |
138 | | - $mediaWiki->setVal( "EnableDublinCoreRdf", $wgEnableDublinCoreRdf ); |
139 | | - $mediaWiki->setVal( "EnableCreativeCommonsRdf", $wgEnableCreativeCommonsRdf ); |
140 | | - $mediaWiki->setVal( "CommandLineMode", $wgCommandLineMode ); |
141 | | - $mediaWiki->setVal( "UseExternalEditor", $wgUseExternalEditor ); |
142 | | - $mediaWiki->performAction( $action, $wgOut, $wgArticle, $wgTitle, $wgUser, $wgRequest ); |
143 | | - } |
144 | | - |
145 | | - |
146 | | -} |
147 | 140 | wfProfileOut( 'main-action' ); |
148 | 141 | |
149 | 142 | # Deferred updates aren't really deferred anymore. It's important to report errors to the |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -15,10 +15,19 @@ |
16 | 16 | $this->GET = $_GET; |
17 | 17 | } |
18 | 18 | |
| 19 | + /** |
| 20 | + * Stores key/value pairs to circumvent global variables |
| 21 | + * Note that keys are case-insensitive! |
| 22 | + */ |
19 | 23 | function setVal( $key, &$value ) { |
20 | | - $this->param[strtolower( $key )] = $value; |
| 24 | + $key = strtolower( $key ); |
| 25 | + $this->params[$key] =& $value; |
21 | 26 | } |
22 | 27 | |
| 28 | + /** |
| 29 | + * Retieves key/value pairs to circumvent global variables |
| 30 | + * Note that keys are case-insensitive! |
| 31 | + */ |
23 | 32 | function getVal( $key, $default = "" ) { |
24 | 33 | $key = strtolower( $key ); |
25 | 34 | if( isset( $this->params[$key] ) ) { |
— | — | @@ -28,10 +37,29 @@ |
29 | 38 | } |
30 | 39 | |
31 | 40 | /** |
| 41 | + * Initialization of ... everything |
| 42 | + @return Article either the object to become $wgArticle, or NULL |
| 43 | + */ |
| 44 | + function initialize ( &$title, &$output, &$user, $request ) { |
| 45 | + wfProfileIn( 'MediaWiki::initialize' ); |
| 46 | + $article = NULL; |
| 47 | + if ( !$this->initializeSpecialCases( $title, $output, $request ) ) { |
| 48 | + $article = $this->initializeArticle( $title, $request ); |
| 49 | + $this->performAction( $output, $article, $title, $user, $request ); |
| 50 | + } |
| 51 | + wfProfileOut( 'MediaWiki::initialize' ); |
| 52 | + return $article; |
| 53 | + } |
| 54 | + |
| 55 | + /** |
32 | 56 | * Initialize the object to be known as $wgArticle for special cases |
33 | 57 | */ |
34 | | - function initializeSpecialCases ( &$title , &$output , $request , $action , &$search ) { |
| 58 | + function initializeSpecialCases ( &$title, &$output, $request ) { |
| 59 | + |
35 | 60 | wfProfileIn( 'MediaWiki::initializeSpecialCases' ); |
| 61 | + |
| 62 | + $search = $this->getVal('Search'); |
| 63 | + $action = $this->getVal('Action'); |
36 | 64 | if( !$this->getVal('DisableInternalSearch') && !is_null( $search ) && $search !== '' ) { |
37 | 65 | require_once( 'includes/SpecialSearch.php' ); |
38 | 66 | $title = Title::makeTitle( NS_SPECIAL, 'Search' ); |
— | — | @@ -75,9 +103,11 @@ |
76 | 104 | /** |
77 | 105 | * Initialize the object to be known as $wgArticle for "standard" actions |
78 | 106 | */ |
79 | | - function initializeArticle( &$title, $request, $action ) { |
| 107 | + function initializeArticle( &$title, $request ) { |
80 | 108 | |
81 | 109 | wfProfileIn( 'MediaWiki::initializeArticle' ); |
| 110 | + |
| 111 | + $action = $this->getVal('Action'); |
82 | 112 | |
83 | 113 | if( NS_MEDIA == $title->getNamespace() ) { |
84 | 114 | $title = Title::makeTitle( NS_IMAGE, $title->getDBkey() ); |
— | — | @@ -119,10 +149,16 @@ |
120 | 150 | /** |
121 | 151 | * Perform one of the "standard" actions |
122 | 152 | */ |
123 | | - function performAction( $action, &$output, &$article, &$title, &$user, &$request ) { |
| 153 | + function performAction( &$output, &$article, &$title, &$user, &$request ) { |
124 | 154 | |
125 | 155 | wfProfileIn( 'MediaWiki::performAction' ); |
126 | 156 | |
| 157 | + $action = $this->getVal('Action'); |
| 158 | + if( in_array( $action, $this->getVal('DisabledActions',array()) ) ) { |
| 159 | + /* No such action; this will switch to the default case */ |
| 160 | + $action = "nosuchaction"; |
| 161 | + } |
| 162 | + |
127 | 163 | switch( $action ) { |
128 | 164 | case 'view': |
129 | 165 | $output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) ); |