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