r103762 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103761‎ | r103762 | r103763 >
Date:15:16, 20 November 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
* (bug 24765) User tool links edit hook

Original patch by "biolizard", updated to not use $this in static, and added relevant documentation
Modified paths:
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/Linker.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -387,7 +387,7 @@
388388 'ApiRsdServiceApis': Add or remove APIs from the RSD services list.
389389 Each service should have its own entry in the $apis array and have a
390390 unique name, passed as key for the array that represents the service data.
391 -In this data array, the key-value-pair identified by the apiLink key is
 391+In this data array, the key-value-pair identified by the apiLink key is
392392 required.
393393 &$apis: array of services
394394
@@ -613,15 +613,15 @@
614614 &$parser: Parser object
615615 &$ig: ImageGallery object
616616
617 -'BeforeWelcomeCreation': before the welcomecreation message is displayed to a newly created user
 617+'BeforeWelcomeCreation': before the welcomecreation message is displayed to a newly created user
618618 &$welcome_creation_msg: MediaWiki message name to display on the welcome screen to a newly created user account
619 -&$injected_html: Any HTML to inject after the "logged in" message of a newly created user account
 619+&$injected_html: Any HTML to inject after the "logged in" message of a newly created user account
620620
621 -'BitmapHandlerTransform': before a file is transformed, gives extension the
 621+'BitmapHandlerTransform': before a file is transformed, gives extension the
622622 possibility to transform it themselves
623 -$handler: BitmapHandler
 623+$handler: BitmapHandler
624624 $image: File
625 -&$scalerParams: Array with scaler parameters
 625+&$scalerParams: Array with scaler parameters
626626 &$mto: null, set to a MediaTransformOutput
627627
628628 'BitmapHandlerCheckImageArea': by BitmapHandler::normaliseParams, after all normalizations have been performed, except for the $wgMaxImageArea check
@@ -647,7 +647,7 @@
648648
649649 'CanonicalNamespaces': For extensions adding their own namespaces or altering the defaults
650650 &$namespaces: Array of namespace numbers with corresponding canonical names
651 -
 651+
652652 'CategoryPageView': before viewing a categorypage in CategoryPage::view
653653 $catpage: CategoryPage instance
654654
@@ -753,7 +753,7 @@
754754
755755 'EditPage::importFormData': allow extensions to read additional data
756756 posted in the form
757 -$editpage: EditPage instance
 757+$editpage: EditPage instance
758758 $request: Webrequest
759759 return value is ignored (should always return true)
760760
@@ -959,7 +959,7 @@
960960 that need to have versioned metadata should add an element to the end of
961961 the version array of the form 'handler_name=version'. Most media handlers
962962 won't need to do this unless they broke backwards compatibility with a
963 - previous version of the media handler metadata output.
 963+ previous version of the media handler metadata output.
964964 &$version: Array of version strings
965965
966966 'GetPreferences': modify user preferences
@@ -1000,7 +1000,7 @@
10011001 $imagePage: ImagePage object ($this)
10021002 $output: $wgOut
10031003
1004 -'ImagePageAfterImageLinks': called after the image links section on an image
 1004+'ImagePageAfterImageLinks': called after the image links section on an image
10051005 page is built
10061006 $imagePage: ImagePage object ($this)
10071007 &$html: HTML for the hook to add
@@ -1066,7 +1066,7 @@
10671067 'InterwikiLoadPrefix': When resolving if a given prefix is an interwiki or not.
10681068 Return true without providing an interwiki to continue interwiki search.
10691069 $prefix: interwiki prefix we are looking for.
1070 -&$iwData: output array describing the interwiki with keys iw_url, iw_local,
 1070+&$iwData: output array describing the interwiki with keys iw_url, iw_local,
10711071 iw_trans and optionally iw_api and iw_wikiid.
10721072
10731073 'InternalParseBeforeLinks': during Parser's internalParse method before links
@@ -1101,12 +1101,12 @@
11021102 $user: User the password is being validated for
11031103
11041104 'LanguageGetNamespaces': Provide custom ordering for namespaces or
1105 -remove namespaces. Do not use this hook to add namespaces. Use
 1105+remove namespaces. Do not use this hook to add namespaces. Use
11061106 CanonicalNamespaces for that.
11071107 &$namespaces: Array of namespaces indexed by their numbers
11081108
1109 -'LanguageGetMagic': DEPRECATED, use $magicWords in a file listed in
1110 -$wgExtensionMessagesFiles instead.
 1109+'LanguageGetMagic': DEPRECATED, use $magicWords in a file listed in
 1110+$wgExtensionMessagesFiles instead.
