r43461 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43460‎ | r43461 | r43462 >
Date:20:11, 13 November 2008
Author:tparscal
Status:old (Comments)
Tags:
Comment:
Added detail view on mouseover.
Modified paths:
  • /trunk/extensions/ContributionReporting/ContributionReporting.i18n.php (modified) (history)
  • /trunk/extensions/ContributionReporting/FundraiserStatistics_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ContributionReporting/ContributionReporting.i18n.php
@@ -52,6 +52,11 @@
5353
5454 // Fundraiser statistics
5555 'fundraiserstatistics' => 'Fundraiser statistics',
 56+ 'fundraiserstats-date' => 'Date',
 57+ 'fundraiserstats-total' => 'Total (USD)',
 58+ 'fundraiserstats-avg' => 'Average (USD)',
 59+ 'fundraiserstats-min' => 'Minimum (USD)',
 60+ 'fundraiserstats-max' => 'Maximum (USD)',
5661 );
5762
5863 /** Message documentation (Message documentation)
Index: trunk/extensions/ContributionReporting/FundraiserStatistics_body.php
@@ -26,7 +26,30 @@
2727 // Begin output
2828 $this->setHeaders();
2929
30 - $htmlOut = Xml::openElement( 'div', array( 'style' => 'margin-bottom: 10px;' ) );
 30+ $style = <<<END
 31+.fundraiserstats-view-box {
 32+ width: 100%;
 33+ height: 200px;
 34+ margin-top:20px;
 35+ border: solid 1px silver;
 36+}
 37+
 38+END;
 39+ $script = <<<END
 40+var currentLayerID = 'fundraiserstats-view-box-0';
 41+function replaceView( newLayerID ) {
 42+ var currentLayer = document.getElementById( currentLayerID );
 43+ currentLayer.style.display = 'none';
 44+ var newLayer = document.getElementById( newLayerID );
 45+ newLayer.style.display = 'block';
 46+ currentLayerID = newLayerID;
 47+}
 48+END;
 49+
 50+ $htmlOut = Xml::element( 'style', array( 'type' => 'text/css' ), $style );
 51+ $htmlOut .= Xml::element( 'script', array( 'type' => 'text/javascript' ), $script );
 52+
 53+ $htmlOut .= Xml::openElement( 'div', array( 'style' => 'margin-bottom: 20px;' ) );
3154 $today = strtotime( date( 'M j Y' ) );
3255
3356 $max = 0;
@@ -34,13 +57,15 @@
3558 $days = $this->getDailyTotals( $fundraiser['start'], $fundraiser['end'] );
3659 // Determine maximimum for fundraiser
3760 foreach ( $days as $day ) {
38 - if ( $day[0] > $max ) {
39 - $max = $day[0];
 61+ if ( $day[1] > $max ) {
 62+ $max = $day[1];
4063 }
4164 }
4265 }
4366
4467 $columns = array();
 68+ $views = array();
 69+ $view = 0;
4570 foreach ( $egFundraiserStatisticsFundraisers as $fundraiser ) {
4671 $htmlOut .= Xml::element( 'span',
4772 array(
@@ -64,7 +89,7 @@
6590 // Build columns
6691 $column = 0;
6792 foreach( $days as $day ) {
68 - $height = ( 200 / $max ) * $day[0];
 93+ $height = ( 200 / $max ) * $day[1];
6994 if ( !isset( $columns[$column] ) ) {
7095 $columns[$column] = '';
7196 }
@@ -81,12 +106,55 @@
82107 );
83108 }
84109 $columns[$column] .= Xml::tags( 'td', array( 'valign' => 'bottom' ),
85 - Xml::element( 'div', array( 'style' => $style ), '', false ) . $extra
 110+ Xml::element( 'div',
 111+ array(
 112+ 'style' => $style,
 113+ 'onMouseOver' => "replaceView( 'fundraiserstats-view-box-{$view}' )"
 114+ ),
 115+ '',
 116+ false
 117+ ) . $extra
86118 );
 119+
 120+ $viewHTML = Xml::openElement( 'table',
 121+ array(
 122+ 'cellpadding' => 5,
 123+ 'cellspacing' => 0,
 124+ 'border' => 0,
 125+ 'style' => 'margin:10px'
 126+ )
 127+ );
 128+ $viewHTML .= Xml::tags( 'tr', null,
 129+ Xml::element( 'td', null, wfMsg( 'fundraiserstats-date' ) ) .
 130+ Xml::element( 'td', null, $day[0] )
 131+ );
 132+ $viewHTML .= Xml::tags( 'tr', null,
 133+ Xml::element( 'td', null, wfMsg( 'fundraiserstats-total' ) ) .
 134+ Xml::element( 'td', null, $day[1] )
 135+ );
 136+ $viewHTML .= Xml::tags( 'tr', null,
 137+ Xml::element( 'td', null, wfMsg( 'fundraiserstats-avg' ) ) .
 138+ Xml::element( 'td', null, $day[2] )
 139+ );
 140+ $viewHTML .= Xml::tags( 'tr', null,
 141+ Xml::element( 'td', null, wfMsg( 'fundraiserstats-max' ) ) .
 142+ Xml::element( 'td', null, $day[3] )
 143+ );
 144+ $viewHTML .= Xml::closeElement( 'table' );
 145+
 146+ $views[$day[1]] = Xml::tags( 'div',
 147+ array(
 148+ 'id' => 'fundraiserstats-view-box-' . $view,
 149+ 'class' => 'fundraiserstats-view-box',
 150+ 'style' => 'display: ' . ( $view == 0 ? 'block' : 'none' )
 151+ ),
 152+ $viewHTML
 153+ );
 154+
87155 $column++;
 156+ $view++;
88157 }
89158 }
90 -
91159 $htmlOut .= Xml::closeElement( 'div' );
92160
93161 // Show bar graph
@@ -98,14 +166,35 @@
99167 )
100168 );
101169 $htmlOut .= Xml::openElement( 'tr' );
102 - foreach( $columns as $column ) {
 170+ $htmlOut .= Xml::openElement( 'td' );
 171+ $htmlOut .= Xml::openElement( 'table',
 172+ array(
 173+ 'cellpadding' => 0,
 174+ 'cellspacing' => 0,
 175+ 'border' => 0
 176+ )
 177+ );
 178+ $htmlOut .= Xml::openElement( 'tr' );
 179+ foreach( $columns as $i => $column ) {
103180 $htmlOut .= $column;
104 - $htmlOut .= Xml::tags( 'td', array( 'valign' => 'bottom' ),
105 - Xml::element( 'div', array( 'style' => "width:4px;" ), '', false )
106 - );
 181+ if ( $i < count( $columns ) - 1 ) {
 182+ $htmlOut .= Xml::tags( 'td', array( 'valign' => 'bottom' ),
 183+ Xml::element( 'div', array( 'style' => "width:4px;" ), '', false )
 184+ );
 185+ }
107186 }
108187 $htmlOut .= Xml::closeElement( 'tr' );
109188 $htmlOut .= Xml::closeElement( 'table' );
 189+ $htmlOut .= Xml::closeElement( 'td' );
 190+ $htmlOut .= Xml::closeElement( 'tr' );
 191+ $htmlOut .= Xml::openElement( 'tr' );
 192+ $htmlOut .= Xml::openElement( 'td' );
 193+ foreach( $views as $view ) {
 194+ $htmlOut .= $view;
 195+ }
 196+ $htmlOut .= Xml::closeElement( 'td' );
 197+ $htmlOut .= Xml::closeElement( 'tr' );
 198+ $htmlOut .= Xml::closeElement( 'table' );
110199
111200 $wgOut->addHTML( $htmlOut );
112201 }
@@ -122,8 +211,10 @@
123212 // Select sums and dates of contributions grouped by day
124213 $res = $dbr->select( 'public_reporting',
125214 array(
 215+ "FROM_UNIXTIME(received, '%Y-%m-%d')",
126216 'sum(converted_amount)',
127 - "FROM_UNIXTIME(received, '%Y-%m-%d')"
 217+ 'avg(converted_amount)',
 218+ 'max(converted_amount)',
128219 ),
129220 array_merge(
130221 array(

Comments

#Comment by Brion VIBBER (talk | contribs)   21:39, 13 November 2008

woot

Status & tagging log