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,7 +123,38 @@ |
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 | + * @return String: Html string containing the month selector |
| 134 | + */ |
| 135 | + public static function monthSelector($selected = '', $allmonths = null) { |
| 136 | + if( is_null( $selected ) ) |
| 137 | + $selected = ''; |
| 138 | + $s = "\n<select id='month' name='month' class='monthselector'>\n"; |
| 139 | + $arr = Language::$mMonthGenMsgs; |
| 140 | + |
| 141 | + if( !is_null($allmonths) ) { |
| 142 | + $arr = array($allmonths => 'monthsall') + $arr; |
| 143 | + } |
| 144 | + foreach ($arr as $index => $name) { |
| 145 | + $message = wfMsgHtml($name); |
| 146 | + $index++; // Let January be 1 |
127 | 147 | |
| 148 | + if ($index === $selected) { |
| 149 | + $s .= "\t" . self::element("option", |
| 150 | + array("value" => $index, "selected" => "selected"), $message) . "\n"; |
| 151 | + } else { |
| 152 | + $s .= "\t" . self::element("option", array("value" => $index), $message) . "\n"; |
| 153 | + } |
| 154 | + } |
| 155 | + $s .= "</select>\n"; |
| 156 | + return $s; |
| 157 | + } |
| 158 | + |
128 | 159 | /** |
129 | 160 | * |
130 | 161 | * @param $language The language code of the selected language |
Index: trunk/phase3/includes/SpecialContributions.php |
— | — | @@ -9,13 +9,19 @@ |
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 > 1 && $month < 13) ? $month : false; |
20 | 26 | $this->mDb = wfGetDB( DB_SLAVE, 'contributions' ); |
21 | 27 | } |
22 | 28 | |
— | — | @@ -27,7 +33,7 @@ |
28 | 34 | |
29 | 35 | function getQueryInfo() { |
30 | 36 | list( $index, $userCond ) = $this->getUserCond(); |
31 | | - $conds = array_merge( array( 'page_id=rev_page' ), $userCond, $this->getNamespaceCond() ); |
| 37 | + $conds = array_merge( array('page_id=rev_page'), $userCond, $this->getNamespaceCond(), $this->GetDateCond() ); |
32 | 38 | |
33 | 39 | return array( |
34 | 40 | 'tables' => array( 'page', 'revision' ), |
— | — | @@ -62,6 +68,37 @@ |
63 | 69 | return array(); |
64 | 70 | } |
65 | 71 | } |
| 72 | + |
| 73 | + function getDateCond() { |
| 74 | + $condition = array(); |
| 75 | + |
| 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_start = str_pad($this->month, 2, '0', STR_PAD_LEFT); |
| 86 | + $month_end = str_pad($this->month + 1, 2, '0', STR_PAD_LEFT); |
| 87 | + $year_end = $year_start; |
| 88 | + } else { |
| 89 | + $month_start = 0; |
| 90 | + $month_end = 0; |
| 91 | + $year_end = $year_start + 1; |
| 92 | + } |
| 93 | + |
| 94 | + $ts_start = str_pad($year_start . $month_start, 14, '0' ); |
| 95 | + $ts_end = str_pad($year_end . $month_end, 14, '0' ); |
| 96 | + |
| 97 | + $condition[] = "rev_timestamp >= $ts_start"; |
| 98 | + $condition[] = "rev_timestamp < $ts_end"; |
| 99 | + } |
| 100 | + |
| 101 | + return $condition; |
| 102 | + } |
66 | 103 | |
67 | 104 | function getIndexField() { |
68 | 105 | return 'rev_timestamp'; |
— | — | @@ -233,12 +270,26 @@ |
234 | 271 | if ( $wgUser->isAllowed( 'rollback' ) && $wgRequest->getBool( 'bot' ) ) { |
235 | 272 | $options['bot'] = '1'; |
236 | 273 | } |
| 274 | + |
| 275 | + if ( ( $month = $wgRequest->getVal( 'month', null ) ) !== null && $month !== '' ) { |
| 276 | + $options['month'] = intval( $month ); |
| 277 | + } else { |
| 278 | + $options['month'] = ''; |
| 279 | + } |
| 280 | + |
| 281 | + if ( ( $year = $wgRequest->getVal( 'year', null ) ) !== null && $year !== '' ) { |
| 282 | + $options['year'] = intval( $year ); |
| 283 | + } else if( $month ) { |
| 284 | + $options['year'] = intval( substr( wfTimestampNow(), 0, 4 ) ); |
| 285 | + } else { |
| 286 | + $options['year'] = ''; |
| 287 | + } |
237 | 288 | |
238 | 289 | wfRunHooks( 'SpecialContributionsBeforeMainOutput', $id ); |
239 | 290 | |
240 | 291 | $wgOut->addHTML( contributionsForm( $options ) ); |
241 | 292 | |
242 | | - $pager = new ContribsPager( $target, $options['namespace'] ); |
| 293 | + $pager = new ContribsPager( $target, $options['namespace'], $options['year'], $options['month'] ); |
243 | 294 | if ( !$pager->getNumRows() ) { |
244 | 295 | $wgOut->addWikiText( wfMsg( 'nocontribs' ) ); |
245 | 296 | return; |
— | — | @@ -334,7 +385,15 @@ |
335 | 386 | if ( !isset( $options['contribs'] ) ) { |
336 | 387 | $options['contribs'] = 'user'; |
337 | 388 | } |
| 389 | + |
| 390 | + if ( !isset( $options['year'] ) ) { |
| 391 | + $options['year'] = ''; |
| 392 | + } |
338 | 393 | |
| 394 | + if ( !isset( $options['month'] ) ) { |
| 395 | + $options['month'] = ''; |
| 396 | + } |
| 397 | + |
339 | 398 | if ( $options['contribs'] == 'newbie' ) { |
340 | 399 | $options['target'] = ''; |
341 | 400 | } |
— | — | @@ -355,7 +414,13 @@ |
356 | 415 | Xml::input( 'target', 20, $options['target']) . ' '. |
357 | 416 | Xml::label( wfMsg( 'namespace' ), 'namespace' ) . |
358 | 417 | Xml::namespaceSelector( $options['namespace'], '' ) . |
| 418 | + Xml::openElement( 'p' ) . |
| 419 | + Xml::label( wfMsg( 'year' ), 'year' ) . ' '. |
| 420 | + Xml::input( 'year', 4, $options['year'], array('id' => 'year', 'maxlength' => 4) ) . ' '. |
| 421 | + Xml::label( wfMsg( 'month' ), 'month' ) . ' '. |
| 422 | + xml::monthSelector( $options['month'], -1 ) . |
359 | 423 | Xml::submitButton( wfMsg( 'sp-contributions-submit' ) ) . |
| 424 | + Xml::closeElement( 'p' ) . |
360 | 425 | '</fieldset>' . |
361 | 426 | Xml::closeElement( 'form' ); |
362 | 427 | return $f; |
Index: trunk/phase3/languages/messages/MessagesEn.php |
— | — | @@ -1908,6 +1908,9 @@ |
1909 | 1909 | 'uclinks' => 'View the last $1 changes; view the last $2 days.', |
1910 | 1910 | 'uctop' => ' (top)', |
1911 | 1911 | |
| 1912 | +'month' => 'Month:', |
| 1913 | +'year' => 'Year:', |
| 1914 | + |
1912 | 1915 | 'sp-contributions-newest' => 'Newest', |
1913 | 1916 | 'sp-contributions-oldest' => 'Oldest', |
1914 | 1917 | 'sp-contributions-newer' => 'Newer $1', |
— | — | @@ -2734,6 +2737,7 @@ |
2735 | 2738 | 'watchlistall1' => 'all', |
2736 | 2739 | 'watchlistall2' => 'all', |
2737 | 2740 | 'namespacesall' => 'all', |
| 2741 | +'monthsall' => 'all', |
2738 | 2742 | |
2739 | 2743 | # E-mail address confirmation |
2740 | 2744 | 'confirmemail' => 'Confirm E-mail address', |