SpecialUploadStash: Add links to view a thumb of each uploaded file
authorBartosz Dziewoński <matma.rex@gmail.com>
Fri, 18 Mar 2016 19:50:44 +0000 (20:50 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Fri, 18 Mar 2016 19:54:21 +0000 (20:54 +0100)
Recently I'm debugging some upload stash issues, and I'm finding it
really annoying when I can't view what's hidden behind the meaningless
names, as it's refusing to serve any files above 1 MB. Constructing
the thumb paths by hand is tiresome.

Change-Id: Ia88b1bb8ef1c9599ee6bc727d310c48393be36fd

includes/specials/SpecialUploadStash.php
languages/i18n/en.json
languages/i18n/qqq.json

index 199eebd..5d24e7b 100644 (file)
@@ -392,11 +392,21 @@ 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 ) );
                        $form->displayForm( $formResult );
index b27aee4..1675800 100644 (file)
        "uploadstash-badtoken": "Performing that action failed. Perhaps because your editing credentials expired. Please try again.",
        "uploadstash-errclear": "Clearing the files failed.",
        "uploadstash-refresh": "Refresh the list of files",
+       "uploadstash-thumbnail": "view thumbnail",
        "invalid-chunk-offset": "Invalid chunk offset",
        "img-auth-accessdenied": "Access denied",
        "img-auth-nopathinfo": "Missing PATH_INFO.\nYour server is not set up to pass this information.\nIt may be CGI-based and cannot support img_auth.\nSee https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Image_Authorization.",
index ae2eca4..5e517ec 100644 (file)
        "uploadstash-badtoken": "Used as error message in [[Special:UploadStash]].",
        "uploadstash-errclear": "Used as error message in [[Special:UploadStash]].",
        "uploadstash-refresh": "Used as link text in [[Special:UploadStash]].",
+       "uploadstash-thumbnail": "Used as link text in [[Special:UploadStash]].",
        "invalid-chunk-offset": "Error that can happen if chunks get uploaded out of order.\nAs a result of this error, clients can continue from an offset provided or restart the upload.\nUsed on [[Special:UploadWizard]].",
        "img-auth-accessdenied": "[[mw:Manual:Image Authorization|Manual:Image Authorization]]: Access Denied\n{{Identical|Access denied}}",
        "img-auth-nopathinfo": "[[mw:Manual:Image Authorization|Manual:Image Authorization]]: Missing PATH_INFO - see english description\n{{Doc-important|This is plain text. Do not use any wiki syntax.}}",