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