Followup r92155, move preferences-specific code introduced in HTMLForm to Preferences...
authorRoan Kattouw <catrope@users.mediawiki.org>
Thu, 25 Aug 2011 09:44:20 +0000 (09:44 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Thu, 25 Aug 2011 09:44:20 +0000 (09:44 +0000)
includes/HTMLForm.php
includes/Preferences.php
resources/mediawiki.special/mediawiki.special.preferences.js

index cfaa9c4..da84fc3 100644 (file)
@@ -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 <table> tag for this section, ignored if empty
+        * @param $fieldsetIDPrefix string ID prefix for the <fieldset> 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";
                        }
index c8d3b50..c999a2e 100644 (file)
@@ -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-' );
        }
 }
index ac0bc65..63e3885 100644 (file)
@@ -28,7 +28,7 @@ $legends.each( function( i, legend ) {
        });
        var $a = $( '<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();
        }
 } );