jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/363312 )
Change subject: SpecialNewFiles: Swap from/to date serverside
......................................................................
SpecialNewFiles: Swap from/to date serverside
Bug: T168695
Change-Id: I760096138da15a6f3b84a6db68ab5590f5a3e59b
---
M includes/specials/SpecialNewimages.php
M resources/Resources.php
D resources/src/mediawiki.special/mediawiki.special.newFiles.js
3 files changed, 15 insertions(+), 33 deletions(-)
Approvals:
Bartosz Dziewoński: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/specials/SpecialNewimages.php
b/includes/specials/SpecialNewimages.php
index 8528ce2..feceef1 100644
--- a/includes/specials/SpecialNewimages.php
+++ b/includes/specials/SpecialNewimages.php
@@ -33,6 +33,8 @@
}
public function execute( $par ) {
+ $context = new DerivativeContext( $this->getContext() );
+
$this->setHeaders();
$this->outputHeader();
$mimeAnalyzer =
MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
@@ -71,6 +73,15 @@
$opts->setValue( 'start', $start, true );
$opts->setValue( 'end', $end, true );
+
+ // also swap values in request object, which is used by
HTMLForm
+ // to pre-populate the fields with the previous input
+ $request = $context->getRequest();
+ $context->setRequest( new DerivativeRequest(
+ $request,
+ [ 'start' => $start, 'end' => $end ] +
$request->getValues(),
+ $request->wasPosted()
+ ) );
}
// if all media types have been selected, wipe out the array to
prevent
@@ -87,10 +98,10 @@
if ( !$this->including() ) {
$this->setTopText();
- $this->buildForm();
+ $this->buildForm( $context );
}
- $pager = new NewFilesPager( $this->getContext(), $opts );
+ $pager = new NewFilesPager( $context, $opts );
$out->addHTML( $pager->getBody() );
if ( !$this->including() ) {
@@ -98,7 +109,7 @@
}
}
- protected function buildForm() {
+ protected function buildForm( IContextSource $context ) {
$mediaTypesText = array_map( function ( $type ) {
// mediastatistics-header-unknown,
mediastatistics-header-bitmap,
// mediastatistics-header-drawing,
mediastatistics-header-audio,
@@ -184,7 +195,7 @@
unset( $formDescriptor['hidepatrolled'] );
}
- HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext()
)
+ HTMLForm::factory( 'ooui', $formDescriptor, $context )
// For the 'multiselect' field values to be preserved
on submit
->setFormIdentifier( 'specialnewimages' )
->setWrapperLegendMsg( 'newimages-legend' )
@@ -192,8 +203,6 @@
->setMethod( 'get' )
->prepareForm()
->displayForm( false );
-
- $this->getOutput()->addModules( 'mediawiki.special.newFiles' );
}
protected function getGroupName() {
diff --git a/resources/Resources.php b/resources/Resources.php
index 12f482f..8001243 100644
--- a/resources/Resources.php
+++ b/resources/Resources.php
@@ -2030,12 +2030,6 @@
'mediawiki.special.movePage.styles' => [
'styles' =>
'resources/src/mediawiki.special/mediawiki.special.movePage.css',
],
- 'mediawiki.special.newFiles' => [
- 'scripts' =>
'resources/src/mediawiki.special/mediawiki.special.newFiles.js',
- 'dependencies' => [
- 'mediawiki.widgets.datetime',
- ],
- ],
'mediawiki.special.pageLanguage' => [
'scripts' =>
'resources/src/mediawiki.special/mediawiki.special.pageLanguage.js',
'dependencies' => [
diff --git a/resources/src/mediawiki.special/mediawiki.special.newFiles.js
b/resources/src/mediawiki.special/mediawiki.special.newFiles.js
deleted file mode 100644
index 5e86eaa..0000000
--- a/resources/src/mediawiki.special/mediawiki.special.newFiles.js
+++ /dev/null
@@ -1,21 +0,0 @@
-/*!
- * JavaScript for Special:NewFiles
- */
-( function ( mw, $ ) {
- $( function () {
- var start =
mw.widgets.datetime.DateTimeInputWidget.static.infuse( 'mw-input-start' ),
- end =
mw.widgets.datetime.DateTimeInputWidget.static.infuse( 'mw-input-end' ),
- temp;
-
- // If the start date comes after the end date, swap the two
values.
- // This swap is already done internally when the form is
submitted with a start date that
- // comes after the end date, but this swap makes the change
visible in the HTMLForm.
- if ( start.getValue() !== '' &&
- end.getValue() !== '' &&
- start.getValue() > end.getValue() ) {
- temp = start.getValue();
- start.setValue( end.getValue() );
- end.setValue( temp );
- }
- } );
-}( mediaWiki, jQuery ) );
--
To view, visit https://gerrit.wikimedia.org/r/363312
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I760096138da15a6f3b84a6db68ab5590f5a3e59b
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits