-
- /** @todo document */
- function makeNavbar($revisions, $offset, $limit, $direction) {
- global $wgLang;
-
- $revisions = array_slice($revisions, 0, $limit);
-
- $latestTimestamp = wfTimestamp(TS_MW, $this->getLatestOffset());
- $earliestTimestamp = wfTimestamp(TS_MW, $this->getEarliestOffset());
-
- /*
- * When we're displaying previous revisions, we need to reverse
- * the array, because it's queried in reverse order.
- */
- if ($direction == PageHistory::DIR_PREV)
- $revisions = array_reverse($revisions);
-
- /*
- * lowts is the timestamp of the first revision on this page.
- * hights is the timestamp of the last revision.
- */
-
- $lowts = $hights = 0;
-
- if( count( $revisions ) ) {
- $latestShown = wfTimestamp(TS_MW, $revisions[0]->rev_timestamp);
- $earliestShown = wfTimestamp(TS_MW, $revisions[count($revisions) - 1]->rev_timestamp);
- } else {
- $latestShown = null;
- $earliestShown = null;
- }
-
- /* Don't announce the limit everywhere if it's the default */
- $usefulLimit = $limit == $this->defaultLimit ? '' : $limit;
-
- $urls = array();
- foreach (array(20, 50, 100, 250, 500) as $num) {
- $urls[] = $this->MakeLink( $wgLang->formatNum($num),
- array('offset' => $offset == 0 ? '' : wfTimestamp(TS_MW, $offset), 'limit' => $num, ) );
- }
-
- $bits = implode($urls, ' | ');
-
- wfDebug("latestShown=$latestShown latestTimestamp=$latestTimestamp\n");
- if( $latestShown < $latestTimestamp ) {
- $prevtext = $this->MakeLink( wfMsgHtml("prevn", $limit),
- array( 'dir' => 'prev', 'offset' => $latestShown, 'limit' => $usefulLimit ) );
- $lasttext = $this->MakeLink( wfMsgHtml('histlast'),
- array( 'limit' => $usefulLimit ) );
- } else {
- $prevtext = wfMsgHtml("prevn", $limit);
- $lasttext = wfMsgHtml('histlast');
- }
-
- wfDebug("earliestShown=$earliestShown earliestTimestamp=$earliestTimestamp\n");
- if( $earliestShown > $earliestTimestamp ) {
- $nexttext = $this->MakeLink( wfMsgHtml("nextn", $limit),
- array( 'offset' => $earliestShown, 'limit' => $usefulLimit ) );
- $firsttext = $this->MakeLink( wfMsgHtml('histfirst'),
- array( 'go' => 'first', 'limit' => $usefulLimit ) );
- } else {
- $nexttext = wfMsgHtml("nextn", $limit);
- $firsttext = wfMsgHtml('histfirst');
- }
-
- $firstlast = "($lasttext | $firsttext)";
-
- return "$firstlast " . wfMsgHtml("viewprevnext", $prevtext, $nexttext, $bits);
- }
-
- function MakeLink($text, $query = NULL) {
- if ( $query === null ) return $text;
- return $this->mSkin->makeKnownLinkObj(
- $this->mTitle, $text,
- wfArrayToCGI( $query, array( 'action' => 'history' )));
- }
-