Make Special:MediaStatistics show a total count of file sizes
authorPranavK <pranavmk98@gmail.com>
Sat, 19 Dec 2015 12:42:06 +0000 (18:12 +0530)
committerPranavK <pranavmk98@gmail.com>
Tue, 22 Dec 2015 02:07:05 +0000 (07:37 +0530)
Bug: T117606
Change-Id: I4216566df4dd2423d679f0f64fa694fa06e55c0e

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

index e5ba8c6..aeebc42 100644 (file)
  */
 class MediaStatisticsPage extends QueryPage {
        protected $totalCount = 0, $totalBytes = 0;
+       /**
+       * @var integer $totalPerType Combined file size of all files in a section
+       */
+       protected $totalPerType = 0;
+       /**
+       * @var integer $totalSize Combined file size of all files
+       */
+       protected $totalSize = 0;
 
        function __construct( $name = 'MediaStatistics' ) {
                parent::__construct( $name );
@@ -123,6 +131,7 @@ class MediaStatisticsPage extends QueryPage {
                                        $this->outputTableEnd();
                                }
                                $this->outputMediaType( $mediaType );
+                               $this->totalPerType = 0;
                                $this->outputTableStart( $mediaType );
                                $prevMediaType = $mediaType;
                        }
@@ -130,6 +139,11 @@ class MediaStatisticsPage extends QueryPage {
                }
                if ( $prevMediaType !== null ) {
                        $this->outputTableEnd();
+                       $this->getOutput()->addWikiText(
+                               $this->msg( 'mediastatistics-allbytes' )
+                                       ->numParams( $this->totalSize )
+                                       ->text()
+                       );
                }
        }
 
@@ -138,6 +152,12 @@ class MediaStatisticsPage extends QueryPage {
         */
        protected function outputTableEnd() {
                $this->getOutput()->addHtml( Html::closeElement( 'table' ) );
+               $this->getOutput()->addWikiText(
+                               $this->msg( 'mediastatistics-bytespertype' )
+                                       ->numParams( $this->totalPerType )
+                                       ->text()
+               );
+               $this->totalSize += $this->totalPerType;
        }
 
        /**
@@ -180,7 +200,7 @@ class MediaStatisticsPage extends QueryPage {
                                ->numParams( $this->makePercentPretty( $bytes / $this->totalBytes ) )
                                ->parse()
                );
-
+               $this->totalPerType += $bytes;
                $this->getOutput()->addHTML( Html::rawElement( 'tr', array(), $row ) );
        }
 
index 70a2b80..b239e90 100644 (file)
        "mediastatistics-summary": "Statistics about uploaded file types. This only includes the most recent version of a file. Old or deleted versions of files are excluded.",
        "mediastatistics-nfiles": "$1 ($2%)",
        "mediastatistics-nbytes": "{{PLURAL:$1|$1 byte|$1 bytes}} ($2; $3%)",
+       "mediastatistics-bytespertype": "Total file size for this section: $1 bytes.",
+       "mediastatistics-allbytes": "Total file size for all files: $1 bytes.",
        "mediastatistics-table-mimetype": "MIME type",
        "mediastatistics-table-extensions": "Possible extensions",
        "mediastatistics-table-count": "Number of files",
index fc72a4b..86137cb 100644 (file)
        "mediastatistics-summary": "Used to explain that this page only does statistics over current versions of files. \"Old\" versions of files and deleted files are not counted.",
        "mediastatistics-nfiles": "{{optional}}\nEntry in table on [[Special:MediaStatistics]] that gives total number of files. $1 - number of files. $2 - percentage of total files that is this type (percent will be formatted to have about 3 interesting digits. e.g. 0.121 or 10.2)",
        "mediastatistics-nbytes": "Combined space of this type of file. Bytes and \"human units\" are shown so that users can better get a sense of magnitude when making comparisons.\n*$1 - total space in bytes.\n*$2 - total space in \"human units\" (i.e. KB, MB, GB, etc)\n*$3 - What percentage of the space all uploads take up does this file take up.",
+       "mediastatistics-bytespertype": "Combined space of one section of [[Special:MediaStatistics]]. \n*$1 - total space in bytes",
+       "mediastatistics-allbytes": "Combined space of all uploaded files. \n*$1 - total space in bytes",
        "mediastatistics-table-mimetype": "Header for table on Special:MediaStatistics. Column that lists MIME types (The values in this column will look like 'image/jpeg', and be linked to Special:MIMESearch).",
        "mediastatistics-table-extensions": "Header for column in tables on [[Special:MediaStatistics]] that lists possible extensions for a given file type. (The values in this column will be a comma separated list of file extensions, such as '.webm' or '.png, .apng').",
        "mediastatistics-table-count": "Column header on Special:MediaStatistics for the number of files column. The headers in this column use {{msg-mw|mediastatistics-nfiles}}.",