11111111 Use this to define synonyms of magic words depending of the language
11121112 $magicExtensions: associative array of magic words synonyms
11131113 $lang: laguage code (string)
@@ -1239,7 +1239,7 @@
12401240 $refreshLinks: RefreshLinks object
12411241
12421242 'MagicWordMagicWords': When defining new magic word.
1243 -DEPRECATED: use $magicWords in a file listed in
 1243+DEPRECATED: use $magicWords in a file listed in
12441244 $wgExtensionMessagesFiles instead.
12451245 $magicWords: array of strings
12461246
@@ -1296,8 +1296,8 @@
12971297 'MonoBookTemplateToolboxEnd': Called by Monobook skin after toolbox links have
12981298 been rendered (useful for adding more)
12991299 Note: this is only run for the Monobook skin. This hook is deprecated and
1300 -may be removed in the future. To add items to the toolbox you should use
1301 -the SkinTemplateToolboxEnd hook instead, which works for all
 1300+may be removed in the future. To add items to the toolbox you should use
 1301+the SkinTemplateToolboxEnd hook instead, which works for all
13021302 "SkinTemplate"-type skins.
13031303 $tools: array of tools
13041304
@@ -1542,8 +1542,8 @@
15431543
15441544 'ResourceLoaderGetStartupModules': Run once the startup module is being generated. This allows you
15451545 to add modules to the startup module. This hook should be used sparingly since any module added here
1546 -will be loaded on all pages. This hook is useful if you want to make code available to module loader
1547 -scripts.
 1546+will be loaded on all pages. This hook is useful if you want to make code available to module loader
 1547+scripts.
15481548
15491549 'ResourceLoaderRegisterModules': Right before modules information is required, such as when responding to a resource
15501550 loader request or generating HTML output.
@@ -1577,7 +1577,7 @@
15781578 &$title : Current Title object that is being returned (null if none found).
15791579
15801580 'SearchEngineReplacePrefixesComplete': Run after SearchEngine::replacePrefixes().
1581 -$searchEngine : The SearchEngine object. Users of this hooks will be interested
 1581+$searchEngine : The SearchEngine object. Users of this hooks will be interested
15821582 in the $searchEngine->namespaces array.
15831583 $query : Original query.
15841584 &$parsed : Resultant query with the prefixes stripped.
@@ -1635,7 +1635,7 @@
16361636 $type: 'normal' or 'history' for old/diff views
16371637 &$msg: overridable message; usually 'copyright' or 'history_copyright'. This message must be in HTML format, not wikitext!
16381638 &$link: overridable HTML link to be passed into the message as $1
1639 -&$forContent: overridable flag if copyright footer is shown in content language.
 1639+&$forContent: overridable flag if copyright footer is shown in content language.
16401640
16411641 'SkinGetPoweredBy'
16421642 &$text: additional 'powered by' icons in HTML.
@@ -1758,9 +1758,9 @@
17591759 'SpecialRandomGetRandomTitle': called during the execution of Special:Random,
17601760 use this to change some selection criteria or substitute a different title
17611761 &$randstr: The random number from wfRandom()
1762 -&$isRedir: Boolean, whether to select a redirect or non-redirect
 1762+&$isRedir: Boolean, whether to select a redirect or non-redirect
17631763 &$namespaces: An array of namespace indexes to get the title from
1764 -&$extra: An array of extra SQL statements
 1764+&$extra: An array of extra SQL statements
17651765 &$title: If the hook returns false, a Title object to use instead of the
17661766 result from the normal query
17671767
@@ -1828,10 +1828,10 @@
18291829 $term: string of search term
18301830
18311831 'SpecialStatsAddExtra': add extra statistic at the end of Special:Statistics
1832 -&$extraStats: Array to save the new stats
 1832+&$extraStats: Array to save the new stats
18331833 ( $extraStats['<name of statistic>'] => <value>; )
18341834
1835 -'SpecialUploadComplete': Called after successfully uploading a file from
 1835+'SpecialUploadComplete': Called after successfully uploading a file from
