jenkins-bot has submitted this change and it was merged. Change subject: Use HTMLForm for Special:FileDuplicateSearch ......................................................................
Use HTMLForm for Special:FileDuplicateSearch * Prepare the usage of MediaWiki UI. * Add new HTMLForm output mode "inline" (very close to "raw") Bug: 71436 Change-Id: I12240aaf624dff5219b344648b20373594b5ec46 --- M includes/htmlform/HTMLForm.php M includes/htmlform/HTMLFormField.php M includes/specials/SpecialFileDuplicateSearch.php 3 files changed, 48 insertions(+), 18 deletions(-) Approvals: TTO: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index 908fdf2..39ed24f 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -207,6 +207,7 @@ 'table', 'div', 'raw', + 'inline', ); /** @@ -1366,6 +1367,8 @@ $html = Html::rawElement( 'table', $attribs, Html::rawElement( 'tbody', array(), "\n$html\n" ) ) . "\n"; + } elseif ( $displayFormat === 'inline' ) { + $html = Html::rawElement( 'span', $attribs, "\n$html\n" ); } else { $html = Html::rawElement( 'div', $attribs, "\n$html\n" ); } diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php index 645b507..9576c77 100644 --- a/includes/htmlform/HTMLFormField.php +++ b/includes/htmlform/HTMLFormField.php @@ -567,6 +567,27 @@ } /** + * Get the complete field as an inline element. + * @since 1.25 + * @param string $value The value to set the input to. + * @return string Complete HTML inline element + */ + public function getInline( $value ) { + list( $errors, $errorClass ) = $this->getErrorsAndErrorClass( $value ); + $inputHtml = $this->getInputHTML( $value ); + $helptext = $this->getHelpTextHtmlDiv( $this->getHelpText() ); + $cellAttributes = array(); + $label = $this->getLabelHtml( $cellAttributes ); + + $html = "\n" . $errors . + $label . ' ' . + $inputHtml . + $helptext; + + return $html; + } + + /** * Generate help text HTML in table format * @since 1.20 * diff --git a/includes/specials/SpecialFileDuplicateSearch.php b/includes/specials/SpecialFileDuplicateSearch.php index 606f837..da79bb8 100644 --- a/includes/specials/SpecialFileDuplicateSearch.php +++ b/includes/specials/SpecialFileDuplicateSearch.php @@ -110,25 +110,31 @@ $out = $this->getOutput(); # Create the input form - $out->addHTML( - Html::openElement( - 'form', - array( 'id' => 'fileduplicatesearch', 'method' => 'get', 'action' => wfScript() ) - ) . "\n" . - Html::hidden( 'title', $this->getPageTitle()->getPrefixedDBkey() ) . "\n" . - Html::openElement( 'fieldset' ) . "\n" . - Html::element( 'legend', null, $this->msg( 'fileduplicatesearch-legend' )->text() ) . "\n" . - Xml::inputLabel( - $this->msg( 'fileduplicatesearch-filename' )->text(), - 'filename', - 'filename', - 50, - $this->filename - ) . "\n" . - Xml::submitButton( $this->msg( 'fileduplicatesearch-submit' )->text() ) . "\n" . - Html::closeElement( 'fieldset' ) . "\n" . - Html::closeElement( 'form' ) + $formFields = array( + 'filename' => array( + 'type' => 'text', + 'name' => 'filename', + 'label-message' => 'fileduplicatesearch-filename', + 'id' => 'filename', + 'size' => 50, + 'value' => $this->filename, + 'cssclass' => 'mw-ui-input-inline' + ), ); + $hiddenFields = array( + 'title' => $this->getPageTitle()->getPrefixedDBKey(), + ); + $htmlForm = HTMLForm::factory( 'inline', $formFields, $this->getContext() ); + $htmlForm->addHiddenFields( $hiddenFields ); + $htmlForm->setAction( wfScript() ); + $htmlForm->setMethod( 'get' ); + $htmlForm->setSubmitProgressive(); + $htmlForm->setSubmitTextMsg( $this->msg( 'fileduplicatesearch-submit' ) ); + $htmlForm->setWrapperLegendMsg( 'fileduplicatesearch-legend' ); + + // The form should be visible always, even if it was submitted (e.g. to perform another action). + // To bypass the callback validation of HTMLForm, use prepareForm() and displayForm(). + $htmlForm->prepareForm()->displayForm( false ); if ( $this->file ) { $this->hash = $this->file->getSha1(); -- To view, visit https://gerrit.wikimedia.org/r/170309 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I12240aaf624dff5219b344648b20373594b5ec46 Gerrit-PatchSet: 10 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.wel...@t-online.de> Gerrit-Reviewer: Bartosz DziewoĆski <matma....@gmail.com> Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.wel...@t-online.de> Gerrit-Reviewer: IAlex <coderev...@emsenhuber.ch> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: TTO <at.li...@live.com.au> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits