52
52
if( $target != 'newbies' ) {
53
53
$target = $nt->getText();
54
54
$wgOut->setSubtitle( $this->contributionsSub( $nt, $id ) );
55
$wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'contributions-title', $target ) ) );
55
$wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsgExt( 'contributions-title', array( 'parsemag' ),$target ) ) );
57
57
$wgOut->setSubtitle( wfMsgHtml( 'sp-contributions-newbies-sub') );
58
58
$wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'sp-contributions-newbies-title' ) ) );
73
75
$skip = $wgRequest->getText( 'offset' ) || $wgRequest->getText( 'dir' ) == 'prev';
74
76
# Offset overrides year/month selection
75
if( ( $month = $wgRequest->getIntOrNull( 'month' ) ) !== null && $month !== -1 ) {
76
$this->opts['month'] = intval( $month );
78
$this->opts['month'] = '';
80
if( ( $year = $wgRequest->getIntOrNull( 'year' ) ) !== null ) {
81
$this->opts['year'] = intval( $year );
82
} else if( $this->opts['month'] ) {
83
$thisMonth = intval( gmdate( 'n' ) );
84
$thisYear = intval( gmdate( 'Y' ) );
85
if( intval( $this->opts['month'] ) > $thisMonth ) {
88
$this->opts['year'] = $thisYear;
90
$this->opts['year'] = '';
94
78
$this->opts['year'] = '';
95
79
$this->opts['month'] = '';
81
$this->opts['year'] = $wgRequest->getIntOrNull( 'year' );
82
$this->opts['month'] = $wgRequest->getIntOrNull( 'month' );
98
85
// Add RSS/atom links
105
92
wfRunHooks( 'SpecialContributionsBeforeMainOutput', $id );
107
$wgOut->addHTML( $this->getForm( $this->opts ) );
94
$wgOut->addHTML( $this->getForm() );
109
96
$pager = new ContribsPager( $target, $this->opts['namespace'], $this->opts['year'], $this->opts['month'] );
110
97
if( !$pager->getNumRows() ) {
111
$wgOut->addWikiMsg( 'nocontribs' );
98
$wgOut->addWikiMsg( 'nocontribs', $target );
177
164
wfMsgHtml( 'sp-contributions-blocklog' ), 'type=block&page=' . $nt->getPrefixedUrl() );
179
166
# Other logs link
180
$tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'Log' ), wfMsgHtml( 'log' ),
181
'user=' . $nt->getPartialUrl() );
167
$tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'Log' ), wfMsg( 'sp-contributions-logs' ),
168
'user=' . $nt->getPartialUrl() );
183
170
# Add link to deleted user contributions for priviledged users
184
171
if( $wgUser->isAllowed( 'deletedhistory' ) ) {
185
$tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'DeletedContributions',
172
$tools[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'DeletedContributions',
186
173
$nt->getDBkey() ), wfMsgHtml( 'deletedcontributions' ) );
176
# Add a link to change user rights for privileged users
177
$userrightsPage = new UserrightsPage();
178
if( 0 !== $id && $userrightsPage->userCanChangeRights( User::newFromId( $id ) ) ) {
179
$tools[] = $sk->makeKnownLinkObj(
180
SpecialPage::getTitleFor( 'Userrights', $nt->getDBkey() ),
181
wfMsgHtml( 'userrights' )
189
185
wfRunHooks( 'ContributionsToolLinks', array( $id, $nt, &$tools ) );
191
$links = implode( ' | ', $tools );
187
$links = $wgLang->pipeList( $tools );
194
190
// Old message 'contribsub' had one parameter, but that doesn't work for
235
231
if( $this->opts['contribs'] == 'newbie' ) {
236
232
$this->opts['target'] = '';
235
if( !isset( $this->opts['tagfilter'] ) ) {
236
$this->opts['tagfilter'] = '';
239
239
$f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
240
# Add hidden params for tracking
241
241
foreach ( $this->opts as $name => $value ) {
242
242
if( in_array( $name, array( 'namespace', 'target', 'contribs', 'year', 'month' ) ) ) {
245
245
$f .= "\t" . Xml::hidden( $name, $value ) . "\n";
248
$tagFilter = ChangeTags::buildTagFilterSelector( $this->opts['tagfilter'] );
248
250
$f .= '<fieldset>' .
249
251
Xml::element( 'legend', array(), wfMsg( 'sp-contributions-search' ) ) .
256
258
Xml::label( wfMsg( 'namespace' ), 'namespace' ) . ' ' .
257
259
Xml::namespaceSelector( $this->opts['namespace'], '' ) .
261
( $tagFilter ? Xml::tags( 'p', null, implode( ' ', $tagFilter ) ) : '' ) .
259
262
Xml::openElement( 'p' ) .
260
263
'<span style="white-space: nowrap">' .
261
Xml::label( wfMsg( 'year' ), 'year' ) . ' '.
262
Xml::input( 'year', 4, $this->opts['year'], array('id' => 'year', 'maxlength' => 4) ) .
265
'<span style="white-space: nowrap">' .
266
Xml::label( wfMsg( 'month' ), 'month' ) . ' '.
267
Xml::monthSelector( $this->opts['month'], -1 ) . ' '.
264
Xml::dateMenu( $this->opts['year'], $this->opts['month'] ) .
269
266
Xml::submitButton( wfMsg( 'sp-contributions-submit' ) ) .
270
267
Xml::closeElement( 'p' );
300
297
$feed = new $wgFeedClasses[$type](
301
298
$this->feedTitle(),
302
299
wfMsgExt( 'tagline', 'parsemag' ),
303
$this->getTitle()->getFullUrl() );
300
$this->getTitle()->getFullUrl() . "/" . urlencode($this->opts['target'])
305
303
// Already valid title
306
304
$nt = Title::makeTitleSafe( NS_USER, $this->opts['target'] );
307
305
$target = $this->opts['target'] == 'newbies' ? 'newbies' : $nt->getText();
309
307
$pager = new ContribsPager( $target, $this->opts['namespace'],
310
$this->opts['year'], $this->opts['month'] );
308
$this->opts['year'], $this->opts['month'], $this->opts['tagfilter'] );
312
310
$pager->mLimit = min( $this->opts['limit'], $wgFeedLimit );
354
352
protected function feedItemDesc( $revision ) {
355
353
if( $revision ) {
356
return '<p>' . htmlspecialchars( $revision->getUserText() ) . ': ' .
354
return '<p>' . htmlspecialchars( $revision->getUserText() ) . wfMsgForContent( 'colon-separator' ) .
357
355
htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) .
358
356
"</p>\n<hr />\n<div>" .
359
357
nl2br( htmlspecialchars( $revision->getText() ) ) . "</div>";
371
369
var $messages, $target;
372
370
var $namespace = '', $mDb;
374
function __construct( $target, $namespace = false, $year = false, $month = false ) {
372
function __construct( $target, $namespace = false, $year = false, $month = false, $tagFilter = false ) {
375
373
parent::__construct();
376
374
foreach( explode( ' ', 'uctop diff newarticle rollbacklink diff hist newpageletter minoreditletter' ) as $msg ) {
377
375
$this->messages[$msg] = wfMsgExt( $msg, array( 'escape') );
379
377
$this->target = $target;
380
378
$this->namespace = $namespace;
379
$this->tagFilter = $tagFilter;
382
381
$this->getDateCond( $year, $month );
393
392
function getQueryInfo() {
394
394
list( $tables, $index, $userCond, $join_cond ) = $this->getUserCond();
395
$conds = array_merge( array('page_id=rev_page'), $userCond, $this->getNamespaceCond() );
396
$conds = array_merge( $userCond, $this->getNamespaceCond() );
397
// Paranoia: avoid brute force searches (bug 17342)
398
if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
399
$conds[] = 'rev_deleted & ' . Revision::DELETED_USER . ' = 0';
401
$join_cond['page'] = array( 'INNER JOIN', 'page_id=rev_page' );
396
403
$queryInfo = array(
397
404
'tables' => $tables,
398
405
'fields' => array(
399
'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'rev_id', 'rev_page',
400
'rev_text_id', 'rev_timestamp', 'rev_comment', 'rev_minor_edit', 'rev_user',
401
'rev_user_text', 'rev_parent_id', 'rev_deleted'
406
'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'page_is_redirect',
407
'page_len','rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment',
408
'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted'
403
410
'conds' => $conds,
404
411
'options' => array( 'USE INDEX' => array('revision' => $index) ),
405
412
'join_conds' => $join_cond
415
ChangeTags::modifyDisplayQuery( $queryInfo['tables'],
416
$queryInfo['fields'],
418
$queryInfo['join_conds'],
419
$queryInfo['options'],
407
422
wfRunHooks( 'ContribsPager::getQueryInfo', array( &$this, &$queryInfo ) );
408
423
return $queryInfo;
458
473
* @todo This would probably look a lot nicer in a table.
460
475
function formatRow( $row ) {
476
global $wgLang, $wgUser, $wgContLang;
461
477
wfProfileIn( __METHOD__ );
463
global $wgLang, $wgUser, $wgContLang;
465
479
$sk = $this->getSkin();
466
480
$rev = new Revision( $row );
468
$page = Title::makeTitle( $row->page_namespace, $row->page_title );
469
$link = $sk->makeKnownLinkObj( $page );
483
$page = Title::newFromRow( $row );
484
$page->resetArticleId( $row->rev_page ); // use process cache
485
$link = $sk->makeLinkObj( $page, $page->getPrefixedText(), $page->isRedirect() ? 'redirect=no' : '' );
486
# Mark current revisions
470
487
$difftext = $topmarktext = '';
471
488
if( $row->rev_id == $row->page_latest ) {
472
489
$topmarktext .= '<strong>' . $this->messages['uctop'] . '</strong>';
473
490
if( !$row->page_is_new ) {
474
491
$difftext .= '(' . $sk->makeKnownLinkObj( $page, $this->messages['diff'], 'diff=0' ) . ')';
493
if( $page->quickUserCan( 'rollback') && $page->quickUserCan( 'edit' ) ) {
494
$topmarktext .= ' '.$sk->generateRollback( $rev );
476
497
$difftext .= $this->messages['newarticle'];
479
if( $page->userCan( 'rollback') && $page->userCan( 'edit' ) ) {
480
$topmarktext .= ' '.$sk->generateRollback( $rev );
484
500
# Is there a visible previous revision?
485
501
if( $rev->userCan(Revision::DELETED_TEXT) ) {
486
$difftext = '(' . $sk->makeKnownLinkObj( $page, $this->messages['diff'], 'diff=prev&oldid='.$row->rev_id ) . ')';
502
$difftext = '(' . $sk->makeKnownLinkObj( $page, $this->messages['diff'],
503
'diff=prev&oldid='.$row->rev_id ) . ')';
488
505
$difftext = '(' . $this->messages['diff'] . ')';
490
$histlink='('.$sk->makeKnownLinkObj( $page, $this->messages['hist'], 'action=history' ) . ')';
507
$histlink = '('.$sk->makeKnownLinkObj( $page, $this->messages['hist'], 'action=history' ) . ')';
492
509
$comment = $wgContLang->getDirMark() . $sk->revComment( $rev, false, true );
493
510
$date = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true );
520
537
if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
521
538
$ret .= ' ' . wfMsgHtml( 'deletedrev' );
542
list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'contributions' );
543
$classes = array_merge( $classes, $newClasses );
544
$ret .= " $tagSummary";
523
546
// Let extensions add data
524
547
wfRunHooks( 'ContributionsLineEnding', array( &$this, &$ret, $row ) );
526
$ret = "<li>$ret</li>\n";
549
$classes = implode( ' ', $classes );
550
$ret = "<li class=\"$classes\">$ret</li>\n";
527
551
wfProfileOut( __METHOD__ );