r47192 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r47191‎ | r47192 | r47193 >
Date:19:02, 12 February 2009
Author:aaron
Status:deferred
Tags:
Comment:
* consolidated getDateMenu duplication into xml.php
* made filter settings carry over when pressing "go"
* made filter links a bit smaller
* removed DefaultQuery cruft
* updated docs
Modified paths:
  • /trunk/phase3/includes/LogEventsList.php (modified) (history)
  • /trunk/phase3/includes/Xml.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialContributions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Xml.php
@@ -172,6 +172,36 @@
173173 . implode( "\n", $options )
174174 . self::closeElement( 'select' );
175175 }
 176+
 177+ /**
 178+ * @param $year Integer
 179+ * @param $month Integer
 180+ * @return string Formatted HTML
 181+ */
 182+ public static function dateMenu( $year, $month ) {
 183+ # Offset overrides year/month selection
 184+ if( $month && $month !== -1 ) {
 185+ $encMonth = intval( $month );
 186+ } else {
 187+ $encMonth = '';
 188+ }
 189+ if( $year ) {
 190+ $encYear = intval( $year );
 191+ } else if( $encMonth ) {
 192+ $thisMonth = intval( gmdate( 'n' ) );
 193+ $thisYear = intval( gmdate( 'Y' ) );
 194+ if( intval($encMonth) > $thisMonth ) {
 195+ $thisYear--;
 196+ }
 197+ $encYear = $thisYear;
 198+ } else {
 199+ $encYear = '';
 200+ }
 201+ return Xml::label( wfMsg( 'year' ), 'year' ) . ' '.
 202+ Xml::input( 'year', 4, $encYear, array('id' => 'year', 'maxlength' => 4) ) . ' '.
 203+ Xml::label( wfMsg( 'month' ), 'month' ) . ' '.
 204+ Xml::monthSelector( $encMonth, -1 );
 205+ }
176206
177207 /**
178208 *
Index: trunk/phase3/includes/LogEventsList.php
@@ -65,10 +65,11 @@
6666 * @param $pattern String
6767 * @param $year Integer: year
6868 * @param $month Integer: month
69 - * @param $filter Boolean
 69+ * @param $filter: array
 70+ * @param $tagFilter: array?
7071 */
7172 public function showOptions( $type = '', $user = '', $page = '', $pattern = '', $year = '',
72 - $month = '', $filter = null, $tagFilter='' )
 73+ $month = '', $filter = null, $tagFilter='' )
