r114288 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114287‎ | r114288 | r114289 >
Date:17:54, 20 March 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Follow up to r114026; fix plural stuff and add in var for the duration
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPUtils.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialStudentActivity.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialStudentActivity.php
@@ -50,14 +50,16 @@
5151 *
5252 * @return string
5353 */
54 - protected function displayCachedContent() {
 54+ public function displayCachedContent() {
 55+ $duration = EPSettings::get( 'recentActivityLimit' );
 56+
5557 $conds = array( 'last_active > ' . wfGetDB( DB_SLAVE )->addQuotes(
56 - wfTimestamp( TS_MW, time() - ( EPSettings::get( 'recentActivityLimit' ) ) )
 58+ wfTimestamp( TS_MW, time() - $duration )
5759 ) );
5860
59 - return $this->displayStudentMeter( $conds ) .
 61+ return $this->displayStudentMeter( $conds, $duration ) .
6062 '<br />' .
61 - $this->displayPager( $conds );
 63+ $this->displayPager( $conds, $duration );
6264 }
6365
6466 /**
@@ -69,7 +71,7 @@
7072 *
7173 * @return string
7274 */
73 - public function displayPager( array $conds ) {
 75+ public function displayPager( array $conds, $duration ) {
7476 $pager = new EPStudentActivityPager( $this->getContext(), $conds );
7577
7678 if ( $pager->getNumRows() ) {
@@ -83,7 +85,7 @@
8486 else {
8587 $html = $pager->getFilterControl( true )
8688 . '<br />'
87 - . wfMsgExt( 'ep-studentactivity-noresults', 'parseinline' );
 89+ . wfMsgExt( 'ep-studentactivity-noresults', 'parseinline', EPUtils::formatDuration( $duration, array( 'hours' ) ) );
8890 }
8991
9092 return '<div class="studentactivity">' . $html . '</div>';
@@ -95,10 +97,11 @@
9698 * @since 0.1
9799 *
98100 * @param array $conds
 101+ * @param integer $duration
99102 *
100103 * @return string
101104 */
102 - public function displayStudentMeter( array $conds ) {
 105+ public function displayStudentMeter( array $conds, $duration ) {
103106 $studentCount = EPStudents::singleton()->count( $conds );
104107
105108 if ( $studentCount < 10 ) {
@@ -108,7 +111,7 @@
109112 $image = min( round( $studentCount / 10 ) * 10, 60 );
110113 }
111114
112 - $message = $this->msg( 'ep-studentactivity-count', $studentCount )->escaped();
 115+ $message = $this->msg( 'ep-studentactivity-count', $studentCount, EPUtils::formatDuration( $duration, array( 'hours' ) ) )->escaped();
113116
114117 return Html::element( 'img', array(
115118 'src' => EPSettings::get( 'imageDir' ) . 'student-o-meter_morethan-' . $image . '.png',
Index: trunk/extensions/EducationProgram/includes/EPUtils.php
@@ -270,4 +270,9 @@
271271 return $article->fetchContent();
272272 }
273273
 274+ public static function formatDuration( $seconds, $units = array( 'days', 'hours', 'minutes', 'seconds' ) ) {
 275+ // TODO: compat
 276+ return $GLOBALS['wgLang']->formatDuration( $seconds, $units );
 277+ }
 278+
274279 }
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -776,10 +776,10 @@
777777 'epca-visible' => 'Publicly list me as Campus Ambassador',
778778
779779 // Special:StudentActivity
780 - 'ep-studentactivity-noresults' => 'There are no students that where active in the last 24 hours :(
 780+ 'ep-studentactivity-noresults' => 'There are no students that where active in the last $1 :(
781781
782782 You can find a full list of students on [[Special:Students|the student list]].',
783 - 'ep-studentactivity-count' => 'There {{PLURAL:$1|is|are}} currently $1 {{PLURAL:$1|student|students}} that {{PLURAL:$1|was|where}} active in the last 24 hours.',
 783+ 'ep-studentactivity-count' => '{{PLURAL:$1|One student was|$1 students were}} active in the last $2.',
784784
785785 // Cached special page, back compat for MW < 1.20
786786 'cachedspecial-viewing-cached-ttl' => 'You are viewing a cached version of this page, which can be up to $1 old.',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r114026follow up r114023 add missing pluraljeroendedauw17:58, 16 March 2012

Status & tagging log