| 1 |
<?php |
<?php |
| 2 |
// $Id: luceneapi_node.module,v 1.44 2009/11/16 03:26:23 cpliakas Exp $ |
// $Id: luceneapi_node.module,v 1.45 2009/11/16 03:40:47 cpliakas Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 459 |
throw new LuceneAPI_Exception(t('Error loading node.')); |
throw new LuceneAPI_Exception(t('Error loading node.')); |
| 460 |
} |
} |
| 461 |
|
|
| 462 |
// gets the contents of the node from the database |
$node = node_load($nid); |
| 463 |
$node->build_mode = NODE_BUILD_SEARCH_RESULT; |
$build = node_build($node, 'search_result'); |
| 464 |
$node = node_build_content($node, FALSE, FALSE); |
unset($build['#theme']); |
| 465 |
$node->body = drupal_render($node->content); |
$node->rendered = drupal_render($build); |
| 466 |
|
|
| 467 |
// fetch comments, taxonomy terms for snippet |
$node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node); |
| 468 |
$node->body .= module_invoke('comment', 'nodeapi', $node, 'update index'); |
$node->rendered .= ' ' . module_invoke('taxonomy', 'node_update_index', $node); |
| 469 |
$node->body .= module_invoke('taxonomy', 'nodeapi', $node, 'update index'); |
$extra = module_invoke_all('node_search_result', $node); |
| 470 |
|
|
| 471 |
// returns standard result item array |
// returns standard result item array |
| 472 |
$result = array( |
$result = array( |
| 473 |
'link' => url('node/'. $node->nid, array('absolute' => TRUE)), |
'link' => url('node/' . $nid, array('absolute' => TRUE)), |
| 474 |
'type' => node_get_types('name', $node), |
'type' => check_plain(node_type_get_name($node)), |
| 475 |
'title' => $node->title, |
'title' => $node->title[FIELD_LANGUAGE_NONE][0]['value'], |
| 476 |
'user' => theme('username', $node), |
'user' => theme('username', array('account' => $node)), |
| 477 |
'date' => $node->changed, |
'date' => $node->changed, |
| 478 |
'node' => $node, |
'node' => $node, |
| 479 |
'extra' => node_invoke_nodeapi($node, 'search result'), |
'extra' => $extra, |
| 480 |
'score' => $hit->score, |
'score' => $hit->score, |
| 481 |
'snippet' => luceneapi_excerpt($positive_keys, $node->body), |
'snippet' => luceneapi_excerpt($positive_keys, $node->body), |
| 482 |
); |
); |
| 491 |
} |
} |
| 492 |
|
|
| 493 |
// allows modules to alter the item's result array, adds to results |
// allows modules to alter the item's result array, adds to results |
| 494 |
drupal_alter('luceneapi_result', $result, 'luceneapi_node', 'node'); |
//drupal_alter('luceneapi_result', $result, 'luceneapi_node', 'node'); |
| 495 |
$results[] = $result; |
$results[] = $result; |
| 496 |
} |
} |
| 497 |
|
|
| 958 |
if (isset($items['type'])) { |
if (isset($items['type'])) { |
| 959 |
|
|
| 960 |
// gets content type minus the excluded ones |
// gets content type minus the excluded ones |
| 961 |
$types = array_map('check_plain', node_get_types('names')); |
$types = array_map('check_plain', node_type_get_types()); |
| 962 |
foreach (luceneapi_node_excluded_types_get() as $excluded) { |
foreach (luceneapi_node_excluded_types_get() as $excluded) { |
| 963 |
unset($types[$excluded]); |
unset($types[$excluded]); |
| 964 |
} |
} |