86c0f36b2771d7f0d3097a36aa9f062d9afbe0ef
[lhc/web/wiklou.git] / includes / specials / SpecialContributions.php
1 <?php
2 /**
3 * Implements Special:Contributions
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup SpecialPage
22 */
23
24 /**
25 * Special:Contributions, show user contributions in a paged list
26 *
27 * @ingroup SpecialPage
28 */
29
30 class SpecialContributions extends SpecialPage {
31
32 protected $opts;
33
34 public function __construct() {
35 parent::__construct( 'Contributions' );
36 }
37
38 public function execute( $par ) {
39 global $wgUser, $wgOut, $wgRequest;
40
41 $this->setHeaders();
42 $this->outputHeader();
43 $wgOut->addModuleStyles( 'mediawiki.special' );
44
45 $this->opts = array();
46
47 if( $par == 'newbies' ) {
48 $target = 'newbies';
49 $this->opts['contribs'] = 'newbie';
50 } elseif( isset( $par ) ) {
51 $target = $par;
52 } else {
53 $target = $wgRequest->getVal( 'target' );
54 }
55
56 // check for radiobox
57 if( $wgRequest->getVal( 'contribs' ) == 'newbie' ) {
58 $target = 'newbies';
59 $this->opts['contribs'] = 'newbie';
60 }
61
62 $this->opts['deletedOnly'] = $wgRequest->getBool( 'deletedOnly' );
63
64 if( !strlen( $target ) ) {
65 $wgOut->addHTML( $this->getForm() );
66 return;
67 }
68
69 $this->opts['limit'] = $wgRequest->getInt( 'limit', $wgUser->getOption('rclimit') );
70 $this->opts['target'] = $target;
71 $this->opts['topOnly'] = $wgRequest->getBool( 'topOnly' );
72
73 $nt = Title::makeTitleSafe( NS_USER, $target );
74 if( !$nt ) {
75 $wgOut->addHTML( $this->getForm() );
76 return;
77 }
78 $id = User::idFromName( $nt->getText() );
79
80 if( $target != 'newbies' ) {
81 $target = $nt->getText();
82 $wgOut->setSubtitle( $this->contributionsSub( $nt, $id ) );
83 $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsgExt( 'contributions-title', array( 'parsemag' ),$target ) ) );
84 $user = User::newFromName( $target, false );
85 if ( is_object( $user ) ) {
86 $this->getSkin()->setRelevantUser( $user );
87 }
88 } else {
89 $wgOut->setSubtitle( wfMsgHtml( 'sp-contributions-newbies-sub') );
90 $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'sp-contributions-newbies-title' ) ) );
91 }
92
93 if( ( $ns = $wgRequest->getVal( 'namespace', null ) ) !== null && $ns !== '' ) {
94 $this->opts['namespace'] = intval( $ns );
95 } else {
96 $this->opts['namespace'] = '';
97 }
98
99 $this->opts['tagFilter'] = (string) $wgRequest->getVal( 'tagFilter' );
100
101 // Allows reverts to have the bot flag in recent changes. It is just here to
102 // be passed in the form at the top of the page
103 if( $wgUser->isAllowed( 'markbotedits' ) && $wgRequest->getBool( 'bot' ) ) {
104 $this->opts['bot'] = '1';
105 }
106
107 $skip = $wgRequest->getText( 'offset' ) || $wgRequest->getText( 'dir' ) == 'prev';
108 # Offset overrides year/month selection
109 if( $skip ) {
110 $this->opts['year'] = '';
111 $this->opts['month'] = '';
112 } else {
113 $this->opts['year'] = $wgRequest->getIntOrNull( 'year' );
114 $this->opts['month'] = $wgRequest->getIntOrNull( 'month' );
115 }
116
117 $feedType = $wgRequest->getVal( 'feed' );
118 if( $feedType ) {
119 // Maintain some level of backwards compatability
120 // If people request feeds using the old parameters, redirect to API
121 $apiParams = array(
122 'action' => 'feedcontributions',
123 'feedformat' => $feedType,
124 'user' => $target,
125 );
126 if ( $this->opts['topOnly'] ) {
127 $apiParams['toponly'] = true;
128 }
129 if ( $this->opts['showSizeDiff'] ) {
130 $apiParams['showsizediff'] = true;
131 }
132 if ( $this->opts['deletedOnly'] ) {
133 $apiParams['deletedonly'] = true;
134 }
135 if ( $this->opts['tagFilter'] !== '' ) {
136 $apiParams['tagfilter'] = $this->opts['tagFilter'];
137 }
138 if ( $this->opts['namespace'] !== '' ) {
139 $apiParams['namespace'] = $this->opts['namespace'];
140 }
141 if ( $this->opts['year'] !== null ) {
142 $apiParams['year'] = $this->opts['year'];
143 }
144 if ( $this->opts['month'] !== null ) {
145 $apiParams['month'] = $this->opts['month'];
146 }
147
148 $url = wfScript( 'api' ) . '?' . wfArrayToCGI( $apiParams );
149
150 $wgOut->redirect( $url, '301' );
151 return;
152 }
153
154 // Add RSS/atom links
155 $this->addFeedLinks( array( 'action' => 'feedcontributions', 'user' => $target ) );
156
157 if ( wfRunHooks( 'SpecialContributionsBeforeMainOutput', array( $id ) ) ) {
158
159 $wgOut->addHTML( $this->getForm() );
160
161 $pager = new ContribsPager( array(
162 'target' => $target,
163 'namespace' => $this->opts['namespace'],
164 'year' => $this->opts['year'],
165 'month' => $this->opts['month'],
166 'deletedOnly' => $this->opts['deletedOnly'],
167 'topOnly' => $this->opts['topOnly'],
168 ) );
169 if( !$pager->getNumRows() ) {
170 $wgOut->addWikiMsg( 'nocontribs', $target );
171 } else {
172 # Show a message about slave lag, if applicable
173 $lag = wfGetLB()->safeGetLag( $pager->getDatabase() );
174 if( $lag > 0 )
175 $wgOut->showLagWarning( $lag );
176
177 $wgOut->addHTML(
178 '<p>' . $pager->getNavigationBar() . '</p>' .
179 $pager->getBody() .
180 '<p>' . $pager->getNavigationBar() . '</p>'
181 );
182 }
183 $wgOut->preventClickjacking( $pager->getPreventClickjacking() );
184
185 # Show the appropriate "footer" message - WHOIS tools, etc.
186 if( $target != 'newbies' ) {
187 $message = 'sp-contributions-footer';
188 if ( IP::isIPAddress( $target ) ) {
189 $message = 'sp-contributions-footer-anon';
190 } else {
191 $user = User::newFromName( $target );
192 if ( !$user || $user->isAnon() ) {
193 // No message for non-existing users
194 return;
195 }
196 }
197
198 if( !wfMessage( $message, $target )->isDisabled() ) {
199 $wgOut->wrapWikiMsg(
200 "<div class='mw-contributions-footer'>\n$1\n</div>",
201 array( $message, $target ) );
202 }
203 }
204 }
205 }
206
207 /**
208 * Generates the subheading with links
209 * @param $nt Title object for the target
210 * @param $id Integer: User ID for the target
211 * @return String: appropriately-escaped HTML to be output literally
212 * @todo FIXME: Almost the same as getSubTitle in SpecialDeletedContributions.php. Could be combined.
213 */
214 protected function contributionsSub( $nt, $id ) {
215 global $wgLang, $wgUser, $wgOut;
216
217 $sk = $this->getSkin();
218
219 if ( $id === null ) {
220 $user = htmlspecialchars( $nt->getText() );
221 } else {
222 $user = $sk->link( $nt, htmlspecialchars( $nt->getText() ) );
223 }
224 $userObj = User::newFromName( $nt->getText(), /* check for username validity not needed */ false );
225 $talk = $nt->getTalkPage();
226 if( $talk ) {
227 $tools = self::getUserLinks( $nt, $talk, $userObj, $wgUser );
228 $links = $wgLang->pipeList( $tools );
229
230 // Show a note if the user is blocked and display the last block log entry.
231 if ( $userObj->isBlocked() ) {
232 LogEventsList::showLogExtract(
233 $wgOut,
234 'block',
235 $nt->getPrefixedText(),
236 '',
237 array(
238 'lim' => 1,
239 'showIfEmpty' => false,
240 'msgKey' => array(
241 $userObj->isAnon() ?
242 'sp-contributions-blocked-notice-anon' :
243 'sp-contributions-blocked-notice',
244 $nt->getText() # Support GENDER in 'sp-contributions-blocked-notice'
245 ),
246 'offset' => '' # don't use $wgRequest parameter offset
247 )
248 );
249 }
250 }
251
252 // Old message 'contribsub' had one parameter, but that doesn't work for
253 // languages that want to put the "for" bit right after $user but before
254 // $links. If 'contribsub' is around, use it for reverse compatibility,
255 // otherwise use 'contribsub2'.
256 if( wfEmptyMsg( 'contribsub' ) ) {
257 return wfMsgHtml( 'contribsub2', $user, $links );
258 } else {
259 return wfMsgHtml( 'contribsub', "$user ($links)" );
260 }
261 }
262
263 /**
264 * Links to different places.
265 * @param $userpage Title: Target user page
266 * @param $talkpage Title: Talk page
267 * @param $target User: Target user object
268 * @param $subject User: The viewing user ($wgUser is still checked in some cases, like userrights page!!)
269 */
270 public static function getUserLinks( Title $userpage, Title $talkpage, User $target, User $subject ) {
271
272 $sk = $subject->getSkin();
273 $id = $target->getId();
274 $username = $target->getName();
275
276 $tools[] = $sk->link( $talkpage, wfMsgHtml( 'sp-contributions-talk' ) );
277
278 if( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) {
279 if( $subject->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
280 if ( $target->isBlocked() ) {
281 $tools[] = $sk->linkKnown( # Change block link
282 SpecialPage::getTitleFor( 'Block', $username ),
283 wfMsgHtml( 'change-blocklink' )
284 );
285 $tools[] = $sk->linkKnown( # Unblock link
286 SpecialPage::getTitleFor( 'Unblock', $username ),
287 wfMsgHtml( 'unblocklink' )
288 );
289 } else { # User is not blocked
290 $tools[] = $sk->linkKnown( # Block link
291 SpecialPage::getTitleFor( 'Block', $username ),
292 wfMsgHtml( 'blocklink' )
293 );
294 }
295 }
296 # Block log link
297 $tools[] = $sk->linkKnown(
298 SpecialPage::getTitleFor( 'Log', 'block' ),
299 wfMsgHtml( 'sp-contributions-blocklog' ),
300 array(),
301 array(
302 'page' => $userpage->getPrefixedText()
303 )
304 );
305 }
306 # Uploads
307 $tools[] = $sk->linkKnown(
308 SpecialPage::getTitleFor( 'Listfiles', $username ),
309 wfMsgHtml( 'sp-contributions-uploads' )
310 );
311
312 # Other logs link
313 $tools[] = $sk->linkKnown(
314 SpecialPage::getTitleFor( 'Log', $username ),
315 wfMsgHtml( 'sp-contributions-logs' )
316 );
317
318 # Add link to deleted user contributions for priviledged users
319 if( $subject->isAllowed( 'deletedhistory' ) && !$subject->isBlocked() ) {
320 $tools[] = $sk->linkKnown(
321 SpecialPage::getTitleFor( 'DeletedContributions', $username ),
322 wfMsgHtml( 'sp-contributions-deleted' )
323 );
324 }
325
326 # Add a link to change user rights for privileged users
327 $userrightsPage = new UserrightsPage();
328 if( $id !== null && $userrightsPage->userCanChangeRights( $target ) ) {
329 $tools[] = $sk->linkKnown(
330 SpecialPage::getTitleFor( 'Userrights', $username ),
331 wfMsgHtml( 'sp-contributions-userrights' )
332 );
333 }
334
335 wfRunHooks( 'ContributionsToolLinks', array( $id, $userpage, &$tools ) );
336 return $tools;
337 }
338
339 /**
340 * Generates the namespace selector form with hidden attributes.
341 * @return String: HTML fragment
342 */
343 protected function getForm() {
344 global $wgScript, $wgMiserMode;
345
346 $this->opts['title'] = $this->getTitle()->getPrefixedText();
347 if( !isset( $this->opts['target'] ) ) {
348 $this->opts['target'] = '';
349 } else {
350 $this->opts['target'] = str_replace( '_' , ' ' , $this->opts['target'] );
351 }
352
353 if( !isset( $this->opts['namespace'] ) ) {
354 $this->opts['namespace'] = '';
355 }
356
357 if( !isset( $this->opts['contribs'] ) ) {
358 $this->opts['contribs'] = 'user';
359 }
360
361 if( !isset( $this->opts['year'] ) ) {
362 $this->opts['year'] = '';
363 }
364
365 if( !isset( $this->opts['month'] ) ) {
366 $this->opts['month'] = '';
367 }
368
369 if( $this->opts['contribs'] == 'newbie' ) {
370 $this->opts['target'] = '';
371 }
372
373 if( !isset( $this->opts['tagFilter'] ) ) {
374 $this->opts['tagFilter'] = '';
375 }
376
377 if( !isset( $this->opts['topOnly'] ) ) {
378 $this->opts['topOnly'] = false;
379 }
380
381 $f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'class' => 'mw-contributions-form' ) );
382
383 # Add hidden params for tracking except for parameters in $skipParameters
384 $skipParameters = array( 'namespace', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly' );
385 foreach ( $this->opts as $name => $value ) {
386 if( in_array( $name, $skipParameters ) ) {
387 continue;
388 }
389 $f .= "\t" . Html::hidden( $name, $value ) . "\n";
390 }
391
392 $tagFilter = ChangeTags::buildTagFilterSelector( $this->opts['tagFilter'] );
393
394 $fNS = ( $wgMiserMode ) ? '' :
395 Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
396 Xml::label( wfMsg( 'namespace' ), 'namespace' ) . ' ' .
397 Xml::namespaceSelector( $this->opts['namespace'], '' )
398 );
399
400 $f .= Xml::fieldset( wfMsg( 'sp-contributions-search' ) ) .
401 Xml::radioLabel( wfMsgExt( 'sp-contributions-newbies', array( 'parsemag' ) ),
402 'contribs', 'newbie' , 'newbie', $this->opts['contribs'] == 'newbie' ) . '<br />' .
403 Xml::radioLabel( wfMsgExt( 'sp-contributions-username', array( 'parsemag' ) ),
404 'contribs' , 'user', 'user', $this->opts['contribs'] == 'user' ) . ' ' .
405 Html::input( 'target', $this->opts['target'], 'text', array(
406 'size' => '20',
407 'required' => ''
408 ) + ( $this->opts['target'] ? array() : array( 'autofocus' ) ) ) . ' '.
409 $fNS.
410 Xml::checkLabel( wfMsg( 'history-show-deleted' ),
411 'deletedOnly', 'mw-show-deleted-only', $this->opts['deletedOnly'] ) . '<br />' .
412 Xml::tags( 'p', null, Xml::checkLabel( wfMsg( 'sp-contributions-toponly' ),
413 'topOnly', 'mw-show-top-only', $this->opts['topOnly'] ) ) .
414 ( $tagFilter ? Xml::tags( 'p', null, implode( '&#160;', $tagFilter ) ) : '' ) .
415 Html::rawElement( 'p', array( 'style' => 'white-space: nowrap' ),
416 Xml::dateMenu( $this->opts['year'], $this->opts['month'] ) . ' ' .
417 Xml::submitButton( wfMsg( 'sp-contributions-submit' ) )
418 ) . ' ';
419 $explain = wfMessage( 'sp-contributions-explain' );
420 if ( $explain->exists() ) {
421 $f .= "<p id='mw-sp-contributions-explain'>{$explain}</p>";
422 }
423 $f .= Xml::closeElement('fieldset' ) .
424 Xml::closeElement( 'form' );
425 return $f;
426 }
427 }
428
429 /**
430 * Pager for Special:Contributions
431 * @ingroup SpecialPage Pager
432 */
433 class ContribsPager extends ReverseChronologicalPager {
434 public $mDefaultDirection = true;
435 var $messages, $target;
436 var $namespace = '', $mDb;
437 var $preventClickjacking = false;
438
439 function __construct( $options ) {
440 parent::__construct();
441
442 $msgs = array( 'uctop', 'diff', 'newarticle', 'rollbacklink', 'diff', 'hist', 'rev-delundel', 'pipe-separator' );
443
444 foreach( $msgs as $msg ) {
445 $this->messages[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
446 }
447
448 $this->target = isset( $options['target'] ) ? $options['target'] : '';
449 $this->namespace = isset( $options['namespace'] ) ? $options['namespace'] : '';
450 $this->tagFilter = isset( $options['tagFilter'] ) ? $options['tagFilter'] : false;
451
452 $this->deletedOnly = !empty( $options['deletedOnly'] );
453 $this->topOnly = !empty( $options['topOnly'] );
454
455 $year = isset( $options['year'] ) ? $options['year'] : false;
456 $month = isset( $options['month'] ) ? $options['month'] : false;
457 $this->getDateCond( $year, $month );
458
459 $this->mDb = wfGetDB( DB_SLAVE, 'contributions' );
460 }
461
462 function getDefaultQuery() {
463 $query = parent::getDefaultQuery();
464 $query['target'] = $this->target;
465 return $query;
466 }
467
468 function getTitle() {
469 return SpecialPage::getTitleFor( 'Contributions' );
470 }
471
472 function getQueryInfo() {
473 global $wgUser;
474 list( $tables, $index, $userCond, $join_cond ) = $this->getUserCond();
475
476 $conds = array_merge( $userCond, $this->getNamespaceCond() );
477 // Paranoia: avoid brute force searches (bug 17342)
478 if( !$wgUser->isAllowed( 'deletedhistory' ) || $wgUser->isBlocked() ) {
479 $conds[] = $this->mDb->bitAnd('rev_deleted',Revision::DELETED_USER) . ' = 0';
480 } elseif( !$wgUser->isAllowed( 'suppressrevision' ) ) {
481 $conds[] = $this->mDb->bitAnd('rev_deleted',Revision::SUPPRESSED_USER) .
482 ' != ' . Revision::SUPPRESSED_USER;
483 }
484 $join_cond['page'] = array( 'INNER JOIN', 'page_id=rev_page' );
485
486 $queryInfo = array(
487 'tables' => $tables,
488 'fields' => array(
489 'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'page_is_redirect',
490 'page_len','rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment',
491 'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted'
492 ),
493 'conds' => $conds,
494 'options' => array( 'USE INDEX' => array('revision' => $index) ),
495 'join_conds' => $join_cond
496 );
497
498 ChangeTags::modifyDisplayQuery(
499 $queryInfo['tables'],
500 $queryInfo['fields'],
501 $queryInfo['conds'],
502 $queryInfo['join_conds'],
503 $queryInfo['options'],
504 $this->tagFilter
505 );
506
507 wfRunHooks( 'ContribsPager::getQueryInfo', array( &$this, &$queryInfo ) );
508 return $queryInfo;
509 }
510
511 function getUserCond() {
512 $condition = array();
513 $join_conds = array();
514 if( $this->target == 'newbies' ) {
515 $tables = array( 'user_groups', 'page', 'revision' );
516 $max = $this->mDb->selectField( 'user', 'max(user_id)', false, __METHOD__ );
517 $condition[] = 'rev_user >' . (int)($max - $max / 100);
518 $condition[] = 'ug_group IS NULL';
519 $index = 'user_timestamp';
520 # @todo FIXME: Other groups may have 'bot' rights
521 $join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" );
522 } else {
523 $tables = array( 'page', 'revision' );
524 $condition['rev_user_text'] = $this->target;
525 $index = 'usertext_timestamp';
526 }
527 if( $this->deletedOnly ) {
528 $condition[] = "rev_deleted != '0'";
529 }
530 if( $this->topOnly ) {
531 $condition[] = "rev_id = page_latest";
532 }
533 return array( $tables, $index, $condition, $join_conds );
534 }
535
536 function getNamespaceCond() {
537 global $wgMiserMode;
538 if( $this->namespace !== '' && !$wgMiserMode ) {
539 return array( 'page_namespace' => (int)$this->namespace );
540 } else {
541 return array();
542 }
543 }
544
545 function getIndexField() {
546 return 'rev_timestamp';
547 }
548
549 function getStartBody() {
550 return "<ul>\n";
551 }
552
553 function getEndBody() {
554 return "</ul>\n";
555 }
556
557 /**
558 * Generates each row in the contributions list.
559 *
560 * Contributions which are marked "top" are currently on top of the history.
561 * For these contributions, a [rollback] link is shown for users with roll-
562 * back privileges. The rollback link restores the most recent version that
563 * was not written by the target user.
564 *
565 * @todo This would probably look a lot nicer in a table.
566 */
567 function formatRow( $row ) {
568 global $wgUser, $wgLang;
569 wfProfileIn( __METHOD__ );
570
571 $sk = $this->getSkin();
572 $rev = new Revision( $row );
573 $classes = array();
574
575 $page = Title::newFromRow( $row );
576 $link = $sk->link(
577 $page,
578 htmlspecialchars( $page->getPrefixedText() ),
579 array(),
580 $page->isRedirect() ? array( 'redirect' => 'no' ) : array()
581 );
582 # Mark current revisions
583 $topmarktext = '';
584 if( $row->rev_id == $row->page_latest ) {
585 $topmarktext .= '<span class="mw-uctop">' . $this->messages['uctop'] . '</span>';
586 # Add rollback link
587 if( !$row->page_is_new && $page->quickUserCan( 'rollback' )
588 && $page->quickUserCan( 'edit' ) )
589 {
590 $this->preventClickjacking();
591 $topmarktext .= ' '.$sk->generateRollback( $rev );
592 }
593 }
594 # Is there a visible previous revision?
595 if( $rev->userCan( Revision::DELETED_TEXT ) && $rev->getParentId() !== 0 ) {
596 $difftext = $sk->linkKnown(
597 $page,
598 $this->messages['diff'],
599 array(),
600 array(
601 'diff' => 'prev',
602 'oldid' => $row->rev_id
603 )
604 );
605 } else {
606 $difftext = $this->messages['diff'];
607 }
608 $histlink = $sk->linkKnown(
609 $page,
610 $this->messages['hist'],
611 array(),
612 array( 'action' => 'history' )
613 );
614
615 $comment = $wgLang->getDirMark() . $sk->revComment( $rev, false, true );
616 $date = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true );
617 if( $rev->userCan( Revision::DELETED_TEXT ) ) {
618 $d = $sk->linkKnown(
619 $page,
620 htmlspecialchars($date),
621 array(),
622 array( 'oldid' => intval( $row->rev_id ) )
623 );
624 } else {
625 $d = htmlspecialchars( $date );
626 }
627 if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
628 $d = '<span class="history-deleted">' . $d . '</span>';
629 }
630
631 if( $this->target == 'newbies' ) {
632 $userlink = ' . . ' . $sk->userLink( $row->rev_user, $row->rev_user_text );
633 $userlink .= ' ' . wfMsg( 'parentheses', $sk->userTalkLink( $row->rev_user, $row->rev_user_text ) ) . ' ';
634 } else {
635 $userlink = '';
636 }
637
638 if( $rev->getParentId() === 0 ) {
639 $nflag = ChangesList::flag( 'newpage' );
640 } else {
641 $nflag = '';
642 }
643
644 if( $rev->isMinor() ) {
645 $mflag = ChangesList::flag( 'minor' );
646 } else {
647 $mflag = '';
648 }
649
650 // Don't show useless link to people who cannot hide revisions
651 $canHide = $wgUser->isAllowed( 'deleterevision' );
652 if( $canHide || ($rev->getVisibility() && $wgUser->isAllowed('deletedhistory')) ) {
653 if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
654 $del = $this->mSkin->revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
655 } else {
656 $query = array(
657 'type' => 'revision',
658 'target' => $page->getPrefixedDbkey(),
659 'ids' => $rev->getId()
660 );
661 $del = $this->mSkin->revDeleteLink( $query,
662 $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide );
663 }
664 $del .= ' ';
665 } else {
666 $del = '';
667 }
668
669 $diffHistLinks = '(' . $difftext . $this->messages['pipe-separator'] . $histlink . ')';
670 $ret = "{$del}{$d} {$diffHistLinks} {$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}";
671
672 # Denote if username is redacted for this edit
673 if( $rev->isDeleted( Revision::DELETED_USER ) ) {
674 $ret .= " <strong>" . wfMsgHtml('rev-deleted-user-contribs') . "</strong>";
675 }
676
677 # Tags, if any.
678 list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'contributions' );
679 $classes = array_merge( $classes, $newClasses );
680 $ret .= " $tagSummary";
681
682 // Let extensions add data
683 wfRunHooks( 'ContributionsLineEnding', array( &$this, &$ret, $row ) );
684
685 $classes = implode( ' ', $classes );
686 $ret = "<li class=\"$classes\">$ret</li>\n";
687 wfProfileOut( __METHOD__ );
688 return $ret;
689 }
690
691 /**
692 * Get the Database object in use
693 *
694 * @return DatabaseBase
695 */
696 public function getDatabase() {
697 return $this->mDb;
698 }
699
700 /**
701 * Overwrite Pager function and return a helpful comment
702 */
703 function getSqlComment() {
704 if ( $this->namespace || $this->deletedOnly ) {
705 return 'contributions page filtered for namespace or RevisionDeleted edits'; // potentially slow, see CR r58153
706 } else {
707 return 'contributions page unfiltered';
708 }
709 }
710
711 protected function preventClickjacking() {
712 $this->preventClickjacking = true;
713 }
714
715 public function getPreventClickjacking() {
716 return $this->preventClickjacking;
717 }
718 }