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