Index: trunk/phase3/includes/XmlFunctions.php |
— | — | @@ -18,6 +18,9 @@ |
19 | 19 | function HTMLnamespaceselector($selected = '', $allnamespaces = null, $includehidden=false) { |
20 | 20 | return Xml::namespaceSelector( $selected, $allnamespaces, $includehidden ); |
21 | 21 | } |
| 22 | +function HTMLmonthelector($selected = '', $allmonths = null) { |
| 23 | + return Xml::monthSelector( $selected, $allmonths ); |
| 24 | +} |
22 | 25 | function wfSpan( $text, $class, $attribs=array() ) { |
23 | 26 | return Xml::span( $text, $class, $attribs ); |
24 | 27 | } |
Index: trunk/phase3/includes/Xml.php |
— | — | @@ -123,6 +123,28 @@ |
124 | 124 | $s .= "</select>\n"; |
125 | 125 | return $s; |
126 | 126 | } |
| 127 | + |
| 128 | + /** |
| 129 | + * Create a date selector |
| 130 | + * |
| 131 | + * @param $selected Mixed: the month which should be selected, default '' |
| 132 | + * @param $allmonths String: value of a special item denoting all month. Null to not include (default) |
| 133 | + * @param string $id Element identifier |
| 134 | + * @return String: Html string containing the month selector |
| 135 | + */ |
| 136 | + public static function monthSelector( $selected = '', $allmonths = null, $id = 'month' ) { |
| 137 | + global $wgLang; |
| 138 | + $options = array(); |
| 139 | + if( is_null( $selected ) ) |
| 140 | + $selected = ''; |
| 141 | + if( !is_null( $allmonths ) ) |
| 142 | + $options[] = self::option( wfMsg( 'monthsall' ), $allmonths, $selected === $allmonths ); |
| 143 | + for( $i = 1; $i < 13; $i++ ) |
| 144 | + $options[] = self::option( $wgLang->getMonthName( $i ), $i, $selected === $i ); |
| 145 | + return self::openElement( 'select', array( 'id' => $id, 'name' => 'month' ) ) |
| 146 | + . implode( "\n", $options ) |
| 147 | + . self::closeElement( 'select' ); |
| 148 | + } |
127 | 149 | |
128 | 150 | /** |
129 | 151 | * |
Index: trunk/phase3/includes/SpecialContributions.php |
— | — | @@ -9,13 +9,21 @@ |
10 | 10 | var $messages, $target; |
11 | 11 | var $namespace = '', $mDb; |
12 | 12 | |
13 | | - function __construct( $target, $namespace = false ) { |
| 13 | + function __construct( $target, $namespace = false, $year = false, $month = false ) { |
14 | 14 | parent::__construct(); |
15 | 15 | foreach( explode( ' ', 'uctop diff newarticle rollbacklink diff hist minoreditletter' ) as $msg ) { |
16 | 16 | $this->messages[$msg] = wfMsgExt( $msg, array( 'escape') ); |
17 | 17 | } |
18 | 18 | $this->target = $target; |
19 | 19 | $this->namespace = $namespace; |
| 20 | + |
| 21 | + $year = intval($year); |
| 22 | + $month = intval($month); |
| 23 | + |
| 24 | + $this->year = ($year > 0 && $year < 10000) ? $year : false; |
| 25 | + $this->month = ($month > 0 && $month < 13) ? $month : false; |
| 26 | + $this->GetDateCond(); |
| 27 | + |
20 | 28 | $this->mDb = wfGetDB( DB_SLAVE, 'contributions' ); |
21 | 29 | } |
22 | 30 | |
— | — | @@ -63,6 +71,28 @@ |
64 | 72 | } |
65 | 73 | } |
66 | 74 | |
| 75 | + function getDateCond() { |
| 76 | + if ( $this->year || $this->month ) { |
| 77 | + // Assume this year if only a month is given |
| 78 | + if ( $this->year ) { |
| 79 | + $year_start = $this->year; |
| 80 | + } else { |
| 81 | + $year_start = substr( wfTimestampNow(), 0, 4 ); |
| 82 | + } |
| 83 | + |
| 84 | + if ( $this->month ) { |
| 85 | + $month_end = str_pad($this->month + 1, 2, '0', STR_PAD_LEFT); |
| 86 | + $year_end = $year_start; |
| 87 | + } else { |
| 88 | + $month_end = 0; |
| 89 | + $year_end = $year_start + 1; |
| 90 | + } |
| 91 | + $ts_end = str_pad($year_end . $month_end, 14, '0' ); |
| 92 | + |
| 93 | + $this->mOffset = $ts_end; |
| 94 | + } |
| 95 | + } |
| 96 | + |
67 | 97 | function getIndexField() { |
68 | 98 | return 'rev_timestamp'; |
69 | 99 | } |
— | — | @@ -234,11 +264,33 @@ |
235 | 265 | $options['bot'] = '1'; |
236 | 266 | } |
237 | 267 | |
| 268 | + $skip = $wgRequest->getText( 'offset' ) || $wgRequest->getText( 'dir' ) == 'prev'; |
| 269 | + # Offset overrides year/month selection |
| 270 | + if ( ( $month = $wgRequest->getIntOrNull( 'month' ) ) !== null && $month !== -1 ) { |
| 271 | + $options['month'] = intval( $month ); |
| 272 | + } else { |
| 273 | + $options['month'] = ''; |
| 274 | + } |
| 275 | + if ( ( $year = $wgRequest->getIntOrNull( 'year' ) ) !== null ) { |
| 276 | + $options['year'] = intval( $year ); |
| 277 | + } else if( $options['month'] ) { |
| 278 | + $options['year'] = intval( substr( wfTimestampNow(), 0, 4 ) ); |
| 279 | + } else { |
| 280 | + $options['year'] = ''; |
| 281 | + } |
| 282 | + |
238 | 283 | wfRunHooks( 'SpecialContributionsBeforeMainOutput', $id ); |
239 | 284 | |
240 | 285 | $wgOut->addHTML( contributionsForm( $options ) ); |
| 286 | + # Show original selected options, don't apply them so as to allow paging |
| 287 | + $_GET['year'] = ''; // hack for Pager |
| 288 | + $_GET['month'] = ''; // hack for Pager |
| 289 | + if( $skip ) { |
| 290 | + $options['year'] = ''; |
| 291 | + $options['month'] = ''; |
| 292 | + } |
241 | 293 | |
242 | | - $pager = new ContribsPager( $target, $options['namespace'] ); |
| 294 | + $pager = new ContribsPager( $target, $options['namespace'], $options['year'], $options['month'] ); |
243 | 295 | if ( !$pager->getNumRows() ) { |
244 | 296 | $wgOut->addWikiText( wfMsg( 'nocontribs' ) ); |
245 | 297 | return; |
— | — | @@ -335,6 +387,14 @@ |
336 | 388 | $options['contribs'] = 'user'; |
337 | 389 | } |
338 | 390 | |
| 391 | + if ( !isset( $options['year'] ) ) { |
| 392 | + $options['year'] = ''; |
| 393 | + } |
| 394 | + |
| 395 | + if ( !isset( $options['month'] ) ) { |
| 396 | + $options['month'] = ''; |
| 397 | + } |
| 398 | + |
339 | 399 | if ( $options['contribs'] == 'newbie' ) { |
340 | 400 | $options['target'] = ''; |
341 | 401 | } |
— | — | @@ -342,7 +402,7 @@ |
343 | 403 | $f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ); |
344 | 404 | |
345 | 405 | foreach ( $options as $name => $value ) { |
346 | | - if ( in_array( $name, array( 'namespace', 'target', 'contribs' ) ) ) { |
| 406 | + if ( in_array( $name, array( 'namespace', 'target', 'contribs', 'year', 'month' ) ) ) { |
347 | 407 | continue; |
348 | 408 | } |
349 | 409 | $f .= "\t" . Xml::hidden( $name, $value ) . "\n"; |
— | — | @@ -355,11 +415,17 @@ |
356 | 416 | Xml::input( 'target', 20, $options['target']) . ' '. |
357 | 417 | Xml::label( wfMsg( 'namespace' ), 'namespace' ) . |
358 | 418 | Xml::namespaceSelector( $options['namespace'], '' ) . |
| 419 | + Xml::openElement( 'p' ) . |
| 420 | + Xml::label( wfMsg( 'year' ), 'year' ) . ' '. |
| 421 | + Xml::input( 'year', 4, $options['year'], array('id' => 'year', 'maxlength' => 4) ) . ' '. |
| 422 | + Xml::label( wfMsg( 'month' ), 'month' ) . ' '. |
| 423 | + xml::monthSelector( $options['month'], -1 ) . ' '. |
359 | 424 | Xml::submitButton( wfMsg( 'sp-contributions-submit' ) ) . |
| 425 | + Xml::closeElement( 'p' ) . |
360 | 426 | '</fieldset>' . |
361 | 427 | Xml::closeElement( 'form' ); |
362 | 428 | return $f; |
363 | 429 | } |
364 | 430 | |
365 | 431 | |
366 | | - |
| 432 | +?> |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -1900,8 +1900,8 @@ |
1901 | 1901 | 'ucnote' => "Below are this user's last <b>$1</b> changes in the last <b>$2</b> days.", |
1902 | 1902 | 'uclinks' => 'View the last $1 changes; view the last $2 days.', |
1903 | 1903 | 'uctop' => ' (top)', |
1904 | | -'month' => 'Month:', |
1905 | | -'year' => 'Year:', |
| 1904 | +'month' => 'From month (and earlier):', |
| 1905 | +'year' => 'From year (and earlier):', |
1906 | 1906 | |
1907 | 1907 | 'sp-contributions-newest' => 'Newest', |
1908 | 1908 | 'sp-contributions-oldest' => 'Oldest', |