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