From 2167d0326101dcdcacd423227bc71ef6848d7478 Mon Sep 17 00:00:00 2001 From: Chad Horohoe Date: Tue, 30 Sep 2008 14:05:21 +0000 Subject: [PATCH] Cleanup for Xml::namespaceSelector(): * 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 | 10 +++++++--- includes/XmlFunctions.php | 4 ++-- includes/specials/SpecialListUserRestrictions.php | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/includes/Xml.php b/includes/Xml.php index 005428ef99..78f958f8f1 100644 --- a/includes/Xml.php +++ b/includes/Xml.php @@ -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 ) . ' ' . $ret; + } + return $ret; } /** diff --git a/includes/XmlFunctions.php b/includes/XmlFunctions.php index bc18a2cdac..b31ac89cdb 100644 --- a/includes/XmlFunctions.php +++ b/includes/XmlFunctions.php @@ -15,8 +15,8 @@ function wfOpenElement( $element, $attribs = null ) { function wfCloseElement( $element ) { return ""; } -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 ); diff --git a/includes/specials/SpecialListUserRestrictions.php b/includes/specials/SpecialListUserRestrictions.php index 908bdc1a9e..6c3817a117 100644 --- a/includes/specials/SpecialListUserRestrictions.php +++ b/includes/specials/SpecialListUserRestrictions.php @@ -35,7 +35,7 @@ class SpecialListUserRestrictionsForm { false, $wgRequest->getVal( 'user' ) ); $s .= '

'; $s .= Xml::label( wfMsgHtml( 'listuserrestrictions-namespace' ), 'namespace' ) . ' ' . - Xml::namespaceSelector( $wgRequest->getVal( 'namespace' ), '', false, 'namespace' ); + Xml::namespaceSelector( $wgRequest->getVal( 'namespace' ), '', 'namespace' ); $s .= ' '; $s .= Xml::inputLabel( wfMsgHtml( 'listuserrestrictions-page' ), 'page', 'page', false, $wgRequest->getVal( 'page' ) ); -- 2.20.1