You are here

function blockreference_field_settings_form in Block reference 7

Implements hook_field_settings_form().

File

./blockreference.module, line 135
Defines a field type for referencing a block from a node.

Code

function blockreference_field_settings_form($field, $instance, $has_data) {
  $settings = $field['settings'];
  $form = array();
  $regions = array(
    '' => t('Disabled'),
  );
  $referenceable_themes = blockreference_field_referenceable_themes($field);
  foreach ($referenceable_themes as $referenceable_theme) {
    $regions = $regions + system_region_list($referenceable_theme);
  }
  $form['referenceable_regions'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Regions containing blocks that can be referenced'),
    '#multiple' => TRUE,
    '#default_value' => $settings['referenceable_regions'],
    '#options' => $regions,
    '#description' => t('If no regions are selected, blocks from all regions will be available.'),
  );
  $form['referenceable_modules'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Modules defining blocks that can be referenced'),
    '#multiple' => TRUE,
    '#default_value' => $settings['referenceable_modules'],
    '#options' => blockreference_get_block_modules(),
    '#description' => t('If no modules are selected, blocks from all modules will be available.'),
  );
  $form['referenceable_operator'] = array(
    '#type' => 'radios',
    '#title' => t('Operator to use if referenceable regions and referenceable modules are selected.'),
    '#default_value' => $settings['referenceable_operator'],
    '#options' => array(
      'AND' => '<strong>AND</strong> - ' . t('Block must be both contained in a referenceable region and defined by a referenceable module.'),
      'OR' => '<strong>OR</strong> - ' . t('Block must be either contained in a referenceable region or defined by a referenceable module.'),
    ),
    '#description' => t('If regions and modules are selected, choose operator to use when retrieving blocks list.'),
  );
  $form['respect_visibility'] = array(
    '#type' => 'checkbox',
    '#title' => t('Respect block visibility settings'),
    '#default_value' => $settings['respect_visibility'],
    '#description' => t('Allows the block module to remove the block if it is restricted by visibility settings.'),
  );
  $themes = list_themes();
  $current_theme = $themes[variable_get('theme_default', 'bartik')]->info['name'];
  $admin_theme = $themes[variable_get('admin_theme', 'seven')]->info['name'];
  $form['referenceable_theme'] = array(
    '#type' => 'radios',
    '#title' => t('Themes that can provide blocks for selection.'),
    '#default_value' => $settings['referenceable_theme'],
    '#options' => array(
      'default' => t('Default theme (%theme) only.', array(
        '%theme' => $current_theme,
      )),
      'all' => t('All themes.'),
      'not_admin' => t('All themes except admin theme (%theme).', array(
        '%theme' => $admin_theme,
      )),
    ),
  );
  return $form;
}