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 == 'newbies' ) {
49 $this->opts
['contribs'] = 'newbie';
50 } elseif ( $par !== null ) {
53 $target = $request->getVal( 'target' );
57 if ( $request->getVal( 'contribs' ) == 'newbie' ) {
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 $userObj = User
::newFromName( $target, false );
79 $out->addHTML( $this->getForm() );
82 $nt = $userObj->getUserPage();
83 $id = $userObj->getID();
85 if ( $this->opts
['contribs'] != 'newbie' ) {
86 $target = $nt->getText();
87 $out->addSubtitle( $this->contributionsSub( $userObj ) );
88 $out->setHTMLTitle( $this->msg( 'pagetitle', $this->msg( 'contributions-title', $target )->plain() ) );
89 $this->getSkin()->setRelevantUser( $userObj );
91 $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub' ) );
92 $out->setHTMLTitle( $this->msg( 'pagetitle', $this->msg( 'sp-contributions-newbies-title' )->plain() ) );
95 if ( ( $ns = $request->getVal( 'namespace', null ) ) !== null && $ns !== '' ) {
96 $this->opts
['namespace'] = intval( $ns );
98 $this->opts
['namespace'] = '';
101 $this->opts
['associated'] = $request->getBool( 'associated' );
103 $this->opts
['nsInvert'] = (bool) $request->getVal( 'nsInvert' );
105 $this->opts
['tagfilter'] = (string) $request->getVal( 'tagfilter' );
107 // Allows reverts to have the bot flag in recent changes. It is just here to
108 // be passed in the form at the top of the page
109 if ( $user->isAllowed( 'markbotedits' ) && $request->getBool( 'bot' ) ) {
110 $this->opts
['bot'] = '1';
113 $skip = $request->getText( 'offset' ) ||
$request->getText( 'dir' ) == 'prev';
114 # Offset overrides year/month selection
116 $this->opts
['year'] = '';
117 $this->opts
['month'] = '';
119 $this->opts
['year'] = $request->getIntOrNull( 'year' );
120 $this->opts
['month'] = $request->getIntOrNull( 'month' );
123 $feedType = $request->getVal( 'feed' );
125 // Maintain some level of backwards compatability
126 // If people request feeds using the old parameters, redirect to API
128 'action' => 'feedcontributions',
129 'feedformat' => $feedType,
132 if ( $this->opts
['topOnly'] ) {
133 $apiParams['toponly'] = true;
135 if ( $this->opts
['deletedOnly'] ) {
136 $apiParams['deletedonly'] = true;
138 if ( $this->opts
['tagfilter'] !== '' ) {
139 $apiParams['tagfilter'] = $this->opts
['tagfilter'];
141 if ( $this->opts
['namespace'] !== '' ) {
142 $apiParams['namespace'] = $this->opts
['namespace'];
144 if ( $this->opts
['year'] !== null ) {
145 $apiParams['year'] = $this->opts
['year'];
147 if ( $this->opts
['month'] !== null ) {
148 $apiParams['month'] = $this->opts
['month'];
151 $url = wfScript( 'api' ) . '?' . wfArrayToCGI( $apiParams );
153 $out->redirect( $url, '301' );
157 // Add RSS/atom links
158 $this->addFeedLinks( array( 'action' => 'feedcontributions', 'user' => $target ) );
160 if ( wfRunHooks( 'SpecialContributionsBeforeMainOutput', array( $id ) ) ) {
162 $out->addHTML( $this->getForm() );
164 $pager = new ContribsPager( $this->getContext(), array(
166 'contribs' => $this->opts
['contribs'],
167 'namespace' => $this->opts
['namespace'],
168 'year' => $this->opts
['year'],
169 'month' => $this->opts
['month'],
170 'deletedOnly' => $this->opts
['deletedOnly'],
171 'topOnly' => $this->opts
['topOnly'],
172 'nsInvert' => $this->opts
['nsInvert'],
173 'associated' => $this->opts
['associated'],
175 if ( !$pager->getNumRows() ) {
176 $out->addWikiMsg( 'nocontribs', $target );
178 # Show a message about slave lag, if applicable
179 $lag = wfGetLB()->safeGetLag( $pager->getDatabase() );
181 $out->showLagWarning( $lag );
184 '<p>' . $pager->getNavigationBar() . '</p>' .
186 '<p>' . $pager->getNavigationBar() . '</p>'
189 $out->preventClickjacking( $pager->getPreventClickjacking() );
191 # Show the appropriate "footer" message - WHOIS tools, etc.
192 if ( $this->opts
['contribs'] != 'newbie' ) {
193 $message = 'sp-contributions-footer';
194 if ( IP
::isIPAddress( $target ) ) {
195 $message = 'sp-contributions-footer-anon';
197 if ( $userObj->isAnon() ) {
198 // No message for non-existing users
203 if ( !$this->msg( $message, $target )->isDisabled() ) {
205 "<div class='mw-contributions-footer'>\n$1\n</div>",
206 array( $message, $target ) );
213 * Generates the subheading with links
214 * @param $userObj User object for the target
215 * @return String: appropriately-escaped HTML to be output literally
216 * @todo FIXME: Almost the same as getSubTitle in SpecialDeletedContributions.php. Could be combined.
218 protected function contributionsSub( $userObj ) {
219 if ( $userObj->isAnon() ) {
220 $user = htmlspecialchars( $userObj->getName() );
222 $user = Linker
::link( $userObj->getUserPage(), htmlspecialchars( $userObj->getName() ) );
224 $nt = $userObj->getUserPage();
225 $talk = $userObj->getTalkPage();
227 $tools = $this->getUserLinks( $nt, $talk, $userObj, $this->getUser() );
228 $links = $this->getLanguage()->pipeList( $tools );
230 // Show a note if the user is blocked and display the last block log entry.
231 if ( $userObj->isBlocked() ) {
232 $out = $this->getOutput(); // showLogExtract() wants first parameter by reference
233 LogEventsList
::showLogExtract(
240 'showIfEmpty' => false,
243 'sp-contributions-blocked-notice-anon' :
244 'sp-contributions-blocked-notice',
245 $userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice'
247 'offset' => '' # don't use WebRequest parameter offset
253 // Old message 'contribsub' had one parameter, but that doesn't work for
254 // languages that want to put the "for" bit right after $user but before
255 // $links. If 'contribsub' is around, use it for reverse compatibility,
256 // otherwise use 'contribsub2'.
257 $oldMsg = $this->msg( 'contribsub' );
258 if ( $oldMsg->exists() ) {
259 return $oldMsg->rawParams( "$user ($links)" );
261 return $this->msg( 'contribsub2' )->rawParams( $user, $links );
266 * Links to different places.
267 * @param $userpage Title: Target user page
268 * @param $talkpage Title: Talk page
269 * @param $target User: Target user object
270 * @param $subject User: The viewing user ($wgUser might be still checked in some cases)
273 public function getUserLinks( Title
$userpage, Title
$talkpage, User
$target, User
$subject ) {
275 $id = $target->getId();
276 $username = $target->getName();
278 $tools[] = Linker
::link( $talkpage, $this->msg( 'sp-contributions-talk' )->escaped() );
280 if ( ( $id !== null ) ||
( $id === null && IP
::isIPAddress( $username ) ) ) {
281 if ( $subject->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
282 if ( $target->isBlocked() ) {
283 $tools[] = Linker
::linkKnown( # Change block link
284 SpecialPage
::getTitleFor( 'Block', $username ),
285 $this->msg( 'change-blocklink' )->escaped()
287 $tools[] = Linker
::linkKnown( # Unblock link
288 SpecialPage
::getTitleFor( 'Unblock', $username ),
289 $this->msg( 'unblocklink' )->escaped()
291 } else { # User is not blocked
292 $tools[] = Linker
::linkKnown( # Block link
293 SpecialPage
::getTitleFor( 'Block', $username ),
294 $this->msg( 'blocklink' )->escaped()
299 $tools[] = Linker
::linkKnown(
300 SpecialPage
::getTitleFor( 'Log', 'block' ),
301 $this->msg( 'sp-contributions-blocklog' )->escaped(),
304 'page' => $userpage->getPrefixedText()
309 $tools[] = Linker
::linkKnown(
310 SpecialPage
::getTitleFor( 'Listfiles', $username ),
311 $this->msg( 'sp-contributions-uploads' )->escaped()
315 $tools[] = Linker
::linkKnown(
316 SpecialPage
::getTitleFor( 'Log', $username ),
317 $this->msg( 'sp-contributions-logs' )->escaped()
320 # Add link to deleted user contributions for priviledged users
321 if ( $subject->isAllowed( 'deletedhistory' ) ) {
322 $tools[] = Linker
::linkKnown(
323 SpecialPage
::getTitleFor( 'DeletedContributions', $username ),
324 $this->msg( 'sp-contributions-deleted' )->escaped()
328 # Add a link to change user rights for privileged users
329 $userrightsPage = new UserrightsPage();
330 $userrightsPage->getContext()->setUser( $subject );
331 if ( $id !== null && $userrightsPage->userCanChangeRights( $target ) ) {
332 $tools[] = Linker
::linkKnown(
333 SpecialPage
::getTitleFor( 'Userrights', $username ),
334 $this->msg( 'sp-contributions-userrights' )->escaped()
338 wfRunHooks( 'ContributionsToolLinks', array( $id, $userpage, &$tools ) );
343 * Generates the namespace selector form with hidden attributes.
344 * @return String: HTML fragment
346 protected function getForm() {
349 $this->opts
['title'] = $this->getTitle()->getPrefixedText();
350 if ( !isset( $this->opts
['target'] ) ) {
351 $this->opts
['target'] = '';
353 $this->opts
['target'] = str_replace( '_' , ' ' , $this->opts
['target'] );
356 if ( !isset( $this->opts
['namespace'] ) ) {
357 $this->opts
['namespace'] = '';
360 if ( !isset( $this->opts
['nsInvert'] ) ) {
361 $this->opts
['nsInvert'] = '';
364 if ( !isset( $this->opts
['associated'] ) ) {
365 $this->opts
['associated'] = false;
368 if ( !isset( $this->opts
['contribs'] ) ) {
369 $this->opts
['contribs'] = 'user';
372 if ( !isset( $this->opts
['year'] ) ) {
373 $this->opts
['year'] = '';
376 if ( !isset( $this->opts
['month'] ) ) {
377 $this->opts
['month'] = '';
380 if ( $this->opts
['contribs'] == 'newbie' ) {
381 $this->opts
['target'] = '';
384 if ( !isset( $this->opts
['tagfilter'] ) ) {
385 $this->opts
['tagfilter'] = '';
388 if ( !isset( $this->opts
['topOnly'] ) ) {
389 $this->opts
['topOnly'] = false;
392 $form = Xml
::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'class' => 'mw-contributions-form' ) );
394 # Add hidden params for tracking except for parameters in $skipParameters
395 $skipParameters = array( 'namespace', 'nsInvert', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly', 'associated' );
396 foreach ( $this->opts
as $name => $value ) {
397 if ( in_array( $name, $skipParameters ) ) {
400 $form .= "\t" . Html
::hidden( $name, $value ) . "\n";
403 $tagFilter = ChangeTags
::buildTagFilterSelector( $this->opts
['tagfilter'] );
407 Xml
::tags( 'td', array( 'class' => 'mw-label' ), array_shift( $tagFilter ) ) .
408 Xml
::tags( 'td', array( 'class' => 'mw-input' ), implode( ' ', $tagFilter ) );
410 $filterSelection = Xml
::tags( 'td', array( 'colspan' => 2 ), '' );
413 $targetSelection = Xml
::tags( 'td', array( 'colspan' => 2 ),
415 $this->msg( 'sp-contributions-newbies' )->text(),
419 $this->opts
['contribs'] == 'newbie',
420 array( 'class' => 'mw-input' )
423 $this->msg( 'sp-contributions-username' )->text(),
427 $this->opts
['contribs'] == 'user',
428 array( 'class' => 'mw-input' )
432 $this->opts
['target'],
434 array( 'size' => '20', 'required' => '', 'class' => 'mw-input' ) +
435 ( $this->opts
['target'] ?
array() : array( 'autofocus' )
440 $namespaceSelection =
441 Xml
::tags( 'td', array( 'class' => 'mw-label' ),
443 $this->msg( 'namespace' )->text(),
448 Xml
::tags( 'td', null,
449 Xml
::namespaceSelector( $this->opts
['namespace'], '' ) . ' ' .
450 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
452 $this->msg( 'invert' )->text(),
455 $this->opts
['nsInvert'],
456 array( 'title' => $this->msg( 'tooltip-invert' )->text(), 'class' => 'mw-input' )
459 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
461 $this->msg( 'namespace_association' )->text(),
464 $this->opts
['associated'],
465 array( 'title' => $this->msg( 'tooltip-namespace_association' )->text(), 'class' => 'mw-input' )
470 $extraOptions = Xml
::tags( 'td', array( 'colspan' => 2 ),
471 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
473 $this->msg( 'history-show-deleted' )->text(),
475 'mw-show-deleted-only',
476 $this->opts
['deletedOnly'],
477 array( 'class' => 'mw-input' )
480 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
482 $this->msg( 'sp-contributions-toponly' )->text(),
485 $this->opts
['topOnly'],
486 array( 'class' => 'mw-input' )
491 $dateSelectionAndSubmit = Xml
::tags( 'td', array( 'colspan' => 2 ),
497 $this->msg( 'sp-contributions-submit' )->text(),
498 array( 'class' => 'mw-submit' )
503 Xml
::fieldset( $this->msg( 'sp-contributions-search' )->text() ) .
504 Xml
::openElement( 'table', array( 'class' => 'mw-contributions-table' ) ) .
505 Xml
::openElement( 'tr' ) .
507 Xml
::closeElement( 'tr' ) .
508 Xml
::openElement( 'tr' ) .
509 $namespaceSelection .
510 Xml
::closeElement( 'tr' ) .
511 Xml
::openElement( 'tr' ) .
513 Xml
::closeElement( 'tr' ) .
514 Xml
::openElement( 'tr' ) .
516 Xml
::closeElement( 'tr' ) .
517 Xml
::openElement( 'tr' ) .
518 $dateSelectionAndSubmit .
519 Xml
::closeElement( 'tr' ) .
520 Xml
::closeElement( 'table' );
522 $explain = $this->msg( 'sp-contributions-explain' );
523 if ( $explain->exists() ) {
524 $form .= "<p id='mw-sp-contributions-explain'>{$explain}</p>";
526 $form .= Xml
::closeElement( 'fieldset' ) .
527 Xml
::closeElement( 'form' );
533 * Pager for Special:Contributions
534 * @ingroup SpecialPage Pager
536 class ContribsPager
extends ReverseChronologicalPager
{
537 public $mDefaultDirection = true;
538 var $messages, $target;
539 var $namespace = '', $mDb;
540 var $preventClickjacking = false;
542 function __construct( IContextSource
$context, array $options ) {
543 parent
::__construct( $context );
545 $msgs = array( 'uctop', 'diff', 'newarticle', 'rollbacklink', 'diff', 'hist', 'rev-delundel', 'pipe-separator' );
547 foreach ( $msgs as $msg ) {
548 $this->messages
[$msg] = $this->msg( $msg )->escaped();
551 $this->target
= isset( $options['target'] ) ?
$options['target'] : '';
552 $this->contribs
= isset( $options['contribs'] ) ?
$options['contribs'] : 'users';
553 $this->namespace = isset( $options['namespace'] ) ?
$options['namespace'] : '';
554 $this->tagFilter
= isset( $options['tagfilter'] ) ?
$options['tagfilter'] : false;
555 $this->nsInvert
= isset( $options['nsInvert'] ) ?
$options['nsInvert'] : false;
556 $this->associated
= isset( $options['associated'] ) ?
$options['associated'] : false;
558 $this->deletedOnly
= !empty( $options['deletedOnly'] );
559 $this->topOnly
= !empty( $options['topOnly'] );
561 $year = isset( $options['year'] ) ?
$options['year'] : false;
562 $month = isset( $options['month'] ) ?
$options['month'] : false;
563 $this->getDateCond( $year, $month );
565 $this->mDb
= wfGetDB( DB_SLAVE
, 'contributions' );
568 function getDefaultQuery() {
569 $query = parent
::getDefaultQuery();
570 $query['target'] = $this->target
;
574 function getQueryInfo() {
575 list( $tables, $index, $userCond, $join_cond ) = $this->getUserCond();
577 $user = $this->getUser();
578 $conds = array_merge( $userCond, $this->getNamespaceCond() );
580 // Paranoia: avoid brute force searches (bug 17342)
581 if ( !$user->isAllowed( 'deletedhistory' ) ) {
582 $conds[] = $this->mDb
->bitAnd( 'rev_deleted', Revision
::DELETED_USER
) . ' = 0';
583 } elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
584 $conds[] = $this->mDb
->bitAnd( 'rev_deleted', Revision
::SUPPRESSED_USER
) .
585 ' != ' . Revision
::SUPPRESSED_USER
;
588 # Don't include orphaned revisions
589 $join_cond['page'] = Revision
::pageJoinCond();
590 # Get the current user name for accounts
591 $join_cond['user'] = Revision
::userJoinCond();
595 'fields' => array_merge(
596 Revision
::selectFields(),
597 Revision
::selectUserFields(),
598 array( 'page_namespace', 'page_title', 'page_is_new',
599 'page_latest', 'page_is_redirect', 'page_len' )
602 'options' => array( 'USE INDEX' => array( 'revision' => $index ) ),
603 'join_conds' => $join_cond
606 ChangeTags
::modifyDisplayQuery(
607 $queryInfo['tables'],
608 $queryInfo['fields'],
610 $queryInfo['join_conds'],
611 $queryInfo['options'],
615 wfRunHooks( 'ContribsPager::getQueryInfo', array( &$this, &$queryInfo ) );
619 function getUserCond() {
620 $condition = array();
621 $join_conds = array();
622 $tables = array( 'revision', 'page', 'user' );
623 if ( $this->contribs
== 'newbie' ) {
624 $tables[] = 'user_groups';
625 $max = $this->mDb
->selectField( 'user', 'max(user_id)', false, __METHOD__
);
626 $condition[] = 'rev_user >' . (int)( $max - $max / 100 );
627 $condition[] = 'ug_group IS NULL';
628 $index = 'user_timestamp';
629 # @todo FIXME: Other groups may have 'bot' rights
630 $join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" );
632 if ( IP
::isIPAddress( $this->target
) ) {
633 $condition['rev_user_text'] = $this->target
;
634 $index = 'usertext_timestamp';
636 $condition['rev_user'] = User
::idFromName( $this->target
);
637 $index = 'user_timestamp';
640 if ( $this->deletedOnly
) {
641 $condition[] = "rev_deleted != '0'";
643 if ( $this->topOnly
) {
644 $condition[] = "rev_id = page_latest";
646 return array( $tables, $index, $condition, $join_conds );
649 function getNamespaceCond() {
650 if ( $this->namespace !== '' ) {
651 $selectedNS = $this->mDb
->addQuotes( $this->namespace );
652 $eq_op = $this->nsInvert ?
'!=' : '=';
653 $bool_op = $this->nsInvert ?
'AND' : 'OR';
655 if ( !$this->associated
) {
656 return array( "page_namespace $eq_op $selectedNS" );
658 $associatedNS = $this->mDb
->addQuotes (
659 MWNamespace
::getAssociated( $this->namespace )
662 "page_namespace $eq_op $selectedNS " .
664 " page_namespace $eq_op $associatedNS"
673 function getIndexField() {
674 return 'rev_timestamp';
677 function doBatchLookups() {
678 $this->mResult
->rewind();
680 foreach ( $this->mResult
as $row ) {
681 $revIds[] = $row->rev_parent_id
;
683 $this->mParentLens
= $this->getParentLengths( $revIds );
684 $this->mResult
->rewind(); // reset
686 if ( $this->contribs
=== 'newbie' ) { // multiple users
687 # Do a link batch query
688 $this->mResult
->seek( 0 );
689 $batch = new LinkBatch();
690 # Give some pointers to make (last) links
691 foreach ( $this->mResult
as $row ) {
692 $batch->addObj( Title
::makeTitleSafe( NS_USER
, $row->user_name
) );
693 $batch->addObj( Title
::makeTitleSafe( NS_USER_TALK
, $row->user_name
) );
696 $this->mResult
->seek( 0 );
701 * Do a batched query to get the parent revision lengths
703 private function getParentLengths( array $revIds ) {
706 return $revLens; // empty
708 wfProfileIn( __METHOD__
);
709 $res = $this->getDatabase()->select( 'revision',
710 array( 'rev_id', 'rev_len' ),
711 array( 'rev_id' => $revIds ),
713 foreach ( $res as $row ) {
714 $revLens[$row->rev_id
] = $row->rev_len
;
716 wfProfileOut( __METHOD__
);
723 function getStartBody() {
730 function getEndBody() {
735 * Generates each row in the contributions list.
737 * Contributions which are marked "top" are currently on top of the history.
738 * For these contributions, a [rollback] link is shown for users with roll-
739 * back privileges. The rollback link restores the most recent version that
740 * was not written by the target user.
742 * @todo This would probably look a lot nicer in a table.
744 function formatRow( $row ) {
745 wfProfileIn( __METHOD__
);
747 $rev = new Revision( $row );
750 $page = Title
::newFromRow( $row );
751 $link = Linker
::link(
753 htmlspecialchars( $page->getPrefixedText() ),
755 $page->isRedirect() ?
array( 'redirect' => 'no' ) : array()
757 # Mark current revisions
759 if ( $row->rev_id
== $row->page_latest
) {
760 $topmarktext .= '<span class="mw-uctop">' . $this->messages
['uctop'] . '</span>';
762 if ( !$row->page_is_new
&& $page->quickUserCan( 'rollback' )
763 && $page->quickUserCan( 'edit' ) )
765 $this->preventClickjacking();
766 $topmarktext .= ' ' . Linker
::generateRollback( $rev );
769 $user = $this->getUser();
770 # Is there a visible previous revision?
771 if ( $rev->userCan( Revision
::DELETED_TEXT
, $user ) && $rev->getParentId() !== 0 ) {
772 $difftext = Linker
::linkKnown(
774 $this->messages
['diff'],
778 'oldid' => $row->rev_id
782 $difftext = $this->messages
['diff'];
784 $histlink = Linker
::linkKnown(
786 $this->messages
['hist'],
788 array( 'action' => 'history' )
791 if ( isset( $this->mParentLens
[$row->rev_parent_id
] ) ) {
792 $chardiff = ' . . ' . ChangesList
::showCharacterDifference(
793 $this->mParentLens
[$row->rev_parent_id
], $row->rev_len
) . ' . . ';
798 $lang = $this->getLanguage();
799 $comment = $lang->getDirMark() . Linker
::revComment( $rev, false, true );
800 $date = $lang->userTimeAndDate( $row->rev_timestamp
, $user );
801 if ( $rev->userCan( Revision
::DELETED_TEXT
, $user ) ) {
802 $d = Linker
::linkKnown(
804 htmlspecialchars( $date ),
806 array( 'oldid' => intval( $row->rev_id
) )
809 $d = htmlspecialchars( $date );
811 if ( $rev->isDeleted( Revision
::DELETED_TEXT
) ) {
812 $d = '<span class="history-deleted">' . $d . '</span>';
815 # Show user names for /newbies as there may be different users.
816 # Note that we already excluded rows with hidden user names.
817 if ( $this->contribs
== 'newbie' ) {
818 $userlink = ' . . ' . Linker
::userLink( $rev->getUser(), $rev->getUserText() );
819 $userlink .= ' ' . $this->msg( 'parentheses' )->rawParams(
820 Linker
::userTalkLink( $rev->getUser(), $rev->getUserText() ) )->escaped() . ' ';
825 if ( $rev->getParentId() === 0 ) {
826 $nflag = ChangesList
::flag( 'newpage' );
831 if ( $rev->isMinor() ) {
832 $mflag = ChangesList
::flag( 'minor' );
837 // Don't show useless link to people who cannot hide revisions
838 $canHide = $user->isAllowed( 'deleterevision' );
839 if ( $canHide ||
( $rev->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) ) {
840 if ( !$rev->userCan( Revision
::DELETED_RESTRICTED
, $user ) ) {
841 $del = Linker
::revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
844 'type' => 'revision',
845 'target' => $page->getPrefixedDbkey(),
846 'ids' => $rev->getId()
848 $del = Linker
::revDeleteLink( $query,
849 $rev->isDeleted( Revision
::DELETED_RESTRICTED
), $canHide );
856 $diffHistLinks = '(' . $difftext . $this->messages
['pipe-separator'] . $histlink . ')';
857 $ret = "{$del}{$d} {$diffHistLinks}{$chardiff}{$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}";
859 # Denote if username is redacted for this edit
860 if ( $rev->isDeleted( Revision
::DELETED_USER
) ) {
861 $ret .= " <strong>" . $this->msg( 'rev-deleted-user-contribs' )->escaped() . "</strong>";
865 list( $tagSummary, $newClasses ) = ChangeTags
::formatSummaryRow( $row->ts_tags
, 'contributions' );
866 $classes = array_merge( $classes, $newClasses );
867 $ret .= " $tagSummary";
869 // Let extensions add data
870 wfRunHooks( 'ContributionsLineEnding', array( &$this, &$ret, $row ) );
872 $classes = implode( ' ', $classes );
873 $ret = "<li class=\"$classes\">$ret</li>\n";
874 wfProfileOut( __METHOD__
);
879 * Get the Database object in use
881 * @return DatabaseBase
883 public function getDatabase() {
888 * Overwrite Pager function and return a helpful comment
890 function getSqlComment() {
891 if ( $this->namespace ||
$this->deletedOnly
) {
892 return 'contributions page filtered for namespace or RevisionDeleted edits'; // potentially slow, see CR r58153
894 return 'contributions page unfiltered';
898 protected function preventClickjacking() {
899 $this->preventClickjacking
= true;
902 public function getPreventClickjacking() {
903 return $this->preventClickjacking
;