r102035 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102034‎ | r102035 | r102036 >
Date:20:06, 4 November 2011
Author:mah
Status:ok
Tags:
Comment:
w/s fixups
Modified paths:
  • /trunk/extensions/ContributionReporting/ContributionHistory_body.php (modified) (history)
  • /trunk/extensions/ContributionReporting/ContributionReporting.i18n.php (modified) (history)
  • /trunk/extensions/ContributionReporting/ContributionReporting.php (modified) (history)
  • /trunk/extensions/ContributionReporting/ContributionTrackingStatistics_body.php (modified) (history)
  • /trunk/extensions/ContributionReporting/FundraiserStatistics.js (modified) (history)
  • /trunk/extensions/ContributionReporting/FundraiserStatistics_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ContributionReporting/ContributionReporting.php
@@ -168,31 +168,31 @@
169169
170170 # Output
171171 $output = $row['ttl'] ? $row['ttl'] : '0';
172 -
 172+
173173 $output += $fudgeFactor;
174 -
 174+
175175 return $output;
176176 }
177177
178178 function efContributionReportingTotal_Render() {
179179 $args = func_get_args();
180180 array_shift( $args );
181 -
 181+
182182 $fudgeFactor = false;
183183 $start = false;
184 -
 184+
185185 foreach( $args as $arg ) {
186186 if ( strpos($arg,'=') === false )
187187 continue;
188 -
 188+
189189 list($key,$value) = explode( '=', trim($arg), 2 );
190 -
 190+
191191 if ($key == 'fudgefactor') {
192192 $fudgeFactor = $value;
193193 } elseif ($key == 'start') {
194194 $start = $value;
195195 }
196196 }
197 -
 197+
198198 return efContributionReportingTotal( $start, $fudgeFactor );
199199 }
Index: trunk/extensions/ContributionReporting/ContributionTrackingStatistics_body.php
@@ -37,18 +37,18 @@
3838 );
3939
4040 $htmlOut .= Xml::tags( 'tr', null,
41 - Xml::element( 'td', array( 'align' => 'left' ),
 41+ Xml::element( 'td', array( 'align' => 'left' ),
4242 wfMsg( 'contribstats-imperfect-data' ) ) .
43 - Xml::element( 'td', array( 'align' => 'right' ),
 43+ Xml::element( 'td', array( 'align' => 'right' ),
4444 wfTimestamp( TS_DB ) . ' (UTC)')
4545 );
4646 $htmlOut .= Xml::tags( 'tr', null,
47 - Xml::element( 'td', array( 'align' => 'left' ),
48 - wfMsg( 'contribstats-fraud-note' ) . " " .
 47+ Xml::element( 'td', array( 'align' => 'left' ),
 48+ wfMsg( 'contribstats-fraud-note' ) . " " .
4949 wfMsg( 'contribstats-unaudited' ) )
5050 );
5151 $htmlOut .= Xml::tags( 'tr', null,
52 - Xml::element( 'td', array( 'align' => 'left' ),
 52+ Xml::element( 'td', array( 'align' => 'left' ),
5353 'PP = ' . wfMsg( 'contribstats-paypal-donations' ) . ', ' .
5454 'CC = ' . wfMsg( 'contribstats-credit-card' ) )
5555 );
@@ -74,11 +74,11 @@
7575 public function showTotalsForRange( $range, $format ) {
7676 list( $start, $end ) = $range;
7777 $current = $end;
78 -
 78+
7979 switch( $format ) {
8080 case 1:
8181 while( $current > $start ) {
82 - $this->showDayTotals( $current );
 82+ $this->showDayTotals( $current );
8383 $current = $current - 24 * 60 * 60;
8484 }
8585 break;
@@ -91,7 +91,7 @@
9292 $this->showCombinedTotals( $totals, $range );
9393 break;
9494
95 - }
 95+ }
9696 }
9797
9898 // Display tracking information for one day
@@ -187,7 +187,7 @@
188188 public function showCombinedTotals( $totals, $range ) {
189189 global $wgOut;
190190
191 - $msg = date( 'o-m-d', wfTimestamp( TS_UNIX, $range[0] ) ) . ' - ' .
 191+ $msg = date( 'o-m-d', wfTimestamp( TS_UNIX, $range[0] ) ) . ' - ' .
192192 date( 'o-m-d', wfTimestamp( TS_UNIX, $range[1] ) ) ;
193193 $htmlOut = Xml::element( 'h3', null, $msg );
194194
@@ -224,7 +224,7 @@
225225
226226 $res = $dbr->select(
227227 array( 'contribution_tracking',
228 - 'civicrm.public_reporting',
 228+ 'civicrm.public_reporting',
229229 ),
230230 array(
231231 'utm_source',
@@ -242,7 +242,7 @@
243243 array( 'civicrm.public_reporting' =>
244244 array(
245245 'LEFT JOIN',
246 - 'contribution_tracking.contribution_id = civicrm.public_reporting.contribution_id',
 246+ 'contribution_tracking.contribution_id = civicrm.public_reporting.contribution_id',
247247 )
248248 )
249249
Index: trunk/extensions/ContributionReporting/FundraiserStatistics_body.php
@@ -13,10 +13,10 @@
1414 public function __construct() {
1515 parent::__construct( 'FundraiserStatistics' );
1616 }
17 -
 17+
1818 public function execute( $sub ) {
1919 global $wgRequest, $wgOut, $wgUser, $wgLang, $wgScriptPath, $egFundraiserStatisticsFundraisers;
20 -
 20+
2121 $showYear = array();
2222 foreach ( $egFundraiserStatisticsFundraisers as $fundraiser ) {
2323 if ( $wgRequest->wasPosted() ) {
@@ -25,11 +25,11 @@
2626 $showYear[$fundraiser['id']] = true;
2727 }
2828 }
29 -
 29+
3030 $this->timezone = $wgRequest->getText( 'timezone', '+0:00' );
31 -
 31+
3232 /* Configuration (this isn't totally static data, some of it gets built on the fly) */
33 -
 33+
3434 $charts = array(
3535 'totals' => array(
3636 'data' => array(),
@@ -72,9 +72,9 @@
7373 'max' => 1,
7474 ),
7575 );
76 -
 76+
7777 /* Setup */
78 -
 78+
7979 $this->setHeaders();
8080 $wgOut->addScriptFile( $wgScriptPath . '/extensions/ContributionReporting/FundraiserStatistics.js' );
8181 $wgOut->addLink(
@@ -84,9 +84,9 @@
8585 'href' => $wgScriptPath . '/extensions/ContributionReporting/FundraiserStatistics.css',
8686 )
8787 );
88 -
 88+
8989 /* Display */
90 -
 90+
9191 // Chart maximums
9292 foreach ( $egFundraiserStatisticsFundraisers as $fundraiser ) {
9393 foreach ( $charts as $name => $chart ) {
@@ -97,7 +97,7 @@
9898 }
9999 }
100100 // Scale factors
101 - foreach ( $charts as $name => $chart ) {
 101+ foreach ( $charts as $name => $chart ) {
102102 $charts[$name]['factor'] = 300 / $chart['max'];
103103 }
104104 // HTML-time!
@@ -112,7 +112,7 @@
113113 if ( !isset( $charts[$name]['data'][$column] ) ) {
114114 $charts[$name]['data'][$column] = '';
115115 }
116 -
 116+
117117 // Add spacer between days
118118 if ( $fundraiserIndex == 0 ) {
119119 $attributes = array(
@@ -123,7 +123,7 @@
124124 'td', array( 'valign' => 'bottom' ), Xml::element( 'div', $attributes, '', false )
125125 );
126126 }
127 -
 127+
128128 $height = $chart['factor'] * $day[$chart['index']];
129129 $style = "height:{$height}px;";
130130 if ( $showYear[$fundraiser['id']] !== true ) {
@@ -189,13 +189,13 @@
190190 }
191191 }
192192 }
193 -
 193+
194194 $wgOut->addHTML( Xml::openElement( 'div', array( 'id' => 'configtoggle' ) ) );
195195 $wgOut->addHTML( '<a id="customize-chart">'.wfMsg( 'fundraiserstats-customize' ).'</a>' );
196196 $wgOut->addHTML( Xml::closeElement( 'div' ) );
197 -
 197+
198198 $wgOut->addHTML( Xml::openElement( 'form', array( 'method' => 'post', 'id' => 'configform' ) ) );
199 -
 199+
200200 $years = wfMsg( 'fundraiserstats-show-years' ).'<br/>';
201201 foreach ( $egFundraiserStatisticsFundraisers as $fundraiser ) {
202202 $years .= Xml::check( 'toogle'.$fundraiser['id'], $showYear[$fundraiser['id']], array( 'id' => 'bar-'.$fundraiser['id'], 'class' => 'yeartoggle' ) );
@@ -207,9 +207,9 @@
208208 $wgOut->addHTML( wfMsg( 'fundraiserstats-time-zone' ).'<br/>' );
209209 $wgOut->addHTML( '&#160;'.Xml::listDropDown( 'timezone', $this->dropDownList( range ( -12, 14, 1 ) ), '', $this->timezone, '', 1 ).' '.wfMsg( 'fundraiserstats-utc' ) );
210210 $wgOut->addHTML( Xml::closeElement( 'div' ) );
211 -
 211+
212212 $wgOut->addHTML( Xml::closeElement( 'form' ) );
213 -
 213+
214214 // Instructions
215215 $wgOut->addWikiMsg( 'fundraiserstats-instructions' );
216216
@@ -237,7 +237,7 @@
238238 array(
239239 'id' => "fundraiserstats-chart-{$name}",
240240 'class' => 'fundraiserstats-chart',
241 - 'style' => 'display:' . ( $first ? 'block' : 'none' )
 241+ 'style' => 'display:' . ( $first ? 'block' : 'none' )
242242 ),
243243 Xml::tags(
244244 'table',
@@ -261,12 +261,12 @@
262262 )
263263 );
264264 }
265 -
 265+
266266 /* Private Functions */
267 -
 267+
268268 private function query( $type, $start, $end ) {
269269 global $wgMemc, $egFundraiserStatisticsMinimum, $egFundraiserStatisticsMaximum, $egFundraiserStatisticsCacheTimeout;
270 -
 270+
271271 $key = wfMemcKey( 'fundraiserstatistics', $type, $start, $end );
272272 $cache = $wgMemc->get( $key );
273273 if ( $cache != false && $cache != -1 ) {
@@ -362,7 +362,7 @@
363363 }
364364 return null;
365365 }
366 -
 366+
367367 private function dropDownList ( $values ) {
368368 $dropDown = '';
369369 foreach ( $values as $value ) {
Index: trunk/extensions/ContributionReporting/ContributionHistory_body.php
@@ -10,27 +10,27 @@
1111 # Emergecny short cut until post donation comments are enabled
1212 $wgOut->redirect( SpecialPage::getTitleFor( 'FundraiserStatistics' )->getFullURL() );
1313 return;
14 -
1514
 15+
1616 if ( !preg_match( '/^[a-z-]+$/', $language ) ) {
1717 $language = 'en';
1818 }
1919 $this->lang = Language::factory( $language );
20 -
 20+
2121 // Get request data
2222 $offset = $wgRequest->getIntOrNull( 'offset' );
2323 $show = 100;
24 -
 24+
2525 $this->setHeaders();
26 -
 26+
2727 $db = efContributionReportingConnection();
28 -
 28+
2929 $output = '<style type="text/css">';
3030 $output .= 'td.left {padding-right: 10px;}';
3131 $output .= 'td.right {padding-left: 10px; text-align: right;}';
3232 $output .= 'td.alt {background-color: #DDDDDD;}';
3333 $output .= '</style>';
34 -
 34+
3535 // Paging controls
3636 $newer = $db->selectField( 'public_reporting', 'received',
3737 array_merge(
@@ -41,7 +41,7 @@
4242 array(
4343 'ORDER BY' => 'received ASC',
4444 'LIMIT' => 1,
45 - 'OFFSET' => $show
 45+ 'OFFSET' => $show
4646 )
4747 );
4848 $older = $db->selectField( 'public_reporting', 'received',
@@ -56,9 +56,9 @@
5757 'OFFSET' => $show
5858 )
5959 );
60 -
 60+
6161 $title = $this->getTitle( $language == 'en' ? null : $language );
62 -
 62+
6363 $pagingLinks = array();
6464 if( $offset !== null ) {
6565 $pagingLinks[] = Xml::element( 'a',
@@ -79,14 +79,14 @@
8080 $wgLang->pipeList( $pagingLinks ) .
8181 Xml::closeElement( 'div' );
8282 $output .= $pagingDiv;
83 -
 83+
8484 $output .= '<table style="width: 100%">';
8585 $output .= '<tr>';
8686 $output .= '<th width="60%">' . $this->msg( 'contrib-hist-name' ) . '</th>';
8787 $output .= '<th width="25%">' . $this->msg( 'contrib-hist-date' ) . '</th>';
8888 $output .= '<th width="15%" align="right">' . $this->msg( 'contrib-hist-amount' ) . '</th>';
8989 $output .= '</tr>';
90 -
 90+
9191 if ( $offset == null ) {
9292 $offset = $db->selectField( 'public_reporting', 'received',
9393 array( 'received > ' . strtotime( 'July 1st 2008' ) ),
@@ -97,9 +97,9 @@
9898 )
9999 );
100100 }
101 -
 101+
102102 $url = SpecialPage::getTitleFor( 'ContributionHistory' )->getFullURL();
103 -
 103+
104104 $res = $db->select( 'public_reporting', '*',
105105 array_merge(
106106 array( 'received > ' . strtotime( 'July 1st 2008' ) ),
@@ -126,7 +126,7 @@
127127 if ( $alt ) {
128128 $class = ' alt';
129129 }
130 -
 130+
131131 $output .= "<tr>";
132132 $output .= "<td class=\"left $class\"><a name=\"{$contributionId}\"></a><a href=\"{$url}?offset={$offset}#{$contributionId}\">{$name}</a></td>";
133133 $output .= "<td class=\"left $class\" style=\"width: 100px;\">$date</td>";
@@ -135,9 +135,9 @@
136136
137137 $alt = !$alt;
138138 }
139 -
 139+
140140 $output .= '</table>';
141 -
 141+
142142 $output .= $pagingDiv;
143143
144144 header( 'Cache-Control: max-age=300,s-maxage=300' );
@@ -146,25 +146,25 @@
147147 $wgOut->addWikiText( '<strong>{{2008/Contribution history introduction/' . $language . '}}</strong>' );
148148 $wgOut->addHTML( $output );
149149 }
150 -
 150+
151151 function msg( $key ) {
152152 return wfMsgExt( $key, array( 'escape', 'language' => $this->lang ) );
153153 }
154 -
 154+
155155 function formatName( $row ) {
156156 $name = htmlspecialchars( $row['name'] );
157157 if( !$name ) {
158158 $name = $this->msg( 'contrib-hist-anonymous' );
159159 }
160160 $name = '<strong>' . $name . '</strong>';
161 -
 161+
162162 if( $row['note'] && !$this->isTiny( $row ) ) {
163163 $name .= '<br />' . htmlspecialchars( $row['note'] );
164164 }
165165
166166 return $name;
167167 }
168 -
 168+
169169 function isTiny( $row ) {
170170 $mins = array(
171171 'USD' => 1,
@@ -200,7 +200,7 @@
201201 return false;
202202 }
203203 }
204 -
 204+
205205 function formatDate( $row ) {
206206 $ts = wfTimestamp( TS_MW, $row['received'] );
207207 return $this->lang->timeanddate( $ts );
@@ -208,7 +208,7 @@
209209
210210 function formatAmount( $row ) {
211211 $converted = $row['converted_amount'];
212 -
 212+
213213 if ( $row['original_currency'] ) {
214214 $currency = $row['original_currency'];
215215 $amount = $row['original_amount'];
Index: trunk/extensions/ContributionReporting/FundraiserStatistics.js
@@ -1,7 +1,7 @@
22 /* JavaScript */
33
44 $j( document ).ready( function() {
5 -
 5+
66 var currentViewID = 'fundraiserstats-view-box-0';
77 function replaceView( newLayerID ) {
88 var currentLayer = document.getElementById( currentViewID );
@@ -10,7 +10,7 @@
1111 newLayer.style.display = 'block';
1212 currentViewID = newLayerID;
1313 }
14 -
 14+
1515 var currentChartID = 'fundraiserstats-chart-totals';
1616 function replaceChart( newLayerID ) {
1717 var currentLayer = document.getElementById( currentChartID );
@@ -47,5 +47,5 @@
4848 $j( '#timezone' ).change( function() {
4949 $j('#configform').submit();
5050 } );
51 -
 51+
5252 } );
Index: trunk/extensions/ContributionReporting/ContributionReporting.i18n.php
@@ -16,16 +16,16 @@
1717 'contributionreporting-desc' => 'Live reporting on the Wikimedia fundraiser',
1818 'contributiontotal' => 'Contribution total',
1919 'contributionhistory' => 'Contribution history',
20 -
 20+
2121 'contrib-hist-header' => 'Donor comments from around the world',
22 -
 22+
2323 'contrib-hist-name' => 'Name',
2424 'contrib-hist-date' => 'Time and date',
2525 'contrib-hist-amount' => 'Amount',
26 -
 26+
2727 'contrib-hist-next' => 'Earlier donations',
2828 'contrib-hist-previous' => 'Newer donations',
29 -
 29+
3030 'contrib-hist-anonymous' => 'Anonymous',
3131
3232 // ContributionStatistics
@@ -118,21 +118,21 @@
119119 'contrib-hist-name' => '{{Identical|Name}}',
120120 'contrib-hist-date' => '{{Identical|Date}}',
121121 'contrib-hist-amount' => '{{Identical|Amount}}',
122 - 'contributionstatistics' => 'Title on the contribution report for <nowiki>[[Special:ContributionStatistics]]</nowiki>.
 122+ 'contributionstatistics' => 'Title on the contribution report for <nowiki>[[Special:ContributionStatistics]]</nowiki>.
123123 You may see an example in context at http://wikimediafoundation.org/wiki/Special:ContributionStatistics',
124124 'contribstats-desc' => '{{desc}}',
125125 'contribstats-currency-range-totals' => '* $1 is a start date
126126 * $2 is an end date',
127 - 'contribstats-contribution-breakdown' => 'Title on the contribution report for <nowiki>[[</nowiki>Special:ContributionStatistics<nowiki>]]</nowiki>.
 127+ 'contribstats-contribution-breakdown' => 'Title on the contribution report for <nowiki>[[</nowiki>Special:ContributionStatistics<nowiki>]]</nowiki>.
128128 You may see an example in context at http://wikimediafoundation.org/wiki/Special:ContributionStatistics',
129 - 'contribstats-day' => '"Day" on the contribution report for <nowiki>[[</nowiki>Special:ContributionStatistics<nowiki>]]</nowiki>.
 129+ 'contribstats-day' => '"Day" on the contribution report for <nowiki>[[</nowiki>Special:ContributionStatistics<nowiki>]]</nowiki>.
130130 You may see an example in context at http://wikimediafoundation.org/wiki/Special:ContributionStatistics
131131 {{Identical|Day}}',
132 - 'contribstats-month' => '"Month" on the contribution report for <nowiki>[[</nowiki>Special:ContributionStatistics<nowiki>]]</nowiki>.
 132+ 'contribstats-month' => '"Month" on the contribution report for <nowiki>[[</nowiki>Special:ContributionStatistics<nowiki>]]</nowiki>.
133133 You may see an example in context at http://wikimediafoundation.org/wiki/Special:ContributionStatistics
134134 {{Identical|Month}}',
135135 'contribstats-currency' => '{{Identical|Currency}}',
136 - 'contribstats-contributions' => 'The number of contributions (donations) on a report for <nowiki>[[</nowiki>Special:ContributionStatistics<nowiki>]]</nowiki>.
 136+ 'contribstats-contributions' => 'The number of contributions (donations) on a report for <nowiki>[[</nowiki>Special:ContributionStatistics<nowiki>]]</nowiki>.
137137 You may see an example in context at http://wikimediafoundation.org/wiki/Special:ContributionStatistics',
138138 'contribstats-day-totals' => 'The day for which the contribution statistics are being displayed.',
139139 'contribstats-conversion' => 'Click conversion rate, see [[:wikipedia:Conversion rate|Wikipedia article]].',

Follow-up revisions

RevisionCommit summaryAuthorDate
r102697MFT r45856, r71558, r71962, r73304, r73309, r75671, r75680, r75726, r76542, r...awjrichards22:02, 10 November 2011

Status & tagging log