The conversion of SpecialNewpages to HTMLForm seems to be half-finished.
It's not using HTMLForm to read in the request query, which means we have
to roll our own logic. Kind of defeats the purpose of using HTMLForm in
the first place.
When ProtectedPages is converted to HTMLForm (T117722), it can use this new
field type.
Bug: T12817
Change-Id: I069609fbb37b18c3df25156779ad7ac7cd5d6813
'HTMLSelectNamespace' => __DIR__ . '/includes/htmlform/fields/HTMLSelectNamespace.php',
'HTMLSelectNamespaceWithButton' => __DIR__ . '/includes/htmlform/fields/HTMLSelectNamespaceWithButton.php',
'HTMLSelectOrOtherField' => __DIR__ . '/includes/htmlform/fields/HTMLSelectOrOtherField.php',
+ 'HTMLSizeFilterField' => __DIR__ . '/includes/htmlform/fields/HTMLSizeFilterField.php',
'HTMLSubmitField' => __DIR__ . '/includes/htmlform/fields/HTMLSubmitField.php',
'HTMLTagFilter' => __DIR__ . '/includes/htmlform/fields/HTMLTagFilter.php',
'HTMLTextAreaField' => __DIR__ . '/includes/htmlform/fields/HTMLTextAreaField.php',
'namespaceselect' => 'HTMLSelectNamespace',
'namespaceselectwithbutton' => 'HTMLSelectNamespaceWithButton',
'tagfilter' => 'HTMLTagFilter',
+ 'sizefilter' => 'HTMLSizeFilterField',
'submit' => 'HTMLSubmitField',
'hidden' => 'HTMLHiddenField',
'edittools' => 'HTMLEditTools',
--- /dev/null
+<?php
+
+/**
+ * A size filter field for use on query-type special pages. It looks a bit like:
+ *
+ * (o) Min size ( ) Max size: [ ] bytes
+ *
+ * Minimum size limits are represented using a positive integer, while maximum
+ * size limits are represented using a negative integer.
+ */
+class HTMLSizeFilterField extends HTMLIntField {
+ function getSize() {
+ return isset( $this->mParams['size'] ) ? $this->mParams['size'] : 9;
+ }
+
+ function getInputHTML( $value ) {
+ $attribs = [];
+ if ( !empty( $this->mParams['disabled'] ) ) {
+ $attribs['disabled'] = 'disabled';
+ }
+
+ $html = Xml::radioLabel(
+ $this->msg( 'minimum-size' )->text(),
+ $this->mName . '-mode',
+ 'min',
+ $this->mID . '-mode-min',
+ $value >= 0,
+ $attribs
+ );
+ $html .= ' ' . Xml::radioLabel(
+ $this->msg( 'maximum-size' )->text(),
+ $this->mName . '-mode',
+ 'max',
+ $this->mID . '-mode-max',
+ $value < 0,
+ $attribs
+ );
+ $html .= ' ' . parent::getInputHTML( $value ? abs( $value ) : '' );
+ $html .= ' ' . $this->msg( 'pagesize' )->parse();
+
+ return $html;
+ }
+
+ // No OOUI yet
+ function getInputOOUI( $value ) {
+ return false;
+ }
+
+ /**
+ * @param WebRequest $request
+ *
+ * @return string
+ */
+ function loadDataFromRequest( $request ) {
+ $size = $request->getInt( $this->mName );
+ if ( !$size ) {
+ return $this->getDefault();
+ }
+ $size = abs( $size );
+
+ // negative numbers represent "max", positive numbers represent "min"
+ if ( $request->getVal( $this->mName . '-mode' ) === 'max' ) {
+ return -$size;
+ } else {
+ return $size;
+ }
+ }
+
+ protected function needsLabel() {
+ return false;
+ }
+}
$opts->add( 'feed', '' );
$opts->add( 'tagfilter', '' );
$opts->add( 'invert', false );
+ $opts->add( 'size-mode', 'max' );
+ $opts->add( 'size', 0 );
$this->customFilters = [];
Hooks::run( 'SpecialNewPagesFilters', [ $this, &$this->customFilters ] );
$tagFilterVal = $this->opts->consumeValue( 'tagfilter' );
$nsinvert = $this->opts->consumeValue( 'invert' );
+ $size = $this->opts->consumeValue( 'size' );
+ $max = $this->opts->consumeValue( 'size-mode' ) === 'max';
+
// Check username input validity
$ut = Title::makeTitleSafe( NS_USER, $username );
$userText = $ut ? $ut->getText() : '';
'size' => 30,
'cssclass' => 'mw-autocomplete-user', // used by mediawiki.userSuggest
],
+ 'size' => [
+ 'type' => 'sizefilter',
+ 'name' => 'size',
+ 'default' => -$max * $size,
+ ],
];
$htmlForm = new HTMLForm( $form, $this->getContext() );
$username = $this->opts->getValue( 'username' );
$user = Title::makeTitleSafe( NS_USER, $username );
+ $size = abs( intval( $this->opts->getValue( 'size' ) ) );
+ if ( $size > 0 ) {
+ if ( $this->opts->getValue( 'size-mode' ) === 'max' ) {
+ $conds[] = 'page_len <= ' . $size;
+ } else {
+ $conds[] = 'page_len >= ' . $size;
+ }
+ }
+
$rcIndexes = [];
if ( $namespace !== false ) {