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