r43013 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r43012‎ | r43013 | r43014 >
Date:19:15, 1 November 2008
Author:brion
Status:old
Tags:
Comment:
i18n, add time to the date so we don't have an entire page of the same date all the time
Modified paths:
  • /trunk/extensions/ContributionReporting/ContributionHistory_body.php (modified) (history)
  • /trunk/extensions/ContributionReporting/ContributionReporting.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ContributionReporting/ContributionHistory_body.php
@@ -10,6 +10,7 @@
1111 if ( !$language ) {
1212 $language = 'en';
1313 }
 14+ $this->lang = Language::factory( $language );
1415
1516 // Get request data
1617 $dir = $wgRequest->getText( 'dir', '' );
@@ -34,29 +35,33 @@
3536 $output .= '</style>';
3637
3738 $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+ $output .= '<tr>';
 40+ $output .= '<th style="width: 200px;">' . $this->msg( 'contrib-hist-name' ) . '</th>';
 41+ $output .= '<th>' . $this->msg( 'contrib-hist-date' ) . '</th>';
 42+ $output .= '<th style="text-align: right;">' . $this->msg( 'contrib-hist-amount' ) . '</th>';
 43+ $output .= '</tr>';
3944
4045 $alt = TRUE;
4146 while ( $row = $res->fetchRow() ) {
42 - $name = htmlspecialchars( $row['name'] );
43 - if ( !$name ) {
44 - $name = 'Anonymous';
45 - }
 47+ $name = $this->formatName( $row );
4648
47 - $name = '<strong>' . $name . '</strong>';
48 -
4949 if ( $row['note'] ) {
5050 $name .= '<br />' . htmlspecialchars( $row['note'] );
5151 }
5252
5353 $amount = $this->formatAmount( $row );
 54+ $date = $this->formatDate( $row );
5455
5556 $class = '';
5657 if ( $alt ) {
5758 $class = ' alt';
5859 }
5960
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+ $output .= "<tr>";
 62+ $output .= "<td class=\"left $class\">$name</td>";
 63+ $output .= "<td class=\"left $class\" style=\"width: 100px;\">$date</td>";
 64+ $output .= "<td class=\"right $class\" style=\"width: 75px;\">$amount</td>";
 65+ $output .= "</tr>";
6166
6267 $alt = !$alt;
6368 }
@@ -66,12 +71,31 @@
6772 header( 'Cache-Control: max-age=300,s-maxage=300' );
6873 $wgOut->addWikiText( '{{Template:Donate-header/' . $language . '}}' );
6974 $wgOut->addWikiText( '<skin>Tomas</skin>' );
70 - $wgOut->addHTML( '<h1>Real-time donor comments from around the world</h1>' );
 75+ $wgOut->addHTML( '<h1>' . $this->msg( 'contrib-hist-header' ) . '</h1>' );
7176 $wgOut->addWikiText( '<strong>{{Template:Contribution history introduction/' . $language . '}}</strong>' );
7277 $wgOut->addHTML( $output );
7378 $wgOut->addWikiText( '{{Template:Donate-footer/' . $language . '}}' );
7479 }
 80+
 81+ function msg( $key ) {
 82+ return wfMsgExt( $key, array( 'escape', 'lang' => $this->lang ) );
 83+ }
 84+
 85+ function formatName( $row ) {
 86+ $name = htmlspecialchars( $row['name'] );
 87+ if ( !$name ) {
 88+ $name = $this->msg( 'contrib-hist-anonymous' );
 89+ }
7590
 91+ $name = '<strong>' . $name . '</strong>';
 92+ return $name;
 93+ }
 94+
 95+ function formatDate( $row ) {
 96+ $ts = wfTimestamp( TS_MW, $row['received'] );
 97+ return $this->lang->timeanddate( $ts );
 98+ }
 99+
76100 function formatAmount( $row ) {
77101 if ( $row['original_currency'] ) {
78102 $currency = $row['original_currency'];
Index: trunk/extensions/ContributionReporting/ContributionReporting.i18n.php
@@ -14,4 +14,12 @@
1515 $messages['en'] = array(
1616 'contributiontotal' => 'Contribution total',
1717 'contributionhistory' => 'Contribution history',
 18+
 19+ 'contrib-hist-header' => 'Real-time donor comments from around the world',
 20+
 21+ 'contrib-hist-name' => 'Name',
 22+ 'contrib-hist-date' => 'Time and date',
 23+ 'contrib-hist-amount' => 'Amount',
 24+
 25+ 'contrib-hist-anonymous' => 'Anonymous',
1826 );

Status & tagging log