7374 {
7475 global $wgScript, $wgMiserMode;
7576 $action = htmlspecialchars( $wgScript );
@@ -98,15 +99,17 @@
99100 $messages = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' ) );
100101 // Option value -> message mapping
101102 $links = array();
 103+ $hiddens = ''; // keep track for "go" button
102104 foreach( $filter as $type => $val ) {
103105 $hideVal = 1 - intval($val);
104106 $link = $this->skin->makeKnownLinkObj( $wgTitle, $messages[$hideVal],
105107 wfArrayToCGI( array( "hide_{$type}_log" => $hideVal ), $this->getDefaultQuery() )
106108 );
107109 $links[$type] = wfMsgHtml( "log-show-hide-{$type}", $link );
 110+ $hiddens .= Xml::hidden( "hide_{$type}_log", $val ) . "\n";
108111 }
109112 // Build links
110 - return $wgLang->pipeList( $links );
 113+ return '<small>'.$wgLang->pipeList( $links ) . '</small>' . $hiddens;
111114 }
112115
113116 private function getDefaultQuery() {
@@ -183,29 +186,7 @@
184187 * @return string Formatted HTML
185188 */
186189 private function getDateMenu( $year, $month ) {
187 - # Offset overrides year/month selection
188 - if( $month && $month !== -1 ) {
189 - $encMonth = intval( $month );
190 - } else {
191 - $encMonth = '';
192 - }
193 - if ( $year ) {
194 - $encYear = intval( $year );
195 - } else if( $encMonth ) {
196 - $thisMonth = intval( gmdate( 'n' ) );
197 - $thisYear = intval( gmdate( 'Y' ) );
198 - if( intval($encMonth) > $thisMonth ) {
199 - $thisYear--;
200 - }
201 - $encYear = $thisYear;
202 - } else {
203 - $encYear = '';
204 - }
205 - return Xml::label( wfMsg( 'year' ), 'year' ) . ' '.
206 - Xml::input( 'year', 4, $encYear, array('id' => 'year', 'maxlength' => 4) ) .
207 - ' '.
208 - Xml::label( wfMsg( 'month' ), 'month' ) . ' '.
209 - Xml::monthSelector( $encMonth, -1 );
 190+ return Xml::dateMenu( $year, $month );
210191 }
211192
212193 /**
@@ -523,7 +504,7 @@
524505
525506 $this->mLogEventsList = $list;
526507
527 - $this->limitType( $type );
 508+ $this->limitType( $type ); // excludes hidden types too
528509 $this->limitUser( $user );
529510 $this->limitTitle( $title, $pattern );
530511 $this->getDateCond( $year, $month );
@@ -532,10 +513,6 @@
533514
534515 public function getDefaultQuery() {
535516 $query = parent::getDefaultQuery();
536 - $query['type'] = $this->type;
537 - $query['user'] = $this->user;
538 - $query['month'] = $this->mMonth;
539 - $query['year'] = $this->mYear;
540517 return $query;
541518 }
542519
Index: trunk/phase3/includes/specials/SpecialContributions.php
@@ -74,27 +74,12 @@
7575
7676 $skip = $wgRequest->getText( 'offset' ) || $wgRequest->getText( 'dir' ) == 'prev';
7777 # Offset overrides year/month selection
78 - if( ( $month = $wgRequest->getIntOrNull( 'month' ) ) !== null && $month !== -1 ) {
79 - $this->opts['month'] = intval( $month );
80 - } else {
81 - $this->opts['month'] = '';
82 - }
83 - if( ( $year = $wgRequest->getIntOrNull( 'year' ) ) !== null ) {
84 - $this->opts['year'] = intval( $year );
85 - } else if( $this->opts['month'] ) {
86 - $thisMonth = intval( gmdate( 'n' ) );
87 - $thisYear = intval( gmdate( 'Y' ) );
88 - if( intval( $this->opts['month'] ) > $thisMonth ) {
89 - $thisYear--;
90 - }
91 - $this->opts['year'] = $thisYear;
92 - } else {
93 - $this->opts['year'] = '';
94 - }
95 -
9678 if( $skip ) {
9779 $this->opts['year'] = '';
9880 $this->opts['month'] = '';
 81+ } else {
 82+ $this->opts['year'] = $wgRequest->getIntOrNull( 'year' );
 83+ $this->opts['month'] = $wgRequest->getIntOrNull( 'month' );
9984 }
10085
10186 // Add RSS/atom links
@@ -243,7 +228,7 @@
244229 }
245230
246231 $f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
247 -
 232+ # Add hidden params for tracking
248233 foreach ( $this->opts as $name => $value ) {
249234 if( in_array( $name, array( 'namespace', 'target', 'contribs', 'year', 'month' ) ) ) {
250235 continue;
@@ -267,14 +252,8 @@
268253 ( $tagFilter ? Xml::tags( 'p', null, implode( '&nbsp;', $tagFilter ) ) : '' ) .
269254 Xml::openElement( 'p' ) .
270255 '<span style="white-space: nowrap">' .
271 - Xml::label( wfMsg( 'year' ), 'year' ) . ' '.
272 - Xml::input( 'year', 4, $this->opts['year'], array('id' => 'year', 'maxlength' => 4) ) .
273 - '</span>' .
274 - ' '.
275 - '<span style="white-space: nowrap">' .
276 - Xml::label( wfMsg( 'month' ), 'month' ) . ' '.
277 - Xml::monthSelector( $this->opts['month'], -1 ) . ' '.
278 - '</span>' .
 256+ Xml::dateMenu( $this->opts['year'], $this->opts['month'] ) .
 257+ '</span>' . ' ' .
279258 Xml::submitButton( wfMsg( 'sp-contributions-submit' ) ) .
280259 Xml::closeElement( 'p' );
281260

Follow-up revisions

RevisionCommit summaryAuthorDate
r47193Follow-up to r47192: do the same for PageHistoryaaron19:23, 12 February 2009
r47418Partial revert of r47192 (* removed DefaultQuery cruft) -- That cruft was kin...werdna04:49, 18 February 2009

Status & tagging log