Cleanup for Xml::namespaceSelector():
authorChad Horohoe <demon@users.mediawiki.org>
Tue, 30 Sep 2008 14:05:21 +0000 (14:05 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Tue, 30 Sep 2008 14:05:21 +0000 (14:05 +0000)
* Removed useless $hidden param, cleaned up calls that specified it (only 1, and it passed default false)
* Add $label param for easy attachment of labels to the selector.

includes/Xml.php
includes/XmlFunctions.php
includes/specials/SpecialListUserRestrictions.php

index 005428e..78f958f 100644 (file)
@@ -112,11 +112,11 @@ class Xml {
         *
         * @param $selected Mixed: Namespace which should be pre-selected
         * @param $all Mixed: Value of an item denoting all namespaces, or null to omit
-        * @param $hidden Mixed: Include hidden namespaces? [WTF? --RC]
         * @param $element_name String: value of the "name" attribute of the select tag
+        * @param $label String: optional label to add to the field
         * @return string
         */
-       public static function namespaceSelector( $selected = '', $all = null, $hidden = false, $element_name = 'namespace' ) {
+       public static function namespaceSelector( $selected = '', $all = null, $element_name = 'namespace', $label = null ) {
                global $wgContLang;
                $namespaces = $wgContLang->getFormattedNamespaces();
                $options = array();
@@ -139,12 +139,16 @@ class Xml {
                        $options[] = self::option( $name, $index, $index === $selected );
                }
 
-               return Xml::openElement( 'select', array( 'id' => 'namespace', 'name' => $element_name,
+               $ret = Xml::openElement( 'select', array( 'id' => 'namespace', 'name' => $element_name,
                        'class' => 'namespaceselector' ) )
                        . "\n"
                        . implode( "\n", $options )
                        . "\n"
                        . Xml::closeElement( 'select' );
+               if ( !is_null( $label ) ) {
+                       $ret = Xml::label( $label, $element_name ) . '&nbsp;' . $ret;
+               }
+               return $ret;
        }
 
        /**
index bc18a2c..b31ac89 100644 (file)
@@ -15,8 +15,8 @@ function wfOpenElement( $element, $attribs = null ) {
 function wfCloseElement( $element ) {
        return "</$element>";
 }
-function HTMLnamespaceselector($selected = '', $allnamespaces = null, $includehidden=false) {
-       return Xml::namespaceSelector( $selected, $allnamespaces, $includehidden );
+function HTMLnamespaceselector($selected = '', $allnamespaces = null ) {
+       return Xml::namespaceSelector( $selected, $allnamespaces );
 }
 function wfSpan( $text, $class, $attribs=array() ) {
        return Xml::span( $text, $class, $attribs );
index 908bdc1..6c3817a 100644 (file)
@@ -35,7 +35,7 @@ class SpecialListUserRestrictionsForm {
                        false, $wgRequest->getVal( 'user' ) );
                $s .= '<p>';
                $s .= Xml::label( wfMsgHtml( 'listuserrestrictions-namespace' ), 'namespace' ) . '&nbsp;' .
-                       Xml::namespaceSelector( $wgRequest->getVal( 'namespace' ), '', false, 'namespace' );
+                       Xml::namespaceSelector( $wgRequest->getVal( 'namespace' ), '', 'namespace' );
                $s .= '&nbsp;';
                $s .= Xml::inputLabel( wfMsgHtml( 'listuserrestrictions-page' ), 'page', 'page',
                        false, $wgRequest->getVal( 'page' ) );