r23490 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23489‎ | r23490 | r23491 >
Date:20:36, 27 June 2007
Author:brion
Status:old
Tags:
Comment:
Stripping out the year/month filter on contribs for the moment, since there's disagreement over how it should work.
Rather than annoy everyone by having it one way and changing it, we'll put it back when it's changed.
Modified paths:
  • /trunk/phase3/includes/SpecialContributions.php (modified) (history)
  • /trunk/phase3/includes/Xml.php (modified) (history)
  • /trunk/phase3/includes/XmlFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/XmlFunctions.php
@@ -18,9 +18,6 @@
1919 function HTMLnamespaceselector($selected = '', $allnamespaces = null, $includehidden=false) {
2020 return Xml::namespaceSelector( $selected, $allnamespaces, $includehidden );
2121 }
22 -function HTMLmonthelector($selected = '', $allmonths = null) {
23 - return Xml::monthSelector( $selected, $allmonths );
24 -}
2522 function wfSpan( $text, $class, $attribs=array() ) {
2623 return Xml::span( $text, $class, $attribs );
2724 }
Index: trunk/phase3/includes/Xml.php
@@ -123,28 +123,6 @@
124124 $s .= "</select>\n";
125125 return $s;
126126 }
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 - }
149127
150128 /**
151129 *
Index: trunk/phase3/includes/SpecialContributions.php
@@ -9,19 +9,13 @@
1010 var $messages, $target;
1111 var $namespace = '', $mDb;
1212
13 - function __construct( $target, $namespace = false, $year = false, $month = false ) {
 13+ function __construct( $target, $namespace = false ) {
1414 parent::__construct();
1515 foreach( explode( ' ', 'uctop diff newarticle rollbacklink diff hist minoreditletter' ) as $msg ) {
1616 $this->messages[$msg] = wfMsgExt( $msg, array( 'escape') );
1717 }
1818 $this->target = $target;
1919 $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;
2620 $this->mDb = wfGetDB( DB_SLAVE, 'contributions' );
2721 }
2822
@@ -33,7 +27,7 @@
3428
3529 function getQueryInfo() {
3630 list( $index, $userCond ) = $this->getUserCond();
37 - $conds = array_merge( array('page_id=rev_page'), $userCond, $this->getNamespaceCond(), $this->GetDateCond() );
 31+ $conds = array_merge( array('page_id=rev_page'), $userCond, $this->getNamespaceCond() );
3832
3933 return array(
4034 'tables' => array( 'page', 'revision' ),
@@ -69,39 +63,6 @@
7064 }
7165 }
7266
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 - # If just given the year 9999, we need not enforce an upper bound
99 - if( strlen($year_end) <= 4 )
100 - $condition[] = "rev_timestamp < $ts_end";
101 - }
102 -
103 - return $condition;
104 - }
105 -
10667 function getIndexField() {
10768 return 'rev_timestamp';
10869 }
@@ -273,25 +234,11 @@
274235 $options['bot'] = '1';
275236 }
276237
277 - if ( ( $month = $wgRequest->getVal( 'month', null ) ) !== null && $month !== '' ) {
278 - $options['month'] = intval( $month );
279 - } else {
280 - $options['month'] = '';
281 - }
282 -
283 - if ( ( $year = $wgRequest->getVal( 'year', null ) ) !== null && $year !== '' ) {
284 - $options['year'] = intval( $year );
285 - } else if( $month ) {
286 - $options['year'] = intval( substr( wfTimestampNow(), 0, 4 ) );
287 - } else {
288 - $options['year'] = '';
289 - }
290 -
291238 wfRunHooks( 'SpecialContributionsBeforeMainOutput', $id );
292239
293240 $wgOut->addHTML( contributionsForm( $options ) );
294241
295 - $pager = new ContribsPager( $target, $options['namespace'], $options['year'], $options['month'] );
 242+ $pager = new ContribsPager( $target, $options['namespace'] );
296243 if ( !$pager->getNumRows() ) {
297244 $wgOut->addWikiText( wfMsg( 'nocontribs' ) );
298245 return;
@@ -388,14 +335,6 @@
389336 $options['contribs'] = 'user';
390337 }
391338
392 - if ( !isset( $options['year'] ) ) {
393 - $options['year'] = '';
394 - }
395 -
396 - if ( !isset( $options['month'] ) ) {
397 - $options['month'] = '';
398 - }
399 -
400339 if ( $options['contribs'] == 'newbie' ) {
401340 $options['target'] = '';
402341 }
@@ -416,13 +355,7 @@
417356 Xml::input( 'target', 20, $options['target']) . ' '.
418357 Xml::label( wfMsg( 'namespace' ), 'namespace' ) .
419358 Xml::namespaceSelector( $options['namespace'], '' ) .
420 - Xml::openElement( 'p' ) .
421 - Xml::label( wfMsg( 'year' ), 'year' ) . ' '.
422 - Xml::input( 'year', 4, $options['year'], array('id' => 'year', 'maxlength' => 4) ) . ' '.
423 - Xml::label( wfMsg( 'month' ), 'month' ) . ' '.
424 - xml::monthSelector( $options['month'], -1 ) .
425359 Xml::submitButton( wfMsg( 'sp-contributions-submit' ) ) .
426 - Xml::closeElement( 'p' ) .
427360 '</fieldset>' .
428361 Xml::closeElement( 'form' );
429362 return $f;

Follow-up revisions

RevisionCommit summaryAuthorDate
r23581Merged revisions 23406-23580 via svnmerge from...david04:50, 30 June 2007

Status & tagging log