r101354 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101353‎ | r101354 | r101355 >
Date:12:36, 31 October 2011
Author:catrope
Status:ok
Tags:
Comment:
Introduce the PreferencesGetLegend hook. I need this to customize the labels of <fieldset>s in the preferences for the Gadgets extension in the RL2 branch and I can't think of a cleaner way to do this.
Modified paths:
  • /trunk/phase3/docs/hooks.txt (modified) (history)
  • /trunk/phase3/includes/Preferences.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -1486,6 +1486,10 @@
14871487 &$text : text of the new section
14881488 Return false and put the merged text into $text to override the default behavior.
14891489
 1490+'PreferencesGetLegend': Override the text used for the <legend> of a preferences section
 1491+$key: the section name
 1492+&$legend: the legend text. Defaults to wfMsg( "prefs-$key" ) but may be overridden
 1493+
14901494 'PrefixSearchBackend': Override the title prefix search used for OpenSearch and
14911495 AJAX search suggestions. Put results into &$results outparam and return false.
14921496 $ns : array of int namespace keys to search in
Index: trunk/phase3/includes/Preferences.php
@@ -1565,4 +1565,14 @@
15661566 function getBody() {
15671567 return $this->displaySection( $this->mFieldTree, '', 'mw-prefsection-' );
15681568 }
 1569+
 1570+ /**
 1571+ * Get the <legend> for a given section key. Normally this is the
 1572+ * prefs-$key message but we'll allow extensions to override it.
 1573+ */
 1574+ function getLegend( $key ) {
 1575+ $legend = parent::getLegend( $key );
 1576+ wfRunHooks( 'PreferencesGetLegend', array( $key, &$legend ) );
 1577+ return $legend;
 1578+ }
15691579 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r101355Followup r101354: pass $this to the PreferencesGetLegend hook so the callee w...catrope13:19, 31 October 2011

Status & tagging log