r95295 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95294‎ | r95295 | r95296 >
Date:01:24, 23 August 2011
Author:kaldari
Status:ok
Tags:
Comment:
follow-up to r94677, functionalizing date range creation
Modified paths:
  • /trunk/extensions/CentralNotice/special/SpecialCentralNotice.php (modified) (history)
  • /trunk/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CentralNotice/special/SpecialCentralNotice.php
@@ -242,9 +242,7 @@
243243
244244 public static function dateSelector( $prefix, $editable, $timestamp = null ) {
245245 if ( $editable ) {
246 - $years = range( 2010, 2016 );
247 - $months = CentralNotice::paddedRange( 1, 12 );
248 - $days = CentralNotice::paddedRange( 1, 31 );
 246+ $dateRanges = CentralNotice::getDateRanges();
249247
250248 // Normalize timestamp format. If no timestamp is passed, default to now. If -1 is
251249 // passed, set no defaults.
@@ -255,9 +253,9 @@
256254 }
257255
258256 $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 ) ),
262260 );
263261
264262 return CentralNotice::createSelector( $prefix, $fields );
@@ -266,6 +264,18 @@
267265 return $wgLang->date( $timestamp );
268266 }
269267 }
 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+ }
270280
271281 public static function timeSelector( $prefix, $editable, $timestamp = null ) {
272282 if ( $editable ) {
Index: trunk/extensions/CentralNotice/special/SpecialCentralNoticeLogs.php
@@ -201,14 +201,12 @@
202202 }
203203
204204 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();
208206
209207 $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 ),
213211 );
214212
215213 $out = '';

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r94677more work on campaign log filteringkaldari19:17, 16 August 2011

Status & tagging log