From: Roan Kattouw Date: Thu, 25 Aug 2011 09:44:20 +0000 (+0000) Subject: Followup r92155, move preferences-specific code introduced in HTMLForm to Preferences... X-Git-Tag: 1.31.0-rc.0~28075 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=b295b9e1e1d48fb0c63bef43ee515721813f2d47;p=lhc%2Fweb%2Fwiklou.git Followup r92155, move preferences-specific code introduced in HTMLForm to Preferences.php. Dropping $displayTitle and replacing it with something else is OK since $displayTitle was introduced as a hack for the preferences form anyway --- diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index cfaa9c494e..da84fc30e2 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -681,9 +681,11 @@ class HTMLForm { /** * TODO: Document - * @param $fields + * @param $fields array of fields (either arrays or objects) + * @param $sectionName string ID attribute of the tag for this section, ignored if empty + * @param $fieldsetIDPrefix string ID prefix for the
tag of each subsection, ignored if empty */ - function displaySection( $fields, $sectionName = '', $displayTitle = false ) { + function displaySection( $fields, $sectionName = '', $fieldsetIDPrefix = '' ) { $tableHtml = ''; $subsectionHtml = ''; $hasLeftColumn = false; @@ -708,8 +710,8 @@ class HTMLForm { $section .= $this->mSectionFooters[$key]; } $attributes = array(); - if ( $displayTitle ) { - $attributes["id"] = 'prefsection-' . Sanitizer::escapeId( $key, 'noninitial' ); + if ( $fieldsetIDPrefix ) { + $attributes['id'] = Sanitizer::escapeId( "$fieldsetIDPrefix$key" ); } $subsectionHtml .= Xml::fieldset( $legend, $section, $attributes ) . "\n"; } diff --git a/includes/Preferences.php b/includes/Preferences.php index c8d3b50863..c999a2ef81 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -1535,6 +1535,6 @@ class PreferencesForm extends HTMLForm { * Get the whole body of the form. */ function getBody() { - return $this->displaySection( $this->mFieldTree, '', true ); + return $this->displaySection( $this->mFieldTree, '', 'mw-prefsection-' ); } } diff --git a/resources/mediawiki.special/mediawiki.special.preferences.js b/resources/mediawiki.special/mediawiki.special.preferences.js index ac0bc65780..63e3885bcb 100644 --- a/resources/mediawiki.special/mediawiki.special.preferences.js +++ b/resources/mediawiki.special/mediawiki.special.preferences.js @@ -28,7 +28,7 @@ $legends.each( function( i, legend ) { }); var $a = $( '', { text : $legend.text(), - id : ident.replace('prefsection', 'preftab'), + id : ident.replace( 'mw-prefsection', 'preftab' ), href : '#' + ident }).click( function( e ) { e.preventDefault(); @@ -52,8 +52,8 @@ $legends.each( function( i, legend ) { // On document ready: $( function() { var hash = window.location.hash; - if( hash.match( /^#prefsection-[\w-]+/ ) ) { - var $tab = $( hash.replace('prefsection', 'preftab') ); + if( hash.match( /^#mw-prefsection-[\w-]+/ ) ) { + var $tab = $( hash.replace( 'mw-prefsection', 'preftab' ) ); $tab.click(); } } );