Merge "SpecialNewFiles: Swap from/to date serverside"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 7 Jul 2017 16:16:32 +0000 (16:16 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 7 Jul 2017 16:16:32 +0000 (16:16 +0000)
1  2 
includes/specials/SpecialNewimages.php

@@@ -33,6 -33,8 +33,8 @@@ class SpecialNewFiles extends Includabl
        }
  
        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,
                        // mediastatistics-header-video, mediastatistics-header-multimedia,
                        // mediastatistics-header-office, mediastatistics-header-text,
                        // mediastatistics-header-executable, mediastatistics-header-archive,
 +                      // mediastatistics-header-3d,
                        return $this->msg( 'mediastatistics-header-' . strtolower( $type ) )->text();
                }, $this->mediaTypes );
                $mediaTypesOptions = array_combine( $mediaTypesText, $this->mediaTypes );
                        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() {