r41425 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41424‎ | r41425 | r41426 >
Date:14:05, 30 September 2008
Author:demon
Status:old (Comments)
Tags:
Comment:
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.
Modified paths:
  • /trunk/phase3/includes/Xml.php (modified) (history)
  • /trunk/phase3/includes/XmlFunctions.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialListUserRestrictions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Xml.php
@@ -112,11 +112,11 @@
113113 *
114114 * @param $selected Mixed: Namespace which should be pre-selected
115115 * @param $all Mixed: Value of an item denoting all namespaces, or null to omit
116 - * @param $hidden Mixed: Include hidden namespaces? [WTF? --RC]
117116 * @param $element_name String: value of the "name" attribute of the select tag
 117+ * @param $label String: optional label to add to the field
118118 * @return string
119119 */
120 - public static function namespaceSelector( $selected = '', $all = null, $hidden = false, $element_name = 'namespace' ) {
 120+ public static function namespaceSelector( $selected = '', $all = null, $element_name = 'namespace', $label = null ) {
121121 global $wgContLang;
122122 $namespaces = $wgContLang->getFormattedNamespaces();
123123 $options = array();
@@ -139,12 +139,16 @@
140140 $options[] = self::option( $name, $index, $index === $selected );
141141 }
142142
143 - return Xml::openElement( 'select', array( 'id' => 'namespace', 'name' => $element_name,
 143+ $ret = Xml::openElement( 'select', array( 'id' => 'namespace', 'name' => $element_name,
144144 'class' => 'namespaceselector' ) )
145145 . "\n"
146146 . implode( "\n", $options )
147147 . "\n"
148148 . Xml::closeElement( 'select' );
 149+ if ( !is_null( $label ) ) {
 150+ $ret = Xml::label( $label, $element_name ) . ' ' . $ret;
 151+ }
 152+ return $ret;
149153 }
150154
151155 /**
Index: trunk/phase3/includes/XmlFunctions.php
@@ -15,8 +15,8 @@
1616 function wfCloseElement( $element ) {
1717 return "</$element>";
1818 }
19 -function HTMLnamespaceselector($selected = '', $allnamespaces = null, $includehidden=false) {
20 - return Xml::namespaceSelector( $selected, $allnamespaces, $includehidden );
 19+function HTMLnamespaceselector($selected = '', $allnamespaces = null ) {
 20+ return Xml::namespaceSelector( $selected, $allnamespaces );
2121 }
2222 function wfSpan( $text, $class, $attribs=array() ) {
2323 return Xml::span( $text, $class, $attribs );
Index: trunk/phase3/includes/specials/SpecialListUserRestrictions.php
@@ -35,7 +35,7 @@
3636 false, $wgRequest->getVal( 'user' ) );
3737 $s .= '<p>';
3838 $s .= Xml::label( wfMsgHtml( 'listuserrestrictions-namespace' ), 'namespace' ) . '&nbsp;' .
39 - Xml::namespaceSelector( $wgRequest->getVal( 'namespace' ), '', false, 'namespace' );
 39+ Xml::namespaceSelector( $wgRequest->getVal( 'namespace' ), '', 'namespace' );
4040 $s .= '&nbsp;';
4141 $s .= Xml::inputLabel( wfMsgHtml( 'listuserrestrictions-page' ), 'page', 'page',
4242 false, $wgRequest->getVal( 'page' ) );

Follow-up revisions

RevisionCommit summaryAuthorDate
r109993[Html] Unit test + bugfix Html::namespaceSelector...krinkle03:25, 25 January 2012

Comments

#Comment by Brion VIBBER (talk | contribs)   01:02, 1 October 2008

I'm a little worried about this since it changes the order of parameters on the function. Are you sure it's being being used in extensions etc?

#Comment by 😂 (talk | contribs)   14:39, 6 October 2008

Double checked against all extensions in the MW svn, nothing came up that needed changing.

#Comment by Brion VIBBER (talk | contribs)   20:47, 8 October 2008

w00t. I still hate interface changes like that, though...

Status & tagging log