}
/**
- * Return the result wrapper.
+ * @return ResultWrapper The result wrapper.
*/
function getResult() {
return $this->mResult;
function extractResultInfo( $offset, $limit, ResultWrapper $res ) {
$numRows = $res->numRows();
if ( $numRows ) {
+ # Remove any table prefix from index field
+ $parts = explode( '.', $this->mIndexField );
+ $indexColumn = end( $parts );
+
$row = $res->fetchRow();
- $firstIndex = $row[$this->mIndexField];
+ $firstIndex = $row[$indexColumn];
# Discard the extra result row if there is one
if ( $numRows > $this->mLimit && $numRows > 1 ) {
$this->mPastTheEndIndex = $this->mPastTheEndRow->$indexField;
$res->seek( $numRows - 2 );
$row = $res->fetchRow();
- $lastIndex = $row[$this->mIndexField];
+ $lastIndex = $row[$indexColumn];
} else {
$this->mPastTheEndRow = null;
# Setting indexes to an empty string means that they will be
$this->mPastTheEndIndex = '';
$res->seek( $numRows - 1 );
$row = $res->fetchRow();
- $lastIndex = $row[$this->mIndexField];
+ $lastIndex = $row[$indexColumn];
}
} else {
$firstIndex = '';
# Make table header
foreach ( $fields as $field => $name ) {
if ( strval( $name ) == '' ) {
- $s .= "<th> </th>\n";
+ $s .= "<th> </th>\n";
} elseif ( $this->isFieldSortable( $field ) ) {
$query = array( 'sort' => $field, 'limit' => $this->mLimit );
if ( $field == $this->mSort ) {
$value = isset( $row->$field ) ? $row->$field : null;
$formatted = strval( $this->formatValue( $field, $value ) );
if ( $formatted == '' ) {
- $formatted = ' ';
+ $formatted = ' ';
}
$s .= Xml::tags( 'td', $this->getCellAttrs( $field, $value ), $formatted );
}
function getNavigationBar() {
global $wgStylePath, $wgContLang;
- if ( !$this->isNavigationBarShown() ) return '';
+ if ( !$this->isNavigationBarShown() ) {
+ return '';
+ }
$path = "$wgStylePath/common/images";
$labels = array(
*/
function getLimitSelect() {
global $wgLang;
- $s = "<select name=\"limit\">";
+
+ # Add the current limit from the query string
+ # to avoid that the limit is lost after clicking Go next time
+ if ( !in_array( $this->mLimit, $this->mLimitsShown ) ) {
+ $this->mLimitsShown[] = $this->mLimit;
+ sort( $this->mLimitsShown );
+ }
+ $s = Html::openElement( 'select', array( 'name' => 'limit' ) ) . "\n";
foreach ( $this->mLimitsShown as $key => $value ) {
# The pair is either $index => $limit, in which case the $value
# will be numeric, or $limit => $text, in which case the $value
$limit = $key;
$text = $value;
}
- $selected = ( $limit == $this->mLimit ? 'selected="selected"' : '' );
- $s .= "<option value=\"$limit\" $selected>$text</option>\n";
+ $s .= Xml::option( $text, $limit, $limit == $this->mLimit ) . "\n";
}
- $s .= "</select>";
+ $s .= Html::closeElement( 'select' );
return $s;
}
function getLimitForm() {
global $wgScript;
+ return Xml::openElement(
+ 'form',
+ array(
+ 'method' => 'get',
+ 'action' => $wgScript
+ ) ) . "\n" . $this->getLimitDropdown() . "</form>\n";
+ }
+
+ /**
+ * Gets a limit selection dropdown
+ *
+ * @return string
+ */
+ function getLimitDropdown() {
# Make the select with some explanatory text
$msgSubmit = wfMsgHtml( 'table_pager_limit_submit' );
- return
- Xml::openElement(
- 'form',
- array(
- 'method' => 'get',
- 'action' => $wgScript
- )
- ) . "\n" .
- wfMsgHtml( 'table_pager_limit', $this->getLimitSelect() ) .
+
+ return wfMsgHtml( 'table_pager_limit', $this->getLimitSelect() ) .
"\n<input type=\"submit\" value=\"$msgSubmit\"/>\n" .
- $this->getHiddenFields( array( 'limit' ) ) .
- "</form>\n";
+ $this->getHiddenFields( array( 'limit' ) );
}
/**
/**
* Format a table cell. The return value should be HTML, but use an empty
- * string not for empty cells. Do not include the <td> and </td>.
+ * string not   for empty cells. Do not include the <td> and </td>.
*
* The current result row is available as $this->mCurrentRow, in case you
* need more context.