Localisation updates for core and extension messages from translatewiki.net (2011...
[mediawiki.git] / includes / specials / SpecialContributions.php
blob1fb89a57bcf65309e0e698208d187d632879f4a0
1 <?php
2 /**
3 * Implements Special:Contributions
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.
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.
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
20 * @file
21 * @ingroup SpecialPage
24 /**
25 * Special:Contributions, show user contributions in a paged list
27 * @ingroup SpecialPage
30 class SpecialContributions extends SpecialPage {
32 protected $opts;
34 public function __construct() {
35 parent::__construct( 'Contributions' );
38 public function execute( $par ) {
39 global $wgUser, $wgOut, $wgRequest;
41 $this->setHeaders();
42 $this->outputHeader();
43 $wgOut->addModuleStyles( 'mediawiki.special' );
45 $this->opts = array();
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' );
56 // check for radiobox
57 if( $wgRequest->getVal( 'contribs' ) == 'newbie' ) {
58 $target = 'newbies';
59 $this->opts['contribs'] = 'newbie';
62 $this->opts['deletedOnly'] = $wgRequest->getBool( 'deletedOnly' );
64 if( !strlen( $target ) ) {
65 $wgOut->addHTML( $this->getForm() );
66 return;
69 $this->opts['limit'] = $wgRequest->getInt( 'limit', $wgUser->getOption('rclimit') );
70 $this->opts['target'] = $target;
71 $this->opts['topOnly'] = $wgRequest->getBool( 'topOnly' );
73 $nt = Title::makeTitleSafe( NS_USER, $target );
74 if( !$nt ) {
75 $wgOut->addHTML( $this->getForm() );
76 return;
78 $id = User::idFromName( $nt->getText() );
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 $wgUser->getSkin()->setRelevantUser( $user );
88 } else {
89 $wgOut->setSubtitle( wfMsgHtml( 'sp-contributions-newbies-sub') );
90 $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'sp-contributions-newbies-title' ) ) );
93 if( ( $ns = $wgRequest->getVal( 'namespace', null ) ) !== null && $ns !== '' ) {
94 $this->opts['namespace'] = intval( $ns );
95 } else {
96 $this->opts['namespace'] = '';
99 $this->opts['tagFilter'] = (string) $wgRequest->getVal( 'tagFilter' );
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';
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' );
117 // Add RSS/atom links
118 $this->setSyndicated();
119 $feedType = $wgRequest->getVal( 'feed' );
120 if( $feedType ) {
121 return $this->feed( $feedType );
124 if ( wfRunHooks( 'SpecialContributionsBeforeMainOutput', array( $id ) ) ) {
126 $wgOut->addHTML( $this->getForm() );
128 $pager = new ContribsPager( array(
129 'target' => $target,
130 'namespace' => $this->opts['namespace'],
131 'year' => $this->opts['year'],
132 'month' => $this->opts['month'],
133 'deletedOnly' => $this->opts['deletedOnly'],
134 'topOnly' => $this->opts['topOnly'],
135 ) );
136 if( !$pager->getNumRows() ) {
137 $wgOut->addWikiMsg( 'nocontribs', $target );
138 } else {
139 # Show a message about slave lag, if applicable
140 if( ( $lag = $pager->getDatabase()->getLag() ) > 0 )
141 $wgOut->showLagWarning( $lag );
143 $wgOut->addHTML(
144 '<p>' . $pager->getNavigationBar() . '</p>' .
145 $pager->getBody() .
146 '<p>' . $pager->getNavigationBar() . '</p>'
149 $wgOut->preventClickjacking( $pager->getPreventClickjacking() );
152 # Show the appropriate "footer" message - WHOIS tools, etc.
153 if( $target != 'newbies' ) {
154 $message = 'sp-contributions-footer';
155 if ( IP::isIPAddress( $target ) ) {
156 $message = 'sp-contributions-footer-anon';
157 } else {
158 $user = User::newFromName( $target );
159 if ( !$user || $user->isAnon() ) {
160 // No message for non-existing users
161 return;
165 if( !wfMessage( $message, $target )->isDisabled() ) {
166 $wgOut->wrapWikiMsg(
167 "<div class='mw-contributions-footer'>\n$1\n</div>",
168 array( $message, $target ) );
174 protected function setSyndicated() {
175 global $wgOut;
176 $wgOut->setSyndicated( true );
177 $wgOut->setFeedAppendQuery( wfArrayToCGI( $this->opts ) );
181 * Generates the subheading with links
182 * @param $nt Title object for the target
183 * @param $id Integer: User ID for the target
184 * @return String: appropriately-escaped HTML to be output literally
185 * @todo Fixme: almost the same as getSubTitle in SpecialDeletedContributions.php. Could be combined.
187 protected function contributionsSub( $nt, $id ) {
188 global $wgLang, $wgUser, $wgOut;
190 $sk = $wgUser->getSkin();
192 if ( $id === null ) {
193 $user = htmlspecialchars( $nt->getText() );
194 } else {
195 $user = $sk->link( $nt, htmlspecialchars( $nt->getText() ) );
197 $userObj = User::newFromName( $nt->getText(), /* check for username validity not needed */ false );
198 $talk = $nt->getTalkPage();
199 if( $talk ) {
200 $tools = self::getUserLinks( $nt, $talk, $userObj, $wgUser );
201 $links = $wgLang->pipeList( $tools );
203 // Show a note if the user is blocked and display the last block log entry.
204 if ( $userObj->isBlocked() ) {
205 LogEventsList::showLogExtract(
206 $wgOut,
207 'block',
208 $nt->getPrefixedText(),
210 array(
211 'lim' => 1,
212 'showIfEmpty' => false,
213 'msgKey' => array(
214 $userObj->isAnon() ?
215 'sp-contributions-blocked-notice-anon' :
216 'sp-contributions-blocked-notice',
217 $nt->getText() # Support GENDER in 'sp-contributions-blocked-notice'
219 'offset' => '' # don't use $wgRequest parameter offset
225 // Old message 'contribsub' had one parameter, but that doesn't work for
226 // languages that want to put the "for" bit right after $user but before
227 // $links. If 'contribsub' is around, use it for reverse compatibility,
228 // otherwise use 'contribsub2'.
229 if( wfEmptyMsg( 'contribsub' ) ) {
230 return wfMsgHtml( 'contribsub2', $user, $links );
231 } else {
232 return wfMsgHtml( 'contribsub', "$user ($links)" );
237 * Links to different places.
238 * @param $userpage Title: Target user page
239 * @param $talkpage Title: Talk page
240 * @param $target User: Target user object
241 * @param $subject User: The viewing user ($wgUser is still checked in some cases, like userrights page!!)
243 public static function getUserLinks( Title $userpage, Title $talkpage, User $target, User $subject ) {
245 $sk = $subject->getSkin();
246 $id = $target->getId();
247 $username = $target->getName();
249 $tools[] = $sk->link( $talkpage, wfMsgHtml( 'sp-contributions-talk' ) );
251 if( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) {
252 if( $subject->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
253 if ( $target->isBlocked() ) {
254 $tools[] = $sk->linkKnown( # Change block link
255 SpecialPage::getTitleFor( 'Block', $username ),
256 wfMsgHtml( 'change-blocklink' )
258 $tools[] = $sk->linkKnown( # Unblock link
259 SpecialPage::getTitleFor( 'Unblock', $username ),
260 wfMsgHtml( 'unblocklink' )
262 } else { # User is not blocked
263 $tools[] = $sk->linkKnown( # Block link
264 SpecialPage::getTitleFor( 'Block', $username ),
265 wfMsgHtml( 'blocklink' )
269 # Block log link
270 $tools[] = $sk->linkKnown(
271 SpecialPage::getTitleFor( 'Log' ),
272 wfMsgHtml( 'sp-contributions-blocklog' ),
273 array(),
274 array(
275 'type' => 'block',
276 'page' => $userpage->getPrefixedText()
280 # Uploads
281 $tools[] = $sk->linkKnown(
282 SpecialPage::getTitleFor( 'Listfiles', $username ),
283 wfMsgHtml( 'sp-contributions-uploads' )
286 # Other logs link
287 $tools[] = $sk->linkKnown(
288 SpecialPage::getTitleFor( 'Log' ),
289 wfMsgHtml( 'sp-contributions-logs' ),
290 array(),
291 array( 'user' => $username )
294 # Add link to deleted user contributions for priviledged users
295 if( $subject->isAllowed( 'deletedhistory' ) ) {
296 $tools[] = $sk->linkKnown(
297 SpecialPage::getTitleFor( 'DeletedContributions', $username ),
298 wfMsgHtml( 'sp-contributions-deleted' )
302 # Add a link to change user rights for privileged users
303 $userrightsPage = new UserrightsPage();
304 if( $id !== null && $userrightsPage->userCanChangeRights( $target ) ) {
305 $tools[] = $sk->linkKnown(
306 SpecialPage::getTitleFor( 'Userrights', $username ),
307 wfMsgHtml( 'sp-contributions-userrights' )
311 wfRunHooks( 'ContributionsToolLinks', array( $id, $userpage, &$tools ) );
312 return $tools;
316 * Generates the namespace selector form with hidden attributes.
317 * @return String: HTML fragment
319 protected function getForm() {
320 global $wgScript;
322 $this->opts['title'] = $this->getTitle()->getPrefixedText();
323 if( !isset( $this->opts['target'] ) ) {
324 $this->opts['target'] = '';
325 } else {
326 $this->opts['target'] = str_replace( '_' , ' ' , $this->opts['target'] );
329 if( !isset( $this->opts['namespace'] ) ) {
330 $this->opts['namespace'] = '';
333 if( !isset( $this->opts['contribs'] ) ) {
334 $this->opts['contribs'] = 'user';
337 if( !isset( $this->opts['year'] ) ) {
338 $this->opts['year'] = '';
341 if( !isset( $this->opts['month'] ) ) {
342 $this->opts['month'] = '';
345 if( $this->opts['contribs'] == 'newbie' ) {
346 $this->opts['target'] = '';
349 if( !isset( $this->opts['tagFilter'] ) ) {
350 $this->opts['tagFilter'] = '';
353 if( !isset( $this->opts['topOnly'] ) ) {
354 $this->opts['topOnly'] = false;
357 $f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'class' => 'mw-contributions-form' ) );
359 # Add hidden params for tracking except for parameters in $skipParameters
360 $skipParameters = array( 'namespace', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly' );
361 foreach ( $this->opts as $name => $value ) {
362 if( in_array( $name, $skipParameters ) ) {
363 continue;
365 $f .= "\t" . Html::hidden( $name, $value ) . "\n";
368 $tagFilter = ChangeTags::buildTagFilterSelector( $this->opts['tagFilter'] );
370 $f .= Xml::fieldset( wfMsg( 'sp-contributions-search' ) ) .
371 Xml::radioLabel( wfMsgExt( 'sp-contributions-newbies', array( 'parsemag' ) ),
372 'contribs', 'newbie' , 'newbie', $this->opts['contribs'] == 'newbie' ) . '<br />' .
373 Xml::radioLabel( wfMsgExt( 'sp-contributions-username', array( 'parsemag' ) ),
374 'contribs' , 'user', 'user', $this->opts['contribs'] == 'user' ) . ' ' .
375 Html::input( 'target', $this->opts['target'], 'text', array(
376 'size' => '20',
377 'required' => ''
378 ) + ( $this->opts['target'] ? array() : array( 'autofocus' ) ) ) . ' '.
379 Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
380 Xml::label( wfMsg( 'namespace' ), 'namespace' ) . ' ' .
381 Xml::namespaceSelector( $this->opts['namespace'], '' )
383 Xml::checkLabel( wfMsg( 'history-show-deleted' ),
384 'deletedOnly', 'mw-show-deleted-only', $this->opts['deletedOnly'] ) . '<br />' .
385 Xml::tags( 'p', null, Xml::checkLabel( wfMsg( 'sp-contributions-toponly' ),
386 'topOnly', 'mw-show-top-only', $this->opts['topOnly'] ) ) .
387 ( $tagFilter ? Xml::tags( 'p', null, implode( '&#160;', $tagFilter ) ) : '' ) .
388 Html::rawElement( 'p', array( 'style' => 'white-space: nowrap' ),
389 Xml::dateMenu( $this->opts['year'], $this->opts['month'] ) . ' ' .
390 Xml::submitButton( wfMsg( 'sp-contributions-submit' ) )
391 ) . ' ';
392 $explain = wfMsgExt( 'sp-contributions-explain', 'parseinline' );
393 if( !wfEmptyMsg( 'sp-contributions-explain' ) ) {
394 $f .= "<p id='mw-sp-contributions-explain'>{$explain}</p>";
396 $f .= Xml::closeElement('fieldset' ) .
397 Xml::closeElement( 'form' );
398 return $f;
402 * Output a subscription feed listing recent edits to this page.
403 * @param $type String
405 protected function feed( $type ) {
406 global $wgFeed, $wgFeedClasses, $wgFeedLimit, $wgOut;
408 if( !$wgFeed ) {
409 $wgOut->addWikiMsg( 'feed-unavailable' );
410 return;
413 if( !isset( $wgFeedClasses[$type] ) ) {
414 $wgOut->addWikiMsg( 'feed-invalid' );
415 return;
418 $feed = new $wgFeedClasses[$type](
419 $this->feedTitle(),
420 wfMsgExt( 'tagline', 'parsemag' ),
421 $this->getTitle()->getFullUrl() . "/" . urlencode($this->opts['target'])
424 // Already valid title
425 $nt = Title::makeTitleSafe( NS_USER, $this->opts['target'] );
426 $target = $this->opts['target'] == 'newbies' ? 'newbies' : $nt->getText();
428 $pager = new ContribsPager( array(
429 'target' => $target,
430 'namespace' => $this->opts['namespace'],
431 'year' => $this->opts['year'],
432 'month' => $this->opts['month'],
433 'tagFilter' => $this->opts['tagFilter'],
434 'deletedOnly' => $this->opts['deletedOnly'],
435 'topOnly' => $this->opts['topOnly'],
436 ) );
438 $pager->mLimit = min( $this->opts['limit'], $wgFeedLimit );
440 $feed->outHeader();
441 if( $pager->getNumRows() > 0 ) {
442 foreach ( $pager->mResult as $row ) {
443 $feed->outItem( $this->feedItem( $row ) );
446 $feed->outFooter();
449 protected function feedTitle() {
450 global $wgLanguageCode, $wgSitename;
451 $desc = $this->getDescription();
452 return "$wgSitename - $desc [$wgLanguageCode]";
455 protected function feedItem( $row ) {
456 $title = Title::MakeTitle( intval( $row->page_namespace ), $row->page_title );
457 if( $title ) {
458 $date = $row->rev_timestamp;
459 $comments = $title->getTalkPage()->getFullURL();
460 $revision = Revision::newFromTitle( $title, $row->rev_id );
462 return new FeedItem(
463 $title->getPrefixedText(),
464 $this->feedItemDesc( $revision ),
465 $title->getFullURL(),
466 $date,
467 $this->feedItemAuthor( $revision ),
468 $comments
470 } else {
471 return null;
476 * @param $revision Revision
477 * @return string
479 protected function feedItemAuthor( $revision ) {
480 return $revision->getUserText();
484 * @param $revision Revision
485 * @return string
487 protected function feedItemDesc( $revision ) {
488 if( $revision ) {
489 return '<p>' . htmlspecialchars( $revision->getUserText() ) . wfMsgForContent( 'colon-separator' ) .
490 htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) .
491 "</p>\n<hr />\n<div>" .
492 nl2br( htmlspecialchars( $revision->getText() ) ) . "</div>";
494 return '';
499 * Pager for Special:Contributions
500 * @ingroup SpecialPage Pager
502 class ContribsPager extends ReverseChronologicalPager {
503 public $mDefaultDirection = true;
504 var $messages, $target;
505 var $namespace = '', $mDb;
506 var $preventClickjacking = false;
508 function __construct( $options ) {
509 parent::__construct();
511 $msgs = array( 'uctop', 'diff', 'newarticle', 'rollbacklink', 'diff', 'hist', 'rev-delundel', 'pipe-separator' );
513 foreach( $msgs as $msg ) {
514 $this->messages[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
517 $this->target = isset( $options['target'] ) ? $options['target'] : '';
518 $this->namespace = isset( $options['namespace'] ) ? $options['namespace'] : '';
519 $this->tagFilter = isset( $options['tagFilter'] ) ? $options['tagFilter'] : false;
521 $this->deletedOnly = !empty( $options['deletedOnly'] );
522 $this->topOnly = !empty( $options['topOnly'] );
524 $year = isset( $options['year'] ) ? $options['year'] : false;
525 $month = isset( $options['month'] ) ? $options['month'] : false;
526 $this->getDateCond( $year, $month );
528 $this->mDb = wfGetDB( DB_SLAVE, 'contributions' );
531 function getDefaultQuery() {
532 $query = parent::getDefaultQuery();
533 $query['target'] = $this->target;
534 return $query;
537 function getQueryInfo() {
538 global $wgUser;
539 list( $tables, $index, $userCond, $join_cond ) = $this->getUserCond();
541 $conds = array_merge( $userCond, $this->getNamespaceCond() );
542 // Paranoia: avoid brute force searches (bug 17342)
543 if( !$wgUser->isAllowed( 'deletedhistory' ) ) {
544 $conds[] = $this->mDb->bitAnd('rev_deleted',Revision::DELETED_USER) . ' = 0';
545 } else if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
546 $conds[] = $this->mDb->bitAnd('rev_deleted',Revision::SUPPRESSED_USER) .
547 ' != ' . Revision::SUPPRESSED_USER;
549 $join_cond['page'] = array( 'INNER JOIN', 'page_id=rev_page' );
551 $queryInfo = array(
552 'tables' => $tables,
553 'fields' => array(
554 'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'page_is_redirect',
555 'page_len','rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment',
556 'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted'
558 'conds' => $conds,
559 'options' => array( 'USE INDEX' => array('revision' => $index) ),
560 'join_conds' => $join_cond
563 ChangeTags::modifyDisplayQuery(
564 $queryInfo['tables'],
565 $queryInfo['fields'],
566 $queryInfo['conds'],
567 $queryInfo['join_conds'],
568 $queryInfo['options'],
569 $this->tagFilter
572 wfRunHooks( 'ContribsPager::getQueryInfo', array( &$this, &$queryInfo ) );
573 return $queryInfo;
576 function getUserCond() {
577 $condition = array();
578 $join_conds = array();
579 if( $this->target == 'newbies' ) {
580 $tables = array( 'user_groups', 'page', 'revision' );
581 $max = $this->mDb->selectField( 'user', 'max(user_id)', false, __METHOD__ );
582 $condition[] = 'rev_user >' . (int)($max - $max / 100);
583 $condition[] = 'ug_group IS NULL';
584 $index = 'user_timestamp';
585 # FIXME: other groups may have 'bot' rights
586 $join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" );
587 } else {
588 $tables = array( 'page', 'revision' );
589 $condition['rev_user_text'] = $this->target;
590 $index = 'usertext_timestamp';
592 if( $this->deletedOnly ) {
593 $condition[] = "rev_deleted != '0'";
595 if( $this->topOnly ) {
596 $condition[] = "rev_id = page_latest";
598 return array( $tables, $index, $condition, $join_conds );
601 function getNamespaceCond() {
602 if( $this->namespace !== '' ) {
603 return array( 'page_namespace' => (int)$this->namespace );
604 } else {
605 return array();
609 function getIndexField() {
610 return 'rev_timestamp';
613 function getStartBody() {
614 return "<ul>\n";
617 function getEndBody() {
618 return "</ul>\n";
622 * Generates each row in the contributions list.
624 * Contributions which are marked "top" are currently on top of the history.
625 * For these contributions, a [rollback] link is shown for users with roll-
626 * back privileges. The rollback link restores the most recent version that
627 * was not written by the target user.
629 * @todo This would probably look a lot nicer in a table.
631 function formatRow( $row ) {
632 global $wgUser, $wgLang, $wgContLang;
633 wfProfileIn( __METHOD__ );
635 $sk = $this->getSkin();
636 $rev = new Revision( $row );
637 $classes = array();
639 $page = Title::newFromRow( $row );
640 $link = $sk->link(
641 $page,
642 htmlspecialchars( $page->getPrefixedText() ),
643 array(),
644 $page->isRedirect() ? array( 'redirect' => 'no' ) : array()
646 # Mark current revisions
647 $topmarktext = '';
648 if( $row->rev_id == $row->page_latest ) {
649 $topmarktext .= '<span class="mw-uctop">' . $this->messages['uctop'] . '</span>';
650 # Add rollback link
651 if( !$row->page_is_new && $page->quickUserCan( 'rollback' )
652 && $page->quickUserCan( 'edit' ) )
654 $this->preventClickjacking();
655 $topmarktext .= ' '.$sk->generateRollback( $rev );
658 # Is there a visible previous revision?
659 if( $rev->userCan( Revision::DELETED_TEXT ) && $rev->getParentId() !== 0 ) {
660 $difftext = $sk->linkKnown(
661 $page,
662 $this->messages['diff'],
663 array(),
664 array(
665 'diff' => 'prev',
666 'oldid' => $row->rev_id
669 } else {
670 $difftext = $this->messages['diff'];
672 $histlink = $sk->linkKnown(
673 $page,
674 $this->messages['hist'],
675 array(),
676 array( 'action' => 'history' )
679 $comment = $wgContLang->getDirMark() . $sk->revComment( $rev, false, true );
680 $date = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true );
681 if( $rev->userCan( Revision::DELETED_TEXT ) ) {
682 $d = $sk->linkKnown(
683 $page,
684 htmlspecialchars($date),
685 array(),
686 array( 'oldid' => intval( $row->rev_id ) )
688 } else {
689 $d = htmlspecialchars( $date );
691 if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
692 $d = '<span class="history-deleted">' . $d . '</span>';
695 if( $this->target == 'newbies' ) {
696 $userlink = ' . . ' . $sk->userLink( $row->rev_user, $row->rev_user_text );
697 $userlink .= ' ' . wfMsg( 'parentheses', $sk->userTalkLink( $row->rev_user, $row->rev_user_text ) ) . ' ';
698 } else {
699 $userlink = '';
702 if( $rev->getParentId() === 0 ) {
703 $nflag = ChangesList::flag( 'newpage' );
704 } else {
705 $nflag = '';
708 if( $rev->isMinor() ) {
709 $mflag = ChangesList::flag( 'minor' );
710 } else {
711 $mflag = '';
714 // Don't show useless link to people who cannot hide revisions
715 $canHide = $wgUser->isAllowed( 'deleterevision' );
716 if( $canHide || ($rev->getVisibility() && $wgUser->isAllowed('deletedhistory')) ) {
717 if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
718 $del = $this->mSkin->revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
719 } else {
720 $query = array(
721 'type' => 'revision',
722 'target' => $page->getPrefixedDbkey(),
723 'ids' => $rev->getId()
725 $del = $this->mSkin->revDeleteLink( $query,
726 $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide );
728 $del .= ' ';
729 } else {
730 $del = '';
733 $diffHistLinks = '(' . $difftext . $this->messages['pipe-separator'] . $histlink . ')';
734 $ret = "{$del}{$d} {$diffHistLinks} {$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}";
736 # Denote if username is redacted for this edit
737 if( $rev->isDeleted( Revision::DELETED_USER ) ) {
738 $ret .= " <strong>" . wfMsgHtml('rev-deleted-user-contribs') . "</strong>";
741 # Tags, if any.
742 list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'contributions' );
743 $classes = array_merge( $classes, $newClasses );
744 $ret .= " $tagSummary";
746 // Let extensions add data
747 wfRunHooks( 'ContributionsLineEnding', array( &$this, &$ret, $row ) );
749 $classes = implode( ' ', $classes );
750 $ret = "<li class=\"$classes\">$ret</li>\n";
751 wfProfileOut( __METHOD__ );
752 return $ret;
756 * Get the Database object in use
758 * @return DatabaseBase
760 public function getDatabase() {
761 return $this->mDb;
765 * Overwrite Pager function and return a helpful comment
767 function getSqlComment() {
768 if ( $this->namespace || $this->deletedOnly ) {
769 return 'contributions page filtered for namespace or RevisionDeleted edits'; // potentially slow, see CR r58153
770 } else {
771 return 'contributions page unfiltered';
775 protected function preventClickjacking() {
776 $this->preventClickjacking = true;
779 public function getPreventClickjacking() {
780 return $this->preventClickjacking;