- $dbr =& wfGetDB(DB_SLAVE);
-
- /*
- * Extract limit, the number of revisions to show, and
- * offset, the timestamp to begin at, from the URL.
- */
- $limit = $wgRequest->getInt('limit', $this->defaultLimit);
- $offset = $wgRequest->getText('offset');
-
- /* Offset must be an integral. */
- if (!strlen($offset) || !preg_match("/^[0-9]+$/", $offset))
- $offset = 0;
-# $offset = $dbr->timestamp($offset);
- $dboffset = $offset === 0 ? 0 : $dbr->timestamp($offset);
- /*
- * "go=last" means to jump to the last history page.
- */
- if (($gowhere = $wgRequest->getText("go")) !== NULL) {
- switch ($gowhere) {
- case "first":
- if (($lastid = $this->getLastOffsetForPaging($this->mTitle->getArticleID(), $limit)) === NULL)
- break;
- $gourl = $wgTitle->getLocalURL("action=history&limit={$limit}&offset=".
- wfTimestamp(TS_MW, $lastid));
- break;
- default:
- $gourl = NULL;
- }
-
- if (!is_null($gourl)) {
- $wgOut->redirect($gourl);
- return;
- }
- }
-
- /*
- * Fetch revisions.
- *
- * If the user clicked "previous", we retrieve the revisions backwards,
- * then reverse them. This is to avoid needing to know the timestamp of
- * previous revisions when generating the URL.
- */
- $direction = $this->getDirection();
- $revisions = $this->fetchRevisions($limit, $dboffset, $direction);
- $navbar = $this->makeNavbar($revisions, $offset, $limit, $direction);
-
- /*
- * We fetch one more revision than needed to get the timestamp of the
- * one after this page (and to know if it exists).
- *
- * linesonpage stores the actual number of lines.
- */
- if (count($revisions) < $limit + 1)
- $this->linesonpage = count($revisions);
- else
- $this->linesonpage = count($revisions) - 1;
-
- /* Un-reverse revisions */
- if ($direction == DIR_PREV)
- $revisions = array_reverse($revisions);
-
- /*
- * Print the top navbar.
- */
- $s = $navbar;
- $s .= $this->beginHistoryList();
- $counter = 1;
-