Extension:ExtendedPagers

This is not a stand-alone extension and therefore only intended to be used by developers but can be useful to display search results. Maybe it will one time find it's way to the trunk, so please help me testing it ;)

I designed this pagers because none of the built-in's supplied the features I needed. Espacially with ordering (sorting) a result and using the paging function which doesn't work properly with all the other pagers when the order columns don't contain unique values.

This pagers implement paging based on row indices and have the additional feature to jump to a specific page in the result. Furthermore they don't 'forget' the column to order when you change the page like the AlphabeticPager does.

Configuration
If you want to use one of this pagers in your extension, create a file named  and paste the following line somewhere in the initialization of your extension:

Example
Here is a little examle on how you can design the NavigationBar. I used the pager for a custom table so I cant't post that here. If somebody uses this on a default wiki table or even creates a special page as an example, please post it here. (sorry for not using i18n messages)

It is also possible to use multiple indexFields for ordering (sorting), then it should behave like AlphabeticPager (or even better ; )

ExtendedPagers.php
\n";	}

function getEmptyBody { $colspan = count( $this->getFieldNames ); $msgEmpty = wfMsgHtml( 'table_pager_empty' ); return " $msgEmpty \n"; }

function formatRow( $row ) { $s = " \n"; $fieldNames = $this->getFieldNames; $this->mCurrentRow = $row; # In case formatValue needs to know foreach ( $fieldNames as $field => $name ) { $value = isset( $row->$field ) ? $row->$field : null; $formatted = strval( $this->formatValue( $field, $value ) ); if ( $formatted == '' ) { $formatted = ' '; }			$class = 'TablePager_col_'. htmlspecialchars( $field ); $s .= "$formatted \n"; }		$s .= " \n"; return $s; }

function getIndexField { return $this->mSort; }

function getTableClass { return 'TablePager'; }

function getNavClass { return 'TablePager_nav'; }

function getSortHeaderClass { return 'TablePager_sort'; }

/**	 * A navigation bar with images */	function getNavigationBar { global $wgStylePath, $wgContLang; $path = "$wgStylePath/common/images"; $labels = array(			'first' => 'table_pager_first',			'prev' => 'table_pager_prev',			'next' => 'table_pager_next',			'last' => 'table_pager_last',		); $images = array(			'first' => $wgContLang->isRTL ? 'arrow_last_25.png' : 'arrow_first_25.png',			'prev' => $wgContLang->isRTL ? 'arrow_right_25.png' : 'arrow_left_25.png',			'next' =>  $wgContLang->isRTL ? 'arrow_left_25.png' : 'arrow_right_25.png',			'last' =>  $wgContLang->isRTL ? 'arrow_first_25.png' : 'arrow_last_25.png',		); $disabledImages = array(			'first' => $wgContLang->isRTL ? 'arrow_disabled_last_25.png' : 'arrow_disabled_first_25.png',			'prev' => $wgContLang->isRTL ? 'arrow_disabled_right_25.png' : 'arrow_disabled_left_25.png',			'next' =>  $wgContLang->isRTL ? 'arrow_disabled_left_25.png' : 'arrow_disabled_right_25.png',			'last' =>  $wgContLang->isRTL ? 'arrow_disabled_first_25.png' : 'arrow_disabled_last_25.png',		);

$linkTexts = array; $disabledTexts = array; foreach ( $labels as $type => $label ) { $msgLabel = wfMsgHtml( $label ); $linkTexts[$type] = " $msgLabel"; $disabledTexts[$type] = " $msgLabel"; }		$links = $this->getPagingLinks( $linkTexts, $disabledTexts );

$navClass = htmlspecialchars( $this->getNavClass ); $s = " \n"; return $s; }

/**	 * Get a element which has options for each of the allowed limits */	function getLimitSelect { global $wgLang; $s = ""; foreach ( $this->mLimitsShown as $limit ) { $selected = $limit == $this->mLimit ? 'selected="selected"' : ''; $formattedLimit = $wgLang->formatNum( $limit ); $s .= "$formattedLimit \n"; }		$s .= " "; return $s; }

/**	 * Get elements for use in a method="get" form. * Resubmits all defined elements of the $_GET array, except for a	 * blacklist, passed in the $blacklist parameter. */	function getHiddenFields( $blacklist = array ) { $blacklist = (array)$blacklist; $query = $_GET; foreach ( $blacklist as $name ) { unset( $query[$name] ); }		$s = ''; foreach ( $query as $name => $value ) { $encName = htmlspecialchars( $name ); $encValue = htmlspecialchars( $value ); $s .= "\n"; }		return $s; }

/**	 * Get a form containing a limit selection dropdown */	function getLimitForm { # Make the select with some explanatory text $url = $this->getTitle->escapeLocalURL; $msgSubmit = wfMsgHtml( 'table_pager_limit_submit' ); return "". wfMsgHtml( 'table_pager_limit', $this->getLimitSelect ). "\n\n". $this->getHiddenFields( array('limit','title') ). " \n"; }

/**	 * Return true if the named field should be sortable by the UI, false * otherwise *	 * @param string $field */	abstract function isFieldSortable( $field );

/**	 * Format a table cell. The return value should be HTML, but use an empty * string not  for empty cells. Do not include the and. *	 * The current result row is available as $this->mCurrentRow, in case you * need more context. *	 * @param string $name The database field name * @param string $value The value retrieved from the database */	abstract function formatValue( $name, $value );

/**	 * The database field name used as a default sort order */	abstract function getDefaultSort;

/**	 * An array mapping database field names to a textual description of the * field name, for use in the table header. The description should be plain * text, it will be HTML-escaped later. */	abstract function getFieldNames; }

?>