4 * Basic pager interface.
8 function getNavigationBar();
13 * IndexPager is an efficient pager which uses a (roughly unique) index in the
14 * data set to implement paging, rather than a "LIMIT offset,limit" clause.
15 * In MySQL, such a limit/offset clause requires counting through the
16 * specified number of offset rows to find the desired data, which can be
17 * expensive for large offsets.
19 * ReverseChronologicalPager is a child class of the abstract IndexPager, and
20 * contains some formatting and display code which is specific to the use of
21 * timestamps as indexes. Here is a synopsis of its operation:
23 * * The query is specified by the offset, limit and direction (dir)
24 * parameters, in addition to any subclass-specific parameters.
25 * * The offset is the non-inclusive start of the DB query. A row with an
26 * index value equal to the offset will never be shown.
27 * * The query may either be done backwards, where the rows are returned by
28 * the database in the opposite order to which they are displayed to the
29 * user, or forwards. This is specified by the "dir" parameter, dir=prev
30 * means backwards, anything else means forwards. The offset value
31 * specifies the start of the database result set, which may be either
32 * the start or end of the displayed data set. This allows "previous"
33 * links to be implemented without knowledge of the index value at the
34 * start of the previous page.
35 * * An additional row beyond the user-specified limit is always requested.
36 * This allows us to tell whether we should display a "next" link in the
37 * case of forwards mode, or a "previous" link in the case of backwards
38 * mode. Determining whether to display the other link (the one for the
39 * page before the start of the database result set) can be done
40 * heuristically by examining the offset.
42 * * An empty offset indicates that the offset condition should be omitted
43 * from the query. This naturally produces either the first page or the
44 * last page depending on the dir parameter.
46 * Subclassing the pager to implement concrete functionality should be fairly
47 * simple, please see the examples in PageHistory.php and
48 * SpecialIpblocklist.php. You just need to override formatRow(),
49 * getQueryInfo() and getIndexField(). Don't forget to call the parent
50 * constructor if you override it.
54 abstract class IndexPager
implements Pager
{
56 public $mLimitsShown = array( 20, 50, 100, 250, 500 );
57 public $mDefaultLimit = 50;
58 public $mOffset, $mLimit;
59 public $mQueryDone = false;
61 public $mPastTheEndRow;
64 * The index to actually be used for ordering. This is a single string e-
65 * ven if multiple orderings are supported.
67 protected $mIndexField;
68 /** For pages that support multiple types of ordering, which one to use. */
69 protected $mOrderType;
71 * $mDefaultDirection gives the direction to use when sorting results:
72 * false for ascending, true for descending. If $mIsBackwards is set, we
73 * start from the opposite end, but we still sort the page itself according
74 * to $mDefaultDirection. E.g., if $mDefaultDirection is false but we're
75 * going backwards, we'll display the last page of results, but the last
76 * result will be at the bottom, not the top.
78 * "Default" is really a misnomer here, since now it's possible for the
79 * user to directly modify this with query parameters. TODO: rename that
80 * to $mDescending, maybe set this to that by reference for compatibility.
82 public $mDefaultDirection;
86 * Result object for the query. Warning: seek before use.
90 public function __construct() {
91 global $wgRequest, $wgUser;
92 $this->mRequest
= $wgRequest;
94 # NB: the offset is quoted, not validated. It is treated as an
95 # arbitrary string to support the widest variety of index types. Be
96 # careful outputting it into HTML!
97 $this->mOffset
= $this->mRequest
->getText( 'offset' );
99 # Use consistent behavior for the limit options
100 $this->mDefaultLimit
= intval( $wgUser->getOption( 'rclimit' ) );
101 list( $this->mLimit
, /* $offset */ ) = $this->mRequest
->getLimitOffset();
103 $this->mIsBackwards
= ( $this->mRequest
->getVal( 'dir' ) == 'prev' );
104 $this->mDb
= wfGetDB( DB_SLAVE
);
106 $index = $this->getIndexField();
107 $order = $this->mRequest
->getVal( 'order' );
108 if( is_array( $index ) && isset( $index[$order] ) ) {
109 $this->mOrderType
= $order;
110 $this->mIndexField
= $index[$order];
111 } elseif( is_array( $index ) ) {
112 # First element is the default
114 list( $this->mOrderType
, $this->mIndexField
) = each( $index );
116 # $index is not an array
117 $this->mOrderType
= null;
118 $this->mIndexField
= $index;
121 if( !isset( $this->mDefaultDirection
) ) {
122 $dir = $this->getDefaultDirection();
123 $this->mDefaultDirection
= is_array( $dir )
124 ?
$dir[$this->mOrderType
]
128 # FIXME: Can we figure out a less confusing convention than using a
129 # "direction" parameter when we already have "dir" and "order"?
130 if( $this->mRequest
->getVal( 'direction' ) == 'asc' ) {
131 $this->mDefaultDirection
= false;
133 if( $this->mRequest
->getVal( 'direction' ) == 'desc' ) {
134 $this->mDefaultDirection
= true;
139 * Do the query, using information from the object context. This function
140 * has been kept minimal to make it overridable if necessary, to allow for
141 * result sets formed from multiple DB queries.
144 # Use the child class name for profiling
145 $fname = __METHOD__
. ' (' . get_class( $this ) . ')';
146 wfProfileIn( $fname );
148 $descending = ( $this->mIsBackwards
== $this->mDefaultDirection
);
149 # Plus an extra row so that we can tell the "next" link should be shown
150 $queryLimit = $this->mLimit +
1;
152 $this->mResult
= $this->reallyDoQuery( $this->mOffset
, $queryLimit, $descending );
153 $this->extractResultInfo( $this->mOffset
, $queryLimit, $this->mResult
);
154 $this->mQueryDone
= true;
156 $this->preprocessResults( $this->mResult
);
157 $this->mResult
->rewind(); // Paranoia
159 wfProfileOut( $fname );
163 * Extract some useful data from the result object for use by
164 * the navigation bar, put it into $this
166 function extractResultInfo( $offset, $limit, ResultWrapper
$res ) {
167 $numRows = $res->numRows();
169 $row = $res->fetchRow();
170 $firstIndex = $row[$this->mIndexField
];
172 # Discard the extra result row if there is one
173 if ( $numRows > $this->mLimit
&& $numRows > 1 ) {
174 $res->seek( $numRows - 1 );
175 $this->mPastTheEndRow
= $res->fetchObject();
176 $indexField = $this->mIndexField
;
177 $this->mPastTheEndIndex
= $this->mPastTheEndRow
->$indexField;
178 $res->seek( $numRows - 2 );
179 $row = $res->fetchRow();
180 $lastIndex = $row[$this->mIndexField
];
182 $this->mPastTheEndRow
= null;
183 # Setting indexes to an empty string means that they will be
184 # omitted if they would otherwise appear in URLs. It just so
185 # happens that this is the right thing to do in the standard
186 # UI, in all the relevant cases.
187 $this->mPastTheEndIndex
= '';
188 $res->seek( $numRows - 1 );
189 $row = $res->fetchRow();
190 $lastIndex = $row[$this->mIndexField
];
195 $this->mPastTheEndRow
= null;
196 $this->mPastTheEndIndex
= '';
199 if ( $this->mIsBackwards
) {
200 $this->mIsFirst
= ( $numRows < $limit );
201 $this->mIsLast
= ( $offset == '' );
202 $this->mLastShown
= $firstIndex;
203 $this->mFirstShown
= $lastIndex;
205 $this->mIsFirst
= ( $offset == '' );
206 $this->mIsLast
= ( $numRows < $limit );
207 $this->mLastShown
= $lastIndex;
208 $this->mFirstShown
= $firstIndex;
213 * Do a query with specified parameters, rather than using the object
216 * @param string $offset Index offset, inclusive
217 * @param integer $limit Exact query limit
218 * @param boolean $descending Query direction, false for ascending, true for descending
219 * @return ResultWrapper
221 function reallyDoQuery( $offset, $limit, $descending ) {
222 $fname = __METHOD__
. ' (' . get_class( $this ) . ')';
223 $info = $this->getQueryInfo();
224 $tables = $info['tables'];
225 $fields = $info['fields'];
226 $conds = isset( $info['conds'] ) ?
$info['conds'] : array();
227 $options = isset( $info['options'] ) ?
$info['options'] : array();
229 $options['ORDER BY'] = $this->mIndexField
;
232 $options['ORDER BY'] = $this->mIndexField
. ' DESC';
235 if ( $offset != '' ) {
236 $conds[] = $this->mIndexField
. $operator . $this->mDb
->addQuotes( $offset );
238 $options['LIMIT'] = intval( $limit );
239 $res = $this->mDb
->select( $tables, $fields, $conds, $fname, $options );
240 return new ResultWrapper( $this->mDb
, $res );
244 * Pre-process results; useful for performing batch existence checks, etc.
246 * @param ResultWrapper $result Result wrapper
248 protected function preprocessResults( $result ) {}
251 * Get the formatted result list. Calls getStartBody(), formatRow() and
252 * getEndBody(), concatenates the results and returns them.
255 if ( !$this->mQueryDone
) {
258 # Don't use any extra rows returned by the query
259 $numRows = min( $this->mResult
->numRows(), $this->mLimit
);
261 $s = $this->getStartBody();
263 if ( $this->mIsBackwards
) {
264 for ( $i = $numRows - 1; $i >= 0; $i-- ) {
265 $this->mResult
->seek( $i );
266 $row = $this->mResult
->fetchObject();
267 $s .= $this->formatRow( $row );
270 $this->mResult
->seek( 0 );
271 for ( $i = 0; $i < $numRows; $i++
) {
272 $row = $this->mResult
->fetchObject();
273 $s .= $this->formatRow( $row );
277 $s .= $this->getEmptyBody();
279 $s .= $this->getEndBody();
286 function makeLink($text, $query = null) {
287 if ( $query === null ) {
290 return $this->getSkin()->makeKnownLinkObj( $this->getTitle(), $text,
291 wfArrayToCGI( $query, $this->getDefaultQuery() ) );
295 * Hook into getBody(), allows text to be inserted at the start. This
296 * will be called even if there are no rows in the result set.
298 function getStartBody() {
303 * Hook into getBody() for the end of the list
305 function getEndBody() {
310 * Hook into getBody(), for the bit between the start and the
311 * end when there are no rows
313 function getEmptyBody() {
318 * Title used for self-links. Override this if you want to be able to
319 * use a title other than $wgTitle
321 function getTitle() {
322 return $GLOBALS['wgTitle'];
326 * Get the current skin. This can be overridden if necessary.
329 if ( !isset( $this->mSkin
) ) {
331 $this->mSkin
= $wgUser->getSkin();
337 * Get an array of query parameters that should be put into self-links.
338 * By default, all parameters passed in the URL are used, except for a
341 function getDefaultQuery() {
342 if ( !isset( $this->mDefaultQuery
) ) {
343 $this->mDefaultQuery
= $_GET;
344 unset( $this->mDefaultQuery
['title'] );
345 unset( $this->mDefaultQuery
['dir'] );
346 unset( $this->mDefaultQuery
['offset'] );
347 unset( $this->mDefaultQuery
['limit'] );
348 unset( $this->mDefaultQuery
['direction'] );
349 unset( $this->mDefaultQuery
['order'] );
351 return $this->mDefaultQuery
;
355 * Get the number of rows in the result set
357 function getNumRows() {
358 if ( !$this->mQueryDone
) {
361 return $this->mResult
->numRows();
365 * Get a query array for the prev, next, first and last links.
367 function getPagingQueries() {
368 if ( !$this->mQueryDone
) {
372 # Don't announce the limit everywhere if it's the default
373 $urlLimit = $this->mLimit
== $this->mDefaultLimit ?
'' : $this->mLimit
;
375 if ( $this->mIsFirst
) {
379 $prev = array( 'dir' => 'prev', 'offset' => $this->mFirstShown
, 'limit' => $urlLimit );
380 $first = array( 'limit' => $urlLimit );
382 if ( $this->mIsLast
) {
386 $next = array( 'offset' => $this->mLastShown
, 'limit' => $urlLimit );
387 $last = array( 'dir' => 'prev', 'limit' => $urlLimit );
389 return array( 'prev' => $prev, 'next' => $next, 'first' => $first, 'last' => $last );
393 * Get paging links. If a link is disabled, the item from $disabledTexts
394 * will be used. If there is no such item, the unlinked text from
395 * $linkTexts will be used. Both $linkTexts and $disabledTexts are arrays
398 function getPagingLinks( $linkTexts, $disabledTexts = array() ) {
399 $queries = $this->getPagingQueries();
401 foreach ( $queries as $type => $query ) {
402 if ( $query !== false ) {
403 $links[$type] = $this->makeLink( $linkTexts[$type], $queries[$type] );
404 } elseif ( isset( $disabledTexts[$type] ) ) {
405 $links[$type] = $disabledTexts[$type];
407 $links[$type] = $linkTexts[$type];
413 function getLimitLinks() {
416 if ( $this->mIsBackwards
) {
417 $offset = $this->mPastTheEndIndex
;
419 $offset = $this->mOffset
;
421 foreach ( $this->mLimitsShown
as $limit ) {
422 $links[] = $this->makeLink( $wgLang->formatNum( $limit ),
423 array( 'offset' => $offset, 'limit' => $limit ) );
429 * Abstract formatting function. This should return an HTML string
430 * representing the result row $row. Rows will be concatenated and
431 * returned by getBody()
433 abstract function formatRow( $row );
436 * This function should be overridden to provide all parameters
437 * needed for the main paged query. It returns an associative
438 * array with the following elements:
439 * tables => Table(s) for passing to Database::select()
440 * fields => Field(s) for passing to Database::select(), may be *
441 * conds => WHERE conditions
442 * options => option array
444 abstract function getQueryInfo();
447 * This function should be overridden to return the name of the index fi-
448 * eld. If the pager supports multiple orders, it may return an array of
449 * 'querykey' => 'indexfield' pairs, so that a request with &count=querykey
450 * will use indexfield to sort. In this case, the first returned key is
453 abstract function getIndexField();
456 * Return the default sorting direction: false for ascending, true for de-
457 * scending. You can also have an associative array of ordertype => dir,
458 * if multiple order types are supported. In this case getIndexField()
459 * must return an array, and the keys of that must exactly match the keys
462 * For backward compatibility, this method's return value will be ignored
463 * if $this->mDefaultDirection is already set when the constructor is
464 * called, for instance if it's statically initialized. In that case the
465 * value of that variable (which must be a boolean) will be used.
467 * Note that despite its name, this does not return the value of the now-
468 * misnamed $this->mDefaultDirection member variable. That is not a
469 * default, it's the actual direction used. This is just the default and
470 * can be overridden by user input.
472 protected function getDefaultDirection() { return false; }
477 * IndexPager with an alphabetic list and a formatted navigation bar
480 abstract class AlphabeticPager
extends IndexPager
{
481 function __construct() {
482 parent
::__construct();
486 * Shamelessly stolen bits from ReverseChronologicalPager, d
487 * didn't want to do class magic as may be still revamped
489 function getNavigationBar() {
492 if( isset( $this->mNavigationBar
) ) {
493 return $this->mNavigationBar
;
497 'prev' => wfMsgHtml( 'prevn', $wgLang->formatNum( $this->mLimit
) ),
498 'next' => wfMsgHtml( 'nextn', $wgLang->formatNum($this->mLimit
) ),
499 'first' => wfMsgHtml( 'page_first' ),
500 'last' => wfMsgHtml( 'page_last' )
503 $pagingLinks = $this->getPagingLinks( $linkTexts );
504 $limitLinks = $this->getLimitLinks();
505 $limits = implode( ' | ', $limitLinks );
507 $this->mNavigationBar
=
508 "({$pagingLinks['first']} | {$pagingLinks['last']}) " .
509 wfMsgHtml( 'viewprevnext', $pagingLinks['prev'],
510 $pagingLinks['next'], $limits );
514 # Note for grep: uses pager-sort-asc, pager-sort-desc (each in two
516 foreach( array( 'asc', 'desc' ) as $dir ) {
517 if( ($this->mDefaultDirection ? 'desc' : 'asc' ) == $dir ) {
518 # Don't print a link, just some text
519 $dirlinks[$dir] = wfMsgHTML( "pager-sort-$dir" );
521 $query = array( 'direction' => $dir );
522 if( $this->mOrderType !== null ) {
523 $query['order'] = $this->mOrderType;
525 $dirlinks[$dir] = $this->makeLink(
526 wfMsgHTML( "pager-sort-$dir" ),
531 $this->mNavigationBar .= ' (' . implode( ' | ', $dirlinks ) . ')';
533 if( !is_array( $this->getIndexField() ) ) {
534 # Early return to avoid undue nesting
535 return $this->mNavigationBar;
540 $msgs = $this->getOrderTypeMessages();
541 foreach( array_keys( $msgs ) as $order ) {
548 if( $order == $this->mOrderType ) {
549 $extra .= wfMsgHTML( $msgs[$order] );
551 $extra .= $this->makeLink(
552 wfMsgHTML( $msgs[$order] ),
553 array( 'order' => $order )
558 if( $extra !== '' ) {
559 $this->mNavigationBar .= " ($extra)";
563 return $this->mNavigationBar
;
567 * If this supports multiple order type messages, give the message key for
568 * enabling each one in getNavigationBar. The return type is an associa-
569 * tive array whose keys must exactly match the keys of the array returned
570 * by getIndexField(), and whose values are message keys.
573 protected function getOrderTypeMessages() {
579 * IndexPager with a formatted navigation bar
582 abstract class ReverseChronologicalPager
extends IndexPager
{
583 public $mDefaultDirection = true;
585 function __construct() {
586 parent
::__construct();
589 function getNavigationBar() {
592 if ( isset( $this->mNavigationBar
) ) {
593 return $this->mNavigationBar
;
595 $nicenumber = $wgLang->formatNum( $this->mLimit
);
597 'prev' => wfMsgExt( 'pager-newer-n', array( 'parsemag' ), $nicenumber ),
598 'next' => wfMsgExt( 'pager-older-n', array( 'parsemag' ), $nicenumber ),
599 'first' => wfMsgHtml( 'histlast' ),
600 'last' => wfMsgHtml( 'histfirst' )
603 $pagingLinks = $this->getPagingLinks( $linkTexts );
604 $limitLinks = $this->getLimitLinks();
605 $limits = implode( ' | ', $limitLinks );
607 $this->mNavigationBar
= "({$pagingLinks['first']} | {$pagingLinks['last']}) " .
608 wfMsgHtml("viewprevnext", $pagingLinks['prev'], $pagingLinks['next'], $limits);
609 return $this->mNavigationBar
;
614 * Table-based display with a user-selectable sort order
617 abstract class TablePager
extends IndexPager
{
621 function __construct() {
623 $this->mSort
= $wgRequest->getText( 'sort' );
624 if ( !array_key_exists( $this->mSort
, $this->getFieldNames() ) ) {
625 $this->mSort
= $this->getDefaultSort();
627 if ( $wgRequest->getBool( 'asc' ) ) {
628 $this->mDefaultDirection
= false;
629 } elseif ( $wgRequest->getBool( 'desc' ) ) {
630 $this->mDefaultDirection
= true;
631 } /* Else leave it at whatever the class default is */
633 parent
::__construct();
636 function getStartBody() {
638 $tableClass = htmlspecialchars( $this->getTableClass() );
639 $sortClass = htmlspecialchars( $this->getSortHeaderClass() );
641 $s = "<table border='1' class=\"$tableClass\"><thead><tr>\n";
642 $fields = $this->getFieldNames();
645 foreach ( $fields as $field => $name ) {
646 if ( strval( $name ) == '' ) {
647 $s .= "<th> </th>\n";
648 } elseif ( $this->isFieldSortable( $field ) ) {
649 $query = array( 'sort' => $field, 'limit' => $this->mLimit
);
650 if ( $field == $this->mSort
) {
651 # This is the sorted column
652 # Prepare a link that goes in the other sort order
653 if ( $this->mDefaultDirection
) {
655 $image = 'Arr_u.png';
658 $alt = htmlspecialchars( wfMsg( 'descending_abbrev' ) );
661 $image = 'Arr_d.png';
663 $query['desc'] = '1';
664 $alt = htmlspecialchars( wfMsg( 'ascending_abbrev' ) );
666 $image = htmlspecialchars( "$wgStylePath/common/images/$image" );
667 $link = $this->makeLink(
668 "<img width=\"12\" height=\"12\" alt=\"$alt\" src=\"$image\" />" .
669 htmlspecialchars( $name ), $query );
670 $s .= "<th class=\"$sortClass\">$link</th>\n";
672 $s .= '<th>' . $this->makeLink( htmlspecialchars( $name ), $query ) . "</th>\n";
675 $s .= '<th>' . htmlspecialchars( $name ) . "</th>\n";
678 $s .= "</tr></thead><tbody>\n";
682 function getEndBody() {
683 return "</tbody></table>\n";
686 function getEmptyBody() {
687 $colspan = count( $this->getFieldNames() );
688 $msgEmpty = wfMsgHtml( 'table_pager_empty' );
689 return "<tr><td colspan=\"$colspan\">$msgEmpty</td></tr>\n";
692 function formatRow( $row ) {
694 $fieldNames = $this->getFieldNames();
695 $this->mCurrentRow
= $row; # In case formatValue needs to know
696 foreach ( $fieldNames as $field => $name ) {
697 $value = isset( $row->$field ) ?
$row->$field : null;
698 $formatted = strval( $this->formatValue( $field, $value ) );
699 if ( $formatted == '' ) {
700 $formatted = ' ';
702 $class = 'TablePager_col_' . htmlspecialchars( $field );
703 $s .= "<td class=\"$class\">$formatted</td>\n";
709 function getIndexField() {
713 function getTableClass() {
717 function getNavClass() {
718 return 'TablePager_nav';
721 function getSortHeaderClass() {
722 return 'TablePager_sort';
726 * A navigation bar with images
728 function getNavigationBar() {
729 global $wgStylePath, $wgContLang;
730 $path = "$wgStylePath/common/images";
732 'first' => 'table_pager_first',
733 'prev' => 'table_pager_prev',
734 'next' => 'table_pager_next',
735 'last' => 'table_pager_last',
738 'first' => $wgContLang->isRTL() ?
'arrow_last_25.png' : 'arrow_first_25.png',
739 'prev' => $wgContLang->isRTL() ?
'arrow_right_25.png' : 'arrow_left_25.png',
740 'next' => $wgContLang->isRTL() ?
'arrow_left_25.png' : 'arrow_right_25.png',
741 'last' => $wgContLang->isRTL() ?
'arrow_first_25.png' : 'arrow_last_25.png',
743 $disabledImages = array(
744 'first' => $wgContLang->isRTL() ?
'arrow_disabled_last_25.png' : 'arrow_disabled_first_25.png',
745 'prev' => $wgContLang->isRTL() ?
'arrow_disabled_right_25.png' : 'arrow_disabled_left_25.png',
746 'next' => $wgContLang->isRTL() ?
'arrow_disabled_left_25.png' : 'arrow_disabled_right_25.png',
747 'last' => $wgContLang->isRTL() ?
'arrow_disabled_first_25.png' : 'arrow_disabled_last_25.png',
750 $linkTexts = array();
751 $disabledTexts = array();
752 foreach ( $labels as $type => $label ) {
753 $msgLabel = wfMsgHtml( $label );
754 $linkTexts[$type] = "<img src=\"$path/{$images[$type]}\" alt=\"$msgLabel\"/><br/>$msgLabel";
755 $disabledTexts[$type] = "<img src=\"$path/{$disabledImages[$type]}\" alt=\"$msgLabel\"/><br/>$msgLabel";
757 $links = $this->getPagingLinks( $linkTexts, $disabledTexts );
759 $navClass = htmlspecialchars( $this->getNavClass() );
760 $s = "<table class=\"$navClass\" align=\"center\" cellpadding=\"3\"><tr>\n";
761 $cellAttrs = 'valign="top" align="center" width="' . 100 / count( $links ) . '%"';
762 foreach ( $labels as $type => $label ) {
763 $s .= "<td $cellAttrs>{$links[$type]}</td>\n";
765 $s .= "</tr></table>\n";
770 * Get a <select> element which has options for each of the allowed limits
772 function getLimitSelect() {
774 $s = "<select name=\"limit\">";
775 foreach ( $this->mLimitsShown
as $limit ) {
776 $selected = $limit == $this->mLimit ?
'selected="selected"' : '';
777 $formattedLimit = $wgLang->formatNum( $limit );
778 $s .= "<option value=\"$limit\" $selected>$formattedLimit</option>\n";
785 * Get <input type="hidden"> elements for use in a method="get" form.
786 * Resubmits all defined elements of the $_GET array, except for a
787 * blacklist, passed in the $blacklist parameter.
789 function getHiddenFields( $blacklist = array() ) {
790 $blacklist = (array)$blacklist;
792 foreach ( $blacklist as $name ) {
793 unset( $query[$name] );
796 foreach ( $query as $name => $value ) {
797 $encName = htmlspecialchars( $name );
798 $encValue = htmlspecialchars( $value );
799 $s .= "<input type=\"hidden\" name=\"$encName\" value=\"$encValue\"/>\n";
805 * Get a form containing a limit selection dropdown
807 function getLimitForm() {
808 # Make the select with some explanatory text
809 $url = $this->getTitle()->escapeLocalURL();
810 $msgSubmit = wfMsgHtml( 'table_pager_limit_submit' );
812 "<form method=\"get\" action=\"$url\">" .
813 wfMsgHtml( 'table_pager_limit', $this->getLimitSelect() ) .
814 "\n<input type=\"submit\" value=\"$msgSubmit\"/>\n" .
815 $this->getHiddenFields( 'limit' ) .
820 * Return true if the named field should be sortable by the UI, false
823 * @param string $field
825 abstract function isFieldSortable( $field );
828 * Format a table cell. The return value should be HTML, but use an empty
829 * string not for empty cells. Do not include the <td> and </td>.
831 * The current result row is available as $this->mCurrentRow, in case you
834 * @param string $name The database field name
835 * @param string $value The value retrieved from the database
837 abstract function formatValue( $name, $value );
840 * The database field name used as a default sort order
842 abstract function getDefaultSort();
845 * An array mapping database field names to a textual description of the
846 * field name, for use in the table header. The description should be plain
847 * text, it will be HTML-escaped later.
849 abstract function getFieldNames();