<?php
/**
- * @defgroup Pager Pager
+ * Efficient paging for SQL queries.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
*
* @file
* @ingroup Pager
*/
+/**
+ * @defgroup Pager Pager
+ */
+
/**
* Basic pager interface.
* @ingroup Pager
$join_conds = isset( $info['join_conds'] ) ? $info['join_conds'] : array();
$sortColumns = array_merge( array( $this->mIndexField ), $this->mExtraSortFields );
if ( $descending ) {
- $options['ORDER BY'] = implode( ',', $sortColumns );
+ $options['ORDER BY'] = $sortColumns;
$operator = '>';
} else {
$orderBy = array();
foreach ( $sortColumns as $col ) {
$orderBy[] = $col . ' DESC';
}
- $options['ORDER BY'] = implode( ',', $orderBy );
+ $options['ORDER BY'] = $orderBy;
$operator = '<';
}
if ( $offset != '' ) {
* @param $text String: text displayed on the link
* @param $query Array: associative array of paramter to be in the query string
* @param $type String: value of the "rel" attribute
+ *
* @return String: HTML fragment
*/
- function makeLink($text, $query = null, $type=null) {
+ function makeLink( $text, array $query = null, $type = null ) {
if ( $query === null ) {
return $text;
}
if( $type ) {
$attrs['class'] = "mw-{$type}link";
}
+
return Linker::linkKnown(
$this->getTitle(),
$text,
}
# Don't announce the limit everywhere if it's the default
- $urlLimit = $this->mLimit == $this->mDefaultLimit ? '' : $this->mLimit;
+ $urlLimit = $this->mLimit == $this->mDefaultLimit ? null : $this->mLimit;
if ( $this->mIsFirst ) {
$prev = false;
function getPagingLinks( $linkTexts, $disabledTexts = array() ) {
$queries = $this->getPagingQueries();
$links = array();
+
foreach ( $queries as $type => $query ) {
if ( $query !== false ) {
$links[$type] = $this->makeLink(
$links[$type] = $linkTexts[$type];
}
}
+
return $links;
}
* @return String HTML
*/
function getNavigationBar() {
- if ( !$this->isNavigationBarShown() ) return '';
+ if ( !$this->isNavigationBarShown() ) {
+ return '';
+ }
if( isset( $this->mNavigationBar ) ) {
return $this->mNavigationBar;
$limitLinks = $this->getLimitLinks();
$limits = $lang->pipeList( $limitLinks );
- $this->mNavigationBar =
- "(" . $lang->pipeList(
+ $this->mNavigationBar = wfMessage( 'parentheses' )->rawParams(
+ $lang->pipeList(
array( $pagingLinks['first'],
- $pagingLinks['last'] )
- ) . ") " .
+ $pagingLinks['last'] )
+ ) )->escaped() . " " .
wfMsgHtml( 'viewprevnext', $pagingLinks['prev'],
- $pagingLinks['next'], $limits );
+ $pagingLinks['next'], $limits );
if( !is_array( $this->getIndexField() ) ) {
# Early return to avoid undue nesting
}
if( $extra !== '' ) {
- $this->mNavigationBar .= " ($extra)";
+ $extra = ' ' . wfMessage( 'parentheses' )->rawParams( $extra )->escaped();
+ $this->mNavigationBar .= $extra;
}
return $this->mNavigationBar;
$pagingLinks = $this->getPagingLinks( $linkTexts );
$limitLinks = $this->getLimitLinks();
$limits = $this->getLanguage()->pipeList( $limitLinks );
-
- $this->mNavigationBar = "({$pagingLinks['first']}" .
+ $firstLastLinks = wfMessage( 'parentheses' )->rawParams( "{$pagingLinks['first']}" .
wfMsgExt( 'pipe-separator' , 'escapenoentities' ) .
- "{$pagingLinks['last']}) " .
+ "{$pagingLinks['last']}" )->escaped();
+
+ $this->mNavigationBar = $firstLastLinks . ' ' .
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)
if ( !$this->mYear && !$this->mMonth ) {
return;
}
+
if ( $this->mYear ) {
$year = $this->mYear;
} else {
$year--;
}
}
+
if ( $this->mMonth ) {
$month = $this->mMonth + 1;
// For December, we want January 1 of the next year
$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" );
}
}
$image = htmlspecialchars( "$wgStylePath/common/images/$image" );
$link = $this->makeLink(
"<img width=\"12\" height=\"12\" alt=\"$alt\" src=\"$image\" />" .
- htmlspecialchars( $name ), $query );
+ htmlspecialchars( $name ), $query );
$s .= "<th class=\"$sortClass\">$link</th>\n";
} else {
$s .= '<th>' . $this->makeLink( htmlspecialchars( $name ), $query ) . "</th>\n";