*/
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 );
$this->shownavigation = false;
}
- function isExpensive() {
+ public function isExpensive() {
return true;
}
protected function outputResults( $out, $skin, $dbr, $res, $num, $offset ) {
$prevMediaType = null;
foreach ( $res as $row ) {
- list( $mediaType, $mime, $totalCount, $totalBytes ) = $this->splitFakeTitle( $row->title );
+ $mediaStats = $this->splitFakeTitle( $row->title );
+ if ( count( $mediaStats ) < 4 ) {
+ continue;
+ }
+ list( $mediaType, $mime, $totalCount, $totalBytes ) = $mediaStats;
if ( $prevMediaType !== $mediaType ) {
if ( $prevMediaType !== null ) {
// We're not at beginning, so we have to
$this->outputTableEnd();
}
$this->outputMediaType( $mediaType );
+ $this->totalPerType = 0;
$this->outputTableStart( $mediaType );
$prevMediaType = $mediaType;
}
}
if ( $prevMediaType !== null ) {
$this->outputTableEnd();
+ $this->getOutput()->addWikiText(
+ $this->msg( 'mediastatistics-allbytes' )
+ ->numParams( $this->totalSize )
+ ->text()
+ );
}
}
*/
protected function outputTableEnd() {
$this->getOutput()->addHtml( Html::closeElement( 'table' ) );
+ $this->getOutput()->addWikiText(
+ $this->msg( 'mediastatistics-bytespertype' )
+ ->numParams( $this->totalPerType )
+ ->text()
+ );
+ $this->totalSize += $this->totalPerType;
}
/**
->numParams( $this->makePercentPretty( $bytes / $this->totalBytes ) )
->parse()
);
-
+ $this->totalPerType += $bytes;
$this->getOutput()->addHTML( Html::rawElement( 'tr', array(), $row ) );
}
'mw-mediastats-table-' . strtolower( $mediaType ),
'sortable',
'wikitable'
- ))
+ ) )
)
);
$this->getOutput()->addHTML( $this->getTableHeaderRow() );
array( 'class' => array(
'mw-mediastats-mediatype',
'mw-mediastats-mediatype-' . strtolower( $mediaType )
- )),
+ ) ),
// for grep
// mediastatistics-header-unknown, mediastatistics-header-bitmap,
// mediastatistics-header-drawing, mediastatistics-header-audio,