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' ),
92 'Resetpass' => 'SpecialResetpass',
95 'Recentchanges' => 'SpecialRecentchanges',
96 'Upload' => array( 'SpecialPage', 'Upload' ),
97 'Listfiles' => array( 'SpecialPage', 'Listfiles' ),
98 'Newimages' => array( 'IncludableSpecialPage', 'Newimages' ),
99 'Listusers' => array( 'SpecialPage', 'Listusers' ),
100 'Listgrouprights' => 'SpecialListGroupRights',
101 'DeletedContributions' => 'DeletedContributionsPage',
102 'Statistics' => 'SpecialStatistics',
103 'Randompage' => 'Randompage',
104 'Lonelypages' => array( 'SpecialPage', 'Lonelypages' ),
105 'Uncategorizedpages' => array( 'SpecialPage', 'Uncategorizedpages' ),
106 'Uncategorizedcategories' => array( 'SpecialPage', 'Uncategorizedcategories' ),
107 'Uncategorizedimages' => array( 'SpecialPage', 'Uncategorizedimages' ),
108 'Uncategorizedtemplates' => array( 'SpecialPage', 'Uncategorizedtemplates' ),
109 'Unusedcategories' => array( 'SpecialPage', 'Unusedcategories' ),
110 'Unusedimages' => array( 'SpecialPage', 'Unusedimages' ),
111 'Wantedpages' => array( 'IncludableSpecialPage', 'Wantedpages' ),
112 'Wantedcategories' => array( 'SpecialPage', 'Wantedcategories' ),
113 'Wantedfiles' => array( 'SpecialPage', 'Wantedfiles' ),
114 'Wantedtemplates' => array( 'SpecialPage', 'Wantedtemplates' ),
115 'Mostlinked' => array( 'SpecialPage', 'Mostlinked' ),
116 'Mostlinkedcategories' => array( 'SpecialPage', 'Mostlinkedcategories' ),
117 'Mostlinkedtemplates' => array( 'SpecialPage', 'Mostlinkedtemplates' ),
118 'Mostcategories' => array( 'SpecialPage', 'Mostcategories' ),
119 'Mostimages' => array( 'SpecialPage', 'Mostimages' ),
120 'Mostrevisions' => array( 'SpecialPage', 'Mostrevisions' ),
121 'Fewestrevisions' => array( 'SpecialPage', 'Fewestrevisions' ),
122 'Shortpages' => array( 'SpecialPage', 'Shortpages' ),
123 'Longpages' => array( 'SpecialPage', 'Longpages' ),
124 'Newpages' => 'SpecialNewpages',
125 'Ancientpages' => array( 'SpecialPage', 'Ancientpages' ),
126 'Deadendpages' => array( 'SpecialPage', 'Deadendpages' ),
127 'Protectedpages' => array( 'SpecialPage', 'Protectedpages' ),
128 'Protectedtitles' => array( 'SpecialPage', 'Protectedtitles' ),
129 'Allpages' => 'SpecialAllpages',
130 'Prefixindex' => 'SpecialPrefixindex',
131 'Ipblocklist' => array( 'SpecialPage', 'Ipblocklist' ),
132 'Specialpages' => array( 'UnlistedSpecialPage', 'Specialpages' ),
133 'Contributions' => 'SpecialContributions',
134 'Emailuser' => array( 'UnlistedSpecialPage', 'Emailuser' ),
135 'Whatlinkshere' => array( 'SpecialPage', 'Whatlinkshere' ),
136 'LinkSearch' => array( 'SpecialPage', 'LinkSearch' ),
137 'Recentchangeslinked' => 'SpecialRecentchangeslinked',
138 'Movepage' => array( 'UnlistedSpecialPage', 'Movepage' ),
139 'Blockme' => array( 'UnlistedSpecialPage', 'Blockme' ),
140 'Booksources' => 'SpecialBookSources',
141 'Categories' => array( 'SpecialPage', 'Categories' ),
142 'Export' => array( 'SpecialPage', 'Export' ),
143 'Version' => 'SpecialVersion',
144 'Blankpage' => array( 'UnlistedSpecialPage', 'Blankpage' ),
145 'Allmessages' => array( 'SpecialPage', 'Allmessages' ),
146 'Log' => array( 'SpecialPage', 'Log' ),
147 'Blockip' => array( 'SpecialPage', 'Blockip', 'block' ),
148 'Undelete' => array( 'SpecialPage', 'Undelete', 'deletedhistory' ),
149 'Import' => 'SpecialImport',
150 'Lockdb' => array( 'SpecialPage', 'Lockdb', 'siteadmin' ),
151 'Unlockdb' => array( 'SpecialPage', 'Unlockdb', 'siteadmin' ),
152 'Userrights' => 'UserrightsPage',
153 'MIMEsearch' => array( 'SpecialPage', 'MIMEsearch' ),
154 'FileDuplicateSearch' => array( 'SpecialPage', 'FileDuplicateSearch' ),
155 'Unwatchedpages' => array( 'SpecialPage', 'Unwatchedpages', 'unwatchedpages' ),
156 'Listredirects' => array( 'SpecialPage', 'Listredirects' ),
157 'Revisiondelete' => array( 'UnlistedSpecialPage', 'Revisiondelete', 'deleterevision' ),
158 'Unusedtemplates' => array( 'SpecialPage', 'Unusedtemplates' ),
159 'Randomredirect' => 'SpecialRandomredirect',
160 'Withoutinterwiki' => array( 'SpecialPage', 'Withoutinterwiki' ),
161 'Filepath' => array( 'SpecialPage', 'Filepath' ),
162 'Tags' => 'SpecialTags',
164 'Mypage' => array( 'SpecialMypage' ),
165 'Mytalk' => array( 'SpecialMytalk' ),
166 'Mycontributions' => array( 'SpecialMycontributions' ),
167 'Listadmins' => array( 'SpecialRedirectToSpecial', 'Listadmins', 'Listusers', 'sysop' ),
168 'MergeHistory' => array( 'SpecialPage', 'MergeHistory', 'mergehistory' ),
169 'Listbots' => array( 'SpecialRedirectToSpecial', 'Listbots', 'Listusers', 'bot' ),
172 static public $mAliases;
173 static public $mListInitialised = false;
178 * Initialise the special page list
179 * This must be called before accessing SpecialPage::$mList
181 static function initList() {
182 global $wgSpecialPages;
183 global $wgDisableCounters, $wgDisableInternalSearch, $wgEmailAuthentication;
185 if ( self
::$mListInitialised ) {
188 wfProfileIn( __METHOD__
);
190 # Better to set this now, to avoid infinite recursion in carelessly written hooks
191 self
::$mListInitialised = true;
193 if( !$wgDisableCounters ) {
194 self
::$mList['Popularpages'] = array( 'SpecialPage', 'Popularpages' );
197 if( !$wgDisableInternalSearch ) {
198 self
::$mList['Search'] = array( 'SpecialPage', 'Search' );
201 if( $wgEmailAuthentication ) {
202 self
::$mList['Confirmemail'] = 'EmailConfirmation';
203 self
::$mList['Invalidateemail'] = 'EmailInvalidation';
206 # Add extension special pages
207 self
::$mList = array_merge( self
::$mList, $wgSpecialPages );
210 # This hook can be used to remove undesired built-in special pages
211 wfRunHooks( 'SpecialPage_initList', array( &self
::$mList ) );
212 wfProfileOut( __METHOD__
);
215 static function initAliasList() {
216 if ( !is_null( self
::$mAliases ) ) {
221 $aliases = $wgContLang->getSpecialPageAliases();
222 $missingPages = self
::$mList;
223 self
::$mAliases = array();
224 foreach ( $aliases as $realName => $aliasList ) {
225 foreach ( $aliasList as $alias ) {
226 self
::$mAliases[$wgContLang->caseFold( $alias )] = $realName;
228 unset( $missingPages[$realName] );
230 foreach ( $missingPages as $name => $stuff ) {
231 self
::$mAliases[$wgContLang->caseFold( $name )] = $name;
236 * Given a special page alias, return the special page name.
237 * Returns false if there is no such alias.
239 static function resolveAlias( $alias ) {
242 if ( !self
::$mListInitialised ) self
::initList();
243 if ( is_null( self
::$mAliases ) ) self
::initAliasList();
244 $caseFoldedAlias = $wgContLang->caseFold( $alias );
245 if ( isset( self
::$mAliases[$caseFoldedAlias] ) ) {
246 return self
::$mAliases[$caseFoldedAlias];
253 * Given a special page name with a possible subpage, return an array
254 * where the first element is the special page name and the second is the
257 static function resolveAliasWithSubpage( $alias ) {
258 $bits = explode( '/', $alias, 2 );
259 $name = self
::resolveAlias( $bits[0] );
260 if( !isset( $bits[1] ) ) { // bug 2087
265 return array( $name, $par );
269 * Add a page to the list of valid special pages. This used to be the preferred
270 * method for adding special pages in extensions. It's now suggested that you add
271 * an associative record to $wgSpecialPages. This avoids autoloading SpecialPage.
273 * @param SpecialPage $page
276 static function addPage( &$page ) {
277 if ( !self
::$mListInitialised ) {
280 self
::$mList[$page->mName
] = $page;
284 * Add a page to a certain display group for Special:SpecialPages
286 * @param mixed $page (SpecialPage or string)
287 * @param string $group
290 static function setGroup( $page, $group ) {
291 global $wgSpecialPageGroups;
292 $name = is_object($page) ?
$page->mName
: $page;
293 $wgSpecialPageGroups[$name] = $group;
297 * Add a page to a certain display group for Special:SpecialPages
299 * @param SpecialPage $page
302 static function getGroup( &$page ) {
303 global $wgSpecialPageGroups;
304 static $specialPageGroupsCache = array();
305 if( isset($specialPageGroupsCache[$page->mName
]) ) {
306 return $specialPageGroupsCache[$page->mName
];
308 $group = wfMsg('specialpages-specialpagegroup-'.strtolower($page->mName
));
310 ||
wfEmptyMsg('specialpages-specialpagegroup-'.strtolower($page->mName
), $group ) ) {
311 $group = isset($wgSpecialPageGroups[$page->mName
])
312 ?
$wgSpecialPageGroups[$page->mName
]
315 if( $group == '-' ) $group = 'other';
316 $specialPageGroupsCache[$page->mName
] = $group;
321 * Remove a special page from the list
322 * Formerly used to disable expensive or dangerous special pages. The
323 * preferred method is now to add a SpecialPage_initList hook.
327 static function removePage( $name ) {
328 if ( !self
::$mListInitialised ) {
331 unset( self
::$mList[$name] );
335 * Check if a given name exist as a special page or as a special page alias
336 * @param $name string: name of a special page
337 * @return boolean: true if a special page exists with this name
339 static function exists( $name ) {
341 if ( !self
::$mListInitialised ) {
344 if( !self
::$mAliases ) {
345 self
::initAliasList();
348 # Remove special pages inline parameters:
349 $bits = explode( '/', $name );
350 $name = $wgContLang->caseFold($bits[0]);
353 array_key_exists( $name, self
::$mList )
354 or array_key_exists( $name, self
::$mAliases )
359 * Find the object with a given name and return it (or NULL)
361 * @param string $name
363 static function getPage( $name ) {
364 if ( !self
::$mListInitialised ) {
367 if ( array_key_exists( $name, self
::$mList ) ) {
368 $rec = self
::$mList[$name];
369 if ( is_string( $rec ) ) {
371 self
::$mList[$name] = new $className;
372 } elseif ( is_array( $rec ) ) {
373 $className = array_shift( $rec );
374 self
::$mList[$name] = wfCreateObject( $className, $rec );
376 return self
::$mList[$name];
383 * Get a special page with a given localised name, or NULL if there
384 * is no such special page.
386 static function getPageByAlias( $alias ) {
387 $realName = self
::resolveAlias( $alias );
389 return self
::getPage( $realName );
396 * Return categorised listable special pages which are available
397 * for the current user, and everyone.
400 static function getUsablePages() {
402 if ( !self
::$mListInitialised ) {
407 foreach ( self
::$mList as $name => $rec ) {
408 $page = self
::getPage( $name );
409 if ( $page->isListed()
411 !$page->isRestricted()
412 ||
$page->userCanExecute( $wgUser )
415 $pages[$name] = $page;
422 * Return categorised listable special pages for all users
425 static function getRegularPages() {
426 if ( !self
::$mListInitialised ) {
431 foreach ( self
::$mList as $name => $rec ) {
432 $page = self
::getPage( $name );
433 if ( $page->isListed() && !$page->isRestricted() ) {
434 $pages[$name] = $page;
441 * Return categorised listable special pages which are available
442 * for the current user, but not for everyone
445 static function getRestrictedPages() {
447 if( !self
::$mListInitialised ) {
452 foreach( self
::$mList as $name => $rec ) {
453 $page = self
::getPage( $name );
456 && $page->isRestricted()
457 && $page->userCanExecute( $wgUser )
459 $pages[$name] = $page;
466 * Execute a special page path.
467 * The path may contain parameters, e.g. Special:Name/Params
468 * Extracts the special page name and call the execute method, passing the parameters
470 * Returns a title object if the page is redirected, false if there was no such special
471 * page, and true if it was successful.
473 * @param $title a title object
474 * @param $including output is being captured for use in {{special:whatever}}
476 static function executePath( &$title, $including = false ) {
477 global $wgOut, $wgTitle, $wgRequest;
478 wfProfileIn( __METHOD__
);
480 # FIXME: redirects broken due to this call
481 $bits = explode( '/', $title->getDBkey(), 2 );
483 if( !isset( $bits[1] ) ) { // bug 2087
488 $page = SpecialPage
::getPageByAlias( $name );
492 $wgOut->setArticleRelated( false );
493 $wgOut->setRobotPolicy( 'noindex,nofollow' );
494 $wgOut->setStatusCode( 404 );
495 $wgOut->showErrorPage( 'nosuchspecialpage', 'nospecialpagetext' );
497 wfProfileOut( __METHOD__
);
503 $redirect = $page->getRedirect( $par );
505 $query = $page->getRedirectQuery();
506 $url = $redirect->getFullUrl( $query );
507 $wgOut->redirect( $url );
508 wfProfileOut( __METHOD__
);
513 # Redirect to canonical alias for GET commands
514 # Not for POST, we'd lose the post data, so it's best to just distribute
515 # the request. Such POST requests are possible for old extensions that
516 # generate self-links without being aware that their default name has
518 if ( !$including && $name != $page->getLocalName() && !$wgRequest->wasPosted() ) {
520 unset( $query['title'] );
521 $query = wfArrayToCGI( $query );
522 $title = $page->getTitle( $par );
523 $url = $title->getFullUrl( $query );
524 $wgOut->redirect( $url );
525 wfProfileOut( __METHOD__
);
529 if ( $including && !$page->includable() ) {
530 wfProfileOut( __METHOD__
);
532 } elseif ( !$including ) {
533 $wgTitle = $page->getTitle();
535 $page->including( $including );
537 // Execute special page
538 $profName = 'Special:' . $page->getName();
539 wfProfileIn( $profName );
540 $page->execute( $par );
541 wfProfileOut( $profName );
542 wfProfileOut( __METHOD__
);
547 * Just like executePath() except it returns the HTML instead of outputting it
548 * Returns false if there was no such special page, or a title object if it was
552 static function capturePath( &$title ) {
553 global $wgOut, $wgTitle;
555 $oldTitle = $wgTitle;
557 $wgOut = new OutputPage
;
559 $ret = SpecialPage
::executePath( $title, true );
560 if ( $ret === true ) {
561 $ret = $wgOut->getHTML();
563 $wgTitle = $oldTitle;
569 * Get the local name for a specified canonical name
572 * @param mixed $subpage Boolean false, or string
576 static function getLocalNameFor( $name, $subpage = false ) {
578 $aliases = $wgContLang->getSpecialPageAliases();
579 if ( isset( $aliases[$name][0] ) ) {
580 $name = $aliases[$name][0];
582 if ( $subpage !== false && !is_null( $subpage ) ) {
583 $name = "$name/$subpage";
585 return ucfirst( $name );
589 * Get a localised Title object for a specified special page name
591 static function getTitleFor( $name, $subpage = false ) {
592 $name = self
::getLocalNameFor( $name, $subpage );
594 return Title
::makeTitle( NS_SPECIAL
, $name );
596 throw new MWException( "Invalid special page name \"$name\"" );
601 * Get a localised Title object for a page name with a possibly unvalidated subpage
603 static function getSafeTitleFor( $name, $subpage = false ) {
604 $name = self
::getLocalNameFor( $name, $subpage );
606 return Title
::makeTitleSafe( NS_SPECIAL
, $name );
613 * Get a title for a given alias
614 * @return Title or null if there is no such alias
616 static function getTitleForAlias( $alias ) {
617 $name = self
::resolveAlias( $alias );
619 return self
::getTitleFor( $name );
626 * Default constructor for special pages
627 * Derivative classes should call this from their constructor
628 * Note that if the user does not have the required level, an error message will
629 * be displayed by the default execute() method, without the global function ever
632 * If you override execute(), you can recover the default behaviour with userCanExecute()
633 * and displayRestrictionError()
635 * @param string $name Name of the special page, as seen in links and URLs
636 * @param string $restriction User right required, e.g. "block" or "delete"
637 * @param boolean $listed Whether the page is listed in Special:Specialpages
638 * @param string $function Function called by execute(). By default it is constructed from $name
639 * @param string $file File which is included by execute(). It is also constructed from $name by default
641 function SpecialPage( $name = '', $restriction = '', $listed = true, $function = false, $file = 'default', $includable = false ) {
642 $this->mName
= $name;
643 $this->mRestriction
= $restriction;
644 $this->mListed
= $listed;
645 $this->mIncludable
= $includable;
646 if ( $function == false ) {
647 $this->mFunction
= 'wfSpecial'.$name;
649 $this->mFunction
= $function;
651 if ( $file === 'default' ) {
652 $this->mFile
= dirname(__FILE__
) . "/specials/Special$name.php";
654 $this->mFile
= $file;
663 function getName() { return $this->mName
; }
664 function getRestriction() { return $this->mRestriction
; }
665 function getFile() { return $this->mFile
; }
666 function isListed() { return $this->mListed
; }
670 * Accessor and mutator
672 function name( $x = NULL ) { return wfSetVar( $this->mName
, $x ); }
673 function restrictions( $x = NULL) { return wfSetVar( $this->mRestrictions
, $x ); }
674 function listed( $x = NULL) { return wfSetVar( $this->mListed
, $x ); }
675 function func( $x = NULL) { return wfSetVar( $this->mFunction
, $x ); }
676 function file( $x = NULL) { return wfSetVar( $this->mFile
, $x ); }
677 function includable( $x = NULL ) { return wfSetVar( $this->mIncludable
, $x ); }
678 function including( $x = NULL ) { return wfSetVar( $this->mIncluding
, $x ); }
682 * Get the localised name of the special page
684 function getLocalName() {
685 if ( !isset( $this->mLocalName
) ) {
686 $this->mLocalName
= self
::getLocalNameFor( $this->mName
);
688 return $this->mLocalName
;
692 * Can be overridden by subclasses with more complicated permissions
695 * @return bool Should the page be displayed with the restricted-access
698 public function isRestricted() {
699 return $this->mRestriction
!= '';
703 * Checks if the given user (identified by an object) can execute this
704 * special page (as defined by $mRestriction). Can be overridden by sub-
705 * classes with more complicated permissions schemes.
707 * @param User $user The user to check
708 * @return bool Does the user have permission to view the page?
710 public function userCanExecute( $user ) {
711 return $user->isAllowed( $this->mRestriction
);
715 * Output an error message telling the user what access level they have to have
717 function displayRestrictionError() {
719 $wgOut->permissionRequired( $this->mRestriction
);
723 * Sets headers - this should be called from the execute() method of all derived classes!
725 function setHeaders() {
727 $wgOut->setArticleRelated( false );
728 $wgOut->setRobotPolicy( "noindex,nofollow" );
729 $wgOut->setPageTitle( $this->getDescription() );
733 * Default execute method
734 * Checks user permissions, calls the function given in mFunction
736 * This may be overridden by subclasses.
738 function execute( $par ) {
743 if ( $this->userCanExecute( $wgUser ) ) {
744 $func = $this->mFunction
;
745 // only load file if the function does not exist
746 if(!is_callable($func) and $this->mFile
) {
747 require_once( $this->mFile
);
749 $this->outputHeader();
750 call_user_func( $func, $par, $this );
752 $this->displayRestrictionError();
756 function outputHeader() {
757 global $wgOut, $wgContLang;
759 $msg = $wgContLang->lc( $this->name() ) . '-summary';
760 $out = wfMsgNoTrans( $msg );
761 if ( ! wfEmptyMsg( $msg, $out ) and $out !== '' and ! $this->including() ) {
762 $wgOut->addWikiMsg( $msg );
767 # Returns the name that goes in the <h1> in the special page itself, and also the name that
768 # will be listed in Special:Specialpages
770 # Derived classes can override this, but usually it is easier to keep the default behaviour.
771 # Messages can be added at run-time, see MessageCache.php
772 function getDescription() {
773 return wfMsg( strtolower( $this->mName
) );
777 * Get a self-referential title object
779 function getTitle( $subpage = false) {
780 return self
::getTitleFor( $this->mName
, $subpage );
784 * Set whether this page is listed in Special:Specialpages, at run-time
786 function setListed( $listed ) {
787 return wfSetVar( $this->mListed
, $listed );
791 * If the special page is a redirect, then get the Title object it redirects to.
794 function getRedirect( $subpage ) {
799 * Return part of the request string for a special redirect page
800 * This allows passing, e.g. action=history to Special:Mypage, etc.
804 function getRedirectQuery() {
807 foreach( $this->mAllowedRedirectParams
as $arg ) {
808 if( $val = $wgRequest->getVal( $arg, false ) )
809 $params[] = $arg . '=' . $val;
812 return count( $params ) ?
implode( '&', $params ) : false;
817 * Shortcut to construct a special page which is unlisted by default
818 * @ingroup SpecialPage
820 class UnlistedSpecialPage
extends SpecialPage
822 function UnlistedSpecialPage( $name, $restriction = '', $function = false, $file = 'default' ) {
823 SpecialPage
::SpecialPage( $name, $restriction, false, $function, $file );
828 * Shortcut to construct an includable special page
829 * @ingroup SpecialPage
831 class IncludableSpecialPage
extends SpecialPage
833 function IncludableSpecialPage( $name, $restriction = '', $listed = true, $function = false, $file = 'default' ) {
834 SpecialPage
::SpecialPage( $name, $restriction, $listed, $function, $file, true );
839 * Shortcut to construct a special page alias.
840 * @ingroup SpecialPage
842 class SpecialRedirectToSpecial
extends UnlistedSpecialPage
{
843 var $redirName, $redirSubpage;
845 function __construct( $name, $redirName, $redirSubpage = false, $redirectParams = array() ) {
846 parent
::__construct( $name );
847 $this->redirName
= $redirName;
848 $this->redirSubpage
= $redirSubpage;
849 $this->mAllowedRedirectParams
= $redirectParams;
852 function getRedirect( $subpage ) {
853 if ( $this->redirSubpage
=== false ) {
854 return SpecialPage
::getTitleFor( $this->redirName
, $subpage );
856 return SpecialPage
::getTitleFor( $this->redirName
, $this->redirSubpage
);
861 /** SpecialMypage, SpecialMytalk and SpecialMycontributions special pages
862 * are used to get user independant links pointing to the user page, talk
863 * page and list of contributions.
864 * This can let us cache a single copy of any generated content for all
869 * Shortcut to construct a special page pointing to current user user's page.
870 * @ingroup SpecialPage
872 class SpecialMypage
extends UnlistedSpecialPage
{
873 function __construct() {
874 parent
::__construct( 'Mypage' );
875 $this->mAllowedRedirectParams
= array( 'action' , 'preload' , 'editintro', 'section' );
878 function getRedirect( $subpage ) {
880 if ( strval( $subpage ) !== '' ) {
881 return Title
::makeTitle( NS_USER
, $wgUser->getName() . '/' . $subpage );
883 return Title
::makeTitle( NS_USER
, $wgUser->getName() );
889 * Shortcut to construct a special page pointing to current user talk page.
890 * @ingroup SpecialPage
892 class SpecialMytalk
extends UnlistedSpecialPage
{
893 function __construct() {
894 parent
::__construct( 'Mytalk' );
895 $this->mAllowedRedirectParams
= array( 'action' , 'preload' , 'editintro', 'section' );
898 function getRedirect( $subpage ) {
900 if ( strval( $subpage ) !== '' ) {
901 return Title
::makeTitle( NS_USER_TALK
, $wgUser->getName() . '/' . $subpage );
903 return Title
::makeTitle( NS_USER_TALK
, $wgUser->getName() );
909 * Shortcut to construct a special page pointing to current user contributions.
910 * @ingroup SpecialPage
912 class SpecialMycontributions
extends UnlistedSpecialPage
{
913 function __construct() {
914 parent
::__construct( 'Mycontributions' );
917 function getRedirect( $subpage ) {
919 return SpecialPage
::getTitleFor( 'Contributions', $wgUser->getName() );