|This page is under construction|
Please help review and edit this page.
If you have read the guide on how to write an extension already, continue on! Otherwise, please go back to it as it is a prerequisite for this guide.
Special pages are unique pages in MediaWiki that allow performing a certain function, such as protecting a page so only users with certain permissions can edit it, changing the password to your account, viewing the contributions to the wiki by a specific user, and so on.
Difference between concrete classes and abstract classes
This guide makes references to concrete classes and abstract classes. The following bullet points aim to explain the difference to programmers who are writing their first extension in PHP, and don't understand the difference yet. If you already understand these concepts, feel free to skip ahead to the next section.
- A concrete class is considered "complete" as it has implementations for all of its methods, while an abstract does not have implementations for all of its methods.
- An abstract class is prefixed at its declaration with
abstract, while a concrete class does not have this keyword prefixed.
- A concrete class can be instantiated using the
newkeyword, while abstract classes cannot be instantiated.
- A concrete class is not necessarily meant to always be extended. An abstract class is always meant to be extended, where the subclass must implement all methods marked as
In this special case, whileis a concrete class, it is always meant to be extended.
PHP class hierarchy
: A concrete class that all special pages inherit from. Special pages that need extra functionality can extend one of the listed subclasses that are marked as stable to extend.
- : An abstract class that special pages use for managing authentication requests and session requests.
- Special:RecentChanges and Special:Watchlist. : An abstract class that special pages use to show a list of changes based on certain conditions. This is used by
- HTMLForm component. This includes by default, but is not limited to: Special:BotPasswords, Special:ChangeContentModel, and Special:ChangeEmail. : An abstract class that is used to help create special pages with HTML forms, using the MediaWiki
- Special:Contributions is includable, and could be written as
User123with your own username in a sandbox page to test this out!)
: A concrete class that can be extended to easily mark a special page as includable. An includable special page means its content can be inserted into another page, by writing two curly brackets on the side of a special page, and the name of a special page. For example,
: An abstract class for special pages that query the database.
- Special:MostLinkedFiles, Special:UncategorizedFiles, and Special:UnusedFiles. : An abstract class that outputs a gallery for querying images. This by default includes
- Special:DeadendPages, Special:LonelyPages, Special:UncategorizedPages (which Special:UncategorizedCategories and Special:UncategorizedTemplates both extend from), and Special:WithoutInterwiki. : An abstract class that renders an HTML link to each page in the queried list. This by default includes
- Special:WantedFiles, Special:WantedPages, Special:WantedTemplates, and Special:WantedCategories. : An abstract class for defining wanted pages. This by default includes
- Special:SpecialPages by default.
: An abstract class for making a special page that is unlisted from
- (introduced in 1.33) : A concrete class for marking a special page as disabled.
- : An abstract class for defining an alias to a special page.