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' => 'SpecialRecentchanges',
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 'Wantedfiles' => array( 'SpecialPage', 'Wantedfiles' ),
111 'Mostlinked' => array( 'SpecialPage', 'Mostlinked' ),
112 'Mostlinkedcategories' => array( 'SpecialPage', 'Mostlinkedcategories' ),
113 'Mostlinkedtemplates' => array( 'SpecialPage', 'Mostlinkedtemplates' ),
114 'Mostcategories' => array( 'SpecialPage', 'Mostcategories' ),
115 'Mostimages' => array( 'SpecialPage', 'Mostimages' ),
116 'Mostrevisions' => array( 'SpecialPage', 'Mostrevisions' ),
117 'Fewestrevisions' => array( 'SpecialPage', 'Fewestrevisions' ),
118 'Shortpages' => array( 'SpecialPage', 'Shortpages' ),
119 'Longpages' => array( 'SpecialPage', 'Longpages' ),
120 'Newpages' => 'SpecialNewpages',
121 'Ancientpages' => array( 'SpecialPage', 'Ancientpages' ),
122 'Deadendpages' => array( 'SpecialPage', 'Deadendpages' ),
123 'Protectedpages' => array( 'SpecialPage', 'Protectedpages' ),
124 'Protectedtitles' => array( 'SpecialPage', 'Protectedtitles' ),
125 'Allpages' => 'SpecialAllpages',
126 'Prefixindex' => 'SpecialPrefixindex',
127 'Ipblocklist' => array( 'SpecialPage', 'Ipblocklist' ),
128 'Specialpages' => array( 'UnlistedSpecialPage', 'Specialpages' ),
129 'Contributions' => array( 'SpecialPage', 'Contributions' ),
130 'Emailuser' => array( 'UnlistedSpecialPage', 'Emailuser' ),
131 'Whatlinkshere' => array( 'SpecialPage', 'Whatlinkshere' ),
132 'LinkSearch' => array( 'SpecialPage', 'LinkSearch' ),
133 'Recentchangeslinked' => 'SpecialRecentchangeslinked',
134 'Movepage' => array( 'UnlistedSpecialPage', 'Movepage' ),
135 'Blockme' => array( 'UnlistedSpecialPage', 'Blockme' ),
136 'Resetpass' => array( 'UnlistedSpecialPage', 'Resetpass' ),
137 'Booksources' => 'SpecialBookSources',
138 'Categories' => array( 'SpecialPage', 'Categories' ),
139 'Export' => array( 'SpecialPage', 'Export' ),
140 'Version' => array( 'SpecialPage', 'Version' ),
141 'Blankpage' => array( 'UnlistedSpecialPage', 'Blankpage' ),
142 'Allmessages' => array( 'SpecialPage', 'Allmessages' ),
143 'Log' => array( 'SpecialPage', 'Log' ),
144 'Blockip' => array( 'SpecialPage', 'Blockip', 'block' ),
145 'Undelete' => array( 'SpecialPage', 'Undelete', 'deletedhistory' ),
146 'Import' => array( 'SpecialPage', 'Import', 'import' ),
147 'Lockdb' => array( 'SpecialPage', 'Lockdb', 'siteadmin' ),
148 'Unlockdb' => array( 'SpecialPage', 'Unlockdb', 'siteadmin' ),
149 'Userrights' => 'UserrightsPage',
150 'MIMEsearch' => array( 'SpecialPage', 'MIMEsearch' ),
151 'FileDuplicateSearch' => array( 'SpecialPage', 'FileDuplicateSearch' ),
152 'Unwatchedpages' => array( 'SpecialPage', 'Unwatchedpages', 'unwatchedpages' ),
153 'Listredirects' => array( 'SpecialPage', 'Listredirects' ),
154 'Revisiondelete' => array( 'UnlistedSpecialPage', 'Revisiondelete', 'deleterevision' ),
155 'Unusedtemplates' => array( 'SpecialPage', 'Unusedtemplates' ),
156 'Randomredirect' => 'SpecialRandomredirect',
157 'Withoutinterwiki' => array( 'SpecialPage', 'Withoutinterwiki' ),
158 'Filepath' => array( 'SpecialPage', 'Filepath' ),
160 'Mypage' => array( 'SpecialMypage' ),
161 'Mytalk' => array( 'SpecialMytalk' ),
162 'Mycontributions' => array( 'SpecialMycontributions' ),
163 'Listadmins' => array( 'SpecialRedirectToSpecial', 'Listadmins', 'Listusers', 'sysop' ),
164 'MergeHistory' => array( 'SpecialPage', 'MergeHistory', 'mergehistory' ),
165 'Listbots' => array( 'SpecialRedirectToSpecial', 'Listbots', 'Listusers', 'bot' ),
168 static public $mAliases;
169 static public $mListInitialised = false;
174 * Initialise the special page list
175 * This must be called before accessing SpecialPage::$mList
177 static function initList() {
178 global $wgSpecialPages;
179 global $wgDisableCounters, $wgDisableInternalSearch, $wgEmailAuthentication;
181 if ( self
::$mListInitialised ) {
184 wfProfileIn( __METHOD__
);
186 # Better to set this now, to avoid infinite recursion in carelessly written hooks
187 self
::$mListInitialised = true;
189 if( !$wgDisableCounters ) {
190 self
::$mList['Popularpages'] = array( 'SpecialPage', 'Popularpages' );
193 if( !$wgDisableInternalSearch ) {
194 self
::$mList['Search'] = array( 'SpecialPage', 'Search' );
197 if( $wgEmailAuthentication ) {
198 self
::$mList['Confirmemail'] = 'EmailConfirmation';
199 self
::$mList['Invalidateemail'] = 'EmailInvalidation';
202 # Add extension special pages
203 self
::$mList = array_merge( self
::$mList, $wgSpecialPages );
206 # This hook can be used to remove undesired built-in special pages
207 wfRunHooks( 'SpecialPage_initList', array( &self
::$mList ) );
208 wfProfileOut( __METHOD__
);
211 static function initAliasList() {
212 if ( !is_null( self
::$mAliases ) ) {
217 $aliases = $wgContLang->getSpecialPageAliases();
218 $missingPages = self
::$mList;
219 self
::$mAliases = array();
220 foreach ( $aliases as $realName => $aliasList ) {
221 foreach ( $aliasList as $alias ) {
222 self
::$mAliases[$wgContLang->caseFold( $alias )] = $realName;
224 unset( $missingPages[$realName] );
226 foreach ( $missingPages as $name => $stuff ) {
227 self
::$mAliases[$wgContLang->caseFold( $name )] = $name;
232 * Given a special page alias, return the special page name.
233 * Returns false if there is no such alias.
235 static function resolveAlias( $alias ) {
238 if ( !self
::$mListInitialised ) self
::initList();
239 if ( is_null( self
::$mAliases ) ) self
::initAliasList();
240 $caseFoldedAlias = $wgContLang->caseFold( $alias );
241 if ( isset( self
::$mAliases[$caseFoldedAlias] ) ) {
242 return self
::$mAliases[$caseFoldedAlias];
249 * Given a special page name with a possible subpage, return an array
250 * where the first element is the special page name and the second is the
253 static function resolveAliasWithSubpage( $alias ) {
254 $bits = explode( '/', $alias, 2 );
255 $name = self
::resolveAlias( $bits[0] );
256 if( !isset( $bits[1] ) ) { // bug 2087
261 return array( $name, $par );
265 * Add a page to the list of valid special pages. This used to be the preferred
266 * method for adding special pages in extensions. It's now suggested that you add
267 * an associative record to $wgSpecialPages. This avoids autoloading SpecialPage.
269 * @param SpecialPage $page
272 static function addPage( &$page ) {
273 if ( !self
::$mListInitialised ) {
276 self
::$mList[$page->mName
] = $page;
280 * Add a page to a certain display group for Special:SpecialPages
282 * @param mixed $page (SpecialPage or string)
283 * @param string $group
286 static function setGroup( $page, $group ) {
287 global $wgSpecialPageGroups;
288 $name = is_object($page) ?
$page->mName
: $page;
289 $wgSpecialPageGroups[$name] = $group;
293 * Add a page to a certain display group for Special:SpecialPages
295 * @param SpecialPage $page
298 static function getGroup( &$page ) {
299 global $wgSpecialPageGroups;
300 static $specialPageGroupsCache = array();
301 if( isset($specialPageGroupsCache[$page->mName
]) ) {
302 return $specialPageGroupsCache[$page->mName
];
304 $group = wfMsg('specialpages-specialpagegroup-'.strtolower($page->mName
));
306 ||
wfEmptyMsg('specialpages-specialpagegroup-'.strtolower($page->mName
), $group ) ) {
307 $group = isset($wgSpecialPageGroups[$page->mName
])
308 ?
$wgSpecialPageGroups[$page->mName
]
311 if( $group == '-' ) $group = 'other';
312 $specialPageGroupsCache[$page->mName
] = $group;
317 * Remove a special page from the list
318 * Formerly used to disable expensive or dangerous special pages. The
319 * preferred method is now to add a SpecialPage_initList hook.
323 static function removePage( $name ) {
324 if ( !self
::$mListInitialised ) {
327 unset( self
::$mList[$name] );
331 * Check if a given name exist as a special page or as a special page alias
332 * @param $name string: name of a special page
333 * @return boolean: true if a special page exists with this name
335 static function exists( $name ) {
337 if ( !self
::$mListInitialised ) {
340 if( !self
::$mAliases ) {
341 self
::initAliasList();
344 # Remove special pages inline parameters:
345 $bits = explode( '/', $name );
346 $name = $wgContLang->caseFold($bits[0]);
349 array_key_exists( $name, self
::$mList )
350 or array_key_exists( $name, self
::$mAliases )
355 * Find the object with a given name and return it (or NULL)
357 * @param string $name
359 static function getPage( $name ) {
360 if ( !self
::$mListInitialised ) {
363 if ( array_key_exists( $name, self
::$mList ) ) {
364 $rec = self
::$mList[$name];
365 if ( is_string( $rec ) ) {
367 self
::$mList[$name] = new $className;
368 } elseif ( is_array( $rec ) ) {
369 $className = array_shift( $rec );
370 self
::$mList[$name] = wfCreateObject( $className, $rec );
372 return self
::$mList[$name];
379 * Get a special page with a given localised name, or NULL if there
380 * is no such special page.
382 static function getPageByAlias( $alias ) {
383 $realName = self
::resolveAlias( $alias );
385 return self
::getPage( $realName );
392 * Return categorised listable special pages which are available
393 * for the current user, and everyone.
396 static function getUsablePages() {
398 if ( !self
::$mListInitialised ) {
403 foreach ( self
::$mList as $name => $rec ) {
404 $page = self
::getPage( $name );
405 if ( $page->isListed()
407 !$page->isRestricted()
408 ||
$page->userCanExecute( $wgUser )
411 $pages[$name] = $page;
418 * Return categorised listable special pages for all users
421 static function getRegularPages() {
422 if ( !self
::$mListInitialised ) {
427 foreach ( self
::$mList as $name => $rec ) {
428 $page = self
::getPage( $name );
429 if ( $page->isListed() && !$page->isRestricted() ) {
430 $pages[$name] = $page;
437 * Return categorised listable special pages which are available
438 * for the current user, but not for everyone
441 static function getRestrictedPages() {
443 if( !self
::$mListInitialised ) {
448 foreach( self
::$mList as $name => $rec ) {
449 $page = self
::getPage( $name );
452 && $page->isRestricted()
453 && $page->userCanExecute( $wgUser )
455 $pages[$name] = $page;
462 * Execute a special page path.
463 * The path may contain parameters, e.g. Special:Name/Params
464 * Extracts the special page name and call the execute method, passing the parameters
466 * Returns a title object if the page is redirected, false if there was no such special
467 * page, and true if it was successful.
469 * @param $title a title object
470 * @param $including output is being captured for use in {{special:whatever}}
472 static function executePath( &$title, $including = false ) {
473 global $wgOut, $wgTitle, $wgRequest;
474 wfProfileIn( __METHOD__
);
476 # FIXME: redirects broken due to this call
477 $bits = explode( '/', $title->getDBkey(), 2 );
479 if( !isset( $bits[1] ) ) { // bug 2087
484 $page = SpecialPage
::getPageByAlias( $name );
488 $wgOut->setArticleRelated( false );
489 $wgOut->setRobotPolicy( 'noindex,nofollow' );
490 $wgOut->setStatusCode( 404 );
491 $wgOut->showErrorPage( 'nosuchspecialpage', 'nospecialpagetext' );
493 wfProfileOut( __METHOD__
);
499 $redirect = $page->getRedirect( $par );
501 $query = $page->getRedirectQuery();
502 $url = $redirect->getFullUrl( $query );
503 $wgOut->redirect( $url );
504 wfProfileOut( __METHOD__
);
509 # Redirect to canonical alias for GET commands
510 # Not for POST, we'd lose the post data, so it's best to just distribute
511 # the request. Such POST requests are possible for old extensions that
512 # generate self-links without being aware that their default name has
514 if ( !$including && $name != $page->getLocalName() && !$wgRequest->wasPosted() ) {
516 unset( $query['title'] );
517 $query = wfArrayToCGI( $query );
518 $title = $page->getTitle( $par );
519 $url = $title->getFullUrl( $query );
520 $wgOut->redirect( $url );
521 wfProfileOut( __METHOD__
);
525 if ( $including && !$page->includable() ) {
526 wfProfileOut( __METHOD__
);
528 } elseif ( !$including ) {
529 $wgTitle = $page->getTitle();
531 $page->including( $including );
533 // Execute special page
534 $profName = 'Special:' . $page->getName();
535 wfProfileIn( $profName );
536 $page->execute( $par );
537 wfProfileOut( $profName );
538 wfProfileOut( __METHOD__
);
543 * Just like executePath() except it returns the HTML instead of outputting it
544 * Returns false if there was no such special page, or a title object if it was
548 static function capturePath( &$title ) {
549 global $wgOut, $wgTitle;
551 $oldTitle = $wgTitle;
553 $wgOut = new OutputPage
;
555 $ret = SpecialPage
::executePath( $title, true );
556 if ( $ret === true ) {
557 $ret = $wgOut->getHTML();
559 $wgTitle = $oldTitle;
565 * Get the local name for a specified canonical name
568 * @param mixed $subpage Boolean false, or string
572 static function getLocalNameFor( $name, $subpage = false ) {
574 $aliases = $wgContLang->getSpecialPageAliases();
575 if ( isset( $aliases[$name][0] ) ) {
576 $name = $aliases[$name][0];
578 if ( $subpage !== false && !is_null( $subpage ) ) {
579 $name = "$name/$subpage";
585 * Get a localised Title object for a specified special page name
587 static function getTitleFor( $name, $subpage = false ) {
588 $name = self
::getLocalNameFor( $name, $subpage );
590 return Title
::makeTitle( NS_SPECIAL
, $name );
592 throw new MWException( "Invalid special page name \"$name\"" );
597 * Get a localised Title object for a page name with a possibly unvalidated subpage
599 static function getSafeTitleFor( $name, $subpage = false ) {
600 $name = self
::getLocalNameFor( $name, $subpage );
602 return Title
::makeTitleSafe( NS_SPECIAL
, $name );
609 * Get a title for a given alias
610 * @return Title or null if there is no such alias
612 static function getTitleForAlias( $alias ) {
613 $name = self
::resolveAlias( $alias );
615 return self
::getTitleFor( $name );
622 * Default constructor for special pages
623 * Derivative classes should call this from their constructor
624 * Note that if the user does not have the required level, an error message will
625 * be displayed by the default execute() method, without the global function ever
628 * If you override execute(), you can recover the default behaviour with userCanExecute()
629 * and displayRestrictionError()
631 * @param string $name Name of the special page, as seen in links and URLs
632 * @param string $restriction User right required, e.g. "block" or "delete"
633 * @param boolean $listed Whether the page is listed in Special:Specialpages
634 * @param string $function Function called by execute(). By default it is constructed from $name
635 * @param string $file File which is included by execute(). It is also constructed from $name by default
637 function SpecialPage( $name = '', $restriction = '', $listed = true, $function = false, $file = 'default', $includable = false ) {
638 $this->mName
= $name;
639 $this->mRestriction
= $restriction;
640 $this->mListed
= $listed;
641 $this->mIncludable
= $includable;
642 if ( $function == false ) {
643 $this->mFunction
= 'wfSpecial'.$name;
645 $this->mFunction
= $function;
647 if ( $file === 'default' ) {
648 $this->mFile
= dirname(__FILE__
) . "/specials/Special$name.php";
650 $this->mFile
= $file;
659 function getName() { return $this->mName
; }
660 function getRestriction() { return $this->mRestriction
; }
661 function getFile() { return $this->mFile
; }
662 function isListed() { return $this->mListed
; }
666 * Accessor and mutator
668 function name( $x = NULL ) { return wfSetVar( $this->mName
, $x ); }
669 function restrictions( $x = NULL) { return wfSetVar( $this->mRestrictions
, $x ); }
670 function listed( $x = NULL) { return wfSetVar( $this->mListed
, $x ); }
671 function func( $x = NULL) { return wfSetVar( $this->mFunction
, $x ); }
672 function file( $x = NULL) { return wfSetVar( $this->mFile
, $x ); }
673 function includable( $x = NULL ) { return wfSetVar( $this->mIncludable
, $x ); }
674 function including( $x = NULL ) { return wfSetVar( $this->mIncluding
, $x ); }
678 * Get the localised name of the special page
680 function getLocalName() {
681 if ( !isset( $this->mLocalName
) ) {
682 $this->mLocalName
= self
::getLocalNameFor( $this->mName
);
684 return $this->mLocalName
;
688 * Can be overridden by subclasses with more complicated permissions
691 * @return bool Should the page be displayed with the restricted-access
694 public function isRestricted() {
695 return $this->mRestriction
!= '';
699 * Checks if the given user (identified by an object) can execute this
700 * special page (as defined by $mRestriction). Can be overridden by sub-
701 * classes with more complicated permissions schemes.
703 * @param User $user The user to check
704 * @return bool Does the user have permission to view the page?
706 public function userCanExecute( $user ) {
707 return $user->isAllowed( $this->mRestriction
);
711 * Output an error message telling the user what access level they have to have
713 function displayRestrictionError() {
715 $wgOut->permissionRequired( $this->mRestriction
);
719 * Sets headers - this should be called from the execute() method of all derived classes!
721 function setHeaders() {
723 $wgOut->setArticleRelated( false );
724 $wgOut->setRobotPolicy( "noindex,nofollow" );
725 $wgOut->setPageTitle( $this->getDescription() );
729 * Default execute method
730 * Checks user permissions, calls the function given in mFunction
732 * This may be overridden by subclasses.
734 function execute( $par ) {
739 if ( $this->userCanExecute( $wgUser ) ) {
740 $func = $this->mFunction
;
741 // only load file if the function does not exist
742 if(!is_callable($func) and $this->mFile
) {
743 require_once( $this->mFile
);
745 # FIXME: these hooks are broken for extensions and anything else that subclasses SpecialPage.
746 if ( wfRunHooks( 'SpecialPageExecuteBeforeHeader', array( &$this, &$par, &$func ) ) )
747 $this->outputHeader();
748 if ( ! wfRunHooks( 'SpecialPageExecuteBeforePage', array( &$this, &$par, &$func ) ) )
750 call_user_func( $func, $par, $this );
751 if ( ! wfRunHooks( 'SpecialPageExecuteAfterPage', array( &$this, &$par, &$func ) ) )
754 $this->displayRestrictionError();
758 function outputHeader() {
759 global $wgOut, $wgContLang;
761 $msg = $wgContLang->lc( $this->name() ) . '-summary';
762 $out = wfMsgNoTrans( $msg );
763 if ( ! wfEmptyMsg( $msg, $out ) and $out !== '' and ! $this->including() ) {
764 $wgOut->addWikiMsg( $msg );
769 # Returns the name that goes in the <h1> in the special page itself, and also the name that
770 # will be listed in Special:Specialpages
772 # Derived classes can override this, but usually it is easier to keep the default behaviour.
773 # Messages can be added at run-time, see MessageCache.php
774 function getDescription() {
775 return wfMsg( strtolower( $this->mName
) );
779 * Get a self-referential title object
781 function getTitle( $subpage = false) {
782 return self
::getTitleFor( $this->mName
, $subpage );
786 * Set whether this page is listed in Special:Specialpages, at run-time
788 function setListed( $listed ) {
789 return wfSetVar( $this->mListed
, $listed );
793 * If the special page is a redirect, then get the Title object it redirects to.
796 function getRedirect( $subpage ) {
801 * Return part of the request string for a special redirect page
802 * This allows passing, e.g. action=history to Special:Mypage, etc.
806 function getRedirectQuery() {
809 foreach( $this->mAllowedRedirectParams
as $arg ) {
810 if( $val = $wgRequest->getVal( $arg, false ) )
811 $params[] = $arg . '=' . $val;
814 return count( $params ) ?
implode( '&', $params ) : false;
819 * Shortcut to construct a special page which is unlisted by default
820 * @ingroup SpecialPage
822 class UnlistedSpecialPage
extends SpecialPage
824 function UnlistedSpecialPage( $name, $restriction = '', $function = false, $file = 'default' ) {
825 SpecialPage
::SpecialPage( $name, $restriction, false, $function, $file );
830 * Shortcut to construct an includable special page
831 * @ingroup SpecialPage
833 class IncludableSpecialPage
extends SpecialPage
835 function IncludableSpecialPage( $name, $restriction = '', $listed = true, $function = false, $file = 'default' ) {
836 SpecialPage
::SpecialPage( $name, $restriction, $listed, $function, $file, true );
841 * Shortcut to construct a special page alias.
842 * @ingroup SpecialPage
844 class SpecialRedirectToSpecial
extends UnlistedSpecialPage
{
845 var $redirName, $redirSubpage;
847 function __construct( $name, $redirName, $redirSubpage = false, $redirectParams = array() ) {
848 parent
::__construct( $name );
849 $this->redirName
= $redirName;
850 $this->redirSubpage
= $redirSubpage;
851 $this->mAllowedRedirectParams
= $redirectParams;
854 function getRedirect( $subpage ) {
855 if ( $this->redirSubpage
=== false ) {
856 return SpecialPage
::getTitleFor( $this->redirName
, $subpage );
858 return SpecialPage
::getTitleFor( $this->redirName
, $this->redirSubpage
);
863 /** SpecialMypage, SpecialMytalk and SpecialMycontributions special pages
864 * are used to get user independant links pointing to the user page, talk
865 * page and list of contributions.
866 * This can let us cache a single copy of any generated content for all
871 * Shortcut to construct a special page pointing to current user user's page.
872 * @ingroup SpecialPage
874 class SpecialMypage
extends UnlistedSpecialPage
{
875 function __construct() {
876 parent
::__construct( 'Mypage' );
877 $this->mAllowedRedirectParams
= array( 'action' , 'preload' , 'editintro', 'section' );
880 function getRedirect( $subpage ) {
882 if ( strval( $subpage ) !== '' ) {
883 return Title
::makeTitle( NS_USER
, $wgUser->getName() . '/' . $subpage );
885 return Title
::makeTitle( NS_USER
, $wgUser->getName() );
891 * Shortcut to construct a special page pointing to current user talk page.
892 * @ingroup SpecialPage
894 class SpecialMytalk
extends UnlistedSpecialPage
{
895 function __construct() {
896 parent
::__construct( 'Mytalk' );
897 $this->mAllowedRedirectParams
= array( 'action' , 'preload' , 'editintro', 'section' );
900 function getRedirect( $subpage ) {
902 if ( strval( $subpage ) !== '' ) {
903 return Title
::makeTitle( NS_USER_TALK
, $wgUser->getName() . '/' . $subpage );
905 return Title
::makeTitle( NS_USER_TALK
, $wgUser->getName() );
911 * Shortcut to construct a special page pointing to current user contributions.
912 * @ingroup SpecialPage
914 class SpecialMycontributions
extends UnlistedSpecialPage
{
915 function __construct() {
916 parent
::__construct( 'Mycontributions' );
919 function getRedirect( $subpage ) {
921 return SpecialPage
::getTitleFor( 'Contributions', $wgUser->getName() );