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.
This commit is contained in:
parent
860eb6bed8
commit
2167d03261
3 changed files with 10 additions and 6 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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 );
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class SpecialListUserRestrictionsForm {
|
|||
false, $wgRequest->getVal( 'user' ) );
|
||||
$s .= '<p>';
|
||||
$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' ) );
|
||||
|
|
|
|||
Loading…
Reference in a new issue