64 parent::__construct(
'MediaStatistics' );
68 $this->shownavigation =
false;
94 $fakeTitle =
$dbr->buildConcat( [
96 $dbr->addQuotes(
';' ),
98 $dbr->addQuotes(
'/' ),
100 $dbr->addQuotes(
';' ),
101 $dbr->buildStringCast(
'COUNT(*)' ),
102 $dbr->addQuotes(
';' ),
103 $dbr->buildStringCast(
'SUM( img_size )' )
106 'tables' => [
'image' ],
108 'title' => $fakeTitle,
130 return [
'img_media_type',
'count(*)',
'img_major_mime',
'img_minor_mime' ];
144 $prevMediaType =
null;
145 foreach (
$res as $row ) {
147 if ( count( $mediaStats ) < 4 ) {
151 if ( $prevMediaType !== $mediaType ) {
152 if ( $prevMediaType !==
null ) {
158 $this->totalPerType = 0;
159 $this->countPerType = 0;
161 $prevMediaType = $mediaType;
165 if ( $prevMediaType !==
null ) {
169 $this->
getOutput()->addWikiTextAsInterface(
170 $this->
msg(
'mediastatistics-allbytes' )
171 ->numParams( $this->totalSize )
172 ->sizeParams( $this->totalSize )
173 ->numParams( $this->totalCount )
184 Html::closeElement(
'tbody' ) .
185 Html::closeElement(
'table' )
187 $this->
getOutput()->addWikiTextAsInterface(
188 $this->
msg(
'mediastatistics-bytespertype' )
189 ->numParams( $this->totalPerType )
190 ->sizeParams( $this->totalPerType )
191 ->numParams( $this->
makePercentPretty( $this->totalPerType / $this->totalBytes ) )
192 ->numParams( $this->countPerType )
193 ->numParams( $this->
makePercentPretty( $this->countPerType / $this->totalCount ) )
209 $row = Html::rawElement(
214 $row .= Html::rawElement(
219 $row .= Html::rawElement(
222 [
'data-sort-value' => $count ],
223 $this->
msg(
'mediastatistics-nfiles' )
224 ->numParams( $count )
229 $row .= Html::rawElement(
232 [
'data-sort-value' => $bytes ],
233 $this->
msg(
'mediastatistics-nbytes' )
234 ->numParams( $bytes )
235 ->sizeParams( $bytes )
240 $this->totalPerType += $bytes;
241 $this->countPerType += $count;
242 $this->
getOutput()->addHTML( Html::rawElement(
'tr', [], $row ) );
252 if ( $decimal == 0 ) {
255 if ( $decimal >= 100 ) {
258 $percent = sprintf(
"%." . max( 0, 2 - floor( log10( $decimal ) ) ) .
"f", $decimal );
260 return preg_replace(
'/\.?0*$/',
'', $percent );
270 $exts = $this->mimeAnalyzer->getExtensionsFromMimeType(
$mime );
274 foreach ( $exts as &
$ext ) {
275 $ext = htmlspecialchars(
'.' .
$ext );
289 $out->addModuleStyles(
'jquery.tablesorter.styles' );
290 $out->addModules(
'jquery.tablesorter' );
295 'mw-mediastats-table',
296 'mw-mediastats-table-' . strtolower( $mediaType ),
302 Html::openElement(
'tbody' )
312 $headers = [
'mimetype',
'extensions',
'count',
'totalbytes' ];
314 foreach ( $headers as
$header ) {
315 $ths .= Html::rawElement(
321 $this->
msg(
'mediastatistics-table-' . $header )->parse()
324 return Html::rawElement(
'tr', [], $ths );
337 'mw-mediastats-mediatype',
338 'mw-mediastats-mediatype-' . strtolower( $mediaType )
347 $this->
msg(
'mediastatistics-header-' . strtolower( $mediaType ) )->text()
362 return explode(
';', $fakeTitle, 4 );
395 $this->totalCount = $this->totalBytes = 0;
396 foreach (
$res as $row ) {
398 $this->totalCount += $mediaStats[2] ?? 0;
399 $this->totalBytes += $mediaStats[3] ?? 0;
This is a class for doing query pages; since they're almost all the same, we factor out some of the f...
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
setDBLoadBalancer(ILoadBalancer $loadBalancer)
LinkBatchFactory null $linkBatchFactory
int $offset
The offset and limit in use, as passed to the query() function.
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
ILoadBalancer null $loadBalancer
getOutput()
Get the OutputPage being used for this instance.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
LinkRenderer null $linkRenderer
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getLanguage()
Shortcut to get user's language.
if(!is_readable( $file)) $ext