function fuzzysearch_scoring in Fuzzy Search 6
Set factors for scores returned by modules implementing hook_search_score().
1 string reference to 'fuzzysearch_scoring'
- fuzzysearch_admin in ./
fuzzysearch.admin.inc - Build the administration settings panel.
File
- ./
fuzzysearch.admin.inc, line 239 - Admin settings and related functions
Code
function fuzzysearch_scoring() {
$form['scoring'] = array(
'#title' => t('Scoring adjustment'),
'#description' => t('Choose a multiplier for each of the score factors. Changing these settings will require all content to be reindexed.'),
'#type' => 'fieldset',
);
// Allow multipliers to range from 10 = max impact on score, to 0 = no impact on score.
$select_values = array(
10 => 10,
9 => 9,
8 => 8,
7 => 7,
6 => 6,
5 => 5,
4 => 4,
3 => 3,
2 => 2,
1 => 1,
0 => 0,
);
// Return all the score modifiers using hook_search_score
// expects each score modifier to return an array defining the title and
// description of the modifier.
$scores = module_invoke_all('fuzzysearch_score', 'settings', NULL);
if (count($scores)) {
foreach ($scores as $key => $score) {
$form_index = $score['id'];
$form['scoring'][$form_index] = array(
'#title' => $score['title'],
'#description' => $score['description'],
'#type' => 'select',
'#options' => $select_values,
'#default_value' => variable_get('fuzzysearch_scoring_' . $score['id'], 5),
);
}
$form['scoring']['submit'] = array(
'#value' => t('Update score factors'),
'#type' => 'submit',
);
return $form;
}
else {
$form['scoring']['no_modifiers'] = array(
'#value' => t('No enabled modules provide scoring multipliers.'),
);
return $form;
}
}