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