3 * SpecialPage: handling special pages and lists thereof.
5 * To add a special page in an extension, add to $wgSpecialPages either
6 * an object instance or an array containing the name and constructor
7 * parameters. The latter is preferred for performance reasons.
9 * The object instantiated must be either an instance of SpecialPage or a
10 * sub-class thereof. It must have an execute() method, which sends the HTML
11 * for the special page to $wgOut. The parent class has an execute() method
12 * which distributes the call to the historical global functions. Additionally,
13 * execute() also checks if the user has the necessary access privileges
14 * and bails out if not.
16 * To add a core special page, use the similar static list in
17 * SpecialPage::$mList. To remove a core static special page at runtime, use
18 * a SpecialPage_initList hook.
20 * @addtogroup SpecialPage
28 * Parent special page class, also static functions for handling the special
30 * @addtogroup SpecialPage
38 * The canonical name of this special page
39 * Also used for the default <h1> heading, @see getDescription()
43 * The local name of this special page
47 * Minimum user level required to access this page, or "" for anyone.
48 * Also used to categorise the pages in Special:Specialpages
52 * Listed in Special:Specialpages?
56 * Function name called by the default execute()
60 * File which needs to be included before the function above can be called
64 * Whether or not this special page is being included from an article
68 * Whether the special page can be included in an article
72 * Query parameters that can be passed through redirects
74 var $mAllowedRedirectParams = array();
76 static public $mList = array(
77 'DoubleRedirects' => array( 'SpecialPage', 'DoubleRedirects' ),
78 'BrokenRedirects' => array( 'SpecialPage', 'BrokenRedirects' ),
79 'Disambiguations' => array( 'SpecialPage', 'Disambiguations' ),
81 'Userlogin' => array( 'SpecialPage', 'Userlogin' ),
82 'Userlogout' => array( 'UnlistedSpecialPage', 'Userlogout' ),
83 'CreateAccount' => array( 'SpecialRedirectToSpecial', 'CreateAccount', 'Userlogin', 'signup', array( 'uselang' ) ),
84 'Preferences' => array( 'SpecialPage', 'Preferences' ),
85 'Watchlist' => array( 'SpecialPage', 'Watchlist' ),
87 'Recentchanges' => array( 'IncludableSpecialPage', 'Recentchanges' ),
88 'Upload' => array( 'SpecialPage', 'Upload' ),
89 'Imagelist' => array( 'SpecialPage', 'Imagelist' ),
90 'Newimages' => array( 'IncludableSpecialPage', 'Newimages' ),
91 'Listusers' => array( 'SpecialPage', 'Listusers' ),
92 'Statistics' => array( 'SpecialPage', 'Statistics' ),
93 'Randompage' => 'Randompage',
94 'Lonelypages' => array( 'SpecialPage', 'Lonelypages' ),
95 'Uncategorizedpages' => array( 'SpecialPage', 'Uncategorizedpages' ),
96 'Uncategorizedcategories' => array( 'SpecialPage', 'Uncategorizedcategories' ),
97 'Uncategorizedimages' => array( 'SpecialPage', 'Uncategorizedimages' ),
98 'Uncategorizedtemplates' => array( 'SpecialPage', 'Uncategorizedtemplates' ),
99 'Unusedcategories' => array( 'SpecialPage', 'Unusedcategories' ),
100 'Unusedimages' => array( 'SpecialPage', 'Unusedimages' ),
101 'Wantedpages' => array( 'IncludableSpecialPage', 'Wantedpages' ),
102 'Wantedcategories' => array( 'SpecialPage', 'Wantedcategories' ),
103 'Mostlinked' => array( 'SpecialPage', 'Mostlinked' ),
104 'Mostlinkedcategories' => array( 'SpecialPage', 'Mostlinkedcategories' ),
105 'Mostlinkedtemplates' => array( 'SpecialPage', 'Mostlinkedtemplates' ),
106 'Mostcategories' => array( 'SpecialPage', 'Mostcategories' ),
107 'Mostimages' => array( 'SpecialPage', 'Mostimages' ),
108 'Mostrevisions' => array( 'SpecialPage', 'Mostrevisions' ),
109 'Fewestrevisions' => array( 'SpecialPage', 'Fewestrevisions' ),
110 'Shortpages' => array( 'SpecialPage', 'Shortpages' ),
111 'Longpages' => array( 'SpecialPage', 'Longpages' ),
112 'Newpages' => array( 'IncludableSpecialPage', 'Newpages' ),
113 'Ancientpages' => array( 'SpecialPage', 'Ancientpages' ),
114 'Deadendpages' => array( 'SpecialPage', 'Deadendpages' ),
115 'Protectedpages' => array( 'SpecialPage', 'Protectedpages' ),
116 'Protectedtitles' => array( 'SpecialPage', 'Protectedtitles' ),
117 'Allpages' => array( 'IncludableSpecialPage', 'Allpages' ),
118 'Prefixindex' => array( 'IncludableSpecialPage', 'Prefixindex' ) ,
119 'Ipblocklist' => array( 'SpecialPage', 'Ipblocklist' ),
120 'Specialpages' => array( 'UnlistedSpecialPage', 'Specialpages' ),
121 'Contributions' => array( 'SpecialPage', 'Contributions' ),
122 'Emailuser' => array( 'UnlistedSpecialPage', 'Emailuser' ),
123 'Whatlinkshere' => array( 'SpecialPage', 'Whatlinkshere' ),
124 'Recentchangeslinked' => array( 'UnlistedSpecialPage', 'Recentchangeslinked' ),
125 'Movepage' => array( 'UnlistedSpecialPage', 'Movepage' ),
126 'Blockme' => array( 'UnlistedSpecialPage', 'Blockme' ),
127 'Resetpass' => array( 'UnlistedSpecialPage', 'Resetpass' ),
128 'Booksources' => 'SpecialBookSources',
129 'Categories' => array( 'SpecialPage', 'Categories' ),
130 'Export' => array( 'SpecialPage', 'Export' ),
131 'Version' => array( 'SpecialPage', 'Version' ),
132 'Allmessages' => array( 'SpecialPage', 'Allmessages' ),
133 'Log' => array( 'SpecialPage', 'Log' ),
134 'Blockip' => array( 'SpecialPage', 'Blockip', 'block' ),
135 'Undelete' => array( 'SpecialPage', 'Undelete', 'deletedhistory' ),
136 'Import' => array( 'SpecialPage', 'Import', 'import' ),
137 'Lockdb' => array( 'SpecialPage', 'Lockdb', 'siteadmin' ),
138 'Unlockdb' => array( 'SpecialPage', 'Unlockdb', 'siteadmin' ),
139 'Userrights' => 'UserrightsPage',
140 'MIMEsearch' => array( 'SpecialPage', 'MIMEsearch' ),
141 'Unwatchedpages' => array( 'SpecialPage', 'Unwatchedpages', 'unwatchedpages' ),
142 'Listredirects' => array( 'SpecialPage', 'Listredirects' ),
143 'Revisiondelete' => array( 'UnlistedSpecialPage', 'Revisiondelete', 'deleterevision' ),
144 'Unusedtemplates' => array( 'SpecialPage', 'Unusedtemplates' ),
145 'Randomredirect' => 'SpecialRandomredirect',
146 'Withoutinterwiki' => array( 'SpecialPage', 'Withoutinterwiki' ),
147 'Filepath' => array( 'SpecialPage', 'Filepath' ),
149 'Mypage' => array( 'SpecialMypage' ),
150 'Mytalk' => array( 'SpecialMytalk' ),
151 'Mycontributions' => array( 'SpecialMycontributions' ),
152 'Listadmins' => array( 'SpecialRedirectToSpecial', 'Listadmins', 'Listusers', 'sysop' ),
153 'MergeHistory' => array( 'SpecialPage', 'MergeHistory', 'mergehistory' ),
154 'Listbots' => array( 'SpecialRedirectToSpecial', 'Listbots', 'Listusers', 'bot' ),
157 static public $mAliases;
158 static public $mListInitialised = false;
163 * Initialise the special page list
164 * This must be called before accessing SpecialPage::$mList
166 static function initList() {
167 global $wgSpecialPages;
168 global $wgDisableCounters, $wgDisableInternalSearch, $wgEmailAuthentication;
170 if ( self
::$mListInitialised ) {
173 wfProfileIn( __METHOD__
);
175 # Better to set this now, to avoid infinite recursion in carelessly written hooks
176 self
::$mListInitialised = true;
178 if( !$wgDisableCounters ) {
179 self
::$mList['Popularpages'] = array( 'SpecialPage', 'Popularpages' );
182 if( !$wgDisableInternalSearch ) {
183 self
::$mList['Search'] = array( 'SpecialPage', 'Search' );
186 if( $wgEmailAuthentication ) {
187 self
::$mList['Confirmemail'] = 'EmailConfirmation';
190 # Add extension special pages
191 self
::$mList = array_merge( self
::$mList, $wgSpecialPages );
194 # This hook can be used to remove undesired built-in special pages
195 wfRunHooks( 'SpecialPage_initList', array( &self
::$mList ) );
196 wfProfileOut( __METHOD__
);
199 static function initAliasList() {
200 if ( !is_null( self
::$mAliases ) ) {
205 $aliases = $wgContLang->getSpecialPageAliases();
206 $missingPages = self
::$mList;
207 self
::$mAliases = array();
208 foreach ( $aliases as $realName => $aliasList ) {
209 foreach ( $aliasList as $alias ) {
210 self
::$mAliases[$wgContLang->caseFold( $alias )] = $realName;
212 unset( $missingPages[$realName] );
214 foreach ( $missingPages as $name => $stuff ) {
215 self
::$mAliases[$wgContLang->caseFold( $name )] = $name;
220 * Given a special page alias, return the special page name.
221 * Returns false if there is no such alias.
223 static function resolveAlias( $alias ) {
226 if ( !self
::$mListInitialised ) self
::initList();
227 if ( is_null( self
::$mAliases ) ) self
::initAliasList();
228 $caseFoldedAlias = $wgContLang->caseFold( $alias );
229 if ( isset( self
::$mAliases[$caseFoldedAlias] ) ) {
230 return self
::$mAliases[$caseFoldedAlias];
237 * Given a special page name with a possible subpage, return an array
238 * where the first element is the special page name and the second is the
241 static function resolveAliasWithSubpage( $alias ) {
242 $bits = explode( '/', $alias, 2 );
243 $name = self
::resolveAlias( $bits[0] );
244 if( !isset( $bits[1] ) ) { // bug 2087
249 return array( $name, $par );
253 * Add a page to the list of valid special pages. This used to be the preferred
254 * method for adding special pages in extensions. It's now suggested that you add
255 * an associative record to $wgSpecialPages. This avoids autoloading SpecialPage.
257 * @param mixed $page Must either be an array specifying a class name and
258 * constructor parameters, or an object. The object,
259 * when constructed, must have an execute() method which
260 * sends HTML to $wgOut.
263 static function addPage( &$page ) {
264 if ( !self
::$mListInitialised ) {
267 self
::$mList[$page->mName
] = $page;
271 * Remove a special page from the list
272 * Formerly used to disable expensive or dangerous special pages. The
273 * preferred method is now to add a SpecialPage_initList hook.
277 static function removePage( $name ) {
278 if ( !self
::$mListInitialised ) {
281 unset( self
::$mList[$name] );
285 * Check if a given name exist as a special page or as a special page alias
286 * @param $name string: name of a special page
287 * @return boolean: true if a special page exists with this name
289 static function exists( $name ) {
291 if ( !self
::$mListInitialised ) {
294 if( !self
::$mAliases ) {
295 self
::initAliasList();
298 # Remove special pages inline parameters:
299 $bits = explode( '/', $name );
300 $name = $wgContLang->caseFold($bits[0]);
303 array_key_exists( $name, self
::$mList )
304 or array_key_exists( $name, self
::$mAliases )
309 * Find the object with a given name and return it (or NULL)
311 * @param string $name
313 static function getPage( $name ) {
314 if ( !self
::$mListInitialised ) {
317 if ( array_key_exists( $name, self
::$mList ) ) {
318 $rec = self
::$mList[$name];
319 if ( is_string( $rec ) ) {
321 self
::$mList[$name] = new $className;
322 } elseif ( is_array( $rec ) ) {
323 $className = array_shift( $rec );
324 self
::$mList[$name] = wfCreateObject( $className, $rec );
326 return self
::$mList[$name];
333 * Get a special page with a given localised name, or NULL if there
334 * is no such special page.
336 static function getPageByAlias( $alias ) {
337 $realName = self
::resolveAlias( $alias );
339 return self
::getPage( $realName );
346 * Return categorised listable special pages for all users
349 static function getRegularPages() {
350 if ( !self
::$mListInitialised ) {
355 foreach ( self
::$mList as $name => $rec ) {
356 $page = self
::getPage( $name );
357 if ( $page->isListed() && !$page->isRestricted() ) {
358 $pages[$name] = $page;
365 * Return categorised listable special pages which are available
366 * for the current user, but not for everyone
369 static function getRestrictedPages() {
371 if ( !self
::$mListInitialised ) {
376 foreach ( self
::$mList as $name => $rec ) {
377 $page = self
::getPage( $name );
380 and $page->isRestricted()
381 and $page->userCanExecute( $wgUser )
383 $pages[$name] = $page;
390 * Execute a special page path.
391 * The path may contain parameters, e.g. Special:Name/Params
392 * Extracts the special page name and call the execute method, passing the parameters
394 * Returns a title object if the page is redirected, false if there was no such special
395 * page, and true if it was successful.
397 * @param $title a title object
398 * @param $including output is being captured for use in {{special:whatever}}
400 static function executePath( &$title, $including = false ) {
401 global $wgOut, $wgTitle, $wgRequest;
402 wfProfileIn( __METHOD__
);
404 # FIXME: redirects broken due to this call
405 $bits = explode( '/', $title->getDBkey(), 2 );
407 if( !isset( $bits[1] ) ) { // bug 2087
412 $page = SpecialPage
::getPageByAlias( $name );
416 $wgOut->setArticleRelated( false );
417 $wgOut->setRobotpolicy( 'noindex,nofollow' );
418 $wgOut->setStatusCode( 404 );
419 $wgOut->showErrorPage( 'nosuchspecialpage', 'nospecialpagetext' );
421 wfProfileOut( __METHOD__
);
427 $redirect = $page->getRedirect( $par );
429 $query = $page->getRedirectQuery();
430 $url = $redirect->getFullUrl( $query );
431 $wgOut->redirect( $url );
432 wfProfileOut( __METHOD__
);
437 # Redirect to canonical alias for GET commands
438 # Not for POST, we'd lose the post data, so it's best to just distribute
439 # the request. Such POST requests are possible for old extensions that
440 # generate self-links without being aware that their default name has
442 if ( !$including && $name != $page->getLocalName() && !$wgRequest->wasPosted() ) {
444 unset( $query['title'] );
445 $query = wfArrayToCGI( $query );
446 $title = $page->getTitle( $par );
447 $url = $title->getFullUrl( $query );
448 $wgOut->redirect( $url );
449 wfProfileOut( __METHOD__
);
453 if ( $including && !$page->includable() ) {
454 wfProfileOut( __METHOD__
);
456 } elseif ( !$including ) {
457 $wgTitle = $page->getTitle();
459 $page->including( $including );
461 // Execute special page
462 $profName = 'Special:' . $page->getName();
463 wfProfileIn( $profName );
464 $page->execute( $par );
465 wfProfileOut( $profName );
466 wfProfileOut( __METHOD__
);
471 * Just like executePath() except it returns the HTML instead of outputting it
472 * Returns false if there was no such special page, or a title object if it was
476 static function capturePath( &$title ) {
477 global $wgOut, $wgTitle;
479 $oldTitle = $wgTitle;
481 $wgOut = new OutputPage
;
483 $ret = SpecialPage
::executePath( $title, true );
484 if ( $ret === true ) {
485 $ret = $wgOut->getHTML();
487 $wgTitle = $oldTitle;
493 * Get the local name for a specified canonical name
496 * @param mixed $subpage Boolean false, or string
500 static function getLocalNameFor( $name, $subpage = false ) {
502 $aliases = $wgContLang->getSpecialPageAliases();
503 if ( isset( $aliases[$name][0] ) ) {
504 $name = $aliases[$name][0];
506 if ( $subpage !== false && !is_null( $subpage ) ) {
507 $name = "$name/$subpage";
513 * Get a localised Title object for a specified special page name
515 static function getTitleFor( $name, $subpage = false ) {
516 $name = self
::getLocalNameFor( $name, $subpage );
518 return Title
::makeTitle( NS_SPECIAL
, $name );
520 throw new MWException( "Invalid special page name \"$name\"" );
525 * Get a localised Title object for a page name with a possibly unvalidated subpage
527 static function getSafeTitleFor( $name, $subpage = false ) {
528 $name = self
::getLocalNameFor( $name, $subpage );
530 return Title
::makeTitleSafe( NS_SPECIAL
, $name );
537 * Get a title for a given alias
538 * @return Title or null if there is no such alias
540 static function getTitleForAlias( $alias ) {
541 $name = self
::resolveAlias( $alias );
543 return self
::getTitleFor( $name );
550 * Default constructor for special pages
551 * Derivative classes should call this from their constructor
552 * Note that if the user does not have the required level, an error message will
553 * be displayed by the default execute() method, without the global function ever
556 * If you override execute(), you can recover the default behaviour with userCanExecute()
557 * and displayRestrictionError()
559 * @param string $name Name of the special page, as seen in links and URLs
560 * @param string $restriction User right required, e.g. "block" or "delete"
561 * @param boolean $listed Whether the page is listed in Special:Specialpages
562 * @param string $function Function called by execute(). By default it is constructed from $name
563 * @param string $file File which is included by execute(). It is also constructed from $name by default
565 function SpecialPage( $name = '', $restriction = '', $listed = true, $function = false, $file = 'default', $includable = false ) {
566 $this->mName
= $name;
567 $this->mRestriction
= $restriction;
568 $this->mListed
= $listed;
569 $this->mIncludable
= $includable;
570 if ( $function == false ) {
571 $this->mFunction
= 'wfSpecial'.$name;
573 $this->mFunction
= $function;
575 if ( $file === 'default' ) {
576 $this->mFile
= dirname(__FILE__
) . "/Special{$name}.php";
578 $this->mFile
= $file;
587 function getName() { return $this->mName
; }
588 function getRestriction() { return $this->mRestriction
; }
589 function getFile() { return $this->mFile
; }
590 function isListed() { return $this->mListed
; }
594 * Accessor and mutator
596 function name( $x = NULL ) { return wfSetVar( $this->mName
, $x ); }
597 function restrictions( $x = NULL) { return wfSetVar( $this->mRestrictions
, $x ); }
598 function listed( $x = NULL) { return wfSetVar( $this->mListed
, $x ); }
599 function func( $x = NULL) { return wfSetVar( $this->mFunction
, $x ); }
600 function file( $x = NULL) { return wfSetVar( $this->mFile
, $x ); }
601 function includable( $x = NULL ) { return wfSetVar( $this->mIncludable
, $x ); }
602 function including( $x = NULL ) { return wfSetVar( $this->mIncluding
, $x ); }
606 * Get the localised name of the special page
608 function getLocalName() {
609 if ( !isset( $this->mLocalName
) ) {
610 $this->mLocalName
= self
::getLocalNameFor( $this->mName
);
612 return $this->mLocalName
;
616 * Can be overridden by subclasses with more complicated permissions
619 * @return bool Should the page be displayed with the restricted-access
622 public function isRestricted() {
623 return $this->mRestriction
!= '';
627 * Checks if the given user (identified by an object) can execute this
628 * special page (as defined by $mRestriction). Can be overridden by sub-
629 * classes with more complicated permissions schemes.
631 * @param User $user The user to check
632 * @return bool Does the user have permission to view the page?
634 public function userCanExecute( $user ) {
635 return $user->isAllowed( $this->mRestriction
);
639 * Output an error message telling the user what access level they have to have
641 function displayRestrictionError() {
643 $wgOut->permissionRequired( $this->mRestriction
);
647 * Sets headers - this should be called from the execute() method of all derived classes!
649 function setHeaders() {
651 $wgOut->setArticleRelated( false );
652 $wgOut->setRobotPolicy( "noindex,nofollow" );
653 $wgOut->setPageTitle( $this->getDescription() );
657 * Default execute method
658 * Checks user permissions, calls the function given in mFunction
660 * This may be overridden by subclasses.
662 function execute( $par ) {
667 if ( $this->userCanExecute( $wgUser ) ) {
668 $func = $this->mFunction
;
669 // only load file if the function does not exist
670 if(!is_callable($func) and $this->mFile
) {
671 require_once( $this->mFile
);
673 # FIXME: these hooks are broken for extensions and anything else that subclasses SpecialPage.
674 if ( wfRunHooks( 'SpecialPageExecuteBeforeHeader', array( &$this, &$par, &$func ) ) )
675 $this->outputHeader();
676 if ( ! wfRunHooks( 'SpecialPageExecuteBeforePage', array( &$this, &$par, &$func ) ) )
678 call_user_func( $func, $par, $this );
679 if ( ! wfRunHooks( 'SpecialPageExecuteAfterPage', array( &$this, &$par, &$func ) ) )
682 $this->displayRestrictionError();
686 function outputHeader() {
687 global $wgOut, $wgContLang;
689 $msg = $wgContLang->lc( $this->name() ) . '-summary';
690 $out = wfMsgNoTrans( $msg );
691 if ( ! wfEmptyMsg( $msg, $out ) and $out !== '' and ! $this->including() ) {
692 $wgOut->addWikiText( $out );
697 # Returns the name that goes in the <h1> in the special page itself, and also the name that
698 # will be listed in Special:Specialpages
700 # Derived classes can override this, but usually it is easier to keep the default behaviour.
701 # Messages can be added at run-time, see MessageCache.php
702 function getDescription() {
703 return wfMsg( strtolower( $this->mName
) );
707 * Get a self-referential title object
709 function getTitle( $subpage = false) {
710 return self
::getTitleFor( $this->mName
, $subpage );
714 * Set whether this page is listed in Special:Specialpages, at run-time
716 function setListed( $listed ) {
717 return wfSetVar( $this->mListed
, $listed );
721 * If the special page is a redirect, then get the Title object it redirects to.
724 function getRedirect( $subpage ) {
729 * Return part of the request string for a special redirect page
730 * This allows passing, e.g. action=history to Special:Mypage, etc.
734 function getRedirectQuery() {
737 foreach( $this->mAllowedRedirectParams
as $arg ) {
738 if( $val = $wgRequest->getVal( $arg, false ) )
739 $params[] = $arg . '=' . $val;
742 return count( $params ) ?
implode( '&', $params ) : false;
747 * Shortcut to construct a special page which is unlisted by default
748 * @addtogroup SpecialPage
750 class UnlistedSpecialPage
extends SpecialPage
752 function UnlistedSpecialPage( $name, $restriction = '', $function = false, $file = 'default' ) {
753 SpecialPage
::SpecialPage( $name, $restriction, false, $function, $file );
758 * Shortcut to construct an includable special page
759 * @addtogroup SpecialPage
761 class IncludableSpecialPage
extends SpecialPage
763 function IncludableSpecialPage( $name, $restriction = '', $listed = true, $function = false, $file = 'default' ) {
764 SpecialPage
::SpecialPage( $name, $restriction, $listed, $function, $file, true );
769 * Shortcut to construct a special page alias.
770 * @addtogroup SpecialPage
772 class SpecialRedirectToSpecial
extends UnlistedSpecialPage
{
773 var $redirName, $redirSubpage;
775 function __construct( $name, $redirName, $redirSubpage = false, $redirectParams = array() ) {
776 parent
::__construct( $name );
777 $this->redirName
= $redirName;
778 $this->redirSubpage
= $redirSubpage;
779 $this->mAllowedRedirectParams
= $redirectParams;
782 function getRedirect( $subpage ) {
783 if ( $this->redirSubpage
=== false ) {
784 return SpecialPage
::getTitleFor( $this->redirName
, $subpage );
786 return SpecialPage
::getTitleFor( $this->redirName
, $this->redirSubpage
);
791 /** SpecialMypage, SpecialMytalk and SpecialMycontributions special pages
792 * are used to get user independant links pointing to the user page, talk
793 * page and list of contributions.
794 * This can let us cache a single copy of any generated content for all
799 * Shortcut to construct a special page pointing to current user user's page.
800 * @addtogroup SpecialPage
802 class SpecialMypage
extends UnlistedSpecialPage
{
803 function __construct() {
804 parent
::__construct( 'Mypage' );
805 $this->mAllowedRedirectParams
= array( 'action' , 'preload' , 'editintro', 'section' );
808 function getRedirect( $subpage ) {
810 if ( strval( $subpage ) !== '' ) {
811 return Title
::makeTitle( NS_USER
, $wgUser->getName() . '/' . $subpage );
813 return Title
::makeTitle( NS_USER
, $wgUser->getName() );
819 * Shortcut to construct a special page pointing to current user talk page.
820 * @addtogroup SpecialPage
822 class SpecialMytalk
extends UnlistedSpecialPage
{
823 function __construct() {
824 parent
::__construct( 'Mytalk' );
825 $this->mAllowedRedirectParams
= array( 'action' , 'preload' , 'editintro', 'section' );
828 function getRedirect( $subpage ) {
830 if ( strval( $subpage ) !== '' ) {
831 return Title
::makeTitle( NS_USER_TALK
, $wgUser->getName() . '/' . $subpage );
833 return Title
::makeTitle( NS_USER_TALK
, $wgUser->getName() );
839 * Shortcut to construct a special page pointing to current user contributions.
840 * @addtogroup SpecialPage
842 class SpecialMycontributions
extends UnlistedSpecialPage
{
843 function __construct() {
844 parent
::__construct( 'Mycontributions' );
847 function getRedirect( $subpage ) {
849 return SpecialPage
::getTitleFor( 'Contributions', $wgUser->getName() );