function ddblock_block_configure in Dynamic display block 6
Same name and namespace in other branches
- 7 ddblock.module \ddblock_block_configure()
Block configuration page of dynamic display block blocks added to standard block configuration page.
Parameters
$delta: Blocknumber of the block.
Return value
form with configuration settings.
1 call to ddblock_block_configure()
- ddblock_block in ./
ddblock.module - Implementation of hook_block().
File
- ./
ddblock.module, line 216 - Enables your site to display dynamic content in a block.
Code
function ddblock_block_configure($delta) {
// get saved or default configuration settings.
$configuration_settings = ddblock_get_configuration_settings('ddblock', $delta);
$container = _ddblock_get_variable($configuration_settings, 'container', 'img');
$content_type = _ddblock_get_variable($configuration_settings, 'content_type', 'none');
$custom_jquery = _ddblock_get_variable($configuration_settings, 'custom_jquery', '');
// get folder relative to the drupal folder settings
$folder = _ddblock_get_variable($configuration_settings, 'folder', 'images/ddblock');
$fx = _ddblock_get_variable($configuration_settings, 'fx', "fade");
$height = _ddblock_get_variable($configuration_settings, 'height', 195);
$ignore_files = _ddblock_get_variable($configuration_settings, 'ignore_files', '');
$image_height = _ddblock_get_variable($configuration_settings, 'image_height', 183);
$image_width = _ddblock_get_variable($configuration_settings, 'image_width', 183);
$imgcache_toggle = _ddblock_get_variable($configuration_settings, 'imgcache_toggle', 0);
$imgcache_slide = _ddblock_get_variable($configuration_settings, 'imgcache_slide', '<none>');
$imgcache_pager_item = _ddblock_get_variable($configuration_settings, 'imgcache_pager_item', '<none>');
$input_type = _ddblock_get_variable($configuration_settings, 'input_type', 'images');
$max_image = _ddblock_get_variable($configuration_settings, 'max_image', 5);
$next = _ddblock_get_variable($configuration_settings, 'next', 0);
$nodes = _ddblock_get_variable($configuration_settings, 'nodes', '');
$node_body_teaser = _ddblock_get_variable($configuration_settings, 'node_body_teaser', 'body');
$order = _ddblock_get_variable($configuration_settings, 'order', 'asc');
$overflow = _ddblock_get_variable($configuration_settings, 'overflow', 1);
$pause = _ddblock_get_variable($configuration_settings, 'pause', 1);
$pager_toggle = _ddblock_get_variable($configuration_settings, 'pager_toggle', 0);
$pager = _ddblock_get_variable($configuration_settings, 'pager', 'none');
$pager_prev_next_loop = _ddblock_get_variable($configuration_settings, 'pager_prev_next_loop', 1);
$pager_scrollable_loop = _ddblock_get_variable($configuration_settings, 'pager_scrollable_loop', 1);
$nr_of_pager_items = _ddblock_get_variable($configuration_settings, 'nr_of_pager_items', 4);
$pager_event = _ddblock_get_variable($configuration_settings, 'pager_event', 'click');
$pager_disable_click = _ddblock_get_variable($configuration_settings, 'pager_disable_click', 1);
$pager_fast = _ddblock_get_variable($configuration_settings, 'pager_fast', 1);
$pager_pause = _ddblock_get_variable($configuration_settings, 'pager_pause', 1);
if ($pager == 'number-pager' || $pager == 'prev-next-pager') {
$pager_height = _ddblock_get_variable($configuration_settings, 'pager_height', 25);
$pager_width = _ddblock_get_variable($configuration_settings, 'pager_width', 195);
}
else {
$pager_height = _ddblock_get_variable($configuration_settings, 'pager_height', 63);
$pager_width = _ddblock_get_variable($configuration_settings, 'pager_width', 195);
}
$speed = _ddblock_get_variable($configuration_settings, 'speed', 500);
$timeout = _ddblock_get_variable($configuration_settings, 'timeout', 5000);
$width = _ddblock_get_variable($configuration_settings, 'width', 195);
// get module path to dynamic display block module
$ddblock_path = drupal_get_path('module', 'ddblock');
// add ddblock js file
drupal_add_js($ddblock_path . '/js/ddblock.admin.js', 'module');
// Need this for AJAX.
$form['#cache'] = TRUE;
// content settings: what to use as content for the dynamic display block.
$form['content'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#title' => t('Content settings'),
'#prefix' => '<div id="ddblock-content-settings">',
'#suffix' => '</div>',
'#weight' => -3,
);
$options = array(
'images' => t('Image folder'),
'nodes' => t('Content type'),
);
$form['content']['input_type'] = array(
'#type' => 'select',
'#title' => t('Input type'),
'#default_value' => $input_type,
'#options' => $options,
'#multiple' => FALSE,
'#required' => TRUE,
'#description' => t("Input of the dynamic display block."),
'#weight' => -7,
);
// image folder settings.
$form['content']['image_folder'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#title' => t('Image folder settings'),
'#prefix' => '<div id="ddblock-image-folder-settings-wrapper">',
'#suffix' => '</div>',
'#weight' => -6,
);
$form['content']['image_folder']['folder'] = array(
'#type' => 'textfield',
'#title' => t('Image Folder'),
'#default_value' => $folder,
'#size' => 25,
'#maxlength' => 100,
'#required' => FALSE,
'#description' => t("The folder containing image files to be used as the content of dynamic display block. The folder is relative to the drupal files path in admin > settings > file-system. e.g. <strong>images/ddblock</strong>."),
);
$form['content']['image_folder']['ignore_files'] = array(
'#type' => 'textfield',
'#title' => t('Ignore files'),
'#default_value' => $ignore_files,
'#required' => FALSE,
'#description' => t("Ignore these files to be shown. e.g. ignore file with _thumbnail, _preview in the file_name.<br />\n You can use a comma seprated list"),
);
$form['content']['image_folder']['max_image'] = array(
'#type' => 'textfield',
'#title' => t('Number of images'),
'#default_value' => $max_image,
'#required' => FALSE,
'#description' => t("The number of images to show in the block."),
);
// content type settings.
$form['content']['content_types'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#title' => t('Content type settings'),
'#prefix' => '<div id="ddblock-content-types-settings-wrapper">',
'#suffix' => '</div>',
'#weight' => -5,
);
//get possible content types from settings.
$node_types = variable_get('ddblock_node_type', array());
foreach ($node_types as $key => $value) {
if ($value) {
$content_types[$key] = $value;
}
}
// add a none option to the content types to choose from.
$content_types['none'] = t("None");
$form['content']['content_types']['content_type'] = array(
'#type' => 'select',
'#title' => t('Content Type'),
'#default_value' => $content_type,
'#options' => $content_types,
'#description' => t("The nodes of the content type to be used as content of dynamic display block."),
'#attributes' => array(
'class' => 'content-type-select',
),
'#ahah' => array(
'path' => 'ddblock/js/select_nodes',
'wrapper' => 'select-nodes-wrapper',
'effect' => 'slide',
),
);
ddblock_select_nodes_form($form, $content_type, $nodes);
$options = array(
'body' => t('Body'),
'teaser' => t('Teaser'),
);
$form['content']['content_types']['node_body_teaser'] = array(
'#type' => 'radios',
'#title' => t('Node content'),
'#default_value' => $node_body_teaser,
'#options' => $options,
'#multiple' => FALSE,
'#required' => TRUE,
'#description' => t("Show node body or teaser"),
);
// if image cache module exist make it possible to use image cache presets
if (module_exists('imagecache') && is_array(imagecache_presets())) {
$imgcache_options = array(
'<none>' => '<none>',
);
// get imagecache presets using imagecache function
foreach (imagecache_presets() as $preset) {
$name = $preset['presetname'];
$imgcache_options[$name] = $name;
}
$imgcache_slide_desc = t("Imagecache preset to use for slide image");
$imgcache_pager_item_desc = t("Imagecache preset to use for pager-item image. Only for themes that use an image in the pager");
// Image cache toggle
$form['block_settings']['imgcache_toggle'] = array(
'#type' => 'checkbox',
'#title' => t('Use imagecache presets'),
'#default_value' => $imgcache_toggle,
'#required' => FALSE,
'#description' => t("Use imagecache presets for images"),
'#weight' => -5,
);
// Image cache settings.
$form['block_settings']['imgcache'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#title' => t('Image cache preset settings'),
'#prefix' => '<div id="ddblock-imgcache-settings-wrapper"' . $extra . '>',
'#suffix' => '</div>',
'#weight' => -4,
);
$form['block_settings']['imgcache']['imgcache_slide'] = array(
'#type' => 'select',
'#title' => t('Imagecache slide image'),
'#default_value' => $imgcache_slide,
'#options' => $imgcache_options,
'#multiple' => FALSE,
'#required' => FALSE,
'#description' => $imgcache_slide_desc,
'#weight' => 1,
);
$form['block_settings']['imgcache']['imgcache_pager_item'] = array(
'#type' => 'select',
'#title' => t('Imagecache pager-item image'),
'#default_value' => $imgcache_pager_item,
'#options' => $imgcache_options,
'#multiple' => FALSE,
'#required' => FALSE,
'#description' => $imgcache_pager_item_desc,
'#weight' => 2,
);
}
// content container settings.
$form['content']['content_container'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#title' => t('Content container settings'),
'#weight' => -4,
);
$form['content']['content_container']['container'] = array(
'#type' => 'textfield',
'#title' => t('Content container'),
'#default_value' => $container,
'#required' => FALSE,
'#description' => t("Container of the content to show, eg. img, to show images."),
);
$form['content']['content_container']['overflow'] = array(
'#type' => 'checkbox',
'#title' => t('Overflow hidden'),
'#default_value' => $overflow,
'#required' => FALSE,
'#description' => t("Hide the overflow of the container"),
);
$form['content']['content_container']['height'] = array(
'#type' => 'textfield',
'#title' => t('Height'),
'#default_value' => $height,
'#required' => FALSE,
'#description' => t("Height of the content to show"),
);
$form['content']['content_container']['width'] = array(
'#type' => 'textfield',
'#title' => t('Width'),
'#default_value' => $width,
'#required' => FALSE,
'#description' => t("Width of the content to show"),
);
// Image settings.
$form['content']['images'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#title' => t('Image settings'),
'#description' => t('Set to 0 (zero) for both the height and the width to be able to use the original image size or imagecache presets'),
'#weight' => -3,
);
$form['content']['images']['image_height'] = array(
'#type' => 'textfield',
'#title' => t('Height'),
'#default_value' => $image_height,
'#required' => FALSE,
'#description' => t("Height of the image to show"),
);
$form['content']['images']['image_width'] = array(
'#type' => 'textfield',
'#title' => t('Width'),
'#default_value' => $image_width,
'#required' => FALSE,
'#description' => t("Width of the image to show"),
);
//wrapper for ddblock block settings
$form['block_settings']['#prefix'] = '<div id="ddblock-block-settings">';
$form['block_settings']['#suffix'] = '</div>';
$form['block_settings']['settings'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#title' => t('Settings'),
'#weight' => -2,
);
$options = _ddblock_get_effects();
$form['block_settings']['settings']['fx'] = array(
'#type' => 'select',
'#title' => t('Transition Effect'),
'#default_value' => $fx,
'#options' => $options,
'#multiple' => FALSE,
'#required' => TRUE,
'#description' => t("The transition effect between content.<br />(all for random effect per slide, none for no effect)<br />Multiple effects can be set in the Custom jQuery Cycle Plugin Settings."),
);
$options = drupal_map_assoc(array(
0,
250,
500,
1000,
2000,
3000,
4000,
5000,
6000,
7000,
8000,
9000,
10000,
15000,
20000,
));
$form['block_settings']['settings']['speed'] = array(
'#type' => 'select',
'#title' => t('Speed'),
'#default_value' => $speed,
'#options' => $options,
'#required' => TRUE,
'#description' => t("Speed of the transitions (1000 = 1 second, 0 = direct)."),
);
$options = drupal_map_assoc(array(
0,
250,
500,
1000,
2000,
3000,
4000,
5000,
6000,
7000,
8000,
9000,
10000,
15000,
20000,
30000,
));
$form['block_settings']['settings']['timeout'] = array(
'#type' => 'select',
'#title' => t('Timeout'),
'#default_value' => $timeout,
'#options' => $options,
'#required' => TRUE,
'#description' => t("The time (in milliseconds) between transitions (1000 = 1 second, 0 to disable auto advance)."),
);
$options = array(
'none' => t('None'),
'asc' => t('Ascending'),
'desc' => t('Descending'),
'random' => t('Random'),
);
$form['block_settings']['settings']['order'] = array(
'#type' => 'radios',
'#title' => t('Sort Order'),
'#default_value' => $order,
'#options' => $options,
'#multiple' => FALSE,
'#required' => TRUE,
'#description' => t("The display order of the content. None for using the original content order."),
);
$form['block_settings']['settings']['pause'] = array(
'#type' => 'checkbox',
'#title' => t('Pause'),
'#default_value' => $pause,
'#description' => t("Enable users to pause the cycle by hovering on the content."),
);
$form['block_settings']['settings']['next'] = array(
'#type' => 'checkbox',
'#title' => t('Next'),
'#default_value' => $next,
'#description' => t("Enable users to advanced to the next content by clicking on the content."),
);
// pager settings toggle
$form['block_settings']['settings']['pager_toggle'] = array(
'#type' => 'checkbox',
'#title' => t('Use Pager'),
'#default_value' => $pager_toggle,
'#required' => FALSE,
'#description' => t("Use a pager to select slides"),
);
// pager settings.
// show fields when using pager
$extra = empty($pager_toggle) ? ' style="display:none"' : '';
$form['block_settings']['settings']['pager_settings'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#prefix' => '<div id="ddblock-pager-settings-wrapper"' . $extra . '>',
'#suffix' => '</div>',
'#title' => t('Pager settings'),
);
if ($input_type == 'images') {
$options = array(
'none' => t('None'),
'number-pager' => t('Number pager'),
'prev-next-pager' => t('Prev next pager'),
'image-pager' => t('Image pager'),
);
}
else {
$options = array(
'none' => t('None'),
'number-pager' => t('Number Pager'),
'prev-next-pager' => t('Prev next pager'),
);
}
$form['block_settings']['settings']['pager_settings']['pager'] = array(
'#type' => 'select',
'#title' => t('Pager'),
'#default_value' => $pager,
'#options' => $options,
'#required' => TRUE,
'#description' => t("Add a pager to the block."),
);
$options = array(
'click' => t('Click'),
'mouseover' => t('Mouseover'),
);
$form['block_settings']['settings']['pager_settings']['pager_event'] = array(
'#type' => 'select',
'#title' => t('Pager event'),
'#default_value' => $pager_event,
'#options' => $options,
'#required' => FALSE,
'#description' => t("The event on which the pager reacts."),
);
$form['block_settings']['settings']['pager_settings']['pager_height'] = array(
'#type' => 'textfield',
'#title' => t('Height'),
'#default_value' => $pager_height,
'#required' => FALSE,
'#description' => t("Height of the pager"),
);
$form['block_settings']['settings']['pager_settings']['pager_width'] = array(
'#type' => 'textfield',
'#title' => t('Width'),
'#default_value' => $pager_width,
'#required' => FALSE,
'#description' => t("Width of the pager"),
);
$form['block_settings']['settings']['pager_settings']['pager_fast'] = array(
'#type' => 'checkbox',
'#title' => t('Fast Pager'),
'#default_value' => $pager_fast,
'#required' => FALSE,
'#description' => t("Use fast pager event when clicked or hovered."),
);
$form['block_settings']['settings']['pager_settings']['pager_pause'] = array(
'#type' => 'checkbox',
'#title' => t('Pager pause'),
'#default_value' => $pager_pause,
'#required' => FALSE,
'#description' => t("Pause the slideshow when pager hovered."),
);
// collapsed or not collapsed depending on value for custom settings.
if ($custom_jquery) {
$collapsed = FALSE;
}
else {
$collapsed = TRUE;
}
$form['block_settings']['settings']['custom'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => $collapsed,
'#title' => t('Custom jQuery Cycle Plugin Settings'),
'#weight' => 1,
'#description' => t('If you use custom jQuery options, they will override your other settings.'),
);
$form['block_settings']['settings']['custom']['custom_jquery'] = array(
'#type' => 'textarea',
'#title' => t('Custom Options'),
'#default_value' => $custom_jquery,
'#cols' => 60,
'#rows' => 10,
'#required' => FALSE,
'#description' => t('Use valid JSON syntax, with double quotes for key/and string value pairs.<br />The total script needs to be enclosed in curly brackets.<br />No comma allowed after the last statement like in an array.<br />e.g.<br />{"fx":"fade",<br />"startingSlide":2,<br />"autostop":1}'),
);
$form['#redirect'] = 'admin/settings/ddblock/list';
return $form;
}