Index: trunk/extensions/ContributionReporting/ContributionHistory.i18n.php |
— | — | @@ -1,5 +0,0 @@ |
2 | | -<?php |
3 | | -$messages = array(); |
4 | | -$messages['en'] = array( |
5 | | - 'contributionhistory' => 'Contribution history', |
6 | | - ); |
Index: trunk/extensions/ContributionReporting/ContributionTotal.i18n.php |
— | — | @@ -1,5 +0,0 @@ |
2 | | -<?php |
3 | | -$messages = array(); |
4 | | -$messages['en'] = array( |
5 | | - 'contributiontotal' => 'Contribution total', |
6 | | - ); |
Index: trunk/extensions/ContributionReporting/ContributionReporting.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | # Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly. |
5 | | -if (!defined('MEDIAWIKI')) { |
| 5 | +if ( !defined( 'MEDIAWIKI' ) ) { |
6 | 6 | echo <<<EOT |
7 | 7 | To install my extension, put the following line in LocalSettings.php: |
8 | 8 | require_once( "\$IP/extensions/ContributionReporting/ContributionReporting.php" ); |
— | — | @@ -15,49 +15,28 @@ |
16 | 16 | $wgContributionReportingDBpassword = $wgDBpassword; |
17 | 17 | $wgContributionReportingDBname = $wgDBname; |
18 | 18 | |
19 | | -$dir = dirname(__FILE__) . '/'; |
| 19 | +$dir = dirname( __FILE__ ) . '/'; |
20 | 20 | |
21 | | -// Add any aliases for the special page. |
22 | | -$wgHooks['LanguageGetSpecialPageAliases'][] = 'contributionReportingLocalizedPageName'; |
23 | | - |
24 | | -$wgExtensionMessagesFiles['ContributionHistory'] = $dir . 'ContributionHistory.i18n.php'; |
| 21 | +$wgExtensionMessagesFiles['ContributionReporting'] = $dir . 'ContributionReporting.i18n.php'; |
| 22 | +$wgExtensionAliasesFiles['ContributionReporting'] = $dir . 'ContributionReporting.alias.php'; |
25 | 23 | $wgAutoloadClasses['ContributionHistory'] = $dir . 'ContributionHistory_body.php'; |
26 | | -$wgSpecialPages['ContributionHistory'] = 'ContributionHistory'; |
27 | | - |
28 | | -$wgExtensionMessagesFiles['ContributionTotal'] = $dir . 'ContributionTotal.i18n.php'; |
29 | 24 | $wgAutoloadClasses['ContributionTotal'] = $dir . 'ContributionTotal_body.php'; |
| 25 | +$wgSpecialPages['ContributionHistory'] = 'ContributionHistory'; |
30 | 26 | $wgSpecialPages['ContributionTotal'] = 'ContributionTotal'; |
31 | 27 | |
32 | | -function contributionReportingLocalizedPageName(&$specialPageArray, $code) { |
33 | | - # The localized title of the special page is among the messages of the extension: |
34 | | - wfLoadExtensionMessages('ContributionHistory'); |
35 | | - $text = wfMsg('contributionhistory'); |
36 | | - |
37 | | - # Convert from title in text form to DBKey and put it into the alias array: |
38 | | - $title = Title::newFromText($text); |
39 | | - $specialPageArray['ContributionHistory'][] = $title->getDBKey(); |
40 | | - |
41 | | - wfLoadExtensionMessages('ContributionTotal'); |
42 | | - $text = wfMsg('contributiontotal'); |
43 | | - $title = Title::newFromText($text); |
44 | | - $specialPageArray['ContributionTotal'][] = $title->getDBKey(); |
45 | | - |
46 | | - return true; |
47 | | -} |
48 | | - |
49 | 28 | function contributionReportingConnection() { |
50 | 29 | global $wgContributionReportingDBserver, $wgContributionReportingDBname; |
51 | 30 | global $wgContributionReportingDBuser, $wgContributionReportingDBpassword; |
52 | | - |
| 31 | + |
53 | 32 | static $db; |
54 | | - |
55 | | - if (!$db) { |
| 33 | + |
| 34 | + if ( !$db ) { |
56 | 35 | $db = new DatabaseMysql( |
57 | 36 | $wgContributionReportingDBserver, |
58 | 37 | $wgContributionReportingDBuser, |
59 | 38 | $wgContributionReportingDBpassword, |
60 | 39 | $wgContributionReportingDBname ); |
61 | 40 | } |
62 | | - |
| 41 | + |
63 | 42 | return $db; |
64 | 43 | } |
Index: trunk/extensions/ContributionReporting/ContributionHistory_body.php |
— | — | @@ -1,91 +1,91 @@ |
2 | 2 | <?php |
3 | 3 | class ContributionHistory extends SpecialPage { |
4 | | - function ContributionHistory() { |
5 | | - SpecialPage::SpecialPage('ContributionHistory'); |
6 | | - wfLoadExtensionMessages('ContributionHistory'); |
7 | | - } |
8 | | - |
9 | | - function execute( $language = NULL ) { |
10 | | - global $wgRequest, $wgOut; |
11 | | - |
12 | | - if (!$language) { |
13 | | - $language = 'en'; |
14 | | - } |
15 | | - |
16 | | - // Get request data |
17 | | - $dir = $wgRequest->getText('dir', ''); |
18 | | - $offset = $wgRequest->getText('offset'); |
19 | | - $limit = $wgRequest->getText('limit', 50); |
20 | | - |
21 | | - $this->setHeaders(); |
22 | | - |
23 | | - $db = contributionReportingConnection(); |
| 4 | + function ContributionHistory() { |
| 5 | + SpecialPage::SpecialPage( 'ContributionHistory' ); |
| 6 | + } |
24 | 7 | |
25 | | - $sql = 'SELECT * FROM public_reporting ORDER BY received DESC LIMIT ' . intval($limit); |
26 | | - |
27 | | - $res = $db->query($sql); |
28 | | - |
29 | | - $output = '<style type="text/css">'; |
30 | | - $output .= 'td {vertical-align: top; padding: 5px;}'; |
31 | | - $output .= 'td.left {padding-right: 10px;}'; |
32 | | - $output .= 'td.right {padding-left: 10px; text-align: right;}'; |
33 | | - $output .= 'td.alt {background-color: #DDDDDD;}'; |
34 | | - $output .= '</style>'; |
35 | | - |
36 | | - $output .= '<table style="width: 100%">'; |
37 | | - $output .= '<tr><th style="width: 200px;">Name</th><th>Date</th><th style="text-align: right;">Amount</th></tr>'; |
38 | | - |
39 | | - $alt = TRUE; |
40 | | - while ($row = $res->fetchRow()) { |
41 | | - $name = htmlspecialchars($row['name']); |
42 | | - if (!$name) { |
43 | | - $name = 'Anonymous'; |
44 | | - } |
45 | | - |
46 | | - $name = '<strong>' . $name . '</strong>'; |
47 | | - |
48 | | - if ($row['note']) { |
49 | | - $name .= '<br />' . htmlspecialchars($row['note']); |
50 | | - } |
51 | | - |
52 | | - $amount = $this->formatAmount( $row ); |
53 | | - |
54 | | - $class = ''; |
55 | | - if ($alt) { |
56 | | - $class = ' alt'; |
57 | | - } |
58 | | - |
59 | | - $output .= '<tr><td class="left' . $class . '">' . $name . '</td><td class="left' . $class . '" style="width: 50px;">' . date('Y-m-j', $row['received']) . '</td><td class="right' . $class . '" style="width: 75px;">' . $amount . '</td></tr>'; |
60 | | - |
61 | | - $alt = !$alt; |
62 | | - } |
63 | | - |
64 | | - $output .= '</table>'; |
65 | | - |
66 | | - header('Cache-Control: max-age=300,s-maxage=300'); |
67 | | - $wgOut->addWikiText('{{Template:Donate-header/' . $language . '}}'); |
68 | | - $wgOut->addWikiText('<skin>Tomas</skin>'); |
69 | | - $wgOut->addHTML('<h1>Real-time donor comments from around the world</h1>'); |
70 | | - $wgOut->addWikiText('<strong>{{Template:Contribution history introduction/' . $language . '}}</strong>'); |
71 | | - $wgOut->addHTML( $output ); |
72 | | - $wgOut->addWikiText('{{Template:Donate-footer/' . $language . '}}'); |
73 | | - } |
| 8 | + function execute( $language = NULL ) { |
| 9 | + global $wgRequest, $wgOut; |
74 | 10 | |
75 | | - function formatAmount( $row ) { |
76 | | - if( $row['original_currency'] ) { |
77 | | - $currency = $row['original_currency']; |
78 | | - $amount = $row['original_amount']; |
79 | | - } else { |
80 | | - $currency = 'USD'; |
81 | | - $amount = $row['converted_amount']; |
82 | | - } |
83 | | - |
84 | | - if( $currency == 'JPY' ) { |
85 | | - // No decimals for yen |
86 | | - $amount = intval( $amount ); |
87 | | - } |
88 | | - |
89 | | - return htmlspecialchars( "$currency $amount" ); |
90 | | - } |
| 11 | + if ( !$language ) { |
| 12 | + $language = 'en'; |
| 13 | + } |
91 | 14 | |
| 15 | + // Get request data |
| 16 | + $dir = $wgRequest->getText( 'dir', '' ); |
| 17 | + $offset = $wgRequest->getText( 'offset' ); |
| 18 | + $limit = $wgRequest->getText( 'limit', 50 ); |
| 19 | + |
| 20 | + wfLoadExtensionMessages( 'ContributionReporting' ); |
| 21 | + |
| 22 | + $this->setHeaders(); |
| 23 | + |
| 24 | + $db = contributionReportingConnection(); |
| 25 | + |
| 26 | + $sql = 'SELECT * FROM public_reporting ORDER BY received DESC LIMIT ' . intval( $limit ); |
| 27 | + |
| 28 | + $res = $db->query( $sql ); |
| 29 | + |
| 30 | + $output = '<style type="text/css">'; |
| 31 | + $output .= 'td {vertical-align: top; padding: 5px;}'; |
| 32 | + $output .= 'td.left {padding-right: 10px;}'; |
| 33 | + $output .= 'td.right {padding-left: 10px; text-align: right;}'; |
| 34 | + $output .= 'td.alt {background-color: #DDDDDD;}'; |
| 35 | + $output .= '</style>'; |
| 36 | + |
| 37 | + $output .= '<table style="width: 100%">'; |
| 38 | + $output .= '<tr><th style="width: 200px;">Name</th><th>Date</th><th style="text-align: right;">Amount</th></tr>'; |
| 39 | + |
| 40 | + $alt = TRUE; |
| 41 | + while ( $row = $res->fetchRow() ) { |
| 42 | + $name = htmlspecialchars( $row['name'] ); |
| 43 | + if ( !$name ) { |
| 44 | + $name = 'Anonymous'; |
| 45 | + } |
| 46 | + |
| 47 | + $name = '<strong>' . $name . '</strong>'; |
| 48 | + |
| 49 | + if ( $row['note'] ) { |
| 50 | + $name .= '<br />' . htmlspecialchars( $row['note'] ); |
| 51 | + } |
| 52 | + |
| 53 | + $amount = $this->formatAmount( $row ); |
| 54 | + |
| 55 | + $class = ''; |
| 56 | + if ( $alt ) { |
| 57 | + $class = ' alt'; |
| 58 | + } |
| 59 | + |
| 60 | + $output .= '<tr><td class="left' . $class . '">' . $name . '</td><td class="left' . $class . '" style="width: 50px;">' . date( 'Y-m-j', $row['received'] ) . '</td><td class="right' . $class . '" style="width: 75px;">' . $amount . '</td></tr>'; |
| 61 | + |
| 62 | + $alt = !$alt; |
| 63 | + } |
| 64 | + |
| 65 | + $output .= '</table>'; |
| 66 | + |
| 67 | + header( 'Cache-Control: max-age=300,s-maxage=300' ); |
| 68 | + $wgOut->addWikiText( '{{Template:Donate-header/' . $language . '}}' ); |
| 69 | + $wgOut->addWikiText( '<skin>Tomas</skin>' ); |
| 70 | + $wgOut->addHTML( '<h1>Real-time donor comments from around the world</h1>' ); |
| 71 | + $wgOut->addWikiText( '<strong>{{Template:Contribution history introduction/' . $language . '}}</strong>' ); |
| 72 | + $wgOut->addHTML( $output ); |
| 73 | + $wgOut->addWikiText( '{{Template:Donate-footer/' . $language . '}}' ); |
| 74 | + } |
| 75 | + |
| 76 | + function formatAmount( $row ) { |
| 77 | + if ( $row['original_currency'] ) { |
| 78 | + $currency = $row['original_currency']; |
| 79 | + $amount = $row['original_amount']; |
| 80 | + } else { |
| 81 | + $currency = 'USD'; |
| 82 | + $amount = $row['converted_amount']; |
| 83 | + } |
| 84 | + |
| 85 | + if ( $currency == 'JPY' ) { |
| 86 | + // No decimals for yen |
| 87 | + $amount = intval( $amount ); |
| 88 | + } |
| 89 | + |
| 90 | + return htmlspecialchars( "$currency $amount" ); |
| 91 | + } |
92 | 92 | } |
Index: trunk/extensions/ContributionReporting/ContributionTotal_body.php |
— | — | @@ -1,43 +1,44 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class ContributionTotal extends SpecialPage { |
5 | | - function ContributionTotal() { |
6 | | - SpecialPage::SpecialPage('ContributionTotal'); |
7 | | - wfLoadExtensionMessages('ContributionTotal'); |
8 | | - } |
9 | | - |
10 | | - function execute( $par ) { |
11 | | - global $wgRequest, $wgOut; |
12 | | - |
13 | | - $this->setHeaders(); |
14 | | - |
15 | | - # Get request data from, e.g. |
16 | | - $start = $wgRequest->getText('start'); |
17 | | - $action = $wgRequest->getText('action'); |
18 | | - |
19 | | - $db = contributionReportingConnection(); |
| 5 | + function ContributionTotal() { |
| 6 | + SpecialPage::SpecialPage( 'ContributionTotal' ); |
| 7 | + } |
20 | 8 | |
21 | | - $sql = 'SELECT SUM(converted_amount) AS ttl FROM public_reporting'; |
22 | | - |
23 | | - if ($start) { |
24 | | - $sql .= ' WHERE received >= ' . $db->addQuotes($start); |
25 | | - } |
26 | | - |
27 | | - $res = $db->query($sql); |
28 | | - |
29 | | - $row = $res->fetchRow(); |
30 | | - |
31 | | - # Output |
32 | | - $output = $row['ttl'] ? $row['ttl'] : '0'; |
33 | | - |
34 | | - header('Cache-Control: max-age=300,s-maxage=300'); |
35 | | - if ($action == 'raw') { |
36 | | - $wgOut->disable(); |
37 | | - echo $output; |
38 | | - } |
39 | | - else { |
40 | | - $wgOut->setRobotpolicy( 'noindex,nofollow' ); |
41 | | - $wgOut->addHTML( $output ); |
42 | | - } |
43 | | - } |
| 9 | + function execute( $par ) { |
| 10 | + global $wgRequest, $wgOut; |
| 11 | + |
| 12 | + wfLoadExtensionMessages( 'ContributionReporting' ); |
| 13 | + |
| 14 | + $this->setHeaders(); |
| 15 | + |
| 16 | + # Get request data from, e.g. |
| 17 | + $start = $wgRequest->getText( 'start' ); |
| 18 | + $action = $wgRequest->getText( 'action' ); |
| 19 | + |
| 20 | + $db = contributionReportingConnection(); |
| 21 | + |
| 22 | + $sql = 'SELECT SUM(converted_amount) AS ttl FROM public_reporting'; |
| 23 | + |
| 24 | + if ( $start ) { |
| 25 | + $sql .= ' WHERE received >= ' . $db->addQuotes( $start ); |
| 26 | + } |
| 27 | + |
| 28 | + $res = $db->query( $sql ); |
| 29 | + |
| 30 | + $row = $res->fetchRow(); |
| 31 | + |
| 32 | + # Output |
| 33 | + $output = $row['ttl'] ? $row['ttl'] : '0'; |
| 34 | + |
| 35 | + header( 'Cache-Control: max-age=300,s-maxage=300' ); |
| 36 | + if ( $action == 'raw' ) { |
| 37 | + $wgOut->disable(); |
| 38 | + echo $output; |
| 39 | + } |
| 40 | + else { |
| 41 | + $wgOut->setRobotpolicy( 'noindex,nofollow' ); |
| 42 | + $wgOut->addHTML( $output ); |
| 43 | + } |
| 44 | + } |
44 | 45 | } |
Property changes on: trunk/extensions/ContributionReporting/ContributionTotal_body.php |
___________________________________________________________________ |
Added: svn:keywords |
45 | 46 | + Id |
Index: trunk/extensions/ContributionReporting/ContributionReporting.alias.php |
— | — | @@ -0,0 +1,15 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Aliases for ContributionReporting extension special pages |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$aliases = array(); |
| 11 | + |
| 12 | +/** English */ |
| 13 | +$aliases['en'] = array( |
| 14 | + 'ContributionHistory' => array( 'ContributionHistory' ), |
| 15 | + 'ContributionTotal' => array( 'ContributionTotal' ), |
| 16 | +); |
Property changes on: trunk/extensions/ContributionReporting/ContributionReporting.alias.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 17 | + native |
Added: svn:keywords |
2 | 18 | + Id |
Index: trunk/extensions/ContributionReporting/ContributionReporting.i18n.php |
— | — | @@ -0,0 +1,17 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalisation for ContributionReporting extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$messages = array(); |
| 11 | + |
| 12 | +/** English |
| 13 | + * @author Trevor Parscal |
| 14 | + */ |
| 15 | +$messages['en'] = array( |
| 16 | + 'contributiontotal' => 'Contribution total', |
| 17 | + 'contributionhistory' => 'Contribution history', |
| 18 | +); |
Property changes on: trunk/extensions/ContributionReporting/ContributionReporting.i18n.php |
___________________________________________________________________ |
Added: svn:mergeinfo |
Added: svn:eol-style |
1 | 19 | + native |
Added: svn:keywords |
2 | 20 | + Id |