3 * SpecialPage: handling special pages and lists thereof.
5 * To add a special page in an extension, add to $wgSpecialPages either
6 * an object instance or an array containing the name and constructor
7 * parameters. The latter is preferred for performance reasons.
9 * The object instantiated must be either an instance of SpecialPage or a
10 * sub-class thereof. It must have an execute() method, which sends the HTML
11 * for the special page to $wgOut. The parent class has an execute() method
12 * which distributes the call to the historical global functions. Additionally,
13 * execute() also checks if the user has the necessary access privileges
14 * and bails out if not.
16 * To add a core special page, use the similar static list in
17 * SpecialPage::$mList. To remove a core static special page at runtime, use
18 * a SpecialPage_initList hook.
21 * @ingroup SpecialPage
22 * @defgroup SpecialPage SpecialPage
26 * Parent special page class, also static functions for handling the special
28 * @ingroup SpecialPage
32 // The canonical name of this special page
33 // Also used for the default <h1> heading, @see getDescription()
36 // The local name of this special page
39 // Minimum user level required to access this page, or "" for anyone.
40 // Also used to categorise the pages in Special:Specialpages
41 private $mRestriction;
43 // Listed in Special:Specialpages?
46 // Function name called by the default execute()
49 // File which needs to be included before the function above can be called
52 // Whether or not this special page is being included from an article
53 protected $mIncluding;
55 // Whether the special page can be included in an article
56 protected $mIncludable;
59 * Current request context
65 * Initialise the special page list
66 * This must be called before accessing SpecialPage::$mList
67 * @deprecated since 1.18
69 static function initList() {
74 * @deprecated since 1.18
76 static function initAliasList() {
81 * Given a special page alias, return the special page name.
82 * Returns false if there is no such alias.
84 * @param $alias String
85 * @return String or false
86 * @deprecated since 1.18 call SpecialPageFactory method directly
88 static function resolveAlias( $alias ) {
89 list( $name, /*...*/ ) = SpecialPageFactory
::resolveAlias( $alias );
94 * Given a special page name with a possible subpage, return an array
95 * where the first element is the special page name and the second is the
98 * @param $alias String
100 * @deprecated since 1.18 call SpecialPageFactory method directly
102 static function resolveAliasWithSubpage( $alias ) {
103 return SpecialPageFactory
::resolveAlias( $alias );
107 * Add a page to the list of valid special pages. This used to be the preferred
108 * method for adding special pages in extensions. It's now suggested that you add
109 * an associative record to $wgSpecialPages. This avoids autoloading SpecialPage.
111 * @param $page SpecialPage
112 * @deprecated since 1.7, warnings in 1.17, might be removed in 1.20
114 static function addPage( &$page ) {
115 wfDeprecated( __METHOD__
);
116 SpecialPageFactory
::getList()->{$page->mName
} = $page;
120 * Add a page to a certain display group for Special:SpecialPages
122 * @param $page Mixed: SpecialPage or string
123 * @param $group String
125 * @deprecated since 1.18 call SpecialPageFactory method directly
127 static function setGroup( $page, $group ) {
128 return SpecialPageFactory
::setGroup( $page, $group );
132 * Get the group that the special page belongs in on Special:SpecialPage
134 * @param $page SpecialPage
136 * @deprecated since 1.18 call SpecialPageFactory method directly
138 static function getGroup( &$page ) {
139 return SpecialPageFactory
::getGroup( $page );
143 * Remove a special page from the list
144 * Formerly used to disable expensive or dangerous special pages. The
145 * preferred method is now to add a SpecialPage_initList hook.
146 * @deprecated since 1.18
148 * @param $name String the page to remove
150 static function removePage( $name ) {
151 unset( SpecialPageFactory
::getList()->$name );
155 * Check if a given name exist as a special page or as a special page alias
157 * @param $name String: name of a special page
158 * @return Boolean: true if a special page exists with this name
159 * @deprecated since 1.18 call SpecialPageFactory method directly
161 static function exists( $name ) {
162 return SpecialPageFactory
::exists( $name );
166 * Find the object with a given name and return it (or NULL)
168 * @param $name String
169 * @return SpecialPage object or null if the page doesn't exist
170 * @deprecated since 1.18 call SpecialPageFactory method directly
172 static function getPage( $name ) {
173 return SpecialPageFactory
::getPage( $name );
177 * Get a special page with a given localised name, or NULL if there
178 * is no such special page.
180 * @param $alias String
181 * @return SpecialPage object or null if the page doesn't exist
182 * @deprecated since 1.18 call SpecialPageFactory method directly
184 static function getPageByAlias( $alias ) {
185 return SpecialPageFactory
::getPage( $alias );
189 * Return categorised listable special pages which are available
190 * for the current user, and everyone.
192 * @param $user User object to check permissions, $wgUser will be used
194 * @return Associative array mapping page's name to its SpecialPage object
195 * @deprecated since 1.18 call SpecialPageFactory method directly
197 static function getUsablePages( User
$user = null ) {
198 return SpecialPageFactory
::getUsablePages( $user );
202 * Return categorised listable special pages for all users
204 * @return Associative array mapping page's name to its SpecialPage object
205 * @deprecated since 1.18 call SpecialPageFactory method directly
207 static function getRegularPages() {
208 return SpecialPageFactory
::getRegularPages();
212 * Return categorised listable special pages which are available
213 * for the current user, but not for everyone
215 * @return Associative array mapping page's name to its SpecialPage object
216 * @deprecated since 1.18 call SpecialPageFactory method directly
218 static function getRestrictedPages() {
219 return SpecialPageFactory
::getRestrictedPages();
223 * Execute a special page path.
224 * The path may contain parameters, e.g. Special:Name/Params
225 * Extracts the special page name and call the execute method, passing the parameters
227 * Returns a title object if the page is redirected, false if there was no such special
228 * page, and true if it was successful.
230 * @param $title Title object
231 * @param $context IContextSource
232 * @param $including Bool output is being captured for use in {{special:whatever}}
234 * @deprecated since 1.18 call SpecialPageFactory method directly
236 public static function executePath( &$title, IContextSource
&$context, $including = false ) {
237 return SpecialPageFactory
::executePath( $title, $context, $including );
241 * Get the local name for a specified canonical name
243 * @param $name String
244 * @param $subpage Mixed: boolean false, or string
247 * @deprecated since 1.18 call SpecialPageFactory method directly
249 static function getLocalNameFor( $name, $subpage = false ) {
250 return SpecialPageFactory
::getLocalNameFor( $name, $subpage );
254 * Get a localised Title object for a specified special page name
256 * @param $name String
257 * @param $subpage String|Bool subpage string, or false to not use a subpage
258 * @return Title object
260 public static function getTitleFor( $name, $subpage = false ) {
261 $name = SpecialPageFactory
::getLocalNameFor( $name, $subpage );
263 return Title
::makeTitle( NS_SPECIAL
, $name );
265 throw new MWException( "Invalid special page name \"$name\"" );
270 * Get a localised Title object for a page name with a possibly unvalidated subpage
272 * @param $name String
273 * @param $subpage String|Bool subpage string, or false to not use a subpage
274 * @return Title object or null if the page doesn't exist
276 public static function getSafeTitleFor( $name, $subpage = false ) {
277 $name = SpecialPageFactory
::getLocalNameFor( $name, $subpage );
279 return Title
::makeTitleSafe( NS_SPECIAL
, $name );
286 * Get a title for a given alias
288 * @param $alias String
289 * @return Title or null if there is no such alias
290 * @deprecated since 1.18 call SpecialPageFactory method directly
292 static function getTitleForAlias( $alias ) {
293 return SpecialPageFactory
::getTitleForAlias( $alias );
297 * Default constructor for special pages
298 * Derivative classes should call this from their constructor
299 * Note that if the user does not have the required level, an error message will
300 * be displayed by the default execute() method, without the global function ever
303 * If you override execute(), you can recover the default behaviour with userCanExecute()
304 * and displayRestrictionError()
306 * @param $name String: name of the special page, as seen in links and URLs
307 * @param $restriction String: user right required, e.g. "block" or "delete"
308 * @param $listed Bool: whether the page is listed in Special:Specialpages
309 * @param $function Callback|Bool: function called by execute(). By default it is constructed from $name
310 * @param $file String: file which is included by execute(). It is also constructed from $name by default
311 * @param $includable Bool: whether the page can be included in normal pages
313 public function __construct(
314 $name = '', $restriction = '', $listed = true,
315 $function = false, $file = 'default', $includable = false
317 $this->init( $name, $restriction, $listed, $function, $file, $includable );
321 * Do the real work for the constructor, mainly so __call() can intercept
322 * calls to SpecialPage()
323 * @param $name String: name of the special page, as seen in links and URLs
324 * @param $restriction String: user right required, e.g. "block" or "delete"
325 * @param $listed Bool: whether the page is listed in Special:Specialpages
326 * @param $function Callback|Bool: function called by execute(). By default it is constructed from $name
327 * @param $file String: file which is included by execute(). It is also constructed from $name by default
328 * @param $includable Bool: whether the page can be included in normal pages
330 private function init( $name, $restriction, $listed, $function, $file, $includable ) {
331 $this->mName
= $name;
332 $this->mRestriction
= $restriction;
333 $this->mListed
= $listed;
334 $this->mIncludable
= $includable;
336 $this->mFunction
= 'wfSpecial'.$name;
338 $this->mFunction
= $function;
340 if ( $file === 'default' ) {
341 $this->mFile
= dirname(__FILE__
) . "/specials/Special$name.php";
343 $this->mFile
= $file;
348 * Use PHP's magic __call handler to get calls to the old PHP4 constructor
349 * because PHP E_STRICT yells at you for having __construct() and SpecialPage()
351 * @param $fName String Name of called method
352 * @param $a Array Arguments to the method
353 * @deprecated since 1.17, call parent::__construct()
355 public function __call( $fName, $a ) {
356 // Sometimes $fName is SpecialPage, sometimes it's specialpage. <3 PHP
357 if( strtolower( $fName ) == 'specialpage' ) {
358 // Deprecated messages now, remove in 1.19 or 1.20?
359 wfDeprecated( __METHOD__
);
361 $name = isset( $a[0] ) ?
$a[0] : '';
362 $restriction = isset( $a[1] ) ?
$a[1] : '';
363 $listed = isset( $a[2] ) ?
$a[2] : true;
364 $function = isset( $a[3] ) ?
$a[3] : false;
365 $file = isset( $a[4] ) ?
$a[4] : 'default';
366 $includable = isset( $a[5] ) ?
$a[5] : false;
367 $this->init( $name, $restriction, $listed, $function, $file, $includable );
369 $className = get_class( $this );
370 throw new MWException( "Call to undefined method $className::$fName" );
375 * Get the name of this Special Page.
383 * Get the permission that a user must have to execute this page
386 function getRestriction() {
387 return $this->mRestriction
;
391 * Get the file which will be included by SpecialPage::execute() if your extension is
392 * still stuck in the past and hasn't overridden the execute() method. No modern code
393 * should want or need to know this.
395 * @deprecated since 1.18
401 // @todo FIXME: Decide which syntax to use for this, and stick to it
403 * Whether this special page is listed in Special:SpecialPages
404 * @since r3583 (v1.3)
407 function isListed() {
408 return $this->mListed
;
411 * Set whether this page is listed in Special:Specialpages, at run-time
412 * @since r3583 (v1.3)
413 * @param $listed Bool
416 function setListed( $listed ) {
417 return wfSetVar( $this->mListed
, $listed );
420 * Get or set whether this special page is listed in Special:SpecialPages
421 * @since r11308 (v1.6)
425 function listed( $x = null) {
426 return wfSetVar( $this->mListed
, $x );
430 * Whether it's allowed to transclude the special page via {{Special:Foo/params}}
433 public function isIncludable(){
434 return $this->mIncludable
;
438 * These mutators are very evil, as the relevant variables should not mutate. So
442 * @deprecated since 1.18
444 function name( $x = null ) { return wfSetVar( $this->mName
, $x ); }
445 function restriction( $x = null) { return wfSetVar( $this->mRestriction
, $x ); }
446 function func( $x = null) { return wfSetVar( $this->mFunction
, $x ); }
447 function file( $x = null) { return wfSetVar( $this->mFile
, $x ); }
448 function includable( $x = null ) { return wfSetVar( $this->mIncludable
, $x ); }
451 * Whether the special page is being evaluated via transclusion
455 function including( $x = null ) {
456 return wfSetVar( $this->mIncluding
, $x );
460 * Get the localised name of the special page
462 function getLocalName() {
463 if ( !isset( $this->mLocalName
) ) {
464 $this->mLocalName
= SpecialPageFactory
::getLocalNameFor( $this->mName
);
466 return $this->mLocalName
;
470 * Is this page expensive (for some definition of expensive)?
471 * Expensive pages are disabled or cached in miser mode. Originally used
472 * (and still overridden) by QueryPage and subclasses, moved here so that
473 * Special:SpecialPages can safely call it for all special pages.
477 public function isExpensive() {
482 * Can be overridden by subclasses with more complicated permissions
485 * @return Boolean: should the page be displayed with the restricted-access
488 public function isRestricted() {
489 global $wgGroupPermissions;
490 // DWIM: If all anons can do something, then it is not restricted
491 return $this->mRestriction
!= '' && empty($wgGroupPermissions['*'][$this->mRestriction
]);
495 * Checks if the given user (identified by an object) can execute this
496 * special page (as defined by $mRestriction). Can be overridden by sub-
497 * classes with more complicated permissions schemes.
499 * @param $user User: the user to check
500 * @return Boolean: does the user have permission to view the page?
502 public function userCanExecute( User
$user ) {
503 return $user->isAllowed( $this->mRestriction
);
507 * Output an error message telling the user what access level they have to have
509 function displayRestrictionError() {
510 throw new PermissionsError( $this->mRestriction
);
514 * Checks if userCanExecute, and if not throws a PermissionsError
518 public function checkPermissions() {
519 if ( !$this->userCanExecute( $this->getUser() ) ) {
520 $this->displayRestrictionError();
525 * Sets headers - this should be called from the execute() method of all derived classes!
527 function setHeaders() {
528 $out = $this->getOutput();
529 $out->setArticleRelated( false );
530 $out->setRobotPolicy( "noindex,nofollow" );
531 $out->setPageTitle( $this->getDescription() );
535 * Default execute method
536 * Checks user permissions, calls the function given in mFunction
538 * This must be overridden by subclasses; it will be made abstract in a future version
540 * @param $par String subpage string, if one was specified
542 function execute( $par ) {
544 $this->checkPermissions();
546 $func = $this->mFunction
;
547 // only load file if the function does not exist
548 if( !is_callable($func) && $this->mFile
) {
549 require_once( $this->mFile
);
551 $this->outputHeader();
552 call_user_func( $func, $par, $this );
556 * Outputs a summary message on top of special pages
557 * Per default the message key is the canonical name of the special page
558 * May be overriden, i.e. by extensions to stick with the naming conventions
559 * for message keys: 'extensionname-xxx'
561 * @param $summaryMessageKey String: message key of the summary
563 function outputHeader( $summaryMessageKey = '' ) {
566 if( $summaryMessageKey == '' ) {
567 $msg = $wgContLang->lc( $this->getName() ) . '-summary';
569 $msg = $summaryMessageKey;
571 if ( !$this->msg( $msg )->isBlank() && !$this->including() ) {
572 $this->getOutput()->wrapWikiMsg(
573 "<div class='mw-specialpage-summary'>\n$1\n</div>", $msg );
579 * Returns the name that goes in the \<h1\> in the special page itself, and
580 * also the name that will be listed in Special:Specialpages
582 * Derived classes can override this, but usually it is easier to keep the
583 * default behaviour. Messages can be added at run-time, see
588 function getDescription() {
589 return $this->msg( strtolower( $this->mName
) )->text();
593 * Get a self-referential title object
595 * @param $subpage String|Bool
596 * @return Title object
598 function getTitle( $subpage = false ) {
599 return self
::getTitleFor( $this->mName
, $subpage );
603 * Sets the context this SpecialPage is executed in
605 * @param $context IContextSource
608 public function setContext( $context ) {
609 $this->mContext
= $context;
613 * Gets the context this SpecialPage is executed in
615 * @return IContextSource
618 public function getContext() {
619 if ( $this->mContext
instanceof IContextSource
) {
620 return $this->mContext
;
622 wfDebug( __METHOD__
. " called and \$mContext is null. Return RequestContext::getMain(); for sanity\n" );
623 return RequestContext
::getMain();
628 * Get the WebRequest being used for this instance
633 public function getRequest() {
634 return $this->getContext()->getRequest();
638 * Get the OutputPage being used for this instance
643 public function getOutput() {
644 return $this->getContext()->getOutput();
648 * Shortcut to get the User executing this instance
653 public function getUser() {
654 return $this->getContext()->getUser();
658 * Shortcut to get the skin being used for this instance
663 public function getSkin() {
664 return $this->getContext()->getSkin();
668 * Shortcut to get user's language
673 public function getLang() {
674 return $this->getContext()->getLang();
678 * Return the full title, including $par
683 public function getFullTitle() {
684 return $this->getContext()->getTitle();
688 * Wrapper around wfMessage that sets the current context.
693 public function msg( /* $args */ ) {
694 // Note: can't use func_get_args() directly as second or later item in
695 // a parameter list until PHP 5.3 or you get a fatal error.
696 // Works fine as the first parameter, which appears elsewhere in the
697 // code base. Sighhhh.
698 $args = func_get_args();
699 return call_user_func_array( array( $this->getContext(), 'msg' ), $args );
703 * Adds RSS/atom links
705 * @param $params array
707 protected function addFeedLinks( $params ) {
708 global $wgFeedClasses;
710 $feedTemplate = wfScript( 'api' ) . '?';
712 foreach( $wgFeedClasses as $format => $class ) {
713 $theseParams = $params +
array( 'feedformat' => $format );
714 $url = $feedTemplate . wfArrayToCGI( $theseParams );
715 $this->getOutput()->addFeedLink( $format, $url );
721 * Special page which uses an HTMLForm to handle processing. This is mostly a
722 * clone of FormAction. More special pages should be built this way; maybe this could be
723 * a new structure for SpecialPages
725 abstract class FormSpecialPage
extends SpecialPage
{
728 * Get an HTMLForm descriptor array
731 protected abstract function getFormFields();
734 * Add pre- or post-text to the form
735 * @return String HTML which will be sent to $form->addPreText()
737 protected function preText() { return ''; }
738 protected function postText() { return ''; }
741 * Play with the HTMLForm if you need to more substantially
742 * @param $form HTMLForm
744 protected function alterForm( HTMLForm
$form ) {}
747 * Get the HTMLForm to control behaviour
748 * @return HTMLForm|null
750 protected function getForm() {
751 $this->fields
= $this->getFormFields();
753 $form = new HTMLForm( $this->fields
, $this->getContext() );
754 $form->setSubmitCallback( array( $this, 'onSubmit' ) );
755 $form->setWrapperLegend( $this->msg( strtolower( $this->getName() ) . '-legend' ) );
756 $form->addHeaderText(
757 $this->msg( strtolower( $this->getName() ) . '-text' )->parseAsBlock() );
759 // Retain query parameters (uselang etc)
760 $params = array_diff_key(
761 $this->getRequest()->getQueryValues(), array( 'title' => null ) );
762 $form->addHiddenField( 'redirectparams', wfArrayToCGI( $params ) );
764 $form->addPreText( $this->preText() );
765 $form->addPostText( $this->postText() );
766 $this->alterForm( $form );
768 // Give hooks a chance to alter the form, adding extra fields or text etc
769 wfRunHooks( "Special{$this->getName()}BeforeFormDisplay", array( &$form ) );
775 * Process the form on POST submission.
777 * @return Bool|Array true for success, false for didn't-try, array of errors on failure
779 public abstract function onSubmit( array $data );
782 * Do something exciting on successful processing of the form, most likely to show a
783 * confirmation message
785 public abstract function onSuccess();
788 * Basic SpecialPage workflow: get a form, send it to the user; get some data back,
790 * @param $par String Subpage string if one was specified
792 public function execute( $par ) {
793 $this->setParameter( $par );
796 // This will throw exceptions if there's a problem
797 $this->checkExecutePermissions( $this->getUser() );
799 $form = $this->getForm();
800 if ( $form->show() ) {
806 * Maybe do something interesting with the subpage parameter
809 protected function setParameter( $par ){}
812 * Called from execute() to check if the given user can perform this action.
813 * Failures here must throw subclasses of ErrorPageError.
816 * @throws ErrorPageError
818 protected function checkExecutePermissions( User
$user ) {
819 if ( $this->requiresWrite() && wfReadOnly() ) {
820 throw new ReadOnlyError();
823 if ( !$this->userCanExecute( $this->getUser() ) ) {
824 throw new PermissionsError( $this->getRestriction() );
827 if ( $this->requiresUnblock() && $user->isBlocked() ) {
828 $block = $user->mBlock
;
829 throw new UserBlockedError( $block );
836 * Whether this action requires the wiki not to be locked
839 public function requiresWrite() {
844 * Whether this action cannot be executed by a blocked user
847 public function requiresUnblock() {
853 * Shortcut to construct a special page which is unlisted by default
854 * @ingroup SpecialPage
856 class UnlistedSpecialPage
extends SpecialPage
{
857 function __construct( $name, $restriction = '', $function = false, $file = 'default' ) {
858 parent
::__construct( $name, $restriction, false, $function, $file );
861 public function isListed(){
867 * Shortcut to construct an includable special page
868 * @ingroup SpecialPage
870 class IncludableSpecialPage
extends SpecialPage
{
871 function __construct(
872 $name, $restriction = '', $listed = true, $function = false, $file = 'default'
874 parent
::__construct( $name, $restriction, $listed, $function, $file, true );
877 public function isIncludable(){
883 * Shortcut to construct a special page alias.
884 * @ingroup SpecialPage
886 abstract class RedirectSpecialPage
extends UnlistedSpecialPage
{
888 // Query parameters that can be passed through redirects
889 protected $mAllowedRedirectParams = array();
891 // Query parameteres added by redirects
892 protected $mAddedRedirectParams = array();
894 public function execute( $par ){
895 $redirect = $this->getRedirect( $par );
896 $query = $this->getRedirectQuery();
897 // Redirect to a page title with possible query parameters
898 if ( $redirect instanceof Title
) {
899 $url = $redirect->getFullUrl( $query );
900 $this->getOutput()->redirect( $url );
901 wfProfileOut( __METHOD__
);
903 // Redirect to index.php with query parameters
904 } elseif ( $redirect === true ) {
906 $url = $wgScript . '?' . wfArrayToCGI( $query );
907 $this->getOutput()->redirect( $url );
908 wfProfileOut( __METHOD__
);
912 throw new MWException( "RedirectSpecialPage $class doesn't redirect!" );
917 * If the special page is a redirect, then get the Title object it redirects to.
920 * @param $par String Subpage string
921 * @return Title|false
923 abstract public function getRedirect( $par );
926 * Return part of the request string for a special redirect page
927 * This allows passing, e.g. action=history to Special:Mypage, etc.
931 public function getRedirectQuery() {
934 foreach( $this->mAllowedRedirectParams
as $arg ) {
935 if( $this->getRequest()->getVal( $arg, null ) !== null ){
936 $params[$arg] = $this->getRequest()->getVal( $arg );
940 foreach( $this->mAddedRedirectParams
as $arg => $val ) {
941 $params[$arg] = $val;
944 return count( $params )
950 abstract class SpecialRedirectToSpecial
extends RedirectSpecialPage
{
951 var $redirName, $redirSubpage;
953 function __construct(
954 $name, $redirName, $redirSubpage = false,
955 $allowedRedirectParams = array(), $addedRedirectParams = array()
957 parent
::__construct( $name );
958 $this->redirName
= $redirName;
959 $this->redirSubpage
= $redirSubpage;
960 $this->mAllowedRedirectParams
= $allowedRedirectParams;
961 $this->mAddedRedirectParams
= $addedRedirectParams;
964 public function getRedirect( $subpage ) {
965 if ( $this->redirSubpage
=== false ) {
966 return SpecialPage
::getTitleFor( $this->redirName
, $subpage );
968 return SpecialPage
::getTitleFor( $this->redirName
, $this->redirSubpage
);
974 * ListAdmins --> ListUsers/sysop
976 class SpecialListAdmins
extends SpecialRedirectToSpecial
{
977 function __construct(){
978 parent
::__construct( 'Listadmins', 'Listusers', 'sysop' );
983 * ListBots --> ListUsers/bot
985 class SpecialListBots
extends SpecialRedirectToSpecial
{
986 function __construct(){
987 parent
::__construct( 'Listbots', 'Listusers', 'bot' );
992 * CreateAccount --> UserLogin/signup
993 * @todo FIXME: This (and the rest of the login frontend) needs to die a horrible painful death
995 class SpecialCreateAccount
extends SpecialRedirectToSpecial
{
996 function __construct(){
997 parent
::__construct( 'CreateAccount', 'Userlogin', 'signup', array( 'uselang' ) );
1001 * SpecialMypage, SpecialMytalk and SpecialMycontributions special pages
1002 * are used to get user independant links pointing to the user page, talk
1003 * page and list of contributions.
1004 * This can let us cache a single copy of any generated content for all
1009 * Shortcut to construct a special page pointing to current user user's page.
1010 * @ingroup SpecialPage
1012 class SpecialMypage
extends RedirectSpecialPage
{
1013 function __construct() {
1014 parent
::__construct( 'Mypage' );
1015 $this->mAllowedRedirectParams
= array( 'action' , 'preload' , 'editintro',
1016 'section', 'oldid', 'diff', 'dir',
1017 // Options for action=raw; missing ctype can break JS or CSS in some browsers
1018 'ctype', 'maxage', 'smaxage' );
1021 function getRedirect( $subpage ) {
1022 if ( strval( $subpage ) !== '' ) {
1023 return Title
::makeTitle( NS_USER
, $this->getUser()->getName() . '/' . $subpage );
1025 return Title
::makeTitle( NS_USER
, $this->getUser()->getName() );
1031 * Shortcut to construct a special page pointing to current user talk page.
1032 * @ingroup SpecialPage
1034 class SpecialMytalk
extends RedirectSpecialPage
{
1035 function __construct() {
1036 parent
::__construct( 'Mytalk' );
1037 $this->mAllowedRedirectParams
= array( 'action' , 'preload' , 'editintro',
1038 'section', 'oldid', 'diff', 'dir' );
1041 function getRedirect( $subpage ) {
1042 if ( strval( $subpage ) !== '' ) {
1043 return Title
::makeTitle( NS_USER_TALK
, $this->getUser()->getName() . '/' . $subpage );
1045 return Title
::makeTitle( NS_USER_TALK
, $this->getUser()->getName() );
1051 * Shortcut to construct a special page pointing to current user contributions.
1052 * @ingroup SpecialPage
1054 class SpecialMycontributions
extends RedirectSpecialPage
{
1055 function __construct() {
1056 parent
::__construct( 'Mycontributions' );
1057 $this->mAllowedRedirectParams
= array( 'limit', 'namespace', 'tagfilter',
1058 'offset', 'dir', 'year', 'month', 'feed' );
1061 function getRedirect( $subpage ) {
1062 return SpecialPage
::getTitleFor( 'Contributions', $this->getUser()->getName() );
1067 * Redirect to Special:Listfiles?user=$wgUser
1069 class SpecialMyuploads
extends RedirectSpecialPage
{
1070 function __construct() {
1071 parent
::__construct( 'Myuploads' );
1072 $this->mAllowedRedirectParams
= array( 'limit' );
1075 function getRedirect( $subpage ) {
1076 return SpecialPage
::getTitleFor( 'Listfiles', $this->getUser()->getName() );
1081 * Redirect from Special:PermanentLink/### to index.php?oldid=###
1083 class SpecialPermanentLink
extends RedirectSpecialPage
{
1084 function __construct() {
1085 parent
::__construct( 'PermanentLink' );
1086 $this->mAllowedRedirectParams
= array();
1089 function getRedirect( $subpage ) {
1090 $subpage = intval( $subpage );
1091 if( $subpage === 0 ) {
1092 # throw an error page when no subpage was given
1093 throw new ErrorPageError( 'nopagetitle', 'nopagetext' );
1095 $this->mAddedRedirectParams
['oldid'] = $subpage;