Projet

Général

Profil

Paste
Télécharger (1,1 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / modules / search / views_handler_sort_search_score.inc @ 5d12d676

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of views_handler_sort_search_score.
6
 */
7

    
8
/**
9
 * Field handler to provide simple renderer that allows linking to a node.
10
 *
11
 * @ingroup views_sort_handlers
12
 */
13
class views_handler_sort_search_score extends views_handler_sort {
14

    
15
  /**
16
   * {@inheritdoc}
17
   */
18
  public function query() {
19
    // Check to see if the search filter/argument added 'score' to the table.
20
    // Our filter stores it as $handler->search_score -- and we also need to
21
    // check its relationship to make sure that we're using the same one or
22
    // obviously this won't work.
23
    foreach (array('filter', 'argument') as $type) {
24
      foreach ($this->view->{$type} as $handler) {
25
        if (isset($handler->search_score) && $handler->relationship == $this->relationship) {
26
          $this->query->add_orderby(NULL, NULL, $this->options['order'], $handler->search_score);
27
          $this->table_alias = $handler->table_alias;
28
          return;
29
        }
30
      }
31
    }
32

    
33
    // Do absolutely nothing if there is no filter/argument in place; there is
34
    // no reason to sort on the raw scores with this handler.
35
  }
36

    
37
}