Fix log type and name in revdeleted messages: suppressions are stored in the suppress...
[lhc/web/wiklou.git] / includes / PageHistory.php
1 <?php
2 /**
3 * Page history
4 *
5 * Split off from Article.php and Skin.php, 2003-12-22
6 * @file
7 */
8
9 /**
10 * This class handles printing the history page for an article. In order to
11 * be efficient, it uses timestamps rather than offsets for paging, to avoid
12 * costly LIMIT,offset queries.
13 *
14 * Construct it by passing in an Article, and call $h->history() to print the
15 * history.
16 *
17 */
18 class PageHistory {
19 const DIR_PREV = 0;
20 const DIR_NEXT = 1;
21
22 var $mArticle, $mTitle, $mSkin;
23 var $lastdate;
24 var $linesonpage;
25 var $mLatestId = null;
26
27 private $mOldIdChecked = 0;
28
29 /**
30 * Construct a new PageHistory.
31 *
32 * @param Article $article
33 * @returns nothing
34 */
35 function __construct( $article ) {
36 global $wgUser;
37 $this->mArticle =& $article;
38 $this->mTitle =& $article->mTitle;
39 $this->mSkin = $wgUser->getSkin();
40 $this->preCacheMessages();
41 }
42
43 function getArticle() {
44 return $this->mArticle;
45 }
46
47 function getTitle() {
48 return $this->mTitle;
49 }
50
51 /**
52 * As we use the same small set of messages in various methods and that
53 * they are called often, we call them once and save them in $this->message
54 */
55 function preCacheMessages() {
56 // Precache various messages
57 if( !isset( $this->message ) ) {
58 foreach( explode(' ', 'cur last rev-delundel' ) as $msg ) {
59 $this->message[$msg] = wfMsgExt( $msg, array( 'escape') );
60 }
61 }
62 }
63
64 /**
65 * Print the history page for an article.
66 *
67 * @returns nothing
68 */
69 function history() {
70 global $wgOut, $wgRequest, $wgScript;
71
72 /*
73 * Allow client caching.
74 */
75 if( $wgOut->checkLastModified( $this->mArticle->getTouched() ) )
76 return; // Client cache fresh and headers sent, nothing more to do.
77
78 wfProfileIn( __METHOD__ );
79
80 /*
81 * Setup page variables.
82 */
83 $wgOut->setPageTitle( wfMsg( 'history-title', $this->mTitle->getPrefixedText() ) );
84 $wgOut->setPageTitleActionText( wfMsg( 'history_short' ) );
85 $wgOut->setArticleFlag( false );
86 $wgOut->setArticleRelated( true );
87 $wgOut->setRobotPolicy( 'noindex,nofollow' );
88 $wgOut->setSyndicated( true );
89 $wgOut->setFeedAppendQuery( 'action=history' );
90 $wgOut->addScriptFile( 'history.js' );
91
92 $logPage = SpecialPage::getTitleFor( 'Log' );
93 $logLink = $this->mSkin->link(
94 $logPage,
95 wfMsgHtml( 'viewpagelogs' ),
96 array(),
97 array( 'page' => $this->mTitle->getPrefixedText() ),
98 array( 'known', 'noclasses' )
99 );
100 $wgOut->setSubtitle( $logLink );
101
102 $feedType = $wgRequest->getVal( 'feed' );
103 if( $feedType ) {
104 wfProfileOut( __METHOD__ );
105 return $this->feed( $feedType );
106 }
107
108 /*
109 * Fail if article doesn't exist.
110 */
111 if( !$this->mTitle->exists() ) {
112 $wgOut->addWikiMsg( 'nohistory' );
113 wfProfileOut( __METHOD__ );
114 return;
115 }
116
117 /**
118 * Add date selector to quickly get to a certain time
119 */
120 $year = $wgRequest->getInt( 'year' );
121 $month = $wgRequest->getInt( 'month' );
122 $tagFilter = $wgRequest->getVal( 'tagfilter' );
123 $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter );
124
125 $action = htmlspecialchars( $wgScript );
126 $wgOut->addHTML(
127 "<form action=\"$action\" method=\"get\" id=\"mw-history-searchform\">" .
128 Xml::fieldset( wfMsg( 'history-fieldset-title' ), false, array( 'id' => 'mw-history-search' ) ) .
129 Xml::hidden( 'title', $this->mTitle->getPrefixedDBKey() ) . "\n" .
130 Xml::hidden( 'action', 'history' ) . "\n" .
131 xml::dateMenu( $year, $month ) . '&nbsp;' .
132 ( $tagSelector ? ( implode( '&nbsp;', $tagSelector ) . '&nbsp;' ) : '' ) .
133 Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
134 '</fieldset></form>'
135 );
136
137 wfRunHooks( 'PageHistoryBeforeList', array( &$this->mArticle ) );
138
139 /**
140 * Do the list
141 */
142 $pager = new PageHistoryPager( $this, $year, $month, $tagFilter );
143 $this->linesonpage = $pager->getNumRows();
144 $wgOut->addHTML(
145 $pager->getNavigationBar() .
146 $this->beginHistoryList() .
147 $pager->getBody() .
148 $this->endHistoryList() .
149 $pager->getNavigationBar()
150 );
151
152 wfProfileOut( __METHOD__ );
153 }
154
155 /**
156 * Creates begin of history list with a submit button
157 *
158 * @return string HTML output
159 */
160 function beginHistoryList() {
161 global $wgUser, $wgScript, $wgEnableHtmlDiff;
162 $this->lastdate = '';
163 $s = wfMsgExt( 'histlegend', array( 'parse') );
164 if( $this->linesonpage > 1 && $wgUser->isAllowed('deleterevision') ) {
165 $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
166 $s .= Xml::openElement( 'form',
167 array(
168 'action' => $revdel->getLocalURL( array(
169 'type' => 'revision',
170 'target' => $this->mTitle->getPrefixedDbKey()
171 ) ),
172 'method' => 'post',
173 'id' => 'mw-history-revdeleteform',
174 'style' => 'visibility:hidden;float:right;'
175 )
176 );
177 $s .= Xml::hidden( 'ids', '', array('id'=>'revdel-oldid') );
178 $s .= Xml::submitButton( wfMsg( 'showhideselectedversions' ) );
179 $s .= Xml::closeElement( 'form' );
180 }
181 $s .= Xml::openElement( 'form', array( 'action' => $wgScript,
182 'id' => 'mw-history-compare' ) );
183 $s .= Xml::hidden( 'title', $this->mTitle->getPrefixedDbKey() );
184 if( $wgEnableHtmlDiff ) {
185 $s .= $this->submitButton( wfMsg( 'visualcomparison'),
186 array(
187 'name' => 'htmldiff',
188 'class' => 'historysubmit',
189 'accesskey' => wfMsg( 'accesskey-visualcomparison' ),
190 'title' => wfMsg( 'tooltip-compareselectedversions' ),
191 )
192 );
193 $s .= $this->submitButton( wfMsg( 'wikicodecomparison'),
194 array(
195 'class' => 'historysubmit',
196 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ),
197 'title' => wfMsg( 'tooltip-compareselectedversions' ),
198 )
199 );
200 } else {
201 $s .= $this->submitButton( wfMsg( 'compareselectedversions'),
202 array(
203 'class' => 'historysubmit',
204 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ),
205 'title' => wfMsg( 'tooltip-compareselectedversions' ),
206 )
207 );
208 }
209 $s .= '<ul id="pagehistory">' . "\n";
210 return $s;
211 }
212
213 /**
214 * Creates end of history list with a submit button
215 *
216 * @return string HTML output
217 */
218 function endHistoryList() {
219 global $wgEnableHtmlDiff;
220 $s = '</ul>';
221 if( $wgEnableHtmlDiff ) {
222 $s .= $this->submitButton( wfMsg( 'visualcomparison'),
223 array(
224 'name' => 'htmldiff',
225 'class' => 'historysubmit',
226 'accesskey' => wfMsg( 'accesskey-visualcomparison' ),
227 'title' => wfMsg( 'tooltip-compareselectedversions' ),
228 )
229 );
230 $s .= $this->submitButton( wfMsg( 'wikicodecomparison'),
231 array(
232 'class' => 'historysubmit',
233 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ),
234 'title' => wfMsg( 'tooltip-compareselectedversions' ),
235 )
236 );
237 } else {
238 $s .= $this->submitButton( wfMsg( 'compareselectedversions'),
239 array(
240 'class' => 'historysubmit',
241 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ),
242 'title' => wfMsg( 'tooltip-compareselectedversions' ),
243 )
244 );
245 }
246 $s .= '</form>';
247 return $s;
248 }
249
250 /**
251 * Creates a submit button
252 *
253 * @param array $attributes attributes
254 * @return string HTML output for the submit button
255 */
256 function submitButton($message, $attributes = array() ) {
257 # Disable submit button if history has 1 revision only
258 if( $this->linesonpage > 1 ) {
259 return Xml::submitButton( $message , $attributes );
260 } else {
261 return '';
262 }
263 }
264
265 /**
266 * Returns a row from the history printout.
267 *
268 * @todo document some more, and maybe clean up the code (some params redundant?)
269 *
270 * @param Row $row The database row corresponding to the previous line.
271 * @param mixed $next The database row corresponding to the next line.
272 * @param int $counter Apparently a counter of what row number we're at, counted from the top row = 1.
273 * @param $notificationtimestamp
274 * @param bool $latest Whether this row corresponds to the page's latest revision.
275 * @param bool $firstInList Whether this row corresponds to the first displayed on this history page.
276 * @return string HTML output for the row
277 */
278 function historyLine( $row, $next, $counter = '', $notificationtimestamp = false,
279 $latest = false, $firstInList = false )
280 {
281 global $wgUser, $wgLang;
282 $rev = new Revision( $row );
283 $rev->setTitle( $this->mTitle );
284
285 $curlink = $this->curLink( $rev, $latest );
286 $lastlink = $this->lastLink( $rev, $next, $counter );
287 $arbitrary = $this->diffButtons( $rev, $firstInList, $counter );
288 $link = $this->revLink( $rev );
289 $classes = array();
290
291 $s = "($curlink) ($lastlink) $arbitrary";
292
293 if( $wgUser->isAllowed( 'deleterevision' ) ) {
294 // Hide JS by default for non-JS browsing
295 $hidden = array( 'style' => 'display:none' );
296 // If revision was hidden from sysops
297 if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
298 $del = Xml::check( 'deleterevisions', false,
299 $hidden + array('disabled' => 'disabled') );
300 $del .= Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ),
301 '(' . $this->message['rev-delundel'] . ')' );
302 // Otherwise, show the link...
303 } else {
304 $jsCall = 'updateShowHideForm('.$rev->getId().',this.checked)';
305 $del = Xml::check( 'showhiderevisions', false,
306 $hidden + array('onchange' => $jsCall) );
307 $query = array(
308 'type' => 'revision',
309 'target' => $this->mTitle->getPrefixedDbkey(),
310 'ids' => $rev->getId() );
311 $del .= $this->mSkin->revDeleteLink( $query,
312 $rev->isDeleted( Revision::DELETED_RESTRICTED ) );
313 }
314 $s .= " $del ";
315 }
316
317 $s .= " $link";
318 $s .= " <span class='history-user'>" . $this->mSkin->revUserTools( $rev, true ) . "</span>";
319
320 if( $rev->isMinor() ) {
321 $s .= ' ' . Xml::element( 'span', array( 'class' => 'minor' ), wfMsg( 'minoreditletter') );
322 }
323
324 if( !is_null( $size = $rev->getSize() ) && !$rev->isDeleted( Revision::DELETED_TEXT ) ) {
325 $s .= ' ' . $this->mSkin->formatRevisionSize( $size );
326 }
327
328 $s .= $this->mSkin->revComment( $rev, false, true );
329
330 if( $notificationtimestamp && ($row->rev_timestamp >= $notificationtimestamp) ) {
331 $s .= ' <span class="updatedmarker">' . wfMsgHtml( 'updatedmarker' ) . '</span>';
332 }
333
334 $tools = array();
335
336 if( !is_null( $next ) && is_object( $next ) ) {
337 if( $latest && $this->mTitle->userCan( 'rollback' ) && $this->mTitle->userCan( 'edit' ) ) {
338 $tools[] = '<span class="mw-rollback-link">'.
339 $this->mSkin->buildRollbackLink( $rev ).'</span>';
340 }
341
342 if( $this->mTitle->quickUserCan( 'edit' )
343 && !$rev->isDeleted( Revision::DELETED_TEXT )
344 && !$next->rev_deleted & Revision::DELETED_TEXT )
345 {
346 # Create undo tooltip for the first (=latest) line only
347 $undoTooltip = $latest
348 ? array( 'title' => wfMsg( 'tooltip-undo' ) )
349 : array();
350 $undolink = $this->mSkin->link(
351 $this->mTitle,
352 wfMsgHtml( 'editundo' ),
353 $undoTooltip,
354 array( 'action' => 'edit', 'undoafter' => $next->rev_id, 'undo' => $rev->getId() ),
355 array( 'known', 'noclasses' )
356 );
357 $tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
358 }
359 }
360
361 if( $tools ) {
362 $s .= ' (' . $wgLang->pipeList( $tools ) . ')';
363 }
364
365 # Tags
366 list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'history' );
367 $classes = array_merge( $classes, $newClasses );
368 $s .= " $tagSummary";
369
370 wfRunHooks( 'PageHistoryLineEnding', array( $this, &$row , &$s ) );
371
372 $classes = implode( ' ', $classes );
373
374 return "<li class=\"$classes\">$s</li>\n";
375 }
376
377 /**
378 * Create a link to view this revision of the page
379 * @param Revision $rev
380 * @returns string
381 */
382 function revLink( $rev ) {
383 global $wgLang;
384 $date = $wgLang->timeanddate( wfTimestamp(TS_MW, $rev->getTimestamp()), true );
385 $date = htmlspecialchars( $date );
386 if( !$rev->isDeleted( Revision::DELETED_TEXT ) ) {
387 $link = $this->mSkin->link(
388 $this->mTitle,
389 $date,
390 array(),
391 array( 'oldid' => $rev->getId() ),
392 array( 'known', 'noclasses' )
393 );
394 } else {
395 $link = "<span class=\"history-deleted\">$date</span>";
396 }
397 return $link;
398 }
399
400 /**
401 * Create a diff-to-current link for this revision for this page
402 * @param Revision $rev
403 * @param Bool $latest, this is the latest revision of the page?
404 * @returns string
405 */
406 function curLink( $rev, $latest ) {
407 $cur = $this->message['cur'];
408 if( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) {
409 return $cur;
410 } else {
411 return $this->mSkin->link(
412 $this->mTitle,
413 $cur,
414 array(),
415 array(
416 'diff' => $this->mTitle->getLatestRevID(),
417 'oldid' => $rev->getId()
418 ),
419 array( 'known', 'noclasses' )
420 );
421 }
422 }
423
424 /**
425 * Create a diff-to-previous link for this revision for this page.
426 * @param Revision $prevRev, the previous revision
427 * @param mixed $next, the newer revision
428 * @param int $counter, what row on the history list this is
429 * @returns string
430 */
431 function lastLink( $prevRev, $next, $counter ) {
432 $last = $this->message['last'];
433 # $next may either be a Row, null, or "unkown"
434 $nextRev = is_object($next) ? new Revision( $next ) : $next;
435 if( is_null($next) ) {
436 # Probably no next row
437 return $last;
438 } elseif( $next === 'unknown' ) {
439 # Next row probably exists but is unknown, use an oldid=prev link
440 return $this->mSkin->link(
441 $this->mTitle,
442 $last,
443 array(),
444 array(
445 'diff' => $prevRev->getId(),
446 'oldid' => 'prev'
447 ),
448 array( 'known', 'noclasses' )
449 );
450 } elseif( !$prevRev->userCan(Revision::DELETED_TEXT) || !$nextRev->userCan(Revision::DELETED_TEXT) ) {
451 return $last;
452 } else {
453 return $this->mSkin->link(
454 $this->mTitle,
455 $last,
456 array(),
457 array(
458 'diff' => $prevRev->getId(),
459 'oldid' => $next->rev_id
460 ),
461 array( 'known', 'noclasses' )
462 );
463 }
464 }
465
466 /**
467 * Create radio buttons for page history
468 *
469 * @param object $rev Revision
470 * @param bool $firstInList Is this version the first one?
471 * @param int $counter A counter of what row number we're at, counted from the top row = 1.
472 * @return string HTML output for the radio buttons
473 */
474 function diffButtons( $rev, $firstInList, $counter ) {
475 if( $this->linesonpage > 1 ) {
476 $radio = array( 'type' => 'radio', 'value' => $rev->getId() );
477 /** @todo: move title texts to javascript */
478 if( $firstInList ) {
479 $first = Xml::element( 'input',
480 array_merge( $radio, array( 'style' => 'visibility:hidden', 'name' => 'oldid' ) )
481 );
482 $checkmark = array( 'checked' => 'checked' );
483 } else {
484 # Check visibility of old revisions
485 if( !$rev->userCan( Revision::DELETED_TEXT ) ) {
486 $radio['disabled'] = 'disabled';
487 $checkmark = array(); // We will check the next possible one
488 } else if( $counter == 2 || !$this->mOldIdChecked ) {
489 $checkmark = array( 'checked' => 'checked' );
490 $this->mOldIdChecked = $rev->getId();
491 } else {
492 $checkmark = array();
493 }
494 $first = Xml::element( 'input', array_merge( $radio, $checkmark, array( 'name' => 'oldid' ) ) );
495 $checkmark = array();
496 }
497 $second = Xml::element( 'input', array_merge( $radio, $checkmark, array( 'name' => 'diff' ) ) );
498 return $first . $second;
499 } else {
500 return '';
501 }
502 }
503
504 /**
505 * Fetch an array of revisions, specified by a given limit, offset and
506 * direction. This is now only used by the feeds. It was previously
507 * used by the main UI but that's now handled by the pager.
508 */
509 function fetchRevisions($limit, $offset, $direction) {
510 $dbr = wfGetDB( DB_SLAVE );
511
512 if( $direction == PageHistory::DIR_PREV )
513 list($dirs, $oper) = array("ASC", ">=");
514 else /* $direction == PageHistory::DIR_NEXT */
515 list($dirs, $oper) = array("DESC", "<=");
516
517 if( $offset )
518 $offsets = array("rev_timestamp $oper '$offset'");
519 else
520 $offsets = array();
521
522 $page_id = $this->mTitle->getArticleID();
523
524 return $dbr->select( 'revision',
525 Revision::selectFields(),
526 array_merge(array("rev_page=$page_id"), $offsets),
527 __METHOD__,
528 array( 'ORDER BY' => "rev_timestamp $dirs",
529 'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit)
530 );
531 }
532
533 /**
534 * Output a subscription feed listing recent edits to this page.
535 * @param string $type
536 */
537 function feed( $type ) {
538 global $wgFeedClasses, $wgRequest, $wgFeedLimit;
539 if( !FeedUtils::checkFeedOutput($type) ) {
540 return;
541 }
542
543 $feed = new $wgFeedClasses[$type](
544 $this->mTitle->getPrefixedText() . ' - ' .
545 wfMsgForContent( 'history-feed-title' ),
546 wfMsgForContent( 'history-feed-description' ),
547 $this->mTitle->getFullUrl( array( 'action' => 'history' ) )
548 );
549
550 // Get a limit on number of feed entries. Provide a sane default
551 // of 10 if none is defined (but limit to $wgFeedLimit max)
552 $limit = $wgRequest->getInt( 'limit', 10 );
553 if( $limit > $wgFeedLimit || $limit < 1 ) {
554 $limit = 10;
555 }
556 $items = $this->fetchRevisions($limit, 0, PageHistory::DIR_NEXT);
557
558 $feed->outHeader();
559 if( $items ) {
560 foreach( $items as $row ) {
561 $feed->outItem( $this->feedItem( $row ) );
562 }
563 } else {
564 $feed->outItem( $this->feedEmpty() );
565 }
566 $feed->outFooter();
567 }
568
569 function feedEmpty() {
570 global $wgOut;
571 return new FeedItem(
572 wfMsgForContent( 'nohistory' ),
573 $wgOut->parse( wfMsgForContent( 'history-feed-empty' ) ),
574 $this->mTitle->getFullUrl(),
575 wfTimestamp( TS_MW ),
576 '',
577 $this->mTitle->getTalkPage()->getFullUrl() );
578 }
579
580 /**
581 * Generate a FeedItem object from a given revision table row
582 * Borrows Recent Changes' feed generation functions for formatting;
583 * includes a diff to the previous revision (if any).
584 *
585 * @param $row
586 * @return FeedItem
587 */
588 function feedItem( $row ) {
589 $rev = new Revision( $row );
590 $rev->setTitle( $this->mTitle );
591 $text = FeedUtils::formatDiffRow( $this->mTitle,
592 $this->mTitle->getPreviousRevisionID( $rev->getId() ),
593 $rev->getId(),
594 $rev->getTimestamp(),
595 $rev->getComment() );
596
597 if( $rev->getComment() == '' ) {
598 global $wgContLang;
599 $ts = $rev->getTimestamp();
600 $title = wfMsgForContent( 'history-feed-item-nocomment',
601 $rev->getUserText(),
602 $wgContLang->timeanddate( $ts ),
603 $wgContLang->date( $ts ),
604 $wgContLang->time( $ts ) );
605 } else {
606 $title = $rev->getUserText() . wfMsgForContent( 'colon-separator' ) . FeedItem::stripComment( $rev->getComment() );
607 }
608
609 return new FeedItem(
610 $title,
611 $text,
612 $this->mTitle->getFullUrl( array(
613 'diff' => $rev->getId(),
614 'oldid' => 'prev'
615 ) ),
616 $rev->getTimestamp(),
617 $rev->getUserText(),
618 $this->mTitle->getTalkPage()->getFullUrl() );
619 }
620 }
621
622 /**
623 * @ingroup Pager
624 */
625 class PageHistoryPager extends ReverseChronologicalPager {
626 public $mLastRow = false, $mPageHistory, $mTitle;
627
628 function __construct( $pageHistory, $year='', $month='', $tagFilter = '' ) {
629 parent::__construct();
630 $this->mPageHistory = $pageHistory;
631 $this->mTitle =& $this->mPageHistory->mTitle;
632 $this->tagFilter = $tagFilter;
633 $this->getDateCond( $year, $month );
634 }
635
636 function getQueryInfo() {
637 $queryInfo = array(
638 'tables' => array('revision'),
639 'fields' => array_merge( Revision::selectFields(), array('ts_tags') ),
640 'conds' => array('rev_page' => $this->mPageHistory->mTitle->getArticleID() ),
641 'options' => array( 'USE INDEX' => array('revision' => 'page_timestamp') ),
642 'join_conds' => array( 'tag_summary' => array( 'LEFT JOIN', 'ts_rev_id=rev_id' ) ),
643 );
644 ChangeTags::modifyDisplayQuery( $queryInfo['tables'],
645 $queryInfo['fields'],
646 $queryInfo['conds'],
647 $queryInfo['join_conds'],
648 $queryInfo['options'],
649 $this->tagFilter );
650 wfRunHooks( 'PageHistoryPager::getQueryInfo', array( &$this, &$queryInfo ) );
651 return $queryInfo;
652 }
653
654 function getIndexField() {
655 return 'rev_timestamp';
656 }
657
658 function formatRow( $row ) {
659 if( $this->mLastRow ) {
660 $latest = $this->mCounter == 1 && $this->mIsFirst;
661 $firstInList = $this->mCounter == 1;
662 $s = $this->mPageHistory->historyLine( $this->mLastRow, $row, $this->mCounter++,
663 $this->mTitle->getNotificationTimestamp(), $latest, $firstInList );
664 } else {
665 $s = '';
666 }
667 $this->mLastRow = $row;
668 return $s;
669 }
670
671 function getStartBody() {
672 $this->mLastRow = false;
673 $this->mCounter = 1;
674 return '';
675 }
676
677 function getEndBody() {
678 if( $this->mLastRow ) {
679 $latest = $this->mCounter == 1 && $this->mIsFirst;
680 $firstInList = $this->mCounter == 1;
681 if( $this->mIsBackwards ) {
682 # Next row is unknown, but for UI reasons, probably exists if an offset has been specified
683 if( $this->mOffset == '' ) {
684 $next = null;
685 } else {
686 $next = 'unknown';
687 }
688 } else {
689 # The next row is the past-the-end row
690 $next = $this->mPastTheEndRow;
691 }
692 $s = $this->mPageHistory->historyLine( $this->mLastRow, $next, $this->mCounter++,
693 $this->mTitle->getNotificationTimestamp(), $latest, $firstInList );
694 } else {
695 $s = '';
696 }
697 return $s;
698 }
699 }