Sethakill has uploaded a new change for review.
https://gerrit.wikimedia.org/r/286944
Change subject: Convert Special:AllMessages to use OOUI.
......................................................................
Convert Special:AllMessages to use OOUI.
Moved form from pager and
added new HTMLSelectLanguageField.
Bug: T117749, T134425
Change-Id: I46dc6cc8f7ddf8552a726202df136cbbff66588c
---
M autoload.php
M includes/htmlform/HTMLForm.php
M includes/specials/SpecialAllMessages.php
M includes/specials/pagers/AllMessagesTablePager.php
4 files changed, 84 insertions(+), 114 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/44/286944/1
diff --git a/autoload.php b/autoload.php
index 3b17215..4445b50 100644
--- a/autoload.php
+++ b/autoload.php
@@ -521,6 +521,7 @@
'HTMLRadioField' => __DIR__ . '/includes/htmlform/HTMLRadioField.php',
'HTMLSelectAndOtherField' => __DIR__ .
'/includes/htmlform/HTMLSelectAndOtherField.php',
'HTMLSelectField' => __DIR__ . '/includes/htmlform/HTMLSelectField.php',
+ 'HTMLSelectLanguageField' => __DIR__ .
'/includes/htmlform/HTMLSelectLanguageField.php',
'HTMLSelectLimitField' => __DIR__ .
'/includes/htmlform/HTMLSelectLimitField.php',
'HTMLSelectNamespace' => __DIR__ .
'/includes/htmlform/HTMLSelectNamespace.php',
'HTMLSelectNamespaceWithButton' => __DIR__ .
'/includes/htmlform/HTMLSelectNamespaceWithButton.php',
diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php
index 0dab3bb..8030916 100644
--- a/includes/htmlform/HTMLForm.php
+++ b/includes/htmlform/HTMLForm.php
@@ -148,6 +148,7 @@
'checkmatrix' => 'HTMLCheckMatrix',
'cloner' => 'HTMLFormFieldCloner',
'autocompleteselect' => 'HTMLAutoCompleteSelectField',
+ 'language' => 'HTMLSelectLanguageField',
// HTMLTextField will output the correct type="" attribute
automagically.
// There are about four zillion other HTML5 input types, like
range, but
// we don't use those at the moment, so no point in adding all
of them.
diff --git a/includes/specials/SpecialAllMessages.php
b/includes/specials/SpecialAllMessages.php
index 49ca9f4..481290b 100644
--- a/includes/specials/SpecialAllMessages.php
+++ b/includes/specials/SpecialAllMessages.php
@@ -28,10 +28,6 @@
* @ingroup SpecialPage
*/
class SpecialAllMessages extends SpecialPage {
- /**
- * @var AllMessagesTablePager
- */
- protected $table;
/**
* Constructor
@@ -46,7 +42,6 @@
* @param string $par Parameter passed to the page or null
*/
public function execute( $par ) {
- $request = $this->getRequest();
$out = $this->getOutput();
$this->setHeaders();
@@ -57,20 +52,74 @@
return;
}
- $this->outputHeader( 'allmessagestext' );
$out->addModuleStyles( 'mediawiki.special' );
$this->addHelpLink( 'Help:System message' );
- $this->table = new AllMessagesTablePager(
- $this,
- [],
- wfGetLangObj( $request->getVal( 'lang', $par ) )
- );
+ $lang = $this->getLanguage();
- $this->langcode = $this->table->lang->getCode();
+ $opts = new FormOptions();
- $out->addHTML( $this->table->buildForm() );
- $out->addParserOutputContent( $this->table->getFullOutput() );
+ $opts->add( 'prefix', '' );
+ $opts->add( 'filter', 'all' );
+ $opts->add( 'lang', $lang->getCode() );
+ $opts->add( 'limit', 50 );
+
+ $opts->fetchValuesFromRequest( $this->getRequest() );
+ $opts->validateIntBounds( 'limit', 0, 5000 );
+
+ $pager = new AllMessagesTablePager( $this->getContext(), $opts
);
+
+ $formDescriptor = [
+ 'prefix' => [
+ 'type' => 'text',
+ 'name' => 'prefix',
+ 'label-message' => 'allmessages-prefix',
+ ],
+
+ 'filter' => [
+ 'type' => 'radio',
+ 'name' => 'filter',
+ 'label-message' => 'allmessages-filter',
+ 'options' => [
+ $this->msg(
'allmessages-filter-unmodified' )->text() => 'unmodified',
+ $this->msg( 'allmessages-filter-all'
)->text() => 'all',
+ $this->msg(
'allmessages-filter-modified' )->text() => 'modified',
+ ],
+ 'default' => 'all',
+ ],
+
+ 'lang' => [
+ 'type' => 'language',
+ 'name' => 'lang',
+ 'label-message' => 'allmessages-language',
+ 'default' => $opts->getValue( 'lang' ),
+ ],
+
+ 'limit' => [
+ 'type' => 'limitselect',
+ 'name' => 'limit',
+ 'label-message' => 'table_pager_limit_label',
+ 'options' => [
+ $lang->formatNum( 20 ) => 20,
+ $lang->formatNum( 50 ) => 50,
+ $lang->formatNum( 100 ) => 100,
+ $lang->formatNum( 250 ) => 250,
+ $lang->formatNum( 500 ) => 500,
+ $lang->formatNum( 5000 ) => 5000,
+ ],
+ 'default' => $opts->getValue( 'limit' ),
+ ],
+ ];
+
+ $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor,
$this->getContext() )
+ ->setIntro( $this->msg( 'allmessagestext' ) )
+ ->setWrapperLegendMsg( 'allmessages' )
+ ->setSubmitTextMsg( 'allmessages-filter-submit' )
+ ->setMethod( 'get' )
+ ->prepareForm()
+ ->displayForm( false );
+
+ $out->addParserOutputContent( $pager->getFullOutput() );
}
protected function getGroupName() {
diff --git a/includes/specials/pagers/AllMessagesTablePager.php
b/includes/specials/pagers/AllMessagesTablePager.php
index 2f2cbc2..92d8c01 100644
--- a/includes/specials/pagers/AllMessagesTablePager.php
+++ b/includes/specials/pagers/AllMessagesTablePager.php
@@ -27,9 +27,7 @@
*/
class AllMessagesTablePager extends TablePager {
- protected $filter, $prefix, $langcode, $displayPrefix;
-
- public $mLimitsShown;
+ protected $langcode, $foreign, $prefix;
/**
* @var Language
@@ -41,42 +39,40 @@
*/
public $custom;
- function __construct( $page, $conds, $langObj = null ) {
- parent::__construct( $page->getContext() );
+ /**
+ * @param IContextSource $context
+ * @param FormOptions $opts
+ */
+ function __construct( IContextSource $context = null, FormOptions $opts
) {
+ parent::__construct( $context );
+
$this->mIndexField = 'am_title';
- $this->mPage = $page;
- $this->mConds = $conds;
// FIXME: Why does this need to be set to DIR_DESCENDING to
produce ascending ordering?
$this->mDefaultDirection = IndexPager::DIR_DESCENDING;
- $this->mLimitsShown = [ 20, 50, 100, 250, 500, 5000 ];
global $wgContLang;
- $this->talk = $this->msg( 'talkpagelinktext' )->escaped();
-
+ $langObj = wfGetLangObj( $opts->getValue( 'lang' ) );
$this->lang = ( $langObj ? $langObj : $wgContLang );
$this->langcode = $this->lang->getCode();
$this->foreign = $this->langcode !== $wgContLang->getCode();
- $request = $this->getRequest();
-
- $this->filter = $request->getVal( 'filter', 'all' );
- if ( $this->filter === 'all' ) {
+ $filter = $opts->getValue( 'filter' );
+ if ( $filter === 'all' ) {
$this->custom = null; // So won't match in either case
} else {
- $this->custom = ( $this->filter === 'unmodified' );
+ $this->custom = ( $filter === 'unmodified' );
}
- $prefix = $this->getLanguage()->ucfirst( $request->getVal(
'prefix', '' ) );
+ $prefix = $this->getLanguage()->ucfirst( $opts->getValue(
'prefix') );
$prefix = $prefix !== '' ?
- Title::makeTitleSafe( NS_MEDIAWIKI, $request->getVal(
'prefix', null ) ) :
+ Title::makeTitleSafe( NS_MEDIAWIKI, $opts->getValue(
'prefix' ) ) :
null;
if ( $prefix !== null ) {
- $this->displayPrefix = $prefix->getDBkey();
- $this->prefix = '/^' . preg_quote(
$this->displayPrefix, '/' ) . '/i';
+ $displayPrefix = $prefix->getDBkey();
+ $this->prefix = '/^' . preg_quote( $displayPrefix, '/'
) . '/i';
} else {
- $this->displayPrefix = false;
$this->prefix = false;
}
@@ -87,84 +83,6 @@
} else {
$this->suffix = '';
}
- }
-
- function buildForm() {
- $attrs = [ 'id' => 'mw-allmessages-form-lang', 'name' => 'lang'
];
- $msg = wfMessage( 'allmessages-language' );
- $langSelect = Xml::languageSelector( $this->langcode, false,
null, $attrs, $msg );
-
- $out = Xml::openElement( 'form', [
- 'method' => 'get',
- 'action' => $this->getConfig()->get( 'Script' ),
- 'id' => 'mw-allmessages-form'
- ] ) .
- Xml::fieldset( $this->msg( 'allmessages-filter-legend'
)->text() ) .
- Html::hidden( 'title',
$this->getTitle()->getPrefixedText() ) .
- Xml::openElement( 'table', [ 'class' =>
'mw-allmessages-table' ] ) . "\n" .
- '<tr>
- <td class="mw-label">' .
- Xml::label( $this->msg( 'allmessages-prefix' )->text(),
'mw-allmessages-form-prefix' ) .
- "</td>\n
- <td class=\"mw-input\">" .
- Xml::input(
- 'prefix',
- 20,
- str_replace( '_', ' ', $this->displayPrefix ),
- [ 'id' => 'mw-allmessages-form-prefix' ]
- ) .
- "</td>\n
- </tr>
- <tr>\n
- <td class='mw-label'>" .
- $this->msg( 'allmessages-filter' )->escaped() .
- "</td>\n
- <td class='mw-input'>" .
- Xml::radioLabel( $this->msg(
'allmessages-filter-unmodified' )->text(),
- 'filter',
- 'unmodified',
- 'mw-allmessages-form-filter-unmodified',
- ( $this->filter === 'unmodified' )
- ) .
- Xml::radioLabel( $this->msg( 'allmessages-filter-all'
)->text(),
- 'filter',
- 'all',
- 'mw-allmessages-form-filter-all',
- ( $this->filter === 'all' )
- ) .
- Xml::radioLabel( $this->msg(
'allmessages-filter-modified' )->text(),
- 'filter',
- 'modified',
- 'mw-allmessages-form-filter-modified',
- ( $this->filter === 'modified' )
- ) .
- "</td>\n
- </tr>
- <tr>\n
- <td class=\"mw-label\">" . $langSelect[0] .
"</td>\n
- <td class=\"mw-input\">" . $langSelect[1] .
"</td>\n
- </tr>" .
-
- '<tr>
- <td class="mw-label">' .
- Xml::label( $this->msg( 'table_pager_limit_label'
)->text(), 'mw-table_pager_limit_label' ) .
- '</td>
- <td class="mw-input">' .
- $this->getLimitSelect( [ 'id' =>
'mw-table_pager_limit_label' ] ) .
- '</td>
- <tr>
- <td></td>
- <td>' .
- Xml::submitButton( $this->msg(
'allmessages-filter-submit' )->text() ) .
- "</td>\n
- </tr>" .
-
- Xml::closeElement( 'table' ) .
- $this->getHiddenFields( [ 'title', 'prefix', 'filter',
'lang', 'limit' ] ) .
- Xml::closeElement( 'fieldset' ) .
- Xml::closeElement( 'form' );
-
- return $out;
}
function getAllMessages( $descending ) {
@@ -312,6 +230,7 @@
] ),
$this->msg(
'allmessages-filter-translate' )->text()
);
+ $talkLink = $this->msg( 'talkpagelinktext'
)->escaped();
if ( $this->mCurrentRow->am_customised ) {
$title = Linker::linkKnown( $title,
$this->getLanguage()->lcfirst( $value ) );
@@ -325,11 +244,11 @@
);
}
if ( $this->mCurrentRow->am_talk_exists ) {
- $talk = Linker::linkKnown( $talk,
$this->talk );
+ $talk = Linker::linkKnown( $talk,
$talkLink );
} else {
$talk = Linker::link(
$talk,
- $this->talk,
+ $talkLink,
[],
[],
[ 'broken' ]
--
To view, visit https://gerrit.wikimedia.org/r/286944
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I46dc6cc8f7ddf8552a726202df136cbbff66588c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Sethakill <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits