Index: trunk/extensions/LastModified/LastModified.i18n.php |
— | — | @@ -28,7 +28,15 @@ |
29 | 29 | */ |
30 | 30 | $messages['en'] = array( |
31 | 31 | 'lastmodified-desc' => 'Generates last modified times for articles', |
32 | | - 'lastmodified' => 'LastModified', |
| 32 | + 'lastmodified' => 'Last Modified', |
| 33 | + 'lastmodified-label-seconds' => 'seconds', |
| 34 | + 'lastmodified-label-minutes' => 'minutes', |
| 35 | + 'lastmodified-label-hours' => 'hours', |
| 36 | + 'lastmodified-label-days' => 'days', |
| 37 | + 'lastmodified-label-months' => 'months', |
| 38 | + 'lastmodified-label-years' => 'years', |
| 39 | + 'lastmodified-options' => 'Options', |
| 40 | + 'lastmodified-display-range-value' => 'Display range value:', |
33 | 41 | 'lastmodified-seconds' => 'Last updated $1 seconds ago', |
34 | 42 | 'lastmodified-minutes' => 'Last updated $1 minutes ago', |
35 | 43 | 'lastmodified-hours' => 'Last updated $1 hours ago', |
Index: trunk/extensions/LastModified/modules/lastmodified.js |
— | — | @@ -112,7 +112,7 @@ |
113 | 113 | * @param integer displayRange The maximum unit of time to display for last updated |
114 | 114 | * |
115 | 115 | * displayRange |
116 | | - * - 0: default - display: years, months, days, hours, minutes, seconds |
| 116 | + * - 0: years - display: years, months, days, hours, minutes, seconds |
117 | 117 | * - 1: months - display: months, days, hours, minutes, seconds |
118 | 118 | * - 2: days - display: days, hours, minutes, seconds |
119 | 119 | * - 3: hours - display: hours, minutes, seconds |
— | — | @@ -136,37 +136,44 @@ |
137 | 137 | else if ( modifiedDifference < 3600 ) { |
138 | 138 | |
139 | 139 | // minutes |
140 | | - lastEdit = parseInt( modifiedDifference / 60 ); |
141 | | - message = ( mw.msg( 'lastmodified-minutes', myLastEdit ) ); |
| 140 | + if ( displayRange <= 4 ) { |
| 141 | + lastEdit = parseInt( modifiedDifference / 60 ); |
| 142 | + message = ( mw.msg( 'lastmodified-minutes', myLastEdit ) ); |
| 143 | + } |
142 | 144 | |
143 | 145 | } |
144 | 146 | else if ( modifiedDifference < 86400 ) { |
145 | 147 | |
146 | 148 | // hours |
147 | | - myLastEdit = parseInt( modifiedDifference / 3600 ); |
148 | | - message = ( mw.msg( 'lastmodified-hours', myLastEdit ) ); |
149 | | - |
| 149 | + if ( displayRange <= 3) { |
| 150 | + myLastEdit = parseInt( modifiedDifference / 3600 ); |
| 151 | + message = ( mw.msg( 'lastmodified-hours', myLastEdit ) ); |
| 152 | + } |
150 | 153 | } |
151 | 154 | else if ( modifiedDifference < 2592000 ) { |
152 | 155 | |
153 | 156 | // days |
154 | | - myLastEdit = parseInt( modifiedDifference / 86400 ); |
155 | | - message = ( mw.msg( 'lastmodified-days', myLastEdit ) ); |
| 157 | + if ( displayRange <= 2) { |
| 158 | + myLastEdit = parseInt( modifiedDifference / 86400 ); |
| 159 | + message = ( mw.msg( 'lastmodified-days', myLastEdit ) ); |
| 160 | + } |
156 | 161 | |
157 | 162 | } |
158 | 163 | else if ( modifiedDifference < 31536000 ) { |
159 | 164 | |
160 | 165 | // months |
161 | | - myLastEdit = parseInt( modifiedDifference / 2592000 ); |
162 | | - message = ( mw.msg( 'lastmodified-months', myLastEdit ) ); |
163 | | - |
| 166 | + if ( displayRange <= 1) { |
| 167 | + myLastEdit = parseInt( modifiedDifference / 2592000 ); |
| 168 | + message = ( mw.msg( 'lastmodified-months', myLastEdit ) ); |
| 169 | + } |
164 | 170 | } |
165 | 171 | else { |
166 | 172 | |
167 | 173 | // years |
168 | | - myLastEdit = parseInt( modifiedDifference / 31536000 ); |
169 | | - message = ( mw.msg( 'lastmodified-years', myLastEdit ) ); |
170 | | - |
| 174 | + if ( displayRange == 0) { |
| 175 | + myLastEdit = parseInt( modifiedDifference / 31536000 ); |
| 176 | + message = ( mw.msg( 'lastmodified-years', myLastEdit ) ); |
| 177 | + } |
171 | 178 | } |
172 | 179 | |
173 | 180 | return message; |
Index: trunk/extensions/LastModified/LastModified.php |
— | — | @@ -38,8 +38,10 @@ |
39 | 39 | |
40 | 40 | $dir = dirname( __FILE__ ) . '/'; |
41 | 41 | |
| 42 | +$wgAutoloadClasses['SpecialLastModified'] = $dir . 'SpecialLastModified.php'; |
42 | 43 | $wgExtensionMessagesFiles['LastModified'] = $dir . 'LastModified.i18n.php'; |
43 | 44 | $wgExtensionAliasesFiles['LastModified'] = $dir . 'LastModified.alias.php'; |
| 45 | +$wgSpecialPages['LastModified'] = 'SpecialLastModified'; |
44 | 46 | |
45 | 47 | /** |
46 | 48 | * ADDITIONAL MAGICAL GLOBALS |
Index: trunk/extensions/LastModified/SpecialLastModified.php |
— | — | @@ -0,0 +1,84 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Wikimedia Foundation |
| 5 | + * |
| 6 | + * LICENSE |
| 7 | + * |
| 8 | + * This program is free software; you can redistribute it and/or modify |
| 9 | + * it under the terms of the GNU General Public License as published by |
| 10 | + * the Free Software Foundation; either version 2 of the License, or |
| 11 | + * (at your option) any later version. |
| 12 | + * |
| 13 | + * This program is distributed in the hope that it will be useful, |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | + * GNU General Public License for more details. |
| 17 | + * |
| 18 | + * @author Katie Horn <khorn@wikimedia.org>, Jeremy Postlethwaite <jpostlethwaite@wikimedia.org> |
| 19 | + */ |
| 20 | + |
| 21 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 22 | + echo "LastModified extension\n"; |
| 23 | + exit( 1 ); |
| 24 | +} |
| 25 | + |
| 26 | +/** |
| 27 | + * Show LastModified options |
| 28 | + */ |
| 29 | +class SpecialLastModified extends SpecialPage { |
| 30 | + |
| 31 | + public function __construct() { |
| 32 | + // Register special page |
| 33 | + parent::__construct( 'LastModified' ); |
| 34 | + } |
| 35 | + |
| 36 | + public function execute( $sub ) { |
| 37 | + |
| 38 | + global $wgLastModifiedRange; |
| 39 | + |
| 40 | + $this->setHeaders(); |
| 41 | + $this->outputHeader(); |
| 42 | + |
| 43 | + $out = $this->getOutput(); |
| 44 | + |
| 45 | + $out->addHTML( Xml::openElement( 'h2' ) ); |
| 46 | + $out->addHTML( wfMsg( 'lastmodified-options' ) ); |
| 47 | + $out->addHTML( Xml::closeElement( 'h2' ) ); |
| 48 | + |
| 49 | + $out->addHTML( Xml::openElement( 'p' ) ); |
| 50 | + $out->addHTML( wfMsg( 'lastmodified-display-range-value' ) . ' ' . $wgLastModifiedRange ); |
| 51 | + $out->addHTML( Xml::closeElement( 'p' ) ); |
| 52 | + |
| 53 | + $rangeMessage = '<p>Display: '; |
| 54 | + $rangeMessageDatetime = ''; |
| 55 | + |
| 56 | + $displayRange = array( |
| 57 | + 0 => 'years', |
| 58 | + 1 => 'months', |
| 59 | + 2 => 'days', |
| 60 | + 3 => 'hours', |
| 61 | + 4 => 'minutes', |
| 62 | + 5 => 'seconds', |
| 63 | + ); |
| 64 | + |
| 65 | + // Display seconds |
| 66 | + |
| 67 | + foreach ( $displayRange as $key => $value ) { |
| 68 | + |
| 69 | + // Check to see which values to display. |
| 70 | + if ( $wgLastModifiedRange == 0 || $key >= $wgLastModifiedRange ) { |
| 71 | + |
| 72 | + // append a comma if necessary |
| 73 | + $rangeMessageDatetime .= empty($rangeMessageDatetime) ? '' : ', '; |
| 74 | + |
| 75 | + // append message |
| 76 | + $rangeMessageDatetime .= wfMsg( 'lastmodified-label-' . $value ); |
| 77 | + } |
| 78 | + } |
| 79 | + |
| 80 | + $rangeMessage .= $rangeMessageDatetime; |
| 81 | + $rangeMessage .= '</p>'; |
| 82 | + |
| 83 | + $out->addHTML( $rangeMessage ); |
| 84 | + } |
| 85 | +} |
Property changes on: trunk/extensions/LastModified/SpecialLastModified.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 86 | + native |
Added: svn:mime-type |
2 | 87 | + text/plain |
Added: svn:keywords |
3 | 88 | + Author Date HeadURL Header Id Revision |