Index: trunk/phase3/includes/Article.php |
— | — | @@ -17,6 +17,8 @@ |
18 | 18 | /**@{{ |
19 | 19 | * @private |
20 | 20 | */ |
| 21 | + protected $mContext; // !< RequestContext |
| 22 | + |
21 | 23 | var $mContent; // !< |
22 | 24 | var $mContentLoaded = false; // !< |
23 | 25 | var $mCounter = -1; // !< Not loaded |
— | — | @@ -4531,6 +4533,31 @@ |
4532 | 4534 | return $this->getOutputFromWikitext( $text, $useParserCache ); |
4533 | 4535 | } |
4534 | 4536 | |
| 4537 | + /** |
| 4538 | + * Sets the context this Article is executed in |
| 4539 | + * |
| 4540 | + * @param $context RequestContext |
| 4541 | + * @since 1.18 |
| 4542 | + */ |
| 4543 | + public function setContext( $context ) { |
| 4544 | + $this->mContext = $context; |
| 4545 | + } |
| 4546 | + |
| 4547 | + /** |
| 4548 | + * Gets the context this Article is executed in |
| 4549 | + * |
| 4550 | + * @return RequestContext |
| 4551 | + * @since 1.18 |
| 4552 | + */ |
| 4553 | + public function getContext() { |
| 4554 | + if ( $this->mContext instanceof RequestContext ) { |
| 4555 | + return $this->mContext; |
| 4556 | + } else { |
| 4557 | + wfDebug( __METHOD__ . " called and \$mContext is null. Return RequestContext::getMain(); for sanity\n" ); |
| 4558 | + return RequestContext::getMain(); |
| 4559 | + } |
| 4560 | + } |
| 4561 | + |
4535 | 4562 | } |
4536 | 4563 | |
4537 | 4564 | class PoolWorkArticleView extends PoolCounterWork { |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -266,7 +266,7 @@ |
267 | 267 | * @param $title Title |
268 | 268 | * @return Article object |
269 | 269 | */ |
270 | | - public static function articleFromTitle( &$title ) { |
| 270 | + public static function articleFromTitle( &$title, RequestContext &$context ) { |
271 | 271 | if ( NS_MEDIA == $title->getNamespace() ) { |
272 | 272 | // FIXME: where should this go? |
273 | 273 | $title = Title::makeTitle( NS_FILE, $title->getDBkey() ); |
— | — | @@ -280,12 +280,14 @@ |
281 | 281 | |
282 | 282 | switch( $title->getNamespace() ) { |
283 | 283 | case NS_FILE: |
284 | | - return new ImagePage( $title ); |
| 284 | + $page = new ImagePage( $title ); |
285 | 285 | case NS_CATEGORY: |
286 | | - return new CategoryPage( $title ); |
| 286 | + $page = new CategoryPage( $title ); |
287 | 287 | default: |
288 | | - return new Article( $title ); |
| 288 | + $page = new Article( $title ); |
289 | 289 | } |
| 290 | + $page->setContext( $context ); |
| 291 | + return $page; |
290 | 292 | } |
291 | 293 | |
292 | 294 | /** |
— | — | @@ -332,7 +334,7 @@ |
333 | 335 | wfProfileIn( __METHOD__ ); |
334 | 336 | |
335 | 337 | $action = $this->context->request->getVal( 'action', 'view' ); |
336 | | - $article = self::articleFromTitle( $this->context->title ); |
| 338 | + $article = self::articleFromTitle( $this->context->title, $this->context ); |
337 | 339 | // NS_MEDIAWIKI has no redirects. |
338 | 340 | // It is also used for CSS/JS, so performance matters here... |
339 | 341 | if ( $this->context->title->getNamespace() == NS_MEDIAWIKI ) { |
— | — | @@ -369,7 +371,7 @@ |
370 | 372 | } |
371 | 373 | if ( is_object( $target ) ) { |
372 | 374 | // Rewrite environment to redirected article |
373 | | - $rarticle = self::articleFromTitle( $target ); |
| 375 | + $rarticle = self::articleFromTitle( $target, $this->context ); |
374 | 376 | $rarticle->loadPageData(); |
375 | 377 | if ( $rarticle->exists() || ( is_object( $file ) && !$file->isLocal() ) ) { |
376 | 378 | $rarticle->setRedirectedFrom( $this->context->title ); |
— | — | @@ -467,9 +469,16 @@ |
468 | 470 | return; |
469 | 471 | } |
470 | 472 | |
471 | | - $action = $this->getAction(); |
| 473 | + $act = $this->getAction(); |
472 | 474 | |
473 | | - switch( $action ) { |
| 475 | + $action = Action::factory( $this->getAction(), $article ); |
| 476 | + if( $action instanceof Action ){ |
| 477 | + $action->execute(); |
| 478 | + wfProfileOut( __METHOD__ ); |
| 479 | + return; |
| 480 | + } |
| 481 | + |
| 482 | + switch( $act ) { |
474 | 483 | case 'view': |
475 | 484 | $this->context->output->setSquidMaxage( $this->getVal( 'SquidMaxage' ) ); |
476 | 485 | $article->view(); |
— | — | @@ -492,7 +501,7 @@ |
493 | 502 | case 'render': |
494 | 503 | case 'deletetrackback': |
495 | 504 | case 'purge': |
496 | | - $article->$action(); |
| 505 | + $article->$act(); |
497 | 506 | break; |
498 | 507 | case 'print': |
499 | 508 | $article->view(); |
— | — | @@ -513,9 +522,6 @@ |
514 | 523 | $rdf->show(); |
515 | 524 | } |
516 | 525 | break; |
517 | | - case 'credits': |
518 | | - Credits::showPage( $article ); |
519 | | - break; |
520 | 526 | case 'submit': |
521 | 527 | if ( session_id() == '' ) { |
522 | 528 | // Send a cookie so anons get talk message notifications |
— | — | @@ -528,7 +534,7 @@ |
529 | 535 | $external = $this->context->request->getVal( 'externaledit' ); |
530 | 536 | $section = $this->context->request->getVal( 'section' ); |
531 | 537 | $oldid = $this->context->request->getVal( 'oldid' ); |
532 | | - if ( !$this->getVal( 'UseExternalEditor' ) || $action == 'submit' || $internal || |
| 538 | + if ( !$this->getVal( 'UseExternalEditor' ) || $act == 'submit' || $internal || |
533 | 539 | $section || $oldid || ( !$this->context->user->getOption( 'externaleditor' ) && !$external ) ) { |
534 | 540 | $editor = new EditPage( $article ); |
535 | 541 | $editor->submit(); |
— | — | @@ -557,7 +563,7 @@ |
558 | 564 | $special->execute( '' ); |
559 | 565 | break; |
560 | 566 | default: |
561 | | - if ( wfRunHooks( 'UnknownAction', array( $action, $article ) ) ) { |
| 567 | + if ( wfRunHooks( 'UnknownAction', array( $act, $article ) ) ) { |
562 | 568 | $this->context->output->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); |
563 | 569 | } |
564 | 570 | } |