Special:ListUsers: Use HTMLForm and OOUI
Also update the hooks documentation. Now that it is using HTMLForm the <fieldset> is closed before the submit button is added. The old code was closing the <fieldset> after adding the submit button so the documentatio made sense. Bug: T111999 Change-Id: I109065100e40fef0c56a010c444de04a40950479
This commit is contained in:
parent
620396a946
commit
283ee7238b
2 changed files with 76 additions and 60 deletions
|
|
@ -3112,7 +3112,7 @@ UsersPager::formatRow().
|
|||
&$item: HTML to be returned. Will be wrapped in <li></li> after the hook finishes
|
||||
$row: Database row object
|
||||
|
||||
'SpecialListusersHeader': Called before closing the <fieldset> in
|
||||
'SpecialListusersHeader': Called after adding the submit button in
|
||||
UsersPager::getPageHeader().
|
||||
$pager: The UsersPager instance
|
||||
&$out: The header HTML
|
||||
|
|
|
|||
|
|
@ -270,71 +270,87 @@ class UsersPager extends AlphabeticPager {
|
|||
function getPageHeader() {
|
||||
list( $self ) = explode( '/', $this->getTitle()->getPrefixedDBkey() );
|
||||
|
||||
$this->getOutput()->addModules( 'mediawiki.userSuggest' );
|
||||
|
||||
# Form tag
|
||||
$out = Xml::openElement(
|
||||
'form',
|
||||
[ 'method' => 'get', 'action' => wfScript(), 'id' => 'mw-listusers-form' ]
|
||||
) .
|
||||
Xml::fieldset( $this->msg( 'listusers' )->text() ) .
|
||||
Html::hidden( 'title', $self );
|
||||
|
||||
# Username field (with autocompletion support)
|
||||
$out .= Xml::label( $this->msg( 'listusersfrom' )->text(), 'offset' ) . ' ' .
|
||||
Html::input(
|
||||
'username',
|
||||
$this->requestedUser,
|
||||
'text',
|
||||
[
|
||||
'class' => 'mw-autocomplete-user',
|
||||
'id' => 'offset',
|
||||
'size' => 20,
|
||||
'autofocus' => $this->requestedUser === ''
|
||||
]
|
||||
) . ' ';
|
||||
|
||||
# Group drop-down list
|
||||
$sel = new XmlSelect( 'group', 'group', $this->requestedGroup );
|
||||
$sel->addOption( $this->msg( 'group-all' )->text(), '' );
|
||||
$groupOptions = [ $this->msg( 'group-all' )->text() => '' ];
|
||||
foreach ( $this->getAllGroups() as $group => $groupText ) {
|
||||
$sel->addOption( $groupText, $group );
|
||||
$groupOptions[ $groupText ] = $group;
|
||||
}
|
||||
|
||||
$out .= Xml::label( $this->msg( 'group' )->text(), 'group' ) . ' ';
|
||||
$out .= $sel->getHTML() . '<br />';
|
||||
$out .= Xml::checkLabel(
|
||||
$this->msg( 'listusers-editsonly' )->text(),
|
||||
'editsOnly',
|
||||
'editsOnly',
|
||||
$this->editsOnly
|
||||
);
|
||||
$out .= ' ';
|
||||
$out .= Xml::checkLabel(
|
||||
$this->msg( 'listusers-creationsort' )->text(),
|
||||
'creationSort',
|
||||
'creationSort',
|
||||
$this->creationSort
|
||||
);
|
||||
$out .= ' ';
|
||||
$out .= Xml::checkLabel(
|
||||
$this->msg( 'listusers-desc' )->text(),
|
||||
'desc',
|
||||
'desc',
|
||||
$this->mDefaultDirection
|
||||
);
|
||||
$out .= '<br />';
|
||||
$optionsDefault = [];
|
||||
if ( $this->editsOnly ) {
|
||||
$optionsDefault[] = 'editsOnly';
|
||||
}
|
||||
if ( $this->creationSort ) {
|
||||
$optionsDefault[] = 'creationSort';
|
||||
}
|
||||
if ( $this->mDefaultDirection ) {
|
||||
$optionsDefault[] = 'desc';
|
||||
}
|
||||
|
||||
Hooks::run( 'SpecialListusersHeaderForm', [ $this, &$out ] );
|
||||
$formDescriptor = [
|
||||
'user' => [
|
||||
'class' => 'HTMLUserTextField',
|
||||
'label' => $this->msg( 'listusersfrom' )->text(),
|
||||
'name' => 'username',
|
||||
'value' => $this->requestedUser,
|
||||
],
|
||||
'dropdown' => [
|
||||
'label' => $this->msg( 'group' ),
|
||||
'name' => 'group',
|
||||
'value' => $this->requestedGroup,
|
||||
'class' => 'HTMLSelectField',
|
||||
'options' => $groupOptions,
|
||||
],
|
||||
'options' => [
|
||||
'class' => 'HTMLMultiSelectField',
|
||||
'options' => [
|
||||
$this->msg( 'listusers-editsonly' )->text() => 'editsOnly',
|
||||
$this->msg( 'listusers-creationsort' )->text() => 'creationSort',
|
||||
$this->msg( 'listusers-desc' )->text() => 'desc'
|
||||
],
|
||||
'default' => $optionsDefault
|
||||
],
|
||||
'limithiddenfield' => [
|
||||
'class' => 'HTMLHiddenField',
|
||||
'name' => 'limit',
|
||||
'value' => $this->mLimit
|
||||
]
|
||||
];
|
||||
|
||||
# Submit button and form bottom
|
||||
$out .= Html::hidden( 'limit', $this->mLimit );
|
||||
$out .= Xml::submitButton( $this->msg( 'listusers-submit' )->text() );
|
||||
Hooks::run( 'SpecialListusersHeader', [ $this, &$out ] );
|
||||
$out .= Xml::closeElement( 'fieldset' ) .
|
||||
Xml::closeElement( 'form' );
|
||||
$beforeSubmitButtonHookOut = '';
|
||||
Hooks::run( 'SpecialListusersHeaderForm', [ $this, &$beforeSubmitButtonHookOut ] );
|
||||
|
||||
return $out;
|
||||
if ( $beforeSubmitButtonHookOut !== '' ) {
|
||||
$formDescriptior[ 'beforeSubmitButtonHookOut' ] = [
|
||||
'class' => 'HTMLInfoField',
|
||||
'raw' => true,
|
||||
'default' => $beforeSubmitButtonHookOut
|
||||
];
|
||||
}
|
||||
|
||||
$formDescriptor[ 'submit' ] = [
|
||||
'class' => 'HTMLSubmitField',
|
||||
'buttonlabel-message' => 'listusers-submit',
|
||||
];
|
||||
|
||||
$beforeClosingFieldsetHookOut = '';
|
||||
Hooks::run( 'SpecialListusersHeader', [ $this, &$beforeClosingFieldsetHookOut ] );
|
||||
|
||||
if ( $beforeClosingFieldsetHookOut !== '' ) {
|
||||
$formDescriptior[ 'beforeClosingFieldsetHookOut' ] = [
|
||||
'class' => 'HTMLInfoField',
|
||||
'raw' => true,
|
||||
'default' => $beforeClosingFieldsetHookOut
|
||||
];
|
||||
}
|
||||
|
||||
$htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() );
|
||||
$htmlForm
|
||||
->setMethod( 'get' )
|
||||
->setId( 'mw-listusers-form' )
|
||||
->setFormIdentifier( 'mw-listusers-form' )
|
||||
->suppressDefaultSubmit()
|
||||
->setWrapperLegendMsg( 'listusers' );
|
||||
return $htmlForm->prepareForm()->getHTML( true );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue