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 which are available
379 * for the current user, and everyone.
382 static function getUsablePages() {
384 if ( !self
::$mListInitialised ) {
389 foreach ( self
::$mList as $name => $rec ) {
390 $page = self
::getPage( $name );
391 if ( $page->isListed()
393 !$page->isRestricted()
394 ||
$page->userCanExecute( $wgUser )
397 $pages[$name] = $page;
404 * Return categorised listable special pages for all users
407 static function getRegularPages() {
408 if ( !self
::$mListInitialised ) {
413 foreach ( self
::$mList as $name => $rec ) {
414 $page = self
::getPage( $name );
415 if ( $page->isListed() && !$page->isRestricted() ) {
416 $pages[$name] = $page;
423 * Return categorised listable special pages which are available
424 * for the current user, but not for everyone
427 static function getRestrictedPages() {
429 if ( !self
::$mListInitialised ) {
434 foreach ( self
::$mList as $name => $rec ) {
435 $page = self
::getPage( $name );
438 && $page->isRestricted()
439 && $page->userCanExecute( $wgUser )
441 $pages[$name] = $page;
448 * Execute a special page path.
449 * The path may contain parameters, e.g. Special:Name/Params
450 * Extracts the special page name and call the execute method, passing the parameters
452 * Returns a title object if the page is redirected, false if there was no such special
453 * page, and true if it was successful.
455 * @param $title a title object
456 * @param $including output is being captured for use in {{special:whatever}}
458 static function executePath( &$title, $including = false ) {
459 global $wgOut, $wgTitle, $wgRequest;
460 wfProfileIn( __METHOD__
);
462 # FIXME: redirects broken due to this call
463 $bits = explode( '/', $title->getDBkey(), 2 );
465 if( !isset( $bits[1] ) ) { // bug 2087
470 $page = SpecialPage
::getPageByAlias( $name );
474 $wgOut->setArticleRelated( false );
475 $wgOut->setRobotpolicy( 'noindex,nofollow' );
476 $wgOut->setStatusCode( 404 );
477 $wgOut->showErrorPage( 'nosuchspecialpage', 'nospecialpagetext' );
479 wfProfileOut( __METHOD__
);
485 $redirect = $page->getRedirect( $par );
487 $query = $page->getRedirectQuery();
488 $url = $redirect->getFullUrl( $query );
489 $wgOut->redirect( $url );
490 wfProfileOut( __METHOD__
);
495 # Redirect to canonical alias for GET commands
496 # Not for POST, we'd lose the post data, so it's best to just distribute
497 # the request. Such POST requests are possible for old extensions that
498 # generate self-links without being aware that their default name has
500 if ( !$including && $name != $page->getLocalName() && !$wgRequest->wasPosted() ) {
502 unset( $query['title'] );
503 $query = wfArrayToCGI( $query );
504 $title = $page->getTitle( $par );
505 $url = $title->getFullUrl( $query );
506 $wgOut->redirect( $url );
507 wfProfileOut( __METHOD__
);
511 if ( $including && !$page->includable() ) {
512 wfProfileOut( __METHOD__
);
514 } elseif ( !$including ) {
515 $wgTitle = $page->getTitle();
517 $page->including( $including );
519 // Execute special page
520 $profName = 'Special:' . $page->getName();
521 wfProfileIn( $profName );
522 $page->execute( $par );
523 wfProfileOut( $profName );
524 wfProfileOut( __METHOD__
);
529 * Just like executePath() except it returns the HTML instead of outputting it
530 * Returns false if there was no such special page, or a title object if it was
534 static function capturePath( &$title ) {
535 global $wgOut, $wgTitle;
537 $oldTitle = $wgTitle;
539 $wgOut = new OutputPage
;
541 $ret = SpecialPage
::executePath( $title, true );
542 if ( $ret === true ) {
543 $ret = $wgOut->getHTML();
545 $wgTitle = $oldTitle;
551 * Get the local name for a specified canonical name
554 * @param mixed $subpage Boolean false, or string
558 static function getLocalNameFor( $name, $subpage = false ) {
560 $aliases = $wgContLang->getSpecialPageAliases();
561 if ( isset( $aliases[$name][0] ) ) {
562 $name = $aliases[$name][0];
564 if ( $subpage !== false && !is_null( $subpage ) ) {
565 $name = "$name/$subpage";
571 * Get a localised Title object for a specified special page name
573 static function getTitleFor( $name, $subpage = false ) {
574 $name = self
::getLocalNameFor( $name, $subpage );
576 return Title
::makeTitle( NS_SPECIAL
, $name );
578 throw new MWException( "Invalid special page name \"$name\"" );
583 * Get a localised Title object for a page name with a possibly unvalidated subpage
585 static function getSafeTitleFor( $name, $subpage = false ) {
586 $name = self
::getLocalNameFor( $name, $subpage );
588 return Title
::makeTitleSafe( NS_SPECIAL
, $name );
595 * Get a title for a given alias
596 * @return Title or null if there is no such alias
598 static function getTitleForAlias( $alias ) {
599 $name = self
::resolveAlias( $alias );
601 return self
::getTitleFor( $name );
608 * Default constructor for special pages
609 * Derivative classes should call this from their constructor
610 * Note that if the user does not have the required level, an error message will
611 * be displayed by the default execute() method, without the global function ever
614 * If you override execute(), you can recover the default behaviour with userCanExecute()
615 * and displayRestrictionError()
617 * @param string $name Name of the special page, as seen in links and URLs
618 * @param string $restriction User right required, e.g. "block" or "delete"
619 * @param boolean $listed Whether the page is listed in Special:Specialpages
620 * @param string $function Function called by execute(). By default it is constructed from $name
621 * @param string $file File which is included by execute(). It is also constructed from $name by default
623 function SpecialPage( $name = '', $restriction = '', $listed = true, $function = false, $file = 'default', $includable = false ) {
624 $this->mName
= $name;
625 $this->mRestriction
= $restriction;
626 $this->mListed
= $listed;
627 $this->mIncludable
= $includable;
628 if ( $function == false ) {
629 $this->mFunction
= 'wfSpecial'.$name;
631 $this->mFunction
= $function;
633 if ( $file === 'default' ) {
634 $this->mFile
= dirname(__FILE__
) . "/Special{$name}.php";
636 $this->mFile
= $file;
645 function getName() { return $this->mName
; }
646 function getRestriction() { return $this->mRestriction
; }
647 function getFile() { return $this->mFile
; }
648 function isListed() { return $this->mListed
; }
652 * Accessor and mutator
654 function name( $x = NULL ) { return wfSetVar( $this->mName
, $x ); }
655 function restrictions( $x = NULL) { return wfSetVar( $this->mRestrictions
, $x ); }
656 function listed( $x = NULL) { return wfSetVar( $this->mListed
, $x ); }
657 function func( $x = NULL) { return wfSetVar( $this->mFunction
, $x ); }
658 function file( $x = NULL) { return wfSetVar( $this->mFile
, $x ); }
659 function includable( $x = NULL ) { return wfSetVar( $this->mIncludable
, $x ); }
660 function including( $x = NULL ) { return wfSetVar( $this->mIncluding
, $x ); }
664 * Get the localised name of the special page
666 function getLocalName() {
667 if ( !isset( $this->mLocalName
) ) {
668 $this->mLocalName
= self
::getLocalNameFor( $this->mName
);
670 return $this->mLocalName
;
674 * Can be overridden by subclasses with more complicated permissions
677 * @return bool Should the page be displayed with the restricted-access
680 public function isRestricted() {
681 return $this->mRestriction
!= '';
685 * Checks if the given user (identified by an object) can execute this
686 * special page (as defined by $mRestriction). Can be overridden by sub-
687 * classes with more complicated permissions schemes.
689 * @param User $user The user to check
690 * @return bool Does the user have permission to view the page?
692 public function userCanExecute( $user ) {
693 return $user->isAllowed( $this->mRestriction
);
697 * Output an error message telling the user what access level they have to have
699 function displayRestrictionError() {
701 $wgOut->permissionRequired( $this->mRestriction
);
705 * Sets headers - this should be called from the execute() method of all derived classes!
707 function setHeaders() {
709 $wgOut->setArticleRelated( false );
710 $wgOut->setRobotPolicy( "noindex,nofollow" );
711 $wgOut->setPageTitle( $this->getDescription() );
715 * Default execute method
716 * Checks user permissions, calls the function given in mFunction
718 * This may be overridden by subclasses.
720 function execute( $par ) {
725 if ( $this->userCanExecute( $wgUser ) ) {
726 $func = $this->mFunction
;
727 // only load file if the function does not exist
728 if(!is_callable($func) and $this->mFile
) {
729 require_once( $this->mFile
);
731 # FIXME: these hooks are broken for extensions and anything else that subclasses SpecialPage.
732 if ( wfRunHooks( 'SpecialPageExecuteBeforeHeader', array( &$this, &$par, &$func ) ) )
733 $this->outputHeader();
734 if ( ! wfRunHooks( 'SpecialPageExecuteBeforePage', array( &$this, &$par, &$func ) ) )
736 call_user_func( $func, $par, $this );
737 if ( ! wfRunHooks( 'SpecialPageExecuteAfterPage', array( &$this, &$par, &$func ) ) )
740 $this->displayRestrictionError();
744 function outputHeader() {
745 global $wgOut, $wgContLang;
747 $msg = $wgContLang->lc( $this->name() ) . '-summary';
748 $out = wfMsgNoTrans( $msg );
749 if ( ! wfEmptyMsg( $msg, $out ) and $out !== '' and ! $this->including() ) {
750 $wgOut->addWikiMsg( $msg );
755 # Returns the name that goes in the <h1> in the special page itself, and also the name that
756 # will be listed in Special:Specialpages
758 # Derived classes can override this, but usually it is easier to keep the default behaviour.
759 # Messages can be added at run-time, see MessageCache.php
760 function getDescription() {
761 return wfMsg( strtolower( $this->mName
) );
765 * Get a self-referential title object
767 function getTitle( $subpage = false) {
768 return self
::getTitleFor( $this->mName
, $subpage );
772 * Set whether this page is listed in Special:Specialpages, at run-time
774 function setListed( $listed ) {
775 return wfSetVar( $this->mListed
, $listed );
779 * If the special page is a redirect, then get the Title object it redirects to.
782 function getRedirect( $subpage ) {
787 * Return part of the request string for a special redirect page
788 * This allows passing, e.g. action=history to Special:Mypage, etc.
792 function getRedirectQuery() {
795 foreach( $this->mAllowedRedirectParams
as $arg ) {
796 if( $val = $wgRequest->getVal( $arg, false ) )
797 $params[] = $arg . '=' . $val;
800 return count( $params ) ?
implode( '&', $params ) : false;
805 * Shortcut to construct a special page which is unlisted by default
806 * @ingroup SpecialPage
808 class UnlistedSpecialPage
extends SpecialPage
810 function UnlistedSpecialPage( $name, $restriction = '', $function = false, $file = 'default' ) {
811 SpecialPage
::SpecialPage( $name, $restriction, false, $function, $file );
816 * Shortcut to construct an includable special page
817 * @ingroup SpecialPage
819 class IncludableSpecialPage
extends SpecialPage
821 function IncludableSpecialPage( $name, $restriction = '', $listed = true, $function = false, $file = 'default' ) {
822 SpecialPage
::SpecialPage( $name, $restriction, $listed, $function, $file, true );
827 * Shortcut to construct a special page alias.
828 * @ingroup SpecialPage
830 class SpecialRedirectToSpecial
extends UnlistedSpecialPage
{
831 var $redirName, $redirSubpage;
833 function __construct( $name, $redirName, $redirSubpage = false, $redirectParams = array() ) {
834 parent
::__construct( $name );
835 $this->redirName
= $redirName;
836 $this->redirSubpage
= $redirSubpage;
837 $this->mAllowedRedirectParams
= $redirectParams;
840 function getRedirect( $subpage ) {
841 if ( $this->redirSubpage
=== false ) {
842 return SpecialPage
::getTitleFor( $this->redirName
, $subpage );
844 return SpecialPage
::getTitleFor( $this->redirName
, $this->redirSubpage
);
849 /** SpecialMypage, SpecialMytalk and SpecialMycontributions special pages
850 * are used to get user independant links pointing to the user page, talk
851 * page and list of contributions.
852 * This can let us cache a single copy of any generated content for all
857 * Shortcut to construct a special page pointing to current user user's page.
858 * @ingroup SpecialPage
860 class SpecialMypage
extends UnlistedSpecialPage
{
861 function __construct() {
862 parent
::__construct( 'Mypage' );
863 $this->mAllowedRedirectParams
= array( 'action' , 'preload' , 'editintro', 'section' );
866 function getRedirect( $subpage ) {
868 if ( strval( $subpage ) !== '' ) {
869 return Title
::makeTitle( NS_USER
, $wgUser->getName() . '/' . $subpage );
871 return Title
::makeTitle( NS_USER
, $wgUser->getName() );
877 * Shortcut to construct a special page pointing to current user talk page.
878 * @ingroup SpecialPage
880 class SpecialMytalk
extends UnlistedSpecialPage
{
881 function __construct() {
882 parent
::__construct( 'Mytalk' );
883 $this->mAllowedRedirectParams
= array( 'action' , 'preload' , 'editintro', 'section' );
886 function getRedirect( $subpage ) {
888 if ( strval( $subpage ) !== '' ) {
889 return Title
::makeTitle( NS_USER_TALK
, $wgUser->getName() . '/' . $subpage );
891 return Title
::makeTitle( NS_USER_TALK
, $wgUser->getName() );
897 * Shortcut to construct a special page pointing to current user contributions.
898 * @ingroup SpecialPage
900 class SpecialMycontributions
extends UnlistedSpecialPage
{
901 function __construct() {
902 parent
::__construct( 'Mycontributions' );
905 function getRedirect( $subpage ) {
907 return SpecialPage
::getTitleFor( 'Contributions', $wgUser->getName() );