Index: trunk/extensions/CentralNotice/special/SpecialCentralNotice.php |
— | — | @@ -242,9 +242,7 @@ |
243 | 243 | |
244 | 244 | public static function dateSelector( $prefix, $editable, $timestamp = null ) { |
245 | 245 | if ( $editable ) { |
246 | | - $years = range( 2010, 2016 ); |
247 | | - $months = CentralNotice::paddedRange( 1, 12 ); |
248 | | - $days = CentralNotice::paddedRange( 1, 31 ); |
| 246 | + $dateRanges = CentralNotice::getDateRanges(); |
249 | 247 | |
250 | 248 | // Normalize timestamp format. If no timestamp is passed, default to now. If -1 is |
251 | 249 | // passed, set no defaults. |
— | — | @@ -255,9 +253,9 @@ |
256 | 254 | } |
257 | 255 | |
258 | 256 | $fields = array( |
259 | | - array( "month", "centralnotice-month", $months, substr( $ts, 4, 2 ) ), |
260 | | - array( "day", "centralnotice-day", $days, substr( $ts, 6, 2 ) ), |
261 | | - array( "year", "centralnotice-year", $years, substr( $ts, 0, 4 ) ), |
| 257 | + array( "month", "centralnotice-month", $dateRanges['months'], substr( $ts, 4, 2 ) ), |
| 258 | + array( "day", "centralnotice-day", $dateRanges['days'], substr( $ts, 6, 2 ) ), |
| 259 | + array( "year", "centralnotice-year", $dateRanges['years'], substr( $ts, 0, 4 ) ), |
262 | 260 | ); |
263 | 261 | |
264 | 262 | return CentralNotice::createSelector( $prefix, $fields ); |
— | — | @@ -266,6 +264,18 @@ |
267 | 265 | return $wgLang->date( $timestamp ); |
268 | 266 | } |
269 | 267 | } |
| 268 | + |
| 269 | + /* |
| 270 | + * Get date ranges for use in date selectors |
| 271 | + * @return array of ranges for months, days, and years (padded with zeros) |
| 272 | + */ |
| 273 | + public static function getDateRanges() { |
| 274 | + $dateRanges = array(); |
| 275 | + $dateRanges['years'] = range( 2011, date("Y") ); |
| 276 | + $dateRanges['months'] = CentralNotice::paddedRange( 1, 12 ); |
| 277 | + $dateRanges['days'] = CentralNotice::paddedRange( 1, 31 ); |
| 278 | + return $dateRanges; |
| 279 | + } |
270 | 280 | |
271 | 281 | public static function timeSelector( $prefix, $editable, $timestamp = null ) { |
272 | 282 | if ( $editable ) { |
Index: trunk/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php |
— | — | @@ -201,14 +201,12 @@ |
202 | 202 | } |
203 | 203 | |
204 | 204 | private function dateSelector( $prefix, $year = 0, $month = 0, $day = 0 ) { |
205 | | - $years = range( 2011, date("Y") ); |
206 | | - $months = CentralNotice::paddedRange( 1, 12 ); |
207 | | - $days = CentralNotice::paddedRange( 1, 31 ); |
| 205 | + $dateRanges = CentralNotice::getDateRanges(); |
208 | 206 | |
209 | 207 | $fields = array( |
210 | | - array( $prefix."_month", "centralnotice-month", $months, $month ), |
211 | | - array( $prefix."_day", "centralnotice-day", $days, $day ), |
212 | | - array( $prefix."_year", "centralnotice-year", $years, $year ), |
| 208 | + array( $prefix."_month", "centralnotice-month", $dateRanges['months'], $month ), |
| 209 | + array( $prefix."_day", "centralnotice-day", $dateRanges['days'], $day ), |
| 210 | + array( $prefix."_year", "centralnotice-year", $dateRanges['years'], $year ), |
213 | 211 | ); |
214 | 212 | |
215 | 213 | $out = ''; |