r68307 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68306‎ | r68307 | r68308 >
Date:11:37, 20 June 2010
Author:mgrabovsky
Status:resolved (Comments)
Tags:
Comment:
(bug 4597) Provide support in Special:Contributions to show only "current" contributions
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/specials/SpecialContributions.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesCs.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -2918,6 +2918,7 @@
29192919 The latest block log entry is provided below for reference:',
29202920 'sp-contributions-search' => 'Search for contributions',
29212921 'sp-contributions-username' => 'IP address or username:',
 2922+'sp-contributions-toponly' => 'Show only top revisions',
29222923 'sp-contributions-submit' => 'Search',
29232924 'sp-contributions-explain' => '', # only translate this message to other languages if you have to change it
29242925 'sp-contributions-footer' => '-', # do not translate or duplicate this message to other languages
Index: trunk/phase3/languages/messages/MessagesCs.php
@@ -2392,6 +2392,7 @@
23932393 Zde je pro přehled zobrazen nejnovější záznam z knihy zablokování:',
23942394 'sp-contributions-search' => 'Zobrazení příspěvků',
23952395 'sp-contributions-username' => 'IP adresa nebo uživatelské jméno:',
 2396+'sp-contributions-toponly' => 'Zobrazit pouze aktuální revize',
23962397 'sp-contributions-submit' => 'Zobrazit',
23972398
23982399 # What links here
Index: trunk/phase3/includes/specials/SpecialContributions.php
@@ -4,7 +4,7 @@
55 * @file
66 * @ingroup SpecialPage
77 */
8 -
 8+
99 class SpecialContributions extends SpecialPage {
1010
1111 public function __construct() {
@@ -43,6 +43,7 @@
4444
4545 $this->opts['limit'] = $wgRequest->getInt( 'limit', $wgUser->getOption('rclimit') );
4646 $this->opts['target'] = $target;
 47+ $this->opts['topOnly'] = $wgRequest->getCheck( 'topOnly' );
4748
4849 $nt = Title::makeTitleSafe( NS_USER, $target );
4950 if( !$nt ) {
@@ -67,9 +68,9 @@
6869 }
6970
7071 $this->opts['tagfilter'] = (string) $wgRequest->getVal( 'tagfilter' );
71 -
 72+
7273 // Allows reverts to have the bot flag in recent changes. It is just here to
73 - // be passed in the form at the top of the page
 74+ // be passed in the form at the top of the page
7475 if( $wgUser->isAllowed( 'markbotedits' ) && $wgRequest->getBool( 'bot' ) ) {
7576 $this->opts['bot'] = '1';
7677 }
@@ -83,7 +84,7 @@
8485 $this->opts['year'] = $wgRequest->getIntOrNull( 'year' );
8586 $this->opts['month'] = $wgRequest->getIntOrNull( 'month' );
8687 }
87 -
 88+
8889 // Add RSS/atom links
8990 $this->setSyndicated();
9091 $feedType = $wgRequest->getVal( 'feed' );
@@ -95,8 +96,8 @@
9697
9798 $wgOut->addHTML( $this->getForm() );
9899
99 - $pager = new ContribsPager( $target, $this->opts['namespace'], $this->opts['year'],
100 - $this->opts['month'], false, $this->opts['deletedOnly'] );
 100+ $pager = new ContribsPager( $target, $this->opts['namespace'], $this->opts['year'],
 101+ $this->opts['month'], false, $this->opts['deletedOnly'], $this->opts['topOnly'] );
101102 if( !$pager->getNumRows() ) {
102103 $wgOut->addWikiMsg( 'nocontribs', $target );
103104 } else {
@@ -134,7 +135,7 @@
135136 }
136137 }
137138 }
138 -
 139+
