From 5aea96df5a7b55fe1be74dcc5259508b05d89577 Mon Sep 17 00:00:00 2001 From: RazeSoldier Date: Fri, 29 Dec 2017 22:03:55 +0800 Subject: [PATCH] Display the file sha1 value in the file info page When a visitor accesses an info page of an existing file, base-36 sha1 value of this file will displayed in the table of basic information. Bug: T181651 Change-Id: Ib8cae3e4070a186e28e8625556d3c510af0701c2 --- includes/actions/InfoAction.php | 12 ++++++++++++ languages/i18n/en.json | 1 + languages/i18n/qqq.json | 1 + 3 files changed, 14 insertions(+) diff --git a/includes/actions/InfoAction.php b/includes/actions/InfoAction.php index 62f7ddfc1a..a8a8317fbc 100644 --- a/includes/actions/InfoAction.php +++ b/includes/actions/InfoAction.php @@ -437,6 +437,18 @@ class InfoAction extends FormlessAction { ]; } + // Display image SHA-1 value + if ( $title->inNamespace( NS_FILE ) ) { + $fileObj = wfFindFile( $title ); + if ( $fileObj !== false ) { + $output = $fileObj->getSha1(); + $pageInfo['header-basic'][] = [ + $this->msg( 'pageinfo-file-hash' ), + $output + ]; + } + } + // Page protection $pageInfo['header-restrictions'] = []; diff --git a/languages/i18n/en.json b/languages/i18n/en.json index 18c546db9b..5e206ef6df 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -3055,6 +3055,7 @@ "pageinfo-category-subcats": "Number of subcategories", "pageinfo-category-files": "Number of files", "pageinfo-user-id": "User ID", + "pageinfo-file-hash": "Hash value", "markaspatrolleddiff": "Mark as patrolled", "markaspatrolledlink": "[$1]", "markaspatrolledtext": "Mark this page as patrolled", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 0659453915..30df1bd6b5 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -3250,6 +3250,7 @@ "pageinfo-category-subcats": "See also:\n* {{msg-mw|Pageinfo-category-pages}}\n* {{msg-mw|Pageinfo-category-files}}", "pageinfo-category-files": "See also:\n* {{msg-mw|Pageinfo-category-pages}}\n* {{msg-mw|Pageinfo-category-subcats}}", "pageinfo-user-id": "The numeric ID for a user\n{{Identical|User ID}}", + "pageinfo-file-hash": "Base-36 SHA-1 value of the file", "markaspatrolleddiff": "{{doc-actionlink}}\nSee also:\n* {{msg-mw|Markaspatrolledtext}}\n{{Identical|Mark as patrolled}}", "markaspatrolledlink": "{{notranslate}}\nParameters:\n* $1 - link which has text {{msg-mw|Markaspatrolledtext}}", "markaspatrolledtext": "{{doc-actionlink}}\nSee also:\n* {{msg-mw|Markaspatrolleddiff}}", -- 2.20.1