Display the file sha1 value in the file info page
authorRazeSoldier <liguangjie4399@hotmail.com>
Fri, 29 Dec 2017 14:03:55 +0000 (22:03 +0800)
committerReedy <reedy@wikimedia.org>
Wed, 3 Jan 2018 12:35:42 +0000 (12:35 +0000)
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
languages/i18n/en.json
languages/i18n/qqq.json

index 62f7ddf..a8a8317 100644 (file)
@@ -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'] = [];
 
index 18c546d..5e206ef 100644 (file)
        "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",
index 0659453..30df1bd 100644 (file)
        "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}}",