X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=docs%2Fhooks.txt;h=a248c290759426e29dec7eb7a73a9485ef16c87a;hb=495f9fa290939a064967d9bddeb2ae966fae9e85;hp=47505607f6d19fc58ec9bd0cb7274b939b3faa27;hpb=5580d3e4da8f4963bf9e8c36ca5c414fa1976bbe;p=lhc%2Fweb%2Fwiklou.git diff --git a/docs/hooks.txt b/docs/hooks.txt index 47505607f6..a248c29075 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -91,23 +91,29 @@ title-reversing if-blocks spread all over the codebase in showAnArticle, 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 @@ -347,19 +353,6 @@ from ApiBase::addDeprecation(). &$msgs: Message[] Messages to include in the help. Multiple messages will be joined with spaces. -'APIEditBeforeSave': DEPRECATED since 1.28! Use EditFilterMergedContent instead. -Before saving a page with api.php?action=edit, after -processing request parameters. Return false to let the request fail, returning -an error message or an tag if $resultArr was filled. -Unlike for example 'EditFilterMergedContent' this also being run on undo. -Since MediaWiki 1.25, 'EditFilterMergedContent' can also return error details -for the API and it's recommended to use it instead of this hook. -$editPage: the EditPage object -$text: the text passed to the API. Note that this includes only the single - section for section edit, and is not necessarily the final text in case of - automatically resolved edit conflicts. -&$resultArr: data in this array will be added to the API result - 'ApiFeedContributions::feedItem': Called to convert the result of ContribsPager into a FeedItem instance that ApiFeedContributions can consume. Implementors of this hook may cancel the hook to signal that the item is not viewable in the @@ -957,12 +950,6 @@ No return data is accepted; this hook is for auditing only. $req: AuthenticationRequest object describing the change (and target user) $status: StatusValue with the result of the action -'ChangePasswordForm': DEPRECATED since 1.27! Use AuthChangeFormFields or -security levels. For extensions that need to add a field to the ChangePassword -form via the Preferences form. -&$extraFields: An array of arrays that hold fields like would be passed to the - pretty function. - 'ChangesListInitRows': Batch process change list rows prior to rendering. $changesList: ChangesList instance $rows: The data that will be rendered. May be a \Wikimedia\Rdbms\IResultWrapper @@ -1546,6 +1533,7 @@ $user: User the list is being fetched for &$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 @@ -1738,6 +1726,11 @@ $contentHandler: ContentHandler for which the slot diff renderer is fetched. &$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 @@ -1829,7 +1822,7 @@ $page: ImagePage object $page: ImagePage object &$toc: Array of
  • strings -'ImgAuthBeforeStream': executed before file is streamed to user, but only when +'ImgAuthBeforeStream': Executed before file is streamed to user, but only when using img_auth.php. &$title: the Title object of the file as it would appear for the upload page &$path: the original file and path name when img_auth was invoked by the web @@ -1842,6 +1835,14 @@ using img_auth.php. $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. +'ImgAuthModifyHeaders': Executed just before a file is streamed to a user via +img_auth.php, allowing headers to be modified beforehand. +$title: LinkTarget object +&$headers: HTTP headers ( name => value, names are case insensitive ). + Two headers get special handling: If-Modified-Since (value must be + a valid HTTP date) and Range (must be of the form "bytes=(\d*-\d*)") + will be honored when streaming the file. + 'ImportHandleLogItemXMLTag': When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader: XMLReader object @@ -2106,8 +2107,6 @@ cache. $cache: The LocalisationCache object $code: language code &$alldata: The localisation data from core and extensions -&$purgeBlobs: whether to purge/update the message blobs via - MessageBlobStore::clear() 'LocalisationCacheRecacheFallback': Called for each language when merging fallback data into the cache. @@ -2828,6 +2827,7 @@ or request state must be added through MakeGlobalVariablesScript instead. Skin is made available for skin specific config. &$vars: [ variable name => value ] $skin: Skin +$config: Config object (since 1.34) 'ResourceLoaderJqueryMsgModuleMagicWords': Called in ResourceLoaderJqueryMsgModule to allow adding magic words for jQueryMsg. @@ -3213,6 +3213,13 @@ $request: WebRequest object for getting the value provided by the current user &$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) @@ -3313,8 +3320,8 @@ $opts: Array: key => value of hidden options for inclusion in custom forms '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 @@ -3498,6 +3505,12 @@ processing. &$archive: PageArchive object $title: Title object of the page that we're about to undelete +'UndeletePageToolLinks': Add one or more links to edit page subtitle when a page +has been previously deleted. +$context: IContextSource (object) +$linkRenderer: LinkRenderer instance +&$links: Array of HTML strings + 'UndeleteShowRevision': Called when showing a revision in Special:Undelete. $title: title object related to the revision $rev: revision (object) that will be viewed @@ -3578,14 +3591,6 @@ $props: (array|null) File properties, as returned by 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 @@ -3707,7 +3712,7 @@ $newUGMs: An associative array (group name => UserGroupMembership object) of 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.