Index: trunk/phase3/includes/AutoLoader.php |
— | — | @@ -191,6 +191,7 @@ |
192 | 192 | 'RdfMetaData' => 'includes/Metadata.php', |
193 | 193 | 'ReadOnlyError' => 'includes/Exception.php', |
194 | 194 | 'RecentChange' => 'includes/RecentChange.php', |
| 195 | + 'RedirectSpecialPage' => 'includes/SpecialPage.php', |
195 | 196 | 'RegexlikeReplacer' => 'includes/StringUtils.php', |
196 | 197 | 'ReplacementArray' => 'includes/StringUtils.php', |
197 | 198 | 'Replacer' => 'includes/StringUtils.php', |
— | — | @@ -206,6 +207,9 @@ |
207 | 208 | 'Skin' => 'includes/Skin.php', |
208 | 209 | 'SkinLegacy' => 'includes/SkinLegacy.php', |
209 | 210 | 'SkinTemplate' => 'includes/SkinTemplate.php', |
| 211 | + 'SpecialCreateAccount' => 'includes/SpecialPage.php', |
| 212 | + 'SpecialListAdmins' => 'includes/SpecialPage.php', |
| 213 | + 'SpecialListBots' => 'includes/SpecialPage.php', |
210 | 214 | 'SpecialMycontributions' => 'includes/SpecialPage.php', |
211 | 215 | 'SpecialMypage' => 'includes/SpecialPage.php', |
212 | 216 | 'SpecialMytalk' => 'includes/SpecialPage.php', |
Index: trunk/phase3/includes/SpecialPage.php |
— | — | @@ -485,7 +485,7 @@ |
486 | 486 | * @param $user User: the user to check |
487 | 487 | * @return Boolean: does the user have permission to view the page? |
488 | 488 | */ |
489 | | - public function userCanExecute( $user ) { |
| 489 | + public function userCanExecute( User $user ) { |
490 | 490 | return $user->isAllowed( $this->mRestriction ); |
491 | 491 | } |
492 | 492 | |
— | — | @@ -693,22 +693,32 @@ |
694 | 694 | * Shortcut to construct a special page alias. |
695 | 695 | * @ingroup SpecialPage |
696 | 696 | */ |
697 | | -abstract class SpecialRedirectToSpecial extends UnlistedSpecialPage { |
| 697 | +abstract class RedirectSpecialPage extends UnlistedSpecialPage { |
698 | 698 | |
699 | 699 | // Query parameters that can be passed through redirects |
700 | | - private $mAllowedRedirectParams = array(); |
| 700 | + protected $mAllowedRedirectParams = array(); |
701 | 701 | |
702 | 702 | // Query parameteres added by redirects |
703 | | - private $mAddedRedirectParams = array(); |
704 | | - |
705 | | - var $redirName, $redirSubpage; |
706 | | - |
707 | | - function __construct( $name, $redirName, $redirSubpage = false, $allowedRedirectParams = array(), $addedRedirectParams = array() ) { |
708 | | - parent::__construct( $name ); |
709 | | - $this->redirName = $redirName; |
710 | | - $this->redirSubpage = $redirSubpage; |
711 | | - $this->mAllowedRedirectParams = $allowedRedirectParams; |
712 | | - $this->mAddedRedirectParams = $addedRedirectParams; |
| 703 | + protected $mAddedRedirectParams = array(); |
| 704 | + |
| 705 | + public function execute( $par ){ |
| 706 | + $redirect = $this->getRedirect( $par ); |
| 707 | + $query = $this->getRedirectQuery(); |
| 708 | + if ( $redirect instanceof Title ) { |
| 709 | + $url = $redirect->getFullUrl( $query ); |
| 710 | + $this->getContext()->output->redirect( $url ); |
| 711 | + wfProfileOut( __METHOD__ ); |
| 712 | + return $redirect; |
| 713 | + } elseif ( $redirect === true ) { |
| 714 | + global $wgScript; |
| 715 | + $url = $wgScript . '?' . wfArrayToCGI( $query ); |
| 716 | + $this->getContext()->output->redirect( $url ); |
| 717 | + wfProfileOut( __METHOD__ ); |
| 718 | + return $redirect; |
| 719 | + } else { |
| 720 | + $class = __CLASS__; |
| 721 | + throw new MWException( "RedirectSpecialPage $class doesn't redirect!" ); |
| 722 | + } |
713 | 723 | } |
714 | 724 | |
715 | 725 | /** |
— | — | @@ -717,13 +727,7 @@ |
718 | 728 | * |
719 | 729 | * @return Title|false |
720 | 730 | */ |
721 | | - public function getRedirect( $subpage ) { |
722 | | - if ( $this->redirSubpage === false ) { |
723 | | - return SpecialPage::getTitleFor( $this->redirName, $subpage ); |
724 | | - } else { |
725 | | - return SpecialPage::getTitleFor( $this->redirName, $this->redirSubpage ); |
726 | | - } |
727 | | - } |
| 731 | + abstract public function getRedirect( $par ); |
728 | 732 | |
729 | 733 | /** |
730 | 734 | * Return part of the request string for a special redirect page |
— | — | @@ -750,6 +754,27 @@ |
751 | 755 | } |
752 | 756 | } |
753 | 757 | |
| 758 | +abstract class SpecialRedirectToSpecial extends RedirectSpecialPage { |
| 759 | + |
| 760 | + var $redirName, $redirSubpage; |
| 761 | + |
| 762 | + function __construct( $name, $redirName, $redirSubpage = false, $allowedRedirectParams = array(), $addedRedirectParams = array() ) { |
| 763 | + parent::__construct( $name ); |
| 764 | + $this->redirName = $redirName; |
| 765 | + $this->redirSubpage = $redirSubpage; |
| 766 | + $this->mAllowedRedirectParams = $allowedRedirectParams; |
| 767 | + $this->mAddedRedirectParams = $addedRedirectParams; |
| 768 | + } |
| 769 | + |
| 770 | + public function getRedirect( $subpage ) { |
| 771 | + if ( $this->redirSubpage === false ) { |
| 772 | + return SpecialPage::getTitleFor( $this->redirName, $subpage ); |
| 773 | + } else { |
| 774 | + return SpecialPage::getTitleFor( $this->redirName, $this->redirSubpage ); |
| 775 | + } |
| 776 | + } |
| 777 | +} |
| 778 | + |
754 | 779 | /** |
755 | 780 | * ListAdmins --> ListUsers/admin |
756 | 781 | */ |
— | — | @@ -789,7 +814,7 @@ |
790 | 815 | * Shortcut to construct a special page pointing to current user user's page. |
791 | 816 | * @ingroup SpecialPage |
792 | 817 | */ |
793 | | -class SpecialMypage extends UnlistedSpecialPage { |
| 818 | +class SpecialMypage extends RedirectSpecialPage { |
794 | 819 | function __construct() { |
795 | 820 | parent::__construct( 'Mypage' ); |
796 | 821 | $this->mAllowedRedirectParams = array( 'action' , 'preload' , 'editintro', |
— | — | @@ -810,7 +835,7 @@ |
811 | 836 | * Shortcut to construct a special page pointing to current user talk page. |
812 | 837 | * @ingroup SpecialPage |
813 | 838 | */ |
814 | | -class SpecialMytalk extends UnlistedSpecialPage { |
| 839 | +class SpecialMytalk extends RedirectSpecialPage { |
815 | 840 | function __construct() { |
816 | 841 | parent::__construct( 'Mytalk' ); |
817 | 842 | $this->mAllowedRedirectParams = array( 'action' , 'preload' , 'editintro', |
— | — | @@ -831,7 +856,7 @@ |
832 | 857 | * Shortcut to construct a special page pointing to current user contributions. |
833 | 858 | * @ingroup SpecialPage |
834 | 859 | */ |
835 | | -class SpecialMycontributions extends UnlistedSpecialPage { |
| 860 | +class SpecialMycontributions extends RedirectSpecialPage { |
836 | 861 | function __construct() { |
837 | 862 | parent::__construct( 'Mycontributions' ); |
838 | 863 | $this->mAllowedRedirectParams = array( 'limit', 'namespace', 'tagfilter', |
— | — | @@ -847,7 +872,7 @@ |
848 | 873 | /** |
849 | 874 | * Redirect to Special:Listfiles?user=$wgUser |
850 | 875 | */ |
851 | | -class SpecialMyuploads extends UnlistedSpecialPage { |
| 876 | +class SpecialMyuploads extends RedirectSpecialPage { |
852 | 877 | function __construct() { |
853 | 878 | parent::__construct( 'Myuploads' ); |
854 | 879 | $this->mAllowedRedirectParams = array( 'limit' ); |
— | — | @@ -862,7 +887,7 @@ |
863 | 888 | /** |
864 | 889 | * Redirect from Special:PermanentLink/### to index.php?oldid=### |
865 | 890 | */ |
866 | | -class SpecialPermanentLink extends UnlistedSpecialPage { |
| 891 | +class SpecialPermanentLink extends RedirectSpecialPage { |
867 | 892 | function __construct() { |
868 | 893 | parent::__construct( 'PermanentLink' ); |
869 | 894 | $this->mAllowedRedirectParams = array(); |