/[drupal]/contributions/modules/swish/swish.module
ViewVC logotype

Diff of /contributions/modules/swish/swish.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.3.2.3.2.5, Fri Mar 7 18:46:22 2008 UTC revision 1.3.2.3.2.6, Fri Mar 7 19:03:36 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
   
2  /**  /**
3  * Swish-E Module Includes  * Swish-E Module Includes
4  */  */
# Line 17  function swish_cron(){ Line 16  function swish_cron(){
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) {
# Line 58  function swish_search ($op = 'search', Line 57  function swish_search ($op = 'search',
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.
# Line 107  function swish_search ($op = 'search', Line 104  function swish_search ($op = 'search',
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    

Legend:
Removed from v.1.3.2.3.2.5  
changed lines
  Added in v.1.3.2.3.2.6

  ViewVC Help
Powered by ViewVC 1.1.2