add GENDER support to revision-info
[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 $id = $rev->getId();
305 $jsCall = "updateShowHideForm($id,this.checked)";
306 $del = Xml::check( 'showhiderevisions', false,
307 $hidden + array(
308 'onchange' => $jsCall,
309 'id' => "mw-revdel-$id" ) );
310 $query = array(
311 'type' => 'revision',
312 'target' => $this->mTitle->getPrefixedDbkey(),
313 'ids' => $rev->getId() );
314 $del .= $this->mSkin->revDeleteLink( $query,
315 $rev->isDeleted( Revision::DELETED_RESTRICTED ) );
316 }
317 $s .= " $del ";
318 }
319
320 $s .= " $link";
321 $s .= " <span class='history-user'>" . $this->mSkin->revUserTools( $rev, true ) . "</span>";
322
323 if( $rev->isMinor() ) {
324 $s .= ' ' . Xml::element( 'span', array( 'class' => 'minor' ), wfMsg( 'minoreditletter') );
325 }
326
327 if( !is_null( $size = $rev->getSize() ) && !$rev->isDeleted( Revision::DELETED_TEXT ) ) {
328 $s .= ' ' . $this->mSkin->formatRevisionSize( $size );
329 }
330
331 $s .= $this->mSkin->revComment( $rev, false, true );
332
333 if( $notificationtimestamp && ($row->rev_timestamp >= $notificationtimestamp) ) {
334 $s .= ' <span class="updatedmarker">' . wfMsgHtml( 'updatedmarker' ) . '</span>';
335 }
336
337 $tools = array();
338
339 if( !is_null( $next ) && is_object( $next ) ) {
340 if( $latest && $this->mTitle->userCan( 'rollback' ) && $this->mTitle->userCan( 'edit' ) ) {
341 $tools[] = '<span class="mw-rollback-link">'.
342 $this->mSkin->buildRollbackLink( $rev ).'</span>';
343 }
344
345 if( $this->mTitle->quickUserCan( 'edit' )
346 && !$rev->isDeleted( Revision::DELETED_TEXT )
347 && !$next->rev_deleted & Revision::DELETED_TEXT )
348 {
349 # Create undo tooltip for the first (=latest) line only
350 $undoTooltip = $latest
351 ? array( 'title' => wfMsg( 'tooltip-undo' ) )
352 : array();
353 $undolink = $this->mSkin->link(
354 $this->mTitle,
355 wfMsgHtml( 'editundo' ),
356 $undoTooltip,
357 array( 'action' => 'edit', 'undoafter' => $next->rev_id, 'undo' => $rev->getId() ),
358 array( 'known', 'noclasses' )
359 );
360 $tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
361 }
362 }
363
364 if( $tools ) {
365 $s .= ' (' . $wgLang->pipeList( $tools ) . ')';
366 }
367
368 # Tags
369 list($tagSummary, $newClasses) = ChangeTags::formatSummaryRow( $row->ts_tags, 'history' );
370 $classes = array_merge( $classes, $newClasses );
371 $s .= " $tagSummary";
372
373 wfRunHooks( 'PageHistoryLineEnding', array( $this, &$row , &$s ) );
374
375 $classes = implode( ' ', $classes );
376
377 return "<li class=\"$classes\">$s</li>\n";
378 }
379
380 /**
381 * Create a link to view this revision of the page
382 * @param Revision $rev
383 * @returns string
384 */
385 function revLink( $rev ) {
386 global $wgLang;
387 $date = $wgLang->timeanddate( wfTimestamp(TS_MW, $rev->getTimestamp()), true );
388 $date = htmlspecialchars( $date );
389 if( !$rev->isDeleted( Revision::DELETED_TEXT ) ) {
390 $link = $this->mSkin->link(
391 $this->mTitle,
392 $date,
393 array(),
394 array( 'oldid' => $rev->getId() ),
395 array( 'known', 'noclasses' )
396 );
397 } else {
398 $link = "<span class=\"history-deleted\">$date</span>";
399 }
400 return $link;
401 }
402
403 /**
404 * Create a diff-to-current link for this revision for this page
405 * @param Revision $rev
406 * @param Bool $latest, this is the latest revision of the page?
407 * @returns string
408 */
409 function curLink( $rev, $latest ) {
410 $cur = $this->message['cur'];
411 if( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) {
412 return $cur;
413 } else {
414 return $this->mSkin->link(
415 $this->mTitle,
416 $cur,
417 array(),
418 array(
419 'diff' => $this->mTitle->getLatestRevID(),
420 'oldid' => $rev->getId()
421 ),
422 array( 'known', 'noclasses' )
423 );
424 }
425 }
426
427 /**
428 * Create a diff-to-previous link for this revision for this page.
429 * @param Revision $prevRev, the previous revision
430 * @param mixed $next, the newer revision
431 * @param int $counter, what row on the history list this is
432 * @returns string
433 */
434 function lastLink( $prevRev, $next, $counter ) {
435 $last = $this->message['last'];
436 # $next may either be a Row, null, or "unkown"
437 $nextRev = is_object($next) ? new Revision( $next ) : $next;
438 if( is_null($next) ) {
439 # Probably no next row
440 return $last;
441 } elseif( $next === 'unknown' ) {
442 # Next row probably exists but is unknown, use an oldid=prev link
443 return $this->mSkin->link(
444 $this->mTitle,
445 $last,
446 array(),
447 array(
448 'diff' => $prevRev->getId(),
449 'oldid' => 'prev'
450 ),
451 array( 'known', 'noclasses' )
452 );
453 } elseif( !$prevRev->userCan(Revision::DELETED_TEXT) || !$nextRev->userCan(Revision::DELETED_TEXT) ) {
454 return $last;
455 } else {
456 return $this->mSkin->link(
457 $this->mTitle,
458 $last,
459 array(),
460 array(
461 'diff' => $prevRev->getId(),
462 'oldid' => $next->rev_id
463 ),
464 array( 'known', 'noclasses' )
465 );
466 }
467 }
468
469 /**
470 * Create radio buttons for page history
471 *
472 * @param object $rev Revision
473 * @param bool $firstInList Is this version the first one?
474 * @param int $counter A counter of what row number we're at, counted from the top row = 1.
475 * @return string HTML output for the radio buttons
476 */
477 function diffButtons( $rev, $firstInList, $counter ) {
478 if( $this->linesonpage > 1 ) {
479 $id = $rev->getId();
480 $radio = array( 'type' => 'radio', 'value' => $id );
481 /** @todo: move title texts to javascript */
482 if( $firstInList ) {
483 $first = Xml::element( 'input',
484 array_merge( $radio, array(
485 'style' => 'visibility:hidden',
486 'name' => 'oldid',
487 'id' => 'mw-oldid-null' ) )
488 );
489 $checkmark = array( 'checked' => 'checked' );
490 } else {
491 # Check visibility of old revisions
492 if( !$rev->userCan( Revision::DELETED_TEXT ) ) {
493 $radio['disabled'] = 'disabled';
494 $checkmark = array(); // We will check the next possible one
495 } else if( $counter == 2 || !$this->mOldIdChecked ) {
496 $checkmark = array( 'checked' => 'checked' );
497 $this->mOldIdChecked = $id;
498 } else {
499 $checkmark = array();
500 }
501 $first = Xml::element( 'input',
502 array_merge( $radio, $checkmark, array(
503 'name' => 'oldid',
504 'id' => "mw-oldid-$id" ) ) );
505 $checkmark = array();
506 }
507 $second = Xml::element( 'input',
508 array_merge( $radio, $checkmark, array(
509 'name' => 'diff',
510 'id' => "mw-diff-$id" ) ) );
511 return $first . $second;
512 } else {
513 return '';
514 }
515 }
516
517 /**
518 * Fetch an array of revisions, specified by a given limit, offset and
519 * direction. This is now only used by the feeds. It was previously
520 * used by the main UI but that's now handled by the pager.
521 */
522 function fetchRevisions($limit, $offset, $direction) {
523 $dbr = wfGetDB( DB_SLAVE );
524
525 if( $direction == PageHistory::DIR_PREV )
526 list($dirs, $oper) = array("ASC", ">=");
527 else /* $direction == PageHistory::DIR_NEXT */
528 list($dirs, $oper) = array("DESC", "<=");
529
530 if( $offset )
531 $offsets = array("rev_timestamp $oper '$offset'");
532 else
533 $offsets = array();
534
535 $page_id = $this->mTitle->getArticleID();
536
537 return $dbr->select( 'revision',
538 Revision::selectFields(),
539 array_merge(array("rev_page=$page_id"), $offsets),
540 __METHOD__,
541 array( 'ORDER BY' => "rev_timestamp $dirs",
542 'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit)
543 );
544 }
545
546 /**
547 * Output a subscription feed listing recent edits to this page.
548 * @param string $type
549 */
550 function feed( $type ) {
551 global $wgFeedClasses, $wgRequest, $wgFeedLimit;
552 if( !FeedUtils::checkFeedOutput($type) ) {
553 return;
554 }
555
556 $feed = new $wgFeedClasses[$type](
557 $this->mTitle->getPrefixedText() . ' - ' .
558 wfMsgForContent( 'history-feed-title' ),
559 wfMsgForContent( 'history-feed-description' ),
560 $this->mTitle->getFullUrl( array( 'action' => 'history' ) )
561 );
562
563 // Get a limit on number of feed entries. Provide a sane default
564 // of 10 if none is defined (but limit to $wgFeedLimit max)
565 $limit = $wgRequest->getInt( 'limit', 10 );
566 if( $limit > $wgFeedLimit || $limit < 1 ) {
567 $limit = 10;
568 }
569 $items = $this->fetchRevisions($limit, 0, PageHistory::DIR_NEXT);
570
571 $feed->outHeader();
572 if( $items ) {
573 foreach( $items as $row ) {
574 $feed->outItem( $this->feedItem( $row ) );
575 }
576 } else {
577 $feed->outItem( $this->feedEmpty() );
578 }
579 $feed->outFooter();
580 }
581
582 function feedEmpty() {
583 global $wgOut;
584 return new FeedItem(
585 wfMsgForContent( 'nohistory' ),
586 $wgOut->parse( wfMsgForContent( 'history-feed-empty' ) ),
587 $this->mTitle->getFullUrl(),
588 wfTimestamp( TS_MW ),
589 '',
590 $this->mTitle->getTalkPage()->getFullUrl() );
591 }
592
593 /**
594 * Generate a FeedItem object from a given revision table row
595 * Borrows Recent Changes' feed generation functions for formatting;
596 * includes a diff to the previous revision (if any).
597 *
598 * @param $row
599 * @return FeedItem
600 */
601 function feedItem( $row ) {
602 $rev = new Revision( $row );
603 $rev->setTitle( $this->mTitle );
604 $text = FeedUtils::formatDiffRow( $this->mTitle,
605 $this->mTitle->getPreviousRevisionID( $rev->getId() ),
606 $rev->getId(),
607 $rev->getTimestamp(),
608 $rev->getComment() );
609
610 if( $rev->getComment() == '' ) {
611 global $wgContLang;
612 $ts = $rev->getTimestamp();
613 $title = wfMsgForContent( 'history-feed-item-nocomment',
614 $rev->getUserText(),
615 $wgContLang->timeanddate( $ts ),
616 $wgContLang->date( $ts ),
617 $wgContLang->time( $ts ) );
618 } else {
619 $title = $rev->getUserText() . wfMsgForContent( 'colon-separator' ) . FeedItem::stripComment( $rev->getComment() );
620 }
621
622 return new FeedItem(
623 $title,
624 $text,
625 $this->mTitle->getFullUrl( array(
626 'diff' => $rev->getId(),
627 'oldid' => 'prev'
628 ) ),
629 $rev->getTimestamp(),
630 $rev->getUserText(),
631 $this->mTitle->getTalkPage()->getFullUrl() );
632 }
633 }
634
635 /**
636 * @ingroup Pager
637 */
638 class PageHistoryPager extends ReverseChronologicalPager {
639 public $mLastRow = false, $mPageHistory, $mTitle;
640
641 function __construct( $pageHistory, $year='', $month='', $tagFilter = '' ) {
642 parent::__construct();
643 $this->mPageHistory = $pageHistory;
644 $this->mTitle =& $this->mPageHistory->mTitle;
645 $this->tagFilter = $tagFilter;
646 $this->getDateCond( $year, $month );
647 }
648
649 function getQueryInfo() {
650 $queryInfo = array(
651 'tables' => array('revision'),
652 'fields' => array_merge( Revision::selectFields(), array('ts_tags') ),
653 'conds' => array('rev_page' => $this->mPageHistory->mTitle->getArticleID() ),
654 'options' => array( 'USE INDEX' => array('revision' => 'page_timestamp') ),
655 'join_conds' => array( 'tag_summary' => array( 'LEFT JOIN', 'ts_rev_id=rev_id' ) ),
656 );
657 ChangeTags::modifyDisplayQuery( $queryInfo['tables'],
658 $queryInfo['fields'],
659 $queryInfo['conds'],
660 $queryInfo['join_conds'],
661 $queryInfo['options'],
662 $this->tagFilter );
663 wfRunHooks( 'PageHistoryPager::getQueryInfo', array( &$this, &$queryInfo ) );
664 return $queryInfo;
665 }
666
667 function getIndexField() {
668 return 'rev_timestamp';
669 }
670
671 function formatRow( $row ) {
672 if( $this->mLastRow ) {
673 $latest = $this->mCounter == 1 && $this->mIsFirst;
674 $firstInList = $this->mCounter == 1;
675 $s = $this->mPageHistory->historyLine( $this->mLastRow, $row, $this->mCounter++,
676 $this->mTitle->getNotificationTimestamp(), $latest, $firstInList );
677 } else {
678 $s = '';
679 }
680 $this->mLastRow = $row;
681 return $s;
682 }
683
684 function getStartBody() {
685 $this->mLastRow = false;
686 $this->mCounter = 1;
687 return '';
688 }
689
690 function getEndBody() {
691 if( $this->mLastRow ) {
692 $latest = $this->mCounter == 1 && $this->mIsFirst;
693 $firstInList = $this->mCounter == 1;
694 if( $this->mIsBackwards ) {
695 # Next row is unknown, but for UI reasons, probably exists if an offset has been specified
696 if( $this->mOffset == '' ) {
697 $next = null;
698 } else {
699 $next = 'unknown';
700 }
701 } else {
702 # The next row is the past-the-end row
703 $next = $this->mPastTheEndRow;
704 }
705 $s = $this->mPageHistory->historyLine( $this->mLastRow, $next, $this->mCounter++,
706 $this->mTitle->getNotificationTimestamp(), $latest, $firstInList );
707 } else {
708 $s = '';
709 }
710 return $s;
711 }
712 }