Index: trunk/wikistats/MetricsReporting/MetricsReporting.php |
— | — | @@ -1,107 +1,73 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -$wgeAnalyticsFieldNames = array( |
5 | | - 'select_regions' => "REGION", |
6 | | - 'select_countries' => "COUNTRY", |
7 | | - 'select_web_projects' => "WEBPROJ", |
8 | | - 'select_wikis' => "WIKI", |
9 | | - 'select_editors' => "EDITOR", |
10 | | - 'select_edits' => "EDITS", |
11 | | - 'select_platform' => "MOBILE", |
12 | | -); |
| 4 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 5 | + die(); |
| 6 | +} |
13 | 7 | |
14 | | -$wgeAnalyticsFieldReturns = array( |
15 | | - 'select_regions' => "region", |
16 | | - 'select_countries' => "country", |
17 | | - 'select_web_projects' => "web project", |
18 | | - 'select_wikis' => "wiki", |
19 | | - 'select_editors' => "editors", |
20 | | - 'select_edits' => "edits", |
21 | | - 'select_platform' => "mobile", |
| 8 | +define( 'METRICS_REPORTING_VERSION', 0.1 ); |
| 9 | + |
| 10 | +$wgExtensionCredits['other'][] = array( |
| 11 | + 'path' => __FILE__, |
| 12 | + 'name' => 'MetricsReporting', |
| 13 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:MetricsReporting', |
| 14 | + 'author' => 'Sam Reed', |
| 15 | + 'version' => METRICS_REPORTING_VERSION, |
| 16 | + 'description' => 'Api for Wikimedia Metrics Reporting output', |
22 | 17 | ); |
23 | 18 | |
| 19 | +$wgMetricAPIModules = array(); |
24 | 20 | |
25 | | -$wgeAnalyticsValidParams = array( |
| 21 | +$wgMetricsDBserver = ''; |
| 22 | +$wgMetricsDBname = ''; |
| 23 | +$wgMetricsDBuser = ''; |
| 24 | +$wgMetricsDBpassword = ''; |
| 25 | +$wgMetricsDBtype = 'mysql'; |
| 26 | +$wgMetricsDBprefix = ''; |
26 | 27 | |
27 | | -"select_regions" => array( |
28 | | - "AS" => "Asia Pacific", |
29 | | - "C" => "China", |
30 | | - "EU" => "Europe", |
31 | | - "I" => "India", |
32 | | - "LA" => "Latin-America", |
33 | | - "MA" => "Middle-East/Africa", |
34 | | - "NA" => "North-America", |
35 | | - "US" => "United States", |
36 | | - "W" => "World", |
37 | | -), |
38 | | -// "select_countries" => array(), |
39 | | -// "select_web_properties"=> array(), |
40 | | -"select_projects" => array( |
41 | | - "wb" => "Wikibooks", |
42 | | - "wk" => "Wiktionary", |
43 | | - "wn" => "Wikinews", |
44 | | - "wp" => "Wikipedia", |
45 | | - "wq" => "Wikiquote", |
46 | | - "ws" => "Wikisource", |
47 | | - "wv" => "Wikiversity", |
48 | | - "co" => "Commons", |
49 | | - "wx" => "Other projects", |
50 | | -), |
51 | | -// "select_wikis"=> array(), |
52 | | -"select_editors" => array( |
53 | | - "A" => "Anonymous", |
54 | | - "R" => "Registered User", |
55 | | - "B" => "Bot", |
56 | | -), |
57 | | -"select_edits" => array( |
58 | | - "M" => "Manual", |
59 | | - "B" => "Bot", |
60 | | -), |
61 | | -"select_platform" => array( |
62 | | - "M" => "Moblie", |
63 | | - "N" => "Non-Mobile", |
64 | | -), |
| 28 | +$dir = dirname( __FILE__ ) . '/'; |
65 | 29 | |
66 | | -); |
| 30 | +$wgAutoloadClasses['ApiAnalytics'] = $dir . 'ApiAnalytics.php'; |
| 31 | +$wgAPIModules['analytics'] = 'ApiAnalytics'; |
67 | 32 | |
68 | | -$dir = dirname( __FILE__ ); |
69 | | -$wgAutoloadClasses['ApiAnalytics'] = $dir . '/api/ApiAnalytics.php'; |
70 | | -$wgAutoloadClasses['ApiAnalyticsMetric'] = $dir . '/api/ApiAnalyticsMetric.php'; |
71 | | -$wgAutoloadClasses['MetricsReportingQuery'] = $dir . '/MetricsReportingQuery.php'; |
| 33 | +$wgAutoloadClasses['ApiAnalyticsBase'] = $dir . 'ApiAnalyticsBase.php'; |
72 | 34 | |
73 | | -$wgeAnalyticsMetricsList = array(); |
74 | | -$metricsdir = $dir . "/metrics"; |
75 | | -$dh = opendir( $metricsdir ); |
76 | | -while ( ( $file = readdir( $dh ) ) !== false ) { |
77 | | - if ( filetype( $metricsdir . "/" . $file ) == "file" ) { |
78 | | - $file_path_parts = pathinfo( $metricsdir . "/" . $file ); |
79 | | - if ( $file_path_parts['extension'] == 'php' ) { |
80 | | - $wgAutoloadClasses["ApiAnalyticsMetric{$file_path_parts['filename']}"] = $metricsdir . "/" . $file; |
81 | | - $wgeAnalyticsMetricsList[] = $file_path_parts['filename']; |
82 | | - } |
83 | | - } |
84 | | -} |
| 35 | +$metricsDir = $dir . 'metrics/'; |
85 | 36 | |
| 37 | +$wgAutoloadClasses['GenericMetricBase'] = $metricsDir . 'GenericMetricBase.php'; |
86 | 38 | |
87 | | -$wgAPIModules['analytics'] = 'ApiAnalytics'; |
| 39 | +$wgAutoloadClasses['ComScoreReachPercentageMetric'] = $metricsDir . 'ComScoreReachPercentageMetric.php'; |
| 40 | +$wgMetricAPIModules['comscorereachpercentage'] = 'ComScoreReachPercentageMetric'; |
88 | 41 | |
| 42 | +$wgAutoloadClasses['ComScoreUniqueVisitorMetric'] = $metricsDir . 'ComScoreUniqueVisitorMetric.php'; |
| 43 | +$wgMetricAPIModules['comscoreuniquevisitors'] = 'ComScoreUniqueVisitorMetric'; |
89 | 44 | |
| 45 | +$wgAutoloadClasses['DumpActiveEditors100Metric'] = $metricsDir . 'DumpActiveEditors100Metric.php'; |
| 46 | +$wgMetricAPIModules['dumpactiveeditors100'] = 'DumpActiveEditors100Metric'; |
90 | 47 | |
91 | | -function wfAnalyticsMetricConnection() { |
92 | | - global $wgeAnalyticsMetricDBserver, $wgeAnalyticsMetricDBname; |
93 | | - global $wgeAnalyticsMetricDBuser, $wgeAnalyticsMetricDBpassword; |
| 48 | +$wgAutoloadClasses['DumpActiveEditors5Metric'] = $metricsDir . 'DumpActiveEditors5Metric.php'; |
| 49 | +$wgMetricAPIModules['dumpactiveeditors5'] = 'DumpActiveEditors5Metric'; |
94 | 50 | |
95 | | - static $db; |
| 51 | +$wgAutoloadClasses['DumpArticleCountMetric'] = $metricsDir . 'DumpArticleCountMetric.php'; |
| 52 | +$wgMetricAPIModules['dumparticlecount'] = 'DumpArticleCountMetric'; |
96 | 53 | |
97 | | - if ( !$db ) { |
98 | | - $db = new DatabaseMysql( |
99 | | - $wgeAnalyticsMetricDBserver, |
100 | | - $wgeAnalyticsMetricDBuser, |
101 | | - $wgeAnalyticsMetricDBpassword, |
102 | | - $wgeAnalyticsMetricDBname ); |
103 | | - $db->query( "SET names utf8" ); |
104 | | - } |
| 54 | +$wgAutoloadClasses['DumpBinaryCountMetric'] = $metricsDir . 'DumpBinaryCountMetric.php'; |
| 55 | +$wgMetricAPIModules['dumpbinarycount'] = 'DumpBinaryCountMetric'; |
105 | 56 | |
106 | | - return $db; |
107 | | -} |
| 57 | +$wgAutoloadClasses['DumpEditsMetric'] = $metricsDir . 'DumpEditsMetric.php'; |
| 58 | +$wgMetricAPIModules['dumpedits'] = 'DumpEditsMetric'; |
108 | 59 | |
| 60 | +$wgAutoloadClasses['DumpNewRegisteredEditorsMetric'] = $metricsDir . 'DumpNewRegisteredEditorsMetric.php'; |
| 61 | +$wgMetricAPIModules['dumpnewregisterededitors'] = 'DumpNewRegisteredEditorsMetric'; |
| 62 | + |
| 63 | +$wgAutoloadClasses['EstimateOfflineMetric'] = $metricsDir . 'EstimateOfflineMetric.php'; |
| 64 | +$wgMetricAPIModules['estimateoffline'] = 'EstimateOfflineMetric'; |
| 65 | + |
| 66 | +$wgAutoloadClasses['SquidPageViewsMetric'] = $metricsDir . 'SquidPageViewsMetric.php'; |
| 67 | +$wgMetricAPIModules['squidpageviews'] = 'SquidPageViewsMetric'; |
| 68 | + |
| 69 | +$wgAutoloadClasses['EditorsByGeographyMetric'] = $metricsDir . 'EditorsByGeographyMetric.php'; |
| 70 | +$wgMetricAPIModules['editorsbygeography'] = 'EditorsByGeographyMetric'; |
| 71 | + |
| 72 | +$wgAutoloadClasses['MobilePageViewsMetric'] = $metricsDir . 'MobilePageViewsMetric.php'; |
| 73 | +$wgMetricAPIModules['mobilepageviews'] = 'MobilePageViewsMetric'; |
| 74 | + |
Index: trunk/wikistats/MetricsReporting/metrics/EditorsByGeographyMetric.php |
— | — | @@ -0,0 +1,17 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * |
| 6 | + */ |
| 7 | +class EditorsByGeographyMetric extends GenericMetricBase { |
| 8 | + |
| 9 | + protected $tableName = 'editorsbygeography'; |
| 10 | + |
| 11 | + public function getDescription() { |
| 12 | + return "Number of active unique registered editors by country"; |
| 13 | + } |
| 14 | + |
| 15 | + protected function getExamples() { |
| 16 | + return ""; |
| 17 | + } |
| 18 | +} |
Property changes on: trunk/wikistats/MetricsReporting/metrics/EditorsByGeographyMetric.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 19 | + native |
Index: trunk/wikistats/MetricsReporting/metrics/MobilePageViewsMetric.php |
— | — | @@ -0,0 +1,17 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +/** |
| 5 | + * |
| 6 | + */ |
| 7 | +class MobilePageViewsMetric extends GenericMetricBase { |
| 8 | + |
| 9 | + protected $tableName = 'mobilepageviews'; |
| 10 | + |
| 11 | + public function getDescription() { |
| 12 | + return "Number of mobile page views"; |
| 13 | + } |
| 14 | + |
| 15 | + protected function getExamples() { |
| 16 | + return ""; |
| 17 | + } |
| 18 | +} |
Property changes on: trunk/wikistats/MetricsReporting/metrics/MobilePageViewsMetric.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 19 | + native |