function custom_search_blocks_block in Custom Search 6
Implementation of hook_block() to provide additional blocks.
File
- modules/
custom_search_blocks/ custom_search_blocks.module, line 46 - Bring additional search blocks
Code
function custom_search_blocks_block($op = 'list', $delta = 0, $edit = array()) {
switch ($op) {
case 'configure':
// Basic settings.
$form = _custom_search_default_admin_form($delta);
// Content.
$form['content'] = array(
'#type' => 'fieldset',
'#title' => t('Content'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['content'] = array_merge($form['content'], _custom_search_content_admin_form($delta));
// Custom search paths
$form = array_merge($form, _custom_search_custom_paths_admin_form($delta));
// Ordering
$form = array_merge($form, _custom_search_ordering_admin_form($delta));
$form['order']['#weight'] = 50;
return $form;
break;
case 'save':
foreach ($edit as $key => $value) {
if (drupal_substr($key, 0, 20) == 'custom_search_blocks') {
variable_set($key, $value);
}
}
foreach ($edit['custom_search_blocks_' . $delta . '_order'] as $key => $data) {
variable_set('custom_search_blocks_' . $delta . '_' . $key . '_weight', $data['sort']);
variable_set('custom_search_blocks_' . $delta . '_' . $key . '_region', $data['region']);
}
// Submit image?
$directory_path = file_directory_path() . '/custom_search';
file_check_directory($directory_path, FILE_CREATE_DIRECTORY);
// Check for a new uploaded image.
if ($file = file_save_upload('custom_search_image', array(
'file_validate_is_image' => array(),
))) {
if (file_copy($file, $directory_path)) {
variable_set('custom_search_blocks_' . $delta . '_image_path', $file->filepath);
}
}
break;
case 'list':
$blocks = array();
for ($a = 1; $a <= variable_get('custom_search_blocks_number', 1); $a++) {
$blocks[$a]['info'] = "Custom Search {$a}";
$blocks[$a]['cache'] = BLOCK_NO_CACHE;
}
return $blocks;
break;
case 'view':
if (user_access('use custom search blocks')) {
$block['content'] = drupal_get_form('custom_search_blocks_form_' . $delta, $delta);
$block['subject'] = "Custom Search {$delta}";
return $block;
}
break;
}
}