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
21 * @ingroup SpecialPage
25 * Special:Contributions, show user contributions in a paged list
27 * @ingroup SpecialPage
30 class SpecialContributions
extends SpecialPage
{
34 public function __construct() {
35 parent
::__construct( 'Contributions' );
38 public function execute( $par ) {
40 $this->outputHeader();
41 $out = $this->getOutput();
42 $out->addModuleStyles( 'mediawiki.special' );
44 $this->opts
= array();
45 $request = $this->getRequest();
47 if ( $par !== null ) {
50 $target = $request->getVal( 'target' );
54 if ( $request->getVal( 'contribs' ) == 'newbie' ) {
56 $this->opts
['contribs'] = 'newbie';
57 } elseif ( $par === 'newbies' ) { // b/c for WMF
59 $this->opts
['contribs'] = 'newbie';
61 $this->opts
['contribs'] = 'user';
64 $this->opts
['deletedOnly'] = $request->getBool( 'deletedOnly' );
66 if ( !strlen( $target ) ) {
67 $out->addHTML( $this->getForm() );
71 $user = $this->getUser();
73 $this->opts
['limit'] = $request->getInt( 'limit', $user->getOption( 'rclimit' ) );
74 $this->opts
['target'] = $target;
75 $this->opts
['topOnly'] = $request->getBool( 'topOnly' );
77 $nt = Title
::makeTitleSafe( NS_USER
, $target );
79 $out->addHTML( $this->getForm() );
82 $userObj = User
::newFromName( $nt->getText(), false );
84 $out->addHTML( $this->getForm() );
87 $id = $userObj->getID();
89 if ( $this->opts
['contribs'] != 'newbie' ) {
90 $target = $nt->getText();
91 $out->addSubtitle( $this->contributionsSub( $userObj ) );
92 $out->setHTMLTitle( $this->msg( 'pagetitle', $this->msg( 'contributions-title', $target )->plain() ) );
93 $this->getSkin()->setRelevantUser( $userObj );
95 $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub' ) );
96 $out->setHTMLTitle( $this->msg( 'pagetitle', $this->msg( 'sp-contributions-newbies-title' )->plain() ) );
99 if ( ( $ns = $request->getVal( 'namespace', null ) ) !== null && $ns !== '' ) {
100 $this->opts
['namespace'] = intval( $ns );
102 $this->opts
['namespace'] = '';
105 $this->opts
['associated'] = $request->getBool( 'associated' );
107 $this->opts
['nsInvert'] = (bool) $request->getVal( 'nsInvert' );
109 $this->opts
['tagfilter'] = (string) $request->getVal( 'tagfilter' );
111 // Allows reverts to have the bot flag in recent changes. It is just here to
112 // be passed in the form at the top of the page
113 if ( $user->isAllowed( 'markbotedits' ) && $request->getBool( 'bot' ) ) {
114 $this->opts
['bot'] = '1';
117 $skip = $request->getText( 'offset' ) ||
$request->getText( 'dir' ) == 'prev';
118 # Offset overrides year/month selection
120 $this->opts
['year'] = '';
121 $this->opts
['month'] = '';
123 $this->opts
['year'] = $request->getIntOrNull( 'year' );
124 $this->opts
['month'] = $request->getIntOrNull( 'month' );
127 $feedType = $request->getVal( 'feed' );
129 // Maintain some level of backwards compatability
130 // If people request feeds using the old parameters, redirect to API
132 'action' => 'feedcontributions',
133 'feedformat' => $feedType,
136 if ( $this->opts
['topOnly'] ) {
137 $apiParams['toponly'] = true;
139 if ( $this->opts
['deletedOnly'] ) {
140 $apiParams['deletedonly'] = true;
142 if ( $this->opts
['tagfilter'] !== '' ) {
143 $apiParams['tagfilter'] = $this->opts
['tagfilter'];
145 if ( $this->opts
['namespace'] !== '' ) {
146 $apiParams['namespace'] = $this->opts
['namespace'];
148 if ( $this->opts
['year'] !== null ) {
149 $apiParams['year'] = $this->opts
['year'];
151 if ( $this->opts
['month'] !== null ) {
152 $apiParams['month'] = $this->opts
['month'];
155 $url = wfScript( 'api' ) . '?' . wfArrayToCGI( $apiParams );
157 $out->redirect( $url, '301' );
161 // Add RSS/atom links
162 $this->addFeedLinks( array( 'action' => 'feedcontributions', 'user' => $target ) );
164 if ( wfRunHooks( 'SpecialContributionsBeforeMainOutput', array( $id ) ) ) {
166 $out->addHTML( $this->getForm() );
168 $pager = new ContribsPager( $this->getContext(), array(
170 'contribs' => $this->opts
['contribs'],
171 'namespace' => $this->opts
['namespace'],
172 'year' => $this->opts
['year'],
173 'month' => $this->opts
['month'],
174 'deletedOnly' => $this->opts
['deletedOnly'],
175 'topOnly' => $this->opts
['topOnly'],
176 'nsInvert' => $this->opts
['nsInvert'],
177 'associated' => $this->opts
['associated'],
179 if ( !$pager->getNumRows() ) {
180 $out->addWikiMsg( 'nocontribs', $target );
182 # Show a message about slave lag, if applicable
183 $lag = wfGetLB()->safeGetLag( $pager->getDatabase() );
185 $out->showLagWarning( $lag );
188 '<p>' . $pager->getNavigationBar() . '</p>' .
190 '<p>' . $pager->getNavigationBar() . '</p>'
193 $out->preventClickjacking( $pager->getPreventClickjacking() );
196 # Show the appropriate "footer" message - WHOIS tools, etc.
197 if ( $this->opts
['contribs'] == 'newbie' ) {
198 $message = 'sp-contributions-footer-newbies';
199 } elseif( IP
::isIPAddress( $target ) ) {
200 $message = 'sp-contributions-footer-anon';
201 } elseif( $userObj->isAnon() ) {
202 // No message for non-existing users
205 $message = 'sp-contributions-footer';
209 if ( !$this->msg( $message, $target )->isDisabled() ) {
211 "<div class='mw-contributions-footer'>\n$1\n</div>",
212 array( $message, $target ) );
219 * Generates the subheading with links
220 * @param $userObj User object for the target
221 * @return String: appropriately-escaped HTML to be output literally
222 * @todo FIXME: Almost the same as getSubTitle in SpecialDeletedContributions.php. Could be combined.
224 protected function contributionsSub( $userObj ) {
225 if ( $userObj->isAnon() ) {
226 $user = htmlspecialchars( $userObj->getName() );
228 $user = Linker
::link( $userObj->getUserPage(), htmlspecialchars( $userObj->getName() ) );
230 $nt = $userObj->getUserPage();
231 $talk = $userObj->getTalkPage();
234 $tools = $this->getUserLinks( $nt, $talk, $userObj );
235 $links = $this->getLanguage()->pipeList( $tools );
237 // Show a note if the user is blocked and display the last block log entry.
238 // Do not expose the autoblocks, since that may lead to a leak of accounts' IPs,
239 // and also this will display a totally irrelevant log entry as a current block.
240 if ( $userObj->isBlocked() && $userObj->getBlock()->getType() != Block
::TYPE_AUTO
) {
241 $out = $this->getOutput(); // showLogExtract() wants first parameter by reference
242 LogEventsList
::showLogExtract(
249 'showIfEmpty' => false,
252 'sp-contributions-blocked-notice-anon' :
253 'sp-contributions-blocked-notice',
254 $userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice'
256 'offset' => '' # don't use WebRequest parameter offset
262 // Old message 'contribsub' had one parameter, but that doesn't work for
263 // languages that want to put the "for" bit right after $user but before
264 // $links. If 'contribsub' is around, use it for reverse compatibility,
265 // otherwise use 'contribsub2'.
266 // @todo Should this be removed at some point?
267 $oldMsg = $this->msg( 'contribsub' );
268 if ( $oldMsg->exists() ) {
269 $linksWithParentheses = $this->msg( 'parentheses' )->rawParams( $links )->escaped();
270 return $oldMsg->rawParams( "$user $linksWithParentheses" );
272 return $this->msg( 'contribsub2' )->rawParams( $user, $links );
277 * Links to different places.
278 * @param $userpage Title: Target user page
279 * @param $talkpage Title: Talk page
280 * @param $target User: Target user object
283 public function getUserLinks( Title
$userpage, Title
$talkpage, User
$target ) {
285 $id = $target->getId();
286 $username = $target->getName();
288 $tools[] = Linker
::link( $talkpage, $this->msg( 'sp-contributions-talk' )->escaped() );
290 if ( ( $id !== null ) ||
( $id === null && IP
::isIPAddress( $username ) ) ) {
291 if ( $this->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
292 if ( $target->isBlocked() ) {
293 $tools[] = Linker
::linkKnown( # Change block link
294 SpecialPage
::getTitleFor( 'Block', $username ),
295 $this->msg( 'change-blocklink' )->escaped()
297 $tools[] = Linker
::linkKnown( # Unblock link
298 SpecialPage
::getTitleFor( 'Unblock', $username ),
299 $this->msg( 'unblocklink' )->escaped()
301 } else { # User is not blocked
302 $tools[] = Linker
::linkKnown( # Block link
303 SpecialPage
::getTitleFor( 'Block', $username ),
304 $this->msg( 'blocklink' )->escaped()
309 $tools[] = Linker
::linkKnown(
310 SpecialPage
::getTitleFor( 'Log', 'block' ),
311 $this->msg( 'sp-contributions-blocklog' )->escaped(),
314 'page' => $userpage->getPrefixedText()
319 $tools[] = Linker
::linkKnown(
320 SpecialPage
::getTitleFor( 'Listfiles', $username ),
321 $this->msg( 'sp-contributions-uploads' )->escaped()
325 $tools[] = Linker
::linkKnown(
326 SpecialPage
::getTitleFor( 'Log', $username ),
327 $this->msg( 'sp-contributions-logs' )->escaped()
330 # Add link to deleted user contributions for priviledged users
331 if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
332 $tools[] = Linker
::linkKnown(
333 SpecialPage
::getTitleFor( 'DeletedContributions', $username ),
334 $this->msg( 'sp-contributions-deleted' )->escaped()
338 # Add a link to change user rights for privileged users
339 $userrightsPage = new UserrightsPage();
340 $userrightsPage->setContext( $this->getContext() );
341 if ( $userrightsPage->userCanChangeRights( $target ) ) {
342 $tools[] = Linker
::linkKnown(
343 SpecialPage
::getTitleFor( 'Userrights', $username ),
344 $this->msg( 'sp-contributions-userrights' )->escaped()
348 wfRunHooks( 'ContributionsToolLinks', array( $id, $userpage, &$tools ) );
353 * Generates the namespace selector form with hidden attributes.
354 * @return String: HTML fragment
356 protected function getForm() {
359 $this->opts
['title'] = $this->getTitle()->getPrefixedText();
360 if ( !isset( $this->opts
['target'] ) ) {
361 $this->opts
['target'] = '';
363 $this->opts
['target'] = str_replace( '_' , ' ' , $this->opts
['target'] );
366 if ( !isset( $this->opts
['namespace'] ) ) {
367 $this->opts
['namespace'] = '';
370 if ( !isset( $this->opts
['nsInvert'] ) ) {
371 $this->opts
['nsInvert'] = '';
374 if ( !isset( $this->opts
['associated'] ) ) {
375 $this->opts
['associated'] = false;
378 if ( !isset( $this->opts
['contribs'] ) ) {
379 $this->opts
['contribs'] = 'user';
382 if ( !isset( $this->opts
['year'] ) ) {
383 $this->opts
['year'] = '';
386 if ( !isset( $this->opts
['month'] ) ) {
387 $this->opts
['month'] = '';
390 if ( $this->opts
['contribs'] == 'newbie' ) {
391 $this->opts
['target'] = '';
394 if ( !isset( $this->opts
['tagfilter'] ) ) {
395 $this->opts
['tagfilter'] = '';
398 if ( !isset( $this->opts
['topOnly'] ) ) {
399 $this->opts
['topOnly'] = false;
402 $form = Xml
::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'class' => 'mw-contributions-form' ) );
404 # Add hidden params for tracking except for parameters in $skipParameters
405 $skipParameters = array( 'namespace', 'nsInvert', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly', 'associated' );
406 foreach ( $this->opts
as $name => $value ) {
407 if ( in_array( $name, $skipParameters ) ) {
410 $form .= "\t" . Html
::hidden( $name, $value ) . "\n";
413 $tagFilter = ChangeTags
::buildTagFilterSelector( $this->opts
['tagfilter'] );
417 Xml
::tags( 'td', array( 'class' => 'mw-label' ), array_shift( $tagFilter ) ) .
418 Xml
::tags( 'td', array( 'class' => 'mw-input' ), implode( ' ', $tagFilter ) );
420 $filterSelection = Xml
::tags( 'td', array( 'colspan' => 2 ), '' );
423 $targetSelection = Xml
::tags( 'td', array( 'colspan' => 2 ),
425 $this->msg( 'sp-contributions-newbies' )->text(),
429 $this->opts
['contribs'] == 'newbie',
430 array( 'class' => 'mw-input' )
433 $this->msg( 'sp-contributions-username' )->text(),
437 $this->opts
['contribs'] == 'user',
438 array( 'class' => 'mw-input' )
442 $this->opts
['target'],
444 array( 'size' => '20', 'required' => '', 'class' => 'mw-input' ) +
445 ( $this->opts
['target'] ?
array() : array( 'autofocus' )
450 $namespaceSelection =
451 Xml
::tags( 'td', array( 'class' => 'mw-label' ),
453 $this->msg( 'namespace' )->text(),
458 Xml
::tags( 'td', null,
459 Html
::namespaceSelector( array(
460 'selected' => $this->opts
['namespace'],
463 'name' => 'namespace',
465 'class' => 'namespaceselector',
468 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
470 $this->msg( 'invert' )->text(),
473 $this->opts
['nsInvert'],
474 array( 'title' => $this->msg( 'tooltip-invert' )->text(), 'class' => 'mw-input' )
477 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
479 $this->msg( 'namespace_association' )->text(),
482 $this->opts
['associated'],
483 array( 'title' => $this->msg( 'tooltip-namespace_association' )->text(), 'class' => 'mw-input' )
488 $extraOptions = Xml
::tags( 'td', array( 'colspan' => 2 ),
489 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
491 $this->msg( 'history-show-deleted' )->text(),
493 'mw-show-deleted-only',
494 $this->opts
['deletedOnly'],
495 array( 'class' => 'mw-input' )
498 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
500 $this->msg( 'sp-contributions-toponly' )->text(),
503 $this->opts
['topOnly'],
504 array( 'class' => 'mw-input' )
509 $dateSelectionAndSubmit = Xml
::tags( 'td', array( 'colspan' => 2 ),
515 $this->msg( 'sp-contributions-submit' )->text(),
516 array( 'class' => 'mw-submit' )
521 Xml
::fieldset( $this->msg( 'sp-contributions-search' )->text() ) .
522 Xml
::openElement( 'table', array( 'class' => 'mw-contributions-table' ) ) .
523 Xml
::openElement( 'tr' ) .
525 Xml
::closeElement( 'tr' ) .
526 Xml
::openElement( 'tr' ) .
527 $namespaceSelection .
528 Xml
::closeElement( 'tr' ) .
529 Xml
::openElement( 'tr' ) .
531 Xml
::closeElement( 'tr' ) .
532 Xml
::openElement( 'tr' ) .
534 Xml
::closeElement( 'tr' ) .
535 Xml
::openElement( 'tr' ) .
536 $dateSelectionAndSubmit .
537 Xml
::closeElement( 'tr' ) .
538 Xml
::closeElement( 'table' );
540 $explain = $this->msg( 'sp-contributions-explain' );
541 if ( $explain->exists() ) {
542 $form .= "<p id='mw-sp-contributions-explain'>{$explain}</p>";
544 $form .= Xml
::closeElement( 'fieldset' ) .
545 Xml
::closeElement( 'form' );
551 * Pager for Special:Contributions
552 * @ingroup SpecialPage Pager
554 class ContribsPager
extends ReverseChronologicalPager
{
555 public $mDefaultDirection = true;
556 var $messages, $target;
557 var $namespace = '', $mDb;
558 var $preventClickjacking = false;
563 protected $mParentLens;
565 function __construct( IContextSource
$context, array $options ) {
566 parent
::__construct( $context );
568 $msgs = array( 'uctop', 'diff', 'newarticle', 'rollbacklink', 'diff', 'hist', 'rev-delundel', 'pipe-separator' );
570 foreach ( $msgs as $msg ) {
571 $this->messages
[$msg] = $this->msg( $msg )->escaped();
574 $this->target
= isset( $options['target'] ) ?
$options['target'] : '';
575 $this->contribs
= isset( $options['contribs'] ) ?
$options['contribs'] : 'users';
576 $this->namespace = isset( $options['namespace'] ) ?
$options['namespace'] : '';
577 $this->tagFilter
= isset( $options['tagfilter'] ) ?
$options['tagfilter'] : false;
578 $this->nsInvert
= isset( $options['nsInvert'] ) ?
$options['nsInvert'] : false;
579 $this->associated
= isset( $options['associated'] ) ?
$options['associated'] : false;
581 $this->deletedOnly
= !empty( $options['deletedOnly'] );
582 $this->topOnly
= !empty( $options['topOnly'] );
584 $year = isset( $options['year'] ) ?
$options['year'] : false;
585 $month = isset( $options['month'] ) ?
$options['month'] : false;
586 $this->getDateCond( $year, $month );
588 $this->mDb
= wfGetDB( DB_SLAVE
, 'contributions' );
591 function getDefaultQuery() {
592 $query = parent
::getDefaultQuery();
593 $query['target'] = $this->target
;
597 function getQueryInfo() {
598 list( $tables, $index, $userCond, $join_cond ) = $this->getUserCond();
600 $user = $this->getUser();
601 $conds = array_merge( $userCond, $this->getNamespaceCond() );
603 // Paranoia: avoid brute force searches (bug 17342)
604 if ( !$user->isAllowed( 'deletedhistory' ) ) {
605 $conds[] = $this->mDb
->bitAnd( 'rev_deleted', Revision
::DELETED_USER
) . ' = 0';
606 } elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
607 $conds[] = $this->mDb
->bitAnd( 'rev_deleted', Revision
::SUPPRESSED_USER
) .
608 ' != ' . Revision
::SUPPRESSED_USER
;
611 # Don't include orphaned revisions
612 $join_cond['page'] = Revision
::pageJoinCond();
613 # Get the current user name for accounts
614 $join_cond['user'] = Revision
::userJoinCond();
618 'fields' => array_merge(
619 Revision
::selectFields(),
620 Revision
::selectUserFields(),
621 array( 'page_namespace', 'page_title', 'page_is_new',
622 'page_latest', 'page_is_redirect', 'page_len' )
625 'options' => array( 'USE INDEX' => array( 'revision' => $index ) ),
626 'join_conds' => $join_cond
629 ChangeTags
::modifyDisplayQuery(
630 $queryInfo['tables'],
631 $queryInfo['fields'],
633 $queryInfo['join_conds'],
634 $queryInfo['options'],
638 wfRunHooks( 'ContribsPager::getQueryInfo', array( &$this, &$queryInfo ) );
642 function getUserCond() {
643 $condition = array();
644 $join_conds = array();
645 $tables = array( 'revision', 'page', 'user' );
646 if ( $this->contribs
== 'newbie' ) {
647 $tables[] = 'user_groups';
648 $max = $this->mDb
->selectField( 'user', 'max(user_id)', false, __METHOD__
);
649 $condition[] = 'rev_user >' . (int)( $max - $max / 100 );
650 $condition[] = 'ug_group IS NULL';
651 $index = 'user_timestamp';
652 # @todo FIXME: Other groups may have 'bot' rights
653 $join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" );
655 $uid = User
::idFromName( $this->target
);
657 $condition['rev_user'] = $uid;
658 $index = 'user_timestamp';
660 $condition['rev_user_text'] = $this->target
;
661 $index = 'usertext_timestamp';
664 if ( $this->deletedOnly
) {
665 $condition[] = "rev_deleted != '0'";
667 if ( $this->topOnly
) {
668 $condition[] = "rev_id = page_latest";
670 return array( $tables, $index, $condition, $join_conds );
673 function getNamespaceCond() {
674 if ( $this->namespace !== '' ) {
675 $selectedNS = $this->mDb
->addQuotes( $this->namespace );
676 $eq_op = $this->nsInvert ?
'!=' : '=';
677 $bool_op = $this->nsInvert ?
'AND' : 'OR';
679 if ( !$this->associated
) {
680 return array( "page_namespace $eq_op $selectedNS" );
682 $associatedNS = $this->mDb
->addQuotes (
683 MWNamespace
::getAssociated( $this->namespace )
686 "page_namespace $eq_op $selectedNS " .
688 " page_namespace $eq_op $associatedNS"
697 function getIndexField() {
698 return 'rev_timestamp';
701 function doBatchLookups() {
702 $this->mResult
->rewind();
704 foreach ( $this->mResult
as $row ) {
705 if( $row->rev_parent_id
) {
706 $revIds[] = $row->rev_parent_id
;
709 $this->mParentLens
= $this->getParentLengths( $revIds );
710 $this->mResult
->rewind(); // reset
712 # Do a link batch query
713 $this->mResult
->seek( 0 );
714 $batch = new LinkBatch();
715 # Give some pointers to make (last) links
716 foreach ( $this->mResult
as $row ) {
717 if ( $this->contribs
=== 'newbie' ) { // multiple users
718 $batch->add( NS_USER
, $row->user_name
);
719 $batch->add( NS_USER_TALK
, $row->user_name
);
721 $batch->add( $row->page_namespace
, $row->page_title
);
724 $this->mResult
->seek( 0 );
728 * Do a batched query to get the parent revision lengths
729 * @param $revIds array
732 private function getParentLengths( array $revIds ) {
735 return $revLens; // empty
737 wfProfileIn( __METHOD__
);
738 $res = $this->getDatabase()->select( 'revision',
739 array( 'rev_id', 'rev_len' ),
740 array( 'rev_id' => $revIds ),
742 foreach ( $res as $row ) {
743 $revLens[$row->rev_id
] = $row->rev_len
;
745 wfProfileOut( __METHOD__
);
752 function getStartBody() {
759 function getEndBody() {
764 * Generates each row in the contributions list.
766 * Contributions which are marked "top" are currently on top of the history.
767 * For these contributions, a [rollback] link is shown for users with roll-
768 * back privileges. The rollback link restores the most recent version that
769 * was not written by the target user.
771 * @todo This would probably look a lot nicer in a table.
775 function formatRow( $row ) {
776 wfProfileIn( __METHOD__
);
778 $rev = new Revision( $row );
781 $page = Title
::newFromRow( $row );
782 $link = Linker
::link(
784 htmlspecialchars( $page->getPrefixedText() ),
786 $page->isRedirect() ?
array( 'redirect' => 'no' ) : array()
788 # Mark current revisions
790 if ( $row->rev_id
== $row->page_latest
) {
791 $topmarktext .= '<span class="mw-uctop">' . $this->messages
['uctop'] . '</span>';
793 if ( !$row->page_is_new
&& $page->quickUserCan( 'rollback' )
794 && $page->quickUserCan( 'edit' ) )
796 $this->preventClickjacking();
797 $topmarktext .= ' ' . Linker
::generateRollback( $rev );
800 $user = $this->getUser();
801 # Is there a visible previous revision?
802 if ( $rev->userCan( Revision
::DELETED_TEXT
, $user ) && $rev->getParentId() !== 0 ) {
803 $difftext = Linker
::linkKnown(
805 $this->messages
['diff'],
809 'oldid' => $row->rev_id
813 $difftext = $this->messages
['diff'];
815 $histlink = Linker
::linkKnown(
817 $this->messages
['hist'],
819 array( 'action' => 'history' )
822 if ( $row->rev_parent_id
=== null ) {
823 // For some reason rev_parent_id isn't populated for this row.
824 // Its rumoured this is true on wikipedia for some revisions (bug 34922).
825 // Next best thing is to have the total number of bytes.
826 $chardiff = ' . . ' . Linker
::formatRevisionSize( $row->rev_len
) . ' . . ';
828 $parentLen = isset( $this->mParentLens
[$row->rev_parent_id
] ) ?
$this->mParentLens
[$row->rev_parent_id
] : 0;
829 $chardiff = ' . . ' . ChangesList
::showCharacterDifference(
830 $parentLen, $row->rev_len
) . ' . . ';
833 $lang = $this->getLanguage();
834 $comment = $lang->getDirMark() . Linker
::revComment( $rev, false, true );
835 $date = $lang->userTimeAndDate( $row->rev_timestamp
, $user );
836 if ( $rev->userCan( Revision
::DELETED_TEXT
, $user ) ) {
837 $d = Linker
::linkKnown(
839 htmlspecialchars( $date ),
841 array( 'oldid' => intval( $row->rev_id
) )
844 $d = htmlspecialchars( $date );
846 if ( $rev->isDeleted( Revision
::DELETED_TEXT
) ) {
847 $d = '<span class="history-deleted">' . $d . '</span>';
850 # Show user names for /newbies as there may be different users.
851 # Note that we already excluded rows with hidden user names.
852 if ( $this->contribs
== 'newbie' ) {
853 $userlink = ' . . ' . Linker
::userLink( $rev->getUser(), $rev->getUserText() );
854 $userlink .= ' ' . $this->msg( 'parentheses' )->rawParams(
855 Linker
::userTalkLink( $rev->getUser(), $rev->getUserText() ) )->escaped() . ' ';
860 if ( $rev->getParentId() === 0 ) {
861 $nflag = ChangesList
::flag( 'newpage' );
866 if ( $rev->isMinor() ) {
867 $mflag = ChangesList
::flag( 'minor' );
872 $del = Linker
::getRevDeleteLink( $user, $rev, $page );
877 $diffHistLinks = $this->msg( 'parentheses' )->rawParams( $difftext . $this->messages
['pipe-separator'] . $histlink )->escaped();
878 $ret = "{$del}{$d} {$diffHistLinks}{$chardiff}{$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}";
880 # Denote if username is redacted for this edit
881 if ( $rev->isDeleted( Revision
::DELETED_USER
) ) {
882 $ret .= " <strong>" . $this->msg( 'rev-deleted-user-contribs' )->escaped() . "</strong>";
886 list( $tagSummary, $newClasses ) = ChangeTags
::formatSummaryRow( $row->ts_tags
, 'contributions' );
887 $classes = array_merge( $classes, $newClasses );
888 $ret .= " $tagSummary";
890 // Let extensions add data
891 wfRunHooks( 'ContributionsLineEnding', array( &$this, &$ret, $row ) );
893 $classes = implode( ' ', $classes );
894 $ret = "<li class=\"$classes\">$ret</li>\n";
895 wfProfileOut( __METHOD__
);
900 * Get the Database object in use
902 * @return DatabaseBase
904 public function getDatabase() {
909 * Overwrite Pager function and return a helpful comment
912 function getSqlComment() {
913 if ( $this->namespace ||
$this->deletedOnly
) {
914 return 'contributions page filtered for namespace or RevisionDeleted edits'; // potentially slow, see CR r58153
916 return 'contributions page unfiltered';
920 protected function preventClickjacking() {
921 $this->preventClickjacking
= true;
927 public function getPreventClickjacking() {
928 return $this->preventClickjacking
;