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';
58 $this->opts
['contribs'] = 'user';
61 $this->opts
['deletedOnly'] = $request->getBool( 'deletedOnly' );
63 if ( !strlen( $target ) ) {
64 $out->addHTML( $this->getForm() );
68 $user = $this->getUser();
70 $this->opts
['limit'] = $request->getInt( 'limit', $user->getOption( 'rclimit' ) );
71 $this->opts
['target'] = $target;
72 $this->opts
['topOnly'] = $request->getBool( 'topOnly' );
74 $nt = Title
::makeTitleSafe( NS_USER
, $target );
76 $out->addHTML( $this->getForm() );
79 $userObj = User
::newFromName( $nt->getText(), false );
81 $out->addHTML( $this->getForm() );
84 $id = $userObj->getID();
86 if ( $this->opts
['contribs'] != 'newbie' ) {
87 $target = $nt->getText();
88 $out->addSubtitle( $this->contributionsSub( $userObj ) );
89 $out->setHTMLTitle( $this->msg( 'pagetitle', $this->msg( 'contributions-title', $target )->plain() ) );
90 $this->getSkin()->setRelevantUser( $userObj );
92 $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub' ) );
93 $out->setHTMLTitle( $this->msg( 'pagetitle', $this->msg( 'sp-contributions-newbies-title' )->plain() ) );
96 if ( ( $ns = $request->getVal( 'namespace', null ) ) !== null && $ns !== '' ) {
97 $this->opts
['namespace'] = intval( $ns );
99 $this->opts
['namespace'] = '';
102 $this->opts
['associated'] = $request->getBool( 'associated' );
104 $this->opts
['nsInvert'] = (bool) $request->getVal( 'nsInvert' );
106 $this->opts
['tagfilter'] = (string) $request->getVal( 'tagfilter' );
108 // Allows reverts to have the bot flag in recent changes. It is just here to
109 // be passed in the form at the top of the page
110 if ( $user->isAllowed( 'markbotedits' ) && $request->getBool( 'bot' ) ) {
111 $this->opts
['bot'] = '1';
114 $skip = $request->getText( 'offset' ) ||
$request->getText( 'dir' ) == 'prev';
115 # Offset overrides year/month selection
117 $this->opts
['year'] = '';
118 $this->opts
['month'] = '';
120 $this->opts
['year'] = $request->getIntOrNull( 'year' );
121 $this->opts
['month'] = $request->getIntOrNull( 'month' );
124 $feedType = $request->getVal( 'feed' );
126 // Maintain some level of backwards compatability
127 // If people request feeds using the old parameters, redirect to API
129 'action' => 'feedcontributions',
130 'feedformat' => $feedType,
133 if ( $this->opts
['topOnly'] ) {
134 $apiParams['toponly'] = true;
136 if ( $this->opts
['deletedOnly'] ) {
137 $apiParams['deletedonly'] = true;
139 if ( $this->opts
['tagfilter'] !== '' ) {
140 $apiParams['tagfilter'] = $this->opts
['tagfilter'];
142 if ( $this->opts
['namespace'] !== '' ) {
143 $apiParams['namespace'] = $this->opts
['namespace'];
145 if ( $this->opts
['year'] !== null ) {
146 $apiParams['year'] = $this->opts
['year'];
148 if ( $this->opts
['month'] !== null ) {
149 $apiParams['month'] = $this->opts
['month'];
152 $url = wfScript( 'api' ) . '?' . wfArrayToCGI( $apiParams );
154 $out->redirect( $url, '301' );
158 // Add RSS/atom links
159 $this->addFeedLinks( array( 'action' => 'feedcontributions', 'user' => $target ) );
161 if ( wfRunHooks( 'SpecialContributionsBeforeMainOutput', array( $id ) ) ) {
163 $out->addHTML( $this->getForm() );
165 $pager = new ContribsPager( $this->getContext(), array(
167 'contribs' => $this->opts
['contribs'],
168 'namespace' => $this->opts
['namespace'],
169 'year' => $this->opts
['year'],
170 'month' => $this->opts
['month'],
171 'deletedOnly' => $this->opts
['deletedOnly'],
172 'topOnly' => $this->opts
['topOnly'],
173 'nsInvert' => $this->opts
['nsInvert'],
174 'associated' => $this->opts
['associated'],
176 if ( !$pager->getNumRows() ) {
177 $out->addWikiMsg( 'nocontribs', $target );
179 # Show a message about slave lag, if applicable
180 $lag = wfGetLB()->safeGetLag( $pager->getDatabase() );
182 $out->showLagWarning( $lag );
185 '<p>' . $pager->getNavigationBar() . '</p>' .
187 '<p>' . $pager->getNavigationBar() . '</p>'
190 $out->preventClickjacking( $pager->getPreventClickjacking() );
192 # Show the appropriate "footer" message - WHOIS tools, etc.
193 if ( $this->opts
['contribs'] != 'newbie' ) {
194 $message = 'sp-contributions-footer';
195 if ( IP
::isIPAddress( $target ) ) {
196 $message = 'sp-contributions-footer-anon';
198 if ( $userObj->isAnon() ) {
199 // No message for non-existing users
204 if ( !$this->msg( $message, $target )->isDisabled() ) {
206 "<div class='mw-contributions-footer'>\n$1\n</div>",
207 array( $message, $target ) );
214 * Generates the subheading with links
215 * @param $userObj User object for the target
216 * @return String: appropriately-escaped HTML to be output literally
217 * @todo FIXME: Almost the same as getSubTitle in SpecialDeletedContributions.php. Could be combined.
219 protected function contributionsSub( $userObj ) {
220 if ( $userObj->isAnon() ) {
221 $user = htmlspecialchars( $userObj->getName() );
223 $user = Linker
::link( $userObj->getUserPage(), htmlspecialchars( $userObj->getName() ) );
225 $nt = $userObj->getUserPage();
226 $talk = $userObj->getTalkPage();
229 $tools = $this->getUserLinks( $nt, $talk, $userObj );
230 $links = $this->getLanguage()->pipeList( $tools );
232 // Show a note if the user is blocked and display the last block log entry.
233 if ( $userObj->isBlocked() ) {
234 $out = $this->getOutput(); // showLogExtract() wants first parameter by reference
235 LogEventsList
::showLogExtract(
242 'showIfEmpty' => false,
245 'sp-contributions-blocked-notice-anon' :
246 'sp-contributions-blocked-notice',
247 $userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice'
249 'offset' => '' # don't use WebRequest parameter offset
255 // Old message 'contribsub' had one parameter, but that doesn't work for
256 // languages that want to put the "for" bit right after $user but before
257 // $links. If 'contribsub' is around, use it for reverse compatibility,
258 // otherwise use 'contribsub2'.
259 // @todo Should this be removed at some point?
260 $oldMsg = $this->msg( 'contribsub' );
261 if ( $oldMsg->exists() ) {
262 $linksWithParentheses = $this->msg( 'parentheses' )->rawParams( $links )->escaped();
263 return $oldMsg->rawParams( "$user $linksWithParentheses" );
265 return $this->msg( 'contribsub2' )->rawParams( $user, $links );
270 * Links to different places.
271 * @param $userpage Title: Target user page
272 * @param $talkpage Title: Talk page
273 * @param $target User: Target user object
276 public function getUserLinks( Title
$userpage, Title
$talkpage, User
$target ) {
278 $id = $target->getId();
279 $username = $target->getName();
281 $tools[] = Linker
::link( $talkpage, $this->msg( 'sp-contributions-talk' )->escaped() );
283 if ( ( $id !== null ) ||
( $id === null && IP
::isIPAddress( $username ) ) ) {
284 if ( $this->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
285 if ( $target->isBlocked() ) {
286 $tools[] = Linker
::linkKnown( # Change block link
287 SpecialPage
::getTitleFor( 'Block', $username ),
288 $this->msg( 'change-blocklink' )->escaped()
290 $tools[] = Linker
::linkKnown( # Unblock link
291 SpecialPage
::getTitleFor( 'Unblock', $username ),
292 $this->msg( 'unblocklink' )->escaped()
294 } else { # User is not blocked
295 $tools[] = Linker
::linkKnown( # Block link
296 SpecialPage
::getTitleFor( 'Block', $username ),
297 $this->msg( 'blocklink' )->escaped()
302 $tools[] = Linker
::linkKnown(
303 SpecialPage
::getTitleFor( 'Log', 'block' ),
304 $this->msg( 'sp-contributions-blocklog' )->escaped(),
307 'page' => $userpage->getPrefixedText()
312 $tools[] = Linker
::linkKnown(
313 SpecialPage
::getTitleFor( 'Listfiles', $username ),
314 $this->msg( 'sp-contributions-uploads' )->escaped()
318 $tools[] = Linker
::linkKnown(
319 SpecialPage
::getTitleFor( 'Log', $username ),
320 $this->msg( 'sp-contributions-logs' )->escaped()
323 # Add link to deleted user contributions for priviledged users
324 if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
325 $tools[] = Linker
::linkKnown(
326 SpecialPage
::getTitleFor( 'DeletedContributions', $username ),
327 $this->msg( 'sp-contributions-deleted' )->escaped()
331 # Add a link to change user rights for privileged users
332 $userrightsPage = new UserrightsPage();
333 $userrightsPage->setContext( $this->getContext() );
334 if ( $id !== null && $userrightsPage->userCanChangeRights( $target ) ) {
335 $tools[] = Linker
::linkKnown(
336 SpecialPage
::getTitleFor( 'Userrights', $username ),
337 $this->msg( 'sp-contributions-userrights' )->escaped()
341 wfRunHooks( 'ContributionsToolLinks', array( $id, $userpage, &$tools ) );
346 * Generates the namespace selector form with hidden attributes.
347 * @return String: HTML fragment
349 protected function getForm() {
352 $this->opts
['title'] = $this->getTitle()->getPrefixedText();
353 if ( !isset( $this->opts
['target'] ) ) {
354 $this->opts
['target'] = '';
356 $this->opts
['target'] = str_replace( '_' , ' ' , $this->opts
['target'] );
359 if ( !isset( $this->opts
['namespace'] ) ) {
360 $this->opts
['namespace'] = '';
363 if ( !isset( $this->opts
['nsInvert'] ) ) {
364 $this->opts
['nsInvert'] = '';
367 if ( !isset( $this->opts
['associated'] ) ) {
368 $this->opts
['associated'] = false;
371 if ( !isset( $this->opts
['contribs'] ) ) {
372 $this->opts
['contribs'] = 'user';
375 if ( !isset( $this->opts
['year'] ) ) {
376 $this->opts
['year'] = '';
379 if ( !isset( $this->opts
['month'] ) ) {
380 $this->opts
['month'] = '';
383 if ( $this->opts
['contribs'] == 'newbie' ) {
384 $this->opts
['target'] = '';
387 if ( !isset( $this->opts
['tagfilter'] ) ) {
388 $this->opts
['tagfilter'] = '';
391 if ( !isset( $this->opts
['topOnly'] ) ) {
392 $this->opts
['topOnly'] = false;
395 $form = Xml
::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'class' => 'mw-contributions-form' ) );
397 # Add hidden params for tracking except for parameters in $skipParameters
398 $skipParameters = array( 'namespace', 'nsInvert', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly', 'associated' );
399 foreach ( $this->opts
as $name => $value ) {
400 if ( in_array( $name, $skipParameters ) ) {
403 $form .= "\t" . Html
::hidden( $name, $value ) . "\n";
406 $tagFilter = ChangeTags
::buildTagFilterSelector( $this->opts
['tagfilter'] );
410 Xml
::tags( 'td', array( 'class' => 'mw-label' ), array_shift( $tagFilter ) ) .
411 Xml
::tags( 'td', array( 'class' => 'mw-input' ), implode( ' ', $tagFilter ) );
413 $filterSelection = Xml
::tags( 'td', array( 'colspan' => 2 ), '' );
416 $targetSelection = Xml
::tags( 'td', array( 'colspan' => 2 ),
418 $this->msg( 'sp-contributions-newbies' )->text(),
422 $this->opts
['contribs'] == 'newbie',
423 array( 'class' => 'mw-input' )
426 $this->msg( 'sp-contributions-username' )->text(),
430 $this->opts
['contribs'] == 'user',
431 array( 'class' => 'mw-input' )
435 $this->opts
['target'],
437 array( 'size' => '20', 'required' => '', 'class' => 'mw-input' ) +
438 ( $this->opts
['target'] ?
array() : array( 'autofocus' )
443 $namespaceSelection =
444 Xml
::tags( 'td', array( 'class' => 'mw-label' ),
446 $this->msg( 'namespace' )->text(),
451 Xml
::tags( 'td', null,
452 Html
::namespaceSelector( array(
453 'selected' => $this->opts
['namespace'],
456 'name' => 'namespace',
458 'class' => 'namespaceselector',
461 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
463 $this->msg( 'invert' )->text(),
466 $this->opts
['nsInvert'],
467 array( 'title' => $this->msg( 'tooltip-invert' )->text(), 'class' => 'mw-input' )
470 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
472 $this->msg( 'namespace_association' )->text(),
475 $this->opts
['associated'],
476 array( 'title' => $this->msg( 'tooltip-namespace_association' )->text(), 'class' => 'mw-input' )
481 $extraOptions = Xml
::tags( 'td', array( 'colspan' => 2 ),
482 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
484 $this->msg( 'history-show-deleted' )->text(),
486 'mw-show-deleted-only',
487 $this->opts
['deletedOnly'],
488 array( 'class' => 'mw-input' )
491 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
493 $this->msg( 'sp-contributions-toponly' )->text(),
496 $this->opts
['topOnly'],
497 array( 'class' => 'mw-input' )
502 $dateSelectionAndSubmit = Xml
::tags( 'td', array( 'colspan' => 2 ),
508 $this->msg( 'sp-contributions-submit' )->text(),
509 array( 'class' => 'mw-submit' )
514 Xml
::fieldset( $this->msg( 'sp-contributions-search' )->text() ) .
515 Xml
::openElement( 'table', array( 'class' => 'mw-contributions-table' ) ) .
516 Xml
::openElement( 'tr' ) .
518 Xml
::closeElement( 'tr' ) .
519 Xml
::openElement( 'tr' ) .
520 $namespaceSelection .
521 Xml
::closeElement( 'tr' ) .
522 Xml
::openElement( 'tr' ) .
524 Xml
::closeElement( 'tr' ) .
525 Xml
::openElement( 'tr' ) .
527 Xml
::closeElement( 'tr' ) .
528 Xml
::openElement( 'tr' ) .
529 $dateSelectionAndSubmit .
530 Xml
::closeElement( 'tr' ) .
531 Xml
::closeElement( 'table' );
533 $explain = $this->msg( 'sp-contributions-explain' );
534 if ( $explain->exists() ) {
535 $form .= "<p id='mw-sp-contributions-explain'>{$explain}</p>";
537 $form .= Xml
::closeElement( 'fieldset' ) .
538 Xml
::closeElement( 'form' );
544 * Pager for Special:Contributions
545 * @ingroup SpecialPage Pager
547 class ContribsPager
extends ReverseChronologicalPager
{
548 public $mDefaultDirection = true;
549 var $messages, $target;
550 var $namespace = '', $mDb;
551 var $preventClickjacking = false;
556 protected $mParentLens;
558 function __construct( IContextSource
$context, array $options ) {
559 parent
::__construct( $context );
561 $msgs = array( 'uctop', 'diff', 'newarticle', 'rollbacklink', 'diff', 'hist', 'rev-delundel', 'pipe-separator' );
563 foreach ( $msgs as $msg ) {
564 $this->messages
[$msg] = $this->msg( $msg )->escaped();
567 $this->target
= isset( $options['target'] ) ?
$options['target'] : '';
568 $this->contribs
= isset( $options['contribs'] ) ?
$options['contribs'] : 'users';
569 $this->namespace = isset( $options['namespace'] ) ?
$options['namespace'] : '';
570 $this->tagFilter
= isset( $options['tagfilter'] ) ?
$options['tagfilter'] : false;
571 $this->nsInvert
= isset( $options['nsInvert'] ) ?
$options['nsInvert'] : false;
572 $this->associated
= isset( $options['associated'] ) ?
$options['associated'] : false;
574 $this->deletedOnly
= !empty( $options['deletedOnly'] );
575 $this->topOnly
= !empty( $options['topOnly'] );
577 $year = isset( $options['year'] ) ?
$options['year'] : false;
578 $month = isset( $options['month'] ) ?
$options['month'] : false;
579 $this->getDateCond( $year, $month );
581 $this->mDb
= wfGetDB( DB_SLAVE
, 'contributions' );
584 function getDefaultQuery() {
585 $query = parent
::getDefaultQuery();
586 $query['target'] = $this->target
;
590 function getQueryInfo() {
591 list( $tables, $index, $userCond, $join_cond ) = $this->getUserCond();
593 $user = $this->getUser();
594 $conds = array_merge( $userCond, $this->getNamespaceCond() );
596 // Paranoia: avoid brute force searches (bug 17342)
597 if ( !$user->isAllowed( 'deletedhistory' ) ) {
598 $conds[] = $this->mDb
->bitAnd( 'rev_deleted', Revision
::DELETED_USER
) . ' = 0';
599 } elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
600 $conds[] = $this->mDb
->bitAnd( 'rev_deleted', Revision
::SUPPRESSED_USER
) .
601 ' != ' . Revision
::SUPPRESSED_USER
;
604 # Don't include orphaned revisions
605 $join_cond['page'] = Revision
::pageJoinCond();
606 # Get the current user name for accounts
607 $join_cond['user'] = Revision
::userJoinCond();
611 'fields' => array_merge(
612 Revision
::selectFields(),
613 Revision
::selectUserFields(),
614 array( 'page_namespace', 'page_title', 'page_is_new',
615 'page_latest', 'page_is_redirect', 'page_len' )
618 'options' => array( 'USE INDEX' => array( 'revision' => $index ) ),
619 'join_conds' => $join_cond
622 ChangeTags
::modifyDisplayQuery(
623 $queryInfo['tables'],
624 $queryInfo['fields'],
626 $queryInfo['join_conds'],
627 $queryInfo['options'],
631 wfRunHooks( 'ContribsPager::getQueryInfo', array( &$this, &$queryInfo ) );
635 function getUserCond() {
636 $condition = array();
637 $join_conds = array();
638 $tables = array( 'revision', 'page', 'user' );
639 if ( $this->contribs
== 'newbie' ) {
640 $tables[] = 'user_groups';
641 $max = $this->mDb
->selectField( 'user', 'max(user_id)', false, __METHOD__
);
642 $condition[] = 'rev_user >' . (int)( $max - $max / 100 );
643 $condition[] = 'ug_group IS NULL';
644 $index = 'user_timestamp';
645 # @todo FIXME: Other groups may have 'bot' rights
646 $join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" );
648 $uid = User
::idFromName( $this->target
);
650 $condition['rev_user'] = $uid;
651 $index = 'user_timestamp';
653 $condition['rev_user_text'] = $this->target
;
654 $index = 'usertext_timestamp';
657 if ( $this->deletedOnly
) {
658 $condition[] = "rev_deleted != '0'";
660 if ( $this->topOnly
) {
661 $condition[] = "rev_id = page_latest";
663 return array( $tables, $index, $condition, $join_conds );
666 function getNamespaceCond() {
667 if ( $this->namespace !== '' ) {
668 $selectedNS = $this->mDb
->addQuotes( $this->namespace );
669 $eq_op = $this->nsInvert ?
'!=' : '=';
670 $bool_op = $this->nsInvert ?
'AND' : 'OR';
672 if ( !$this->associated
) {
673 return array( "page_namespace $eq_op $selectedNS" );
675 $associatedNS = $this->mDb
->addQuotes (
676 MWNamespace
::getAssociated( $this->namespace )
679 "page_namespace $eq_op $selectedNS " .
681 " page_namespace $eq_op $associatedNS"
690 function getIndexField() {
691 return 'rev_timestamp';
694 function doBatchLookups() {
695 $this->mResult
->rewind();
697 foreach ( $this->mResult
as $row ) {
698 if( $row->rev_parent_id
) {
699 $revIds[] = $row->rev_parent_id
;
702 $this->mParentLens
= $this->getParentLengths( $revIds );
703 $this->mResult
->rewind(); // reset
705 # Do a link batch query
706 $this->mResult
->seek( 0 );
707 $batch = new LinkBatch();
708 # Give some pointers to make (last) links
709 foreach ( $this->mResult
as $row ) {
710 if ( $this->contribs
=== 'newbie' ) { // multiple users
711 $batch->add( NS_USER
, $row->user_name
);
712 $batch->add( NS_USER_TALK
, $row->user_name
);
714 $batch->add( $row->page_namespace
, $row->page_title
);
717 $this->mResult
->seek( 0 );
721 * Do a batched query to get the parent revision lengths
722 * @param $revIds array
725 private function getParentLengths( array $revIds ) {
728 return $revLens; // empty
730 wfProfileIn( __METHOD__
);
731 $res = $this->getDatabase()->select( 'revision',
732 array( 'rev_id', 'rev_len' ),
733 array( 'rev_id' => $revIds ),
735 foreach ( $res as $row ) {
736 $revLens[$row->rev_id
] = $row->rev_len
;
738 wfProfileOut( __METHOD__
);
745 function getStartBody() {
752 function getEndBody() {
757 * Generates each row in the contributions list.
759 * Contributions which are marked "top" are currently on top of the history.
760 * For these contributions, a [rollback] link is shown for users with roll-
761 * back privileges. The rollback link restores the most recent version that
762 * was not written by the target user.
764 * @todo This would probably look a lot nicer in a table.
768 function formatRow( $row ) {
769 wfProfileIn( __METHOD__
);
771 $rev = new Revision( $row );
774 $page = Title
::newFromRow( $row );
775 $link = Linker
::link(
777 htmlspecialchars( $page->getPrefixedText() ),
779 $page->isRedirect() ?
array( 'redirect' => 'no' ) : array()
781 # Mark current revisions
783 if ( $row->rev_id
== $row->page_latest
) {
784 $topmarktext .= '<span class="mw-uctop">' . $this->messages
['uctop'] . '</span>';
786 if ( !$row->page_is_new
&& $page->quickUserCan( 'rollback' )
787 && $page->quickUserCan( 'edit' ) )
789 $this->preventClickjacking();
790 $topmarktext .= ' ' . Linker
::generateRollback( $rev );
793 $user = $this->getUser();
794 # Is there a visible previous revision?
795 if ( $rev->userCan( Revision
::DELETED_TEXT
, $user ) && $rev->getParentId() !== 0 ) {
796 $difftext = Linker
::linkKnown(
798 $this->messages
['diff'],
802 'oldid' => $row->rev_id
806 $difftext = $this->messages
['diff'];
808 $histlink = Linker
::linkKnown(
810 $this->messages
['hist'],
812 array( 'action' => 'history' )
815 if ( $row->rev_parent_id
=== null ) {
816 // For some reason rev_parent_id isn't populated for this row.
817 // Its rumoured this is true on wikipedia for some revisions (bug 34922).
818 // Next best thing is to have the total number of bytes.
819 $chardiff = ' . . ' . Linker
::formatRevisionSize( $row->rev_len
) . ' . . ';
821 $parentLen = isset( $this->mParentLens
[$row->rev_parent_id
] ) ?
$this->mParentLens
[$row->rev_parent_id
] : 0;
822 $chardiff = ' . . ' . ChangesList
::showCharacterDifference(
823 $parentLen, $row->rev_len
) . ' . . ';
826 $lang = $this->getLanguage();
827 $comment = $lang->getDirMark() . Linker
::revComment( $rev, false, true );
828 $date = $lang->userTimeAndDate( $row->rev_timestamp
, $user );
829 if ( $rev->userCan( Revision
::DELETED_TEXT
, $user ) ) {
830 $d = Linker
::linkKnown(
832 htmlspecialchars( $date ),
834 array( 'oldid' => intval( $row->rev_id
) )
837 $d = htmlspecialchars( $date );
839 if ( $rev->isDeleted( Revision
::DELETED_TEXT
) ) {
840 $d = '<span class="history-deleted">' . $d . '</span>';
843 # Show user names for /newbies as there may be different users.
844 # Note that we already excluded rows with hidden user names.
845 if ( $this->contribs
== 'newbie' ) {
846 $userlink = ' . . ' . Linker
::userLink( $rev->getUser(), $rev->getUserText() );
847 $userlink .= ' ' . $this->msg( 'parentheses' )->rawParams(
848 Linker
::userTalkLink( $rev->getUser(), $rev->getUserText() ) )->escaped() . ' ';
853 if ( $rev->getParentId() === 0 ) {
854 $nflag = ChangesList
::flag( 'newpage' );
859 if ( $rev->isMinor() ) {
860 $mflag = ChangesList
::flag( 'minor' );
865 $del = Linker
::getRevDeleteLink( $user, $rev, $page );
870 $diffHistLinks = $this->msg( 'parentheses' )->rawParams( $difftext . $this->messages
['pipe-separator'] . $histlink )->escaped();
871 $ret = "{$del}{$d} {$diffHistLinks}{$chardiff}{$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}";
873 # Denote if username is redacted for this edit
874 if ( $rev->isDeleted( Revision
::DELETED_USER
) ) {
875 $ret .= " <strong>" . $this->msg( 'rev-deleted-user-contribs' )->escaped() . "</strong>";
879 list( $tagSummary, $newClasses ) = ChangeTags
::formatSummaryRow( $row->ts_tags
, 'contributions' );
880 $classes = array_merge( $classes, $newClasses );
881 $ret .= " $tagSummary";
883 // Let extensions add data
884 wfRunHooks( 'ContributionsLineEnding', array( &$this, &$ret, $row ) );
886 $classes = implode( ' ', $classes );
887 $ret = "<li class=\"$classes\">$ret</li>\n";
888 wfProfileOut( __METHOD__
);
893 * Get the Database object in use
895 * @return DatabaseBase
897 public function getDatabase() {
902 * Overwrite Pager function and return a helpful comment
905 function getSqlComment() {
906 if ( $this->namespace ||
$this->deletedOnly
) {
907 return 'contributions page filtered for namespace or RevisionDeleted edits'; // potentially slow, see CR r58153
909 return 'contributions page unfiltered';
913 protected function preventClickjacking() {
914 $this->preventClickjacking
= true;
920 public function getPreventClickjacking() {
921 return $this->preventClickjacking
;