r50841 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50840‎ | r50841 | r50842 >
Date:22:36, 20 May 2009
Author:siebrand
Status:deferred
Tags:
Comment:
* add right- message
* remove trailing whitespace, update indentation, stylize.php
* bump version
Modified paths:
  • /trunk/extensions/UsageStatistics/SpecialUserStats.alias.php (modified) (history)
  • /trunk/extensions/UsageStatistics/SpecialUserStats.i18n.php (modified) (history)
  • /trunk/extensions/UsageStatistics/SpecialUserStats.php (modified) (history)
  • /trunk/extensions/UsageStatistics/SpecialUserStats_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsageStatistics/SpecialUserStats.i18n.php
@@ -31,6 +31,7 @@
3232 'usagestatisticscalselect' => 'Select',
3333 'usagestatistics-editindividual' => 'Individual user $1 edits statistics',
3434 'usagestatistics-editpages' => 'Individual user $1 pages statistics',
 35+ 'right-viewsystemstats' => 'View [[Special:UserStats|wiki usage statistics]]',
3536 );
3637
3738 /** Message documentation (Message documentation)
Index: trunk/extensions/UsageStatistics/SpecialUserStats.php
@@ -1,5 +1,5 @@
22 <?php
3 -if (!defined('MEDIAWIKI')) die();
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
44 /**
55 * A Special Page extension to display user statistics
66 *
@@ -14,7 +14,7 @@
1515 $wgExtensionCredits['specialpage'][] = array(
1616 'path' => __FILE__,
1717 'name' => 'UserStats',
18 - 'version' => 'v1.11.4',
 18+ 'version' => 'v1.11.5',
1919 'author' => 'Paul Grinberg',
2020 'email' => 'gri6507 at yahoo dot com',
2121 'url' => 'http://www.mediawiki.org/wiki/Extension:Usage_Statistics',
@@ -35,7 +35,7 @@
3636 $wgGroupPermissions['manager'][$wgUserStatsGlobalRight] = true;
3737 $wgGroupPermissions['sysop'][$wgUserStatsGlobalRight] = true;
3838
39 -$dir = dirname(__FILE__) . '/';
 39+$dir = dirname( __FILE__ ) . '/';
4040 $wgExtensionMessagesFiles['UserStats'] = $dir . '/SpecialUserStats.i18n.php';
4141 $wgExtensionAliasesFiles['UserStats'] = $dir . 'SpecialUserStats.alias.php';
4242 $wgAutoloadClasses['SpecialUserStats'] = $dir . '/SpecialUserStats_body.php';
Index: trunk/extensions/UsageStatistics/SpecialUserStats.alias.php
@@ -10,7 +10,7 @@
1111 * @author Paul Grinberg
1212 */
1313 $aliases['en'] = array(
14 - 'SpecialUserStats' => array( 'UserStats', 'SpecialUserStats' ),
 14+ 'SpecialUserStats' => array( 'UserStats', 'SpecialUserStats' ),
1515 );
1616
1717 /** Arabic (العربية)
Index: trunk/extensions/UsageStatistics/SpecialUserStats_body.php
@@ -1,79 +1,78 @@
22 <?php
33 class SpecialUserStats extends SpecialPage
44 {
5 - function SpecialUserStats() {
6 - SpecialPage::SpecialPage("SpecialUserStats");
 5+ function SpecialUserStats() {
 6+ SpecialPage::SpecialPage( "SpecialUserStats" );
77
8 - # the standard method for LoadingExtensionMessages was apparently broken in several versions of MW
9 - # so, to make this work with multiple versions of MediaWiki, let's load the messages nicely
10 - if (function_exists('wfLoadExtensionMessages'))
11 - wfLoadExtensionMessages( 'UserStats' );
12 - else
13 - self::loadMessages();
 8+ # the standard method for LoadingExtensionMessages was apparently broken in several versions of MW
 9+ # so, to make this work with multiple versions of MediaWiki, let's load the messages nicely
 10+ if ( function_exists( 'wfLoadExtensionMessages' ) )
 11+ wfLoadExtensionMessages( 'UserStats' );
 12+ else
 13+ self::loadMessages();
1414
15 - return true;
16 - }
 15+ return true;
 16+ }
1717
18 - function loadMessages() {
19 - static $messagesLoaded = false;
20 - global $wgMessageCache;
21 - if ( !$messagesLoaded ) {
22 - $messagesLoaded = true;
 18+ function loadMessages() {
 19+ static $messagesLoaded = false;
 20+ global $wgMessageCache;
 21+ if ( !$messagesLoaded ) {
 22+ $messagesLoaded = true;
2323
24 - require( dirname( __FILE__ ) . '/SpecialUserStats.i18n.php' );
25 - foreach ( $messages as $lang => $langMessages ) {
26 - $wgMessageCache->addMessages( $langMessages, $lang );
27 - }
28 - }
29 - return true;
30 - }
 24+ require( dirname( __FILE__ ) . '/SpecialUserStats.i18n.php' );
 25+ foreach ( $messages as $lang => $langMessages ) {
 26+ $wgMessageCache->addMessages( $langMessages, $lang );
 27+ }
 28+ }
 29+ return true;
 30+ }
3131
32 - function execute( $par ) {
33 - global $wgRequest, $wgOut, $wgUser;
 32+ function execute( $par ) {
 33+ global $wgRequest, $wgOut, $wgUser;
3434
35 - $this->setHeaders();
36 - $wgOut->setPagetitle(wfMsg('usagestatistics'));
 35+ $this->setHeaders();
 36+ $wgOut->setPagetitle( wfMsg( 'usagestatistics' ) );
3737
38 - $user = $wgUser->getName();
39 - $wgOut->addWikiText(wfMsg('usagestatisticsfor', $user));
 38+ $user = $wgUser->getName();
 39+ $wgOut->addWikiText( wfMsg( 'usagestatisticsfor', $user ) );
4040
41 - $interval = $wgRequest->getVal('interval', '');
42 - $type = $wgRequest->getVal('type', '');
43 - $start = $wgRequest->getVal('start', '');
44 - $end = $wgRequest->getVal('end', '');
 41+ $interval = $wgRequest->getVal( 'interval', '' );
 42+ $type = $wgRequest->getVal( 'type', '' );
 43+ $start = $wgRequest->getVal( 'start', '' );
 44+ $end = $wgRequest->getVal( 'end', '' );
4545
46 - self::AddCalendarJavascript();
 46+ self::AddCalendarJavascript();
4747
48 - if ($start == "" || $end == "") {
49 - if ($start == "") {
50 - // FIXME: ideally this would use a class for markup.
51 - $wgOut->addWikiText( '* <font color=red>' . wfMsg('usagestatisticsnostart') . '</font>' );
52 - }
53 - if ($end == "") {
54 - // FIXME: ideally this would use a class for markup.
55 - $wgOut->addWikiText( '* <font color=red>' . wfMsg('usagestatisticsnoend') . '</font>' );
56 - }
57 - self::DisplayForm($start,$end);
58 - } else {
59 - $db = wfGetDB( DB_SLAVE );
60 - self::GetUserUsage($db,$user,$start,$end,$interval,$type);
61 - }
 48+ if ( $start == "" || $end == "" ) {
 49+ if ( $start == "" ) {
 50+ // FIXME: ideally this would use a class for markup.
 51+ $wgOut->addWikiText( '* <font color=red>' . wfMsg( 'usagestatisticsnostart' ) . '</font>' );
 52+ }
 53+ if ( $end == "" ) {
 54+ // FIXME: ideally this would use a class for markup.
 55+ $wgOut->addWikiText( '* <font color=red>' . wfMsg( 'usagestatisticsnoend' ) . '</font>' );
 56+ }
 57+ self::DisplayForm( $start, $end );
 58+ } else {
 59+ $db = wfGetDB( DB_SLAVE );
 60+ self::GetUserUsage( $db, $user, $start, $end, $interval, $type );
 61+ }
 62+ }
6263
63 - }
64 -
65 - function generate_google_chart($dates, $edits, $pages)
 64+ function generate_google_chart( $dates, $edits, $pages )
6665 {
6766 $x_labels = 3;
6867 $max_url = 2080; // this is a typical minimum limitation of many browsers
6968
70 - $max_edits = max($edits);
71 - $min_edits = min($edits);
72 - $max_pages = max($pages);
73 - $min_pages = min($pages);
74 -
75 - if (!$max_edits) $max_edits=1;
76 - if (!$max_pages) $max_pages=1;
 69+ $max_edits = max( $edits );
 70+ $min_edits = min( $edits );
 71+ $max_pages = max( $pages );
 72+ $min_pages = min( $pages );
7773
 74+ if ( !$max_edits ) $max_edits = 1;
 75+ if ( !$max_pages ) $max_pages = 1;
 76+
7877 $qry = 'http://chart.apis.google.com/chart?' . // base URL
7978 'chs=400x275' . // size of the graph
8079 '&cht=lc' . // line chart type
@@ -85,101 +84,101 @@
8685 "1,$min_edits,$max_edits|" . // the edits axis
8786 "2,$min_pages,$max_pages" . // the pages axis
8887 '&chxl=0:'; // start specifying the x-axis labels
89 - foreach (self::thin($dates,$x_labels) as $d) {
 88+ foreach ( self::thin( $dates, $x_labels ) as $d ) {
9089 $qry .= "|$d"; // the dates
9190 }
9291 $qry .= '&chd=t:'; // start specifying the first data set
93 - $max_datapoints = ($max_url - strlen($qry))/2; // figure out how much space we have left for each set of data
94 - foreach (self::thin($edits,$max_datapoints/5) as $e) { // on avg, there are 5 chars per datapoint
95 - $qry .= sprintf('%.1f,',
96 - 100*$e/$max_edits); // the edits
 92+ $max_datapoints = ( $max_url - strlen( $qry ) ) / 2; // figure out how much space we have left for each set of data
 93+ foreach ( self::thin( $edits, $max_datapoints / 5 ) as $e ) { // on avg, there are 5 chars per datapoint
 94+ $qry .= sprintf( '%.1f,',
 95+ 100 * $e / $max_edits ); // the edits
9796 }
98 - $qry = substr_replace($qry, '',-1); // get rid of the unwanted comma
 97+ $qry = substr_replace( $qry, '', - 1 ); // get rid of the unwanted comma
9998 $qry .= '|'; // start specifying the second data set
100 - foreach (self::thin($pages,$max_datapoints/5) as $p) { // on avg, there are 5 chars per datapoint
101 - $qry .= sprintf('%.1f,',
102 - 100*$p/$max_pages); // the pages
 99+ foreach ( self::thin( $pages, $max_datapoints / 5 ) as $p ) { // on avg, there are 5 chars per datapoint
 100+ $qry .= sprintf( '%.1f,',
 101+ 100 * $p / $max_pages ); // the pages
103102 }
104 - $qry = substr_replace($qry, '',-1); // get rid of the unwanted comma
 103+ $qry = substr_replace( $qry, '', - 1 ); // get rid of the unwanted comma
105104
106105 return $qry;
107106 }
108107
109 - function thin($input, $max_size) {
110 - $ary_size = sizeof($input);
111 - if ($ary_size <= $max_size) return $input;
 108+ function thin( $input, $max_size ) {
 109+ $ary_size = sizeof( $input );
 110+ if ( $ary_size <= $max_size ) return $input;
112111
113 - # we will always keep the first and the last point
114 - $prev_index = 0;
115 - $new_ary[] = $input[0];
116 - $index_increment = ($ary_size - $prev_index - 2)/($max_size - 1);
 112+ # we will always keep the first and the last point
 113+ $prev_index = 0;
 114+ $new_ary[] = $input[0];
 115+ $index_increment = ( $ary_size - $prev_index - 2 ) / ( $max_size - 1 );
117116
118 - while (($ary_size - $prev_index - 2) >= (2 * $index_increment)) {
119 - $new_index = $prev_index + $index_increment;
120 - $new_ary[] = $input[(int)$new_index];
121 - $prev_index = $new_index;
122 - }
 117+ while ( ( $ary_size - $prev_index - 2 ) >= ( 2 * $index_increment ) ) {
 118+ $new_index = $prev_index + $index_increment;
 119+ $new_ary[] = $input[(int)$new_index];
 120+ $prev_index = $new_index;
 121+ }
123122
124 - $new_ary[] = $input[$ary_size-1];
125 -
126 - //print_r($input);
127 - //print_r($new_ary);
128 - //print "size was " . sizeof($input) . " and became " . sizeof($new_ary) . "\n";
129 -
130 - return $new_ary;
 123+ $new_ary[] = $input[$ary_size - 1];
 124+
 125+ // print_r($input);
 126+ // print_r($new_ary);
 127+ // print "size was " . sizeof($input) . " and became " . sizeof($new_ary) . "\n";
 128+
 129+ return $new_ary;
131130 }
132131
133 - function GetUserUsage($db,$user,$start,$end,$interval,$type) {
134 - global $wgOut, $wgUser, $wgUserStatsGlobalRight, $wgUserStatsGoogleCharts;
 132+ function GetUserUsage( $db, $user, $start, $end, $interval, $type ) {
 133+ global $wgOut, $wgUser, $wgUserStatsGlobalRight, $wgUserStatsGoogleCharts;
135134
136 - list($start_m, $start_d, $start_y) = split('/', $start);
137 - $start_t = mktime(0, 0, 0, $start_m, $start_d, $start_y);
138 - list($end_m, $end_d, $end_y) = split('/', $end);
139 - $end_t = mktime(0, 0, 0, $end_m, $end_d, $end_y);
 135+ list( $start_m, $start_d, $start_y ) = split( '/', $start );
 136+ $start_t = mktime( 0, 0, 0, $start_m, $start_d, $start_y );
 137+ list( $end_m, $end_d, $end_y ) = split( '/', $end );
 138+ $end_t = mktime( 0, 0, 0, $end_m, $end_d, $end_y );
140139
141 - if ($start_t >= $end_t) {
142 - $wgOut->addHTML(wfMsg('usagestatisticsbadstartend'));
143 - return;
144 - }
 140+ if ( $start_t >= $end_t ) {
 141+ $wgOut->addHTML( wfMsg( 'usagestatisticsbadstartend' ) );
 142+ return;
 143+ }
145144
146 - $dates = array();
147 - $csv = 'Username,';
148 - $cur_t = $start_t;
149 - while ($cur_t <= $end_t) {
150 - $a_date = date("Ymd", $cur_t) . '000000';
151 - $dates[$a_date] = array();
152 - $cur_t += $interval;
153 - }
 145+ $dates = array();
 146+ $csv = 'Username,';
 147+ $cur_t = $start_t;
 148+ while ( $cur_t <= $end_t ) {
 149+ $a_date = date( "Ymd", $cur_t ) . '000000';
 150+ $dates[$a_date] = array();
 151+ $cur_t += $interval;
 152+ }
154153
155 - # Let's process the edits that are recorded in the database
156 - $u = array();
157 - $sql = "SELECT rev_user_text,rev_timestamp,page_id FROM " .
158 - $db->tableName('page') . "," . $db->tableName('revision') .
159 - " WHERE rev_page=page_id";
 154+ # Let's process the edits that are recorded in the database
 155+ $u = array();
 156+ $sql = "SELECT rev_user_text,rev_timestamp,page_id FROM " .
 157+ $db->tableName( 'page' ) . "," . $db->tableName( 'revision' ) .
 158+ " WHERE rev_page=page_id";
160159
161 - $res = $db->query($sql, __METHOD__);
 160+ $res = $db->query( $sql, __METHOD__ );
162161
163 - for ($j=0; $j<$db->numRows($res); $j++) {
164 - $row = $db->fetchRow($res);
165 - if (!isset($u[$row[0]]))
166 - $u[$row[0]] = $dates;
167 - foreach ($u[$row[0]] as $d => $v)
168 - if ($d > $row[1]) {
169 - if (!isset($u[$row[0]][$d][$row[2]]))
170 - $u[$row[0]][$d][$row[2]] = 0;
171 - $u[$row[0]][$d][$row[2]]++;
172 - break;
173 - }
174 - }
175 - $db->freeResult($res);
176 -
177 - # in case the current user is not already in the database
178 - if (!isset($u[$user])) {
179 - $u[$user] = $dates;
180 - }
 162+ for ( $j = 0; $j < $db->numRows( $res ); $j++ ) {
 163+ $row = $db->fetchRow( $res );
 164+ if ( !isset( $u[$row[0]] ) )
 165+ $u[$row[0]] = $dates;
 166+ foreach ( $u[$row[0]] as $d => $v )
 167+ if ( $d > $row[1] ) {
 168+ if ( !isset( $u[$row[0]][$d][$row[2]] ) )
 169+ $u[$row[0]][$d][$row[2]] = 0;
 170+ $u[$row[0]][$d][$row[2]]++;
 171+ break;
 172+ }
 173+ }
 174+ $db->freeResult( $res );
181175
182 - # plot the user statistics
183 - $gnuplot ="<gnuplot>
 176+ # in case the current user is not already in the database
 177+ if ( !isset( $u[$user] ) ) {
 178+ $u[$user] = $dates;
 179+ }
 180+
 181+ # plot the user statistics
 182+ $gnuplot = "<gnuplot>
184183 set xdata time
185184 set xtics rotate by 90
186185 set timefmt \"%m/%d/%Y\"
@@ -192,57 +191,57 @@
193192 set key left top
194193 plot '-' using 1:2 t 'edits' with linesp lt 1 lw 3, '-' using 1:2 t 'pages' with linesp lt 2 lw 3 axis x1y2
195194 ";
196 - $gnuplot_pdata = '';
197 - $first = true;
198 - $e = 0;
199 - $p = 0;
200 - $ary_dates = array();
201 - $ary_edits = array();
202 - $ary_pages = array();
203 - foreach ($u[$user] as $d => $v) {
204 - $date = '';
205 - if (preg_match('/^(\d{4})(\d{2})(\d{2})/',$d,$matches))
206 - $date = "$matches[2]/$matches[3]/$matches[1]";
207 - $csv .= "$date,";
208 - if ($type == 'incremental') {
209 - # the first data point includes all edits up to that date, so skip it
210 - if ($first) {
211 - $first = false;
212 - continue;
213 - }
 195+ $gnuplot_pdata = '';
 196+ $first = true;
214197 $e = 0;
215198 $p = 0;
216 - }
217 - foreach ($v as $pageid => $edits) {
218 - $p++;
219 - $e += $edits;
220 - }
221 - $gnuplot .= "$date $e\n";
222 - $gnuplot_pdata .= "$date $p\n";
223 - $ary_dates[] = $date;
224 - $ary_edits[] = $e;
225 - $ary_pages[] = $p;
226 - }
227 - $gnuplot .= "e\n$gnuplot_pdata\ne</gnuplot>";
 199+ $ary_dates = array();
 200+ $ary_edits = array();
 201+ $ary_pages = array();
 202+ foreach ( $u[$user] as $d => $v ) {
 203+ $date = '';
 204+ if ( preg_match( '/^(\d{4})(\d{2})(\d{2})/', $d, $matches ) )
 205+ $date = "$matches[2]/$matches[3]/$matches[1]";
 206+ $csv .= "$date,";
 207+ if ( $type == 'incremental' ) {
 208+ # the first data point includes all edits up to that date, so skip it
 209+ if ( $first ) {
 210+ $first = false;
 211+ continue;
 212+ }
 213+ $e = 0;
 214+ $p = 0;
 215+ }
 216+ foreach ( $v as $pageid => $edits ) {
 217+ $p++;
 218+ $e += $edits;
 219+ }
 220+ $gnuplot .= "$date $e\n";
 221+ $gnuplot_pdata .= "$date $p\n";
 222+ $ary_dates[] = $date;
 223+ $ary_edits[] = $e;
 224+ $ary_pages[] = $p;
 225+ }
 226+ $gnuplot .= "e\n$gnuplot_pdata\ne</gnuplot>";
228227
229 - if ($wgUserStatsGoogleCharts)
230 - {
231 - $wgOut->addHTML('<img src="' .
232 - self::generate_google_chart($ary_dates, $ary_edits, $ary_pages) .
233 - '"/>');
234 - }
235 - else
236 - {
237 - //print "@@@@@@@\n$gnuplot\n@@@@@@@\n";
238 - $wgOut->addWikiText("<center>$gnuplot</center>");
239 - }
 228+ if ( $wgUserStatsGoogleCharts )
 229+ {
 230+ $wgOut->addHTML( '<img src="' .
 231+ self::generate_google_chart( $ary_dates, $ary_edits, $ary_pages ) .
 232+ '"/>' );
 233+ }
 234+ else
 235+ {
 236+ // print "@@@@@@@\n$gnuplot\n@@@@@@@\n";
 237+ $wgOut->addWikiText( "<center>$gnuplot</center>" );
 238+ }
240239
241 - if (!in_array($wgUserStatsGlobalRight, $wgUser->getRights()))
242 - return;
 240+ if ( !in_array( $wgUserStatsGlobalRight, $wgUser->getRights() ) )
 241+ return;
243242
244 - # plot overall usage statistics
245 - $wgOut->addWikiText(wfMsg( 'usagestatisticsforallusers' ));
246 - $gnuplot ="<gnuplot>
 243+ # plot overall usage statistics
 244+ $wgOut->addWikiText( wfMsg( 'usagestatisticsforallusers' ) );
 245+ $gnuplot = "<gnuplot>
247246 set xdata time
248247 set xtics rotate by 90
249248 set timefmt \"%m/%d/%Y\"
@@ -255,195 +254,191 @@
256255 set key left top
257256 plot '-' using 1:2 t 'edits' with linesp lt 1 lw 3, '-' using 1:2 t 'pages' with linesp lt 2 lw 3 axis x1y2
258257 ";
259 - $gnuplot_pdata = '';
260 - $first = true;
261 - $pages = 0;
262 - $edits = 0;
263 - $totals = array();
264 - $ary_dates = array();
265 - $ary_edits = array();
266 - $ary_pages = array();
267 - foreach ($dates as $d => $v) {
268 - if ($type == 'incremental') {
269 - # the first data point includes all edits up to that date, so skip it
270 - if ($first) {
271 - $first = false;
272 - continue;
273 - }
274 - $totals = array();
275 - }
276 - $date = '';
277 - if (preg_match('/^(\d{4})(\d{2})(\d{2})/',$d,$matches))
278 - $date = "$matches[2]/$matches[3]/$matches[1]";
279 - foreach ($u as $usr => $q)
280 - foreach ($u[$usr][$d] as $pageid => $numedits) {
281 - if (!isset($totals[$pageid]))
282 - $totals[$pageid] = 0;
283 - $totals[$pageid] += $numedits;
 258+ $gnuplot_pdata = '';
 259+ $first = true;
 260+ $pages = 0;
 261+ $edits = 0;
 262+ $totals = array();
 263+ $ary_dates = array();
 264+ $ary_edits = array();
 265+ $ary_pages = array();
 266+ foreach ( $dates as $d => $v ) {
 267+ if ( $type == 'incremental' ) {
 268+ # the first data point includes all edits up to that date, so skip it
 269+ if ( $first ) {
 270+ $first = false;
 271+ continue;
 272+ }
 273+ $totals = array();
 274+ }
 275+ $date = '';
 276+ if ( preg_match( '/^(\d{4})(\d{2})(\d{2})/', $d, $matches ) )
 277+ $date = "$matches[2]/$matches[3]/$matches[1]";
 278+ foreach ( $u as $usr => $q )
 279+ foreach ( $u[$usr][$d] as $pageid => $numedits ) {
 280+ if ( !isset( $totals[$pageid] ) )
 281+ $totals[$pageid] = 0;
 282+ $totals[$pageid] += $numedits;
 283+ }
 284+ $pages = 0;
 285+ $edits = 0;
 286+ foreach ( $totals as $pageid => $e ) {
 287+ $pages++;
 288+ $edits += $e;
 289+ }
 290+ $gnuplot .= "$date $edits\n";
 291+ $gnuplot_pdata .= "$date $pages\n";
 292+ $ary_dates[] = $date;
 293+ $ary_edits[] = $edits;
 294+ $ary_pages[] = $pages;
284295 }
285 - $pages = 0;
286 - $edits = 0;
287 - foreach ($totals as $pageid => $e) {
288 - $pages++;
289 - $edits += $e;
290 - }
291 - $gnuplot .= "$date $edits\n";
292 - $gnuplot_pdata .= "$date $pages\n";
293 - $ary_dates[] = $date;
294 - $ary_edits[] = $edits;
295 - $ary_pages[] = $pages;
296 - }
297 - $gnuplot .= "e\n$gnuplot_pdata\ne</gnuplot>";
 296+ $gnuplot .= "e\n$gnuplot_pdata\ne</gnuplot>";
298297
299 - if ($wgUserStatsGoogleCharts)
300 - {
301 - $wgOut->addHTML('<img src="' .
302 - self::generate_google_chart($ary_dates, $ary_edits, $ary_pages) .
303 - '"/>');
304 - }
305 - else
306 - {
307 - //$wgOut->addHTML($gnuplot);
308 - $wgOut->addWikiText("<center>$gnuplot</center>");
309 - }
310 -
311 - # output detailed usage statistics
312 - ksort($u);
313 - $csv_edits = '';
314 - $csv_pages = '';
315 - foreach ($u as $usr => $q) {
316 - $first = true;
317 - $totals = array();
318 - $prev_totals = array();
319 - $csv_edits .= "\n$usr,";
320 - $csv_pages .= "\n$usr,";
321 - foreach ($u[$usr] as $d => $v) {
322 - if ($type == 'incremental') {
323 - # the first data point includes all edits up to that date, so skip it
324 - if ($first) {
325 - $first = false;
326 - $csv_edits .= ',';
327 - $csv_pages .= ',';
328 - continue;
329 - }
330 - $totals = array();
331 - }
332 - foreach ($u[$usr][$d] as $pageid => $numedits) {
333 - if (!isset($totals[$pageid]))
334 - $totals[$pageid] = 0;
335 - $totals[$pageid] += $numedits;
 298+ if ( $wgUserStatsGoogleCharts )
 299+ {
 300+ $wgOut->addHTML( '<img src="' .
 301+ self::generate_google_chart( $ary_dates, $ary_edits, $ary_pages ) .
 302+ '"/>' );
 303+ } else {
 304+ // $wgOut->addHTML($gnuplot);
 305+ $wgOut->addWikiText( "<center>$gnuplot</center>" );
336306 }
337 - $pages = 0;
338 - $edits = 0;
339 - foreach ($totals as $pageid => $e) {
340 - $pages++;
341 - $edits += $e;
342 - }
343 - $csv_edits .= "$edits,";
344 - $csv_pages .= "$pages,";
345 - }
346 - }
347 - if ($type == 'cumulative') {
348 - $nature = wfMsg('usagestatisticscumulative-text');
349 - }
350 - else {
351 - $nature = wfMsg ('usagestatisticsincremental-text');
352 - }
353307
354 - $wgOut->addHTML('<div class="NavFrame" style="padding:0px;border-style:none;">');
355 - $wgOut->addHTML('<div class="NavHead" style="background: #ffffff; text-align: left; font-size:100%;">');
356 - $wgOut->addWikiText(wfMsg ('usagestatistics-editindividual', $nature));
357 - $wgOut->addHTML('</div><div class="NavContent" style="display:none; font-size:normal; text-align:left">');
358 - $wgOut->AddHtml("<pre>$csv$csv_edits</pre></div></div><br />");
 308+ # output detailed usage statistics
 309+ ksort( $u );
 310+ $csv_edits = '';
 311+ $csv_pages = '';
 312+ foreach ( $u as $usr => $q ) {
 313+ $first = true;
 314+ $totals = array();
 315+ $prev_totals = array();
 316+ $csv_edits .= "\n$usr,";
 317+ $csv_pages .= "\n$usr,";
 318+ foreach ( $u[$usr] as $d => $v ) {
 319+ if ( $type == 'incremental' ) {
 320+ # the first data point includes all edits up to that date, so skip it
 321+ if ( $first ) {
 322+ $first = false;
 323+ $csv_edits .= ',';
 324+ $csv_pages .= ',';
 325+ continue;
 326+ }
 327+ $totals = array();
 328+ }
 329+ foreach ( $u[$usr][$d] as $pageid => $numedits ) {
 330+ if ( !isset( $totals[$pageid] ) )
 331+ $totals[$pageid] = 0;
 332+ $totals[$pageid] += $numedits;
 333+ }
 334+ $pages = 0;
 335+ $edits = 0;
 336+ foreach ( $totals as $pageid => $e ) {
 337+ $pages++;
 338+ $edits += $e;
 339+ }
 340+ $csv_edits .= "$edits,";
 341+ $csv_pages .= "$pages,";
 342+ }
 343+ }
 344+ if ( $type == 'cumulative' ) {
 345+ $nature = wfMsg( 'usagestatisticscumulative-text' );
 346+ } else {
 347+ $nature = wfMsg ( 'usagestatisticsincremental-text' );
 348+ }
359349
360 - $wgOut->addHTML('<div class="NavFrame" style="padding:0px;border-style:none;">');
361 - $wgOut->addHTML('<div class="NavHead" style="background: #ffffff; text-align: left; font-size:100%;">');
362 - $wgOut->addWikiText(wfMsg ('usagestatistics-editpages', $nature));
363 - $wgOut->addHTML('</div><div class="NavContent" style="display:none; font-size:normal; text-align:left">');
364 - $wgOut->AddHtml("<pre>$csv$csv_pages</pre></div></div>");
 350+ $wgOut->addHTML( '<div class="NavFrame" style="padding:0px;border-style:none;">' );
 351+ $wgOut->addHTML( '<div class="NavHead" style="background: #ffffff; text-align: left; font-size:100%;">' );
 352+ $wgOut->addWikiText( wfMsg ( 'usagestatistics-editindividual', $nature ) );
 353+ $wgOut->addHTML( '</div><div class="NavContent" style="display:none; font-size:normal; text-align:left">' );
 354+ $wgOut->AddHtml( "<pre>$csv$csv_edits</pre></div></div><br />" );
365355
366 - return;
367 - }
 356+ $wgOut->addHTML( '<div class="NavFrame" style="padding:0px;border-style:none;">' );
 357+ $wgOut->addHTML( '<div class="NavHead" style="background: #ffffff; text-align: left; font-size:100%;">' );
 358+ $wgOut->addWikiText( wfMsg ( 'usagestatistics-editpages', $nature ) );
 359+ $wgOut->addHTML( '</div><div class="NavContent" style="display:none; font-size:normal; text-align:left">' );
 360+ $wgOut->AddHtml( "<pre>$csv$csv_pages</pre></div></div>" );
368361
369 - function DisplayForm($start,$end) {
370 - global $wgOut;
 362+ return;
 363+ }
371364
372 - $wgOut->addHTML("
 365+ function DisplayForm( $start, $end ) {
 366+ global $wgOut;
 367+
 368+ $wgOut->addHTML( "
373369 <script type='text/javascript'>document.write(getCalendarStyles());</SCRIPT>
374370 <form id=\"userstats\" method=\"post\">
375371 <table border='0'>
376372 <tr>
377 - <td align='right'>". wfMsg('usagestatisticsinterval') .":</td>
 373+ <td align='right'>" . wfMsg( 'usagestatisticsinterval' ) . ":</td>
378374 <td align='left'>
379375 <select name='interval'>
380 - <option value='86400'>". wfMsg('usagestatisticsintervalday') ."
381 - <option value='604800'>". wfMsg('usagestatisticsintervalweek') ."
382 - <option value='2629744' selected>". wfMsg('usagestatisticsintervalmonth') ."
 376+ <option value='86400'>" . wfMsg( 'usagestatisticsintervalday' ) . "
 377+ <option value='604800'>" . wfMsg( 'usagestatisticsintervalweek' ) . "
 378+ <option value='2629744' selected>" . wfMsg( 'usagestatisticsintervalmonth' ) . "
383379 </select>
384380 </td>
385381 </tr>
386382 <tr>
387 - <td align='right'>". wfMsg('usagestatisticstype') .":</td>
 383+ <td align='right'>" . wfMsg( 'usagestatisticstype' ) . ":</td>
388384 <td align='left'>
389385 <select name='type'>
390 - <option value='incremental'>". wfMsg('usagestatisticsincremental') ."
391 - <option value='cumulative' selected>". wfMsg('usagestatisticscumulative') ."
 386+ <option value='incremental'>" . wfMsg( 'usagestatisticsincremental' ) . "
 387+ <option value='cumulative' selected>" . wfMsg( 'usagestatisticscumulative' ) . "
392388 </select>
393389 </td>
394390 </tr>
395391 <tr>
396 - <td align='right'>". wfMsg('usagestatisticsstart') .":</td>
 392+ <td align='right'>" . wfMsg( 'usagestatisticsstart' ) . ":</td>
397393 <td align='left'>
398394 <input type='text' size='20' name='start' value='$start'/>
399395 <script type='text/javascript'>
400396 var cal1 = new CalendarPopup('testdiv1');
401397 cal1.showNavigationDropdowns();
402398 </SCRIPT>
403 - <A HREF='#' onClick=\"cal1.select(document.forms[0].start,'anchor1','MM/dd/yyyy'); return false;\" NAME='anchor1' ID='anchor1'>". wfMsg('usagestatisticscalselect') ."</A>
 399+ <A HREF='#' onClick=\"cal1.select(document.forms[0].start,'anchor1','MM/dd/yyyy'); return false;\" NAME='anchor1' ID='anchor1'>" . wfMsg( 'usagestatisticscalselect' ) . "</A>
404400 </td>
405401 </tr>
406402 <tr>
407 - <td align='right'>". wfMsg('usagestatisticsend') .":</td>
 403+ <td align='right'>" . wfMsg( 'usagestatisticsend' ) . ":</td>
408404 <td align='left'>
409405 <input type='text' size='20' name='end' value='$end'/>
410406 <script type='text/javascript'>
411407 var cal2 = new CalendarPopup('testdiv1');
412408 cal2.showNavigationDropdowns();
413409 </SCRIPT>
414 - <A HREF='#' onClick=\"cal2.select(document.forms[0].end,'anchor2','MM/dd/yyyy'); return false;\" NAME='anchor2' ID='anchor2'>". wfMsg('usagestatisticscalselect') ."</A>
 410+ <A HREF='#' onClick=\"cal2.select(document.forms[0].end,'anchor2','MM/dd/yyyy'); return false;\" NAME='anchor2' ID='anchor2'>" . wfMsg( 'usagestatisticscalselect' ) . "</A>
415411 </td>
416412 </tr>
417413 </table>
418 -<input type='submit' name=\"wpSend\" value=\"".wfMsg('usagestatisticssubmit')."\" />
 414+<input type='submit' name=\"wpSend\" value=\"" . wfMsg( 'usagestatisticssubmit' ) . "\" />
419415 </form>
420416 <DIV ID=\"testdiv1\" STYLE=\"position:absolute;visibility:hidden;background-color:white;layer-background-color:white;\"></DIV>
421417 " );
422 - }
 418+ }
423419
424 - function AddCalendarJavascript() {
425 - global $wgOut, $wgContLang;
 420+ function AddCalendarJavascript() {
 421+ global $wgOut, $wgContLang;
426422
427 - $monthnames = '';
428 - for($i = 1; $i <= 12; $i++)
429 - $monthnames .= "'" . $wgContLang->getMonthName($i) . "',";
430 - for($i = 1; $i <= 12; $i++)
431 - $monthnames .= "'" . $wgContLang->getMonthAbbreviation($i) . "',";
432 - $monthnames = substr($monthnames, 0, -1);
 423+ $monthnames = '';
 424+ for ( $i = 1; $i <= 12; $i++ )
 425+ $monthnames .= "'" . $wgContLang->getMonthName( $i ) . "',";
 426+ for ( $i = 1; $i <= 12; $i++ )
 427+ $monthnames .= "'" . $wgContLang->getMonthAbbreviation( $i ) . "',";
 428+ $monthnames = substr( $monthnames, 0, - 1 );
433429
434 - $daynames = '';
435 - for($i = 1; $i <= 7; $i++)
436 - $daynames .= "'" . $wgContLang->getWeekdayName($i) . "',";
437 - for($i = 1; $i <= 7; $i++)
438 - {
439 - if (method_exists($wgContLang, 'getWeekdayAbbreviation'))
440 - $daynames .= "'" . $wgContLang->getWeekdayAbbreviation($i) . "',";
441 - else
442 - $daynames .= "'" . $wgContLang->getWeekdayName($i) . "',";
443 - }
444 - $daynames = substr($daynames, 0, -1);
 430+ $daynames = '';
 431+ for ( $i = 1; $i <= 7; $i++ )
 432+ $daynames .= "'" . $wgContLang->getWeekdayName( $i ) . "',";
 433+ for ( $i = 1; $i <= 7; $i++ )
 434+ {
 435+ if ( method_exists( $wgContLang, 'getWeekdayAbbreviation' ) )
 436+ $daynames .= "'" . $wgContLang->getWeekdayAbbreviation( $i ) . "',";
 437+ else
 438+ $daynames .= "'" . $wgContLang->getWeekdayName( $i ) . "',";
 439+ }
 440+ $daynames = substr( $daynames, 0, - 1 );
445441
446 -
447 - $wgOut->addScript(<<<END
 442+ $wgOut->addScript( <<<END
448443 <script type="text/javascript">
449444 // ===================================================================
450445 // Author: Matt Kruse <matt@mattkruse.com>
@@ -465,7 +460,6 @@
466461 // the files to your server and use them there. Thank you.
467462 // ===================================================================
468463
469 -
470464 /* SOURCE FILE: AnchorPosition.js */
471465
472466 /*
@@ -1910,5 +1904,5 @@
19111905 </script>
19121906 END
19131907 );
1914 - }
 1908+ }
19151909 }

Status & tagging log