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