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