You are here

function _file_entity_rankings in File Entity (fieldable files) 7.3

Same name and namespace in other branches
  1. 7.2 file_entity.module \_file_entity_rankings()

Gather the rankings from the the hook_ranking implementations.

Parameters

$query: A query object that has been extended with the Search DB Extender.

1 call to _file_entity_rankings()
file_entity_search_execute in ./file_entity.module
Implements hook_search_execute().

File

./file_entity.module, line 510
Extends Drupal file entities to be fieldable and viewable.

Code

function _file_entity_rankings(SelectQueryExtender $query) {
  if ($ranking = module_invoke_all('file_ranking')) {
    $tables =& $query
      ->getTables();
    foreach ($ranking as $rank => $values) {
      if ($file_rank = variable_get('file_entity_rank_' . $rank, 0)) {

        // If the table defined in the ranking isn't already joined, then add it.
        if (isset($values['join']) && !isset($tables[$values['join']['alias']])) {
          $query
            ->addJoin($values['join']['type'], $values['join']['table'], $values['join']['alias'], $values['join']['on']);
        }
        $arguments = isset($values['arguments']) ? $values['arguments'] : array();
        $query
          ->addScore($values['score'], $arguments, $file_rank);
      }
    }
  }
}