Minor fixes to r55918 - documentation and variable names
[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 $title Title object for the target
243 * @param $userId ID of the user
244 */
245 protected function showBlock( $title, $userId ) {
246 global $wgUser, $wgOut;
247 if ( !User::newFromID( $userId )->isBlocked() )
248 return; # User is not blocked, nothing to do here
249 $loglist = new LogEventsList( $wgUser->getSkin(), $wgOut );
250 $pager = new LogPager( $loglist, 'block', false, $title->getPrefixedText() );
251 // Check if there is something in the block log.
252 // If this is not the case, either the user is not blocked,
253 // or the account has been hidden via hideuser.
254 if( $pager->getNumRows() > 0 ) {
255 $pager->mLimit = 1; # Show only latest log entry.
256 $wgOut->addHTML( '<div class="mw-warning-with-logexcerpt">' );
257 $wgOut->addWikiMsg( 'sp-contributions-blocked-notice' );
258 $wgOut->addHTML(
259 $loglist->beginLogEventsList() .
260 $pager->getBody() .
261 $loglist->endLogEventsList()
262 );
263 if( $pager->getNumRows() > $pager->mLimit ) {
264 $wgOut->addHTML( $wgUser->getSkin()->link(
265 SpecialPage::getTitleFor( 'Log', 'block' ),
266 wfMsgHtml( 'log-fulllog' ),
267 array(),
268 array( 'page' => $title->getPrefixedText() )
269 ) );
270 }
271 $wgOut->addHTML( '</div>' );
272 }
273 }
274 /**
275 * Generates the namespace selector form with hidden attributes.
276 * @param $this->opts Array: the options to be included.
277 */
278 protected function getForm() {
279 global $wgScript;
280
281 $this->opts['title'] = $this->getTitle()->getPrefixedText();
282 if( !isset( $this->opts['target'] ) ) {
283 $this->opts['target'] = '';
284 } else {
285 $this->opts['target'] = str_replace( '_' , ' ' , $this->opts['target'] );
286 }
287
288 if( !isset( $this->opts['namespace'] ) ) {
289 $this->opts['namespace'] = '';
290 }
291
292 if( !isset( $this->opts['contribs'] ) ) {
293 $this->opts['contribs'] = 'user';
294 }
295
296 if( !isset( $this->opts['year'] ) ) {
297 $this->opts['year'] = '';
298 }
299
300 if( !isset( $this->opts['month'] ) ) {
301 $this->opts['month'] = '';
302 }
303
304 if( $this->opts['contribs'] == 'newbie' ) {
305 $this->opts['target'] = '';
306 }
307
308 if( !isset( $this->opts['tagfilter'] ) ) {
309 $this->opts['tagfilter'] = '';
310 }
311
312 $f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
313 # Add hidden params for tracking
314 foreach ( $this->opts as $name => $value ) {
315 if( in_array( $name, array( 'namespace', 'target', 'contribs', 'year', 'month' ) ) ) {
316 continue;
317 }
318 $f .= "\t" . Xml::hidden( $name, $value ) . "\n";
319 }
320
321 $tagFilter = ChangeTags::buildTagFilterSelector( $this->opts['tagfilter'] );
322
323 $f .= '<fieldset>' .
324 Xml::element( 'legend', array(), wfMsg( 'sp-contributions-search' ) ) .
325 Xml::radioLabel( wfMsgExt( 'sp-contributions-newbies', array( 'parsemag' ) ),
326 'contribs', 'newbie' , 'newbie', $this->opts['contribs'] == 'newbie' ? true : false ) . '<br />' .
327 Xml::radioLabel( wfMsgExt( 'sp-contributions-username', array( 'parsemag' ) ),
328 'contribs' , 'user', 'user', $this->opts['contribs'] == 'user' ? true : false ) . ' ' .
329 Html::input( 'target', $this->opts['target'], 'text', array(
330 'size' => '20',
331 'required' => ''
332 ) + ( $this->opts['target'] ? array() : array( 'autofocus' ) ) ) . ' '.
333 '<span style="white-space: nowrap">' .
334 Xml::label( wfMsg( 'namespace' ), 'namespace' ) . ' ' .
335 Xml::namespaceSelector( $this->opts['namespace'], '' ) .
336 '</span>' .
337 ( $tagFilter ? Xml::tags( 'p', null, implode( '&nbsp;', $tagFilter ) ) : '' ) .
338 Xml::openElement( 'p' ) .
339 '<span style="white-space: nowrap">' .
340 Xml::dateMenu( $this->opts['year'], $this->opts['month'] ) .
341 '</span>' . ' ' .
342 Xml::submitButton( wfMsg( 'sp-contributions-submit' ) ) .
343 Xml::closeElement( 'p' );
344
345 $explain = wfMsgExt( 'sp-contributions-explain', 'parseinline' );
346 if( !wfEmptyMsg( 'sp-contributions-explain', $explain ) )
347 $f .= "<p>{$explain}</p>";
348
349 $f .= '</fieldset>' .
350 Xml::closeElement( 'form' );
351 return $f;
352 }
353
354 /**
355 * Output a subscription feed listing recent edits to this page.
356 * @param string $type
357 */
358 protected function feed( $type ) {
359 global $wgRequest, $wgFeed, $wgFeedClasses, $wgFeedLimit;
360
361 if( !$wgFeed ) {
362 global $wgOut;
363 $wgOut->addWikiMsg( 'feed-unavailable' );
364 return;
365 }
366
367 if( !isset( $wgFeedClasses[$type] ) ) {
368 global $wgOut;
369 $wgOut->addWikiMsg( 'feed-invalid' );
370 return;
371 }
372
373 $feed = new $wgFeedClasses[$type](
374 $this->feedTitle(),
375 wfMsgExt( 'tagline', 'parsemag' ),
376 $this->getTitle()->getFullUrl() . "/" . urlencode($this->opts['target'])
377 );
378
379 // Already valid title
380 $nt = Title::makeTitleSafe( NS_USER, $this->opts['target'] );
381 $target = $this->opts['target'] == 'newbies' ? 'newbies' : $nt->getText();
382
383 $pager = new ContribsPager( $target, $this->opts['namespace'],
384 $this->opts['year'], $this->opts['month'], $this->opts['tagfilter'] );
385
386 $pager->mLimit = min( $this->opts['limit'], $wgFeedLimit );
387
388 $feed->outHeader();
389 if( $pager->getNumRows() > 0 ) {
390 while( $row = $pager->mResult->fetchObject() ) {
391 $feed->outItem( $this->feedItem( $row ) );
392 }
393 }
394 $feed->outFooter();
395 }
396
397 protected function feedTitle() {
398 global $wgContLanguageCode, $wgSitename;
399 $page = SpecialPage::getPage( 'Contributions' );
400 $desc = $page->getDescription();
401 return "$wgSitename - $desc [$wgContLanguageCode]";
402 }
403
404 protected function feedItem( $row ) {
405 $title = Title::MakeTitle( intval( $row->page_namespace ), $row->page_title );
406 if( $title ) {
407 $date = $row->rev_timestamp;
408 $comments = $title->getTalkPage()->getFullURL();
409 $revision = Revision::newFromTitle( $title, $row->rev_id );
410
411 return new FeedItem(
412 $title->getPrefixedText(),
413 $this->feedItemDesc( $revision ),
414 $title->getFullURL(),
415 $date,
416 $this->feedItemAuthor( $revision ),
417 $comments
418 );
419 } else {
420 return NULL;
421 }
422 }
423
424 protected function feedItemAuthor( $revision ) {
425 return $revision->getUserText();
426 }
427
428 protected function feedItemDesc( $revision ) {
429 if( $revision ) {
430 return '<p>' . htmlspecialchars( $revision->getUserText() ) . wfMsgForContent( 'colon-separator' ) .
431 htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) .
432 "</p>\n<hr />\n<div>" .
433 nl2br( htmlspecialchars( $revision->getText() ) ) . "</div>";
434 }
435 return '';
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
448 function __construct( $target, $namespace = false, $year = false, $month = false, $tagFilter = false ) {
449 parent::__construct();
450 foreach( explode( ' ', 'uctop diff newarticle rollbacklink diff hist' ) as $msg ) {
451 $this->messages[$msg] = wfMsgExt( $msg, array( 'escape') );
452 }
453 $this->target = $target;
454 $this->namespace = $namespace;
455 $this->tagFilter = $tagFilter;
456
457 $this->getDateCond( $year, $month );
458
459 $this->mDb = wfGetDB( DB_SLAVE, 'contributions' );
460 }
461
462 function getDefaultQuery() {
463 $query = parent::getDefaultQuery();
464 $query['target'] = $this->target;
465 return $query;
466 }
467
468 function getQueryInfo() {
469 global $wgUser;
470 list( $tables, $index, $userCond, $join_cond ) = $this->getUserCond();
471
472 $conds = array_merge( $userCond, $this->getNamespaceCond() );
473 // Paranoia: avoid brute force searches (bug 17342)
474 if( !$wgUser->isAllowed( 'deleterevision' ) ) {
475 $conds[] = $this->mDb->bitAnd('rev_deleted',Revision::DELETED_USER) . ' = 0';
476 } else if( !$wgUser->isAllowed( 'suppressrevision' ) ) {
477 $conds[] = $this->mDb->bitAnd('rev_deleted',Revision::SUPPRESSED_USER) .
478 ' != ' . Revision::SUPPRESSED_USER;
479 }
480 $join_cond['page'] = array( 'INNER JOIN', 'page_id=rev_page' );
481
482 $queryInfo = array(
483 'tables' => $tables,
484 'fields' => array(
485 'page_namespace', 'page_title', 'page_is_new', 'page_latest', 'page_is_redirect',
486 'page_len','rev_id', 'rev_page', 'rev_text_id', 'rev_timestamp', 'rev_comment',
487 'rev_minor_edit', 'rev_user', 'rev_user_text', 'rev_parent_id', 'rev_deleted'
488 ),
489 'conds' => $conds,
490 'options' => array( 'USE INDEX' => array('revision' => $index) ),
491 'join_conds' => $join_cond
492 );
493
494 ChangeTags::modifyDisplayQuery( $queryInfo['tables'],
495 $queryInfo['fields'],
496 $queryInfo['conds'],
497 $queryInfo['join_conds'],
498 $queryInfo['options'],
499 $this->tagFilter );
500
501 wfRunHooks( 'ContribsPager::getQueryInfo', array( &$this, &$queryInfo ) );
502 return $queryInfo;
503 }
504
505 function getUserCond() {
506 $condition = array();
507 $join_conds = array();
508 if( $this->target == 'newbies' ) {
509 $tables = array( 'user_groups', 'page', 'revision' );
510 $max = $this->mDb->selectField( 'user', 'max(user_id)', false, __METHOD__ );
511 $condition[] = 'rev_user >' . (int)($max - $max / 100);
512 $condition[] = 'ug_group IS NULL';
513 $index = 'user_timestamp';
514 # FIXME: other groups may have 'bot' rights
515 $join_conds['user_groups'] = array( 'LEFT JOIN', "ug_user = rev_user AND ug_group = 'bot'" );
516 } else {
517 $tables = array( 'page', 'revision' );
518 $condition['rev_user_text'] = $this->target;
519 $index = 'usertext_timestamp';
520 }
521 return array( $tables, $index, $condition, $join_conds );
522 }
523
524 function getNamespaceCond() {
525 if( $this->namespace !== '' ) {
526 return array( 'page_namespace' => (int)$this->namespace );
527 } else {
528 return array();
529 }
530 }
531
532 function getIndexField() {
533 return 'rev_timestamp';
534 }
535
536 function getStartBody() {
537 return "<ul>\n";
538 }
539
540 function getEndBody() {
541 return "</ul>\n";
542 }
543
544 /**
545 * Generates each row in the contributions list.
546 *
547 * Contributions which are marked "top" are currently on top of the history.
548 * For these contributions, a [rollback] link is shown for users with roll-
549 * back privileges. The rollback link restores the most recent version that
550 * was not written by the target user.
551 *
552 * @todo This would probably look a lot nicer in a table.
553 */
554 function formatRow( $row ) {
555 global $wgUser, $wgLang, $wgContLang;
556 wfProfileIn( __METHOD__ );
557
558 $sk = $this->getSkin();
559 $rev = new Revision( $row );
560 $classes = array();
561
562 $page = Title::newFromRow( $row );
563 $page->resetArticleId( $row->rev_page ); // use process cache
564 $link = $sk->link(
565 $page,
566 htmlspecialchars( $page->getPrefixedText() ),
567 array(),
568 $page->isRedirect() ? array( 'redirect' => 'no' ) : array()
569 );
570 # Mark current revisions
571 $difftext = $topmarktext = '';
572 if( $row->rev_id == $row->page_latest ) {
573 $topmarktext .= '<span class="mw-uctop">' . $this->messages['uctop'] . '</span>';
574 if( !$row->page_is_new ) {
575 $difftext .= '(' . $sk->linkKnown(
576 $page,
577 $this->messages['diff'],
578 array(),
579 array( 'diff' => 0 )
580 ) . ')';
581 # Add rollback link
582 if( $page->quickUserCan( 'rollback') && $page->quickUserCan( 'edit' ) ) {
583 $topmarktext .= ' '.$sk->generateRollback( $rev );
584 }
585 } else {
586 $difftext .= $this->messages['newarticle'];
587 }
588 }
589 # Is there a visible previous revision?
590 if( !$rev->isDeleted(Revision::DELETED_TEXT) ) {
591 $difftext = '(' . $sk->linkKnown(
592 $page,
593 $this->messages['diff'],
594 array(),
595 array(
596 'diff' => 'prev',
597 'oldid' => $row->rev_id
598 )
599 ) . ')';
600 } else {
601 $difftext = '(' . $this->messages['diff'] . ')';
602 }
603 $histlink = '('.$sk->linkKnown(
604 $page,
605 $this->messages['hist'],
606 array(),
607 array( 'action' => 'history' )
608 ) . ')';
609
610 $comment = $wgContLang->getDirMark() . $sk->revComment( $rev, false, true );
611 $date = $wgLang->timeanddate( wfTimestamp( TS_MW, $row->rev_timestamp ), true );
612 if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
613 $d = '<span class="history-deleted">' . $date . '</span>';
614 } else {
615 $d = $sk->linkKnown(
616 $page,
617 htmlspecialchars($date),
618 array(),
619 array( 'oldid' => intval( $row->rev_id ) )
620 );
621 }
622
623 if( $this->target == 'newbies' ) {
624 $userlink = ' . . ' . $sk->userLink( $row->rev_user, $row->rev_user_text );
625 $userlink .= ' (' . $sk->userTalkLink( $row->rev_user, $row->rev_user_text ) . ') ';
626 } else {
627 $userlink = '';
628 }
629
630 if( $rev->getParentId() === 0 ) {
631 $nflag = ChangesList::flag( 'newpage' );
632 } else {
633 $nflag = '';
634 }
635
636 if( $rev->isMinor() ) {
637 $mflag = ChangesList::flag( 'minor' );
638 } else {
639 $mflag = '';
640 }
641
642 if( $wgUser->isAllowed( 'deleterevision' ) ) {
643 // If revision was hidden from sysops
644 if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
645 $del = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ),
646 '(' . $this->message['rev-delundel'] . ')' ) . ' ';
647 // Otherwise, show the link...
648 } else {
649 $query = array(
650 'type' => 'revision',
651 'target' => $page->getPrefixedDbkey(),
652 'ids' => $rev->getId() );
653 $del = $this->mSkin->revDeleteLink( $query,
654 $rev->isDeleted( Revision::DELETED_RESTRICTED ) ) . ' ';
655 }
656 } else {
657 $del = '';
658 }
659
660 $ret = "{$del}{$d} {$histlink} {$difftext} {$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}";
661
662 # Tags, if any.
663 list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'contributions' );
664 $classes = array_merge( $classes, $newClasses );
665 $ret .= " $tagSummary";
666
667 // Let extensions add data
668 wfRunHooks( 'ContributionsLineEnding', array( &$this, &$ret, $row ) );
669
670 $classes = implode( ' ', $classes );
671 $ret = "<li class=\"$classes\">$ret</li>\n";
672 wfProfileOut( __METHOD__ );
673 return $ret;
674 }
675
676 /**
677 * Get the Database object in use
678 *
679 * @return Database
680 */
681 public function getDatabase() {
682 return $this->mDb;
683 }
684
685 }