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