r80954 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80953‎ | r80954 | r80955 >
Date:02:43, 25 January 2011
Author:kaldari
Status:deferred
Tags:
Comment:
new customizable graph without localization
Modified paths:
  • /trunk/extensions/ContributionReporting/FundraiserStatistics.css (modified) (history)
  • /trunk/extensions/ContributionReporting/FundraiserStatistics.js (modified) (history)
  • /trunk/extensions/ContributionReporting/FundraiserStatistics_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ContributionReporting/FundraiserStatistics_body.php
@@ -17,6 +17,17 @@
1818 public function execute( $sub ) {
1919 global $wgRequest, $wgOut, $wgUser, $wgLang, $wgScriptPath, $egFundraiserStatisticsFundraisers;
2020
 21+ $showYear = array();
 22+ foreach ( $egFundraiserStatisticsFundraisers as $fundraiser ) {
 23+ if ( $wgRequest->wasPosted() ) {
 24+ $showYear[$fundraiser['id']] = $wgRequest->getCheck( 'toogle'.$fundraiser['id'] );
 25+ } else {
 26+ $showYear[$fundraiser['id']] = true;
 27+ }
 28+ }
 29+
 30+ $this->timezone = $wgRequest->getText( 'timezone', '+0:00' );
 31+
2132 /* Configuration (this isn't totally static data, some of it gets built on the fly) */
2233
2334 $charts = array(
@@ -101,9 +112,25 @@
102113 if ( !isset( $charts[$name]['data'][$column] ) ) {
103114 $charts[$name]['data'][$column] = '';
104115 }
 116+
 117+ // Add spacer between days
 118+ if ( $fundraiserIndex == 0 ) {
 119+ $attributes = array(
 120+ 'style' => 'height:1px',
 121+ 'class' => 'fundraiserstats-bar-space'
 122+ );
 123+ $charts[$name]['data'][$column] .= Xml::tags(
 124+ 'td', array( 'valign' => 'bottom' ), Xml::element( 'div', $attributes, '', false )
 125+ );
 126+ }
 127+
105128 $height = $chart['factor'] * $day[$chart['index']];
 129+ $style = "height:{$height}px;";
 130+ if ( $showYear[$fundraiser['id']] !== true ) {
 131+ $style .= "display:none;";
 132+ }
106133 $attributes = array(
107 - 'style' => "height:{$height}px",
 134+ 'style' => $style,
108135 'class' => "fundraiserstats-bar fundraiserstats-bar-{$fundraiser['id']}",
109136 'rel' => "fundraiserstats-view-box-{$view}",
110137 );
@@ -162,6 +189,27 @@
163190 }
164191 }
165192 }
 193+
 194+ $wgOut->addHTML( Xml::openElement( 'div', array( 'id' => 'configtoggle' ) ) );
 195+ $wgOut->addHTML( '<a id="customize-chart">Customize</a>' );
 196+ $wgOut->addHTML( Xml::closeElement( 'div' ) );
 197+
 198+ $wgOut->addHTML( Xml::openElement( 'form', array( 'method' => 'post', 'id' => 'configform' ) ) );
 199+
 200+ $years = 'Show the following years:<br/>';
 201+ foreach ( $egFundraiserStatisticsFundraisers as $fundraiser ) {
 202+ $years .= Xml::check( 'toogle'.$fundraiser['id'], $showYear[$fundraiser['id']], array( 'id' => 'bar-'.$fundraiser['id'], 'class' => 'yeartoggle' ) );
 203+ $years .= Xml::label( $fundraiser['id'], 'toogle'.$fundraiser['id'] );
 204+ $years .= "<br/>";
 205+ }
 206+ $wgOut->addHTML( Xml::openElement( 'div', array( 'id' => 'configholder' ) ) );
 207+ $wgOut->addHTML( $years );
 208+ $wgOut->addHTML( 'Time Zone:<br/>' );
 209+ $wgOut->addHTML( '&nbsp;'.Xml::listDropDown( 'timezone', $this->dropDownList( range ( -12, 14, 1 ) ), '', $this->timezone, '', 1 ).' (from UTC)' );
 210+ $wgOut->addHTML( Xml::closeElement( 'div' ) );
 211+
 212+ $wgOut->addHTML( Xml::closeElement( 'form' ) );
 213+
