Index: trunk/wikistats/MetricsReporting/MetricsReportingQuery.php |
— | — | @@ -1,113 +1,19 @@ |
2 | | -<?php |
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 | | -); |
13 | | - |
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", |
22 | | -); |
23 | | - |
24 | | - |
25 | | -$wgeAnalyticsValidParams = array( |
26 | | - |
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 | | -), |
65 | | - |
66 | | -); |
67 | | - |
68 | | - |
69 | | -$wgAutoloadClasses['ApiAnalytics'] = $dir . '/api/ApiAnalytics.php'; |
70 | | -$wgAutoloadClasses['ApiAnalyticsMetric'] = $dir . '/api/ApiAnalyticsMetric.php'; |
71 | | -$wgAutoloadClasses['MetricsReportingQuery'] = $dir . '/MetricsReportingQuery.php'; |
72 | | - |
73 | | - |
74 | | -$dir = dirname( __FILE__ ); |
75 | | - |
76 | | - |
77 | | -$wgeAnalyticsMetricsList = array(); |
78 | | -$metricsdir = $dir."/metrics"; |
79 | | -$dh = opendir($metricsdir); |
80 | | -while( ($file = readdir($dh)) !== false){ |
81 | | - if(filetype($dir.$file) == "file" ){ |
82 | | - $file_path_parts = pathinfo($dir.$file); |
83 | | - if($file_path_parts['extension'] == 'php'){ |
84 | | - $wgAutoloadClasses["ApiAnalyticsMetric{$file_path_parts['filename']}"] = $dir.$file; |
85 | | - $wgeAnalyticsMetricsList[] = $file_path_parts['filename']; |
86 | | - } |
87 | | - } |
88 | | -} |
89 | | - |
90 | | - |
91 | | -$wgAPIModules['analytics'] = 'ApiAnalytics'; |
92 | | - |
93 | | - |
94 | | - |
95 | | -function wfAnalyticsMetricConnection() { |
96 | | - global $wgeAnalyticsMetricDBserver, $wgeAnalyticsMetricDBname; |
97 | | - global $wgeAnalyticsMetricDBuser, $wgeAnalyticsMetricDBpassword; |
| 2 | +<?php |
| 3 | +class MetricsReportingQuery{ |
98 | 4 | |
99 | | - static $db; |
| 5 | + public $query = ""; |
| 6 | + public $queryProperties = array(); |
100 | 7 | |
101 | | - if ( !$db ) { |
102 | | - $db = new DatabaseMysql( |
103 | | - $wgeAnalyticsMetricDBserver, |
104 | | - $wgeAnalyticsMetricDBuser, |
105 | | - $wgeAnalyticsMetricDBpassword, |
106 | | - $wgeAnalyticsMetricDBname ); |
107 | | - $db->query( "SET names utf8" ); |
| 8 | + public function __construct(){ |
108 | 9 | } |
109 | | - |
110 | | - return $db; |
111 | | -} |
112 | 10 | |
113 | | - |
114 | | -class |
\ No newline at end of file |
| 11 | + public function __construct($initial_query, $initial_prop_name, $initial_prop_value){ |
| 12 | + $this->query = $initial_query; |
| 13 | + $this->queryProperties = array($initial_prop_name => $initial_prop_value); |
| 14 | + } |
| 15 | + |
| 16 | + public function mergeWith(MetricsReportingQuery $queryObj){ |
| 17 | + $this->query = $this->query.$queryObj->query; |
| 18 | + $this->queryProperties = array_merge($this->queryProperties, $queryObj->queryProperties); |
| 19 | + } |
| 20 | +} |
\ No newline at end of file |