https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114063
Revision: 114063
Author: jeroendedauw
Date: 2012-03-17 20:39:23 +0000 (Sat, 17 Mar 2012)
Log Message:
-----------
work on i18n of duration stuff
Modified Paths:
--------------
trunk/extensions/EducationProgram/EducationProgram.i18n.php
trunk/extensions/EducationProgram/resources/ep.studentactivity.css
trunk/extensions/EducationProgram/specials/SpecialCachedPage.php
trunk/extensions/EducationProgram/specials/SpecialStudentActivity.php
Modified: trunk/extensions/EducationProgram/EducationProgram.i18n.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-03-17
20:37:54 UTC (rev 114062)
+++ trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-03-17
20:39:23 UTC (rev 114063)
@@ -786,6 +786,15 @@
'cachedspecial-viewing-cached-ttl' => 'You are viewing a cached version
of this page, which can be up to $1 old.',
'cachedspecial-viewing-cached-ts' => 'You are viewing a cached version
of this page, which might not be completely actual.',
'cachedspecial-refresh-now' => 'View latest.',
+
+ // Durations
+ 'duration-seconds' => '$1 {{PLURAL:$1|second|seconds}}',
+ 'duration-minutes' => '$1 {{PLURAL:$1|minute|minutes}}',
+ 'duration-hours' => '$1 {{PLURAL:$1|hour|hours}}',
+ 'duration-days' => '$1 {{PLURAL:$1|day|days}}',
+ 'duration-weeks' => '$1 {{PLURAL:$1|week|weeks}}',
+ 'duration-years' => '$1 {{PLURAL:$1|year|years}}',
+ 'duration-centuries' => '$1 {{PLURAL:$1|century|centuries}}',
);
/** Message documentation (Message documentation)
Modified: trunk/extensions/EducationProgram/resources/ep.studentactivity.css
===================================================================
--- trunk/extensions/EducationProgram/resources/ep.studentactivity.css
2012-03-17 20:37:54 UTC (rev 114062)
+++ trunk/extensions/EducationProgram/resources/ep.studentactivity.css
2012-03-17 20:39:23 UTC (rev 114063)
@@ -6,7 +6,7 @@
* @author Jeroen De Dauw <jeroendedauw at gmail dot com>
*/
-img.studentometer, table.ep-studentactivity {
+img.studentometer, table.ep-studentactivity, div.studentactivity {
margin-left: auto;
margin-right: auto;
}
@@ -14,3 +14,7 @@
img.studentometer {
display: block;
}
+
+div.studentactivity {
+ text-align: center;
+}
\ No newline at end of file
Modified: trunk/extensions/EducationProgram/specials/SpecialCachedPage.php
===================================================================
--- trunk/extensions/EducationProgram/specials/SpecialCachedPage.php
2012-03-17 20:37:54 UTC (rev 114062)
+++ trunk/extensions/EducationProgram/specials/SpecialCachedPage.php
2012-03-17 20:39:23 UTC (rev 114063)
@@ -96,13 +96,12 @@
if ( $this->cacheExpiry < 1000000000 ) {
$message = $this->msg(
'cachedspecial-viewing-cached-ttl',
- $this->getDurationText()
+ $this->getDurationText( $this->cacheExpiry )
)->escaped();
}
else {
$message = $this->msg(
- 'cachedspecial-viewing-cached-ts',
- $this->getDurationText()
+ 'cachedspecial-viewing-cached-ts'
)->escaped();
}
@@ -114,10 +113,37 @@
*
* @since 0.1
*
+ * @param integer $seconds
+ * @param array $chosenIntervals
+ *
* @return string
*/
- protected function getDurationText() {
- return '5 minutes'; // TODO: generate and i18n
+ protected function getDurationText( $seconds, array $chosenIntervals =
array( 'years', 'days', 'hours', 'minutes', 'seconds' ) ) {
+ $intervals = array(
+ 'years' => 31557600, // 86400 * 365.25
+ 'weeks' => 604800,
+ 'days' => 86400,
+ 'hours' => 3600,
+ 'minutes' => 60,
+ 'seconds' => 1,
+ );
+
+ if ( !empty( $chosenIntervals ) ) {
+ $intervals = array_intersect_key( $intervals,
array_flip( $chosenIntervals ) );
+ }
+
+ $segments = array();
+
+ foreach ( $intervals as $name => $length ) {
+ $value = floor( $seconds / $length );
+
+ if ( $value > 0 || ( $name == 'seconds' && empty(
$segments ) ) ) {
+ $seconds -= $value * $length;
+ $segments[] = wfMsgExt( 'duration-' . $name,
'parsemag', $value );
+ }
+ }
+
+ return $this->getLanguage()->listToText( $segments );
}
/**
Modified: trunk/extensions/EducationProgram/specials/SpecialStudentActivity.php
===================================================================
--- trunk/extensions/EducationProgram/specials/SpecialStudentActivity.php
2012-03-17 20:37:54 UTC (rev 114062)
+++ trunk/extensions/EducationProgram/specials/SpecialStudentActivity.php
2012-03-17 20:39:23 UTC (rev 114063)
@@ -19,7 +19,7 @@
* @since 0.1
*/
public function __construct() {
- $this->cacheExpiry = 60;
+ $this->cacheExpiry = 180;
parent::__construct( 'StudentActivity' );
}
@@ -72,7 +72,7 @@
$pager = new EPStudentActivityPager( $this->getContext(),
$conds );
if ( $pager->getNumRows() ) {
- return
+ $html =
$pager->getFilterControl() .
$pager->getNavigationBar() .
$pager->getBody() .
@@ -80,10 +80,12 @@
$pager->getMultipleItemControl();
}
else {
- return $pager->getFilterControl( true )
+ $html = $pager->getFilterControl( true )
. '<br />'
. wfMsgExt( 'ep-studentactivity-noresults',
'parseinline' );
}
+
+ return '<div class="studentactivity">' . $html . '</div>';
}
/**
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs