Change usages of $wgUser->getSkin() in special pages to use $this->getSkin()
[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 getQueryInfo() {
480 global $wgUser, $wgMiserMode;
481 list( $tables, $index, $userCond, $join_cond ) = $this->getUserCond();
482
483 $conds = array_merge( $userCond, $this->getNamespaceCond() );
484 // Paranoia: avoid brute force searches (bug 17342)
485 if( !$wgUser->isAllowed( 'deletedhistory' ) ) {
486 $conds[] = $this->mDb->bitAnd('rev_deleted',Revision::DELETED_USER) . ' = 0';
487 } elseif( !$wgUser->isAllowed( 'suppressrevision' ) ) {
488 $conds[] = $this->mDb->bitAnd('rev_deleted',Revision::SUPPRESSED_USER) .
489 ' != ' . Revision::SUPPRESSED_USER;
490 }
491 $join_cond['page'] = array( 'INNER JOIN', 'page_id=rev_page' );
492
493 $fields = array(
494 'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'page_is_redirect',
495 'page_len','rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment',
496 'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted',
497 'rev_len'
498 );
499 if ( $this->showSizeDiff && !$wgMiserMode ) {
500 $fields = array_merge( $fields, array( 'rc_old_len', 'rc_new_len' ) );
501 array_unshift( $tables, 'recentchanges' );
502 $join_cond['recentchanges'] = array( 'INNER JOIN', "rev_id = rc_this_oldid" );
503 }
504
505 $queryInfo = array(
506 'tables' => $tables,
507 'fields' => $fields,
508 'conds' => $conds,
509 'options' => array( 'USE INDEX' => array('revision' => $index) ),
510 'join_conds' => $join_cond
511 );
512 ChangeTags::modifyDisplayQuery(
513 $queryInfo['tables'],
514 $queryInfo['fields'],
515 $queryInfo['conds'],
516 $queryInfo['join_conds'],
517 $queryInfo['options'],
518 $this->tagFilter
519 );
520
521 wfRunHooks( 'ContribsPager::getQueryInfo', array( &$this, &$queryInfo ) );
522 return $queryInfo;
523 }
524
525 function getUserCond() {
526 $condition = array();
527 $join_conds = array();
528
529 if( $this->target == 'newbies' ) {
530 $tables = array( 'user_groups', 'page', 'revision' );
531 $max = $this->mDb->selectField( 'user', 'max(user_id)', false, __METHOD__ );
532 $condition[] = 'rev_user >' . (int)($max - $max / 100);
533 $condition[] = 'ug_group IS NULL';
534 $index = 'user_timestamp';
535 # @todo FIXME: Other groups may have 'bot' rights
536 $join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" );
537 } else {
538 $tables = array( 'page', 'revision' );
539 $condition['rev_user_text'] = $this->target;
540 $index = 'usertext_timestamp';
541 }
542 if( $this->deletedOnly ) {
543 $condition[] = "rev_deleted != '0'";
544 }
545 if( $this->topOnly ) {
546 $condition[] = "rev_id = page_latest";
547 }
548 return array( $tables, $index, $condition, $join_conds );
549 }
550
551 function getNamespaceCond() {
552 global $wgMiserMode;
553 if( $this->namespace !== '' && !$wgMiserMode ) {
554 return array( 'page_namespace' => (int)$this->namespace );
555 } else {
556 return array();
557 }
558 }
559
560 function getIndexField() {
561 return 'rev_timestamp';
562 }
563
564 function getStartBody() {
565 return "<ul>\n";
566 }
567
568 function getEndBody() {
569 return "</ul>\n";
570 }
571
572 /**
573 * Generates each row in the contributions list.
574 *
575 * Contributions which are marked "top" are currently on top of the history.
576 * For these contributions, a [rollback] link is shown for users with roll-
577 * back privileges. The rollback link restores the most recent version that
578 * was not written by the target user.
579 *
580 * @todo This would probably look a lot nicer in a table.
581 */
582 function formatRow( $row ) {
583 global $wgUser, $wgLang;
584 wfProfileIn( __METHOD__ );
585
586 $sk = $this->getSkin();
587 $rev = new Revision( $row );
588 $classes = array();
589
590 $page = Title::newFromRow( $row );
591 $link = $sk->link(
592 $page,
593 htmlspecialchars( $page->getPrefixedText() ),
594 array(),
595 $page->isRedirect() ? array( 'redirect' => 'no' ) : array()
596 );
597 # Mark current revisions
598 $topmarktext = '';
599 if( $row->rev_id == $row->page_latest ) {
600 $topmarktext .= '<span class="mw-uctop">' . $this->messages['uctop'] . '</span>';
601 # Add rollback link
602 if( !$row->page_is_new && $page->quickUserCan( 'rollback' )
603 && $page->quickUserCan( 'edit' ) )
604 {
605 $this->preventClickjacking();
606 $topmarktext .= ' '.$sk->generateRollback( $rev );
607 }
608 }
609 # Is there a visible previous revision?
610 if( $rev->userCan( Revision::DELETED_TEXT ) && $rev->getParentId() !== 0 ) {
611 $difftext = $sk->linkKnown(
612 $page,
613 $this->messages['diff'],
614 array(),
615 array(
616 'diff' => 'prev',
617 'oldid' => $row->rev_id
618 )
619 );
620 } else {
621 $difftext = $this->messages['diff'];
622 }
623 $histlink = $sk->linkKnown(
624 $page,
625 $this->messages['hist'],
626 array(),
627 array( 'action' => 'history' )
628 );
629
630 $comment = wfUILang()->getDirMark() . $sk->revComment( $rev, false, true );
631 $date = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true );
632 if( $rev->userCan( Revision::DELETED_TEXT ) ) {
633 $d = $sk->linkKnown(
634 $page,
635 htmlspecialchars($date),
636 array(),
637 array( 'oldid' => intval( $row->rev_id ) )
638 );
639 } else {
640 $d = htmlspecialchars( $date );
641 }
642 if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
643 $d = '<span class="history-deleted">' . $d . '</span>';
644 }
645
646 if( $this->target == 'newbies' ) {
647 $userlink = ' . . ' . $sk->userLink( $row->rev_user, $row->rev_user_text );
648 $userlink .= ' ' . wfMsg( 'parentheses', $sk->userTalkLink( $row->rev_user, $row->rev_user_text ) ) . ' ';
649 } else {
650 $userlink = '';
651 }
652
653 if( $rev->getParentId() === 0 ) {
654 $nflag = ChangesList::flag( 'newpage' );
655 } else {
656 $nflag = '';
657 }
658
659 if( $rev->isMinor() ) {
660 $mflag = ChangesList::flag( 'minor' );
661 } else {
662 $mflag = '';
663 }
664
665 // Don't show useless link to people who cannot hide revisions
666 $canHide = $wgUser->isAllowed( 'deleterevision' );
667 if( $canHide || ($rev->getVisibility() && $wgUser->isAllowed('deletedhistory')) ) {
668 if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
669 $del = $this->mSkin->revDeleteLinkDisabled( $canHide ); // revision was hidden from sysops
670 } else {
671 $query = array(
672 'type' => 'revision',
673 'target' => $page->getPrefixedDbkey(),
674 'ids' => $rev->getId()
675 );
676 $del = $this->mSkin->revDeleteLink( $query,
677 $rev->isDeleted( Revision::DELETED_RESTRICTED ), $canHide );
678 }
679 $del .= ' ';
680 } else {
681 $del = '';
682 }
683
684 $diffHistLinks = '(' . $difftext . $this->messages['pipe-separator'] . $histlink . ')';
685
686
687 $diffOut = ( $this->showSizeDiff ) ? ' . . '.ChangesList::showCharacterDifference( $row->rc_old_len, $row->rc_new_len ) : ' . . '.Linker::formatRevisionSize( $row->rev_len );
688
689 $ret = "{$del}{$d} {$diffHistLinks} {$nflag}{$mflag} {$link}{$diffOut}{$userlink} {$comment} {$topmarktext}";
690
691 # Denote if username is redacted for this edit
692 if( $rev->isDeleted( Revision::DELETED_USER ) ) {
693 $ret .= " <strong>" . wfMsgHtml('rev-deleted-user-contribs') . "</strong>";
694 }
695
696 # Tags, if any.
697 list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'contributions' );
698 $classes = array_merge( $classes, $newClasses );
699 $ret .= " $tagSummary";
700
701 // Let extensions add data
702 wfRunHooks( 'ContributionsLineEnding', array( &$this, &$ret, $row ) );
703
704 $classes = implode( ' ', $classes );
705 $ret = "<li class=\"$classes\">$ret</li>\n";
706 wfProfileOut( __METHOD__ );
707 return $ret;
708 }
709
710 /**
711 * Get the Database object in use
712 *
713 * @return DatabaseBase
714 */
715 public function getDatabase() {
716 return $this->mDb;
717 }
718
719 /**
720 * Overwrite Pager function and return a helpful comment
721 */
722 function getSqlComment() {
723 if ( $this->namespace || $this->deletedOnly ) {
724 return 'contributions page filtered for namespace or RevisionDeleted edits'; // potentially slow, see CR r58153
725 } else {
726 return 'contributions page unfiltered';
727 }
728 }
729
730 protected function preventClickjacking() {
731 $this->preventClickjacking = true;
732 }
733
734 public function getPreventClickjacking() {
735 return $this->preventClickjacking;
736 }
737 }