18361836 Special:Upload
18371837 $form: The SpecialUpload object
18381838
@@ -1938,7 +1938,7 @@
19391939 Lets you poke at member variables like $mUploadDescription before the
19401940 file is saved.
19411941 Do not use this hook to break upload processing. This will return the user to
1942 -a blank form with no error message; use UploadVerification and
 1942+a blank form with no error message; use UploadVerification and
19431943 UploadVerifyFile instead
19441944
19451945 'UploadCreateFromRequest': when UploadBase::createFromRequest has been called
@@ -1948,19 +1948,19 @@
19491949 'UploadComplete': when Upload completes an upload
19501950 &$upload: an UploadBase child instance
19511951
1952 -'UploadFormInitDescriptor': after the descriptor for the upload form as been
 1952+'UploadFormInitDescriptor': after the descriptor for the upload form as been
19531953 assembled
19541954 $descriptor: (array) the HTMLForm descriptor
19551955
1956 -'UploadFormSourceDescriptors': after the standard source inputs have been
 1956+'UploadFormSourceDescriptors': after the standard source inputs have been
19571957 added to the descriptor
19581958 $descriptor: (array) the HTMLForm descriptor
19591959
1960 -'UploadVerification': additional chances to reject an uploaded file. Consider
 1960+'UploadVerification': additional chances to reject an uploaded file. Consider
19611961 using UploadVerifyFile instead.
19621962 string $saveName: destination file name
19631963 string $tempName: filesystem path to the temporary file for checks
1964 -string &$error: output: message key for message to show if upload canceled
 1964+string &$error: output: message key for message to show if upload canceled
19651965 by returning false. May also be an array, where the first element
19661966 is the message key and the remaining elements are used as parameters to
19671967 the message.
@@ -1968,7 +1968,7 @@
19691969 'UploadVerifyFile': extra file verification, based on mime type, etc. Preferred
19701970 in most cases over UploadVerification.
19711971 object $upload: an instance of UploadBase, with all info about the upload
1972 -string $mime: the uploaded file's mime type, as detected by MediaWiki. Handlers
 1972+string $mime: the uploaded file's mime type, as detected by MediaWiki. Handlers
19731973 will typically only apply for specific mime types.
19741974 object &$error: output: true if the file is valid. Otherwise, an indexed array
19751975 representing the problem with the file, where the first element
@@ -2047,7 +2047,7 @@
20482048 called for every call to User::getDefaultOptions(), which means it's
20492049 potentially called dozens or hundreds of times. You may want to cache
20502050 the results of non-trivial operations in your hook function for this reason.
2051 -&$defaultOptions: Array of preference keys and their default values.
 2051+&$defaultOptions: Array of preference keys and their default values.
20522052
20532053 'UserGetEmail': called when getting an user email address
20542054 $user: User object
@@ -2161,6 +2161,11 @@
21622162 &$timestamp: new timestamp, change this to override local email
21632163 authentification timestamp
21642164
 2165+'UserToolLinksEdit': Called when generating a list user tool links
 2166+$userId: User id of the current user
 2167+$userText: User name of the current user
 2168+&$items: Array of user tool links
 2169+
21652170 'WantedPages::getQueryInfo': called in WantedPagesPage::getQueryInfo(), can be
21662171 used to alter the SQL query which gets the list of wanted pages
21672172 &$wantedPages: WantedPagesPage object
Index: trunk/phase3/includes/Linker.php
@@ -969,6 +969,8 @@
970970 $items[] = self::emailLink( $userId, $userText );
971971 }
972972
 973+ wfRunHooks( 'UserToolLinksEdit', array( $userId, $userText, &$items ) );
 974+
973975 if ( $items ) {
974976 return ' <span class="mw-usertoollinks">(' . $wgLang->pipeList( $items ) . ')</span>';
975977 } else {

Follow-up revisions

RevisionCommit summaryAuthorDate
r103994tweak hook doc; followup r103762brion00:56, 23 November 2011

Comments

#Comment by Sumanah (talk | contribs)   20:37, 20 November 2011

Should you also add this contributor to CREDITS?

#Comment by Reedy (talk | contribs)   00:04, 21 November 2011

I'm not sure...

I had to change the hook to get it to be correct ($this doesn't work in a static context), and write the documentation for the new hook

#Comment by Johnduhart (talk | contribs)   00:13, 21 November 2011
+'UserToolLinksEdit': Called when generating a list user tool links

Called when generating a list of user tool links?

#Comment by Brion VIBBER (talk | contribs)   00:57, 23 November 2011

Tweaked in r103994.

Status & tagging log