PageHistory.php 19 KB

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