From: Bartosz DziewoƄski Date: Fri, 18 Mar 2016 19:50:44 +0000 (+0100) Subject: SpecialUploadStash: Add links to view a thumb of each uploaded file X-Git-Tag: 1.31.0-rc.0~7538^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=68288cd6588a690d630a7aca666a70b361cf85c1;p=lhc%2Fweb%2Fwiklou.git SpecialUploadStash: Add links to view a thumb of each uploaded file 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 --- diff --git a/includes/specials/SpecialUploadStash.php b/includes/specials/SpecialUploadStash.php index 199eebd64f..5d24e7b37a 100644 --- a/includes/specials/SpecialUploadStash.php +++ b/includes/specials/SpecialUploadStash.php @@ -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 ); diff --git a/languages/i18n/en.json b/languages/i18n/en.json index b27aee4c51..167580050d 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -1565,6 +1565,7 @@ "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.", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index ae2eca4d75..5e517ecd3a 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -1741,6 +1741,7 @@ "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.}}",