Index: trunk/phase3/includes/actions/CreditsAction.php |
— | — | @@ -25,11 +25,11 @@ |
26 | 26 | |
27 | 27 | class CreditsAction extends FormlessAction { |
28 | 28 | |
29 | | - public function getName(){ |
| 29 | + public function getName() { |
30 | 30 | return 'credits'; |
31 | 31 | } |
32 | 32 | |
33 | | - public function getRestriction(){ |
| 33 | + public function getRestriction() { |
34 | 34 | return null; |
35 | 35 | } |
36 | 36 | |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | * @param $showIfMax Bool: whether to contributors if there more than $cnt |
59 | 59 | * @return String: html |
60 | 60 | */ |
61 | | - protected function getCredits( $cnt, $showIfMax = true ) { |
| 61 | + public function getCredits( $cnt, $showIfMax = true ) { |
62 | 62 | wfProfileIn( __METHOD__ ); |
63 | 63 | $s = ''; |
64 | 64 | |
Index: trunk/phase3/includes/actions/PurgeAction.php |
— | — | @@ -25,19 +25,19 @@ |
26 | 26 | |
27 | 27 | class PurgeAction extends FormAction { |
28 | 28 | |
29 | | - public function getName(){ |
| 29 | + public function getName() { |
30 | 30 | return 'purge'; |
31 | 31 | } |
32 | 32 | |
33 | | - public function getRestriction(){ |
| 33 | + public function getRestriction() { |
34 | 34 | return null; |
35 | 35 | } |
36 | 36 | |
37 | | - public function requiresUnblock(){ |
| 37 | + public function requiresUnblock() { |
38 | 38 | return false; |
39 | 39 | } |
40 | 40 | |
41 | | - public function getDescription(){ |
| 41 | + public function getDescription() { |
42 | 42 | return ''; |
43 | 43 | } |
44 | 44 | |
— | — | @@ -45,11 +45,11 @@ |
46 | 46 | * Just get an empty form with a single submit button |
47 | 47 | * @return array |
48 | 48 | */ |
49 | | - protected function getFormFields(){ |
| 49 | + protected function getFormFields() { |
50 | 50 | return array(); |
51 | 51 | } |
52 | 52 | |
53 | | - public function onSubmit( $data ){ |
| 53 | + public function onSubmit( $data ) { |
54 | 54 | $this->page->doPurge(); |
55 | 55 | return true; |
56 | 56 | } |
— | — | @@ -58,36 +58,36 @@ |
59 | 59 | * purge is slightly wierd because it can be either formed or formless depending |
60 | 60 | * on user permissions |
61 | 61 | */ |
62 | | - public function show(){ |
| 62 | + public function show() { |
63 | 63 | $this->setHeaders(); |
64 | 64 | |
65 | 65 | // This will throw exceptions if there's a problem |
66 | 66 | $this->checkCanExecute( $this->getUser() ); |
67 | 67 | |
68 | | - if( $this->getUser()->isAllowed( 'purge' ) ){ |
| 68 | + if ( $this->getUser()->isAllowed( 'purge' ) ) { |
69 | 69 | $this->onSubmit( array() ); |
70 | 70 | $this->onSuccess(); |
71 | 71 | } else { |
72 | 72 | $form = $this->getForm(); |
73 | | - if( $form->show() ){ |
| 73 | + if ( $form->show() ) { |
74 | 74 | $this->onSuccess(); |
75 | 75 | } |
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
79 | | - protected function alterForm( HTMLForm $form ){ |
| 79 | + protected function alterForm( HTMLForm $form ) { |
80 | 80 | $form->setSubmitText( wfMsg( 'confirm_purge_button' ) ); |
81 | 81 | } |
82 | 82 | |
83 | | - protected function preText(){ |
| 83 | + protected function preText() { |
84 | 84 | return wfMessage( 'confirm-purge-top' )->parse(); |
85 | 85 | } |
86 | 86 | |
87 | | - protected function postText(){ |
| 87 | + protected function postText() { |
88 | 88 | return wfMessage( 'confirm-purge-bottom' )->parse(); |
89 | 89 | } |
90 | 90 | |
91 | | - public function onSuccess(){ |
| 91 | + public function onSuccess() { |
92 | 92 | $this->getOutput()->redirect( $this->getTitle() ); |
93 | 93 | } |
94 | 94 | } |
Index: trunk/phase3/includes/actions/WatchAction.php |
— | — | @@ -22,23 +22,23 @@ |
23 | 23 | |
24 | 24 | class WatchAction extends FormlessAction { |
25 | 25 | |
26 | | - public function getName(){ |
| 26 | + public function getName() { |
27 | 27 | return 'watch'; |
28 | 28 | } |
29 | 29 | |
30 | | - public function getRestriction(){ |
| 30 | + public function getRestriction() { |
31 | 31 | return 'read'; |
32 | 32 | } |
33 | 33 | |
34 | | - public function requiresUnblock(){ |
| 34 | + public function requiresUnblock() { |
35 | 35 | return false; |
36 | 36 | } |
37 | 37 | |
38 | | - protected function getDescription(){ |
| 38 | + protected function getDescription() { |
39 | 39 | return wfMsg( 'addedwatch' ); |
40 | 40 | } |
41 | 41 | |
42 | | - protected function checkCanExecute( User $user ){ |
| 42 | + protected function checkCanExecute( User $user ) { |
43 | 43 | if ( $user->isAnon() ) { |
44 | 44 | throw new ErrorPageError( 'watchnologin', 'watchnologintext' ); |
45 | 45 | } |
— | — | @@ -62,11 +62,11 @@ |
63 | 63 | |
64 | 64 | class UnwatchAction extends WatchAction { |
65 | 65 | |
66 | | - public function getName(){ |
| 66 | + public function getName() { |
67 | 67 | return 'unwatch'; |
68 | 68 | } |
69 | 69 | |
70 | | - protected function getDescription(){ |
| 70 | + protected function getDescription() { |
71 | 71 | return wfMsg( 'removedwatch' ); |
72 | 72 | } |
73 | 73 | |
Index: trunk/phase3/includes/SkinLegacy.php |
— | — | @@ -210,7 +210,7 @@ |
211 | 211 | } |
212 | 212 | |
213 | 213 | if ( $wgMaxCredits != 0 ) { |
214 | | - $s .= ' ' . Credits::getCredits( $article, $wgMaxCredits, $wgShowCreditsIfMax ); |
| 214 | + $s .= ' ' . Action::factory( 'credits', $article )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ); |
215 | 215 | } else { |
216 | 216 | $s .= $this->data['lastmod']; |
217 | 217 | } |
Index: trunk/phase3/includes/SkinTemplate.php |
— | — | @@ -382,7 +382,7 @@ |
383 | 383 | $this->credits = false; |
384 | 384 | |
385 | 385 | if( $wgMaxCredits != 0 ){ |
386 | | - $this->credits = Credits::getCredits( $article, $wgMaxCredits, $wgShowCreditsIfMax ); |
| 386 | + $this->credits = Action::factory( 'credits', $article )->getCredits( $wgMaxCredits, $wgShowCreditsIfMax ); |
387 | 387 | } else { |
388 | 388 | $tpl->set( 'lastmod', $this->lastModified( $article ) ); |
389 | 389 | } |
Index: trunk/phase3/includes/Action.php |
— | — | @@ -43,19 +43,19 @@ |
44 | 44 | * @param $action String |
45 | 45 | * @return bool|null|string |
46 | 46 | */ |
47 | | - private final static function getClass( $action ){ |
| 47 | + private final static function getClass( $action ) { |
48 | 48 | global $wgActions; |
49 | 49 | $action = strtolower( $action ); |
50 | 50 | |
51 | | - if( !isset( $wgActions[$action] ) ){ |
| 51 | + if ( !isset( $wgActions[$action] ) ) { |
52 | 52 | return null; |
53 | 53 | } |
54 | 54 | |
55 | | - if( $wgActions[$action] === false ){ |
| 55 | + if ( $wgActions[$action] === false ) { |
56 | 56 | return false; |
57 | 57 | } |
58 | 58 | |
59 | | - elseif( $wgActions[$action] === true ){ |
| 59 | + elseif ( $wgActions[$action] === true ) { |
60 | 60 | return ucfirst( $action ) . 'Action'; |
61 | 61 | } |
62 | 62 | |
— | — | @@ -71,9 +71,9 @@ |
72 | 72 | * @return Action|false|null false if the action is disabled, null |
73 | 73 | * if it is not recognised |
74 | 74 | */ |
75 | | - public final static function factory( $action, Article $page ){ |
| 75 | + public final static function factory( $action, Article $page ) { |
76 | 76 | $class = self::getClass( $action ); |
77 | | - if( $class ){ |
| 77 | + if ( $class ) { |
78 | 78 | $obj = new $class( $page ); |
79 | 79 | return $obj; |
80 | 80 | } |
— | — | @@ -94,8 +94,8 @@ |
95 | 95 | * Get the RequestContext in use here |
96 | 96 | * @return RequestContext |
97 | 97 | */ |
98 | | - protected final function getContext(){ |
99 | | - if( $this->context instanceof RequestContext ){ |
| 98 | + protected final function getContext() { |
| 99 | + if ( $this->context instanceof RequestContext ) { |
100 | 100 | return $this->context; |
101 | 101 | } |
102 | 102 | return $this->page->getContext(); |
— | — | @@ -138,10 +138,19 @@ |
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
| 142 | + * Shortcut to get the user Language being used for this instance |
| 143 | + * |
| 144 | + * @return Skin |
| 145 | + */ |
| 146 | + protected final function getLang() { |
| 147 | + return $this->getContext()->lang; |
| 148 | + } |
| 149 | + |
| 150 | + /** |
142 | 151 | * Shortcut to get the Title object from the page |
143 | 152 | * @return Title |
144 | 153 | */ |
145 | | - protected final function getTitle(){ |
| 154 | + protected final function getTitle() { |
146 | 155 | return $this->page->getTitle(); |
147 | 156 | } |
148 | 157 | |
— | — | @@ -150,7 +159,7 @@ |
151 | 160 | * these things in the real world |
152 | 161 | * @param Article $page |
153 | 162 | */ |
154 | | - protected function __construct( Article $page ){ |
| 163 | + protected function __construct( Article $page ) { |
155 | 164 | $this->page = $page; |
156 | 165 | } |
157 | 166 | |
— | — | @@ -175,15 +184,15 @@ |
176 | 185 | * @throws ErrorPageError |
177 | 186 | */ |
178 | 187 | protected function checkCanExecute( User $user ) { |
179 | | - if( $this->requiresWrite() && wfReadOnly() ){ |
| 188 | + if ( $this->requiresWrite() && wfReadOnly() ) { |
180 | 189 | throw new ReadOnlyError(); |
181 | 190 | } |
182 | 191 | |
183 | | - if( $this->getRestriction() !== null && !$user->isAllowed( $this->getRestriction() ) ){ |
| 192 | + if ( $this->getRestriction() !== null && !$user->isAllowed( $this->getRestriction() ) ) { |
184 | 193 | throw new PermissionsError( $this->getRestriction() ); |
185 | 194 | } |
186 | 195 | |
187 | | - if( $this->requiresUnblock() && $user->isBlocked() ){ |
| 196 | + if ( $this->requiresUnblock() && $user->isBlocked() ) { |
188 | 197 | $block = $user->mBlock; |
189 | 198 | throw new UserBlockedError( $block ); |
190 | 199 | } |
— | — | @@ -193,7 +202,7 @@ |
194 | 203 | * Whether this action requires the wiki not to be locked |
195 | 204 | * @return Bool |
196 | 205 | */ |
197 | | - public function requiresWrite(){ |
| 206 | + public function requiresWrite() { |
198 | 207 | return true; |
199 | 208 | } |
200 | 209 | |
— | — | @@ -201,7 +210,7 @@ |
202 | 211 | * Whether this action can still be executed by a blocked user |
203 | 212 | * @return Bool |
204 | 213 | */ |
205 | | - public function requiresUnblock(){ |
| 214 | + public function requiresUnblock() { |
206 | 215 | return true; |
207 | 216 | } |
208 | 217 | |
— | — | @@ -220,10 +229,6 @@ |
221 | 230 | /** |
222 | 231 | * Returns the name that goes in the \<h1\> page title |
223 | 232 | * |
224 | | - * Derived classes can override this, but usually it is easier to keep the |
225 | | - * default behaviour. Messages can be added at run-time, see |
226 | | - * MessageCache.php. |
227 | | - * |
228 | 233 | * @return String |
229 | 234 | */ |
230 | 235 | protected function getDescription() { |
— | — | @@ -259,20 +264,20 @@ |
260 | 265 | * Add pre- or post-text to the form |
261 | 266 | * @return String HTML which will be sent to $form->addPreText() |
262 | 267 | */ |
263 | | - protected function preText(){ return ''; } |
264 | | - protected function postText(){ return ''; } |
| 268 | + protected function preText() { return ''; } |
| 269 | + protected function postText() { return ''; } |
265 | 270 | |
266 | 271 | /** |
267 | 272 | * Play with the HTMLForm if you need to more substantially |
268 | | - * @param &$form HTMLForm |
| 273 | + * @param $form HTMLForm |
269 | 274 | */ |
270 | | - protected function alterForm( HTMLForm &$form ){} |
| 275 | + protected function alterForm( HTMLForm $form ) {} |
271 | 276 | |
272 | 277 | /** |
273 | 278 | * Get the HTMLForm to control behaviour |
274 | 279 | * @return HTMLForm|null |
275 | 280 | */ |
276 | | - protected function getForm(){ |
| 281 | + protected function getForm() { |
277 | 282 | $this->fields = $this->getFormFields(); |
278 | 283 | |
279 | 284 | // Give hooks a chance to alter the form, adding extra fields or text etc |
— | — | @@ -315,14 +320,14 @@ |
316 | 321 | * display something new or redirect to somewhere. Some actions have more exotic |
317 | 322 | * behaviour, but that's what subclassing is for :D |
318 | 323 | */ |
319 | | - public function show(){ |
| 324 | + public function show() { |
320 | 325 | $this->setHeaders(); |
321 | 326 | |
322 | 327 | // This will throw exceptions if there's a problem |
323 | 328 | $this->checkCanExecute( $this->getUser() ); |
324 | 329 | |
325 | 330 | $form = $this->getForm(); |
326 | | - if( $form->show() ){ |
| 331 | + if ( $form->show() ) { |
327 | 332 | $this->onSuccess(); |
328 | 333 | } |
329 | 334 | } |
— | — | @@ -334,7 +339,7 @@ |
335 | 340 | * @param bool $captureErrors |
336 | 341 | * @return bool |
337 | 342 | */ |
338 | | - public function execute( array $data = null, $captureErrors = true ){ |
| 343 | + public function execute( array $data = null, $captureErrors = true ) { |
339 | 344 | try { |
340 | 345 | // Set a new context so output doesn't leak. |
341 | 346 | $this->context = clone $this->page->getContext(); |
— | — | @@ -343,17 +348,17 @@ |
344 | 349 | $this->checkCanExecute( $this->getUser() ); |
345 | 350 | |
346 | 351 | $fields = array(); |
347 | | - foreach( $this->fields as $key => $params ){ |
348 | | - if( isset( $data[$key] ) ){ |
| 352 | + foreach ( $this->fields as $key => $params ) { |
| 353 | + if ( isset( $data[$key] ) ) { |
349 | 354 | $fields[$key] = $data[$key]; |
350 | | - } elseif( isset( $params['default'] ) ) { |
| 355 | + } elseif ( isset( $params['default'] ) ) { |
351 | 356 | $fields[$key] = $params['default']; |
352 | 357 | } else { |
353 | 358 | $fields[$key] = null; |
354 | 359 | } |
355 | 360 | } |
356 | 361 | $status = $this->onSubmit( $fields ); |
357 | | - if( $status === true ){ |
| 362 | + if ( $status === true ) { |
358 | 363 | // This might do permanent stuff |
359 | 364 | $this->onSuccess(); |
360 | 365 | return true; |
— | — | @@ -361,8 +366,8 @@ |
362 | 367 | return false; |
363 | 368 | } |
364 | 369 | } |
365 | | - catch ( ErrorPageError $e ){ |
366 | | - if( $captureErrors ){ |
| 370 | + catch ( ErrorPageError $e ) { |
| 371 | + if ( $captureErrors ) { |
367 | 372 | return false; |
368 | 373 | } else { |
369 | 374 | throw $e; |
— | — | @@ -388,19 +393,19 @@ |
389 | 394 | /** |
390 | 395 | * We don't want an HTMLForm |
391 | 396 | */ |
392 | | - protected function getFormFields(){ |
| 397 | + protected function getFormFields() { |
393 | 398 | return false; |
394 | 399 | } |
395 | 400 | |
396 | | - public function onSubmit( $data ){ |
| 401 | + public function onSubmit( $data ) { |
397 | 402 | return false; |
398 | 403 | } |
399 | 404 | |
400 | | - public function onSuccess(){ |
| 405 | + public function onSuccess() { |
401 | 406 | return false; |
402 | 407 | } |
403 | 408 | |
404 | | - public function show(){ |
| 409 | + public function show() { |
405 | 410 | $this->setHeaders(); |
406 | 411 | |
407 | 412 | // This will throw exceptions if there's a problem |
— | — | @@ -416,11 +421,11 @@ |
417 | 422 | * @param $captureErrors Bool whether to catch exceptions and just return false |
418 | 423 | * @return Bool whether execution was successful |
419 | 424 | */ |
420 | | - public function execute( array $data = null, $captureErrors = true){ |
| 425 | + public function execute( array $data = null, $captureErrors = true ) { |
421 | 426 | try { |
422 | 427 | // Set a new context so output doesn't leak. |
423 | 428 | $this->context = clone $this->page->getContext(); |
424 | | - if( is_array( $data ) ){ |
| 429 | + if ( is_array( $data ) ) { |
425 | 430 | $this->context->setRequest( new FauxRequest( $data, false ) ); |
426 | 431 | } |
427 | 432 | |
— | — | @@ -430,8 +435,8 @@ |
431 | 436 | $this->onView(); |
432 | 437 | return true; |
433 | 438 | } |
434 | | - catch ( ErrorPageError $e ){ |
435 | | - if( $captureErrors ){ |
| 439 | + catch ( ErrorPageError $e ) { |
| 440 | + if ( $captureErrors ) { |
436 | 441 | return false; |
437 | 442 | } else { |
438 | 443 | throw $e; |
Index: trunk/extensions/ReplaceText/ReplaceTextJob.php |
— | — | @@ -42,11 +42,11 @@ |
43 | 43 | $create_redirect = $this->params['create_redirect']; |
44 | 44 | $this->title->moveTo( $new_title, true, $reason, $create_redirect ); |
45 | 45 | if ( $this->params['watch_page'] ) { |
46 | | - Action::factory( 'watch', new Article( $new_title ) )->execute(); |
| 46 | + Action::factory( 'watch', new Article( $new_title, 0 ) )->execute(); |
47 | 47 | } |
48 | 48 | $wgUser = $actual_user; |
49 | 49 | } else { |
50 | | - $article = new Article( $this->title ); |
| 50 | + $article = new Article( $this->title, 0 ); |
51 | 51 | if ( !$article ) { |
52 | 52 | $this->error = 'replaceText: Article not found "' . $this->title->getPrefixedDBkey() . '"'; |
53 | 53 | wfProfileOut( __METHOD__ ); |