function imageblock_configure_form in Image Block 6
Same name and namespace in other branches
- 7 imageblock.module \imageblock_configure_form()
1 call to imageblock_configure_form()
- imageblock_block in ./
imageblock.module - Implements hook_block().
File
- ./
imageblock.module, line 145 - imageblock.module Primarily Drupal hooks.
Code
function imageblock_configure_form(&$form, $block = NULL) {
$title = t('Image');
$description = '';
if (!empty($block['bid'])) {
$file = imageblock_get_file($block['bid']);
if (!empty($file->fid)) {
$title = t('Change Image');
$description = t('If new file is selected previous file will be deleted. This action cannot be undone.');
$form['imageblock_prev'] = array(
'#type' => 'item',
'#title' => t('Image'),
'#value' => $file->filename,
'#weight' => isset($form['body_field']['#weight']) ? $form['body_field']['#weight'] - 0.6 : 0,
);
}
}
$data = !empty($block['data']) ? unserialize($block['data']) : array();
$form['imageblock'] = array(
'#type' => 'file',
'#title' => $title,
'#description' => $description,
'#size' => 40,
'#weight' => isset($form['body_field']['#weight']) ? $form['body_field']['#weight'] - 0.5 : 0,
);
$form['imageblock_link'] = array(
'#type' => 'textfield',
'#title' => t('Link'),
'#description' => t('Leave empty for no link.'),
'#size' => 40,
'#default_value' => isset($data['imageblock_link']) ? $data['imageblock_link'] : '',
'#weight' => isset($form['body_field']['#weight']) ? $form['body_field']['#weight'] - 0.3 : 0,
);
$form['imageblock_link_target'] = array(
'#type' => 'select',
'#title' => t('Link target'),
'#description' => t('Leave empty for no link.'),
'#options' => array(
'_blank' => '_blank',
'_parent' => '_parent',
'_self' => '_self',
'_top' => '_top',
),
'#default_value' => isset($data['imageblock_link_target']) ? $data['imageblock_link_target'] : '_self',
'#weight' => isset($form['body_field']['#weight']) ? $form['body_field']['#weight'] - 0.2 : 0,
);
if (module_exists('imagecache')) {
$options = array();
foreach (imagecache_presets() as $preset) {
$options[$preset['presetname']] = $preset['presetname'];
}
if (!empty($options)) {
$form['imageblock_imagecache'] = array(
'#type' => 'select',
'#title' => t('Imagecache Preset'),
'#options' => array(
'' => t('<none>'),
) + $options,
'#default_value' => isset($data['imageblock_imagecache']) ? $data['imageblock_imagecache'] : '',
'#weight' => isset($form['body_field']['#weight']) ? $form['body_field']['#weight'] - 0.4 : 0,
);
}
}
}