166214 // Instructions
167215 $wgOut->addWikiMsg( 'fundraiserstats-instructions' );
168216
@@ -236,7 +284,7 @@
237285 case 'dailyTotals':
238286 $select = $dbr->select( 'public_reporting',
239287 array(
240 - "FROM_UNIXTIME(received, '%Y-%m-%d')",
 288+ "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$this->timezone'),'%Y-%m-%d')",
241289 'sum(converted_amount)',
242290 'count(*)',
243291 'avg(converted_amount)',
@@ -246,7 +294,7 @@
247295 __METHOD__,
248296 array(
249297 'ORDER BY' => 'received',
250 - 'GROUP BY' => "FROM_UNIXTIME(received, '%Y-%m-%d')"
 298+ 'GROUP BY' => "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$this->timezone'),'%Y-%m-%d')"
251299 )
252300 );
253301 $result = array();
@@ -263,7 +311,7 @@
264312 __METHOD__,
265313 array(
266314 'ORDER BY' => 'sum DESC',
267 - 'GROUP BY' => "FROM_UNIXTIME(received, '%Y-%m-%d')",
 315+ 'GROUP BY' => "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$this->timezone'),'%Y-%m-%d')"
268316 )
269317 );
270318 break;
@@ -281,7 +329,7 @@
282330 __METHOD__,
283331 array(
284332 'ORDER BY' => 'sum DESC',
285 - 'GROUP BY' => "FROM_UNIXTIME(received, '%Y-%m-%d')",
 333+ 'GROUP BY' => "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$this->timezone'),'%Y-%m-%d')"
286334 )
287335 );
288336 break;
@@ -292,7 +340,7 @@
293341 __METHOD__,
294342 array(
295343 'ORDER BY' => 'sum DESC',
296 - 'GROUP BY' => "FROM_UNIXTIME(received, '%Y-%m-%d')",
 344+ 'GROUP BY' => "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$this->timezone'),'%Y-%m-%d')"
297345 )
298346 );
299347 break;
@@ -303,7 +351,7 @@
304352 __METHOD__,
305353 array(
306354 'ORDER BY' => 'sum DESC',
307 - 'GROUP BY' => "FROM_UNIXTIME(received, '%Y-%m-%d')",
 355+ 'GROUP BY' => "DATE_FORMAT(CONVERT_TZ(FROM_UNIXTIME(received),'+00:00','$this->timezone'),'%Y-%m-%d')"
308356 )
309357 );
310358 break;
@@ -314,4 +362,13 @@
315363 }
316364 return null;
317365 }
 366+
 367+ private function dropDownList ( $values ) {
 368+ $dropDown = '';
 369+ foreach ( $values as $value ) {
 370+ if ( $value >= 0 ) $dropDown .= '+';
 371+ $dropDown .= "$value:00\n";
 372+ }
 373+ return $dropDown;
 374+ }
318375 }
Index: trunk/extensions/ContributionReporting/FundraiserStatistics.css
@@ -1,3 +1,33 @@
 2+div#configholder {
 3+ position: absolute;
 4+ top: 22px;
 5+ right: 0;
 6+ z-index: 200;
 7+ width: 180px;
 8+ border: 1px solid silver;
 9+ background-color: white;
 10+ padding: 2px 5px 5px 5px;
 11+ display: none;
 12+}
 13+div#configtoggle {
 14+ position: absolute;
 15+ top: 0;
 16+ right: 0;
 17+ z-index: 199;
 18+ height: 17px;
 19+ border: 1px solid silver;
 20+ background-color: white;
 21+ padding: 2px 5px 2px 0px;
 22+ cursor: pointer;
 23+}
 24+div#configtoggle a, div#configtoggle a:visited {
 25+ background-image: url("arrow.png");
 26+ background-position: 0px -3px;
 27+ background-repeat: no-repeat;
 28+ padding-left: 16px;
 29+ outline: 0;
 30+}
 31+
232 .fundraiserstats-view-box {
333 border: solid 1px silver;
434 }
@@ -13,29 +43,27 @@
1444 margin-top: 3px;
1545 margin-left: -1px;
1646 }
 47+.fundraiserstats-bar {
 48+ width: 2px;
 49+}
1750 .fundraiserstats-bar-2007 {
1851 background-color: #AAAAFF;
1952 border: outset 1px #AAAAFF;
20 - width: 2px;
21 - margin-left: 3px;
2253 }
2354 .fundraiserstats-bar-2008 {
2455 background-color: #AAFFAA;
2556 border: outset 1px #AAFFAA;
26 - width: 2px;
2757 }
2858 .fundraiserstats-bar-2009 {
2959 background-color: #FFAAAA;
3060 border: outset 1px #FFAAAA;
31 - width: 2px;
3261 }
3362 .fundraiserstats-bar-2010 {
3463 background-color: #FF0000;
3564 border: outset 1px #FF0000;
36 - width: 2px;
3765 }
3866 .fundraiserstats-bar-space {
39 - width: 2px;
 67+ width: 3px;
4068 }
4169 .fundraiserstats-chart {
4270 padding: 10px;
Index: trunk/extensions/ContributionReporting/FundraiserStatistics.js
@@ -33,4 +33,19 @@
3434 $j( '.fundraiserstats-current' ).each( function() {
3535 replaceView( $j(this).attr( 'rel' ) )
3636 } );
 37+ $j( '#configholder .yeartoggle' ).click( function() {
 38+ $j('.fundraiserstats-'+$j(this).attr( 'id' )).toggle();
 39+ } );
 40+ $j( '#configtoggle' ).click( function() {
 41+ $j('#configholder').toggle();
 42+ if ($j( '#configtoggle a' ).css( 'background-position' ) == '0px -18px') {
 43+ $j( '#configtoggle a' ).css( 'background-position', '0px -3px' );
 44+ } else {
 45+ $j( '#configtoggle a' ).css( 'background-position','0px -18px' );
 46+ }
 47+ } );
 48+ $j( '#timezone' ).change( function() {
 49+ $j('#configform').submit();
 50+ } );
 51+
3752 } );

Follow-up revisions

RevisionCommit summaryAuthorDate
r80955adding localization to r80954kaldari02:52, 25 January 2011
r102697MFT r45856, r71558, r71962, r73304, r73309, r75671, r75680, r75726, r76542, r...awjrichards22:02, 10 November 2011

Status & tagging log