handler_sort.inc 735 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. /**
  3. * Class for sorting results according to a specified field.
  4. */
  5. class SearchApiViewsHandlerSort extends views_handler_sort {
  6. /**
  7. * The associated views query object.
  8. *
  9. * @var SearchApiViewsQuery
  10. */
  11. public $query;
  12. /**
  13. * Called to add the sort to a query.
  14. */
  15. public function query() {
  16. // When there are exposed sorts, the "exposed form" plugin will set
  17. // $query->orderby to an empty array. Therefore, if that property is set,
  18. // we here remove all previous sorts.
  19. if (isset($this->query->orderby)) {
  20. unset($this->query->orderby);
  21. $sort = &$this->query->getSort();
  22. $sort = array();
  23. }
  24. $this->query->sort($this->real_field, $this->options['order']);
  25. }
  26. }