| 1 |
<?php |
<?php |
|
|
|
| 2 |
/** |
/** |
| 3 |
* Swish-E Module Includes |
* Swish-E Module Includes |
| 4 |
*/ |
*/ |
| 16 |
} |
} |
| 17 |
|
|
| 18 |
/** |
/** |
| 19 |
* Implementation of hook_nodeapi(). Updats Full Text Information on Node Update. |
* Implementation of hook_nodeapi(). Updates Full Text Information on Node Update. |
| 20 |
*/ |
*/ |
| 21 |
function swish_nodeapi(&$node, $op) { |
function swish_nodeapi(&$node, $op) { |
| 22 |
switch($op) { |
switch($op) { |
| 57 |
case 'search' : |
case 'search' : |
| 58 |
$find = array(); |
$find = array(); |
| 59 |
$swish_bin = variable_get('swish_path', '/usr/local/bin/swish-e'); |
$swish_bin = variable_get('swish_path', '/usr/local/bin/swish-e'); |
|
// Change the Swish index path depending on if its public or private files |
|
| 60 |
if (variable_get('file_downloads','1') == FILE_DOWNLOADS_PUBLIC) { |
if (variable_get('file_downloads','1') == FILE_DOWNLOADS_PUBLIC) { |
| 61 |
$swish_index = getcwd() .'/' . file_directory_path().'/'. 'my_swish_index'; |
$swish_index = getcwd() .'/' . file_directory_path().'/'. 'my_swish_index'; |
| 62 |
} else { |
} else { |
| 63 |
$swish_index = file_directory_path().'/'. 'my_swish_index'; |
$swish_index = file_directory_path().'/'. 'my_swish_index'; |
| 64 |
} |
} |
|
|
|
| 65 |
//check if swish-e binary is executable and index file is readable. |
//check if swish-e binary is executable and index file is readable. |
| 66 |
//if not, put an entry in the watchdog and just exit quitely. |
//if not, put an entry in the watchdog and just exit quitely. |
| 67 |
//we dont want to disturb the end user. |
//we dont want to disturb the end user. |
| 104 |
|
|
| 105 |
// Display a highlighted snippet of matched text |
// Display a highlighted snippet of matched text |
| 106 |
$snippet = ''; |
$snippet = ''; |
| 107 |
$text = db_result(db_query("SELECT `fulltext` from {swish_fulltext} where filepath = '%s'",variable_get('file_directory_path', 'files') . '/' . $basename)); |
$text_item = db_fetch_object(db_query("SELECT `fulltext`,nid from {swish_fulltext} where filepath = '%s'",variable_get('file_directory_path', 'files') . '/' . $basename)); |
| 108 |
$snippet = search_excerpt($keys,$text); |
$snippet = search_excerpt($keys,$text_item->fulltext); |
| 109 |
|
|
| 110 |
$find[] = array('link' => $link, 'title' => $title, 'snippet' => $snippet, 'extra' => $extra); |
$find[] = array('link' => $link, 'title' => $title, 'snippet' => $snippet, 'extra' => $extra, 'node' => node_load($text_item->nid)); |
| 111 |
} |
} |
| 112 |
} |
} |
| 113 |
|
|