Merge "Add some translations for Western Punjabi (pnb)"
[lhc/web/wiklou.git] / includes / pager / IndexPager.php
1 <?php
2 /**
3 * Efficient paging for SQL queries.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup Pager
22 */
23
24 use Wikimedia\Rdbms\ResultWrapper;
25
26 /**
27 * IndexPager is an efficient pager which uses a (roughly unique) index in the
28 * data set to implement paging, rather than a "LIMIT offset,limit" clause.
29 * In MySQL, such a limit/offset clause requires counting through the
30 * specified number of offset rows to find the desired data, which can be
31 * expensive for large offsets.
32 *
33 * ReverseChronologicalPager is a child class of the abstract IndexPager, and
34 * contains some formatting and display code which is specific to the use of
35 * timestamps as indexes. Here is a synopsis of its operation:
36 *
37 * * The query is specified by the offset, limit and direction (dir)
38 * parameters, in addition to any subclass-specific parameters.
39 * * The offset is the non-inclusive start of the DB query. A row with an
40 * index value equal to the offset will never be shown.
41 * * The query may either be done backwards, where the rows are returned by
42 * the database in the opposite order to which they are displayed to the
43 * user, or forwards. This is specified by the "dir" parameter, dir=prev
44 * means backwards, anything else means forwards. The offset value
45 * specifies the start of the database result set, which may be either
46 * the start or end of the displayed data set. This allows "previous"
47 * links to be implemented without knowledge of the index value at the
48 * start of the previous page.
49 * * An additional row beyond the user-specified limit is always requested.
50 * This allows us to tell whether we should display a "next" link in the
51 * case of forwards mode, or a "previous" link in the case of backwards
52 * mode. Determining whether to display the other link (the one for the
53 * page before the start of the database result set) can be done
54 * heuristically by examining the offset.
55 *
56 * * An empty offset indicates that the offset condition should be omitted
57 * from the query. This naturally produces either the first page or the
58 * last page depending on the dir parameter.
59 *
60 * Subclassing the pager to implement concrete functionality should be fairly
61 * simple, please see the examples in HistoryAction.php and
62 * SpecialBlockList.php. You just need to override formatRow(),
63 * getQueryInfo() and getIndexField(). Don't forget to call the parent
64 * constructor if you override it.
65 *
66 * @ingroup Pager
67 */
68 abstract class IndexPager extends ContextSource implements Pager {
69 /**
70 * Constants for the $mDefaultDirection field.
71 *
72 * These are boolean for historical reasons and should stay boolean for backwards-compatibility.
73 */
74 const DIR_ASCENDING = false;
75 const DIR_DESCENDING = true;
76
77 public $mRequest;
78 public $mLimitsShown = [ 20, 50, 100, 250, 500 ];
79 public $mDefaultLimit = 50;
80 public $mOffset, $mLimit;
81 public $mQueryDone = false;
82 public $mDb;
83 public $mPastTheEndRow;
84
85 /**
86 * The index to actually be used for ordering. This is a single column,
87 * for one ordering, even if multiple orderings are supported.
88 */
89 protected $mIndexField;
90 /**
91 * An array of secondary columns to order by. These fields are not part of the offset.
92 * This is a column list for one ordering, even if multiple orderings are supported.
93 */
94 protected $mExtraSortFields;
95 /** For pages that support multiple types of ordering, which one to use.
96 */
97 protected $mOrderType;
98 /**
99 * $mDefaultDirection gives the direction to use when sorting results:
100 * DIR_ASCENDING or DIR_DESCENDING. If $mIsBackwards is set, we
101 * start from the opposite end, but we still sort the page itself according
102 * to $mDefaultDirection. E.g., if $mDefaultDirection is false but we're
103 * going backwards, we'll display the last page of results, but the last
104 * result will be at the bottom, not the top.
105 *
106 * Like $mIndexField, $mDefaultDirection will be a single value even if the
107 * class supports multiple default directions for different order types.
108 */
109 public $mDefaultDirection;
110 public $mIsBackwards;
111
112 /** True if the current result set is the first one */
113 public $mIsFirst;
114 public $mIsLast;
115
116 protected $mLastShown, $mFirstShown, $mPastTheEndIndex, $mDefaultQuery, $mNavigationBar;
117
118 /**
119 * Whether to include the offset in the query
120 */
121 protected $mIncludeOffset = false;
122
123 /**
124 * Result object for the query. Warning: seek before use.
125 *
126 * @var ResultWrapper
127 */
128 public $mResult;
129
130 public function __construct( IContextSource $context = null ) {
131 if ( $context ) {
132 $this->setContext( $context );
133 }
134
135 $this->mRequest = $this->getRequest();
136
137 # NB: the offset is quoted, not validated. It is treated as an
138 # arbitrary string to support the widest variety of index types. Be
139 # careful outputting it into HTML!
140 $this->mOffset = $this->mRequest->getText( 'offset' );
141
142 # Use consistent behavior for the limit options
143 $this->mDefaultLimit = $this->getUser()->getIntOption( 'rclimit' );
144 if ( !$this->mLimit ) {
145 // Don't override if a subclass calls $this->setLimit() in its constructor.
146 list( $this->mLimit, /* $offset */ ) = $this->mRequest->getLimitOffset();
147 }
148
149 $this->mIsBackwards = ( $this->mRequest->getVal( 'dir' ) == 'prev' );
150 # Let the subclass set the DB here; otherwise use a replica DB for the current wiki
151 $this->mDb = $this->mDb ?: wfGetDB( DB_REPLICA );
152
153 $index = $this->getIndexField(); // column to sort on
154 $extraSort = $this->getExtraSortFields(); // extra columns to sort on for query planning
155 $order = $this->mRequest->getVal( 'order' );
156 if ( is_array( $index ) && isset( $index[$order] ) ) {
157 $this->mOrderType = $order;
158 $this->mIndexField = $index[$order];
159 $this->mExtraSortFields = isset( $extraSort[$order] )
160 ? (array)$extraSort[$order]
161 : [];
162 } elseif ( is_array( $index ) ) {
163 # First element is the default
164 reset( $index );
165 list( $this->mOrderType, $this->mIndexField ) = each( $index );
166 $this->mExtraSortFields = isset( $extraSort[$this->mOrderType] )
167 ? (array)$extraSort[$this->mOrderType]
168 : [];
169 } else {
170 # $index is not an array
171 $this->mOrderType = null;
172 $this->mIndexField = $index;
173 $this->mExtraSortFields = (array)$extraSort;
174 }
175
176 if ( !isset( $this->mDefaultDirection ) ) {
177 $dir = $this->getDefaultDirections();
178 $this->mDefaultDirection = is_array( $dir )
179 ? $dir[$this->mOrderType]
180 : $dir;
181 }
182 }
183
184 /**
185 * Get the Database object in use
186 *
187 * @return IDatabase
188 */
189 public function getDatabase() {
190 return $this->mDb;
191 }
192
193 /**
194 * Do the query, using information from the object context. This function
195 * has been kept minimal to make it overridable if necessary, to allow for
196 * result sets formed from multiple DB queries.
197 */
198 public function doQuery() {
199 # Use the child class name for profiling
200 $fname = __METHOD__ . ' (' . static::class . ')';
201 $section = Profiler::instance()->scopedProfileIn( $fname );
202
203 // @todo This should probably compare to DIR_DESCENDING and DIR_ASCENDING constants
204 $descending = ( $this->mIsBackwards == $this->mDefaultDirection );
205 # Plus an extra row so that we can tell the "next" link should be shown
206 $queryLimit = $this->mLimit + 1;
207
208 if ( $this->mOffset == '' ) {
209 $isFirst = true;
210 } else {
211 // If there's an offset, we may or may not be at the first entry.
212 // The only way to tell is to run the query in the opposite
213 // direction see if we get a row.
214 $oldIncludeOffset = $this->mIncludeOffset;
215 $this->mIncludeOffset = !$this->mIncludeOffset;
216 $isFirst = !$this->reallyDoQuery( $this->mOffset, 1, !$descending )->numRows();
217 $this->mIncludeOffset = $oldIncludeOffset;
218 }
219
220 $this->mResult = $this->reallyDoQuery(
221 $this->mOffset,
222 $queryLimit,
223 $descending
224 );
225
226 $this->extractResultInfo( $isFirst, $queryLimit, $this->mResult );
227 $this->mQueryDone = true;
228
229 $this->preprocessResults( $this->mResult );
230 $this->mResult->rewind(); // Paranoia
231 }
232
233 /**
234 * @return ResultWrapper The result wrapper.
235 */
236 function getResult() {
237 return $this->mResult;
238 }
239
240 /**
241 * Set the offset from an other source than the request
242 *
243 * @param int|string $offset
244 */
245 function setOffset( $offset ) {
246 $this->mOffset = $offset;
247 }
248
249 /**
250 * Set the limit from an other source than the request
251 *
252 * Verifies limit is between 1 and 5000
253 *
254 * @param int|string $limit
255 */
256 function setLimit( $limit ) {
257 $limit = (int)$limit;
258 // WebRequest::getLimitOffset() puts a cap of 5000, so do same here.
259 if ( $limit > 5000 ) {
260 $limit = 5000;
261 }
262 if ( $limit > 0 ) {
263 $this->mLimit = $limit;
264 }
265 }
266
267 /**
268 * Get the current limit
269 *
270 * @return int
271 */
272 function getLimit() {
273 return $this->mLimit;
274 }
275
276 /**
277 * Set whether a row matching exactly the offset should be also included
278 * in the result or not. By default this is not the case, but when the
279 * offset is user-supplied this might be wanted.
280 *
281 * @param bool $include
282 */
283 public function setIncludeOffset( $include ) {
284 $this->mIncludeOffset = $include;
285 }
286
287 /**
288 * Extract some useful data from the result object for use by
289 * the navigation bar, put it into $this
290 *
291 * @param bool $isFirst False if there are rows before those fetched (i.e.
292 * if a "previous" link would make sense)
293 * @param int $limit Exact query limit
294 * @param ResultWrapper $res
295 */
296 function extractResultInfo( $isFirst, $limit, ResultWrapper $res ) {
297 $numRows = $res->numRows();
298 if ( $numRows ) {
299 # Remove any table prefix from index field
300 $parts = explode( '.', $this->mIndexField );
301 $indexColumn = end( $parts );
302
303 $row = $res->fetchRow();
304 $firstIndex = $row[$indexColumn];
305
306 # Discard the extra result row if there is one
307 if ( $numRows > $this->mLimit && $numRows > 1 ) {
308 $res->seek( $numRows - 1 );
309 $this->mPastTheEndRow = $res->fetchObject();
310 $this->mPastTheEndIndex = $this->mPastTheEndRow->$indexColumn;
311 $res->seek( $numRows - 2 );
312 $row = $res->fetchRow();
313 $lastIndex = $row[$indexColumn];
314 } else {
315 $this->mPastTheEndRow = null;
316 # Setting indexes to an empty string means that they will be
317 # omitted if they would otherwise appear in URLs. It just so
318 # happens that this is the right thing to do in the standard
319 # UI, in all the relevant cases.
320 $this->mPastTheEndIndex = '';
321 $res->seek( $numRows - 1 );
322 $row = $res->fetchRow();
323 $lastIndex = $row[$indexColumn];
324 }
325 } else {
326 $firstIndex = '';
327 $lastIndex = '';
328 $this->mPastTheEndRow = null;
329 $this->mPastTheEndIndex = '';
330 }
331
332 if ( $this->mIsBackwards ) {
333 $this->mIsFirst = ( $numRows < $limit );
334 $this->mIsLast = $isFirst;
335 $this->mLastShown = $firstIndex;
336 $this->mFirstShown = $lastIndex;
337 } else {
338 $this->mIsFirst = $isFirst;
339 $this->mIsLast = ( $numRows < $limit );
340 $this->mLastShown = $lastIndex;
341 $this->mFirstShown = $firstIndex;
342 }
343 }
344
345 /**
346 * Get some text to go in brackets in the "function name" part of the SQL comment
347 *
348 * @return string
349 */
350 function getSqlComment() {
351 return static::class;
352 }
353
354 /**
355 * Do a query with specified parameters, rather than using the object
356 * context
357 *
358 * @param string $offset Index offset, inclusive
359 * @param int $limit Exact query limit
360 * @param bool $descending Query direction, false for ascending, true for descending
361 * @return ResultWrapper
362 */
363 public function reallyDoQuery( $offset, $limit, $descending ) {
364 list( $tables, $fields, $conds, $fname, $options, $join_conds ) =
365 $this->buildQueryInfo( $offset, $limit, $descending );
366
367 return $this->mDb->select( $tables, $fields, $conds, $fname, $options, $join_conds );
368 }
369
370 /**
371 * Build variables to use by the database wrapper.
372 *
373 * @param string $offset Index offset, inclusive
374 * @param int $limit Exact query limit
375 * @param bool $descending Query direction, false for ascending, true for descending
376 * @return array
377 */
378 protected function buildQueryInfo( $offset, $limit, $descending ) {
379 $fname = __METHOD__ . ' (' . $this->getSqlComment() . ')';
380 $info = $this->getQueryInfo();
381 $tables = $info['tables'];
382 $fields = $info['fields'];
383 $conds = isset( $info['conds'] ) ? $info['conds'] : [];
384 $options = isset( $info['options'] ) ? $info['options'] : [];
385 $join_conds = isset( $info['join_conds'] ) ? $info['join_conds'] : [];
386 $sortColumns = array_merge( [ $this->mIndexField ], $this->mExtraSortFields );
387 if ( $descending ) {
388 $options['ORDER BY'] = $sortColumns;
389 $operator = $this->mIncludeOffset ? '>=' : '>';
390 } else {
391 $orderBy = [];
392 foreach ( $sortColumns as $col ) {
393 $orderBy[] = $col . ' DESC';
394 }
395 $options['ORDER BY'] = $orderBy;
396 $operator = $this->mIncludeOffset ? '<=' : '<';
397 }
398 if ( $offset != '' ) {
399 $conds[] = $this->mIndexField . $operator . $this->mDb->addQuotes( $offset );
400 }
401 $options['LIMIT'] = intval( $limit );
402 return [ $tables, $fields, $conds, $fname, $options, $join_conds ];
403 }
404
405 /**
406 * Pre-process results; useful for performing batch existence checks, etc.
407 *
408 * @param ResultWrapper $result
409 */
410 protected function preprocessResults( $result ) {
411 }
412
413 /**
414 * Get the formatted result list. Calls getStartBody(), formatRow() and
415 * getEndBody(), concatenates the results and returns them.
416 *
417 * @return string
418 */
419 public function getBody() {
420 if ( !$this->mQueryDone ) {
421 $this->doQuery();
422 }
423
424 if ( $this->mResult->numRows() ) {
425 # Do any special query batches before display
426 $this->doBatchLookups();
427 }
428
429 # Don't use any extra rows returned by the query
430 $numRows = min( $this->mResult->numRows(), $this->mLimit );
431
432 $s = $this->getStartBody();
433 if ( $numRows ) {
434 if ( $this->mIsBackwards ) {
435 for ( $i = $numRows - 1; $i >= 0; $i-- ) {
436 $this->mResult->seek( $i );
437 $row = $this->mResult->fetchObject();
438 $s .= $this->formatRow( $row );
439 }
440 } else {
441 $this->mResult->seek( 0 );
442 for ( $i = 0; $i < $numRows; $i++ ) {
443 $row = $this->mResult->fetchObject();
444 $s .= $this->formatRow( $row );
445 }
446 }
447 } else {
448 $s .= $this->getEmptyBody();
449 }
450 $s .= $this->getEndBody();
451 return $s;
452 }
453
454 /**
455 * Make a self-link
456 *
457 * @param string $text Text displayed on the link
458 * @param array $query Associative array of parameter to be in the query string
459 * @param string $type Link type used to create additional attributes, like "rel", "class" or
460 * "title". Valid values (non-exhaustive list): 'first', 'last', 'prev', 'next', 'asc', 'desc'.
461 * @return string HTML fragment
462 */
463 function makeLink( $text, array $query = null, $type = null ) {
464 if ( $query === null ) {
465 return $text;
466 }
467
468 $attrs = [];
469 if ( in_array( $type, [ 'prev', 'next' ] ) ) {
470 $attrs['rel'] = $type;
471 }
472
473 if ( in_array( $type, [ 'asc', 'desc' ] ) ) {
474 $attrs['title'] = wfMessage( $type == 'asc' ? 'sort-ascending' : 'sort-descending' )->text();
475 }
476
477 if ( $type ) {
478 $attrs['class'] = "mw-{$type}link";
479 }
480
481 return Linker::linkKnown(
482 $this->getTitle(),
483 $text,
484 $attrs,
485 $query + $this->getDefaultQuery()
486 );
487 }
488
489 /**
490 * Called from getBody(), before getStartBody() is called and
491 * after doQuery() was called. This will be called only if there
492 * are rows in the result set.
493 *
494 * @return void
495 */
496 protected function doBatchLookups() {
497 }
498
499 /**
500 * Hook into getBody(), allows text to be inserted at the start. This
501 * will be called even if there are no rows in the result set.
502 *
503 * @return string
504 */
505 protected function getStartBody() {
506 return '';
507 }
508
509 /**
510 * Hook into getBody() for the end of the list
511 *
512 * @return string
513 */
514 protected function getEndBody() {
515 return '';
516 }
517
518 /**
519 * Hook into getBody(), for the bit between the start and the
520 * end when there are no rows
521 *
522 * @return string
523 */
524 protected function getEmptyBody() {
525 return '';
526 }
527
528 /**
529 * Get an array of query parameters that should be put into self-links.
530 * By default, all parameters passed in the URL are used, except for a
531 * short blacklist.
532 *
533 * @return array Associative array
534 */
535 function getDefaultQuery() {
536 if ( !isset( $this->mDefaultQuery ) ) {
537 $this->mDefaultQuery = $this->getRequest()->getQueryValues();
538 unset( $this->mDefaultQuery['title'] );
539 unset( $this->mDefaultQuery['dir'] );
540 unset( $this->mDefaultQuery['offset'] );
541 unset( $this->mDefaultQuery['limit'] );
542 unset( $this->mDefaultQuery['order'] );
543 unset( $this->mDefaultQuery['month'] );
544 unset( $this->mDefaultQuery['year'] );
545 }
546 return $this->mDefaultQuery;
547 }
548
549 /**
550 * Get the number of rows in the result set
551 *
552 * @return int
553 */
554 function getNumRows() {
555 if ( !$this->mQueryDone ) {
556 $this->doQuery();
557 }
558 return $this->mResult->numRows();
559 }
560
561 /**
562 * Get a URL query array for the prev, next, first and last links.
563 *
564 * @return array
565 */
566 function getPagingQueries() {
567 if ( !$this->mQueryDone ) {
568 $this->doQuery();
569 }
570
571 # Don't announce the limit everywhere if it's the default
572 $urlLimit = $this->mLimit == $this->mDefaultLimit ? null : $this->mLimit;
573
574 if ( $this->mIsFirst ) {
575 $prev = false;
576 $first = false;
577 } else {
578 $prev = [
579 'dir' => 'prev',
580 'offset' => $this->mFirstShown,
581 'limit' => $urlLimit
582 ];
583 $first = [ 'limit' => $urlLimit ];
584 }
585 if ( $this->mIsLast ) {
586 $next = false;
587 $last = false;
588 } else {
589 $next = [ 'offset' => $this->mLastShown, 'limit' => $urlLimit ];
590 $last = [ 'dir' => 'prev', 'limit' => $urlLimit ];
591 }
592 return [
593 'prev' => $prev,
594 'next' => $next,
595 'first' => $first,
596 'last' => $last
597 ];
598 }
599
600 /**
601 * Returns whether to show the "navigation bar"
602 *
603 * @return bool
604 */
605 function isNavigationBarShown() {
606 if ( !$this->mQueryDone ) {
607 $this->doQuery();
608 }
609 // Hide navigation by default if there is nothing to page
610 return !( $this->mIsFirst && $this->mIsLast );
611 }
612
613 /**
614 * Get paging links. If a link is disabled, the item from $disabledTexts
615 * will be used. If there is no such item, the unlinked text from
616 * $linkTexts will be used. Both $linkTexts and $disabledTexts are arrays
617 * of HTML.
618 *
619 * @param array $linkTexts
620 * @param array $disabledTexts
621 * @return array
622 */
623 function getPagingLinks( $linkTexts, $disabledTexts = [] ) {
624 $queries = $this->getPagingQueries();
625 $links = [];
626
627 foreach ( $queries as $type => $query ) {
628 if ( $query !== false ) {
629 $links[$type] = $this->makeLink(
630 $linkTexts[$type],
631 $queries[$type],
632 $type
633 );
634 } elseif ( isset( $disabledTexts[$type] ) ) {
635 $links[$type] = $disabledTexts[$type];
636 } else {
637 $links[$type] = $linkTexts[$type];
638 }
639 }
640
641 return $links;
642 }
643
644 function getLimitLinks() {
645 $links = [];
646 if ( $this->mIsBackwards ) {
647 $offset = $this->mPastTheEndIndex;
648 } else {
649 $offset = $this->mOffset;
650 }
651 foreach ( $this->mLimitsShown as $limit ) {
652 $links[] = $this->makeLink(
653 $this->getLanguage()->formatNum( $limit ),
654 [ 'offset' => $offset, 'limit' => $limit ],
655 'num'
656 );
657 }
658 return $links;
659 }
660
661 /**
662 * Abstract formatting function. This should return an HTML string
663 * representing the result row $row. Rows will be concatenated and
664 * returned by getBody()
665 *
666 * @param array|stdClass $row Database row
667 * @return string
668 */
669 abstract function formatRow( $row );
670
671 /**
672 * This function should be overridden to provide all parameters
673 * needed for the main paged query. It returns an associative
674 * array with the following elements:
675 * tables => Table(s) for passing to Database::select()
676 * fields => Field(s) for passing to Database::select(), may be *
677 * conds => WHERE conditions
678 * options => option array
679 * join_conds => JOIN conditions
680 *
681 * @return array
682 */
683 abstract function getQueryInfo();
684
685 /**
686 * This function should be overridden to return the name of the index fi-
687 * eld. If the pager supports multiple orders, it may return an array of
688 * 'querykey' => 'indexfield' pairs, so that a request with &count=querykey
689 * will use indexfield to sort. In this case, the first returned key is
690 * the default.
691 *
692 * Needless to say, it's really not a good idea to use a non-unique index
693 * for this! That won't page right.
694 *
695 * @return string|array
696 */
697 abstract function getIndexField();
698
699 /**
700 * This function should be overridden to return the names of secondary columns
701 * to order by in addition to the column in getIndexField(). These fields will
702 * not be used in the pager offset or in any links for users.
703 *
704 * If getIndexField() returns an array of 'querykey' => 'indexfield' pairs then
705 * this must return a corresponding array of 'querykey' => [ fields... ] pairs
706 * in order for a request with &count=querykey to use [ fields... ] to sort.
707 *
708 * This is useful for pagers that GROUP BY a unique column (say page_id)
709 * and ORDER BY another (say page_len). Using GROUP BY and ORDER BY both on
710 * page_len,page_id avoids temp tables (given a page_len index). This would
711 * also work if page_id was non-unique but we had a page_len,page_id index.
712 *
713 * @return array
714 */
715 protected function getExtraSortFields() {
716 return [];
717 }
718
719 /**
720 * Return the default sorting direction: DIR_ASCENDING or DIR_DESCENDING.
721 * You can also have an associative array of ordertype => dir,
722 * if multiple order types are supported. In this case getIndexField()
723 * must return an array, and the keys of that must exactly match the keys
724 * of this.
725 *
726 * For backward compatibility, this method's return value will be ignored
727 * if $this->mDefaultDirection is already set when the constructor is
728 * called, for instance if it's statically initialized. In that case the
729 * value of that variable (which must be a boolean) will be used.
730 *
731 * Note that despite its name, this does not return the value of the
732 * $this->mDefaultDirection member variable. That's the default for this
733 * particular instantiation, which is a single value. This is the set of
734 * all defaults for the class.
735 *
736 * @return bool
737 */
738 protected function getDefaultDirections() {
739 return IndexPager::DIR_ASCENDING;
740 }
741 }