139140 protected function setSyndicated() {
140141 global $wgOut;
141142 $wgOut->setSyndicated( true );
@@ -176,7 +177,7 @@
177178 array(),
178179 array(
179180 'action' => 'unblock',
180 - 'ip' => $nt->getDBkey()
 181+ 'ip' => $nt->getDBkey()
181182 )
182183 );
183184 }
@@ -266,30 +267,30 @@
267268 */
268269 protected function getForm() {
269270 global $wgScript;
270 -
 271+
271272 $this->opts['title'] = $this->getTitle()->getPrefixedText();
272273 if( !isset( $this->opts['target'] ) ) {
273274 $this->opts['target'] = '';
274275 } else {
275276 $this->opts['target'] = str_replace( '_' , ' ' , $this->opts['target'] );
276277 }
277 -
 278+
278279 if( !isset( $this->opts['namespace'] ) ) {
279280 $this->opts['namespace'] = '';
280281 }
281 -
 282+
282283 if( !isset( $this->opts['contribs'] ) ) {
283284 $this->opts['contribs'] = 'user';
284285 }
285 -
 286+
286287 if( !isset( $this->opts['year'] ) ) {
287288 $this->opts['year'] = '';
288289 }
289 -
 290+
290291 if( !isset( $this->opts['month'] ) ) {
291292 $this->opts['month'] = '';
292293 }
293 -
 294+
294295 if( $this->opts['contribs'] == 'newbie' ) {
295296 $this->opts['target'] = '';
296297 }
@@ -297,11 +298,15 @@
298299 if( !isset( $this->opts['tagfilter'] ) ) {
299300 $this->opts['tagfilter'] = '';
300301 }
301 -
 302+
 303+ if( !isset( $this->opts['topOnly'] ) ) {
 304+ $this->opts['topOnly'] = false;
 305+ }
 306+
302307 $f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
303308
304309 # Add hidden params for tracking except for parameters in $skipParameters
305 - $skipParameters = array( 'namespace', 'deletedOnly', 'target', 'contribs', 'year', 'month' );
 310+ $skipParameters = array( 'namespace', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly' );
306311 foreach ( $this->opts as $name => $value ) {
307312 if( in_array( $name, $skipParameters ) ) {
308313 continue;
@@ -310,12 +315,12 @@
311316 }
312317
313318 $tagFilter = ChangeTags::buildTagFilterSelector( $this->opts['tagfilter'] );
314 -
 319+
315320 $f .= '<fieldset>' .
316321 Xml::element( 'legend', array(), wfMsg( 'sp-contributions-search' ) ) .
317 - Xml::radioLabel( wfMsgExt( 'sp-contributions-newbies', array( 'parsemag' ) ),
 322+ Xml::radioLabel( wfMsgExt( 'sp-contributions-newbies', array( 'parsemag' ) ),
318323 'contribs', 'newbie' , 'newbie', $this->opts['contribs'] == 'newbie' ? true : false ) . '<br />' .
319 - Xml::radioLabel( wfMsgExt( 'sp-contributions-username', array( 'parsemag' ) ),
 324+ Xml::radioLabel( wfMsgExt( 'sp-contributions-username', array( 'parsemag' ) ),
320325 'contribs' , 'user', 'user', $this->opts['contribs'] == 'user' ? true : false ) . ' ' .
321326 Html::input( 'target', $this->opts['target'], 'text', array(
322327 'size' => '20',
@@ -326,7 +331,9 @@
327332 Xml::namespaceSelector( $this->opts['namespace'], '' ) .
328333 '</span>' .
329334 Xml::checkLabel( wfMsg( 'history-show-deleted' ),
330 - 'deletedOnly', 'mw-show-deleted-only', $this->opts['deletedOnly'] ) .
 335+ 'deletedOnly', 'mw-show-deleted-only', $this->opts['deletedOnly'] ) . '<br />' .
 336+ Xml::tags( 'p', null, Xml::checkLabel( wfMsg( 'sp-contributions-toponly' ),
 337+ 'topOnly', 'mw-show-top-only', $this->opts['topOnly'] ) ) .
331338 ( $tagFilter ? Xml::tags( 'p', null, implode( '&#160;', $tagFilter ) ) : '' ) .
332339 Xml::openElement( 'p' ) .
333340 '<span style="white-space: nowrap">' .
@@ -334,16 +341,16 @@
335342 '</span>' . ' ' .
336343 Xml::submitButton( wfMsg( 'sp-contributions-submit' ) ) .
337344 Xml::closeElement( 'p' );
338 -
 345+
339346 $explain = wfMsgExt( 'sp-contributions-explain', 'parseinline' );
340347 if( !wfEmptyMsg( 'sp-contributions-explain', $explain ) )
341348 $f .= "<p id='mw-sp-contributions-explain'>{$explain}</p>";
342 -
 349+
343350 $f .= '</fieldset>' .
344351 Xml::closeElement( 'form' );
345352 return $f;
346353 }
347 -
 354+
348355 /**
349356 * Output a subscription feed listing recent edits to this page.
350357 * @param $type String
@@ -368,14 +375,14 @@
369376 wfMsgExt( 'tagline', 'parsemag' ),
370377 $this->getTitle()->getFullUrl() . "/" . urlencode($this->opts['target'])
371378 );
372 -
 379+
373380 // Already valid title
374381 $nt = Title::makeTitleSafe( NS_USER, $this->opts['target'] );
375382 $target = $this->opts['target'] == 'newbies' ? 'newbies' : $nt->getText();
376 -
377 - $pager = new ContribsPager( $target, $this->opts['namespace'],
378 - $this->opts['year'], $this->opts['month'], $this->opts['tagfilter'], $this->opts['deletedOnly'] );
379383
 384+ $pager = new ContribsPager( $target, $this->opts['namespace'], $this->opts['year'],
 385+ $this->opts['month'], $this->opts['tagfilter'], $this->opts['deletedOnly'], $this->opts['topOnly'] );
 386+
380387 $pager->mLimit = min( $this->opts['limit'], $wgFeedLimit );
381388
382389 $feed->outHeader();
@@ -421,7 +428,7 @@
422429 protected function feedItemDesc( $revision ) {
423430 if( $revision ) {
424431 return '<p>' . htmlspecialchars( $revision->getUserText() ) . wfMsgForContent( 'colon-separator' ) .
425 - htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) .
 432+ htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) .
426433 "</p>\n<hr />\n<div>" .
427434 nl2br( htmlspecialchars( $revision->getText() ) ) . "</div>";
428435 }
@@ -438,7 +445,7 @@
439446 var $messages, $target;
440447 var $namespace = '', $mDb;
441448
442 - function __construct( $target, $namespace = false, $year = false, $month = false, $tagFilter = false, $deletedOnly = false ) {
 449+ function __construct( $target, $namespace = false, $year = false, $month = false, $tagFilter = false, $deletedOnly = false, $topOnly = false ) {
443450 parent::__construct();
444451
445452 $msgs = array( 'uctop', 'diff', 'newarticle', 'rollbacklink', 'diff', 'hist', 'rev-delundel', 'pipe-separator' );
@@ -451,6 +458,7 @@
452459 $this->namespace = $namespace;
453460 $this->tagFilter = $tagFilter;
454461 $this->deletedOnly = $deletedOnly;
 462+ $this->topOnly = $topOnly;
455463
456464 $this->getDateCond( $year, $month );
457465
@@ -466,7 +474,7 @@
467475 function getQueryInfo() {
468476 global $wgUser;
469477 list( $tables, $index, $userCond, $join_cond ) = $this->getUserCond();
470 -
 478+
471479 $conds = array_merge( $userCond, $this->getNamespaceCond() );
472480 // Paranoia: avoid brute force searches (bug 17342)
473481 if( !$wgUser->isAllowed( 'deletedhistory' ) ) {
@@ -476,12 +484,12 @@
477485 ' != ' . Revision::SUPPRESSED_USER;
478486 }
479487 $join_cond['page'] = array( 'INNER JOIN', 'page_id=rev_page' );
480 -
 488+
481489 $queryInfo = array(
482490 'tables' => $tables,
483491 'fields' => array(
484492 'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'page_is_redirect',
485 - 'page_len','rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment',
 493+ 'page_len','rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment',
486494 'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted'
487495 ),
488496 'conds' => $conds,
@@ -518,9 +526,12 @@
519527 $condition['rev_user_text'] = $this->target;
520528 $index = 'usertext_timestamp';
521529 }
522 - if ( $this->deletedOnly ) {
 530+ if( $this->deletedOnly ) {
523531 $condition[] = "rev_deleted != '0'";
524532 }
 533+ if( $this->topOnly ) {
 534+ $condition[] = "rev_id = page_latest";
 535+ }
525536 return array( $tables, $index, $condition, $join_conds );
526537 }
527538
@@ -658,7 +669,7 @@
659670
660671 $diffHistLinks = '(' . $difftext . $this->messages['pipe-separator'] . $histlink . ')';
661672 $ret = "{$del}{$d} {$diffHistLinks} {$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}";
662 -
 673+
663674 # Denote if username is redacted for this edit
664675 if( $rev->isDeleted( Revision::DELETED_USER ) ) {
665676 $ret .= " <strong>" . wfMsgHtml('rev-deleted-user-contribs') . "</strong>";
Index: trunk/phase3/RELEASE-NOTES
@@ -84,6 +84,8 @@
8585 Special:Preferences
8686 * Interlanguage links display the page title in their tooltip.
8787 * (bug 23621) New Special:ComparePages to compare (diff) two articles.
 88+* (bug 4597) Provide support in Special:Contributions to show only "current"
 89+ contributions
8890
8991 === Bug fixes in 1.17 ===
9092 * (bug 17560) Half-broken deletion moved image files to deletion archive
Index: trunk/phase3/maintenance/language/messages.inc
@@ -1943,6 +1943,7 @@
19441944 'sp-contributions-blocked-notice-anon',
19451945 'sp-contributions-search',
19461946 'sp-contributions-username',
 1947+ 'sp-contributions-toponly',
19471948 'sp-contributions-submit',
19481949 'sp-contributions-explain',
19491950 'sp-contributions-footer',

Follow-up revisions

RevisionCommit summaryAuthorDate
r68317Follow-up r68307: ContribsPager now accepts array of options as one parameter...mgrabovsky14:48, 20 June 2010
r68582Follow-up r68307: Rephrased sp-contributions-toponly message as suggested by ...mgrabovsky19:38, 25 June 2010

Comments

#Comment by Nikerabbit (talk | contribs)   13:08, 20 June 2010
+'sp-contributions-toponly'             => 'Show only top revisions',

Sounds jargon to me. Can it be rephrased to something clearer?

+	function __construct( $target, $namespace = false, $year = false, $month = false, $tagFilter = false, $deletedOnly = false, $topOnly = false ) {

That list is getting very long. Alternative approach would be nice.

#Comment by Matěj Grabovský (talk | contribs)   14:26, 20 June 2010

“Show only edits that are current revisions (top)”?

Pass an array to the constructor maybe?

#Comment by Siebrand (talk | contribs)   08:55, 22 June 2010
  • suggesting "Only show edits that are latest revisions"
  • yes, an array would be nice.

Status & tagging log