(bug 4597) Provide support in Special:Contributions to show only "current" contributions

This commit is contained in:
Matěj Grabovský 2010-06-20 11:37:07 +00:00
parent ffa21923c6
commit 1f520f028a
5 changed files with 50 additions and 34 deletions

View file

@ -84,6 +84,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
Special:Preferences
* Interlanguage links display the page title in their tooltip.
* (bug 23621) New Special:ComparePages to compare (diff) two articles.
* (bug 4597) Provide support in Special:Contributions to show only "current"
contributions
=== Bug fixes in 1.17 ===
* (bug 17560) Half-broken deletion moved image files to deletion archive

View file

@ -4,7 +4,7 @@
* @file
* @ingroup SpecialPage
*/
class SpecialContributions extends SpecialPage {
public function __construct() {
@ -43,6 +43,7 @@ class SpecialContributions extends SpecialPage {
$this->opts['limit'] = $wgRequest->getInt( 'limit', $wgUser->getOption('rclimit') );
$this->opts['target'] = $target;
$this->opts['topOnly'] = $wgRequest->getCheck( 'topOnly' );
$nt = Title::makeTitleSafe( NS_USER, $target );
if( !$nt ) {
@ -67,9 +68,9 @@ class SpecialContributions extends SpecialPage {
}
$this->opts['tagfilter'] = (string) $wgRequest->getVal( 'tagfilter' );
// Allows reverts to have the bot flag in recent changes. It is just here to
// be passed in the form at the top of the page
// be passed in the form at the top of the page
if( $wgUser->isAllowed( 'markbotedits' ) && $wgRequest->getBool( 'bot' ) ) {
$this->opts['bot'] = '1';
}
@ -83,7 +84,7 @@ class SpecialContributions extends SpecialPage {
$this->opts['year'] = $wgRequest->getIntOrNull( 'year' );
$this->opts['month'] = $wgRequest->getIntOrNull( 'month' );
}
// Add RSS/atom links
$this->setSyndicated();
$feedType = $wgRequest->getVal( 'feed' );
@ -95,8 +96,8 @@ class SpecialContributions extends SpecialPage {
$wgOut->addHTML( $this->getForm() );
$pager = new ContribsPager( $target, $this->opts['namespace'], $this->opts['year'],
$this->opts['month'], false, $this->opts['deletedOnly'] );
$pager = new ContribsPager( $target, $this->opts['namespace'], $this->opts['year'],
$this->opts['month'], false, $this->opts['deletedOnly'], $this->opts['topOnly'] );
if( !$pager->getNumRows() ) {
$wgOut->addWikiMsg( 'nocontribs', $target );
} else {
@ -134,7 +135,7 @@ class SpecialContributions extends SpecialPage {
}
}
}
protected function setSyndicated() {
global $wgOut;
$wgOut->setSyndicated( true );
@ -176,7 +177,7 @@ class SpecialContributions extends SpecialPage {
array(),
array(
'action' => 'unblock',
'ip' => $nt->getDBkey()
'ip' => $nt->getDBkey()
)
);
}
@ -266,30 +267,30 @@ class SpecialContributions extends SpecialPage {
*/
protected function getForm() {
global $wgScript;
$this->opts['title'] = $this->getTitle()->getPrefixedText();
if( !isset( $this->opts['target'] ) ) {
$this->opts['target'] = '';
} else {
$this->opts['target'] = str_replace( '_' , ' ' , $this->opts['target'] );
}
if( !isset( $this->opts['namespace'] ) ) {
$this->opts['namespace'] = '';
}
if( !isset( $this->opts['contribs'] ) ) {
$this->opts['contribs'] = 'user';
}
if( !isset( $this->opts['year'] ) ) {
$this->opts['year'] = '';
}
if( !isset( $this->opts['month'] ) ) {
$this->opts['month'] = '';
}
if( $this->opts['contribs'] == 'newbie' ) {
$this->opts['target'] = '';
}
@ -297,11 +298,15 @@ class SpecialContributions extends SpecialPage {
if( !isset( $this->opts['tagfilter'] ) ) {
$this->opts['tagfilter'] = '';
}
if( !isset( $this->opts['topOnly'] ) ) {
$this->opts['topOnly'] = false;
}
$f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
# Add hidden params for tracking except for parameters in $skipParameters
$skipParameters = array( 'namespace', 'deletedOnly', 'target', 'contribs', 'year', 'month' );
$skipParameters = array( 'namespace', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly' );
foreach ( $this->opts as $name => $value ) {
if( in_array( $name, $skipParameters ) ) {
continue;
@ -310,12 +315,12 @@ class SpecialContributions extends SpecialPage {
}
$tagFilter = ChangeTags::buildTagFilterSelector( $this->opts['tagfilter'] );
$f .= '<fieldset>' .
Xml::element( 'legend', array(), wfMsg( 'sp-contributions-search' ) ) .
Xml::radioLabel( wfMsgExt( 'sp-contributions-newbies', array( 'parsemag' ) ),
Xml::radioLabel( wfMsgExt( 'sp-contributions-newbies', array( 'parsemag' ) ),
'contribs', 'newbie' , 'newbie', $this->opts['contribs'] == 'newbie' ? true : false ) . '<br />' .
Xml::radioLabel( wfMsgExt( 'sp-contributions-username', array( 'parsemag' ) ),
Xml::radioLabel( wfMsgExt( 'sp-contributions-username', array( 'parsemag' ) ),
'contribs' , 'user', 'user', $this->opts['contribs'] == 'user' ? true : false ) . ' ' .
Html::input( 'target', $this->opts['target'], 'text', array(
'size' => '20',
@ -326,7 +331,9 @@ class SpecialContributions extends SpecialPage {
Xml::namespaceSelector( $this->opts['namespace'], '' ) .
'</span>' .
Xml::checkLabel( wfMsg( 'history-show-deleted' ),
'deletedOnly', 'mw-show-deleted-only', $this->opts['deletedOnly'] ) .
'deletedOnly', 'mw-show-deleted-only', $this->opts['deletedOnly'] ) . '<br />' .
Xml::tags( 'p', null, Xml::checkLabel( wfMsg( 'sp-contributions-toponly' ),
'topOnly', 'mw-show-top-only', $this->opts['topOnly'] ) ) .
( $tagFilter ? Xml::tags( 'p', null, implode( '&#160;', $tagFilter ) ) : '' ) .
Xml::openElement( 'p' ) .
'<span style="white-space: nowrap">' .
@ -334,16 +341,16 @@ class SpecialContributions extends SpecialPage {
'</span>' . ' ' .
Xml::submitButton( wfMsg( 'sp-contributions-submit' ) ) .
Xml::closeElement( 'p' );
$explain = wfMsgExt( 'sp-contributions-explain', 'parseinline' );
if( !wfEmptyMsg( 'sp-contributions-explain', $explain ) )
$f .= "<p id='mw-sp-contributions-explain'>{$explain}</p>";
$f .= '</fieldset>' .
Xml::closeElement( 'form' );
return $f;
}
/**
* Output a subscription feed listing recent edits to this page.
* @param $type String
@ -368,13 +375,13 @@ class SpecialContributions extends SpecialPage {
wfMsgExt( 'tagline', 'parsemag' ),
$this->getTitle()->getFullUrl() . "/" . urlencode($this->opts['target'])
);
// Already valid title
$nt = Title::makeTitleSafe( NS_USER, $this->opts['target'] );
$target = $this->opts['target'] == 'newbies' ? 'newbies' : $nt->getText();
$pager = new ContribsPager( $target, $this->opts['namespace'],
$this->opts['year'], $this->opts['month'], $this->opts['tagfilter'], $this->opts['deletedOnly'] );
$pager = new ContribsPager( $target, $this->opts['namespace'], $this->opts['year'],
$this->opts['month'], $this->opts['tagfilter'], $this->opts['deletedOnly'], $this->opts['topOnly'] );
$pager->mLimit = min( $this->opts['limit'], $wgFeedLimit );
@ -421,7 +428,7 @@ class SpecialContributions extends SpecialPage {
protected function feedItemDesc( $revision ) {
if( $revision ) {
return '<p>' . htmlspecialchars( $revision->getUserText() ) . wfMsgForContent( 'colon-separator' ) .
htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) .
htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) .
"</p>\n<hr />\n<div>" .
nl2br( htmlspecialchars( $revision->getText() ) ) . "</div>";
}
@ -438,7 +445,7 @@ class ContribsPager extends ReverseChronologicalPager {
var $messages, $target;
var $namespace = '', $mDb;
function __construct( $target, $namespace = false, $year = false, $month = false, $tagFilter = false, $deletedOnly = false ) {
function __construct( $target, $namespace = false, $year = false, $month = false, $tagFilter = false, $deletedOnly = false, $topOnly = false ) {
parent::__construct();
$msgs = array( 'uctop', 'diff', 'newarticle', 'rollbacklink', 'diff', 'hist', 'rev-delundel', 'pipe-separator' );
@ -451,6 +458,7 @@ class ContribsPager extends ReverseChronologicalPager {
$this->namespace = $namespace;
$this->tagFilter = $tagFilter;
$this->deletedOnly = $deletedOnly;
$this->topOnly = $topOnly;
$this->getDateCond( $year, $month );
@ -466,7 +474,7 @@ class ContribsPager extends ReverseChronologicalPager {
function getQueryInfo() {
global $wgUser;
list( $tables, $index, $userCond, $join_cond ) = $this->getUserCond();
$conds = array_merge( $userCond, $this->getNamespaceCond() );
// Paranoia: avoid brute force searches (bug 17342)
if( !$wgUser->isAllowed( 'deletedhistory' ) ) {
@ -476,12 +484,12 @@ class ContribsPager extends ReverseChronologicalPager {
' != ' . Revision::SUPPRESSED_USER;
}
$join_cond['page'] = array( 'INNER JOIN', 'page_id=rev_page' );
$queryInfo = array(
'tables' => $tables,
'fields' => array(
'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'page_is_redirect',
'page_len','rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment',
'page_len','rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment',
'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted'
),
'conds' => $conds,
@ -518,9 +526,12 @@ class ContribsPager extends ReverseChronologicalPager {
$condition['rev_user_text'] = $this->target;
$index = 'usertext_timestamp';
}
if ( $this->deletedOnly ) {
if( $this->deletedOnly ) {
$condition[] = "rev_deleted != '0'";
}
if( $this->topOnly ) {
$condition[] = "rev_id = page_latest";
}
return array( $tables, $index, $condition, $join_conds );
}
@ -658,7 +669,7 @@ class ContribsPager extends ReverseChronologicalPager {
$diffHistLinks = '(' . $difftext . $this->messages['pipe-separator'] . $histlink . ')';
$ret = "{$del}{$d} {$diffHistLinks} {$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}";
# Denote if username is redacted for this edit
if( $rev->isDeleted( Revision::DELETED_USER ) ) {
$ret .= " <strong>" . wfMsgHtml('rev-deleted-user-contribs') . "</strong>";

View file

@ -2392,6 +2392,7 @@ $1',
Zde je pro přehled zobrazen nejnovější záznam z knihy zablokování:',
'sp-contributions-search' => 'Zobrazení příspěvků',
'sp-contributions-username' => 'IP adresa nebo uživatelské jméno:',
'sp-contributions-toponly' => 'Zobrazit pouze aktuální revize',
'sp-contributions-submit' => 'Zobrazit',
# What links here

View file

@ -2918,6 +2918,7 @@ The latest block log entry is provided below for reference:',
The latest block log entry is provided below for reference:',
'sp-contributions-search' => 'Search for contributions',
'sp-contributions-username' => 'IP address or username:',
'sp-contributions-toponly' => 'Show only top revisions',
'sp-contributions-submit' => 'Search',
'sp-contributions-explain' => '', # only translate this message to other languages if you have to change it
'sp-contributions-footer' => '-', # do not translate or duplicate this message to other languages

View file

@ -1943,6 +1943,7 @@ $wgMessageStructure = array(
'sp-contributions-blocked-notice-anon',
'sp-contributions-search',
'sp-contributions-username',
'sp-contributions-toponly',
'sp-contributions-submit',
'sp-contributions-explain',
'sp-contributions-footer',