Follow-up r86255: getTitleFor() was not migrated.
[lhc/web/wiklou.git] / includes / SpecialPage.php
1 <?php
2 /**
3 * SpecialPage: handling special pages and lists thereof.
4 *
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.
8 *
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.
15 *
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.
19 *
20 * @file
21 * @ingroup SpecialPage
22 * @defgroup SpecialPage SpecialPage
23 */
24
25 /**
26 * Parent special page class, also static functions for handling the special
27 * page list.
28 * @ingroup SpecialPage
29 */
30 class SpecialPage {
31 /**#@+
32 * @access private
33 */
34 /**
35 * The canonical name of this special page
36 * Also used for the default <h1> heading, @see getDescription()
37 */
38 var $mName;
39 /**
40 * The local name of this special page
41 */
42 var $mLocalName;
43 /**
44 * Minimum user level required to access this page, or "" for anyone.
45 * Also used to categorise the pages in Special:Specialpages
46 */
47 var $mRestriction;
48 /**
49 * Listed in Special:Specialpages?
50 */
51 var $mListed;
52 /**
53 * Function name called by the default execute()
54 */
55 var $mFunction;
56 /**
57 * File which needs to be included before the function above can be called
58 */
59 var $mFile;
60 /**
61 * Whether or not this special page is being included from an article
62 */
63 var $mIncluding;
64 /**
65 * Whether the special page can be included in an article
66 */
67 var $mIncludable;
68 /**
69 * Query parameters that can be passed through redirects
70 */
71 var $mAllowedRedirectParams = array();
72 /**
73 * Query parameteres added by redirects
74 */
75 var $mAddedRedirectParams = array();
76 /**
77 * Current request context
78 * @var RequestContext
79 */
80 protected $mContext;
81
82 /**
83 * Initialise the special page list
84 * This must be called before accessing SpecialPage::$mList
85 * @deprecated since 1.18
86 */
87 static function initList() {
88 // Noop
89 }
90
91 /**
92 * @deprecated since 1.18
93 */
94 static function initAliasList() {
95 // Noop
96 }
97
98 /**
99 * Given a special page alias, return the special page name.
100 * Returns false if there is no such alias.
101 *
102 * @param $alias String
103 * @return String or false
104 * @deprecated since 1.18 call SpecialPageFactory method directly
105 */
106 static function resolveAlias( $alias ) {
107 list( $name, /*...*/ ) = SpecialPageFactory::resolveAlias( $alias );
108 return $name;
109 }
110
111 /**
112 * Given a special page name with a possible subpage, return an array
113 * where the first element is the special page name and the second is the
114 * subpage.
115 *
116 * @param $alias String
117 * @return Array
118 * @deprecated since 1.18 call SpecialPageFactory method directly
119 */
120 static function resolveAliasWithSubpage( $alias ) {
121 return SpecialPageFactory::resolveAlias( $alias );
122 }
123
124 /**
125 * Add a page to the list of valid special pages. This used to be the preferred
126 * method for adding special pages in extensions. It's now suggested that you add
127 * an associative record to $wgSpecialPages. This avoids autoloading SpecialPage.
128 *
129 * @param $page SpecialPage
130 * @deprecated in 1.7, warnings in 1.17, might be removed in 1.20
131 */
132 static function addPage( &$page ) {
133 wfDeprecated( __METHOD__ );
134 SpecialPageFactory::getList()->{$page->mName} = $page;
135 }
136
137 /**
138 * Add a page to a certain display group for Special:SpecialPages
139 *
140 * @param $page Mixed: SpecialPage or string
141 * @param $group String
142 * @deprecated since 1.18 call SpecialPageFactory method directly
143 */
144 static function setGroup( $page, $group ) {
145 return SpecialPageFactory::setGroup( $page, $group );
146 }
147
148 /**
149 * Add a page to a certain display group for Special:SpecialPages
150 *
151 * @param $page SpecialPage
152 * @deprecated since 1.18 call SpecialPageFactory method directly
153 */
154 static function getGroup( &$page ) {
155 return SpecialPageFactory::getGroup( $page );
156 }
157
158 /**
159 * Remove a special page from the list
160 * Formerly used to disable expensive or dangerous special pages. The
161 * preferred method is now to add a SpecialPage_initList hook.
162 * @deprecated since 1.18
163 */
164 static function removePage( $name ) {
165 unset( SpecialPageFactory::getList()->$name );
166 }
167
168 /**
169 * Check if a given name exist as a special page or as a special page alias
170 *
171 * @param $name String: name of a special page
172 * @return Boolean: true if a special page exists with this name
173 * @deprecated since 1.18 call SpecialPageFactory method directly
174 */
175 static function exists( $name ) {
176 return SpecialPageFactory::exists( $name );
177 }
178
179 /**
180 * Find the object with a given name and return it (or NULL)
181 *
182 * @param $name String
183 * @return SpecialPage object or null if the page doesn't exist
184 * @deprecated since 1.18 call SpecialPageFactory method directly
185 */
186 static function getPage( $name ) {
187 return SpecialPageFactory::getPage( $name );
188 }
189
190 /**
191 * Get a special page with a given localised name, or NULL if there
192 * is no such special page.
193 *
194 * @return SpecialPage object or null if the page doesn't exist
195 * @deprecated since 1.18 call SpecialPageFactory method directly
196 */
197 static function getPageByAlias( $alias ) {
198 return SpecialPageFactory::getPage( $alias );
199 }
200
201 /**
202 * Return categorised listable special pages which are available
203 * for the current user, and everyone.
204 *
205 * @return Associative array mapping page's name to its SpecialPage object
206 * @deprecated since 1.18 call SpecialPageFactory method directly
207 */
208 static function getUsablePages() {
209 return SpecialPageFactory::getUsablePages();
210 }
211
212 /**
213 * Return categorised listable special pages for all users
214 *
215 * @return Associative array mapping page's name to its SpecialPage object
216 * @deprecated since 1.18 call SpecialPageFactory method directly
217 */
218 static function getRegularPages() {
219 return SpecialPageFactory::getRegularPages();
220 }
221
222 /**
223 * Return categorised listable special pages which are available
224 * for the current user, but not for everyone
225 *
226 * @return Associative array mapping page's name to its SpecialPage object
227 * @deprecated since 1.18 call SpecialPageFactory method directly
228 */
229 static function getRestrictedPages() {
230 return SpecialPageFactory::getRestrictedPages();
231 }
232
233 /**
234 * Execute a special page path.
235 * The path may contain parameters, e.g. Special:Name/Params
236 * Extracts the special page name and call the execute method, passing the parameters
237 *
238 * Returns a title object if the page is redirected, false if there was no such special
239 * page, and true if it was successful.
240 *
241 * @param $title Title object
242 * @param $context RequestContext
243 * @param $including Bool output is being captured for use in {{special:whatever}}
244 * @deprecated since 1.18 call SpecialPageFactory method directly
245 */
246 public static function executePath( &$title, RequestContext &$context, $including = false ) {
247 return SpecialPageFactory::executePath( $title, $context, $including );
248 }
249
250 /**
251 * Just like executePath() except it returns the HTML instead of outputting it
252 * Returns false if there was no such special page, or a title object if it was
253 * a redirect.
254 *
255 * @return String: HTML fragment
256 * @deprecated since 1.18 call SpecialPageFactory method directly
257 */
258 static function capturePath( &$title ) {
259 return SpecialPageFactory::capturePath( $title );
260 }
261
262 /**
263 * Get the local name for a specified canonical name
264 *
265 * @param $name String
266 * @param $subpage Mixed: boolean false, or string
267 *
268 * @return String
269 * @deprecated since 1.18 call SpecialPageFactory method directly
270 */
271 static function getLocalNameFor( $name, $subpage = false ) {
272 return SpecialPageFactory::getLocalNameFor( $name, $subpage );
273 }
274
275 /**
276 * Get a localised Title object for a specified special page name
277 *
278 * @return Title object
279 */
280 public static function getTitleFor( $name, $subpage = false ) {
281 $name = SpecialPageFactory::getLocalNameFor( $name, $subpage );
282 if ( $name ) {
283 return Title::makeTitle( NS_SPECIAL, $name );
284 } else {
285 throw new MWException( "Invalid special page name \"$name\"" );
286 }
287 }
288
289 /**
290 * Get a localised Title object for a page name with a possibly unvalidated subpage
291 *
292 * @return Title object or null if the page doesn't exist
293 */
294 public static function getSafeTitleFor( $name, $subpage = false ) {
295 $name = SpecialPageFactory::getLocalNameFor( $name, $subpage );
296 if ( $name ) {
297 return Title::makeTitleSafe( NS_SPECIAL, $name );
298 } else {
299 return null;
300 }
301 }
302
303 /**
304 * Get a title for a given alias
305 *
306 * @return Title or null if there is no such alias
307 * @deprecated since 1.18 call SpecialPageFactory method directly
308 */
309 static function getTitleForAlias( $alias ) {
310 return SpecialPageFactory::getTitleForAlias( $alias );
311 }
312
313 /**
314 * Default constructor for special pages
315 * Derivative classes should call this from their constructor
316 * Note that if the user does not have the required level, an error message will
317 * be displayed by the default execute() method, without the global function ever
318 * being called.
319 *
320 * If you override execute(), you can recover the default behaviour with userCanExecute()
321 * and displayRestrictionError()
322 *
323 * @param $name String: name of the special page, as seen in links and URLs
324 * @param $restriction String: user right required, e.g. "block" or "delete"
325 * @param $listed Boolean: whether the page is listed in Special:Specialpages
326 * @param $function Callback: function called by execute(). By default it is constructed from $name
327 * @param $file String: file which is included by execute(). It is also constructed from $name by default
328 * @param $includable Boolean: whether the page can be included in normal pages
329 */
330 public function __construct( $name = '', $restriction = '', $listed = true, $function = false, $file = 'default', $includable = false ) {
331 $this->init( $name, $restriction, $listed, $function, $file, $includable );
332 }
333
334 /**
335 * Do the real work for the constructor, mainly so __call() can intercept
336 * calls to SpecialPage()
337 * @see __construct() for param docs
338 */
339 private function init( $name, $restriction, $listed, $function, $file, $includable ) {
340 $this->mName = $name;
341 $this->mRestriction = $restriction;
342 $this->mListed = $listed;
343 $this->mIncludable = $includable;
344 if ( !$function ) {
345 $this->mFunction = 'wfSpecial'.$name;
346 } else {
347 $this->mFunction = $function;
348 }
349 if ( $file === 'default' ) {
350 $this->mFile = dirname(__FILE__) . "/specials/Special$name.php";
351 } else {
352 $this->mFile = $file;
353 }
354 }
355
356 /**
357 * Use PHP's magic __call handler to get calls to the old PHP4 constructor
358 * because PHP E_STRICT yells at you for having __construct() and SpecialPage()
359 *
360 * @param $fName String Name of called method
361 * @param $a Array Arguments to the method
362 * @deprecated since 1.17, call parent::__construct()
363 */
364 public function __call( $fName, $a ) {
365 // Sometimes $fName is SpecialPage, sometimes it's specialpage. <3 PHP
366 if( strtolower( $fName ) == 'specialpage' ) {
367 // Deprecated messages now, remove in 1.19 or 1.20?
368 wfDeprecated( __METHOD__ );
369
370 $name = isset( $a[0] ) ? $a[0] : '';
371 $restriction = isset( $a[1] ) ? $a[1] : '';
372 $listed = isset( $a[2] ) ? $a[2] : true;
373 $function = isset( $a[3] ) ? $a[3] : false;
374 $file = isset( $a[4] ) ? $a[4] : 'default';
375 $includable = isset( $a[5] ) ? $a[5] : false;
376 $this->init( $name, $restriction, $listed, $function, $file, $includable );
377 } else {
378 $className = get_class( $this );
379 throw new MWException( "Call to undefined method $className::$fName" );
380 }
381 }
382
383 function getName() { return $this->mName; }
384 function getRestriction() { return $this->mRestriction; }
385 function getFile() { return $this->mFile; }
386 function isListed() { return $this->mListed; }
387
388 function name( $x = null ) { return wfSetVar( $this->mName, $x ); }
389 function restrictions( $x = null) {
390 # Use the one below this
391 wfDeprecated( __METHOD__ );
392 return wfSetVar( $this->mRestriction, $x );
393 }
394 function restriction( $x = null) { return wfSetVar( $this->mRestriction, $x ); }
395 function listed( $x = null) { return wfSetVar( $this->mListed, $x ); }
396 function func( $x = null) { return wfSetVar( $this->mFunction, $x ); }
397 function file( $x = null) { return wfSetVar( $this->mFile, $x ); }
398 function includable( $x = null ) { return wfSetVar( $this->mIncludable, $x ); }
399 function including( $x = null ) { return wfSetVar( $this->mIncluding, $x ); }
400
401 /**
402 * Get the localised name of the special page
403 */
404 function getLocalName() {
405 if ( !isset( $this->mLocalName ) ) {
406 $this->mLocalName = SpecialPageFactory::getLocalNameFor( $this->mName );
407 }
408 return $this->mLocalName;
409 }
410
411 /**
412 * Is this page expensive (for some definition of expensive)?
413 * Expensive pages are disabled or cached in miser mode. Originally used
414 * (and still overridden) by QueryPage and subclasses, moved here so that
415 * Special:SpecialPages can safely call it for all special pages.
416 *
417 * @return Boolean
418 */
419 public function isExpensive() {
420 return false;
421 }
422
423 /**
424 * Can be overridden by subclasses with more complicated permissions
425 * schemes.
426 *
427 * @return Boolean: should the page be displayed with the restricted-access
428 * pages?
429 */
430 public function isRestricted() {
431 global $wgGroupPermissions;
432 // DWIM: If all anons can do something, then it is not restricted
433 return $this->mRestriction != '' && empty($wgGroupPermissions['*'][$this->mRestriction]);
434 }
435
436 /**
437 * Checks if the given user (identified by an object) can execute this
438 * special page (as defined by $mRestriction). Can be overridden by sub-
439 * classes with more complicated permissions schemes.
440 *
441 * @param $user User: the user to check
442 * @return Boolean: does the user have permission to view the page?
443 */
444 public function userCanExecute( $user ) {
445 return $user->isAllowed( $this->mRestriction );
446 }
447
448 /**
449 * Output an error message telling the user what access level they have to have
450 */
451 function displayRestrictionError() {
452 throw new PermissionsError( $this->mRestriction );
453 }
454
455 /**
456 * Sets headers - this should be called from the execute() method of all derived classes!
457 */
458 function setHeaders() {
459 $out = $this->getOutput();
460 $out->setArticleRelated( false );
461 $out->setRobotPolicy( "noindex,nofollow" );
462 $out->setPageTitle( $this->getDescription() );
463 }
464
465 /**
466 * Default execute method
467 * Checks user permissions, calls the function given in mFunction
468 *
469 * This may be overridden by subclasses.
470 */
471 function execute( $par ) {
472 $this->setHeaders();
473
474 if ( $this->userCanExecute( $this->getUser() ) ) {
475 $func = $this->mFunction;
476 // only load file if the function does not exist
477 if(!is_callable($func) and $this->mFile) {
478 require_once( $this->mFile );
479 }
480 $this->outputHeader();
481 call_user_func( $func, $par, $this );
482 } else {
483 $this->displayRestrictionError();
484 }
485 }
486
487 /**
488 * Outputs a summary message on top of special pages
489 * Per default the message key is the canonical name of the special page
490 * May be overriden, i.e. by extensions to stick with the naming conventions
491 * for message keys: 'extensionname-xxx'
492 *
493 * @param $summaryMessageKey String: message key of the summary
494 */
495 function outputHeader( $summaryMessageKey = '' ) {
496 global $wgContLang;
497
498 if( $summaryMessageKey == '' ) {
499 $msg = $wgContLang->lc( $this->getName() ) . '-summary';
500 } else {
501 $msg = $summaryMessageKey;
502 }
503 if ( !wfMessage( $msg )->isBlank() and ! $this->including() ) {
504 $this->getOutput()->wrapWikiMsg( "<div class='mw-specialpage-summary'>\n$1\n</div>", $msg );
505 }
506
507 }
508
509 /**
510 * Returns the name that goes in the \<h1\> in the special page itself, and
511 * also the name that will be listed in Special:Specialpages
512 *
513 * Derived classes can override this, but usually it is easier to keep the
514 * default behaviour. Messages can be added at run-time, see
515 * MessageCache.php.
516 *
517 * @return String
518 */
519 function getDescription() {
520 return wfMsg( strtolower( $this->mName ) );
521 }
522
523 /**
524 * Get a self-referential title object
525 *
526 * @return Title object
527 */
528 function getTitle( $subpage = false ) {
529 return self::getTitleFor( $this->mName, $subpage );
530 }
531
532 /**
533 * Set whether this page is listed in Special:Specialpages, at run-time
534 *
535 * @return Bool
536 */
537 function setListed( $listed ) {
538 return wfSetVar( $this->mListed, $listed );
539 }
540
541 /**
542 * If the special page is a redirect, then get the Title object it redirects to.
543 * False otherwise.
544 *
545 * @return Title|false
546 */
547 function getRedirect( $subpage ) {
548 return false;
549 }
550
551 /**
552 * Return part of the request string for a special redirect page
553 * This allows passing, e.g. action=history to Special:Mypage, etc.
554 *
555 * @return String
556 */
557 function getRedirectQuery() {
558 $params = array();
559
560 foreach( $this->mAllowedRedirectParams as $arg ) {
561 if( $this->getContext()->request->getVal( $arg, null ) !== null ){
562 $params[$arg] = $this->getContext()->request->getVal( $arg );
563 }
564 }
565
566 foreach( $this->mAddedRedirectParams as $arg => $val ) {
567 $params[$arg] = $val;
568 }
569
570 return count( $params )
571 ? $params
572 : false;
573 }
574
575 /**
576 * Sets the context this SpecialPage is executed in
577 *
578 * @param $context RequestContext
579 * @since 1.18
580 */
581 public function setContext( $context ) {
582 $this->mContext = $context;
583 }
584
585 /**
586 * Gets the context this SpecialPage is executed in
587 *
588 * @return RequestContext
589 * @since 1.18
590 */
591 public function getContext() {
592 if ( $this->mContext instanceof RequestContext ) {
593 return $this->mContext;
594 } else {
595 wfDebug( __METHOD__ . " called and \$mContext is null. Return RequestContext::getMain(); for sanity\n" );
596 return RequestContext::getMain();
597 }
598 }
599
600 /**
601 * Get the WebRequest being used for this instance
602 *
603 * @return WebRequest
604 * @since 1.18
605 */
606 public function getRequest() {
607 return $this->getContext()->getRequest();
608 }
609
610 /**
611 * Get the OutputPage being used for this instance
612 *
613 * @return OutputPage
614 * @since 1.18
615 */
616 public function getOutput() {
617 return $this->getContext()->getOutput();
618 }
619
620 /**
621 * Shortcut to get the skin being used for this instance
622 *
623 * @return User
624 * @since 1.18
625 */
626 public function getUser() {
627 return $this->getContext()->getUser();
628 }
629
630 /**
631 * Shortcut to get the skin being used for this instance
632 *
633 * @return Skin
634 * @since 1.18
635 */
636 public function getSkin() {
637 return $this->getContext()->getSkin();
638 }
639
640 /**
641 * Return the full title, including $par
642 *
643 * @return Title
644 * @since 1.18
645 */
646 public function getFullTitle() {
647 return $this->getContext()->getTitle();
648 }
649
650 /**
651 * Wrapper around wfMessage that sets the current context. Currently this
652 * is only the title.
653 *
654 * @see wfMessage
655 */
656 public function msg( /* $args */ ) {
657 return call_user_func_array( 'wfMessage', func_get_args() )->title( $this->getFullTitle() );
658 }
659 }
660
661 /**
662 * Shortcut to construct a special page which is unlisted by default
663 * @ingroup SpecialPage
664 */
665 class UnlistedSpecialPage extends SpecialPage
666 {
667 function __construct( $name, $restriction = '', $function = false, $file = 'default' ) {
668 parent::__construct( $name, $restriction, false, $function, $file );
669 }
670 }
671
672 /**
673 * Shortcut to construct an includable special page
674 * @ingroup SpecialPage
675 */
676 class IncludableSpecialPage extends SpecialPage
677 {
678 function __construct( $name, $restriction = '', $listed = true, $function = false, $file = 'default' ) {
679 parent::__construct( $name, $restriction, $listed, $function, $file, true );
680 }
681 }
682
683 /**
684 * Shortcut to construct a special page alias.
685 * @ingroup SpecialPage
686 */
687 abstract class SpecialRedirectToSpecial extends UnlistedSpecialPage {
688 var $redirName, $redirSubpage;
689
690 function __construct( $name, $redirName, $redirSubpage = false, $allowedRedirectParams = array(), $addedRedirectParams = array() ) {
691 parent::__construct( $name );
692 $this->redirName = $redirName;
693 $this->redirSubpage = $redirSubpage;
694 $this->mAllowedRedirectParams = $allowedRedirectParams;
695 $this->mAddedRedirectParams = $addedRedirectParams;
696 }
697
698 function getRedirect( $subpage ) {
699 if ( $this->redirSubpage === false ) {
700 return SpecialPage::getTitleFor( $this->redirName, $subpage );
701 } else {
702 return SpecialPage::getTitleFor( $this->redirName, $this->redirSubpage );
703 }
704 }
705 }
706
707 /**
708 * ListAdmins --> ListUsers/admin
709 */
710 class SpecialListAdmins extends SpecialRedirectToSpecial {
711 function __construct(){
712 parent::__construct( 'ListAdmins', 'ListUsers', 'sysop' );
713 }
714 }
715
716 /**
717 * ListBots --> ListUsers/admin
718 */
719 class SpecialListBots extends SpecialRedirectToSpecial {
720 function __construct(){
721 parent::__construct( 'ListAdmins', 'ListUsers', 'bot' );
722 }
723 }
724
725 /**
726 * CreateAccount --> UserLogin/signup
727 * FIXME: this (and the rest of the login frontend) needs to die a horrible painful death
728 */
729 class SpecialCreateAccount extends SpecialRedirectToSpecial {
730 function __construct(){
731 parent::__construct( 'CreateAccount', 'Userlogin', 'signup', array( 'uselang' ) );
732 }
733 }
734 /**
735 * SpecialMypage, SpecialMytalk and SpecialMycontributions special pages
736 * are used to get user independant links pointing to the user page, talk
737 * page and list of contributions.
738 * This can let us cache a single copy of any generated content for all
739 * users.
740 */
741
742 /**
743 * Shortcut to construct a special page pointing to current user user's page.
744 * @ingroup SpecialPage
745 */
746 class SpecialMypage extends UnlistedSpecialPage {
747 function __construct() {
748 parent::__construct( 'Mypage' );
749 $this->mAllowedRedirectParams = array( 'action' , 'preload' , 'editintro',
750 'section', 'oldid', 'diff', 'dir' );
751 }
752
753 function getRedirect( $subpage ) {
754 global $wgUser;
755 if ( strval( $subpage ) !== '' ) {
756 return Title::makeTitle( NS_USER, $wgUser->getName() . '/' . $subpage );
757 } else {
758 return Title::makeTitle( NS_USER, $wgUser->getName() );
759 }
760 }
761 }
762
763 /**
764 * Shortcut to construct a special page pointing to current user talk page.
765 * @ingroup SpecialPage
766 */
767 class SpecialMytalk extends UnlistedSpecialPage {
768 function __construct() {
769 parent::__construct( 'Mytalk' );
770 $this->mAllowedRedirectParams = array( 'action' , 'preload' , 'editintro',
771 'section', 'oldid', 'diff', 'dir' );
772 }
773
774 function getRedirect( $subpage ) {
775 global $wgUser;
776 if ( strval( $subpage ) !== '' ) {
777 return Title::makeTitle( NS_USER_TALK, $wgUser->getName() . '/' . $subpage );
778 } else {
779 return Title::makeTitle( NS_USER_TALK, $wgUser->getName() );
780 }
781 }
782 }
783
784 /**
785 * Shortcut to construct a special page pointing to current user contributions.
786 * @ingroup SpecialPage
787 */
788 class SpecialMycontributions extends UnlistedSpecialPage {
789 function __construct() {
790 parent::__construct( 'Mycontributions' );
791 $this->mAllowedRedirectParams = array( 'limit', 'namespace', 'tagfilter',
792 'offset', 'dir', 'year', 'month', 'feed' );
793 }
794
795 function getRedirect( $subpage ) {
796 global $wgUser;
797 return SpecialPageFactory::getTitleFor( 'Contributions', $wgUser->getName() );
798 }
799 }
800
801 /**
802 * Redirect to Special:Listfiles?user=$wgUser
803 */
804 class SpecialMyuploads extends UnlistedSpecialPage {
805 function __construct() {
806 parent::__construct( 'Myuploads' );
807 $this->mAllowedRedirectParams = array( 'limit' );
808 }
809
810 function getRedirect( $subpage ) {
811 global $wgUser;
812 return SpecialPageFactory::getTitleFor( 'Listfiles', $wgUser->getName() );
813 }
814 }
815
816 /**
817 * Redirect from Special:PermanentLink/### to index.php?oldid=###
818 */
819 class SpecialPermanentLink extends UnlistedSpecialPage {
820 function __construct() {
821 parent::__construct( 'PermanentLink' );
822 $this->mAllowedRedirectParams = array();
823 }
824
825 function getRedirect( $subpage ) {
826 $subpage = intval( $subpage );
827 $this->mAddedRedirectParams['oldid'] = $subpage;
828 return true;
829 }
830 }