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