| 1 |
<?php |
<?php |
| 2 |
// $Id: node.module,v 1.641.2.23 2006/12/05 13:16:52 killes Exp $ |
// $Id: node.module,v 1.641.2.24 2006/12/12 12:48:57 killes Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 662 |
$ranking = array(); |
$ranking = array(); |
| 663 |
$arguments2 = array(); |
$arguments2 = array(); |
| 664 |
$join2 = ''; |
$join2 = ''; |
| 665 |
|
$total = 0; |
| 666 |
// Used to avoid joining on node_comment_statistics twice |
// Used to avoid joining on node_comment_statistics twice |
| 667 |
$stats_join = false; |
$stats_join = false; |
| 668 |
if ($weight = (int)variable_get('node_rank_relevance', 5)) { |
if ($weight = (int)variable_get('node_rank_relevance', 5)) { |
| 669 |
// Average relevance values hover around 0.15 |
// Average relevance values hover around 0.15 |
| 670 |
$ranking[] = '%d * i.relevance'; |
$ranking[] = '%d * i.relevance'; |
| 671 |
$arguments2[] = $weight; |
$arguments2[] = $weight; |
| 672 |
|
$total += $weight; |
| 673 |
} |
} |
| 674 |
if ($weight = (int)variable_get('node_rank_recent', 5)) { |
if ($weight = (int)variable_get('node_rank_recent', 5)) { |
| 675 |
// Exponential decay with half-life of 6 months, starting at last indexed node |
// Exponential decay with half-life of 6 months, starting at last indexed node |
| 678 |
$arguments2[] = (int)variable_get('node_cron_last', 0); |
$arguments2[] = (int)variable_get('node_cron_last', 0); |
| 679 |
$join2 .= ' INNER JOIN {node} n ON n.nid = i.sid LEFT JOIN {node_comment_statistics} c ON c.nid = i.sid'; |
$join2 .= ' INNER JOIN {node} n ON n.nid = i.sid LEFT JOIN {node_comment_statistics} c ON c.nid = i.sid'; |
| 680 |
$stats_join = true; |
$stats_join = true; |
| 681 |
|
$total += $weight; |
| 682 |
} |
} |
| 683 |
if (module_exist('comment') && $weight = (int)variable_get('node_rank_comments', 5)) { |
if (module_exist('comment') && $weight = (int)variable_get('node_rank_comments', 5)) { |
| 684 |
// Inverse law that maps the highest reply count on the site to 1 and 0 to 0. |
// Inverse law that maps the highest reply count on the site to 1 and 0 to 0. |
| 689 |
if (!$stats_join) { |
if (!$stats_join) { |
| 690 |
$join2 .= ' LEFT JOIN {node_comment_statistics} c ON c.nid = i.sid'; |
$join2 .= ' LEFT JOIN {node_comment_statistics} c ON c.nid = i.sid'; |
| 691 |
} |
} |
| 692 |
|
$total += $weight; |
| 693 |
} |
} |
| 694 |
if (module_exist('statistics') && variable_get('statistics_count_content_views', 0) && |
if (module_exist('statistics') && variable_get('statistics_count_content_views', 0) && |
| 695 |
$weight = (int)variable_get('node_rank_views', 5)) { |
$weight = (int)variable_get('node_rank_views', 5)) { |
| 699 |
$arguments2[] = $weight; |
$arguments2[] = $weight; |
| 700 |
$arguments2[] = $scale; |
$arguments2[] = $scale; |
| 701 |
$join2 .= ' LEFT JOIN {node_counter} nc ON nc.nid = i.sid'; |
$join2 .= ' LEFT JOIN {node_counter} nc ON nc.nid = i.sid'; |
| 702 |
|
$total += $weight; |
| 703 |
} |
} |
| 704 |
$select2 = (count($ranking) ? implode(' + ', $ranking) : 'i.relevance') . ' AS score'; |
$select2 = (count($ranking) ? implode(' + ', $ranking) : 'i.relevance') . ' AS score'; |
| 705 |
|
|
| 734 |
'date' => $node->changed, |
'date' => $node->changed, |
| 735 |
'node' => $node, |
'node' => $node, |
| 736 |
'extra' => $extra, |
'extra' => $extra, |
| 737 |
|
'score' => $item->score / $total, |
| 738 |
'snippet' => search_excerpt($keys, $node->body)); |
'snippet' => search_excerpt($keys, $node->body)); |
| 739 |
} |
} |
| 740 |
return $results; |
return $results; |