}
public function execute( $par ) {
+ $context = new DerivativeContext( $this->getContext() );
+
$this->setHeaders();
$this->outputHeader();
$mimeAnalyzer = MediaWiki\MediaWikiServices::getInstance()->getMimeAnalyzer();
$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
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() ) {
}
}
- 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,
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' )
->setMethod( 'get' )
->prepareForm()
->displayForm( false );
-
- $this->getOutput()->addModules( 'mediawiki.special.newFiles' );
}
protected function getGroupName() {
'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' => [
+++ /dev/null
-/*!
- * 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 ) );