_node_rankings

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 _node_rankings(SelectQueryExtender $query)

Gather the rankings from the the hook_ranking implementations.

Parameters

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

Code

modules/node/node.module, line 1554

<?php
function _node_rankings(SelectQueryExtender $query) {
  if ($ranking = module_invoke_all('ranking')) {
    $tables = &$query->getTables();
    foreach ($ranking as $rank => $values) {
      if ($node_rank = variable_get('node_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, $node_rank);
      }
    }
  }
}
?>