Merge "Use display name in category page subheadings if provided"
[lhc/web/wiklou.git] / includes / specials / SpecialUploadStash.php
index f2da81f..555fe5c 100644 (file)
@@ -306,6 +306,8 @@ class SpecialUploadStash extends UnlistedSpecialPage {
                if ( $size > self::MAX_SERVE_BYTES ) {
                        throw new SpecialUploadStashTooLargeException();
                }
+               // Cancel output buffering and gzipping if set
+               wfResetOutputBuffers();
                self::outputFileHeaders( $contentType, $size );
                print $content;
 
@@ -367,13 +369,14 @@ class SpecialUploadStash extends UnlistedSpecialPage {
 
                $context = new DerivativeContext( $this->getContext() );
                $context->setTitle( $this->getPageTitle() ); // Remove subpage
-               $form = new HTMLForm( [
+               $form = HTMLForm::factory( 'ooui', [
                        'Clear' => [
                                'type' => 'hidden',
                                'default' => true,
                                'name' => 'clear',
                        ]
                ], $context, 'clearStashedUploads' );
+               $form->setSubmitDestructive();
                $form->setSubmitCallback( [ __CLASS__, 'tryClearStashedUploads' ] );
                $form->setSubmitTextMsg( 'uploadstash-clear' );
 
@@ -389,17 +392,27 @@ class SpecialUploadStash extends UnlistedSpecialPage {
                        sort( $files );
                        $fileListItemsHtml = '';
                        foreach ( $files as $file ) {
-                               // TODO: Use Linker::link or even construct the list in plain wikitext
-                               $fileListItemsHtml .= Html::rawElement( 'li', [],
-                                       Html::element( 'a', [ 'href' =>
-                                               $this->getPageTitle( "file/$file" )->getLocalURL() ], $file )
-                               );
+                               $itemHtml = Linker::linkKnown( $this->getPageTitle( "file/$file" ), htmlspecialchars( $file ) );
+                               try {
+                                       $fileObj = $this->stash->getFile( $file );
+                                       $thumb = $fileObj->generateThumbName( $file, [ 'width' => 220 ] );
+                                       $itemHtml .=
+                                               $this->msg( 'word-separator' )->escaped() .
+                                               $this->msg( 'parentheses' )->rawParams(
+                                                       Linker::linkKnown(
+                                                               $this->getPageTitle( "thumb/$file/$thumb" ),
+                                                               $this->msg( 'uploadstash-thumbnail' )->escaped()
+                                                       )
+                                               )->escaped();
+                               } catch ( Exception $e ) {
+                               }
+                               $fileListItemsHtml .= Html::rawElement( 'li', [], $itemHtml );
                        }
-                       $this->getOutput()->addHtml( Html::rawElement( 'ul', [], $fileListItemsHtml ) );
+                       $this->getOutput()->addHTML( Html::rawElement( 'ul', [], $fileListItemsHtml ) );
                        $form->displayForm( $formResult );
-                       $this->getOutput()->addHtml( Html::rawElement( 'p', [], $refreshHtml ) );
+                       $this->getOutput()->addHTML( Html::rawElement( 'p', [], $refreshHtml ) );
                } else {
-                       $this->getOutput()->addHtml( Html::rawElement( 'p', [],
+                       $this->getOutput()->addHTML( Html::rawElement( 'p', [],
                                Html::element( 'span', [], $this->msg( 'uploadstash-nofiles' )->text() )
                                . ' '
                                . $refreshHtml