function fuzzysearch_block in Fuzzy Search 6
Implementation of hook_block().
File
- ./
fuzzysearch.module, line 484 - Module file for fuzzysearch module.
Code
function fuzzysearch_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$blocks[0]['info'] = t('Fuzzy search form');
$blocks[1]['info'] = t('Fuzzy search title query');
return $blocks;
break;
case 'view':
if (user_access('fuzzysearch content')) {
switch ($delta) {
case 0:
$block['content'] = drupal_get_form('fuzzysearch_box_form');
$block['subject'] = t('Search');
return $block;
break;
case 1:
if ($_GET['fuzzysearch']) {
$block['content'] = theme('fuzzysearch_show_results', check_plain($_GET['fuzzysearch']), variable_get('fuzzysearch_block_theme', BLOCK_THEME), variable_get('fuzzysearch_block_limit', 5));
}
return $block;
break;
}
}
break;
case 'configure':
switch ($delta) {
case 1:
$form["fuzzysearch_block_limit"] = array(
'#type' => 'select',
'#title' => t('Number of results to display'),
'#default_value' => variable_get('fuzzysearch_block_limit', 5),
'#options' => drupal_map_assoc(range(1, 15)),
);
$form['fuzzysearch_block_theme'] = array(
'#type' => 'radios',
'#title' => t('Display method'),
'#default_value' => variable_get('fuzzysearch_block_theme', 0),
'#options' => array(
BLOCK_THEME => 'Titles',
NODE_THEME => 'Nodes',
),
'#description' => t('Show titles only or node theme.'),
);
return $form;
break;
}
break;
case 'save':
switch ($delta) {
case 1:
variable_set('fuzzysearch_block_limit', $edit['fuzzysearch_block_limit']);
variable_set('fuzzysearch_block_theme', $edit['fuzzysearch_block_theme']);
break;
}
}
}