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