summaryrefslogtreecommitdiff
path: root/includes/Pager.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2009-02-22 13:37:51 +0100
committerPierre Schmitz <pierre@archlinux.de>2009-02-22 13:37:51 +0100
commitb9b85843572bf283f48285001e276ba7e61b63f6 (patch)
tree4c6f4571552ada9ccfb4030481dcf77308f8b254 /includes/Pager.php
parentd9a20acc4e789cca747ad360d87ee3f3e7aa58c1 (diff)
updated to MediaWiki 1.14.0
Diffstat (limited to 'includes/Pager.php')
-rw-r--r--includes/Pager.php82
1 files changed, 78 insertions, 4 deletions
diff --git a/includes/Pager.php b/includes/Pager.php
index 62c4e551..8ec32ff4 100644
--- a/includes/Pager.php
+++ b/includes/Pager.php
@@ -154,6 +154,26 @@ abstract class IndexPager implements Pager {
wfProfileOut( $fname );
}
+
+ /**
+ * Return the result wrapper.
+ */
+ function getResult() {
+ return $this->mResult;
+ }
+
+ /**
+ * Set the offset from an other source than $wgRequest
+ */
+ function setOffset( $offset ) {
+ $this->mOffset = $offset;
+ }
+ /**
+ * Set the limit from an other source than $wgRequest
+ */
+ function setLimit( $limit ) {
+ $this->mLimit = $limit;
+ }
/**
* Extract some useful data from the result object for use by
@@ -292,9 +312,12 @@ abstract class IndexPager implements Pager {
# HTML 4 has no rel="end" . . .
$attrs = '';
}
+
+ if( $type ) {
+ $attrs .= " class=\"mw-{$type}link\"" ;
+ }
return $this->getSkin()->makeKnownLinkObj( $this->getTitle(), $text,
- wfArrayToCGI( $query, $this->getDefaultQuery() ), '', '',
- $attrs );
+ wfArrayToCGI( $query, $this->getDefaultQuery() ), '', '', $attrs );
}
/**
@@ -352,6 +375,8 @@ abstract class IndexPager implements Pager {
unset( $this->mDefaultQuery['offset'] );
unset( $this->mDefaultQuery['limit'] );
unset( $this->mDefaultQuery['order'] );
+ unset( $this->mDefaultQuery['month'] );
+ unset( $this->mDefaultQuery['year'] );
}
return $this->mDefaultQuery;
}
@@ -425,7 +450,7 @@ abstract class IndexPager implements Pager {
}
foreach ( $this->mLimitsShown as $limit ) {
$links[] = $this->makeLink( $wgLang->formatNum( $limit ),
- array( 'offset' => $offset, 'limit' => $limit ) );
+ array( 'offset' => $offset, 'limit' => $limit ), 'num' );
}
return $links;
}
@@ -564,6 +589,8 @@ abstract class AlphabeticPager extends IndexPager {
*/
abstract class ReverseChronologicalPager extends IndexPager {
public $mDefaultDirection = true;
+ public $mYear;
+ public $mMonth;
function __construct() {
parent::__construct();
@@ -591,6 +618,53 @@ abstract class ReverseChronologicalPager extends IndexPager {
wfMsgHtml("viewprevnext", $pagingLinks['prev'], $pagingLinks['next'], $limits);
return $this->mNavigationBar;
}
+
+ function getDateCond( $year, $month ) {
+ $year = intval($year);
+ $month = intval($month);
+ // Basic validity checks
+ $this->mYear = $year > 0 ? $year : false;
+ $this->mMonth = ($month > 0 && $month < 13) ? $month : false;
+ // Given an optional year and month, we need to generate a timestamp
+ // to use as "WHERE rev_timestamp <= result"
+ // Examples: year = 2006 equals < 20070101 (+000000)
+ // year=2005, month=1 equals < 20050201
+ // year=2005, month=12 equals < 20060101
+ if ( !$this->mYear && !$this->mMonth ) {
+ return;
+ }
+ if ( $this->mYear ) {
+ $year = $this->mYear;
+ } else {
+ // If no year given, assume the current one
+ $year = gmdate( 'Y' );
+ // If this month hasn't happened yet this year, go back to last year's month
+ if( $this->mMonth > gmdate( 'n' ) ) {
+ $year--;
+ }
+ }
+ if ( $this->mMonth ) {
+ $month = $this->mMonth + 1;
+ // For December, we want January 1 of the next year
+ if ($month > 12) {
+ $month = 1;
+ $year++;
+ }
+ } else {
+ // No month implies we want up to the end of the year in question
+ $month = 1;
+ $year++;
+ }
+ // Y2K38 bug
+ if ( $year > 2032 ) {
+ $year = 2032;
+ }
+ $ymd = (int)sprintf( "%04d%02d01", $year, $month );
+ if ( $ymd > 20320101 ) {
+ $ymd = 20320101;
+ }
+ $this->mOffset = $this->mDb->timestamp( "${ymd}000000" );
+ }
}
/**
@@ -795,7 +869,7 @@ abstract class TablePager extends IndexPager {
"<form method=\"get\" action=\"$url\">" .
wfMsgHtml( 'table_pager_limit', $this->getLimitSelect() ) .
"\n<input type=\"submit\" value=\"$msgSubmit\"/>\n" .
- $this->getHiddenFields( 'limit' ) .
+ $this->getHiddenFields( array('limit','title') ) .
"</form>\n";
}