You are here

function ddblock_settings_form in Dynamic display block 7

Same name and namespace in other branches
  1. 6 ddblock.admin.inc \ddblock_settings_form()

Dynamic display block settings form for setting the content types to be used with the dynamic display block module.

1 string reference to 'ddblock_settings_form'
ddblock_menu in ./ddblock.module
Implements hook_menu().

File

./ddblock.admin.inc, line 293
admin blocks of the ddblock module.

Code

function ddblock_settings_form($form, &$form_state) {
  $form = array();

  // get a list of all available content types,  names parameter is used to get an associative array of content type names.
  // the key is the machine-readable name of the content type and the value the human-readable name of the content type.
  $content_types = node_type_get_names();
  $form['ddblock_node_type'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Content types'),
    '#description' => t('The content type(s) that can be used with the dynamic display block module.'),
    '#default_value' => variable_get('ddblock_node_type', array()),
    '#options' => $content_types,
    '#multiple' => TRUE,
    '#required' => FALSE,
  );

  // Fetch blocks directly from modules using block.module function.
  $blocks = _block_rehash();

  // Sort blocks how we want them.
  usort($blocks, 'ddblock_block_sort');

  // Turn $blocks into form options of available blocks.
  $options = array();
  foreach ($blocks as $block) {

    // Don't include ddblock module blocks in the list.
    if ($block['module'] != 'ddblock') {
      $options[$block['module'] . ':' . $block['delta'] . ':' . $block['info']] = $block['module'] . ' - ' . $block['info'];
    }
  }
  $form['ddblock_blocks'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Blocks'),
    '#description' => t('The block(s) that can be used with the dynamic display block module.'),
    '#default_value' => variable_get('ddblock_blocks', array()),
    '#options' => $options,
    '#multiple' => TRUE,
    '#required' => FALSE,
  );
  $form_state['redirect'] = 'admin/structure/ddblock/list';
  return system_settings_form($form);
}