* (bug 9808) Fix regression that ignored user 'rclimit' option for Special:Contributions
[lhc/web/wiklou.git] / includes / Pager.php
1 <?php
2
3 /**
4 * Basic pager interface.
5 * @addtogroup Pager
6 */
7 interface Pager {
8 function getNavigationBar();
9 function getBody();
10 }
11
12 /**
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 specified number
16 * of offset rows to find the desired data, which can be expensive for large offsets.
17 *
18 * ReverseChronologicalPager is a child class of the abstract IndexPager, and contains
19 * some formatting and display code which is specific to the use of timestamps as
20 * indexes. Here is a synopsis of its operation:
21 *
22 * * The query is specified by the offset, limit and direction (dir) parameters, in
23 * addition to any subclass-specific parameters.
24 *
25 * * The offset is the non-inclusive start of the DB query. A row with an index value
26 * equal to the offset will never be shown.
27 *
28 * * The query may either be done backwards, where the rows are returned by the database
29 * in the opposite order to which they are displayed to the user, or forwards. This is
30 * specified by the "dir" parameter, dir=prev means backwards, anything else means
31 * forwards. The offset value specifies the start of the database result set, which
32 * may be either 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 start of the
34 * previous page.
35 *
36 * * An additional row beyond the user-specified limit is always requested. This allows
37 * us to tell whether we should display a "next" link in the case of forwards mode,
38 * or a "previous" link in the case of backwards mode. Determining whether to
39 * display the other link (the one for the page before the start of the database
40 * result set) can be done heuristically by examining the offset.
41 *
42 * * An empty offset indicates that the offset condition should be omitted from the query.
43 * This naturally produces either the first page or the last page depending on the
44 * dir parameter.
45 *
46 * Subclassing the pager to implement concrete functionality should be fairly simple,
47 * please see the examples in PageHistory.php and SpecialIpblocklist.php. You just need
48 * to override formatRow(), getQueryInfo() and getIndexField(). Don't forget to call the
49 * parent constructor if you override it.
50 *
51 * @addtogroup Pager
52 */
53 abstract class IndexPager implements Pager {
54 public $mRequest;
55 public $mLimitsShown = array( 20, 50, 100, 250, 500 );
56 public $mDefaultLimit = 50;
57 public $mOffset, $mLimit;
58 public $mQueryDone = false;
59 public $mDb;
60 public $mPastTheEndRow;
61
62 protected $mIndexField;
63
64 /**
65 * Default query direction. false for ascending, true for descending
66 */
67 public $mDefaultDirection = false;
68
69 /**
70 * Result object for the query. Warning: seek before use.
71 */
72 public $mResult;
73
74 function __construct() {
75 global $wgRequest, $wgUser;
76 $this->mRequest = $wgRequest;
77
78 # NB: the offset is quoted, not validated. It is treated as an arbitrary string
79 # to support the widest variety of index types. Be careful outputting it into
80 # HTML!
81 $this->mOffset = $this->mRequest->getText( 'offset' );
82
83 # Use consistent behavior for the limit options
84 $this->mDefaultLimit = intval( $wgUser->getOption( 'rclimit' ) );
85 list( $this->mLimit, /* $offset */ ) = $this->mRequest->getLimitOffset();
86
87 $this->mIsBackwards = ( $this->mRequest->getVal( 'dir' ) == 'prev' );
88 $this->mIndexField = $this->getIndexField();
89 $this->mDb = wfGetDB( DB_SLAVE );
90 }
91
92 /**
93 * Do the query, using information from the object context. This function
94 * has been kept minimal to make it overridable if necessary, to allow for
95 * result sets formed from multiple DB queries.
96 */
97 function doQuery() {
98 # Use the child class name for profiling
99 $fname = __METHOD__ . ' (' . get_class( $this ) . ')';
100 wfProfileIn( $fname );
101
102 $descending = ( $this->mIsBackwards == $this->mDefaultDirection );
103 # Plus an extra row so that we can tell the "next" link should be shown
104 $queryLimit = $this->mLimit + 1;
105
106 $this->mResult = $this->reallyDoQuery( $this->mOffset, $queryLimit, $descending );
107 $this->extractResultInfo( $this->mOffset, $queryLimit, $this->mResult );
108 $this->mQueryDone = true;
109
110 wfProfileOut( $fname );
111 }
112
113 /**
114 * Extract some useful data from the result object for use by
115 * the navigation bar, put it into $this
116 */
117 function extractResultInfo( $offset, $limit, ResultWrapper $res ) {
118 $numRows = $res->numRows();
119 if ( $numRows ) {
120 $row = $res->fetchRow();
121 $firstIndex = $row[$this->mIndexField];
122
123 # Discard the extra result row if there is one
124 if ( $numRows > $this->mLimit && $numRows > 1 ) {
125 $res->seek( $numRows - 1 );
126 $this->mPastTheEndRow = $res->fetchObject();
127 $indexField = $this->mIndexField;
128 $this->mPastTheEndIndex = $this->mPastTheEndRow->$indexField;
129 $res->seek( $numRows - 2 );
130 $row = $res->fetchRow();
131 $lastIndex = $row[$this->mIndexField];
132 } else {
133 $this->mPastTheEndRow = null;
134 # Setting indexes to an empty string means that they will be omitted
135 # if they would otherwise appear in URLs. It just so happens that this
136 # is the right thing to do in the standard UI, in all the relevant cases.
137 $this->mPastTheEndIndex = '';
138 $res->seek( $numRows - 1 );
139 $row = $res->fetchRow();
140 $lastIndex = $row[$this->mIndexField];
141 }
142 } else {
143 $firstIndex = '';
144 $lastIndex = '';
145 $this->mPastTheEndRow = null;
146 $this->mPastTheEndIndex = '';
147 }
148
149 if ( $this->mIsBackwards ) {
150 $this->mIsFirst = ( $numRows < $limit );
151 $this->mIsLast = ( $offset == '' );
152 $this->mLastShown = $firstIndex;
153 $this->mFirstShown = $lastIndex;
154 } else {
155 $this->mIsFirst = ( $offset == '' );
156 $this->mIsLast = ( $numRows < $limit );
157 $this->mLastShown = $lastIndex;
158 $this->mFirstShown = $firstIndex;
159 }
160 }
161
162 /**
163 * Do a query with specified parameters, rather than using the object context
164 *
165 * @param string $offset Index offset, inclusive
166 * @param integer $limit Exact query limit
167 * @param boolean $descending Query direction, false for ascending, true for descending
168 * @return ResultWrapper
169 */
170 function reallyDoQuery( $offset, $limit, $ascending ) {
171 $fname = __METHOD__ . ' (' . get_class( $this ) . ')';
172 $info = $this->getQueryInfo();
173 $tables = $info['tables'];
174 $fields = $info['fields'];
175 $conds = isset( $info['conds'] ) ? $info['conds'] : array();
176 $options = isset( $info['options'] ) ? $info['options'] : array();
177 if ( $ascending ) {
178 $options['ORDER BY'] = $this->mIndexField;
179 $operator = '>';
180 } else {
181 $options['ORDER BY'] = $this->mIndexField . ' DESC';
182 $operator = '<';
183 }
184 if ( $offset != '' ) {
185 $conds[] = $this->mIndexField . $operator . $this->mDb->addQuotes( $offset );
186 }
187 $options['LIMIT'] = intval( $limit );
188 $res = $this->mDb->select( $tables, $fields, $conds, $fname, $options );
189 return new ResultWrapper( $this->mDb, $res );
190 }
191
192 /**
193 * Get the formatted result list. Calls getStartBody(), formatRow() and
194 * getEndBody(), concatenates the results and returns them.
195 */
196 function getBody() {
197 if ( !$this->mQueryDone ) {
198 $this->doQuery();
199 }
200 # Don't use any extra rows returned by the query
201 $numRows = min( $this->mResult->numRows(), $this->mLimit );
202
203 $s = $this->getStartBody();
204 if ( $numRows ) {
205 if ( $this->mIsBackwards ) {
206 for ( $i = $numRows - 1; $i >= 0; $i-- ) {
207 $this->mResult->seek( $i );
208 $row = $this->mResult->fetchObject();
209 $s .= $this->formatRow( $row );
210 }
211 } else {
212 $this->mResult->seek( 0 );
213 for ( $i = 0; $i < $numRows; $i++ ) {
214 $row = $this->mResult->fetchObject();
215 $s .= $this->formatRow( $row );
216 }
217 }
218 } else {
219 $s .= $this->getEmptyBody();
220 }
221 $s .= $this->getEndBody();
222 return $s;
223 }
224
225 /**
226 * Make a self-link
227 */
228 function makeLink($text, $query = NULL) {
229 if ( $query === null ) {
230 return $text;
231 } else {
232 return $this->getSkin()->makeKnownLinkObj( $this->getTitle(), $text,
233 wfArrayToCGI( $query, $this->getDefaultQuery() ) );
234 }
235 }
236
237 /**
238 * Hook into getBody(), allows text to be inserted at the start. This
239 * will be called even if there are no rows in the result set.
240 */
241 function getStartBody() {
242 return '';
243 }
244
245 /**
246 * Hook into getBody() for the end of the list
247 */
248 function getEndBody() {
249 return '';
250 }
251
252 /**
253 * Hook into getBody(), for the bit between the start and the
254 * end when there are no rows
255 */
256 function getEmptyBody() {
257 return '';
258 }
259
260 /**
261 * Title used for self-links. Override this if you want to be able to
262 * use a title other than $wgTitle
263 */
264 function getTitle() {
265 return $GLOBALS['wgTitle'];
266 }
267
268 /**
269 * Get the current skin. This can be overridden if necessary.
270 */
271 function getSkin() {
272 if ( !isset( $this->mSkin ) ) {
273 global $wgUser;
274 $this->mSkin = $wgUser->getSkin();
275 }
276 return $this->mSkin;
277 }
278
279 /**
280 * Get an array of query parameters that should be put into self-links.
281 * By default, all parameters passed in the URL are used, except for a
282 * short blacklist.
283 */
284 function getDefaultQuery() {
285 if ( !isset( $this->mDefaultQuery ) ) {
286 $this->mDefaultQuery = $_GET;
287 unset( $this->mDefaultQuery['title'] );
288 unset( $this->mDefaultQuery['dir'] );
289 unset( $this->mDefaultQuery['offset'] );
290 unset( $this->mDefaultQuery['limit'] );
291 }
292 return $this->mDefaultQuery;
293 }
294
295 /**
296 * Get the number of rows in the result set
297 */
298 function getNumRows() {
299 if ( !$this->mQueryDone ) {
300 $this->doQuery();
301 }
302 return $this->mResult->numRows();
303 }
304
305 /**
306 * Get a query array for the prev, next, first and last links.
307 */
308 function getPagingQueries() {
309 if ( !$this->mQueryDone ) {
310 $this->doQuery();
311 }
312
313 # Don't announce the limit everywhere if it's the default
314 $urlLimit = $this->mLimit == $this->mDefaultLimit ? '' : $this->mLimit;
315
316 if ( $this->mIsFirst ) {
317 $prev = false;
318 $first = false;
319 } else {
320 $prev = array( 'dir' => 'prev', 'offset' => $this->mFirstShown, 'limit' => $urlLimit );
321 $first = array( 'limit' => $urlLimit );
322 }
323 if ( $this->mIsLast ) {
324 $next = false;
325 $last = false;
326 } else {
327 $next = array( 'offset' => $this->mLastShown, 'limit' => $urlLimit );
328 $last = array( 'dir' => 'prev', 'limit' => $urlLimit );
329 }
330 return array( 'prev' => $prev, 'next' => $next, 'first' => $first, 'last' => $last );
331 }
332
333 /**
334 * Get paging links. If a link is disabled, the item from $disabledTexts will
335 * be used. If there is no such item, the unlinked text from $linkTexts will
336 * be used. Both $linkTexts and $disabledTexts are arrays of HTML.
337 */
338 function getPagingLinks( $linkTexts, $disabledTexts = array() ) {
339 $queries = $this->getPagingQueries();
340 $links = array();
341 foreach ( $queries as $type => $query ) {
342 if ( $query !== false ) {
343 $links[$type] = $this->makeLink( $linkTexts[$type], $queries[$type] );
344 } elseif ( isset( $disabledTexts[$type] ) ) {
345 $links[$type] = $disabledTexts[$type];
346 } else {
347 $links[$type] = $linkTexts[$type];
348 }
349 }
350 return $links;
351 }
352
353 function getLimitLinks() {
354 global $wgLang;
355 $links = array();
356 if ( $this->mIsBackwards ) {
357 $offset = $this->mPastTheEndIndex;
358 } else {
359 $offset = $this->mOffset;
360 }
361 foreach ( $this->mLimitsShown as $limit ) {
362 $links[] = $this->makeLink( $wgLang->formatNum( $limit ),
363 array( 'offset' => $offset, 'limit' => $limit ) );
364 }
365 return $links;
366 }
367
368 /**
369 * Abstract formatting function. This should return an HTML string
370 * representing the result row $row. Rows will be concatenated and
371 * returned by getBody()
372 */
373 abstract function formatRow( $row );
374
375 /**
376 * This function should be overridden to provide all parameters
377 * needed for the main paged query. It returns an associative
378 * array with the following elements:
379 * tables => Table(s) for passing to Database::select()
380 * fields => Field(s) for passing to Database::select(), may be *
381 * conds => WHERE conditions
382 * options => option array
383 */
384 abstract function getQueryInfo();
385
386 /**
387 * This function should be overridden to return the name of the
388 * index field.
389 */
390 abstract function getIndexField();
391 }
392
393
394 /**
395 * IndexPager with an alphabetic list and a formatted navigation bar
396 * @addtogroup Pager
397 */
398 abstract class AlphabeticPager extends IndexPager {
399 public $mDefaultDirection = false;
400
401 function __construct() {
402 parent::__construct();
403 }
404
405 /**
406 * Shamelessly stolen bits from ReverseChronologicalPager, d
407 * didn't want to do class magic as may be still revamped
408 */
409 function getNavigationBar() {
410 global $wgLang;
411
412 $linkTexts = array(
413 'prev' => wfMsgHtml( "prevn", $this->mLimit ),
414 'next' => wfMsgHtml( 'nextn', $this->mLimit ),
415 'first' => wfMsgHtml('page_first'), /* Introduced the message */
416 'last' => wfMsgHtml( 'page_last' ) /* Introduced the message */
417 );
418
419 $pagingLinks = $this->getPagingLinks( $linkTexts );
420 $limitLinks = $this->getLimitLinks();
421 $limits = implode( ' | ', $limitLinks );
422
423 $this->mNavigationBar = "({$pagingLinks['first']} | {$pagingLinks['last']}) " . wfMsgHtml("viewprevnext", $pagingLinks['prev'], $pagingLinks['next'], $limits);
424 return $this->mNavigationBar;
425
426 }
427 }
428
429 /**
430 * IndexPager with a formatted navigation bar
431 * @addtogroup Pager
432 */
433 abstract class ReverseChronologicalPager extends IndexPager {
434 public $mDefaultDirection = true;
435
436 function __construct() {
437 parent::__construct();
438 }
439
440 function getNavigationBar() {
441 global $wgLang;
442
443 if ( isset( $this->mNavigationBar ) ) {
444 return $this->mNavigationBar;
445 }
446 $linkTexts = array(
447 'prev' => wfMsgHtml( "prevn", $this->mLimit ),
448 'next' => wfMsgHtml( 'nextn', $this->mLimit ),
449 'first' => wfMsgHtml('histlast'),
450 'last' => wfMsgHtml( 'histfirst' )
451 );
452
453 $pagingLinks = $this->getPagingLinks( $linkTexts );
454 $limitLinks = $this->getLimitLinks();
455 $limits = implode( ' | ', $limitLinks );
456
457 $this->mNavigationBar = "({$pagingLinks['first']} | {$pagingLinks['last']}) " .
458 wfMsgHtml("viewprevnext", $pagingLinks['prev'], $pagingLinks['next'], $limits);
459 return $this->mNavigationBar;
460 }
461 }
462
463 /**
464 * Table-based display with a user-selectable sort order
465 * @addtogroup Pager
466 */
467 abstract class TablePager extends IndexPager {
468 var $mSort;
469 var $mCurrentRow;
470
471 function __construct() {
472 global $wgRequest;
473 $this->mSort = $wgRequest->getText( 'sort' );
474 if ( !array_key_exists( $this->mSort, $this->getFieldNames() ) ) {
475 $this->mSort = $this->getDefaultSort();
476 }
477 if ( $wgRequest->getBool( 'asc' ) ) {
478 $this->mDefaultDirection = false;
479 } elseif ( $wgRequest->getBool( 'desc' ) ) {
480 $this->mDefaultDirection = true;
481 } /* Else leave it at whatever the class default is */
482
483 parent::__construct();
484 }
485
486 function getStartBody() {
487 global $wgStylePath;
488 $tableClass = htmlspecialchars( $this->getTableClass() );
489 $sortClass = htmlspecialchars( $this->getSortHeaderClass() );
490
491 $s = "<table border='1' class=\"$tableClass\"><thead><tr>\n";
492 $fields = $this->getFieldNames();
493
494 # Make table header
495 foreach ( $fields as $field => $name ) {
496 if ( strval( $name ) == '' ) {
497 $s .= "<th>&nbsp;</th>\n";
498 } elseif ( $this->isFieldSortable( $field ) ) {
499 $query = array( 'sort' => $field, 'limit' => $this->mLimit );
500 if ( $field == $this->mSort ) {
501 # This is the sorted column
502 # Prepare a link that goes in the other sort order
503 if ( $this->mDefaultDirection ) {
504 # Descending
505 $image = 'Arr_u.png';
506 $query['asc'] = '1';
507 $query['desc'] = '';
508 $alt = htmlspecialchars( wfMsg( 'descending_abbrev' ) );
509 } else {
510 # Ascending
511 $image = 'Arr_d.png';
512 $query['asc'] = '';
513 $query['desc'] = '1';
514 $alt = htmlspecialchars( wfMsg( 'ascending_abbrev' ) );
515 }
516 $image = htmlspecialchars( "$wgStylePath/common/images/$image" );
517 $link = $this->makeLink(
518 "<img width=\"12\" height=\"12\" alt=\"$alt\" src=\"$image\" />" .
519 htmlspecialchars( $name ), $query );
520 $s .= "<th class=\"$sortClass\">$link</th>\n";
521 } else {
522 $s .= '<th>' . $this->makeLink( htmlspecialchars( $name ), $query ) . "</th>\n";
523 }
524 } else {
525 $s .= '<th>' . htmlspecialchars( $name ) . "</th>\n";
526 }
527 }
528 $s .= "</tr></thead><tbody>\n";
529 return $s;
530 }
531
532 function getEndBody() {
533 return "</tbody></table>\n";
534 }
535
536 function getEmptyBody() {
537 $colspan = count( $this->getFieldNames() );
538 $msgEmpty = wfMsgHtml( 'table_pager_empty' );
539 return "<tr><td colspan=\"$colspan\">$msgEmpty</td></tr>\n";
540 }
541
542 function formatRow( $row ) {
543 $s = "<tr>\n";
544 $fieldNames = $this->getFieldNames();
545 $this->mCurrentRow = $row; # In case formatValue needs to know
546 foreach ( $fieldNames as $field => $name ) {
547 $value = isset( $row->$field ) ? $row->$field : null;
548 $formatted = strval( $this->formatValue( $field, $value ) );
549 if ( $formatted == '' ) {
550 $formatted = '&nbsp;';
551 }
552 $class = 'TablePager_col_' . htmlspecialchars( $field );
553 $s .= "<td class=\"$class\">$formatted</td>\n";
554 }
555 $s .= "</tr>\n";
556 return $s;
557 }
558
559 function getIndexField() {
560 return $this->mSort;
561 }
562
563 function getTableClass() {
564 return 'TablePager';
565 }
566
567 function getNavClass() {
568 return 'TablePager_nav';
569 }
570
571 function getSortHeaderClass() {
572 return 'TablePager_sort';
573 }
574
575 /**
576 * A navigation bar with images
577 */
578 function getNavigationBar() {
579 global $wgStylePath, $wgContLang;
580 $path = "$wgStylePath/common/images";
581 $labels = array(
582 'first' => 'table_pager_first',
583 'prev' => 'table_pager_prev',
584 'next' => 'table_pager_next',
585 'last' => 'table_pager_last',
586 );
587 $images = array(
588 'first' => $wgContLang->isRTL() ? 'arrow_last_25.png' : 'arrow_first_25.png',
589 'prev' => $wgContLang->isRTL() ? 'arrow_right_25.png' : 'arrow_left_25.png',
590 'next' => $wgContLang->isRTL() ? 'arrow_left_25.png' : 'arrow_right_25.png',
591 'last' => $wgContLang->isRTL() ? 'arrow_first_25.png' : 'arrow_last_25.png',
592 );
593 $disabledImages = array(
594 'first' => $wgContLang->isRTL() ? 'arrow_disabled_last_25.png' : 'arrow_disabled_first_25.png',
595 'prev' => $wgContLang->isRTL() ? 'arrow_disabled_right_25.png' : 'arrow_disabled_left_25.png',
596 'next' => $wgContLang->isRTL() ? 'arrow_disabled_left_25.png' : 'arrow_disabled_right_25.png',
597 'last' => $wgContLang->isRTL() ? 'arrow_disabled_first_25.png' : 'arrow_disabled_last_25.png',
598 );
599
600 $linkTexts = array();
601 $disabledTexts = array();
602 foreach ( $labels as $type => $label ) {
603 $msgLabel = wfMsgHtml( $label );
604 $linkTexts[$type] = "<img src=\"$path/{$images[$type]}\" alt=\"$msgLabel\"/><br/>$msgLabel";
605 $disabledTexts[$type] = "<img src=\"$path/{$disabledImages[$type]}\" alt=\"$msgLabel\"/><br/>$msgLabel";
606 }
607 $links = $this->getPagingLinks( $linkTexts, $disabledTexts );
608
609 $navClass = htmlspecialchars( $this->getNavClass() );
610 $s = "<table class=\"$navClass\" align=\"center\" cellpadding=\"3\"><tr>\n";
611 $cellAttrs = 'valign="top" align="center" width="' . 100 / count( $links ) . '%"';
612 foreach ( $labels as $type => $label ) {
613 $s .= "<td $cellAttrs>{$links[$type]}</td>\n";
614 }
615 $s .= "</tr></table>\n";
616 return $s;
617 }
618
619 /**
620 * Get a <select> element which has options for each of the allowed limits
621 */
622 function getLimitSelect() {
623 global $wgLang;
624 $s = "<select name=\"limit\">";
625 foreach ( $this->mLimitsShown as $limit ) {
626 $selected = $limit == $this->mLimit ? 'selected="selected"' : '';
627 $formattedLimit = $wgLang->formatNum( $limit );
628 $s .= "<option value=\"$limit\" $selected>$formattedLimit</option>\n";
629 }
630 $s .= "</select>";
631 return $s;
632 }
633
634 /**
635 * Get <input type="hidden"> elements for use in a method="get" form.
636 * Resubmits all defined elements of the $_GET array, except for a
637 * blacklist, passed in the $blacklist parameter.
638 */
639 function getHiddenFields( $blacklist = array() ) {
640 $blacklist = (array)$blacklist;
641 $query = $_GET;
642 foreach ( $blacklist as $name ) {
643 unset( $query[$name] );
644 }
645 $s = '';
646 foreach ( $query as $name => $value ) {
647 $encName = htmlspecialchars( $name );
648 $encValue = htmlspecialchars( $value );
649 $s .= "<input type=\"hidden\" name=\"$encName\" value=\"$encValue\"/>\n";
650 }
651 return $s;
652 }
653
654 /**
655 * Get a form containing a limit selection dropdown
656 */
657 function getLimitForm() {
658 # Make the select with some explanatory text
659 $url = $this->getTitle()->escapeLocalURL();
660 $msgSubmit = wfMsgHtml( 'table_pager_limit_submit' );
661 return
662 "<form method=\"get\" action=\"$url\">" .
663 wfMsgHtml( 'table_pager_limit', $this->getLimitSelect() ) .
664 "\n<input type=\"submit\" value=\"$msgSubmit\"/>\n" .
665 $this->getHiddenFields( 'limit' ) .
666 "</form>\n";
667 }
668
669 /**
670 * Return true if the named field should be sortable by the UI, false otherwise
671 * @param string $field
672 */
673 abstract function isFieldSortable( $field );
674
675 /**
676 * Format a table cell. The return value should be HTML, but use an empty string
677 * not &nbsp; for empty cells. Do not include the <td> and </td>.
678 *
679 * @param string $name The database field name
680 * @param string $value The value retrieved from the database
681 *
682 * The current result row is available as $this->mCurrentRow, in case you need
683 * more context.
684 */
685 abstract function formatValue( $name, $value );
686
687 /**
688 * The database field name used as a default sort order
689 */
690 abstract function getDefaultSort();
691
692 /**
693 * An array mapping database field names to a textual description of the field
694 * name, for use in the table header. The description should be plain text, it
695 * will be HTML-escaped later.
696 */
697 abstract function getFieldNames();
698 }
699 ?>