Fixes for IE7 (alignment of checkboxes due to double-margin bug on floated elements...
[mediawiki.git] / includes / SpecialPage.php
blob866cbecd5c7141fd7cf5dc965c46987fe7bb524b
1 <?php
2 /**
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 * @file
21 * @ingroup SpecialPage
22 * @defgroup SpecialPage SpecialPage
25 /**
26 * Parent special page class, also static functions for handling the special
27 * page list.
28 * @ingroup SpecialPage
30 class SpecialPage {
32 // The canonical name of this special page
33 // Also used for the default <h1> heading, @see getDescription()
34 /*private*/ var $mName;
36 // The local name of this special page
37 private $mLocalName;
39 // Minimum user level required to access this page, or "" for anyone.
40 // Also used to categorise the pages in Special:Specialpages
41 private $mRestriction;
43 // Listed in Special:Specialpages?
44 private $mListed;
46 // Function name called by the default execute()
47 private $mFunction;
49 // File which needs to be included before the function above can be called
50 private $mFile;
52 // Whether or not this special page is being included from an article
53 protected $mIncluding;
55 // Whether the special page can be included in an article
56 protected $mIncludable;
58 /**
59 * Current request context
60 * @var RequestContext
62 protected $mContext;
64 /**
65 * Initialise the special page list
66 * This must be called before accessing SpecialPage::$mList
67 * @deprecated since 1.18
69 static function initList() {
70 // Noop
73 /**
74 * @deprecated since 1.18
76 static function initAliasList() {
77 // Noop
80 /**
81 * Given a special page alias, return the special page name.
82 * Returns false if there is no such alias.
84 * @param $alias String
85 * @return String or false
86 * @deprecated since 1.18 call SpecialPageFactory method directly
88 static function resolveAlias( $alias ) {
89 list( $name, /*...*/ ) = SpecialPageFactory::resolveAlias( $alias );
90 return $name;
93 /**
94 * Given a special page name with a possible subpage, return an array
95 * where the first element is the special page name and the second is the
96 * subpage.
98 * @param $alias String
99 * @return Array
100 * @deprecated since 1.18 call SpecialPageFactory method directly
102 static function resolveAliasWithSubpage( $alias ) {
103 return SpecialPageFactory::resolveAlias( $alias );
107 * Add a page to the list of valid special pages. This used to be the preferred
108 * method for adding special pages in extensions. It's now suggested that you add
109 * an associative record to $wgSpecialPages. This avoids autoloading SpecialPage.
111 * @param $page SpecialPage
112 * @deprecated in 1.7, warnings in 1.17, might be removed in 1.20
114 static function addPage( &$page ) {
115 wfDeprecated( __METHOD__ );
116 SpecialPageFactory::getList()->{$page->mName} = $page;
120 * Add a page to a certain display group for Special:SpecialPages
122 * @param $page Mixed: SpecialPage or string
123 * @param $group String
124 * @deprecated since 1.18 call SpecialPageFactory method directly
126 static function setGroup( $page, $group ) {
127 return SpecialPageFactory::setGroup( $page, $group );
131 * Add a page to a certain display group for Special:SpecialPages
133 * @param $page SpecialPage
134 * @deprecated since 1.18 call SpecialPageFactory method directly
136 static function getGroup( &$page ) {
137 return SpecialPageFactory::getGroup( $page );
141 * Remove a special page from the list
142 * Formerly used to disable expensive or dangerous special pages. The
143 * preferred method is now to add a SpecialPage_initList hook.
144 * @deprecated since 1.18
146 static function removePage( $name ) {
147 unset( SpecialPageFactory::getList()->$name );
151 * Check if a given name exist as a special page or as a special page alias
153 * @param $name String: name of a special page
154 * @return Boolean: true if a special page exists with this name
155 * @deprecated since 1.18 call SpecialPageFactory method directly
157 static function exists( $name ) {
158 return SpecialPageFactory::exists( $name );
162 * Find the object with a given name and return it (or NULL)
164 * @param $name String
165 * @return SpecialPage object or null if the page doesn't exist
166 * @deprecated since 1.18 call SpecialPageFactory method directly
168 static function getPage( $name ) {
169 return SpecialPageFactory::getPage( $name );
173 * Get a special page with a given localised name, or NULL if there
174 * is no such special page.
176 * @return SpecialPage object or null if the page doesn't exist
177 * @deprecated since 1.18 call SpecialPageFactory method directly
179 static function getPageByAlias( $alias ) {
180 return SpecialPageFactory::getPage( $alias );
184 * Return categorised listable special pages which are available
185 * for the current user, and everyone.
187 * @return Associative array mapping page's name to its SpecialPage object
188 * @deprecated since 1.18 call SpecialPageFactory method directly
190 static function getUsablePages() {
191 return SpecialPageFactory::getUsablePages();
195 * Return categorised listable special pages for all users
197 * @return Associative array mapping page's name to its SpecialPage object
198 * @deprecated since 1.18 call SpecialPageFactory method directly
200 static function getRegularPages() {
201 return SpecialPageFactory::getRegularPages();
205 * Return categorised listable special pages which are available
206 * for the current user, but not for everyone
208 * @return Associative array mapping page's name to its SpecialPage object
209 * @deprecated since 1.18 call SpecialPageFactory method directly
211 static function getRestrictedPages() {
212 return SpecialPageFactory::getRestrictedPages();
216 * Execute a special page path.
217 * The path may contain parameters, e.g. Special:Name/Params
218 * Extracts the special page name and call the execute method, passing the parameters
220 * Returns a title object if the page is redirected, false if there was no such special
221 * page, and true if it was successful.
223 * @param $title Title object
224 * @param $context RequestContext
225 * @param $including Bool output is being captured for use in {{special:whatever}}
226 * @deprecated since 1.18 call SpecialPageFactory method directly
228 public static function executePath( &$title, RequestContext &$context, $including = false ) {
229 return SpecialPageFactory::executePath( $title, $context, $including );
233 * Just like executePath() except it returns the HTML instead of outputting it
234 * Returns false if there was no such special page, or a title object if it was
235 * a redirect.
237 * @return String: HTML fragment
238 * @deprecated since 1.18 call SpecialPageFactory method directly
240 static function capturePath( &$title ) {
241 return SpecialPageFactory::capturePath( $title );
245 * Get the local name for a specified canonical name
247 * @param $name String
248 * @param $subpage Mixed: boolean false, or string
250 * @return String
251 * @deprecated since 1.18 call SpecialPageFactory method directly
253 static function getLocalNameFor( $name, $subpage = false ) {
254 return SpecialPageFactory::getLocalNameFor( $name, $subpage );
258 * Get a localised Title object for a specified special page name
260 * @return Title object
262 public static function getTitleFor( $name, $subpage = false ) {
263 $name = SpecialPageFactory::getLocalNameFor( $name, $subpage );
264 if ( $name ) {
265 return Title::makeTitle( NS_SPECIAL, $name );
266 } else {
267 throw new MWException( "Invalid special page name \"$name\"" );
272 * Get a localised Title object for a page name with a possibly unvalidated subpage
274 * @return Title object or null if the page doesn't exist
276 public static function getSafeTitleFor( $name, $subpage = false ) {
277 $name = SpecialPageFactory::getLocalNameFor( $name, $subpage );
278 if ( $name ) {
279 return Title::makeTitleSafe( NS_SPECIAL, $name );
280 } else {
281 return null;
286 * Get a title for a given alias
288 * @return Title or null if there is no such alias
289 * @deprecated since 1.18 call SpecialPageFactory method directly
291 static function getTitleForAlias( $alias ) {
292 return SpecialPageFactory::getTitleForAlias( $alias );
296 * Default constructor for special pages
297 * Derivative classes should call this from their constructor
298 * Note that if the user does not have the required level, an error message will
299 * be displayed by the default execute() method, without the global function ever
300 * being called.
302 * If you override execute(), you can recover the default behaviour with userCanExecute()
303 * and displayRestrictionError()
305 * @param $name String: name of the special page, as seen in links and URLs
306 * @param $restriction String: user right required, e.g. "block" or "delete"
307 * @param $listed Boolean: whether the page is listed in Special:Specialpages
308 * @param $function Callback: function called by execute(). By default it is constructed from $name
309 * @param $file String: file which is included by execute(). It is also constructed from $name by default
310 * @param $includable Boolean: whether the page can be included in normal pages
312 public function __construct( $name = '', $restriction = '', $listed = true, $function = false, $file = 'default', $includable = false ) {
313 $this->init( $name, $restriction, $listed, $function, $file, $includable );
317 * Do the real work for the constructor, mainly so __call() can intercept
318 * calls to SpecialPage()
319 * @see __construct() for param docs
321 private function init( $name, $restriction, $listed, $function, $file, $includable ) {
322 $this->mName = $name;
323 $this->mRestriction = $restriction;
324 $this->mListed = $listed;
325 $this->mIncludable = $includable;
326 if ( !$function ) {
327 $this->mFunction = 'wfSpecial'.$name;
328 } else {
329 $this->mFunction = $function;
331 if ( $file === 'default' ) {
332 $this->mFile = dirname(__FILE__) . "/specials/Special$name.php";
333 } else {
334 $this->mFile = $file;
339 * Use PHP's magic __call handler to get calls to the old PHP4 constructor
340 * because PHP E_STRICT yells at you for having __construct() and SpecialPage()
342 * @param $fName String Name of called method
343 * @param $a Array Arguments to the method
344 * @deprecated since 1.17, call parent::__construct()
346 public function __call( $fName, $a ) {
347 // Sometimes $fName is SpecialPage, sometimes it's specialpage. <3 PHP
348 if( strtolower( $fName ) == 'specialpage' ) {
349 // Deprecated messages now, remove in 1.19 or 1.20?
350 wfDeprecated( __METHOD__ );
352 $name = isset( $a[0] ) ? $a[0] : '';
353 $restriction = isset( $a[1] ) ? $a[1] : '';
354 $listed = isset( $a[2] ) ? $a[2] : true;
355 $function = isset( $a[3] ) ? $a[3] : false;
356 $file = isset( $a[4] ) ? $a[4] : 'default';
357 $includable = isset( $a[5] ) ? $a[5] : false;
358 $this->init( $name, $restriction, $listed, $function, $file, $includable );
359 } else {
360 $className = get_class( $this );
361 throw new MWException( "Call to undefined method $className::$fName" );
366 * Get the name of this Special Page.
367 * @return String
369 function getName() {
370 return $this->mName;
374 * Get the permission that a user must have to execute this page
375 * @return String
377 function getRestriction() {
378 return $this->mRestriction;
382 * Get the file which will be included by SpecialPage::execute() if your extension is
383 * still stuck in the past and hasn't overridden the execute() method. No modern code
384 * should want or need to know this.
385 * @return String
386 * @deprecated since 1.18
388 function getFile() {
389 return $this->mFile;
392 // FIXME: decide which syntax to use for this, and stick to it
394 * Whether this special page is listed in Special:SpecialPages
395 * @since r3583 (v1.3)
396 * @return Bool
398 function isListed() {
399 return $this->mListed;
402 * Set whether this page is listed in Special:Specialpages, at run-time
403 * @since r3583 (v1.3)
404 * @return Bool
406 function setListed( $listed ) {
407 return wfSetVar( $this->mListed, $listed );
410 * Get or set whether this special page is listed in Special:SpecialPages
411 * @since r11308 (v1.6)
412 * @return Bool
414 function listed( $x = null) {
415 return wfSetVar( $this->mListed, $x );
419 * Whether it's allowed to transclude the special page via {{Special:Foo/params}}
420 * @return Bool
422 public function isIncludable(){
423 return $this->mIncludable;
427 * These mutators are very evil, as the relevant variables should not mutate. So
428 * don't use them.
429 * @deprecated since 1.18
431 function name( $x = null ) { return wfSetVar( $this->mName, $x ); }
432 function restriction( $x = null) { return wfSetVar( $this->mRestriction, $x ); }
433 function func( $x = null) { return wfSetVar( $this->mFunction, $x ); }
434 function file( $x = null) { return wfSetVar( $this->mFile, $x ); }
435 function includable( $x = null ) { return wfSetVar( $this->mIncludable, $x ); }
438 * Whether the special page is being evaluated via transclusion
439 * @return Bool
441 function including( $x = null ) {
442 return wfSetVar( $this->mIncluding, $x );
446 * Get the localised name of the special page
448 function getLocalName() {
449 if ( !isset( $this->mLocalName ) ) {
450 $this->mLocalName = SpecialPageFactory::getLocalNameFor( $this->mName );
452 return $this->mLocalName;
456 * Is this page expensive (for some definition of expensive)?
457 * Expensive pages are disabled or cached in miser mode. Originally used
458 * (and still overridden) by QueryPage and subclasses, moved here so that
459 * Special:SpecialPages can safely call it for all special pages.
461 * @return Boolean
463 public function isExpensive() {
464 return false;
468 * Can be overridden by subclasses with more complicated permissions
469 * schemes.
471 * @return Boolean: should the page be displayed with the restricted-access
472 * pages?
474 public function isRestricted() {
475 global $wgGroupPermissions;
476 // DWIM: If all anons can do something, then it is not restricted
477 return $this->mRestriction != '' && empty($wgGroupPermissions['*'][$this->mRestriction]);
481 * Checks if the given user (identified by an object) can execute this
482 * special page (as defined by $mRestriction). Can be overridden by sub-
483 * classes with more complicated permissions schemes.
485 * @param $user User: the user to check
486 * @return Boolean: does the user have permission to view the page?
488 public function userCanExecute( User $user ) {
489 return $user->isAllowed( $this->mRestriction );
493 * Output an error message telling the user what access level they have to have
495 function displayRestrictionError() {
496 throw new PermissionsError( $this->mRestriction );
500 * Sets headers - this should be called from the execute() method of all derived classes!
502 function setHeaders() {
503 $out = $this->getOutput();
504 $out->setArticleRelated( false );
505 $out->setRobotPolicy( "noindex,nofollow" );
506 $out->setPageTitle( $this->getDescription() );
510 * Default execute method
511 * Checks user permissions, calls the function given in mFunction
513 * This must be overridden by subclasses; it will be made abstract in a future version
515 function execute( $par ) {
516 $this->setHeaders();
518 if ( $this->userCanExecute( $this->getUser() ) ) {
519 $func = $this->mFunction;
520 // only load file if the function does not exist
521 if(!is_callable($func) and $this->mFile) {
522 require_once( $this->mFile );
524 $this->outputHeader();
525 call_user_func( $func, $par, $this );
526 } else {
527 $this->displayRestrictionError();
532 * Outputs a summary message on top of special pages
533 * Per default the message key is the canonical name of the special page
534 * May be overriden, i.e. by extensions to stick with the naming conventions
535 * for message keys: 'extensionname-xxx'
537 * @param $summaryMessageKey String: message key of the summary
539 function outputHeader( $summaryMessageKey = '' ) {
540 global $wgContLang;
542 if( $summaryMessageKey == '' ) {
543 $msg = $wgContLang->lc( $this->getName() ) . '-summary';
544 } else {
545 $msg = $summaryMessageKey;
547 if ( !wfMessage( $msg )->isBlank() and ! $this->including() ) {
548 $this->getOutput()->wrapWikiMsg( "<div class='mw-specialpage-summary'>\n$1\n</div>", $msg );
554 * Returns the name that goes in the \<h1\> in the special page itself, and
555 * also the name that will be listed in Special:Specialpages
557 * Derived classes can override this, but usually it is easier to keep the
558 * default behaviour. Messages can be added at run-time, see
559 * MessageCache.php.
561 * @return String
563 function getDescription() {
564 return wfMsg( strtolower( $this->mName ) );
568 * Get a self-referential title object
570 * @return Title object
572 function getTitle( $subpage = false ) {
573 return self::getTitleFor( $this->mName, $subpage );
577 * Sets the context this SpecialPage is executed in
579 * @param $context RequestContext
580 * @since 1.18
582 public function setContext( $context ) {
583 $this->mContext = $context;
587 * Gets the context this SpecialPage is executed in
589 * @return RequestContext
590 * @since 1.18
592 public function getContext() {
593 if ( $this->mContext instanceof RequestContext ) {
594 return $this->mContext;
595 } else {
596 wfDebug( __METHOD__ . " called and \$mContext is null. Return RequestContext::getMain(); for sanity\n" );
597 return RequestContext::getMain();
602 * Get the WebRequest being used for this instance
604 * @return WebRequest
605 * @since 1.18
607 public function getRequest() {
608 return $this->getContext()->getRequest();
612 * Get the OutputPage being used for this instance
614 * @return OutputPage
615 * @since 1.18
617 public function getOutput() {
618 return $this->getContext()->getOutput();
622 * Shortcut to get the skin being used for this instance
624 * @return User
625 * @since 1.18
627 public function getUser() {
628 return $this->getContext()->getUser();
632 * Shortcut to get the skin being used for this instance
634 * @return Skin
635 * @since 1.18
637 public function getSkin() {
638 return $this->getContext()->getSkin();
642 * Return the full title, including $par
644 * @return Title
645 * @since 1.18
647 public function getFullTitle() {
648 return $this->getContext()->getTitle();
652 * Wrapper around wfMessage that sets the current context. Currently this
653 * is only the title.
655 * @see wfMessage
657 public function msg( /* $args */ ) {
658 return call_user_func_array( 'wfMessage', func_get_args() )->title( $this->getFullTitle() );
663 * Special page which uses an HTMLForm to handle processing. This is mostly a
664 * clone of FormAction. More special pages should be built this way; maybe this could be
665 * a new structure for SpecialPages
667 abstract class FormSpecialPage extends SpecialPage {
670 * Get an HTMLForm descriptor array
671 * @return Array
673 protected abstract function getFormFields();
676 * Add pre- or post-text to the form
677 * @return String HTML which will be sent to $form->addPreText()
679 protected function preText() { return ''; }
680 protected function postText() { return ''; }
683 * Play with the HTMLForm if you need to more substantially
684 * @param $form HTMLForm
686 protected function alterForm( HTMLForm $form ) {}
689 * Get the HTMLForm to control behaviour
690 * @return HTMLForm|null
692 protected function getForm() {
693 $this->fields = $this->getFormFields();
695 // Give hooks a chance to alter the form, adding extra fields or text etc
696 wfRunHooks( "Special{$this->getName()}ModifyFormFields", array( &$this->fields ) );
698 $form = new HTMLForm( $this->fields, $this->getContext() );
699 $form->setSubmitCallback( array( $this, 'onSubmit' ) );
700 $form->setWrapperLegend( wfMessage( strtolower( $this->getName() ) . '-legend' ) );
701 $form->addHeaderText( wfMessage( strtolower( $this->getName() ) . '-text' )->parseAsBlock() );
703 // Retain query parameters (uselang etc)
704 $params = array_diff_key( $this->getRequest()->getQueryValues(), array( 'title' => null ) );
705 $form->addHiddenField( 'redirectparams', wfArrayToCGI( $params ) );
707 $form->addPreText( $this->preText() );
708 $form->addPostText( $this->postText() );
709 $this->alterForm( $form );
711 // Give hooks a chance to alter the form, adding extra fields or text etc
712 wfRunHooks( "Special{$this->getName()}BeforeFormDisplay", array( &$form ) );
714 return $form;
718 * Process the form on POST submission.
719 * @param $data Array
720 * @return Bool|Array true for success, false for didn't-try, array of errors on failure
722 public abstract function onSubmit( array $data );
725 * Do something exciting on successful processing of the form, most likely to show a
726 * confirmation message
728 public abstract function onSuccess();
731 * Basic SpecialPage workflow: get a form, send it to the user; get some data back,
733 public function execute( $par ) {
734 $this->setParameter( $par );
735 $this->setHeaders();
737 // This will throw exceptions if there's a problem
738 $this->userCanExecute( $this->getUser() );
740 $form = $this->getForm();
741 if ( $form->show() ) {
742 $this->onSuccess();
747 * Maybe do something interesting with the subpage parameter
748 * @param $par String
750 protected function setParameter( $par ){}
753 * Checks if the given user (identified by an object) can perform this action. Can be
754 * overridden by sub-classes with more complicated permissions schemes. Failures here
755 * must throw subclasses of ErrorPageError
757 * @param $user User: the user to check, or null to use the context user
758 * @throws ErrorPageError
760 public function userCanExecute( User $user ) {
761 if ( $this->requiresWrite() && wfReadOnly() ) {
762 throw new ReadOnlyError();
765 if ( $this->getRestriction() !== null && !$user->isAllowed( $this->getRestriction() ) ) {
766 throw new PermissionsError( $this->getRestriction() );
769 if ( $this->requiresUnblock() && $user->isBlocked() ) {
770 $block = $user->mBlock;
771 throw new UserBlockedError( $block );
774 return true;
778 * Whether this action requires the wiki not to be locked
779 * @return Bool
781 public function requiresWrite() {
782 return true;
786 * Whether this action cannot be executed by a blocked user
787 * @return Bool
789 public function requiresUnblock() {
790 return true;
795 * Shortcut to construct a special page which is unlisted by default
796 * @ingroup SpecialPage
798 class UnlistedSpecialPage extends SpecialPage
800 function __construct( $name, $restriction = '', $function = false, $file = 'default' ) {
801 parent::__construct( $name, $restriction, false, $function, $file );
804 public function isListed(){
805 return false;
810 * Shortcut to construct an includable special page
811 * @ingroup SpecialPage
813 class IncludableSpecialPage extends SpecialPage
815 function __construct( $name, $restriction = '', $listed = true, $function = false, $file = 'default' ) {
816 parent::__construct( $name, $restriction, $listed, $function, $file, true );
819 public function isIncludable(){
820 return true;
825 * Shortcut to construct a special page alias.
826 * @ingroup SpecialPage
828 abstract class RedirectSpecialPage extends UnlistedSpecialPage {
830 // Query parameters that can be passed through redirects
831 protected $mAllowedRedirectParams = array();
833 // Query parameteres added by redirects
834 protected $mAddedRedirectParams = array();
836 public function execute( $par ){
837 $redirect = $this->getRedirect( $par );
838 $query = $this->getRedirectQuery();
839 // Redirect to a page title with possible query parameters
840 if ( $redirect instanceof Title ) {
841 $url = $redirect->getFullUrl( $query );
842 $this->getContext()->output->redirect( $url );
843 wfProfileOut( __METHOD__ );
844 return $redirect;
845 // Redirect to index.php with query parameters
846 } elseif ( $redirect === true ) {
847 global $wgScript;
848 $url = $wgScript . '?' . wfArrayToCGI( $query );
849 $this->getContext()->output->redirect( $url );
850 wfProfileOut( __METHOD__ );
851 return $redirect;
852 } else {
853 $class = __CLASS__;
854 throw new MWException( "RedirectSpecialPage $class doesn't redirect!" );
859 * If the special page is a redirect, then get the Title object it redirects to.
860 * False otherwise.
862 * @return Title|false
864 abstract public function getRedirect( $par );
867 * Return part of the request string for a special redirect page
868 * This allows passing, e.g. action=history to Special:Mypage, etc.
870 * @return String
872 public function getRedirectQuery() {
873 $params = array();
875 foreach( $this->mAllowedRedirectParams as $arg ) {
876 if( $this->getContext()->request->getVal( $arg, null ) !== null ){
877 $params[$arg] = $this->getContext()->request->getVal( $arg );
881 foreach( $this->mAddedRedirectParams as $arg => $val ) {
882 $params[$arg] = $val;
885 return count( $params )
886 ? $params
887 : false;
891 abstract class SpecialRedirectToSpecial extends RedirectSpecialPage {
893 var $redirName, $redirSubpage;
895 function __construct( $name, $redirName, $redirSubpage = false, $allowedRedirectParams = array(), $addedRedirectParams = array() ) {
896 parent::__construct( $name );
897 $this->redirName = $redirName;
898 $this->redirSubpage = $redirSubpage;
899 $this->mAllowedRedirectParams = $allowedRedirectParams;
900 $this->mAddedRedirectParams = $addedRedirectParams;
903 public function getRedirect( $subpage ) {
904 if ( $this->redirSubpage === false ) {
905 return SpecialPage::getTitleFor( $this->redirName, $subpage );
906 } else {
907 return SpecialPage::getTitleFor( $this->redirName, $this->redirSubpage );
913 * ListAdmins --> ListUsers/admin
915 class SpecialListAdmins extends SpecialRedirectToSpecial {
916 function __construct(){
917 parent::__construct( 'ListAdmins', 'ListUsers', 'sysop' );
922 * ListBots --> ListUsers/admin
924 class SpecialListBots extends SpecialRedirectToSpecial {
925 function __construct(){
926 parent::__construct( 'ListAdmins', 'ListUsers', 'bot' );
931 * CreateAccount --> UserLogin/signup
932 * FIXME: this (and the rest of the login frontend) needs to die a horrible painful death
934 class SpecialCreateAccount extends SpecialRedirectToSpecial {
935 function __construct(){
936 parent::__construct( 'CreateAccount', 'Userlogin', 'signup', array( 'uselang' ) );
940 * SpecialMypage, SpecialMytalk and SpecialMycontributions special pages
941 * are used to get user independant links pointing to the user page, talk
942 * page and list of contributions.
943 * This can let us cache a single copy of any generated content for all
944 * users.
948 * Shortcut to construct a special page pointing to current user user's page.
949 * @ingroup SpecialPage
951 class SpecialMypage extends RedirectSpecialPage {
952 function __construct() {
953 parent::__construct( 'Mypage' );
954 $this->mAllowedRedirectParams = array( 'action' , 'preload' , 'editintro',
955 'section', 'oldid', 'diff', 'dir' );
958 function getRedirect( $subpage ) {
959 global $wgUser;
960 if ( strval( $subpage ) !== '' ) {
961 return Title::makeTitle( NS_USER, $wgUser->getName() . '/' . $subpage );
962 } else {
963 return Title::makeTitle( NS_USER, $wgUser->getName() );
969 * Shortcut to construct a special page pointing to current user talk page.
970 * @ingroup SpecialPage
972 class SpecialMytalk extends RedirectSpecialPage {
973 function __construct() {
974 parent::__construct( 'Mytalk' );
975 $this->mAllowedRedirectParams = array( 'action' , 'preload' , 'editintro',
976 'section', 'oldid', 'diff', 'dir' );
979 function getRedirect( $subpage ) {
980 global $wgUser;
981 if ( strval( $subpage ) !== '' ) {
982 return Title::makeTitle( NS_USER_TALK, $wgUser->getName() . '/' . $subpage );
983 } else {
984 return Title::makeTitle( NS_USER_TALK, $wgUser->getName() );
990 * Shortcut to construct a special page pointing to current user contributions.
991 * @ingroup SpecialPage
993 class SpecialMycontributions extends RedirectSpecialPage {
994 function __construct() {
995 parent::__construct( 'Mycontributions' );
996 $this->mAllowedRedirectParams = array( 'limit', 'namespace', 'tagfilter',
997 'offset', 'dir', 'year', 'month', 'feed' );
1000 function getRedirect( $subpage ) {
1001 global $wgUser;
1002 return SpecialPage::getTitleFor( 'Contributions', $wgUser->getName() );
1007 * Redirect to Special:Listfiles?user=$wgUser
1009 class SpecialMyuploads extends RedirectSpecialPage {
1010 function __construct() {
1011 parent::__construct( 'Myuploads' );
1012 $this->mAllowedRedirectParams = array( 'limit' );
1015 function getRedirect( $subpage ) {
1016 global $wgUser;
1017 return SpecialPage::getTitleFor( 'Listfiles', $wgUser->getName() );
1022 * Redirect from Special:PermanentLink/### to index.php?oldid=###
1024 class SpecialPermanentLink extends RedirectSpecialPage {
1025 function __construct() {
1026 parent::__construct( 'PermanentLink' );
1027 $this->mAllowedRedirectParams = array();
1030 function getRedirect( $subpage ) {
1031 $subpage = intval( $subpage );
1032 $this->mAddedRedirectParams['oldid'] = $subpage;
1033 return true;