views_handler_sort_search_score.inc

  1. 3.x modules/search/views_handler_sort_search_score.inc
  2. 2.x modules/search/views_handler_sort_search_score.inc

Definition of views_handler_sort_search_score.

File

modules/search/views_handler_sort_search_score.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_handler_sort_search_score.
  5. */
  6. /**
  7. * Field handler to provide simple renderer that allows linking to a node.
  8. *
  9. * @ingroup views_sort_handlers
  10. */
  11. class views_handler_sort_search_score extends views_handler_sort {
  12. function query() {
  13. // Check to see if the search filter/argument added 'score' to the table.
  14. // Our filter stores it as $handler->search_score -- and we also
  15. // need to check its relationship to make sure that we're using the same
  16. // one or obviously this won't work.
  17. foreach (array('filter', 'argument') as $type) {
  18. foreach ($this->view->{$type} as $handler) {
  19. if (isset($handler->search_score) && $handler->relationship == $this->relationship) {
  20. $this->query->add_orderby(NULL, NULL, $this->options['order'], $handler->search_score);
  21. $this->table_alias = $handler->table_alias;
  22. return;
  23. }
  24. }
  25. }
  26. // Do absolutely nothing if there is no filter/argument in place; there is no reason to
  27. // sort on the raw scores with this handler.
  28. }
  29. }