deleteAnArticle, exportArticle, etc., we can concentrate it all in an extension
file:
- function reverseArticleTitle( $article ) {
+ function onArticleShow( &$article ) {
# ...
}
- function reverseForExport( $article ) {
+ function onArticleDelete( &$article ) {
# ...
}
-The setup function for the extension just has to add its hook functions to the
-appropriate events:
-
- setupTitleReversingExtension() {
- global $wgHooks;
+ function onArticleExport( &$article ) {
+ # ...
+ }
- $wgHooks['ArticleShow'][] = 'reverseArticleTitle';
- $wgHooks['ArticleDelete'][] = 'reverseArticleTitle';
- $wgHooks['ArticleExport'][] = 'reverseForExport';
+General practice is to have a dedicated file for functions activated by hooks,
+which functions named 'onHookName'. In the example above, the file
+'ReverseHooks.php' includes the functions that should be activated by the
+'ArticleShow', 'ArticleDelete', and 'ArticleExport' hooks. The 'extension.json'
+file with the extension's registration just has to add its hook functions
+to the appropriate events:
+
+ "Hooks": {
+ "ArticleShow": "ReverseHooks:onArticleShow",
+ "ArticleDelete": "ReverseHooks::onArticleDelete",
+ "ArticleExport": "ReverseHooks::onArticleExport"
}
Having all this code related to the title-reversion option in one place means
&$skin: Skin object to be used with the list
&$list: List object (defaults to NULL, change it to an object instance and
return false override the list derivative used)
+$groups Array of ChangesListFilterGroup objects (added in 1.34)
'FileDeleteComplete': When a file is deleted.
&$file: reference to the deleted file
&$slotDiffRenderer: SlotDiffRenderer to change or replace.
$context: IContextSource
+'GetUserBlock': Modify the block found by the block manager. This may be a
+single block or a composite block made from multiple blocks; the original
+blocks can be seen using CompositeBlock::getOriginalBlocks()
+&$block: AbstractBlock object
+
'getUserPermissionsErrors': Add a permissions error when permissions errors are
checked for. Use instead of userCan for most cases. Return false if the user
can't do it, and populate $result with the reason in the form of
&$oldTitle: old title (object)
&$newTitle: new title (object)
+'SpecialMuteModifyFormFields': Add more fields to Special:Mute
+$sp: SpecialPage object, for context
+&$fields: Current HTMLForm fields descriptors
+
+'SpecialMuteSubmit': DEPRECATED since 1.34! Used only for instrumentation on SpecialMute
+$data: Array containing information about submitted options on SpecialMute form
+
'SpecialNewpagesConditions': Called when building sql query for
Special:NewPages.
&$special: NewPagesPager object (subclass of ReverseChronologicalPager)
'SpecialSearchResults': Called before search result display
$term: string of search term
-&$titleMatches: empty or SearchResultSet object
-&$textMatches: empty or SearchResultSet object
+&$titleMatches: empty or ISearchResultSet object
+&$textMatches: empty or ISearchResultSet object
'SpecialSearchResultsPrepend': Called immediately before returning HTML
on the search results page. Useful for including an external search
MessageSpecifier instance (you might want to use ApiMessage to provide machine
-readable details for the API).
-'UploadVerification': DEPRECATED since 1.28! Use UploadVerifyFile instead.
-Additional chances to reject an uploaded file.
-$saveName: (string) destination file name
-$tempName: (string) filesystem path to the temporary file for checks
-&$error: (string) output: message key for message to show if upload canceled by
- returning false. May also be an array, where the first element is the message
- key and the remaining elements are used as parameters to the message.
-
'UploadVerifyFile': extra file verification, based on MIME type, etc. Preferred
in most cases over UploadVerification.
$upload: (object) an instance of UploadBase, with all info about the upload
the user's current group memberships.
'UserIsBlockedFrom': Check if a user is blocked from a specific page (for
-specific block exemptions).
+specific block exemptions if a user is already blocked).
$user: User in question
$title: Title of the page in question
&$blocked: Out-param, whether or not the user is blocked from that page.