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.
20 * @addtogroup SpecialPage
24 * Parent special page class, also static functions for handling the special
26 * @addtogroup SpecialPage
34 * The canonical name of this special page
35 * Also used for the default <h1> heading, @see getDescription()
39 * The local name of this special page
43 * Minimum user level required to access this page, or "" for anyone.
44 * Also used to categorise the pages in Special:Specialpages
48 * Listed in Special:Specialpages?
52 * Function name called by the default execute()
56 * File which needs to be included before the function above can be called
60 * Whether or not this special page is being included from an article
64 * Whether the special page can be included in an article
68 * Query parameters that can be passed through redirects
70 var $mAllowedRedirectParams = array();
72 * List of special pages, followed by parameters.
73 * If the only parameter is a string, that is the page name.
74 * Otherwise, it is an array. The format is one of:
75 ** array( 'SpecialPage', name, right )
76 ** array( 'IncludableSpecialPage', name, right, listed? )
77 ** array( 'UnlistedSpecialPage', name, right )
78 ** array( 'SpecialRedirectToSpecial', name, page to redirect to, special page param, ... )
80 static public $mList = array(
81 'DoubleRedirects' => array( 'SpecialPage', 'DoubleRedirects' ),
82 'BrokenRedirects' => array( 'SpecialPage', 'BrokenRedirects' ),
83 'Disambiguations' => array( 'SpecialPage', 'Disambiguations' ),
85 'Userlogin' => array( 'SpecialPage', 'Userlogin' ),
86 'Userlogout' => array( 'UnlistedSpecialPage', 'Userlogout' ),
87 'CreateAccount' => array( 'SpecialRedirectToSpecial', 'CreateAccount', 'Userlogin', 'signup', array( 'uselang' ) ),
88 'Preferences' => array( 'SpecialPage', 'Preferences' ),
89 'Watchlist' => array( 'SpecialPage', 'Watchlist' ),
91 'Recentchanges' => array( 'IncludableSpecialPage', 'Recentchanges' ),
92 'Upload' => array( 'SpecialPage', 'Upload' ),
93 'Imagelist' => array( 'SpecialPage', 'Imagelist' ),
94 'Newimages' => array( 'IncludableSpecialPage', 'Newimages' ),
95 'Listusers' => array( 'SpecialPage', 'Listusers' ),
96 'Listgrouprights' => 'SpecialListGroupRights',
97 'Statistics' => array( 'SpecialPage', 'Statistics' ),
98 'Randompage' => 'Randompage',
99 'Lonelypages' => array( 'SpecialPage', 'Lonelypages' ),
100 'Uncategorizedpages' => array( 'SpecialPage', 'Uncategorizedpages' ),
101 'Uncategorizedcategories' => array( 'SpecialPage', 'Uncategorizedcategories' ),
102 'Uncategorizedimages' => array( 'SpecialPage', 'Uncategorizedimages' ),
103 'Uncategorizedtemplates' => array( 'SpecialPage', 'Uncategorizedtemplates' ),
104 'Unusedcategories' => array( 'SpecialPage', 'Unusedcategories' ),
105 'Unusedimages' => array( 'SpecialPage', 'Unusedimages' ),
106 'Wantedpages' => array( 'IncludableSpecialPage', 'Wantedpages' ),
107 'Wantedcategories' => array( 'SpecialPage', 'Wantedcategories' ),
108 'Mostlinked' => array( 'SpecialPage', 'Mostlinked' ),
109 'Mostlinkedcategories' => array( 'SpecialPage', 'Mostlinkedcategories' ),
110 'Mostlinkedtemplates' => array( 'SpecialPage', 'Mostlinkedtemplates' ),
111 'Mostcategories' => array( 'SpecialPage', 'Mostcategories' ),
112 'Mostimages' => array( 'SpecialPage', 'Mostimages' ),
113 'Mostrevisions' => array( 'SpecialPage', 'Mostrevisions' ),
114 'Fewestrevisions' => array( 'SpecialPage', 'Fewestrevisions' ),
115 'Shortpages' => array( 'SpecialPage', 'Shortpages' ),
116 'Longpages' => array( 'SpecialPage', 'Longpages' ),
117 'Newpages' => array( 'IncludableSpecialPage', 'Newpages' ),
118 'Ancientpages' => array( 'SpecialPage', 'Ancientpages' ),
119 'Deadendpages' => array( 'SpecialPage', 'Deadendpages' ),
120 'Protectedpages' => array( 'SpecialPage', 'Protectedpages' ),
121 'Protectedtitles' => array( 'SpecialPage', 'Protectedtitles' ),
122 'Allpages' => array( 'IncludableSpecialPage', 'Allpages' ),
123 'Prefixindex' => array( 'IncludableSpecialPage', 'Prefixindex' ) ,
124 'Ipblocklist' => array( 'SpecialPage', 'Ipblocklist' ),
125 'Specialpages' => array( 'UnlistedSpecialPage', 'Specialpages' ),
126 'Contributions' => array( 'SpecialPage', 'Contributions' ),
127 'Emailuser' => array( 'UnlistedSpecialPage', 'Emailuser' ),
128 'Whatlinkshere' => array( 'SpecialPage', 'Whatlinkshere' ),
129 'Recentchangeslinked' => array( 'SpecialPage', 'Recentchangeslinked' ),
130 'Movepage' => array( 'UnlistedSpecialPage', 'Movepage' ),
131 'Blockme' => array( 'UnlistedSpecialPage', 'Blockme' ),
132 'Resetpass' => array( 'UnlistedSpecialPage', 'Resetpass' ),
133 'Booksources' => 'SpecialBookSources',
134 'Categories' => array( 'SpecialPage', 'Categories' ),
135 'Export' => array( 'SpecialPage', 'Export' ),
136 'Version' => array( 'SpecialPage', 'Version' ),
137 'Allmessages' => array( 'SpecialPage', 'Allmessages' ),
138 'Log' => array( 'SpecialPage', 'Log' ),
139 'Blockip' => array( 'SpecialPage', 'Blockip', 'block' ),
140 'Undelete' => array( 'SpecialPage', 'Undelete', 'deletedhistory' ),
141 'Import' => array( 'SpecialPage', 'Import', 'import' ),
142 'Lockdb' => array( 'SpecialPage', 'Lockdb', 'siteadmin' ),
143 'Unlockdb' => array( 'SpecialPage', 'Unlockdb', 'siteadmin' ),
144 'Userrights' => 'UserrightsPage',
145 'MIMEsearch' => array( 'SpecialPage', 'MIMEsearch' ),
146 'FileDuplicateSearch' => array( 'SpecialPage', 'FileDuplicateSearch' ),
147 'Unwatchedpages' => array( 'SpecialPage', 'Unwatchedpages', 'unwatchedpages' ),
148 'Listredirects' => array( 'SpecialPage', 'Listredirects' ),
149 'Revisiondelete' => array( 'UnlistedSpecialPage', 'Revisiondelete', 'deleterevision' ),
150 'Unusedtemplates' => array( 'SpecialPage', 'Unusedtemplates' ),
151 'Randomredirect' => 'SpecialRandomredirect',
152 'Withoutinterwiki' => array( 'SpecialPage', 'Withoutinterwiki' ),
153 'Filepath' => array( 'SpecialPage', 'Filepath' ),
155 'Mypage' => array( 'SpecialMypage' ),
156 'Mytalk' => array( 'SpecialMytalk' ),
157 'Mycontributions' => array( 'SpecialMycontributions' ),
158 'Listadmins' => array( 'SpecialRedirectToSpecial', 'Listadmins', 'Listusers', 'sysop' ),
159 'MergeHistory' => array( 'SpecialPage', 'MergeHistory', 'mergehistory' ),
160 'Listbots' => array( 'SpecialRedirectToSpecial', 'Listbots', 'Listusers', 'bot' ),
163 static public $mAliases;
164 static public $mListInitialised = false;
169 * Initialise the special page list
170 * This must be called before accessing SpecialPage::$mList
172 static function initList() {
173 global $wgSpecialPages;
174 global $wgDisableCounters, $wgDisableInternalSearch, $wgEmailAuthentication;
176 if ( self
::$mListInitialised ) {
179 wfProfileIn( __METHOD__
);
181 # Better to set this now, to avoid infinite recursion in carelessly written hooks
182 self
::$mListInitialised = true;
184 if( !$wgDisableCounters ) {
185 self
::$mList['Popularpages'] = array( 'SpecialPage', 'Popularpages' );
188 if( !$wgDisableInternalSearch ) {
189 self
::$mList['Search'] = array( 'SpecialPage', 'Search' );
192 if( $wgEmailAuthentication ) {
193 self
::$mList['Confirmemail'] = 'EmailConfirmation';
194 self
::$mList['Invalidateemail'] = 'EmailInvalidation';
197 # Add extension special pages
198 self
::$mList = array_merge( self
::$mList, $wgSpecialPages );
201 # This hook can be used to remove undesired built-in special pages
202 wfRunHooks( 'SpecialPage_initList', array( &self
::$mList ) );
203 wfProfileOut( __METHOD__
);
206 static function initAliasList() {
207 if ( !is_null( self
::$mAliases ) ) {
212 $aliases = $wgContLang->getSpecialPageAliases();
213 $missingPages = self
::$mList;
214 self
::$mAliases = array();
215 foreach ( $aliases as $realName => $aliasList ) {
216 foreach ( $aliasList as $alias ) {
217 self
::$mAliases[$wgContLang->caseFold( $alias )] = $realName;
219 unset( $missingPages[$realName] );
221 foreach ( $missingPages as $name => $stuff ) {
222 self
::$mAliases[$wgContLang->caseFold( $name )] = $name;
227 * Given a special page alias, return the special page name.
228 * Returns false if there is no such alias.
230 static function resolveAlias( $alias ) {
233 if ( !self
::$mListInitialised ) self
::initList();
234 if ( is_null( self
::$mAliases ) ) self
::initAliasList();
235 $caseFoldedAlias = $wgContLang->caseFold( $alias );
236 if ( isset( self
::$mAliases[$caseFoldedAlias] ) ) {
237 return self
::$mAliases[$caseFoldedAlias];
244 * Given a special page name with a possible subpage, return an array
245 * where the first element is the special page name and the second is the
248 static function resolveAliasWithSubpage( $alias ) {
249 $bits = explode( '/', $alias, 2 );
250 $name = self
::resolveAlias( $bits[0] );
251 if( !isset( $bits[1] ) ) { // bug 2087
256 return array( $name, $par );
260 * Add a page to the list of valid special pages. This used to be the preferred
261 * method for adding special pages in extensions. It's now suggested that you add
262 * an associative record to $wgSpecialPages. This avoids autoloading SpecialPage.
264 * @param SpecialPage $page
267 static function addPage( &$page ) {
268 if ( !self
::$mListInitialised ) {
271 self
::$mList[$page->mName
] = $page;
275 * Add a page to a certain display group for Special:SpecialPages
277 * @param mixed $page (SpecialPage or string)
278 * @param string $group
281 static function setGroup( $page, $group ) {
282 global $wgSpecialPageGroups;
283 $name = is_object($page) ?
$page->mName
: $page;
284 $wgSpecialPageGroups[$name] = $group;
288 * Add a page to a certain display group for Special:SpecialPages
290 * @param SpecialPage $page
293 static function getGroup( &$page ) {
294 global $wgSpecialPageGroups;
295 $group = isset($wgSpecialPageGroups[$page->mName
]) ?
296 $wgSpecialPageGroups[$page->mName
] : 'other';
301 * Remove a special page from the list
302 * Formerly used to disable expensive or dangerous special pages. The
303 * preferred method is now to add a SpecialPage_initList hook.
307 static function removePage( $name ) {
308 if ( !self
::$mListInitialised ) {
311 unset( self
::$mList[$name] );
315 * Check if a given name exist as a special page or as a special page alias
316 * @param $name string: name of a special page
317 * @return boolean: true if a special page exists with this name
319 static function exists( $name ) {
321 if ( !self
::$mListInitialised ) {
324 if( !self
::$mAliases ) {
325 self
::initAliasList();
328 # Remove special pages inline parameters:
329 $bits = explode( '/', $name );
330 $name = $wgContLang->caseFold($bits[0]);
333 array_key_exists( $name, self
::$mList )
334 or array_key_exists( $name, self
::$mAliases )
339 * Find the object with a given name and return it (or NULL)
341 * @param string $name
343 static function getPage( $name ) {
344 if ( !self
::$mListInitialised ) {
347 if ( array_key_exists( $name, self
::$mList ) ) {
348 $rec = self
::$mList[$name];
349 if ( is_string( $rec ) ) {
351 self
::$mList[$name] = new $className;
352 } elseif ( is_array( $rec ) ) {
353 $className = array_shift( $rec );
354 self
::$mList[$name] = wfCreateObject( $className, $rec );
356 return self
::$mList[$name];
363 * Get a special page with a given localised name, or NULL if there
364 * is no such special page.
366 static function getPageByAlias( $alias ) {
367 $realName = self
::resolveAlias( $alias );
369 return self
::getPage( $realName );
376 * Return categorised listable special pages for all users
379 static function getRegularPages() {
380 if ( !self
::$mListInitialised ) {
385 foreach ( self
::$mList as $name => $rec ) {
386 $page = self
::getPage( $name );
387 if ( $page->isListed() && !$page->isRestricted() ) {
388 $pages[$name] = $page;
395 * Return categorised listable special pages which are available
396 * for the current user, but not for everyone
399 static function getRestrictedPages() {
401 if ( !self
::$mListInitialised ) {
406 foreach ( self
::$mList as $name => $rec ) {
407 $page = self
::getPage( $name );
410 and $page->isRestricted()
411 and $page->userCanExecute( $wgUser )
413 $pages[$name] = $page;
420 * Execute a special page path.
421 * The path may contain parameters, e.g. Special:Name/Params
422 * Extracts the special page name and call the execute method, passing the parameters
424 * Returns a title object if the page is redirected, false if there was no such special
425 * page, and true if it was successful.
427 * @param $title a title object
428 * @param $including output is being captured for use in {{special:whatever}}
430 static function executePath( &$title, $including = false ) {
431 global $wgOut, $wgTitle, $wgRequest;
432 wfProfileIn( __METHOD__
);
434 # FIXME: redirects broken due to this call
435 $bits = explode( '/', $title->getDBkey(), 2 );
437 if( !isset( $bits[1] ) ) { // bug 2087
442 $page = SpecialPage
::getPageByAlias( $name );
446 $wgOut->setArticleRelated( false );
447 $wgOut->setRobotpolicy( 'noindex,nofollow' );
448 $wgOut->setStatusCode( 404 );
449 $wgOut->showErrorPage( 'nosuchspecialpage', 'nospecialpagetext' );
451 wfProfileOut( __METHOD__
);
457 $redirect = $page->getRedirect( $par );
459 $query = $page->getRedirectQuery();
460 $url = $redirect->getFullUrl( $query );
461 $wgOut->redirect( $url );
462 wfProfileOut( __METHOD__
);
467 # Redirect to canonical alias for GET commands
468 # Not for POST, we'd lose the post data, so it's best to just distribute
469 # the request. Such POST requests are possible for old extensions that
470 # generate self-links without being aware that their default name has
472 if ( !$including && $name != $page->getLocalName() && !$wgRequest->wasPosted() ) {
474 unset( $query['title'] );
475 $query = wfArrayToCGI( $query );
476 $title = $page->getTitle( $par );
477 $url = $title->getFullUrl( $query );
478 $wgOut->redirect( $url );
479 wfProfileOut( __METHOD__
);
483 if ( $including && !$page->includable() ) {
484 wfProfileOut( __METHOD__
);
486 } elseif ( !$including ) {
487 $wgTitle = $page->getTitle();
489 $page->including( $including );
491 // Execute special page
492 $profName = 'Special:' . $page->getName();
493 wfProfileIn( $profName );
494 $page->execute( $par );
495 wfProfileOut( $profName );
496 wfProfileOut( __METHOD__
);
501 * Just like executePath() except it returns the HTML instead of outputting it
502 * Returns false if there was no such special page, or a title object if it was
506 static function capturePath( &$title ) {
507 global $wgOut, $wgTitle;
509 $oldTitle = $wgTitle;
511 $wgOut = new OutputPage
;
513 $ret = SpecialPage
::executePath( $title, true );
514 if ( $ret === true ) {
515 $ret = $wgOut->getHTML();
517 $wgTitle = $oldTitle;
523 * Get the local name for a specified canonical name
526 * @param mixed $subpage Boolean false, or string
530 static function getLocalNameFor( $name, $subpage = false ) {
532 $aliases = $wgContLang->getSpecialPageAliases();
533 if ( isset( $aliases[$name][0] ) ) {
534 $name = $aliases[$name][0];
536 if ( $subpage !== false && !is_null( $subpage ) ) {
537 $name = "$name/$subpage";
543 * Get a localised Title object for a specified special page name
545 static function getTitleFor( $name, $subpage = false ) {
546 $name = self
::getLocalNameFor( $name, $subpage );
548 return Title
::makeTitle( NS_SPECIAL
, $name );
550 throw new MWException( "Invalid special page name \"$name\"" );
555 * Get a localised Title object for a page name with a possibly unvalidated subpage
557 static function getSafeTitleFor( $name, $subpage = false ) {
558 $name = self
::getLocalNameFor( $name, $subpage );
560 return Title
::makeTitleSafe( NS_SPECIAL
, $name );
567 * Get a title for a given alias
568 * @return Title or null if there is no such alias
570 static function getTitleForAlias( $alias ) {
571 $name = self
::resolveAlias( $alias );
573 return self
::getTitleFor( $name );
580 * Default constructor for special pages
581 * Derivative classes should call this from their constructor
582 * Note that if the user does not have the required level, an error message will
583 * be displayed by the default execute() method, without the global function ever
586 * If you override execute(), you can recover the default behaviour with userCanExecute()
587 * and displayRestrictionError()
589 * @param string $name Name of the special page, as seen in links and URLs
590 * @param string $restriction User right required, e.g. "block" or "delete"
591 * @param boolean $listed Whether the page is listed in Special:Specialpages
592 * @param string $function Function called by execute(). By default it is constructed from $name
593 * @param string $file File which is included by execute(). It is also constructed from $name by default
595 function SpecialPage( $name = '', $restriction = '', $listed = true, $function = false, $file = 'default', $includable = false ) {
596 $this->mName
= $name;
597 $this->mRestriction
= $restriction;
598 $this->mListed
= $listed;
599 $this->mIncludable
= $includable;
600 if ( $function == false ) {
601 $this->mFunction
= 'wfSpecial'.$name;
603 $this->mFunction
= $function;
605 if ( $file === 'default' ) {
606 $this->mFile
= dirname(__FILE__
) . "/Special{$name}.php";
608 $this->mFile
= $file;
617 function getName() { return $this->mName
; }
618 function getRestriction() { return $this->mRestriction
; }
619 function getFile() { return $this->mFile
; }
620 function isListed() { return $this->mListed
; }
624 * Accessor and mutator
626 function name( $x = NULL ) { return wfSetVar( $this->mName
, $x ); }
627 function restrictions( $x = NULL) { return wfSetVar( $this->mRestrictions
, $x ); }
628 function listed( $x = NULL) { return wfSetVar( $this->mListed
, $x ); }
629 function func( $x = NULL) { return wfSetVar( $this->mFunction
, $x ); }
630 function file( $x = NULL) { return wfSetVar( $this->mFile
, $x ); }
631 function includable( $x = NULL ) { return wfSetVar( $this->mIncludable
, $x ); }
632 function including( $x = NULL ) { return wfSetVar( $this->mIncluding
, $x ); }
636 * Get the localised name of the special page
638 function getLocalName() {
639 if ( !isset( $this->mLocalName
) ) {
640 $this->mLocalName
= self
::getLocalNameFor( $this->mName
);
642 return $this->mLocalName
;
646 * Can be overridden by subclasses with more complicated permissions
649 * @return bool Should the page be displayed with the restricted-access
652 public function isRestricted() {
653 return $this->mRestriction
!= '';
657 * Checks if the given user (identified by an object) can execute this
658 * special page (as defined by $mRestriction). Can be overridden by sub-
659 * classes with more complicated permissions schemes.
661 * @param User $user The user to check
662 * @return bool Does the user have permission to view the page?
664 public function userCanExecute( $user ) {
665 return $user->isAllowed( $this->mRestriction
);
669 * Output an error message telling the user what access level they have to have
671 function displayRestrictionError() {
673 $wgOut->permissionRequired( $this->mRestriction
);
677 * Sets headers - this should be called from the execute() method of all derived classes!
679 function setHeaders() {
681 $wgOut->setArticleRelated( false );
682 $wgOut->setRobotPolicy( "noindex,nofollow" );
683 $wgOut->setPageTitle( $this->getDescription() );
687 * Default execute method
688 * Checks user permissions, calls the function given in mFunction
690 * This may be overridden by subclasses.
692 function execute( $par ) {
697 if ( $this->userCanExecute( $wgUser ) ) {
698 $func = $this->mFunction
;
699 // only load file if the function does not exist
700 if(!is_callable($func) and $this->mFile
) {
701 require_once( $this->mFile
);
703 # FIXME: these hooks are broken for extensions and anything else that subclasses SpecialPage.
704 if ( wfRunHooks( 'SpecialPageExecuteBeforeHeader', array( &$this, &$par, &$func ) ) )
705 $this->outputHeader();
706 if ( ! wfRunHooks( 'SpecialPageExecuteBeforePage', array( &$this, &$par, &$func ) ) )
708 call_user_func( $func, $par, $this );
709 if ( ! wfRunHooks( 'SpecialPageExecuteAfterPage', array( &$this, &$par, &$func ) ) )
712 $this->displayRestrictionError();
716 function outputHeader() {
717 global $wgOut, $wgContLang;
719 $msg = $wgContLang->lc( $this->name() ) . '-summary';
720 $out = wfMsgNoTrans( $msg );
721 if ( ! wfEmptyMsg( $msg, $out ) and $out !== '' and ! $this->including() ) {
722 $wgOut->addWikiMsg( $msg );
727 # Returns the name that goes in the <h1> in the special page itself, and also the name that
728 # will be listed in Special:Specialpages
730 # Derived classes can override this, but usually it is easier to keep the default behaviour.
731 # Messages can be added at run-time, see MessageCache.php
732 function getDescription() {
733 return wfMsg( strtolower( $this->mName
) );
737 * Get a self-referential title object
739 function getTitle( $subpage = false) {
740 return self
::getTitleFor( $this->mName
, $subpage );
744 * Set whether this page is listed in Special:Specialpages, at run-time
746 function setListed( $listed ) {
747 return wfSetVar( $this->mListed
, $listed );
751 * If the special page is a redirect, then get the Title object it redirects to.
754 function getRedirect( $subpage ) {
759 * Return part of the request string for a special redirect page
760 * This allows passing, e.g. action=history to Special:Mypage, etc.
764 function getRedirectQuery() {
767 foreach( $this->mAllowedRedirectParams
as $arg ) {
768 if( $val = $wgRequest->getVal( $arg, false ) )
769 $params[] = $arg . '=' . $val;
772 return count( $params ) ?
implode( '&', $params ) : false;
777 * Shortcut to construct a special page which is unlisted by default
778 * @addtogroup SpecialPage
780 class UnlistedSpecialPage
extends SpecialPage
782 function UnlistedSpecialPage( $name, $restriction = '', $function = false, $file = 'default' ) {
783 SpecialPage
::SpecialPage( $name, $restriction, false, $function, $file );
788 * Shortcut to construct an includable special page
789 * @addtogroup SpecialPage
791 class IncludableSpecialPage
extends SpecialPage
793 function IncludableSpecialPage( $name, $restriction = '', $listed = true, $function = false, $file = 'default' ) {
794 SpecialPage
::SpecialPage( $name, $restriction, $listed, $function, $file, true );
799 * Shortcut to construct a special page alias.
800 * @addtogroup SpecialPage
802 class SpecialRedirectToSpecial
extends UnlistedSpecialPage
{
803 var $redirName, $redirSubpage;
805 function __construct( $name, $redirName, $redirSubpage = false, $redirectParams = array() ) {
806 parent
::__construct( $name );
807 $this->redirName
= $redirName;
808 $this->redirSubpage
= $redirSubpage;
809 $this->mAllowedRedirectParams
= $redirectParams;
812 function getRedirect( $subpage ) {
813 if ( $this->redirSubpage
=== false ) {
814 return SpecialPage
::getTitleFor( $this->redirName
, $subpage );
816 return SpecialPage
::getTitleFor( $this->redirName
, $this->redirSubpage
);
821 /** SpecialMypage, SpecialMytalk and SpecialMycontributions special pages
822 * are used to get user independant links pointing to the user page, talk
823 * page and list of contributions.
824 * This can let us cache a single copy of any generated content for all
829 * Shortcut to construct a special page pointing to current user user's page.
830 * @addtogroup SpecialPage
832 class SpecialMypage
extends UnlistedSpecialPage
{
833 function __construct() {
834 parent
::__construct( 'Mypage' );
835 $this->mAllowedRedirectParams
= array( 'action' , 'preload' , 'editintro', 'section' );
838 function getRedirect( $subpage ) {
840 if ( strval( $subpage ) !== '' ) {
841 return Title
::makeTitle( NS_USER
, $wgUser->getName() . '/' . $subpage );
843 return Title
::makeTitle( NS_USER
, $wgUser->getName() );
849 * Shortcut to construct a special page pointing to current user talk page.
850 * @addtogroup SpecialPage
852 class SpecialMytalk
extends UnlistedSpecialPage
{
853 function __construct() {
854 parent
::__construct( 'Mytalk' );
855 $this->mAllowedRedirectParams
= array( 'action' , 'preload' , 'editintro', 'section' );
858 function getRedirect( $subpage ) {
860 if ( strval( $subpage ) !== '' ) {
861 return Title
::makeTitle( NS_USER_TALK
, $wgUser->getName() . '/' . $subpage );
863 return Title
::makeTitle( NS_USER_TALK
, $wgUser->getName() );
869 * Shortcut to construct a special page pointing to current user contributions.
870 * @addtogroup SpecialPage
872 class SpecialMycontributions
extends UnlistedSpecialPage
{
873 function __construct() {
874 parent
::__construct( 'Mycontributions' );
877 function getRedirect( $subpage ) {
879 return SpecialPage
::getTitleFor( 'Contributions', $wgUser->getName() );