handler_sort.inc 792 B

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