SetFilter( $attribute, array($values[$x]));
- }
- }
+function _sphinx_do_search($client, $needle, $index, $sort, $limit) {
+ if (trim($sort)) {
+ $client->SetSortMode(SPH_SORT_EXTENDED, $sort);
}
$client->SetMatchMode(SPH_MATCH_EXTENDED);
if (isset($_GET['page'])) {
@@ -279,7 +263,7 @@
}
$client->AddQuery($needle, $index);
$response = $client->RunQueries();
-
+
return $response;
}
@@ -300,7 +284,8 @@
$output = '';
$output .= theme_sphinx_feedback($results, $needle);
if ($results['total_found'] > 0) {
- $lines = array();
+ //TODO: Use theme item-list
+ $output .= '';
foreach ($results['matches'] as $k => $v) {
$node = node_load($k);
if ($node->nid) {
@@ -308,17 +293,16 @@
$fields = _sphinx_excerpt_fields($index);
//$content = _sphinx_excerpt_content($index, $node);
//TODO: need to figure out how db-fields are translated to arrays in order to retrieve the relevant fields
- $excerpt = $client->BuildExcerpts(array($node->title, $node->field_brdtekst), $index, $needle, $opts = array());
- //print_r($fields);
- $lines[] = theme_sphinx_result($node, $excerpt, $fields);
+ $excerpt = $client->BuildExcerpts(array($node->title, $node->body), $index, $needle, $opts = array());
+ $output .= theme_sphinx_result($node, $excerpt, $fields);
}
else {
- $lines[] = theme_sphinx_result($node);
+ $output .= theme_sphinx_result($node);
}
}
}
}
- $output = theme('item_list', $lines);
+ $output .= '
';
return $output;
}
@@ -326,7 +310,7 @@
$output = '';
$output .= '';
$output .= $results['total_found'] .' ';
- $output .= ($results['total_found'] == 1) ? t('result') : t('results');
+ $output .= ($results['total_found'] == 1) ? t('result') : t('results');
$output .= ' '. t('for');
$output .= ' '. $needle .' ('. $results['time'] .' '. t('secs.') .')';
$output .= '
';
@@ -372,8 +356,7 @@
* @see sphinx_search_form_validate()
* @see sphinx_search_form_submit()
*/
-function sphinx_search_form($iid, $needle) {
-
+function sphinx_search_form($form_id, $iid, $needle) {
$sql = 'SELECT * FROM {sphinx_indexes} WHERE iid=%d AND active=1';
$result = db_query($sql, $iid);
$index = db_fetch_object($result);
@@ -404,19 +387,19 @@
'#collapsed' => ($_GET['as'] == 1) ? false : true,
'#weight' => -6,
);
-
+
$sql = 'SELECT aid, attribute_name, display_name FROM {sphinx_attributes} WHERE iid=%d AND active=1';
$result = db_query($sql, $iid);
$options = array(0 => '');
while ($attributes = db_fetch_object($result)) {
-
+
$options[$attributes->aid] = $attributes->display_name;
}
$sql = 'SELECT fid, field_name, display_name FROM {sphinx_fields} WHERE iid=%d AND active=1 ORDER BY weight';
$result = db_query($sql, $iid);
- $count = -40;
+ $count = -40;
while ($fields = db_fetch_object($result)) {
-
+
$form['sphinx_search']['advanced']['field'][$fields->field_name] = array(
'#title' => $fields->display_name,
'#type' => 'textfield',
@@ -441,45 +424,45 @@
'#default_value' => (!empty($_GET['as_sd'])) ? $_GET['as_sd'] : '',
'#weight' => 60,
);
-
+
$form['sphinx_search']['submit'] = array('#type' => 'submit', '#value' => t('Search'), '#weight' => 2,);
-
-
+
+
return $form;
}
-function sphinx_search_form_validate($form_id, $form_values) {
- $search = $form_values['searchstring'];
+function sphinx_search_form_validate($form_id, &$form_state) {
+ $search = $form_state['values']['searchstring'];
$sql = 'SELECT fid,field_name FROM {sphinx_fields} WHERE iid=%d AND active=1 ORDER BY weight DESC';
- $res = db_query($sql, $form_values['iid']);
+ $res = db_query($sql, $form_state['values']['iid']);
while ($fields = db_fetch_object($res)) {
- $field = $form_values[$fields->field_name];
+ $field = $form_state['values'][$fields->field_name];
if (!empty($field)) {
$search .= $field;
}
}
if (empty($search)) {
- form_set_error($form_values['searchstring'], t('You must enter a search string'));
+ form_set_error($form_state['values']['searchstring'], t('You must enter a search string'));
}
}
-function sphinx_search_form_submit($form_id, $form_values) {
- $query = _sphinx_build_advanced_query($form_values);
- drupal_goto('search/'. $form_values['index_path'] .'/'. $form_values['searchstring'], $query);
+function sphinx_search_form_submit($form_id, &$form_state) {
+ $query = _sphinx_build_advanced_query($form_state['values']);
+ drupal_goto('search/'. $form_state['values']['index_path'] .'/'. $form_state['values']['searchstring'], $query);
}
-function _sphinx_build_advanced_query($form_values) {
+function _sphinx_build_advanced_query($form_state) {
$output = '';
$sql = 'SELECT fid,field_name FROM {sphinx_fields} WHERE iid=%d AND active=1 ORDER BY weight DESC';
- $res = db_query($sql, $form_values['iid']);
+ $res = db_query($sql, $form_state['values']['iid']);
while ($fields = db_fetch_object($res)) {
- $field = $form_values[$fields->field_name];
+ $field = $form_state['values'][$fields->field_name];
if (!empty($field)) {
$output .= 'as_f'. $fields->fid .'='. $field .'&';
}
}
- if ($form_values['sort_key']) {
- $output .= 'as_sk='. $form_values['sort_key'] .'&as_sd='. $form_values['sort_direction'] .'&';
+ if ($form_state['values']['sort_key']) {
+ $output .= 'as_sk='. $form_state['values']['sort_key'] .'&as_sd='. $form_state['values']['sort_direction'] .'&';
}
if (!empty($output)) {
return 'as=1&'. substr($output, 0, -1);
diff -Nur /tmp/sphinx/sphinx_suggestion.info sphinx/sphinx_suggestion.info
--- /tmp/sphinx/sphinx_suggestion.info 2008-09-25 23:35:23.000000000 +0400
+++ sphinx/sphinx_suggestion.info 2008-09-29 22:18:57.383809191 +0400
@@ -1,10 +1,8 @@
-; $Id: sphinx_suggestion.info,v 1.1.2.1 2008/09/25 19:26:19 johsw Exp $
-name = Sphinx suggestion module
+; $Id$
+name = "Sphinx suggestion module"
description = "This module provides search term suggestions"
package = "Search"
-version = "0.01"
-; Information added by drupal.org packaging script on 2008-09-25
-version = "5.x-1.1"
-project = "sphinx"
-datestamp = "1222371323"
+version = "6.x-1.0-dev"
+core = "6.x"
+dependencies[] = sphinx
diff -Nur /tmp/sphinx/sphinx_suggestion.install sphinx/sphinx_suggestion.install
--- /tmp/sphinx/sphinx_suggestion.install 2008-08-21 16:14:27.000000000 +0400
+++ sphinx/sphinx_suggestion.install 2008-09-24 12:56:00.457760588 +0400
@@ -2,10 +2,10 @@
function sphinx_suggestion_requirements($phase) {
$t = get_t();
- $pspell = function_exists('pspell_suggest');
- $requirements['pspell'] = array(
+ $pspell = function_exists('pspell_suggest');
+ $requirements['pspell'] = array(
'title' => $t('PSPELL'),
- 'value' => $pspell ? 'pspell installed correctly' : 'pspell not installed ('.l('http://www.php.net/manual/en/pspell.installation.php', 'http://www.php.net/manual/en/pspell.installation.php').')',
+ 'value' => $pspell ? 'pspell installed correctly' : 'pspell not installed ('.l('http://www.php.net/manual/en/pspell.installation.php', 'http://www.php.net/manual/en/pspell.installation.php').')',
'severity' => $pspell ? REQUIREMENT_OK : REQUIREMENT_ERROR,
);
return $requirements;
diff -Nur /tmp/sphinx/sphinx_suggestion.module sphinx/sphinx_suggestion.module
--- /tmp/sphinx/sphinx_suggestion.module 2008-09-25 23:26:19.000000000 +0400
+++ sphinx/sphinx_suggestion.module 2008-09-29 22:16:59.906771482 +0400
@@ -1,10 +1,9 @@
'admin/settings/sphinx/suggestions',
+ $items['admin/settings/sphinx/suggestions'] = array(
'title' => t('Suggestions'),
'description' => t('Configure the Sphinx suggestions'),
'callback' => 'drupal_get_form',
@@ -112,11 +111,11 @@
return system_settings_form($form);
}
-function sphinx_suggestion_administration_validate($form_id, $form_values) {}
+function sphinx_suggestion_administration_validate($form_id, &$form_state) {}
-function sphinx_suggestion_administration_submit($form_id, $form_values) {
- variable_set('sphinx_suggestion_default_language', $form_values['language']);
- variable_set('sphinx_suggestion_default_spelling', $form_values['spelling']);
+function sphinx_suggestion_administration_submit($form_id, &$form_state) {
+ variable_set('sphinx_suggestion_default_language', $form_state['values']['language']);
+ variable_set('sphinx_suggestion_default_spelling', $form_state['values']['spelling']);
drupal_set_message(t('Language settings updated!'));
}