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 $userObj = User
::newFromName( $target, false );
76 $out->addHTML( $this->getForm() );
79 $nt = $userObj->getUserPage();
80 $id = $userObj->getID();
82 if ( $this->opts
['contribs'] != 'newbie' ) {
83 $target = $nt->getText();
84 $out->addSubtitle( $this->contributionsSub( $userObj ) );
85 $out->setHTMLTitle( $this->msg( 'pagetitle', $this->msg( 'contributions-title', $target )->plain() ) );
86 $this->getSkin()->setRelevantUser( $userObj );
88 $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub' ) );
89 $out->setHTMLTitle( $this->msg( 'pagetitle', $this->msg( 'sp-contributions-newbies-title' )->plain() ) );
92 if ( ( $ns = $request->getVal( 'namespace', null ) ) !== null && $ns !== '' ) {
93 $this->opts
['namespace'] = intval( $ns );
95 $this->opts
['namespace'] = '';
98 $this->opts
['associated'] = $request->getBool( 'associated' );
100 $this->opts
['nsInvert'] = (bool) $request->getVal( 'nsInvert' );
102 $this->opts
['tagfilter'] = (string) $request->getVal( 'tagfilter' );
104 // Allows reverts to have the bot flag in recent changes. It is just here to
105 // be passed in the form at the top of the page
106 if ( $user->isAllowed( 'markbotedits' ) && $request->getBool( 'bot' ) ) {
107 $this->opts
['bot'] = '1';
110 $skip = $request->getText( 'offset' ) ||
$request->getText( 'dir' ) == 'prev';
111 # Offset overrides year/month selection
113 $this->opts
['year'] = '';
114 $this->opts
['month'] = '';
116 $this->opts
['year'] = $request->getIntOrNull( 'year' );
117 $this->opts
['month'] = $request->getIntOrNull( 'month' );
120 $feedType = $request->getVal( 'feed' );
122 // Maintain some level of backwards compatability
123 // If people request feeds using the old parameters, redirect to API
125 'action' => 'feedcontributions',
126 'feedformat' => $feedType,
129 if ( $this->opts
['topOnly'] ) {
130 $apiParams['toponly'] = true;
132 if ( $this->opts
['deletedOnly'] ) {
133 $apiParams['deletedonly'] = true;
135 if ( $this->opts
['tagfilter'] !== '' ) {
136 $apiParams['tagfilter'] = $this->opts
['tagfilter'];
138 if ( $this->opts
['namespace'] !== '' ) {
139 $apiParams['namespace'] = $this->opts
['namespace'];
141 if ( $this->opts
['year'] !== null ) {
142 $apiParams['year'] = $this->opts
['year'];
144 if ( $this->opts
['month'] !== null ) {
145 $apiParams['month'] = $this->opts
['month'];
148 $url = wfScript( 'api' ) . '?' . wfArrayToCGI( $apiParams );
150 $out->redirect( $url, '301' );
154 // Add RSS/atom links
155 $this->addFeedLinks( array( 'action' => 'feedcontributions', 'user' => $target ) );
157 if ( wfRunHooks( 'SpecialContributionsBeforeMainOutput', array( $id ) ) ) {
159 $out->addHTML( $this->getForm() );
161 $pager = new ContribsPager( $this->getContext(), array(
163 'contribs' => $this->opts
['contribs'],
164 'namespace' => $this->opts
['namespace'],
165 'year' => $this->opts
['year'],
166 'month' => $this->opts
['month'],
167 'deletedOnly' => $this->opts
['deletedOnly'],
168 'topOnly' => $this->opts
['topOnly'],
169 'nsInvert' => $this->opts
['nsInvert'],
170 'associated' => $this->opts
['associated'],
172 if ( !$pager->getNumRows() ) {
173 $out->addWikiMsg( 'nocontribs', $target );
175 # Show a message about slave lag, if applicable
176 $lag = wfGetLB()->safeGetLag( $pager->getDatabase() );
178 $out->showLagWarning( $lag );
181 '<p>' . $pager->getNavigationBar() . '</p>' .
183 '<p>' . $pager->getNavigationBar() . '</p>'
186 $out->preventClickjacking( $pager->getPreventClickjacking() );
188 # Show the appropriate "footer" message - WHOIS tools, etc.
189 if ( $this->opts
['contribs'] != 'newbie' ) {
190 $message = 'sp-contributions-footer';
191 if ( IP
::isIPAddress( $target ) ) {
192 $message = 'sp-contributions-footer-anon';
194 if ( $userObj->isAnon() ) {
195 // No message for non-existing users
200 if ( !$this->msg( $message, $target )->isDisabled() ) {
202 "<div class='mw-contributions-footer'>\n$1\n</div>",
203 array( $message, $target ) );
210 * Generates the subheading with links
211 * @param $userObj User object for the target
212 * @return String: appropriately-escaped HTML to be output literally
213 * @todo FIXME: Almost the same as getSubTitle in SpecialDeletedContributions.php. Could be combined.
215 protected function contributionsSub( $userObj ) {
216 if ( $userObj->isAnon() ) {
217 $user = htmlspecialchars( $userObj->getName() );
219 $user = Linker
::link( $userObj->getUserPage(), htmlspecialchars( $userObj->getName() ) );
221 $nt = $userObj->getUserPage();
222 $talk = $userObj->getTalkPage();
224 $tools = $this->getUserLinks( $nt, $talk, $userObj );
225 $links = $this->getLanguage()->pipeList( $tools );
227 // Show a note if the user is blocked and display the last block log entry.
228 if ( $userObj->isBlocked() ) {
229 $out = $this->getOutput(); // showLogExtract() wants first parameter by reference
230 LogEventsList
::showLogExtract(
237 'showIfEmpty' => false,
240 'sp-contributions-blocked-notice-anon' :
241 'sp-contributions-blocked-notice',
242 $userObj->getName() # Support GENDER in 'sp-contributions-blocked-notice'
244 'offset' => '' # don't use WebRequest parameter offset
250 // Old message 'contribsub' had one parameter, but that doesn't work for
251 // languages that want to put the "for" bit right after $user but before
252 // $links. If 'contribsub' is around, use it for reverse compatibility,
253 // otherwise use 'contribsub2'.
254 // @todo Should this be removed at some point?
255 $oldMsg = $this->msg( 'contribsub' );
256 if ( $oldMsg->exists() ) {
257 $linksWithParentheses = $this->msg( 'parentheses' )->rawParams( $links )->escaped();
258 return $oldMsg->rawParams( "$user $linksWithParentheses" );
260 return $this->msg( 'contribsub2' )->rawParams( $user, $links );
265 * Links to different places.
266 * @param $userpage Title: Target user page
267 * @param $talkpage Title: Talk page
268 * @param $target User: Target user object
271 public function getUserLinks( Title
$userpage, Title
$talkpage, User
$target ) {
273 $id = $target->getId();
274 $username = $target->getName();
276 $tools[] = Linker
::link( $talkpage, $this->msg( 'sp-contributions-talk' )->escaped() );
278 if ( ( $id !== null ) ||
( $id === null && IP
::isIPAddress( $username ) ) ) {
279 if ( $this->getUser()->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
280 if ( $target->isBlocked() ) {
281 $tools[] = Linker
::linkKnown( # Change block link
282 SpecialPage
::getTitleFor( 'Block', $username ),
283 $this->msg( 'change-blocklink' )->escaped()
285 $tools[] = Linker
::linkKnown( # Unblock link
286 SpecialPage
::getTitleFor( 'Unblock', $username ),
287 $this->msg( 'unblocklink' )->escaped()
289 } else { # User is not blocked
290 $tools[] = Linker
::linkKnown( # Block link
291 SpecialPage
::getTitleFor( 'Block', $username ),
292 $this->msg( 'blocklink' )->escaped()
297 $tools[] = Linker
::linkKnown(
298 SpecialPage
::getTitleFor( 'Log', 'block' ),
299 $this->msg( 'sp-contributions-blocklog' )->escaped(),
302 'page' => $userpage->getPrefixedText()
307 $tools[] = Linker
::linkKnown(
308 SpecialPage
::getTitleFor( 'Listfiles', $username ),
309 $this->msg( 'sp-contributions-uploads' )->escaped()
313 $tools[] = Linker
::linkKnown(
314 SpecialPage
::getTitleFor( 'Log', $username ),
315 $this->msg( 'sp-contributions-logs' )->escaped()
318 # Add link to deleted user contributions for priviledged users
319 if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) {
320 $tools[] = Linker
::linkKnown(
321 SpecialPage
::getTitleFor( 'DeletedContributions', $username ),
322 $this->msg( 'sp-contributions-deleted' )->escaped()
326 # Add a link to change user rights for privileged users
327 $userrightsPage = new UserrightsPage();
328 $userrightsPage->setContext( $this->getContext() );
329 if ( $id !== null && $userrightsPage->userCanChangeRights( $target ) ) {
330 $tools[] = Linker
::linkKnown(
331 SpecialPage
::getTitleFor( 'Userrights', $username ),
332 $this->msg( 'sp-contributions-userrights' )->escaped()
336 wfRunHooks( 'ContributionsToolLinks', array( $id, $userpage, &$tools ) );
341 * Generates the namespace selector form with hidden attributes.
342 * @return String: HTML fragment
344 protected function getForm() {
347 $this->opts
['title'] = $this->getTitle()->getPrefixedText();
348 if ( !isset( $this->opts
['target'] ) ) {
349 $this->opts
['target'] = '';
351 $this->opts
['target'] = str_replace( '_' , ' ' , $this->opts
['target'] );
354 if ( !isset( $this->opts
['namespace'] ) ) {
355 $this->opts
['namespace'] = '';
358 if ( !isset( $this->opts
['nsInvert'] ) ) {
359 $this->opts
['nsInvert'] = '';
362 if ( !isset( $this->opts
['associated'] ) ) {
363 $this->opts
['associated'] = false;
366 if ( !isset( $this->opts
['contribs'] ) ) {
367 $this->opts
['contribs'] = 'user';
370 if ( !isset( $this->opts
['year'] ) ) {
371 $this->opts
['year'] = '';
374 if ( !isset( $this->opts
['month'] ) ) {
375 $this->opts
['month'] = '';
378 if ( $this->opts
['contribs'] == 'newbie' ) {
379 $this->opts
['target'] = '';
382 if ( !isset( $this->opts
['tagfilter'] ) ) {
383 $this->opts
['tagfilter'] = '';
386 if ( !isset( $this->opts
['topOnly'] ) ) {
387 $this->opts
['topOnly'] = false;
390 $form = Xml
::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'class' => 'mw-contributions-form' ) );
392 # Add hidden params for tracking except for parameters in $skipParameters
393 $skipParameters = array( 'namespace', 'nsInvert', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly', 'associated' );
394 foreach ( $this->opts
as $name => $value ) {
395 if ( in_array( $name, $skipParameters ) ) {
398 $form .= "\t" . Html
::hidden( $name, $value ) . "\n";
401 $tagFilter = ChangeTags
::buildTagFilterSelector( $this->opts
['tagfilter'] );
405 Xml
::tags( 'td', array( 'class' => 'mw-label' ), array_shift( $tagFilter ) ) .
406 Xml
::tags( 'td', array( 'class' => 'mw-input' ), implode( ' ', $tagFilter ) );
408 $filterSelection = Xml
::tags( 'td', array( 'colspan' => 2 ), '' );
411 $targetSelection = Xml
::tags( 'td', array( 'colspan' => 2 ),
413 $this->msg( 'sp-contributions-newbies' )->text(),
417 $this->opts
['contribs'] == 'newbie',
418 array( 'class' => 'mw-input' )
421 $this->msg( 'sp-contributions-username' )->text(),
425 $this->opts
['contribs'] == 'user',
426 array( 'class' => 'mw-input' )
430 $this->opts
['target'],
432 array( 'size' => '20', 'required' => '', 'class' => 'mw-input' ) +
433 ( $this->opts
['target'] ?
array() : array( 'autofocus' )
438 $namespaceSelection =
439 Xml
::tags( 'td', array( 'class' => 'mw-label' ),
441 $this->msg( 'namespace' )->text(),
446 Xml
::tags( 'td', null,
447 Html
::namespaceSelector( array(
448 'selected' => $this->opts
['namespace'],
452 'name' => 'namespace',
454 'class' => 'namespaceselector',
457 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
459 $this->msg( 'invert' )->text(),
462 $this->opts
['nsInvert'],
463 array( 'title' => $this->msg( 'tooltip-invert' )->text(), 'class' => 'mw-input' )
466 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
468 $this->msg( 'namespace_association' )->text(),
471 $this->opts
['associated'],
472 array( 'title' => $this->msg( 'tooltip-namespace_association' )->text(), 'class' => 'mw-input' )
477 $extraOptions = Xml
::tags( 'td', array( 'colspan' => 2 ),
478 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
480 $this->msg( 'history-show-deleted' )->text(),
482 'mw-show-deleted-only',
483 $this->opts
['deletedOnly'],
484 array( 'class' => 'mw-input' )
487 Html
::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
489 $this->msg( 'sp-contributions-toponly' )->text(),
492 $this->opts
['topOnly'],
493 array( 'class' => 'mw-input' )
498 $dateSelectionAndSubmit = Xml
::tags( 'td', array( 'colspan' => 2 ),
504 $this->msg( 'sp-contributions-submit' )->text(),
505 array( 'class' => 'mw-submit' )
510 Xml
::fieldset( $this->msg( 'sp-contributions-search' )->text() ) .
511 Xml
::openElement( 'table', array( 'class' => 'mw-contributions-table' ) ) .
512 Xml
::openElement( 'tr' ) .
514 Xml
::closeElement( 'tr' ) .
515 Xml
::openElement( 'tr' ) .
516 $namespaceSelection .
517 Xml
::closeElement( 'tr' ) .
518 Xml
::openElement( 'tr' ) .
520 Xml
::closeElement( 'tr' ) .
521 Xml
::openElement( 'tr' ) .
523 Xml
::closeElement( 'tr' ) .
524 Xml
::openElement( 'tr' ) .
525 $dateSelectionAndSubmit .
526 Xml
::closeElement( 'tr' ) .
527 Xml
::closeElement( 'table' );
529 $explain = $this->msg( 'sp-contributions-explain' );
530 if ( $explain->exists() ) {
531 $form .= "<p id='mw-sp-contributions-explain'>{$explain}</p>";
533 $form .= Xml
::closeElement( 'fieldset' ) .
534 Xml
::closeElement( 'form' );
540 * Pager for Special:Contributions
541 * @ingroup SpecialPage Pager
543 class ContribsPager
extends ReverseChronologicalPager
{
544 public $mDefaultDirection = true;
545 var $messages, $target;
546 var $namespace = '', $mDb;
547 var $preventClickjacking = false;
549 function __construct( IContextSource
$context, array $options ) {
550 parent
::__construct( $context );
552 $msgs = array( 'uctop', 'diff', 'newarticle', 'rollbacklink', 'diff', 'hist', 'rev-delundel', 'pipe-separator' );
554 foreach ( $msgs as $msg ) {
555 $this->messages
[$msg] = $this->msg( $msg )->escaped();
558 $this->target
= isset( $options['target'] ) ?
$options['target'] : '';
559 $this->contribs
= isset( $options['contribs'] ) ?
$options['contribs'] : 'users';
560 $this->namespace = isset( $options['namespace'] ) ?
$options['namespace'] : '';
561 $this->tagFilter
= isset( $options['tagfilter'] ) ?
$options['tagfilter'] : false;
562 $this->nsInvert
= isset( $options['nsInvert'] ) ?
$options['nsInvert'] : false;
563 $this->associated
= isset( $options['associated'] ) ?
$options['associated'] : false;
565 $this->deletedOnly
= !empty( $options['deletedOnly'] );
566 $this->topOnly
= !empty( $options['topOnly'] );
568 $year = isset( $options['year'] ) ?
$options['year'] : false;
569 $month = isset( $options['month'] ) ?
$options['month'] : false;
570 $this->getDateCond( $year, $month );
572 $this->mDb
= wfGetDB( DB_SLAVE
, 'contributions' );
575 function getDefaultQuery() {
576 $query = parent
::getDefaultQuery();
577 $query['target'] = $this->target
;
581 function getQueryInfo() {
582 list( $tables, $index, $userCond, $join_cond ) = $this->getUserCond();
584 $user = $this->getUser();
585 $conds = array_merge( $userCond, $this->getNamespaceCond() );
587 // Paranoia: avoid brute force searches (bug 17342)
588 if ( !$user->isAllowed( 'deletedhistory' ) ) {
589 $conds[] = $this->mDb
->bitAnd( 'rev_deleted', Revision
::DELETED_USER
) . ' = 0';
590 } elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
591 $conds[] = $this->mDb
->bitAnd( 'rev_deleted', Revision
::SUPPRESSED_USER
) .
592 ' != ' . Revision
::SUPPRESSED_USER
;
595 # Don't include orphaned revisions
596 $join_cond['page'] = Revision
::pageJoinCond();
597 # Get the current user name for accounts
598 $join_cond['user'] = Revision
::userJoinCond();
602 'fields' => array_merge(
603 Revision
::selectFields(),
604 Revision
::selectUserFields(),
605 array( 'page_namespace', 'page_title', 'page_is_new',
606 'page_latest', 'page_is_redirect', 'page_len' )
609 'options' => array( 'USE INDEX' => array( 'revision' => $index ) ),
610 'join_conds' => $join_cond
613 ChangeTags
::modifyDisplayQuery(
614 $queryInfo['tables'],
615 $queryInfo['fields'],
617 $queryInfo['join_conds'],
618 $queryInfo['options'],
622 wfRunHooks( 'ContribsPager::getQueryInfo', array( &$this, &$queryInfo ) );
626 function getUserCond() {
627 $condition = array();
628 $join_conds = array();
629 $tables = array( 'revision', 'page', 'user' );
630 if ( $this->contribs
== 'newbie' ) {
631 $tables[] = 'user_groups';
632 $max = $this->mDb
->selectField( 'user', 'max(user_id)', false, __METHOD__
);
633 $condition[] = 'rev_user >' . (int)( $max - $max / 100 );
634 $condition[] = 'ug_group IS NULL';
635 $index = 'user_timestamp';
636 # @todo FIXME: Other groups may have 'bot' rights
637 $join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" );
639 $uid = User
::idFromName( $this->target
);
641 $condition['rev_user'] = $uid;
642 $index = 'user_timestamp';
644 $condition['rev_user_text'] = $this->target
;
645 $index = 'usertext_timestamp';
648 if ( $this->deletedOnly
) {
649 $condition[] = "rev_deleted != '0'";
651 if ( $this->topOnly
) {
652 $condition[] = "rev_id = page_latest";
654 return array( $tables, $index, $condition, $join_conds );
657 function getNamespaceCond() {
658 if ( $this->namespace !== '' ) {
659 $selectedNS = $this->mDb
->addQuotes( $this->namespace );
660 $eq_op = $this->nsInvert ?
'!=' : '=';
661 $bool_op = $this->nsInvert ?
'AND' : 'OR';
663 if ( !$this->associated
) {
664 return array( "page_namespace $eq_op $selectedNS" );
666 $associatedNS = $this->mDb
->addQuotes (
667 MWNamespace
::getAssociated( $this->namespace )
670 "page_namespace $eq_op $selectedNS " .
672 " page_namespace $eq_op $associatedNS"
681 function getIndexField() {
682 return 'rev_timestamp';
685 function doBatchLookups() {
686 $this->mResult
->rewind();
688 foreach ( $this->mResult
as $row ) {
689 if( $row->rev_parent_id
) {
690 $revIds[] = $row->rev_parent_id
;
693 $this->mParentLens
= $this->getParentLengths( $revIds );
694 $this->mResult
->rewind(); // reset
696 # Do a link batch query
697 $this->mResult
->seek( 0 );
698 $batch = new LinkBatch();
699 # Give some pointers to make (last) links
700 foreach ( $this->mResult
as $row ) {
701 if ( $this->contribs
=== 'newbie' ) { // multiple users
702 $batch->add( NS_USER
, $row->user_name
);
703 $batch->add( NS_USER_TALK
, $row->user_name
);
705 $batch->add( $row->page_namespace
, $row->page_title
);
708 $this->mResult
->seek( 0 );
712 * Do a batched query to get the parent revision lengths
715 private function getParentLengths( array $revIds ) {
718 return $revLens; // empty
720 wfProfileIn( __METHOD__
);
721 $res = $this->getDatabase()->select( 'revision',
722 array( 'rev_id', 'rev_len' ),
723 array( 'rev_id' => $revIds ),
725 foreach ( $res as $row ) {
726 $revLens[$row->rev_id
] = $row->rev_len
;
728 wfProfileOut( __METHOD__
);
735 function getStartBody() {
742 function getEndBody() {
747 * Generates each row in the contributions list.
749 * Contributions which are marked "top" are currently on top of the history.
750 * For these contributions, a [rollback] link is shown for users with roll-
751 * back privileges. The rollback link restores the most recent version that
752 * was not written by the target user.
754 * @todo This would probably look a lot nicer in a table.
757 function formatRow( $row ) {
758 wfProfileIn( __METHOD__
);
760 $rev = new Revision( $row );
763 $page = Title
::newFromRow( $row );
764 $link = Linker
::link(
766 htmlspecialchars( $page->getPrefixedText() ),
768 $page->isRedirect() ?
array( 'redirect' => 'no' ) : array()
770 # Mark current revisions
772 if ( $row->rev_id
== $row->page_latest
) {
773 $topmarktext .= '<span class="mw-uctop">' . $this->messages
['uctop'] . '</span>';
775 if ( !$row->page_is_new
&& $page->quickUserCan( 'rollback' )
776 && $page->quickUserCan( 'edit' ) )
778 $this->preventClickjacking();
779 $topmarktext .= ' ' . Linker
::generateRollback( $rev );
782 $user = $this->getUser();
783 # Is there a visible previous revision?
784 if ( $rev->userCan( Revision
::DELETED_TEXT
, $user ) && $rev->getParentId() !== 0 ) {
785 $difftext = Linker
::linkKnown(
787 $this->messages
['diff'],
791 'oldid' => $row->rev_id
795 $difftext = $this->messages
['diff'];
797 $histlink = Linker
::linkKnown(
799 $this->messages
['hist'],
801 array( 'action' => 'history' )
804 if ( $row->rev_parent_id
=== null ) {
805 // For some reason rev_parent_id isn't populated for this row.
806 // Its rumoured this is true on wikipedia for some revisions (bug 34922).
807 // Next best thing is to have the total number of bytes.
808 $chardiff = ' . . ' . Linker
::formatRevisionSize( $row->rev_len
) . ' . . ';
810 $parentLen = isset( $this->mParentLens
[$row->rev_parent_id
] ) ?
$this->mParentLens
[$row->rev_parent_id
] : 0;
811 $chardiff = ' . . ' . ChangesList
::showCharacterDifference(
812 $parentLen, $row->rev_len
) . ' . . ';
815 $lang = $this->getLanguage();
816 $comment = $lang->getDirMark() . Linker
::revComment( $rev, false, true );
817 $date = $lang->userTimeAndDate( $row->rev_timestamp
, $user );
818 if ( $rev->userCan( Revision
::DELETED_TEXT
, $user ) ) {
819 $d = Linker
::linkKnown(
821 htmlspecialchars( $date ),
823 array( 'oldid' => intval( $row->rev_id
) )
826 $d = htmlspecialchars( $date );
828 if ( $rev->isDeleted( Revision
::DELETED_TEXT
) ) {
829 $d = '<span class="history-deleted">' . $d . '</span>';
832 # Show user names for /newbies as there may be different users.
833 # Note that we already excluded rows with hidden user names.
834 if ( $this->contribs
== 'newbie' ) {
835 $userlink = ' . . ' . Linker
::userLink( $rev->getUser(), $rev->getUserText() );
836 $userlink .= ' ' . $this->msg( 'parentheses' )->rawParams(
837 Linker
::userTalkLink( $rev->getUser(), $rev->getUserText() ) )->escaped() . ' ';
842 if ( $rev->getParentId() === 0 ) {
843 $nflag = ChangesList
::flag( 'newpage' );
848 if ( $rev->isMinor() ) {
849 $mflag = ChangesList
::flag( 'minor' );
854 $del = Linker
::getRevDeleteLink( $user, $rev, $page );
859 $diffHistLinks = $this->msg( 'parentheses' )->rawParams( $difftext . $this->messages
['pipe-separator'] . $histlink )->escaped();
860 $ret = "{$del}{$d} {$diffHistLinks}{$chardiff}{$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}";
862 # Denote if username is redacted for this edit
863 if ( $rev->isDeleted( Revision
::DELETED_USER
) ) {
864 $ret .= " <strong>" . $this->msg( 'rev-deleted-user-contribs' )->escaped() . "</strong>";
868 list( $tagSummary, $newClasses ) = ChangeTags
::formatSummaryRow( $row->ts_tags
, 'contributions' );
869 $classes = array_merge( $classes, $newClasses );
870 $ret .= " $tagSummary";
872 // Let extensions add data
873 wfRunHooks( 'ContributionsLineEnding', array( &$this, &$ret, $row ) );
875 $classes = implode( ' ', $classes );
876 $ret = "<li class=\"$classes\">$ret</li>\n";
877 wfProfileOut( __METHOD__
);
882 * Get the Database object in use
884 * @return DatabaseBase
886 public function getDatabase() {
891 * Overwrite Pager function and return a helpful comment
894 function getSqlComment() {
895 if ( $this->namespace ||
$this->deletedOnly
) {
896 return 'contributions page filtered for namespace or RevisionDeleted edits'; // potentially slow, see CR r58153
898 return 'contributions page unfiltered';
902 protected function preventClickjacking() {
903 $this->preventClickjacking
= true;
906 public function getPreventClickjacking() {
907 return $this->preventClickjacking
;