097c5957ce5d9f7a6d806fd794a582d220297403
[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 /**#@+
384 * Accessor
385 *
386 * @deprecated
387 */
388 function getName() { return $this->mName; }
389 function getRestriction() { return $this->mRestriction; }
390 function getFile() { return $this->mFile; }
391 function isListed() { return $this->mListed; }
392 /**#@-*/
393
394 /**#@+
395 * Accessor and mutator
396 */
397 function name( $x = null ) { return wfSetVar( $this->mName, $x ); }
398 function restrictions( $x = null) {
399 # Use the one below this
400 wfDeprecated( __METHOD__ );
401 return wfSetVar( $this->mRestriction, $x );
402 }
403 function restriction( $x = null) { return wfSetVar( $this->mRestriction, $x ); }
404 function listed( $x = null) { return wfSetVar( $this->mListed, $x ); }
405 function func( $x = null) { return wfSetVar( $this->mFunction, $x ); }
406 function file( $x = null) { return wfSetVar( $this->mFile, $x ); }
407 function includable( $x = null ) { return wfSetVar( $this->mIncludable, $x ); }
408 function including( $x = null ) { return wfSetVar( $this->mIncluding, $x ); }
409 /**#@-*/
410
411 /**
412 * Get the localised name of the special page
413 */
414 function getLocalName() {
415 if ( !isset( $this->mLocalName ) ) {
416 $this->mLocalName = SpecialPageFactory::getLocalNameFor( $this->mName );
417 }
418 return $this->mLocalName;
419 }
420
421 /**
422 * Is this page expensive (for some definition of expensive)?
423 * Expensive pages are disabled or cached in miser mode. Originally used
424 * (and still overridden) by QueryPage and subclasses, moved here so that
425 * Special:SpecialPages can safely call it for all special pages.
426 *
427 * @return Boolean
428 */
429 public function isExpensive() {
430 return false;
431 }
432
433 /**
434 * Can be overridden by subclasses with more complicated permissions
435 * schemes.
436 *
437 * @return Boolean: should the page be displayed with the restricted-access
438 * pages?
439 */
440 public function isRestricted() {
441 global $wgGroupPermissions;
442 // DWIM: If all anons can do something, then it is not restricted
443 return $this->mRestriction != '' && empty($wgGroupPermissions['*'][$this->mRestriction]);
444 }
445
446 /**
447 * Checks if the given user (identified by an object) can execute this
448 * special page (as defined by $mRestriction). Can be overridden by sub-
449 * classes with more complicated permissions schemes.
450 *
451 * @param $user User: the user to check
452 * @return Boolean: does the user have permission to view the page?
453 */
454 public function userCanExecute( $user ) {
455 return $user->isAllowed( $this->mRestriction );
456 }
457
458 /**
459 * Output an error message telling the user what access level they have to have
460 */
461 function displayRestrictionError() {
462 throw new PermissionsError( $this->mRestriction );
463 }
464
465 /**
466 * Sets headers - this should be called from the execute() method of all derived classes!
467 */
468 function setHeaders() {
469 $out = $this->getOutput();
470 $out->setArticleRelated( false );
471 $out->setRobotPolicy( "noindex,nofollow" );
472 $out->setPageTitle( $this->getDescription() );
473 }
474
475 /**
476 * Default execute method
477 * Checks user permissions, calls the function given in mFunction
478 *
479 * This may be overridden by subclasses.
480 */
481 function execute( $par ) {
482 $this->setHeaders();
483
484 if ( $this->userCanExecute( $this->getUser() ) ) {
485 $func = $this->mFunction;
486 // only load file if the function does not exist
487 if(!is_callable($func) and $this->mFile) {
488 require_once( $this->mFile );
489 }
490 $this->outputHeader();
491 call_user_func( $func, $par, $this );
492 } else {
493 $this->displayRestrictionError();
494 }
495 }
496
497 /**
498 * Outputs a summary message on top of special pages
499 * Per default the message key is the canonical name of the special page
500 * May be overriden, i.e. by extensions to stick with the naming conventions
501 * for message keys: 'extensionname-xxx'
502 *
503 * @param $summaryMessageKey String: message key of the summary
504 */
505 function outputHeader( $summaryMessageKey = '' ) {
506 global $wgContLang;
507
508 if( $summaryMessageKey == '' ) {
509 $msg = $wgContLang->lc( $this->name() ) . '-summary';
510 } else {
511 $msg = $summaryMessageKey;
512 }
513 if ( !wfMessage( $msg )->isBlank() and ! $this->including() ) {
514 $this->getOutput()->wrapWikiMsg( "<div class='mw-specialpage-summary'>\n$1\n</div>", $msg );
515 }
516
517 }
518
519 /**
520 * Returns the name that goes in the \<h1\> in the special page itself, and
521 * also the name that will be listed in Special:Specialpages
522 *
523 * Derived classes can override this, but usually it is easier to keep the
524 * default behaviour. Messages can be added at run-time, see
525 * MessageCache.php.
526 *
527 * @return String
528 */
529 function getDescription() {
530 return wfMsg( strtolower( $this->mName ) );
531 }
532
533 /**
534 * Get a self-referential title object
535 *
536 * @return Title object
537 */
538 function getTitle( $subpage = false ) {
539 return self::getTitleFor( $this->mName, $subpage );
540 }
541
542 /**
543 * Set whether this page is listed in Special:Specialpages, at run-time
544 *
545 * @return Bool
546 */
547 function setListed( $listed ) {
548 return wfSetVar( $this->mListed, $listed );
549 }
550
551 /**
552 * If the special page is a redirect, then get the Title object it redirects to.
553 * False otherwise.
554 *
555 * @return Title|false
556 */
557 function getRedirect( $subpage ) {
558 return false;
559 }
560
561 /**
562 * Return part of the request string for a special redirect page
563 * This allows passing, e.g. action=history to Special:Mypage, etc.
564 *
565 * @return String
566 */
567 function getRedirectQuery() {
568 $params = array();
569
570 foreach( $this->mAllowedRedirectParams as $arg ) {
571 if( $this->getContext()->request->getVal( $arg, null ) !== null ){
572 $params[$arg] = $this->getContext()->request->getVal( $arg );
573 }
574 }
575
576 foreach( $this->mAddedRedirectParams as $arg => $val ) {
577 $params[$arg] = $val;
578 }
579
580 return count( $params )
581 ? $params
582 : false;
583 }
584
585 /**
586 * Sets the context this SpecialPage is executed in
587 *
588 * @param $context RequestContext
589 * @since 1.18
590 */
591 public function setContext( $context ) {
592 $this->mContext = $context;
593 }
594
595 /**
596 * Gets the context this SpecialPage is executed in
597 *
598 * @return RequestContext
599 * @since 1.18
600 */
601 public function getContext() {
602 if ( $this->mContext instanceof RequestContext ) {
603 return $this->mContext;
604 } else {
605 wfDebug( __METHOD__ . " called and \$mContext is null. Return RequestContext::getMain(); for sanity\n" );
606 return RequestContext::getMain();
607 }
608 }
609
610 /**
611 * Get the WebRequest being used for this instance
612 *
613 * @return WebRequest
614 * @since 1.18
615 */
616 public function getRequest() {
617 return $this->getContext()->getRequest();
618 }
619
620 /**
621 * Get the OutputPage being used for this instance
622 *
623 * @return OutputPage
624 * @since 1.18
625 */
626 public function getOutput() {
627 return $this->getContext()->getOutput();
628 }
629
630 /**
631 * Shortcut to get the skin being used for this instance
632 *
633 * @return User
634 * @since 1.18
635 */
636 public function getUser() {
637 return $this->getContext()->getUser();
638 }
639
640 /**
641 * Shortcut to get the skin being used for this instance
642 *
643 * @return Skin
644 * @since 1.18
645 */
646 public function getSkin() {
647 return $this->getContext()->getSkin();
648 }
649
650 /**
651 * Return the full title, including $par
652 *
653 * @return Title
654 * @since 1.18
655 */
656 public function getFullTitle() {
657 return $this->getContext()->getTitle();
658 }
659
660 /**
661 * Wrapper around wfMessage that sets the current context. Currently this
662 * is only the title.
663 *
664 * @see wfMessage
665 */
666 public function msg( /* $args */ ) {
667 return call_user_func_array( 'wfMessage', func_get_args() )->title( $this->getFullTitle() );
668 }
669 }
670
671 /**
672 * Shortcut to construct a special page which is unlisted by default
673 * @ingroup SpecialPage
674 */
675 class UnlistedSpecialPage extends SpecialPage
676 {
677 function __construct( $name, $restriction = '', $function = false, $file = 'default' ) {
678 parent::__construct( $name, $restriction, false, $function, $file );
679 }
680 }
681
682 /**
683 * Shortcut to construct an includable special page
684 * @ingroup SpecialPage
685 */
686 class IncludableSpecialPage extends SpecialPage
687 {
688 function __construct( $name, $restriction = '', $listed = true, $function = false, $file = 'default' ) {
689 parent::__construct( $name, $restriction, $listed, $function, $file, true );
690 }
691 }
692
693 /**
694 * Shortcut to construct a special page alias.
695 * @ingroup SpecialPage
696 */
697 abstract class SpecialRedirectToSpecial extends UnlistedSpecialPage {
698 var $redirName, $redirSubpage;
699
700 function __construct( $name, $redirName, $redirSubpage = false, $allowedRedirectParams = array(), $addedRedirectParams = array() ) {
701 parent::__construct( $name );
702 $this->redirName = $redirName;
703 $this->redirSubpage = $redirSubpage;
704 $this->mAllowedRedirectParams = $allowedRedirectParams;
705 $this->mAddedRedirectParams = $addedRedirectParams;
706 }
707
708 function getRedirect( $subpage ) {
709 if ( $this->redirSubpage === false ) {
710 return SpecialPageFactory::getTitleFor( $this->redirName, $subpage );
711 } else {
712 return SpecialPageFactory::getTitleFor( $this->redirName, $this->redirSubpage );
713 }
714 }
715 }
716
717 /**
718 * ListAdmins --> ListUsers/admin
719 */
720 class SpecialListAdmins extends SpecialRedirectToSpecial {
721 function __construct(){
722 parent::__construct( 'ListAdmins', 'ListUsers', 'sysop' );
723 }
724 }
725
726 /**
727 * ListBots --> ListUsers/admin
728 */
729 class SpecialListBots extends SpecialRedirectToSpecial {
730 function __construct(){
731 parent::__construct( 'ListAdmins', 'ListUsers', 'bot' );
732 }
733 }
734
735 /**
736 * CreateAccount --> UserLogin/signup
737 * FIXME: this (and the rest of the login frontend) needs to die a horrible painful death
738 */
739 class SpecialCreateAccount extends SpecialRedirectToSpecial {
740 function __construct(){
741 parent::__construct( 'CreateAccount', 'Userlogin', 'signup', array( 'uselang' ) );
742 }
743 }
744 /**
745 * SpecialMypage, SpecialMytalk and SpecialMycontributions special pages
746 * are used to get user independant links pointing to the user page, talk
747 * page and list of contributions.
748 * This can let us cache a single copy of any generated content for all
749 * users.
750 */
751
752 /**
753 * Shortcut to construct a special page pointing to current user user's page.
754 * @ingroup SpecialPage
755 */
756 class SpecialMypage extends UnlistedSpecialPage {
757 function __construct() {
758 parent::__construct( 'Mypage' );
759 $this->mAllowedRedirectParams = array( 'action' , 'preload' , 'editintro',
760 'section', 'oldid', 'diff', 'dir' );
761 }
762
763 function getRedirect( $subpage ) {
764 global $wgUser;
765 if ( strval( $subpage ) !== '' ) {
766 return Title::makeTitle( NS_USER, $wgUser->getName() . '/' . $subpage );
767 } else {
768 return Title::makeTitle( NS_USER, $wgUser->getName() );
769 }
770 }
771 }
772
773 /**
774 * Shortcut to construct a special page pointing to current user talk page.
775 * @ingroup SpecialPage
776 */
777 class SpecialMytalk extends UnlistedSpecialPage {
778 function __construct() {
779 parent::__construct( 'Mytalk' );
780 $this->mAllowedRedirectParams = array( 'action' , 'preload' , 'editintro',
781 'section', 'oldid', 'diff', 'dir' );
782 }
783
784 function getRedirect( $subpage ) {
785 global $wgUser;
786 if ( strval( $subpage ) !== '' ) {
787 return Title::makeTitle( NS_USER_TALK, $wgUser->getName() . '/' . $subpage );
788 } else {
789 return Title::makeTitle( NS_USER_TALK, $wgUser->getName() );
790 }
791 }
792 }
793
794 /**
795 * Shortcut to construct a special page pointing to current user contributions.
796 * @ingroup SpecialPage
797 */
798 class SpecialMycontributions extends UnlistedSpecialPage {
799 function __construct() {
800 parent::__construct( 'Mycontributions' );
801 $this->mAllowedRedirectParams = array( 'limit', 'namespace', 'tagfilter',
802 'offset', 'dir', 'year', 'month', 'feed' );
803 }
804
805 function getRedirect( $subpage ) {
806 global $wgUser;
807 return SpecialPageFactory::getTitleFor( 'Contributions', $wgUser->getName() );
808 }
809 }
810
811 /**
812 * Redirect to Special:Listfiles?user=$wgUser
813 */
814 class SpecialMyuploads extends UnlistedSpecialPage {
815 function __construct() {
816 parent::__construct( 'Myuploads' );
817 $this->mAllowedRedirectParams = array( 'limit' );
818 }
819
820 function getRedirect( $subpage ) {
821 global $wgUser;
822 return SpecialPageFactory::getTitleFor( 'Listfiles', $wgUser->getName() );
823 }
824 }
825
826 /**
827 * Redirect from Special:PermanentLink/### to index.php?oldid=###
828 */
829 class SpecialPermanentLink extends UnlistedSpecialPage {
830 function __construct() {
831 parent::__construct( 'PermanentLink' );
832 $this->mAllowedRedirectParams = array();
833 }
834
835 function getRedirect( $subpage ) {
836 $subpage = intval( $subpage );
837 $this->mAddedRedirectParams['oldid'] = $subpage;
838 return true;
839 }
840 }