Index: trunk/phase3/includes/SpecialPage.php |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | * page list. |
29 | 29 | * @ingroup SpecialPage |
30 | 30 | */ |
31 | | -class SpecialPage extends ContextSource { |
| 31 | +class SpecialPage { |
32 | 32 | |
33 | 33 | // The canonical name of this special page |
34 | 34 | // Also used for the default <h1> heading, @see getDescription() |
— | — | @@ -612,6 +612,92 @@ |
613 | 613 | } |
614 | 614 | |
615 | 615 | /** |
| 616 | + * Sets the context this SpecialPage is executed in |
| 617 | + * |
| 618 | + * @param $context IContextSource |
| 619 | + * @since 1.18 |
| 620 | + */ |
| 621 | + public function setContext( $context ) { |
| 622 | + $this->mContext = $context; |
| 623 | + } |
| 624 | + |
| 625 | + /** |
| 626 | + * Gets the context this SpecialPage is executed in |
| 627 | + * |
| 628 | + * @return IContextSource |
| 629 | + * @since 1.18 |
| 630 | + */ |
| 631 | + public function getContext() { |
| 632 | + if ( $this->mContext instanceof IContextSource ) { |
| 633 | + return $this->mContext; |
| 634 | + } else { |
| 635 | + wfDebug( __METHOD__ . " called and \$mContext is null. Return RequestContext::getMain(); for sanity\n" ); |
| 636 | + return RequestContext::getMain(); |
| 637 | + } |
| 638 | + } |
| 639 | + |
| 640 | + /** |
| 641 | + * Get the WebRequest being used for this instance |
| 642 | + * |
| 643 | + * @return WebRequest |
| 644 | + * @since 1.18 |
| 645 | + */ |
| 646 | + public function getRequest() { |
| 647 | + return $this->getContext()->getRequest(); |
| 648 | + } |
| 649 | + |
| 650 | + /** |
| 651 | + * Get the OutputPage being used for this instance |
| 652 | + * |
| 653 | + * @return OutputPage |
| 654 | + * @since 1.18 |
| 655 | + */ |
| 656 | + public function getOutput() { |
| 657 | + return $this->getContext()->getOutput(); |
| 658 | + } |
| 659 | + |
| 660 | + /** |
| 661 | + * Shortcut to get the User executing this instance |
| 662 | + * |
| 663 | + * @return User |
| 664 | + * @since 1.18 |
| 665 | + */ |
| 666 | + public function getUser() { |
| 667 | + return $this->getContext()->getUser(); |
| 668 | + } |
| 669 | + |
| 670 | + /** |
| 671 | + * Shortcut to get the skin being used for this instance |
| 672 | + * |
| 673 | + * @return Skin |
| 674 | + * @since 1.18 |
| 675 | + */ |
| 676 | + public function getSkin() { |
| 677 | + return $this->getContext()->getSkin(); |
| 678 | + } |
| 679 | + |
| 680 | + /** |
| 681 | + * Shortcut to get user's language |
| 682 | + * |
| 683 | + * @deprecated 1.19 Use getLanguage instead |
| 684 | + * @return Language |
| 685 | + * @since 1.18 |
| 686 | + */ |
| 687 | + public function getLang() { |
| 688 | + return $this->getLanguage(); |
| 689 | + } |
| 690 | + |
| 691 | + /** |
| 692 | + * Shortcut to get user's language |
| 693 | + * |
| 694 | + * @return Language |
| 695 | + * @since 1.19 |
| 696 | + */ |
| 697 | + public function getLanguage() { |
| 698 | + return $this->getContext()->getLanguage(); |
| 699 | + } |
| 700 | + |
| 701 | + /** |
616 | 702 | * Return the full title, including $par |
617 | 703 | * |
618 | 704 | * @return Title |
Index: trunk/phase3/includes/Action.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | * |
25 | 25 | * @file |
26 | 26 | */ |
27 | | -abstract class Action extends ContextSource { |
| 27 | +abstract class Action { |
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Page on which we're performing the action |
— | — | @@ -96,6 +96,91 @@ |
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
| 100 | + * Get the IContextSource in use here |
| 101 | + * @return IContextSource |
| 102 | + */ |
| 103 | + public final function getContext() { |
| 104 | + if ( $this->context instanceof IContextSource ) { |
| 105 | + return $this->context; |
| 106 | + } |
| 107 | + return $this->page->getContext(); |
| 108 | + } |
| 109 | + |
| 110 | + /** |
| 111 | + * Get the WebRequest being used for this instance |
| 112 | + * |
| 113 | + * @return WebRequest |
| 114 | + */ |
| 115 | + public final function getRequest() { |
| 116 | + return $this->getContext()->getRequest(); |
| 117 | + } |
| 118 | + |
| 119 | + /** |
| 120 | + * Get the OutputPage being used for this instance |
| 121 | + * |
| 122 | + * @return OutputPage |
| 123 | + */ |
| 124 | + public final function getOutput() { |
| 125 | + return $this->getContext()->getOutput(); |
| 126 | + } |
| 127 | + |
| 128 | + /** |
| 129 | + * Shortcut to get the User being used for this instance |
| 130 | + * |
| 131 | + * @return User |
| 132 | + */ |
| 133 | + public final function getUser() { |
| 134 | + return $this->getContext()->getUser(); |
| 135 | + } |
| 136 | + |
| 137 | + /** |
| 138 | + * Shortcut to get the Skin being used for this instance |
| 139 | + * |
| 140 | + * @return Skin |
| 141 | + */ |
| 142 | + public final function getSkin() { |
| 143 | + return $this->getContext()->getSkin(); |
| 144 | + } |
| 145 | + |
| 146 | + /** |
| 147 | + * Shortcut to get the user Language being used for this instance |
| 148 | + * |
| 149 | + * @return Skin |
| 150 | + */ |
| 151 | + public final function getLanguage() { |
| 152 | + return $this->getContext()->getLanguage(); |
| 153 | + } |
| 154 | + |
| 155 | + /** |
| 156 | + * Shortcut to get the user Language being used for this instance |
| 157 | + * |
| 158 | + * @deprecated 1.19 Use getLanguage instead |
| 159 | + * @return Skin |
| 160 | + */ |
| 161 | + public final function getLang() { |
| 162 | + return $this->getLanguage(); |
| 163 | + } |
| 164 | + |
| 165 | + /** |
| 166 | + * Shortcut to get the Title object from the page |
| 167 | + * @return Title |
| 168 | + */ |
| 169 | + public final function getTitle() { |
| 170 | + return $this->page->getTitle(); |
| 171 | + } |
| 172 | + |
| 173 | + /** |
| 174 | + * Get a Message object with context set |
| 175 | + * Parameters are the same as wfMessage() |
| 176 | + * |
| 177 | + * @return Message object |
| 178 | + */ |
| 179 | + public final function msg() { |
| 180 | + $params = func_get_args(); |
| 181 | + return call_user_func_array( array( $this->getContext(), 'msg' ), $params ); |
| 182 | + } |
| 183 | + |
| 184 | + /** |
100 | 185 | * Protected constructor: use Action::factory( $action, $page ) to actually build |
101 | 186 | * these things in the real world |
102 | 187 | * @param Page $page |