Index: trunk/extensions/EducationProgram/specials/SpecialStudentActivity.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | * @since 0.1 |
21 | 21 | */ |
22 | 22 | public function __construct() { |
23 | | - $this->cacheExpiry = 60; |
| 23 | + $this->cacheExpiry = 180; |
24 | 24 | parent::__construct( 'StudentActivity' ); |
25 | 25 | } |
26 | 26 | |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | $pager = new EPStudentActivityPager( $this->getContext(), $conds ); |
74 | 74 | |
75 | 75 | if ( $pager->getNumRows() ) { |
76 | | - return |
| 76 | + $html = |
77 | 77 | $pager->getFilterControl() . |
78 | 78 | $pager->getNavigationBar() . |
79 | 79 | $pager->getBody() . |
— | — | @@ -80,10 +80,12 @@ |
81 | 81 | $pager->getMultipleItemControl(); |
82 | 82 | } |
83 | 83 | else { |
84 | | - return $pager->getFilterControl( true ) |
| 84 | + $html = $pager->getFilterControl( true ) |
85 | 85 | . '<br />' |
86 | 86 | . wfMsgExt( 'ep-studentactivity-noresults', 'parseinline' ); |
87 | 87 | } |
| 88 | + |
| 89 | + return '<div class="studentactivity">' . $html . '</div>'; |
88 | 90 | } |
89 | 91 | |
90 | 92 | /** |
Index: trunk/extensions/EducationProgram/specials/SpecialCachedPage.php |
— | — | @@ -96,13 +96,12 @@ |
97 | 97 | if ( $this->cacheExpiry < 1000000000 ) { |
98 | 98 | $message = $this->msg( |
99 | 99 | 'cachedspecial-viewing-cached-ttl', |
100 | | - $this->getDurationText() |
| 100 | + $this->getDurationText( $this->cacheExpiry ) |
101 | 101 | )->escaped(); |
102 | 102 | } |
103 | 103 | else { |
104 | 104 | $message = $this->msg( |
105 | | - 'cachedspecial-viewing-cached-ts', |
106 | | - $this->getDurationText() |
| 105 | + 'cachedspecial-viewing-cached-ts' |
107 | 106 | )->escaped(); |
108 | 107 | } |
109 | 108 | |
— | — | @@ -114,10 +113,37 @@ |
115 | 114 | * |
116 | 115 | * @since 0.1 |
117 | 116 | * |
| 117 | + * @param integer $seconds |
| 118 | + * @param array $chosenIntervals |
| 119 | + * |
118 | 120 | * @return string |
119 | 121 | */ |
120 | | - protected function getDurationText() { |
121 | | - return '5 minutes'; // TODO: generate and i18n |
| 122 | + protected function getDurationText( $seconds, array $chosenIntervals = array( 'years', 'days', 'hours', 'minutes', 'seconds' ) ) { |
| 123 | + $intervals = array( |
| 124 | + 'years' => 31557600, // 86400 * 365.25 |
| 125 | + 'weeks' => 604800, |
| 126 | + 'days' => 86400, |
| 127 | + 'hours' => 3600, |
| 128 | + 'minutes' => 60, |
| 129 | + 'seconds' => 1, |
| 130 | + ); |
| 131 | + |
| 132 | + if ( !empty( $chosenIntervals ) ) { |
| 133 | + $intervals = array_intersect_key( $intervals, array_flip( $chosenIntervals ) ); |
| 134 | + } |
| 135 | + |
| 136 | + $segments = array(); |
| 137 | + |
| 138 | + foreach ( $intervals as $name => $length ) { |
| 139 | + $value = floor( $seconds / $length ); |
| 140 | + |
| 141 | + if ( $value > 0 || ( $name == 'seconds' && empty( $segments ) ) ) { |
| 142 | + $seconds -= $value * $length; |
| 143 | + $segments[] = wfMsgExt( 'duration-' . $name, 'parsemag', $value ); |
| 144 | + } |
| 145 | + } |
| 146 | + |
| 147 | + return $this->getLanguage()->listToText( $segments ); |
122 | 148 | } |
123 | 149 | |
124 | 150 | /** |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -786,6 +786,15 @@ |
787 | 787 | 'cachedspecial-viewing-cached-ttl' => 'You are viewing a cached version of this page, which can be up to $1 old.', |
788 | 788 | 'cachedspecial-viewing-cached-ts' => 'You are viewing a cached version of this page, which might not be completely actual.', |
789 | 789 | 'cachedspecial-refresh-now' => 'View latest.', |
| 790 | + |
| 791 | + // Durations |
| 792 | + 'duration-seconds' => '$1 {{PLURAL:$1|second|seconds}}', |
| 793 | + 'duration-minutes' => '$1 {{PLURAL:$1|minute|minutes}}', |
| 794 | + 'duration-hours' => '$1 {{PLURAL:$1|hour|hours}}', |
| 795 | + 'duration-days' => '$1 {{PLURAL:$1|day|days}}', |
| 796 | + 'duration-weeks' => '$1 {{PLURAL:$1|week|weeks}}', |
| 797 | + 'duration-years' => '$1 {{PLURAL:$1|year|years}}', |
| 798 | + 'duration-centuries' => '$1 {{PLURAL:$1|century|centuries}}', |
790 | 799 | ); |
791 | 800 | |
792 | 801 | /** Message documentation (Message documentation) |
Index: trunk/extensions/EducationProgram/resources/ep.studentactivity.css |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * @author Jeroen De Dauw <jeroendedauw at gmail dot com> |
8 | 8 | */ |
9 | 9 | |
10 | | -img.studentometer, table.ep-studentactivity { |
| 10 | +img.studentometer, table.ep-studentactivity, div.studentactivity { |
11 | 11 | margin-left: auto; |
12 | 12 | margin-right: auto; |
13 | 13 | } |
— | — | @@ -14,3 +14,7 @@ |
15 | 15 | img.studentometer { |
16 | 16 | display: block; |
17 | 17 | } |
| 18 | + |
| 19 | +div.studentactivity { |
| 20 | + text-align: center; |
| 21 | +} |
\ No newline at end of file |