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() );
193 # Show the appropriate "footer" message - WHOIS tools, etc.
194 if ( $this->opts
['contribs'] == 'newbie' ) {
195 $message = 'sp-contributions-footer-newbies';
196 } elseif( IP
::isIPAddress( $target ) ) {
197 $message = 'sp-contributions-footer-anon';
198 } elseif( $userObj->isAnon() ) {
199 // No message for non-existing users
202 $message = 'sp-contributions-footer';
206 if ( !$this->msg( $message, $target )->isDisabled() ) {
208 "<div class='mw-contributions-footer'>\n$1\n</div>",
209 array( $message, $target ) );
216 * Generates the subheading with links
217 * @param $userObj User object for the target
218 * @return String: appropriately-escaped HTML to be output literally
219 * @todo FIXME: Almost the same as getSubTitle in SpecialDeletedContributions.php. Could be combined.
221 protected function contributionsSub( $userObj ) {
222 if ( $userObj->isAnon() ) {
223 $user = htmlspecialchars( $userObj->getName() );
225 $user = Linker
::link( $userObj->getUserPage(), htmlspecialchars( $userObj->getName() ) );
227 $nt = $userObj->getUserPage();
228 $talk = $userObj->getTalkPage();
231 $tools = $this->getUserLinks( $nt, $talk, $userObj );
232 $links = $this->getLanguage()->pipeList( $tools );
234 // Show a note if the user is blocked and display the last block log entry.
235 if ( $userObj->isBlocked() ) {
236 $out = $this->getOutput(); // showLogExtract() wants first parameter by reference
237 LogEventsList
::showLogExtract(
244 'showIfEmpty' => false,
247 'sp-contributions-blocked-notice-anon' :
248 'sp-contributions-blocked-notice',
249 $userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice'
251 'offset' => '' # don't use WebRequest parameter offset
257 // Old message 'contribsub' had one parameter, but that doesn't work for
258 // languages that want to put the "for" bit right after $user but before
259 // $links. If 'contribsub' is around, use it for reverse compatibility,
260 // otherwise use 'contribsub2'.
261 // @todo Should this be removed at some point?
262 $oldMsg = $this->msg( 'contribsub' );
263 if ( $oldMsg->exists() ) {
264 $linksWithParentheses = $this->msg( 'parentheses' )->rawParams( $links )->escaped();
265 return $oldMsg->rawParams( "$user $linksWithParentheses" );
267 return $this->msg( 'contribsub2' )->rawParams( $user, $links );
272 * Links to different places.
273 * @param $userpage Title: Target user page
274 * @param $talkpage Title: Talk page
275 * @param $target User: Target user object
278 public function getUserLinks( Title
$userpage, Title
$talkpage, User
$target ) {
280 $id = $target->getId();
281 $username = $target->getName();
283 $tools[] = Linker
::link( $talkpage, $this->msg( 'sp-contributions-talk' )->escaped() );
285 if ( ( $id !== null ) ||
( $id === null && IP
::isIPAddress( $username ) ) ) {
286 if ( $this->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
287 if ( $target->isBlocked() ) {
288 $tools[] = Linker
::linkKnown( # Change block link
289 SpecialPage
::getTitleFor( 'Block', $username ),
290 $this->msg( 'change-blocklink' )->escaped()
292 $tools[] = Linker
::linkKnown( # Unblock link
293 SpecialPage
::getTitleFor( 'Unblock', $username ),
294 $this->msg( 'unblocklink' )->escaped()
296 } else { # User is not blocked
297 $tools[] = Linker
::linkKnown( # Block link
298 SpecialPage
::getTitleFor( 'Block', $username ),
299 $this->msg( 'blocklink' )->escaped()
304 $tools[] = Linker
::linkKnown(
305 SpecialPage
::getTitleFor( 'Log', 'block' ),
306 $this->msg( 'sp-contributions-blocklog' )->escaped(),
309 'page' => $userpage->getPrefixedText()
314 $tools[] = Linker
::linkKnown(
315 SpecialPage
::getTitleFor( 'Listfiles', $username ),
316 $this->msg( 'sp-contributions-uploads' )->escaped()
320 $tools[] = Linker
::linkKnown(
321 SpecialPage
::getTitleFor( 'Log', $username ),
322 $this->msg( 'sp-contributions-logs' )->escaped()
325 # Add link to deleted user contributions for priviledged users
326 if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
327 $tools[] = Linker
::linkKnown(
328 SpecialPage
::getTitleFor( 'DeletedContributions', $username ),
329 $this->msg( 'sp-contributions-deleted' )->escaped()
333 # Add a link to change user rights for privileged users
334 $userrightsPage = new UserrightsPage();
335 $userrightsPage->setContext( $this->getContext() );
336 if ( $userrightsPage->userCanChangeRights( $target ) ) {
337 $tools[] = Linker
::linkKnown(
338 SpecialPage
::getTitleFor( 'Userrights', $username ),
339 $this->msg( 'sp-contributions-userrights' )->escaped()
343 wfRunHooks( 'ContributionsToolLinks', array( $id, $userpage, &$tools ) );
348 * Generates the namespace selector form with hidden attributes.
349 * @return String: HTML fragment
351 protected function getForm() {
354 $this->opts
['title'] = $this->getTitle()->getPrefixedText();
355 if ( !isset( $this->opts
['target'] ) ) {
356 $this->opts
['target'] = '';
358 $this->opts
['target'] = str_replace( '_' , ' ' , $this->opts
['target'] );
361 if ( !isset( $this->opts
['namespace'] ) ) {
362 $this->opts
['namespace'] = '';
365 if ( !isset( $this->opts
['nsInvert'] ) ) {
366 $this->opts
['nsInvert'] = '';
369 if ( !isset( $this->opts
['associated'] ) ) {
370 $this->opts
['associated'] = false;
373 if ( !isset( $this->opts
['contribs'] ) ) {
374 $this->opts
['contribs'] = 'user';
377 if ( !isset( $this->opts
['year'] ) ) {
378 $this->opts
['year'] = '';
381 if ( !isset( $this->opts
['month'] ) ) {
382 $this->opts
['month'] = '';
385 if ( $this->opts
['contribs'] == 'newbie' ) {
386 $this->opts
['target'] = '';
389 if ( !isset( $this->opts
['tagfilter'] ) ) {
390 $this->opts
['tagfilter'] = '';
393 if ( !isset( $this->opts
['topOnly'] ) ) {
394 $this->opts
['topOnly'] = false;
397 $form = Xml
::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'class' => 'mw-contributions-form' ) );
399 # Add hidden params for tracking except for parameters in $skipParameters
400 $skipParameters = array( 'namespace', 'nsInvert', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly', 'associated' );
401 foreach ( $this->opts
as $name => $value ) {
402 if ( in_array( $name, $skipParameters ) ) {
405 $form .= "\t" . Html
::hidden( $name, $value ) . "\n";
408 $tagFilter = ChangeTags
::buildTagFilterSelector( $this->opts
['tagfilter'] );
412 Xml
::tags( 'td', array( 'class' => 'mw-label' ), array_shift( $tagFilter ) ) .
413 Xml
::tags( 'td', array( 'class' => 'mw-input' ), implode( ' ', $tagFilter ) );
415 $filterSelection = Xml
::tags( 'td', array( 'colspan' => 2 ), '' );
418 $targetSelection = Xml
::tags( 'td', array( 'colspan' => 2 ),
420 $this->msg( 'sp-contributions-newbies' )->text(),
424 $this->opts
['contribs'] == 'newbie',
425 array( 'class' => 'mw-input' )
428 $this->msg( 'sp-contributions-username' )->text(),
432 $this->opts
['contribs'] == 'user',
433 array( 'class' => 'mw-input' )
437 $this->opts
['target'],
439 array( 'size' => '20', 'required' => '', 'class' => 'mw-input' ) +
440 ( $this->opts
['target'] ?
array() : array( 'autofocus' )
445 $namespaceSelection =
446 Xml
::tags( 'td', array( 'class' => 'mw-label' ),
448 $this->msg( 'namespace' )->text(),
453 Xml
::tags( 'td', null,
454 Html
::namespaceSelector( array(
455 'selected' => $this->opts
['namespace'],
458 'name' => 'namespace',
460 'class' => 'namespaceselector',
463 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
465 $this->msg( 'invert' )->text(),
468 $this->opts
['nsInvert'],
469 array( 'title' => $this->msg( 'tooltip-invert' )->text(), 'class' => 'mw-input' )
472 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
474 $this->msg( 'namespace_association' )->text(),
477 $this->opts
['associated'],
478 array( 'title' => $this->msg( 'tooltip-namespace_association' )->text(), 'class' => 'mw-input' )
483 $extraOptions = Xml
::tags( 'td', array( 'colspan' => 2 ),
484 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
486 $this->msg( 'history-show-deleted' )->text(),
488 'mw-show-deleted-only',
489 $this->opts
['deletedOnly'],
490 array( 'class' => 'mw-input' )
493 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
495 $this->msg( 'sp-contributions-toponly' )->text(),
498 $this->opts
['topOnly'],
499 array( 'class' => 'mw-input' )
504 $dateSelectionAndSubmit = Xml
::tags( 'td', array( 'colspan' => 2 ),
510 $this->msg( 'sp-contributions-submit' )->text(),
511 array( 'class' => 'mw-submit' )
516 Xml
::fieldset( $this->msg( 'sp-contributions-search' )->text() ) .
517 Xml
::openElement( 'table', array( 'class' => 'mw-contributions-table' ) ) .
518 Xml
::openElement( 'tr' ) .
520 Xml
::closeElement( 'tr' ) .
521 Xml
::openElement( 'tr' ) .
522 $namespaceSelection .
523 Xml
::closeElement( 'tr' ) .
524 Xml
::openElement( 'tr' ) .
526 Xml
::closeElement( 'tr' ) .
527 Xml
::openElement( 'tr' ) .
529 Xml
::closeElement( 'tr' ) .
530 Xml
::openElement( 'tr' ) .
531 $dateSelectionAndSubmit .
532 Xml
::closeElement( 'tr' ) .
533 Xml
::closeElement( 'table' );
535 $explain = $this->msg( 'sp-contributions-explain' );
536 if ( $explain->exists() ) {
537 $form .= "<p id='mw-sp-contributions-explain'>{$explain}</p>";
539 $form .= Xml
::closeElement( 'fieldset' ) .
540 Xml
::closeElement( 'form' );
546 * Pager for Special:Contributions
547 * @ingroup SpecialPage Pager
549 class ContribsPager
extends ReverseChronologicalPager
{
550 public $mDefaultDirection = true;
551 var $messages, $target;
552 var $namespace = '', $mDb;
553 var $preventClickjacking = false;
558 protected $mParentLens;
560 function __construct( IContextSource
$context, array $options ) {
561 parent
::__construct( $context );
563 $msgs = array( 'uctop', 'diff', 'newarticle', 'rollbacklink', 'diff', 'hist', 'rev-delundel', 'pipe-separator' );
565 foreach ( $msgs as $msg ) {
566 $this->messages
[$msg] = $this->msg( $msg )->escaped();
569 $this->target
= isset( $options['target'] ) ?
$options['target'] : '';
570 $this->contribs
= isset( $options['contribs'] ) ?
$options['contribs'] : 'users';
571 $this->namespace = isset( $options['namespace'] ) ?
$options['namespace'] : '';
572 $this->tagFilter
= isset( $options['tagfilter'] ) ?
$options['tagfilter'] : false;
573 $this->nsInvert
= isset( $options['nsInvert'] ) ?
$options['nsInvert'] : false;
574 $this->associated
= isset( $options['associated'] ) ?
$options['associated'] : false;
576 $this->deletedOnly
= !empty( $options['deletedOnly'] );
577 $this->topOnly
= !empty( $options['topOnly'] );
579 $year = isset( $options['year'] ) ?
$options['year'] : false;
580 $month = isset( $options['month'] ) ?
$options['month'] : false;
581 $this->getDateCond( $year, $month );
583 $this->mDb
= wfGetDB( DB_SLAVE
, 'contributions' );
586 function getDefaultQuery() {
587 $query = parent
::getDefaultQuery();
588 $query['target'] = $this->target
;
592 function getQueryInfo() {
593 list( $tables, $index, $userCond, $join_cond ) = $this->getUserCond();
595 $user = $this->getUser();
596 $conds = array_merge( $userCond, $this->getNamespaceCond() );
598 // Paranoia: avoid brute force searches (bug 17342)
599 if ( !$user->isAllowed( 'deletedhistory' ) ) {
600 $conds[] = $this->mDb
->bitAnd( 'rev_deleted', Revision
::DELETED_USER
) . ' = 0';
601 } elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
602 $conds[] = $this->mDb
->bitAnd( 'rev_deleted', Revision
::SUPPRESSED_USER
) .
603 ' != ' . Revision
::SUPPRESSED_USER
;
606 # Don't include orphaned revisions
607 $join_cond['page'] = Revision
::pageJoinCond();
608 # Get the current user name for accounts
609 $join_cond['user'] = Revision
::userJoinCond();
613 'fields' => array_merge(
614 Revision
::selectFields(),
615 Revision
::selectUserFields(),
616 array( 'page_namespace', 'page_title', 'page_is_new',
617 'page_latest', 'page_is_redirect', 'page_len' )
620 'options' => array( 'USE INDEX' => array( 'revision' => $index ) ),
621 'join_conds' => $join_cond
624 ChangeTags
::modifyDisplayQuery(
625 $queryInfo['tables'],
626 $queryInfo['fields'],
628 $queryInfo['join_conds'],
629 $queryInfo['options'],
633 wfRunHooks( 'ContribsPager::getQueryInfo', array( &$this, &$queryInfo ) );
637 function getUserCond() {
638 $condition = array();
639 $join_conds = array();
640 $tables = array( 'revision', 'page', 'user' );
641 if ( $this->contribs
== 'newbie' ) {
642 $tables[] = 'user_groups';
643 $max = $this->mDb
->selectField( 'user', 'max(user_id)', false, __METHOD__
);
644 $condition[] = 'rev_user >' . (int)( $max - $max / 100 );
645 $condition[] = 'ug_group IS NULL';
646 $index = 'user_timestamp';
647 # @todo FIXME: Other groups may have 'bot' rights
648 $join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" );
650 $uid = User
::idFromName( $this->target
);
652 $condition['rev_user'] = $uid;
653 $index = 'user_timestamp';
655 $condition['rev_user_text'] = $this->target
;
656 $index = 'usertext_timestamp';
659 if ( $this->deletedOnly
) {
660 $condition[] = "rev_deleted != '0'";
662 if ( $this->topOnly
) {
663 $condition[] = "rev_id = page_latest";
665 return array( $tables, $index, $condition, $join_conds );
668 function getNamespaceCond() {
669 if ( $this->namespace !== '' ) {
670 $selectedNS = $this->mDb
->addQuotes( $this->namespace );
671 $eq_op = $this->nsInvert ?
'!=' : '=';
672 $bool_op = $this->nsInvert ?
'AND' : 'OR';
674 if ( !$this->associated
) {
675 return array( "page_namespace $eq_op $selectedNS" );
677 $associatedNS = $this->mDb
->addQuotes (
678 MWNamespace
::getAssociated( $this->namespace )
681 "page_namespace $eq_op $selectedNS " .
683 " page_namespace $eq_op $associatedNS"
692 function getIndexField() {
693 return 'rev_timestamp';
696 function doBatchLookups() {
697 $this->mResult
->rewind();
699 foreach ( $this->mResult
as $row ) {
700 if( $row->rev_parent_id
) {
701 $revIds[] = $row->rev_parent_id
;
704 $this->mParentLens
= $this->getParentLengths( $revIds );
705 $this->mResult
->rewind(); // reset
707 # Do a link batch query
708 $this->mResult
->seek( 0 );
709 $batch = new LinkBatch();
710 # Give some pointers to make (last) links
711 foreach ( $this->mResult
as $row ) {
712 if ( $this->contribs
=== 'newbie' ) { // multiple users
713 $batch->add( NS_USER
, $row->user_name
);
714 $batch->add( NS_USER_TALK
, $row->user_name
);
716 $batch->add( $row->page_namespace
, $row->page_title
);
719 $this->mResult
->seek( 0 );
723 * Do a batched query to get the parent revision lengths
724 * @param $revIds array
727 private function getParentLengths( array $revIds ) {
730 return $revLens; // empty
732 wfProfileIn( __METHOD__
);
733 $res = $this->getDatabase()->select( 'revision',
734 array( 'rev_id', 'rev_len' ),
735 array( 'rev_id' => $revIds ),
737 foreach ( $res as $row ) {
738 $revLens[$row->rev_id
] = $row->rev_len
;
740 wfProfileOut( __METHOD__
);
747 function getStartBody() {
754 function getEndBody() {
759 * Generates each row in the contributions list.
761 * Contributions which are marked "top" are currently on top of the history.
762 * For these contributions, a [rollback] link is shown for users with roll-
763 * back privileges. The rollback link restores the most recent version that
764 * was not written by the target user.
766 * @todo This would probably look a lot nicer in a table.
770 function formatRow( $row ) {
771 wfProfileIn( __METHOD__
);
773 $rev = new Revision( $row );
776 $page = Title
::newFromRow( $row );
777 $link = Linker
::link(
779 htmlspecialchars( $page->getPrefixedText() ),
781 $page->isRedirect() ?
array( 'redirect' => 'no' ) : array()
783 # Mark current revisions
785 if ( $row->rev_id
== $row->page_latest
) {
786 $topmarktext .= '<span class="mw-uctop">' . $this->messages
['uctop'] . '</span>';
788 if ( !$row->page_is_new
&& $page->quickUserCan( 'rollback' )
789 && $page->quickUserCan( 'edit' ) )
791 $this->preventClickjacking();
792 $topmarktext .= ' ' . Linker
::generateRollback( $rev );
795 $user = $this->getUser();
796 # Is there a visible previous revision?
797 if ( $rev->userCan( Revision
::DELETED_TEXT
, $user ) && $rev->getParentId() !== 0 ) {
798 $difftext = Linker
::linkKnown(
800 $this->messages
['diff'],
804 'oldid' => $row->rev_id
808 $difftext = $this->messages
['diff'];
810 $histlink = Linker
::linkKnown(
812 $this->messages
['hist'],
814 array( 'action' => 'history' )
817 if ( $row->rev_parent_id
=== null ) {
818 // For some reason rev_parent_id isn't populated for this row.
819 // Its rumoured this is true on wikipedia for some revisions (bug 34922).
820 // Next best thing is to have the total number of bytes.
821 $chardiff = ' . . ' . Linker
::formatRevisionSize( $row->rev_len
) . ' . . ';
823 $parentLen = isset( $this->mParentLens
[$row->rev_parent_id
] ) ?
$this->mParentLens
[$row->rev_parent_id
] : 0;
824 $chardiff = ' . . ' . ChangesList
::showCharacterDifference(
825 $parentLen, $row->rev_len
) . ' . . ';
828 $lang = $this->getLanguage();
829 $comment = $lang->getDirMark() . Linker
::revComment( $rev, false, true );
830 $date = $lang->userTimeAndDate( $row->rev_timestamp
, $user );
831 if ( $rev->userCan( Revision
::DELETED_TEXT
, $user ) ) {
832 $d = Linker
::linkKnown(
834 htmlspecialchars( $date ),
836 array( 'oldid' => intval( $row->rev_id
) )
839 $d = htmlspecialchars( $date );
841 if ( $rev->isDeleted( Revision
::DELETED_TEXT
) ) {
842 $d = '<span class="history-deleted">' . $d . '</span>';
845 # Show user names for /newbies as there may be different users.
846 # Note that we already excluded rows with hidden user names.
847 if ( $this->contribs
== 'newbie' ) {
848 $userlink = ' . . ' . Linker
::userLink( $rev->getUser(), $rev->getUserText() );
849 $userlink .= ' ' . $this->msg( 'parentheses' )->rawParams(
850 Linker
::userTalkLink( $rev->getUser(), $rev->getUserText() ) )->escaped() . ' ';
855 if ( $rev->getParentId() === 0 ) {
856 $nflag = ChangesList
::flag( 'newpage' );
861 if ( $rev->isMinor() ) {
862 $mflag = ChangesList
::flag( 'minor' );
867 $del = Linker
::getRevDeleteLink( $user, $rev, $page );
872 $diffHistLinks = $this->msg( 'parentheses' )->rawParams( $difftext . $this->messages
['pipe-separator'] . $histlink )->escaped();
873 $ret = "{$del}{$d} {$diffHistLinks}{$chardiff}{$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}";
875 # Denote if username is redacted for this edit
876 if ( $rev->isDeleted( Revision
::DELETED_USER
) ) {
877 $ret .= " <strong>" . $this->msg( 'rev-deleted-user-contribs' )->escaped() . "</strong>";
881 list( $tagSummary, $newClasses ) = ChangeTags
::formatSummaryRow( $row->ts_tags
, 'contributions' );
882 $classes = array_merge( $classes, $newClasses );
883 $ret .= " $tagSummary";
885 // Let extensions add data
886 wfRunHooks( 'ContributionsLineEnding', array( &$this, &$ret, $row ) );
888 $classes = implode( ' ', $classes );
889 $ret = "<li class=\"$classes\">$ret</li>\n";
890 wfProfileOut( __METHOD__
);
895 * Get the Database object in use
897 * @return DatabaseBase
899 public function getDatabase() {
904 * Overwrite Pager function and return a helpful comment
907 function getSqlComment() {
908 if ( $this->namespace ||
$this->deletedOnly
) {
909 return 'contributions page filtered for namespace or RevisionDeleted edits'; // potentially slow, see CR r58153
911 return 'contributions page unfiltered';
915 protected function preventClickjacking() {
916 $this->preventClickjacking
= true;
922 public function getPreventClickjacking() {
923 return $this->preventClickjacking
;