blob: 42389e28373756ba18cd1f09025b9404f24ff260 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
<?php
namespace SMW\MediaWiki\Hooks;
use SMW\DataTypeRegistry;
use SMW\Store;
/**
* Add extra statistic at the end of Special:Statistics
*
* @see https://www.mediawiki.org/wiki/Manual:Hooks/SpecialStatsAddExtra
*
* @license GNU GPL v2+
* @since 1.9
*
* @author mwjames
*/
class SpecialStatsAddExtra extends HookHandler {
/**
* @var Store
*/
private $store;
/**
* @var string[]
*/
private $messageMapper = [
'PROPUSES' => 'smw-statistics-property-instance',
'ERRORUSES' => 'smw-statistics-error-count',
'TOTALPROPS' => 'smw-statistics-property-total',
'USEDPROPS' => 'smw-statistics-property-used',
'OWNPAGE' => 'smw-statistics-property-page',
'DECLPROPS' => 'smw-statistics-property-type',
'DELETECOUNT' => 'smw-statistics-delete-count',
'SUBOBJECTS' => 'smw-statistics-subobject-count',
'QUERY' => 'smw-statistics-query-inline',
'CONCEPTS' => 'smw-statistics-concept-count',
];
/**
* @since 1.9
*
* @param Store $store
*/
public function __construct( Store $store ) {
$this->store = $store;
}
/**
* @since 1.9
*
* @param array &$extraStats
*
* @return true
*/
public function process( array &$extraStats ) {
if ( !$this->getOption( 'smwgSemanticsEnabled', false ) ) {
return true;
}
$this->copyStatistics( $extraStats );
return true;
}
private function copyStatistics( &$extraStats ) {
$statistics = $this->store->getStatistics();
$extraStats['smw-statistics'] = [];
foreach ( $this->messageMapper as $key => $message ) {
if ( isset( $statistics[$key] ) ) {
$extraStats['smw-statistics'][$message] = $statistics[$key];
}
}
$count = count(
DataTypeRegistry::getInstance()->getKnownTypeLabels()
);
$extraStats['smw-statistics']['smw-statistics-datatype-count'] = $count;
}
}
|