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
36 * The canonical name of this special page
37 * Also used for the default <h1> heading, @see getDescription()
41 * The local name of this special page
45 * Minimum user level required to access this page, or "" for anyone.
46 * Also used to categorise the pages in Special:Specialpages
50 * Listed in Special:Specialpages?
54 * Function name called by the default execute()
58 * File which needs to be included before the function above can be called
62 * Whether or not this special page is being included from an article
66 * Whether the special page can be included in an article
70 * Query parameters that can be passed through redirects
72 var $mAllowedRedirectParams = array();
74 * List of special pages, followed by parameters.
75 * If the only parameter is a string, that is the page name.
76 * Otherwise, it is an array. The format is one of:
77 ** array( 'SpecialPage', name, right )
78 ** array( 'IncludableSpecialPage', name, right, listed? )
79 ** array( 'UnlistedSpecialPage', name, right )
80 ** array( 'SpecialRedirectToSpecial', name, page to redirect to, special page param, ... )
82 static public $mList = array(
83 'DoubleRedirects' => array( 'SpecialPage', 'DoubleRedirects' ),
84 'BrokenRedirects' => array( 'SpecialPage', 'BrokenRedirects' ),
85 'Disambiguations' => array( 'SpecialPage', 'Disambiguations' ),
87 'Userlogin' => array( 'SpecialPage', 'Userlogin' ),
88 'Userlogout' => array( 'UnlistedSpecialPage', 'Userlogout' ),
89 'CreateAccount' => array( 'SpecialRedirectToSpecial', 'CreateAccount', 'Userlogin', 'signup', array( 'uselang' ) ),
90 'Preferences' => array( 'SpecialPage', 'Preferences' ),
91 'Watchlist' => array( 'SpecialPage', 'Watchlist' ),
93 'Recentchanges' => array( 'IncludableSpecialPage', 'Recentchanges' ),
94 'Upload' => array( 'SpecialPage', 'Upload' ),
95 'Imagelist' => array( 'SpecialPage', 'Imagelist' ),
96 'Newimages' => array( 'IncludableSpecialPage', 'Newimages' ),
97 'Listusers' => array( 'SpecialPage', 'Listusers' ),
98 'Listgrouprights' => 'SpecialListGroupRights',
99 'Statistics' => array( 'SpecialPage', 'Statistics' ),
100 'Randompage' => 'Randompage',
101 'Lonelypages' => array( 'SpecialPage', 'Lonelypages' ),
102 'Uncategorizedpages' => array( 'SpecialPage', 'Uncategorizedpages' ),
103 'Uncategorizedcategories' => array( 'SpecialPage', 'Uncategorizedcategories' ),
104 'Uncategorizedimages' => array( 'SpecialPage', 'Uncategorizedimages' ),
105 'Uncategorizedtemplates' => array( 'SpecialPage', 'Uncategorizedtemplates' ),
106 'Unusedcategories' => array( 'SpecialPage', 'Unusedcategories' ),
107 'Unusedimages' => array( 'SpecialPage', 'Unusedimages' ),
108 'Wantedpages' => array( 'IncludableSpecialPage', 'Wantedpages' ),
109 'Wantedcategories' => array( 'SpecialPage', 'Wantedcategories' ),
110 'Mostlinked' => array( 'SpecialPage', 'Mostlinked' ),
111 'Mostlinkedcategories' => array( 'SpecialPage', 'Mostlinkedcategories' ),
112 'Mostlinkedtemplates' => array( 'SpecialPage', 'Mostlinkedtemplates' ),
113 'Mostcategories' => array( 'SpecialPage', 'Mostcategories' ),
114 'Mostimages' => array( 'SpecialPage', 'Mostimages' ),
115 'Mostrevisions' => array( 'SpecialPage', 'Mostrevisions' ),
116 'Fewestrevisions' => array( 'SpecialPage', 'Fewestrevisions' ),
117 'Shortpages' => array( 'SpecialPage', 'Shortpages' ),
118 'Longpages' => array( 'SpecialPage', 'Longpages' ),
119 'Newpages' => array( 'IncludableSpecialPage', 'Newpages' ),
120 'Ancientpages' => array( 'SpecialPage', 'Ancientpages' ),
121 'Deadendpages' => array( 'SpecialPage', 'Deadendpages' ),
122 'Protectedpages' => array( 'SpecialPage', 'Protectedpages' ),
123 'Protectedtitles' => array( 'SpecialPage', 'Protectedtitles' ),
124 'Allpages' => array( 'IncludableSpecialPage', 'Allpages' ),
125 'Prefixindex' => array( 'IncludableSpecialPage', 'Prefixindex' ) ,
126 'Ipblocklist' => array( 'SpecialPage', 'Ipblocklist' ),
127 'Specialpages' => array( 'UnlistedSpecialPage', 'Specialpages' ),
128 'Contributions' => array( 'SpecialPage', 'Contributions' ),
129 'Emailuser' => array( 'UnlistedSpecialPage', 'Emailuser' ),
130 'Whatlinkshere' => array( 'SpecialPage', 'Whatlinkshere' ),
131 'Recentchangeslinked' => array( 'SpecialPage', 'Recentchangeslinked' ),
132 'Movepage' => array( 'UnlistedSpecialPage', 'Movepage' ),
133 'Blockme' => array( 'UnlistedSpecialPage', 'Blockme' ),
134 'Resetpass' => array( 'UnlistedSpecialPage', 'Resetpass' ),
135 'Booksources' => 'SpecialBookSources',
136 'Categories' => array( 'SpecialPage', 'Categories' ),
137 'Export' => array( 'SpecialPage', 'Export' ),
138 'Version' => array( 'SpecialPage', 'Version' ),
139 'Allmessages' => array( 'SpecialPage', 'Allmessages' ),
140 'Log' => array( 'SpecialPage', 'Log' ),
141 'Blockip' => array( 'SpecialPage', 'Blockip', 'block' ),
142 'Undelete' => array( 'SpecialPage', 'Undelete', 'deletedhistory' ),
143 'Import' => array( 'SpecialPage', 'Import', 'import' ),
144 'Lockdb' => array( 'SpecialPage', 'Lockdb', 'siteadmin' ),
145 'Unlockdb' => array( 'SpecialPage', 'Unlockdb', 'siteadmin' ),
146 'Userrights' => 'UserrightsPage',
147 'MIMEsearch' => array( 'SpecialPage', 'MIMEsearch' ),
148 'FileDuplicateSearch' => array( 'SpecialPage', 'FileDuplicateSearch' ),
149 'Unwatchedpages' => array( 'SpecialPage', 'Unwatchedpages', 'unwatchedpages' ),
150 'Listredirects' => array( 'SpecialPage', 'Listredirects' ),
151 'Revisiondelete' => array( 'UnlistedSpecialPage', 'Revisiondelete', 'deleterevision' ),
152 'Unusedtemplates' => array( 'SpecialPage', 'Unusedtemplates' ),
153 'Randomredirect' => 'SpecialRandomredirect',
154 'Withoutinterwiki' => array( 'SpecialPage', 'Withoutinterwiki' ),
155 'Filepath' => array( 'SpecialPage', 'Filepath' ),
157 'Mypage' => array( 'SpecialMypage' ),
158 'Mytalk' => array( 'SpecialMytalk' ),
159 'Mycontributions' => array( 'SpecialMycontributions' ),
160 'Listadmins' => array( 'SpecialRedirectToSpecial', 'Listadmins', 'Listusers', 'sysop' ),
161 'MergeHistory' => array( 'SpecialPage', 'MergeHistory', 'mergehistory' ),
162 'Listbots' => array( 'SpecialRedirectToSpecial', 'Listbots', 'Listusers', 'bot' ),
165 static public $mAliases;
166 static public $mListInitialised = false;
171 * Initialise the special page list
172 * This must be called before accessing SpecialPage::$mList
174 static function initList() {
175 global $wgSpecialPages;
176 global $wgDisableCounters, $wgDisableInternalSearch, $wgEmailAuthentication;
178 if ( self
::$mListInitialised ) {
181 wfProfileIn( __METHOD__
);
183 # Better to set this now, to avoid infinite recursion in carelessly written hooks
184 self
::$mListInitialised = true;
186 if( !$wgDisableCounters ) {
187 self
::$mList['Popularpages'] = array( 'SpecialPage', 'Popularpages' );
190 if( !$wgDisableInternalSearch ) {
191 self
::$mList['Search'] = array( 'SpecialPage', 'Search' );
194 if( $wgEmailAuthentication ) {
195 self
::$mList['Confirmemail'] = 'EmailConfirmation';
196 self
::$mList['Invalidateemail'] = 'EmailInvalidation';
199 # Add extension special pages
200 self
::$mList = array_merge( self
::$mList, $wgSpecialPages );
203 # This hook can be used to remove undesired built-in special pages
204 wfRunHooks( 'SpecialPage_initList', array( &self
::$mList ) );
205 wfProfileOut( __METHOD__
);
208 static function initAliasList() {
209 if ( !is_null( self
::$mAliases ) ) {
214 $aliases = $wgContLang->getSpecialPageAliases();
215 $missingPages = self
::$mList;
216 self
::$mAliases = array();
217 foreach ( $aliases as $realName => $aliasList ) {
218 foreach ( $aliasList as $alias ) {
219 self
::$mAliases[$wgContLang->caseFold( $alias )] = $realName;
221 unset( $missingPages[$realName] );
223 foreach ( $missingPages as $name => $stuff ) {
224 self
::$mAliases[$wgContLang->caseFold( $name )] = $name;
229 * Given a special page alias, return the special page name.
230 * Returns false if there is no such alias.
232 static function resolveAlias( $alias ) {
235 if ( !self
::$mListInitialised ) self
::initList();
236 if ( is_null( self
::$mAliases ) ) self
::initAliasList();
237 $caseFoldedAlias = $wgContLang->caseFold( $alias );
238 if ( isset( self
::$mAliases[$caseFoldedAlias] ) ) {
239 return self
::$mAliases[$caseFoldedAlias];
246 * Given a special page name with a possible subpage, return an array
247 * where the first element is the special page name and the second is the
250 static function resolveAliasWithSubpage( $alias ) {
251 $bits = explode( '/', $alias, 2 );
252 $name = self
::resolveAlias( $bits[0] );
253 if( !isset( $bits[1] ) ) { // bug 2087
258 return array( $name, $par );
262 * Add a page to the list of valid special pages. This used to be the preferred
263 * method for adding special pages in extensions. It's now suggested that you add
264 * an associative record to $wgSpecialPages. This avoids autoloading SpecialPage.
266 * @param SpecialPage $page
269 static function addPage( &$page ) {
270 if ( !self
::$mListInitialised ) {
273 self
::$mList[$page->mName
] = $page;
277 * Add a page to a certain display group for Special:SpecialPages
279 * @param mixed $page (SpecialPage or string)
280 * @param string $group
283 static function setGroup( $page, $group ) {
284 global $wgSpecialPageGroups;
285 $name = is_object($page) ?
$page->mName
: $page;
286 $wgSpecialPageGroups[$name] = $group;
290 * Add a page to a certain display group for Special:SpecialPages
292 * @param SpecialPage $page
295 static function getGroup( &$page ) {
296 global $wgSpecialPageGroups;
297 $group = isset($wgSpecialPageGroups[$page->mName
]) ?
298 $wgSpecialPageGroups[$page->mName
] : 'other';
303 * Remove a special page from the list
304 * Formerly used to disable expensive or dangerous special pages. The
305 * preferred method is now to add a SpecialPage_initList hook.
309 static function removePage( $name ) {
310 if ( !self
::$mListInitialised ) {
313 unset( self
::$mList[$name] );
317 * Check if a given name exist as a special page or as a special page alias
318 * @param $name string: name of a special page
319 * @return boolean: true if a special page exists with this name
321 static function exists( $name ) {
323 if ( !self
::$mListInitialised ) {
326 if( !self
::$mAliases ) {
327 self
::initAliasList();
330 # Remove special pages inline parameters:
331 $bits = explode( '/', $name );
332 $name = $wgContLang->caseFold($bits[0]);
335 array_key_exists( $name, self
::$mList )
336 or array_key_exists( $name, self
::$mAliases )
341 * Find the object with a given name and return it (or NULL)
343 * @param string $name
345 static function getPage( $name ) {
346 if ( !self
::$mListInitialised ) {
349 if ( array_key_exists( $name, self
::$mList ) ) {
350 $rec = self
::$mList[$name];
351 if ( is_string( $rec ) ) {
353 self
::$mList[$name] = new $className;
354 } elseif ( is_array( $rec ) ) {
355 $className = array_shift( $rec );
356 self
::$mList[$name] = wfCreateObject( $className, $rec );
358 return self
::$mList[$name];
365 * Get a special page with a given localised name, or NULL if there
366 * is no such special page.
368 static function getPageByAlias( $alias ) {
369 $realName = self
::resolveAlias( $alias );
371 return self
::getPage( $realName );
378 * Return categorised listable special pages for all users
381 static function getRegularPages() {
382 if ( !self
::$mListInitialised ) {
387 foreach ( self
::$mList as $name => $rec ) {
388 $page = self
::getPage( $name );
389 if ( $page->isListed() && !$page->isRestricted() ) {
390 $pages[$name] = $page;
397 * Return categorised listable special pages which are available
398 * for the current user, but not for everyone
401 static function getRestrictedPages() {
403 if ( !self
::$mListInitialised ) {
408 foreach ( self
::$mList as $name => $rec ) {
409 $page = self
::getPage( $name );
412 and $page->isRestricted()
413 and $page->userCanExecute( $wgUser )
415 $pages[$name] = $page;
422 * Execute a special page path.
423 * The path may contain parameters, e.g. Special:Name/Params
424 * Extracts the special page name and call the execute method, passing the parameters
426 * Returns a title object if the page is redirected, false if there was no such special
427 * page, and true if it was successful.
429 * @param $title a title object
430 * @param $including output is being captured for use in {{special:whatever}}
432 static function executePath( &$title, $including = false ) {
433 global $wgOut, $wgTitle, $wgRequest;
434 wfProfileIn( __METHOD__
);
436 # FIXME: redirects broken due to this call
437 $bits = explode( '/', $title->getDBkey(), 2 );
439 if( !isset( $bits[1] ) ) { // bug 2087
444 $page = SpecialPage
::getPageByAlias( $name );
448 $wgOut->setArticleRelated( false );
449 $wgOut->setRobotpolicy( 'noindex,nofollow' );
450 $wgOut->setStatusCode( 404 );
451 $wgOut->showErrorPage( 'nosuchspecialpage', 'nospecialpagetext' );
453 wfProfileOut( __METHOD__
);
459 $redirect = $page->getRedirect( $par );
461 $query = $page->getRedirectQuery();
462 $url = $redirect->getFullUrl( $query );
463 $wgOut->redirect( $url );
464 wfProfileOut( __METHOD__
);
469 # Redirect to canonical alias for GET commands
470 # Not for POST, we'd lose the post data, so it's best to just distribute
471 # the request. Such POST requests are possible for old extensions that
472 # generate self-links without being aware that their default name has
474 if ( !$including && $name != $page->getLocalName() && !$wgRequest->wasPosted() ) {
476 unset( $query['title'] );
477 $query = wfArrayToCGI( $query );
478 $title = $page->getTitle( $par );
479 $url = $title->getFullUrl( $query );
480 $wgOut->redirect( $url );
481 wfProfileOut( __METHOD__
);
485 if ( $including && !$page->includable() ) {
486 wfProfileOut( __METHOD__
);
488 } elseif ( !$including ) {
489 $wgTitle = $page->getTitle();
491 $page->including( $including );
493 // Execute special page
494 $profName = 'Special:' . $page->getName();
495 wfProfileIn( $profName );
496 $page->execute( $par );
497 wfProfileOut( $profName );
498 wfProfileOut( __METHOD__
);
503 * Just like executePath() except it returns the HTML instead of outputting it
504 * Returns false if there was no such special page, or a title object if it was
508 static function capturePath( &$title ) {
509 global $wgOut, $wgTitle;
511 $oldTitle = $wgTitle;
513 $wgOut = new OutputPage
;
515 $ret = SpecialPage
::executePath( $title, true );
516 if ( $ret === true ) {
517 $ret = $wgOut->getHTML();
519 $wgTitle = $oldTitle;
525 * Get the local name for a specified canonical name
528 * @param mixed $subpage Boolean false, or string
532 static function getLocalNameFor( $name, $subpage = false ) {
534 $aliases = $wgContLang->getSpecialPageAliases();
535 if ( isset( $aliases[$name][0] ) ) {
536 $name = $aliases[$name][0];
538 if ( $subpage !== false && !is_null( $subpage ) ) {
539 $name = "$name/$subpage";
545 * Get a localised Title object for a specified special page name
547 static function getTitleFor( $name, $subpage = false ) {
548 $name = self
::getLocalNameFor( $name, $subpage );
550 return Title
::makeTitle( NS_SPECIAL
, $name );
552 throw new MWException( "Invalid special page name \"$name\"" );
557 * Get a localised Title object for a page name with a possibly unvalidated subpage
559 static function getSafeTitleFor( $name, $subpage = false ) {
560 $name = self
::getLocalNameFor( $name, $subpage );
562 return Title
::makeTitleSafe( NS_SPECIAL
, $name );
569 * Get a title for a given alias
570 * @return Title or null if there is no such alias
572 static function getTitleForAlias( $alias ) {
573 $name = self
::resolveAlias( $alias );
575 return self
::getTitleFor( $name );
582 * Default constructor for special pages
583 * Derivative classes should call this from their constructor
584 * Note that if the user does not have the required level, an error message will
585 * be displayed by the default execute() method, without the global function ever
588 * If you override execute(), you can recover the default behaviour with userCanExecute()
589 * and displayRestrictionError()
591 * @param string $name Name of the special page, as seen in links and URLs
592 * @param string $restriction User right required, e.g. "block" or "delete"
593 * @param boolean $listed Whether the page is listed in Special:Specialpages
594 * @param string $function Function called by execute(). By default it is constructed from $name
595 * @param string $file File which is included by execute(). It is also constructed from $name by default
597 function SpecialPage( $name = '', $restriction = '', $listed = true, $function = false, $file = 'default', $includable = false ) {
598 $this->mName
= $name;
599 $this->mRestriction
= $restriction;
600 $this->mListed
= $listed;
601 $this->mIncludable
= $includable;
602 if ( $function == false ) {
603 $this->mFunction
= 'wfSpecial'.$name;
605 $this->mFunction
= $function;
607 if ( $file === 'default' ) {
608 $this->mFile
= dirname(__FILE__
) . "/Special{$name}.php";
610 $this->mFile
= $file;
619 function getName() { return $this->mName
; }
620 function getRestriction() { return $this->mRestriction
; }
621 function getFile() { return $this->mFile
; }
622 function isListed() { return $this->mListed
; }
626 * Accessor and mutator
628 function name( $x = NULL ) { return wfSetVar( $this->mName
, $x ); }
629 function restrictions( $x = NULL) { return wfSetVar( $this->mRestrictions
, $x ); }
630 function listed( $x = NULL) { return wfSetVar( $this->mListed
, $x ); }
631 function func( $x = NULL) { return wfSetVar( $this->mFunction
, $x ); }
632 function file( $x = NULL) { return wfSetVar( $this->mFile
, $x ); }
633 function includable( $x = NULL ) { return wfSetVar( $this->mIncludable
, $x ); }
634 function including( $x = NULL ) { return wfSetVar( $this->mIncluding
, $x ); }
638 * Get the localised name of the special page
640 function getLocalName() {
641 if ( !isset( $this->mLocalName
) ) {
642 $this->mLocalName
= self
::getLocalNameFor( $this->mName
);
644 return $this->mLocalName
;
648 * Can be overridden by subclasses with more complicated permissions
651 * @return bool Should the page be displayed with the restricted-access
654 public function isRestricted() {
655 return $this->mRestriction
!= '';
659 * Checks if the given user (identified by an object) can execute this
660 * special page (as defined by $mRestriction). Can be overridden by sub-
661 * classes with more complicated permissions schemes.
663 * @param User $user The user to check
664 * @return bool Does the user have permission to view the page?
666 public function userCanExecute( $user ) {
667 return $user->isAllowed( $this->mRestriction
);
671 * Output an error message telling the user what access level they have to have
673 function displayRestrictionError() {
675 $wgOut->permissionRequired( $this->mRestriction
);
679 * Sets headers - this should be called from the execute() method of all derived classes!
681 function setHeaders() {
683 $wgOut->setArticleRelated( false );
684 $wgOut->setRobotPolicy( "noindex,nofollow" );
685 $wgOut->setPageTitle( $this->getDescription() );
689 * Default execute method
690 * Checks user permissions, calls the function given in mFunction
692 * This may be overridden by subclasses.
694 function execute( $par ) {
699 if ( $this->userCanExecute( $wgUser ) ) {
700 $func = $this->mFunction
;
701 // only load file if the function does not exist
702 if(!is_callable($func) and $this->mFile
) {
703 require_once( $this->mFile
);
705 # FIXME: these hooks are broken for extensions and anything else that subclasses SpecialPage.
706 if ( wfRunHooks( 'SpecialPageExecuteBeforeHeader', array( &$this, &$par, &$func ) ) )
707 $this->outputHeader();
708 if ( ! wfRunHooks( 'SpecialPageExecuteBeforePage', array( &$this, &$par, &$func ) ) )
710 call_user_func( $func, $par, $this );
711 if ( ! wfRunHooks( 'SpecialPageExecuteAfterPage', array( &$this, &$par, &$func ) ) )
714 $this->displayRestrictionError();
718 function outputHeader() {
719 global $wgOut, $wgContLang;
721 $msg = $wgContLang->lc( $this->name() ) . '-summary';
722 $out = wfMsgNoTrans( $msg );
723 if ( ! wfEmptyMsg( $msg, $out ) and $out !== '' and ! $this->including() ) {
724 $wgOut->addWikiMsg( $msg );
729 # Returns the name that goes in the <h1> in the special page itself, and also the name that
730 # will be listed in Special:Specialpages
732 # Derived classes can override this, but usually it is easier to keep the default behaviour.
733 # Messages can be added at run-time, see MessageCache.php
734 function getDescription() {
735 return wfMsg( strtolower( $this->mName
) );
739 * Get a self-referential title object
741 function getTitle( $subpage = false) {
742 return self
::getTitleFor( $this->mName
, $subpage );
746 * Set whether this page is listed in Special:Specialpages, at run-time
748 function setListed( $listed ) {
749 return wfSetVar( $this->mListed
, $listed );
753 * If the special page is a redirect, then get the Title object it redirects to.
756 function getRedirect( $subpage ) {
761 * Return part of the request string for a special redirect page
762 * This allows passing, e.g. action=history to Special:Mypage, etc.
766 function getRedirectQuery() {
769 foreach( $this->mAllowedRedirectParams
as $arg ) {
770 if( $val = $wgRequest->getVal( $arg, false ) )
771 $params[] = $arg . '=' . $val;
774 return count( $params ) ?
implode( '&', $params ) : false;
779 * Shortcut to construct a special page which is unlisted by default
780 * @ingroup SpecialPage
782 class UnlistedSpecialPage
extends SpecialPage
784 function UnlistedSpecialPage( $name, $restriction = '', $function = false, $file = 'default' ) {
785 SpecialPage
::SpecialPage( $name, $restriction, false, $function, $file );
790 * Shortcut to construct an includable special page
791 * @ingroup SpecialPage
793 class IncludableSpecialPage
extends SpecialPage
795 function IncludableSpecialPage( $name, $restriction = '', $listed = true, $function = false, $file = 'default' ) {
796 SpecialPage
::SpecialPage( $name, $restriction, $listed, $function, $file, true );
801 * Shortcut to construct a special page alias.
802 * @ingroup SpecialPage
804 class SpecialRedirectToSpecial
extends UnlistedSpecialPage
{
805 var $redirName, $redirSubpage;
807 function __construct( $name, $redirName, $redirSubpage = false, $redirectParams = array() ) {
808 parent
::__construct( $name );
809 $this->redirName
= $redirName;
810 $this->redirSubpage
= $redirSubpage;
811 $this->mAllowedRedirectParams
= $redirectParams;
814 function getRedirect( $subpage ) {
815 if ( $this->redirSubpage
=== false ) {
816 return SpecialPage
::getTitleFor( $this->redirName
, $subpage );
818 return SpecialPage
::getTitleFor( $this->redirName
, $this->redirSubpage
);
823 /** SpecialMypage, SpecialMytalk and SpecialMycontributions special pages
824 * are used to get user independant links pointing to the user page, talk
825 * page and list of contributions.
826 * This can let us cache a single copy of any generated content for all
831 * Shortcut to construct a special page pointing to current user user's page.
832 * @ingroup SpecialPage
834 class SpecialMypage
extends UnlistedSpecialPage
{
835 function __construct() {
836 parent
::__construct( 'Mypage' );
837 $this->mAllowedRedirectParams
= array( 'action' , 'preload' , 'editintro', 'section' );
840 function getRedirect( $subpage ) {
842 if ( strval( $subpage ) !== '' ) {
843 return Title
::makeTitle( NS_USER
, $wgUser->getName() . '/' . $subpage );
845 return Title
::makeTitle( NS_USER
, $wgUser->getName() );
851 * Shortcut to construct a special page pointing to current user talk page.
852 * @ingroup SpecialPage
854 class SpecialMytalk
extends UnlistedSpecialPage
{
855 function __construct() {
856 parent
::__construct( 'Mytalk' );
857 $this->mAllowedRedirectParams
= array( 'action' , 'preload' , 'editintro', 'section' );
860 function getRedirect( $subpage ) {
862 if ( strval( $subpage ) !== '' ) {
863 return Title
::makeTitle( NS_USER_TALK
, $wgUser->getName() . '/' . $subpage );
865 return Title
::makeTitle( NS_USER_TALK
, $wgUser->getName() );
871 * Shortcut to construct a special page pointing to current user contributions.
872 * @ingroup SpecialPage
874 class SpecialMycontributions
extends UnlistedSpecialPage
{
875 function __construct() {
876 parent
::__construct( 'Mycontributions' );
879 function getRedirect( $subpage ) {
881 return SpecialPage
::getTitleFor( 'Contributions', $wgUser->getName() );