- $tagFilter = ChangeTags::buildTagFilterSelector(
- $this->opts['tagfilter'], false, $this->getContext() );
-
- if ( $tagFilter ) {
- $filterSelection = Html::rawElement(
- 'div',
- [],
- implode( "\u{00A0}", $tagFilter )
- );
- } else {
- $filterSelection = Html::rawElement( 'div', [], '' );
- }
-
- $labelUsername = Xml::label(
- $this->msg( 'sp-contributions-username' )->text(),
- 'mw-target-user-or-ip'
- );
- $input = Html::input(
- 'target',
- $this->opts['target'],
- 'text',
- [
- 'id' => 'mw-target-user-or-ip',
- 'size' => '40',
- 'class' => [
- 'mw-input',
- 'mw-ui-input-inline',
- 'mw-autocomplete-user', // used by mediawiki.userSuggest
- ],
- ] + (
- // Only autofocus if target hasn't been specified
- $this->opts['target'] ? [] : [ 'autofocus' => true ]
- )
- );
-
- $targetSelection = Html::rawElement(
- 'div',
- [],
- $labelUsername . ' ' . $input . ' '
- );
-
- $hidden = $this->opts['namespace'] === '' ? ' mw-input-hidden' : '';
- $namespaceSelection = Xml::tags(
- 'div',
- [],
- Xml::label(
- $this->msg( 'namespace' )->text(),
- 'namespace'
- ) . "\u{00A0}" .
- Html::namespaceSelector(
- [ 'selected' => $this->opts['namespace'], 'all' => '', 'in-user-lang' => true ],
- [
- 'name' => 'namespace',
- 'id' => 'namespace',
- 'class' => 'namespaceselector',
- ]
- ) . "\u{00A0}" .
- Html::rawElement(
- 'span',
- [ 'class' => 'mw-input-with-label' . $hidden ],
- Xml::checkLabel(
- $this->msg( 'invert' )->text(),
- 'nsInvert',
- 'nsinvert',
- $this->opts['nsInvert'],
- [
- 'title' => $this->msg( 'tooltip-invert' )->text(),
- 'class' => 'mw-input'
- ]
- ) . "\u{00A0}"
- ) .
- Html::rawElement( 'span', [ 'class' => 'mw-input-with-label' . $hidden ],
- Xml::checkLabel(
- $this->msg( 'namespace_association' )->text(),
- 'associated',
- 'nsassociated',
- $this->opts['associated'],
- [
- 'title' => $this->msg( 'tooltip-namespace_association' )->text(),
- 'class' => 'mw-input'
- ]
- ) . "\u{00A0}"
- )
- );
+ $fields[$name] = [
+ 'name' => $name,
+ 'type' => 'hidden',
+ 'default' => $value,
+ ];
+ }
+
+ $target = $this->opts['target'] ?? null;
+ $fields['target'] = [
+ 'type' => 'text',
+ 'cssclass' => 'mw-autocomplete-user mw-ui-input-inline mw-input',
+ 'default' => $target ?
+ str_replace( '_', ' ', $target ) : '' ,
+ 'label' => $this->msg( 'sp-contributions-username' )->text(),
+ 'name' => 'target',
+ 'id' => 'mw-target-user-or-ip',
+ 'size' => 40,
+ 'autofocus' => !$target,
+ 'section' => 'contribs-top',
+ ];