Per Nikerabbit, follow-up to r92231: removed unreachable code
[lhc/web/wiklou.git] / includes / specials / SpecialContributions.php
1 <?php
2 /**
3 * Implements Special:Contributions
4 *
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.
9 *
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.
14 *
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
19 *
20 * @file
21 * @ingroup SpecialPage
22 */
23
24 /**
25 * Special:Contributions, show user contributions in a paged list
26 *
27 * @ingroup SpecialPage
28 */
29
30 class SpecialContributions extends SpecialPage {
31
32 protected $opts;
33
34 public function __construct() {
35 parent::__construct( 'Contributions' );
36 }
37
38 public function execute( $par ) {
39 global $wgUser, $wgOut, $wgRequest;
40
41 $this->setHeaders();
42 $this->outputHeader();
43 $wgOut->addModuleStyles( 'mediawiki.special' );
44
45 $this->opts = array();
46
47 if( $par == 'newbies' ) {
48 $target = 'newbies';
49 $this->opts['contribs'] = 'newbie';
50 } elseif( isset( $par ) ) {
51 $target = $par;
52 } else {
53 $target = $wgRequest->getVal( 'target' );
54 }
55
56 // check for radiobox
57 if( $wgRequest->getVal( 'contribs' ) == 'newbie' ) {
58 $target = 'newbies';
59 $this->opts['contribs'] = 'newbie';
60 }
61
62 $this->opts['deletedOnly'] = $wgRequest->getBool( 'deletedOnly' );
63
64 if( !strlen( $target ) ) {
65 $wgOut->addHTML( $this->getForm() );
66 return;
67 }
68
69 $this->opts['limit'] = $wgRequest->getInt( 'limit', $wgUser->getOption('rclimit') );
70 $this->opts['target'] = $target;
71 $this->opts['topOnly'] = $wgRequest->getBool( 'topOnly' );
72 $this->opts['showSizeDiff'] = $wgRequest->getBool( 'showSizeDiff' );
73
74 $nt = Title::makeTitleSafe( NS_USER, $target );
75 if( !$nt ) {
76 $wgOut->addHTML( $this->getForm() );
77 return;
78 }
79 $id = User::idFromName( $nt->getText() );
80
81 if( $target != 'newbies' ) {
82 $target = $nt->getText();
83 $wgOut->setSubtitle( $this->contributionsSub( $nt, $id ) );
84 $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsgExt( 'contributions-title', array( 'parsemag' ),$target ) ) );
85 $user = User::newFromName( $target, false );
86 if ( is_object( $user ) ) {
87 $this->getSkin()->setRelevantUser( $user );
88 }
89 } else {
90 $wgOut->setSubtitle( wfMsgHtml( 'sp-contributions-newbies-sub') );
91 $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'sp-contributions-newbies-title' ) ) );
92 }
93
94 if( ( $ns = $wgRequest->getVal( 'namespace', null ) ) !== null && $ns !== '' ) {
95 $this->opts['namespace'] = intval( $ns );
96 } else {
97 $this->opts['namespace'] = '';
98 }
99
100 $this->opts['tagFilter'] = (string) $wgRequest->getVal( 'tagFilter' );
101
102 // Allows reverts to have the bot flag in recent changes. It is just here to
103 // be passed in the form at the top of the page
104 if( $wgUser->isAllowed( 'markbotedits' ) && $wgRequest->getBool( 'bot' ) ) {
105 $this->opts['bot'] = '1';
106 }
107
108 $skip = $wgRequest->getText( 'offset' ) || $wgRequest->getText( 'dir' ) == 'prev';
109 # Offset overrides year/month selection
110 if( $skip ) {
111 $this->opts['year'] = '';
112 $this->opts['month'] = '';
113 } else {
114 $this->opts['year'] = $wgRequest->getIntOrNull( 'year' );
115 $this->opts['month'] = $wgRequest->getIntOrNull( 'month' );
116 }
117
118 $feedType = $wgRequest->getVal( 'feed' );
119 if( $feedType ) {
120 // Maintain some level of backwards compatability
121 // If people request feeds using the old parameters, redirect to API
122 $apiParams = array(
123 'action' => 'feedcontributions',
124 'feedformat' => $feedType,
125 'user' => $target,
126 );
127 if ( $this->opts['topOnly'] ) {
128 $apiParams['toponly'] = true;
129 }
130 if ( $this->opts['showSizeDiff'] ) {
131 $apiParams['showsizediff'] = true;
132 }
133 if ( $this->opts['deletedOnly'] ) {
134 $apiParams['deletedonly'] = true;
135 }
136 if ( $this->opts['tagFilter'] !== '' ) {
137 $apiParams['tagfilter'] = $this->opts['tagFilter'];
138 }
139 if ( $this->opts['namespace'] !== '' ) {
140 $apiParams['namespace'] = $this->opts['namespace'];
141 }
142 if ( $this->opts['year'] !== null ) {
143 $apiParams['year'] = $this->opts['year'];
144 }
145 if ( $this->opts['month'] !== null ) {
146 $apiParams['month'] = $this->opts['month'];
147 }
148
149 $url = wfScript( 'api' ) . '?' . wfArrayToCGI( $apiParams );
150
151 $wgOut->redirect( $url, '301' );
152 return;
153 }
154
155 // Add RSS/atom links
156 $this->addFeedLinks( array( 'action' => 'feedcontributions', 'user' => $target ) );
157
158 if ( wfRunHooks( 'SpecialContributionsBeforeMainOutput', array( $id ) ) ) {
159
160 $wgOut->addHTML( $this->getForm() );
161
162 $pager = new ContribsPager( array(
163 'target' => $target,
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 'showSizeDiff' => $this->opts['showSizeDiff'],
170 ) );
171 if( !$pager->getNumRows() ) {
172 $wgOut->addWikiMsg( 'nocontribs', $target );
173 } else {
174 # Show a message about slave lag, if applicable
175 if( ( $lag = $pager->getDatabase()->getLag() ) > 0 )
176 $wgOut->showLagWarning( $lag );
177
178 $wgOut->addHTML(
179 '<p>' . $pager->getNavigationBar() . '</p>' .
180 $pager->getBody() .
181 '<p>' . $pager->getNavigationBar() . '</p>'
182 );
183 }
184 $wgOut->preventClickjacking( $pager->getPreventClickjacking() );
185
186 # Show the appropriate "footer" message - WHOIS tools, etc.
187 if( $target != 'newbies' ) {
188 $message = 'sp-contributions-footer';
189 if ( IP::isIPAddress( $target ) ) {
190 $message = 'sp-contributions-footer-anon';
191 } else {
192 $user = User::newFromName( $target );
193 if ( !$user || $user->isAnon() ) {
194 // No message for non-existing users
195 return;
196 }
197 }
198
199 if( !wfMessage( $message, $target )->isDisabled() ) {
200 $wgOut->wrapWikiMsg(
201 "<div class='mw-contributions-footer'>\n$1\n</div>",
202 array( $message, $target ) );
203 }
204 }
205 }
206 }
207
208 /**
209 * Generates the subheading with links
210 * @param $nt Title object for the target
211 * @param $id Integer: User ID 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.
214 */
215 protected function contributionsSub( $nt, $id ) {
216 global $wgLang, $wgUser, $wgOut;
217
218 $sk = $this->getSkin();
219
220 if ( $id === null ) {
221 $user = htmlspecialchars( $nt->getText() );
222 } else {
223 $user = $sk->link( $nt, htmlspecialchars( $nt->getText() ) );
224 }
225 $userObj = User::newFromName( $nt->getText(), /* check for username validity not needed */ false );
226 $talk = $nt->getTalkPage();
227 if( $talk ) {
228 $tools = self::getUserLinks( $nt, $talk, $userObj, $wgUser );
229 $links = $wgLang->pipeList( $tools );
230
231 // Show a note if the user is blocked and display the last block log entry.
232 if ( $userObj->isBlocked() ) {
233 LogEventsList::showLogExtract(
234 $wgOut,
235 'block',
236 $nt->getPrefixedText(),
237 '',
238 array(
239 'lim' => 1,
240 'showIfEmpty' => false,
241 'msgKey' => array(
242 $userObj->isAnon() ?
243 'sp-contributions-blocked-notice-anon' :
244 'sp-contributions-blocked-notice',
245 $nt->getText() # Support GENDER in 'sp-contributions-blocked-notice'
246 ),
247 'offset' => '' # don't use $wgRequest parameter offset
248 )
249 );
250 }
251 }
252
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 if( wfEmptyMsg( 'contribsub' ) ) {
258 return wfMsgHtml( 'contribsub2', $user, $links );
259 } else {
260 return wfMsgHtml( 'contribsub', "$user ($links)" );
261 }
262 }
263
264 /**
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
269 * @param $subject User: The viewing user ($wgUser is still checked in some cases, like userrights page!!)
270 */
271 public static function getUserLinks( Title $userpage, Title $talkpage, User $target, User $subject ) {
272
273 $sk = $subject->getSkin();
274 $id = $target->getId();
275 $username = $target->getName();
276
277 $tools[] = $sk->link( $talkpage, wfMsgHtml( 'sp-contributions-talk' ) );
278
279 if( ( $id !== null ) || ( $id === null && IP::isIPAddress( $username ) ) ) {
280 if( $subject->isAllowed( 'block' ) ) { # Block / Change block / Unblock links
281 if ( $target->isBlocked() ) {
282 $tools[] = $sk->linkKnown( # Change block link
283 SpecialPage::getTitleFor( 'Block', $username ),
284 wfMsgHtml( 'change-blocklink' )
285 );
286 $tools[] = $sk->linkKnown( # Unblock link
287 SpecialPage::getTitleFor( 'Unblock', $username ),
288 wfMsgHtml( 'unblocklink' )
289 );
290 } else { # User is not blocked
291 $tools[] = $sk->linkKnown( # Block link
292 SpecialPage::getTitleFor( 'Block', $username ),
293 wfMsgHtml( 'blocklink' )
294 );
295 }
296 }
297 # Block log link
298 $tools[] = $sk->linkKnown(
299 SpecialPage::getTitleFor( 'Log', 'block' ),
300 wfMsgHtml( 'sp-contributions-blocklog' ),
301 array(),
302 array(
303 'page' => $userpage->getPrefixedText()
304 )
305 );
306 }
307 # Uploads
308 $tools[] = $sk->linkKnown(
309 SpecialPage::getTitleFor( 'Listfiles', $username ),
310 wfMsgHtml( 'sp-contributions-uploads' )
311 );
312
313 # Other logs link
314 $tools[] = $sk->linkKnown(
315 SpecialPage::getTitleFor( 'Log', $username ),
316 wfMsgHtml( 'sp-contributions-logs' )
317 );
318
319 # Add link to deleted user contributions for priviledged users
320 if( $subject->isAllowed( 'deletedhistory' ) ) {
321 $tools[] = $sk->linkKnown(
322 SpecialPage::getTitleFor( 'DeletedContributions', $username ),
323 wfMsgHtml( 'sp-contributions-deleted' )
324 );
325 }
326
327 # Add a link to change user rights for privileged users
328 $userrightsPage = new UserrightsPage();
329 if( $id !== null && $userrightsPage->userCanChangeRights( $target ) ) {
330 $tools[] = $sk->linkKnown(
331 SpecialPage::getTitleFor( 'Userrights', $username ),
332 wfMsgHtml( 'sp-contributions-userrights' )
333 );
334 }
335
336 wfRunHooks( 'ContributionsToolLinks', array( $id, $userpage, &$tools ) );
337 return $tools;
338 }
339
340 /**
341 * Generates the namespace selector form with hidden attributes.
342 * @return String: HTML fragment
343 */
344 protected function getForm() {
345 global $wgScript, $wgMiserMode;
346
347 $this->opts['title'] = $this->getTitle()->getPrefixedText();
348 if( !isset( $this->opts['target'] ) ) {
349 $this->opts['target'] = '';
350 } else {
351 $this->opts['target'] = str_replace( '_' , ' ' , $this->opts['target'] );
352 }
353
354 if( !isset( $this->opts['namespace'] ) ) {
355 $this->opts['namespace'] = '';
356 }
357
358 if( !isset( $this->opts['contribs'] ) ) {
359 $this->opts['contribs'] = 'user';
360 }
361
362 if( !isset( $this->opts['year'] ) ) {
363 $this->opts['year'] = '';
364 }
365
366 if( !isset( $this->opts['month'] ) ) {
367 $this->opts['month'] = '';
368 }
369
370 if( $this->opts['contribs'] == 'newbie' ) {
371 $this->opts['target'] = '';
372 }
373
374 if( !isset( $this->opts['tagFilter'] ) ) {
375 $this->opts['tagFilter'] = '';
376 }
377
378 if( !isset( $this->opts['topOnly'] ) ) {
379 $this->opts['topOnly'] = false;
380 }
381
382 if( !isset( $this->opts['showSizeDiff'] ) ) {
383 $this->opts['showSizeDiff'] = !$wgMiserMode;
384 }
385
386 $f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'class' => 'mw-contributions-form' ) );
387
388 # Add hidden params for tracking except for parameters in $skipParameters
389 $skipParameters = array( 'namespace', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly', 'showSizeDiff' );
390 foreach ( $this->opts as $name => $value ) {
391 if( in_array( $name, $skipParameters ) ) {
392 continue;
393 }
394 $f .= "\t" . Html::hidden( $name, $value ) . "\n";
395 }
396
397 $tagFilter = ChangeTags::buildTagFilterSelector( $this->opts['tagFilter'] );
398
399 $fNS = '';
400 $fShowDiff = '';
401 if ( !$wgMiserMode ) {
402 $fNS = Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ),
403 Xml::label( wfMsg( 'namespace' ), 'namespace' ) . ' ' .
404 Xml::namespaceSelector( $this->opts['namespace'], '' )
405 );
406 $fShowDiff = Xml::checkLabel( wfMsg( 'sp-contributions-showsizediff' ), 'showSizeDiff', 'mw-show-size-diff', $this->opts['showSizeDiff'] );
407 }
408
409 $f .= Xml::fieldset( wfMsg( 'sp-contributions-search' ) ) .
410 Xml::radioLabel( wfMsgExt( 'sp-contributions-newbies', array( 'parsemag' ) ),
411 'contribs', 'newbie' , 'newbie', $this->opts['contribs'] == 'newbie' ) . '<br />' .
412 Xml::radioLabel( wfMsgExt( 'sp-contributions-username', array( 'parsemag' ) ),
413 'contribs' , 'user', 'user', $this->opts['contribs'] == 'user' ) . ' ' .
414 Html::input( 'target', $this->opts['target'], 'text', array(
415 'size' => '20',
416 'required' => ''
417 ) + ( $this->opts['target'] ? array() : array( 'autofocus' ) ) ) . ' '.
418 $fNS.
419 Xml::checkLabel( wfMsg( 'history-show-deleted' ),
420 'deletedOnly', 'mw-show-deleted-only', $this->opts['deletedOnly'] ) . '<br />' .
421 Xml::tags( 'p', null, Xml::checkLabel( wfMsg( 'sp-contributions-toponly' ),
422 'topOnly', 'mw-show-top-only', $this->opts['topOnly'] ) ) .
423 $fShowDiff.
424 ( $tagFilter ? Xml::tags( 'p', null, implode( '&#160;', $tagFilter ) ) : '' ) .
425 Html::rawElement( 'p', array( 'style' => 'white-space: nowrap' ),
426 Xml::dateMenu( $this->opts['year'], $this->opts['month'] ) . ' ' .
427 Xml::submitButton( wfMsg( 'sp-contributions-submit' ) )
428 ) . ' ';
429 $explain = wfMessage( 'sp-contributions-explain' );
430 if ( $explain->exists() ) {
431 $f .= "<p id='mw-sp-contributions-explain'>{$explain}</p>";
432 }
433 $f .= Xml::closeElement('fieldset' ) .
434 Xml::closeElement( 'form' );
435 return $f;
436 }
437 }
438
439 /**
440 * Pager for Special:Contributions
441 * @ingroup SpecialPage Pager
442 */
443 class ContribsPager extends ReverseChronologicalPager {
444 public $mDefaultDirection = true;
445 var $messages, $target;
446 var $namespace = '', $mDb;
447 var $preventClickjacking = false;
448
449 function __construct( $options ) {
450 parent::__construct();
451
452 $msgs = array( 'uctop', 'diff', 'newarticle', 'rollbacklink', 'diff', 'hist', 'rev-delundel', 'pipe-separator' );
453
454 foreach( $msgs as $msg ) {
455 $this->messages[$msg] = wfMsgExt( $msg, array( 'escapenoentities' ) );
456 }
457
458 $this->target = isset( $options['target'] ) ? $options['target'] : '';
459 $this->namespace = isset( $options['namespace'] ) ? $options['namespace'] : '';
460 $this->tagFilter = isset( $options['tagFilter'] ) ? $options['tagFilter'] : false;
461
462 $this->deletedOnly = !empty( $options['deletedOnly'] );
463 $this->topOnly = !empty( $options['topOnly'] );
464 $this->showSizeDiff = !empty( $options['showSizeDiff'] );
465
466 $year = isset( $options['year'] ) ? $options['year'] : false;
467 $month = isset( $options['month'] ) ? $options['month'] : false;
468 $this->getDateCond( $year, $month );
469
470 $this->mDb = wfGetDB( DB_SLAVE, 'contributions' );
471 }
472
473 function getDefaultQuery() {
474 $query = parent::getDefaultQuery();
475 $query['target'] = $this->target;
476 return $query;
477 }
478
479 function getTitle() {
480 return SpecialPage::getTitleFor( 'Contributions' );
481 }
482
483 function getQueryInfo() {
484 global $wgUser, $wgMiserMode;
485 list( $tables, $index, $userCond, $join_cond ) = $this->getUserCond();
486
487 $conds = array_merge( $userCond, $this->getNamespaceCond() );
488 // Paranoia: avoid brute force searches (bug 17342)
489 if( !$wgUser->isAllowed( 'deletedhistory' ) ) {
490 $conds[] = $this->mDb->bitAnd('rev_deleted',Revision::DELETED_USER) . ' = 0';
491 } elseif( !$wgUser->isAllowed( 'suppressrevision' ) ) {
492 $conds[] = $this->mDb->bitAnd('rev_deleted',Revision::SUPPRESSED_USER) .
493 ' != ' . Revision::SUPPRESSED_USER;
494 }
495 $join_cond['page'] = array( 'INNER JOIN', 'page_id=rev_page' );
496
497 $fields = array(
498 'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'page_is_redirect',
499 'page_len','rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment',
500 'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted',
501 'rev_len'
502 );
503 if ( $this->showSizeDiff && !$wgMiserMode ) {
504 $fields = array_merge( $fields, array( 'rc_old_len', 'rc_new_len' ) );
505 array_unshift( $tables, 'recentchanges' );
506 $join_cond['recentchanges'] = array( 'INNER JOIN', "rev_id = rc_this_oldid" );
507 }
508
509 $queryInfo = array(
510 'tables' => $tables,
511 'fields' => $fields,
512 'conds' => $conds,
513 'options' => array( 'USE INDEX' => array('revision' => $index) ),
514 'join_conds' => $join_cond
515 );
516 ChangeTags::modifyDisplayQuery(
517 $queryInfo['tables'],
518 $queryInfo['fields'],
519 $queryInfo['conds'],
520 $queryInfo['join_conds'],
521 $queryInfo['options'],
522 $this->tagFilter
523 );
524
525 wfRunHooks( 'ContribsPager::getQueryInfo', array( &$this, &$queryInfo ) );
526 return $queryInfo;
527 }
528
529 function getUserCond() {
530 $condition = array();
531 $join_conds = array();
532
533 if( $this->target == 'newbies' ) {
534 $tables = array( 'user_groups', 'page', 'revision' );
535 $max = $this->mDb->selectField( 'user', 'max(user_id)', false, __METHOD__ );
536 $condition[] = 'rev_user >' . (int)($max - $max / 100);
537 $condition[] = 'ug_group IS NULL';
538 $index = 'user_timestamp';
539 # @todo FIXME: Other groups may have 'bot' rights
540 $join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" );
541 } else {
542 $tables = array( 'page', 'revision' );
543 $condition['rev_user_text'] = $this->target;
544 $index = 'usertext_timestamp';
545 }
546 if( $this->deletedOnly ) {
547 $condition[] = "rev_deleted != '0'";
548 }
549 if( $this->topOnly ) {
550 $condition[] = "rev_id = page_latest";
551 }
552 return array( $tables, $index, $condition, $join_conds );
553 }
554
555 function getNamespaceCond() {
556 global $wgMiserMode;
557 if( $this->namespace !== '' && !$wgMiserMode ) {
558 return array( 'page_namespace' => (int)$this->namespace );
559 } else {
560 return array();
561 }
562 }
563
564 function getIndexField() {
565 return 'rev_timestamp';
566 }
567
568 function getStartBody() {
569 return "<ul>\n";
570 }
571
572 function getEndBody() {
573 return "</ul>\n";
574 }
575
576 /**
577 * Generates each row in the contributions list.
578 *
579 * Contributions which are marked "top" are currently on top of the history.
580 * For these contributions, a [rollback] link is shown for users with roll-
581 * back privileges. The rollback link restores the most recent version that
582 * was not written by the target user.
583 *
584 * @todo This would probably look a lot nicer in a table.
585 */
586 function formatRow( $row ) {
587 global $wgUser, $wgLang;
588 wfProfileIn( __METHOD__ );
589
590 $sk = $this->getSkin();
591 $rev = new Revision( $row );
592 $classes = array();
593
594 $page = Title::newFromRow( $row );
595 $link = $sk->link(
596 $page,
597 htmlspecialchars( $page->getPrefixedText() ),
598 array(),
599 $page->isRedirect() ? array( 'redirect' => 'no' ) : array()
600 );
601 # Mark current revisions
602 $topmarktext = '';
603 if( $row->rev_id == $row->page_latest ) {
604 $topmarktext .= '<span class="mw-uctop">' . $this->messages['uctop'] . '</span>';
605 # Add rollback link
606 if( !$row->page_is_new && $page->quickUserCan( 'rollback' )
607 && $page->quickUserCan( 'edit' ) )
608 {
609 $this->preventClickjacking();
610 $topmarktext .= ' '.$sk->generateRollback( $rev );
611 }
612 }
613 # Is there a visible previous revision?
614 if( $rev->userCan( Revision::DELETED_TEXT ) && $rev->getParentId() !== 0 ) {
615 $difftext = $sk->linkKnown(
616 $page,
617 $this->messages['diff'],
618 array(),
619 array(
620 'diff' => 'prev',
621 'oldid' => $row->rev_id
622 )
623 );
624 } else {
625 $difftext = $this->messages['diff'];
626 }
627 $histlink = $sk->linkKnown(
628 $page,
629 $this->messages['hist'],
630 array(),
631 array( 'action' => 'history' )
632 );
633
634 $comment = $wgLang->getDirMark() . $sk->revComment( $rev, false, true );
635 $date = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true );
636 if( $rev->userCan( Revision::DELETED_TEXT ) ) {
637 $d = $sk->linkKnown(
638 $page,
639 htmlspecialchars($date),
640 array(),
641 array( 'oldid' => intval( $row->rev_id ) )
642 );
643 } else {
644 $d = htmlspecialchars( $date );
645 }
646 if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
647 $d = '<span class="history-deleted">' . $d . '</span>';
648 }
649
650 if( $this->target == 'newbies' ) {
651 $userlink = ' . . ' . $sk->userLink( $row->rev_user, $row->rev_user_text );
652 $userlink .= ' ' . wfMsg( 'parentheses', $sk->userTalkLink( $row->rev_user, $row->rev_user_text ) ) . ' ';
653 } else {
654 $userlink = '';
655 }
656
657 if( $rev->getParentId() === 0 ) {
658 $nflag = ChangesList::flag( 'newpage' );
659 } else {
660 $nflag = '';
661 }
662
663 if( $rev->isMinor() ) {
664 $mflag = ChangesList::flag( 'minor' );
665 } else {
666 $mflag = '';
667 }
668
669 // Don't show useless link to people who cannot hide revisions
670 $canHide = $wgUser->isAllowed( 'deleterevision' );
671 if( $canHide || ($rev->getVisibility() && $wgUser->isAllowed('deletedhistory')) ) {
672 if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
673 $del = $this->mSkin->revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
674 } else {
675 $query = array(
676 'type' => 'revision',
677 'target' => $page->getPrefixedDbkey(),
678 'ids' => $rev->getId()
679 );
680 $del = $this->mSkin->revDeleteLink( $query,
681 $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide );
682 }
683 $del .= ' ';
684 } else {
685 $del = '';
686 }
687
688 $diffHistLinks = '(' . $difftext . $this->messages['pipe-separator'] . $histlink . ')';
689
690
691 $diffOut = ' . . ' . $wgLang->getDirMark() . ( $this->showSizeDiff ?
692 ChangesList::showCharacterDifference( $row->rc_old_len, $row->rc_new_len ) : Linker::formatRevisionSize( $row->rev_len ) );
693
694 $ret = "{$del}{$d} {$diffHistLinks} {$nflag}{$mflag} {$link}{$diffOut}{$userlink} {$comment} {$topmarktext}";
695
696 # Denote if username is redacted for this edit
697 if( $rev->isDeleted( Revision::DELETED_USER ) ) {
698 $ret .= " <strong>" . wfMsgHtml('rev-deleted-user-contribs') . "</strong>";
699 }
700
701 # Tags, if any.
702 list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'contributions' );
703 $classes = array_merge( $classes, $newClasses );
704 $ret .= " $tagSummary";
705
706 // Let extensions add data
707 wfRunHooks( 'ContributionsLineEnding', array( &$this, &$ret, $row ) );
708
709 $classes = implode( ' ', $classes );
710 $ret = "<li class=\"$classes\">$ret</li>\n";
711 wfProfileOut( __METHOD__ );
712 return $ret;
713 }
714
715 /**
716 * Get the Database object in use
717 *
718 * @return DatabaseBase
719 */
720 public function getDatabase() {
721 return $this->mDb;
722 }
723
724 /**
725 * Overwrite Pager function and return a helpful comment
726 */
727 function getSqlComment() {
728 if ( $this->namespace || $this->deletedOnly ) {
729 return 'contributions page filtered for namespace or RevisionDeleted edits'; // potentially slow, see CR r58153
730 } else {
731 return 'contributions page unfiltered';
732 }
733 }
734
735 protected function preventClickjacking() {
736 $this->preventClickjacking = true;
737 }
738
739 public function getPreventClickjacking() {
740 return $this->preventClickjacking;
741 }
742 }