function clean_markup_blocks_form_alter in Clean Markup 7
Same name and namespace in other branches
- 7.3 modules/clean_markup_blocks/clean_markup_blocks.module \clean_markup_blocks_form_alter()
- 7.2 modules/clean_markup_blocks/clean_markup_blocks.module \clean_markup_blocks_form_alter()
Implements hook_form_alter().
File
- modules/
clean_markup_blocks/ clean_markup_blocks.module, line 30 - Provides clean block markup.
Code
function clean_markup_blocks_form_alter(&$form, &$form_state, $form_id) {
if ($form_id === 'block_admin_configure' || $form_id == 'block_add_block_form') {
if (user_access('administer clean markup block settings')) {
// Load defaults.
$defaults = variable_get('clean_markup_blocks-defaults');
$wrapper_elements = _clean_markup_get_html_wrapper_elements();
$optional_wrapper_elements = _clean_markup_get_html_wrapper_elements(TRUE);
// Get settings for this block.
$variable_name = _clean_markup_blocks_generate_prefix($form['module']['#value'], $form['delta']['#value']);
$this_block_settings = variable_get($variable_name, $defaults);
// Set our own submit handler so we can save the settings in our custom
// part of the form.
$form['#submit'][] = '_clean_markup_blocks_block_configure_submit';
// Create our custom part of the form.
$form['clean_markup'] = array(
'#type' => 'fieldset',
'#title' => t('Clean markup options'),
'#group' => 'visibility',
);
// Controls for block markup.
$form['clean_markup']['block_wrapper'] = array(
'#type' => 'select',
'#title' => t('Block wrapper markup'),
'#description' => t('Choose the HTML element to wrap the block.'),
'#default_value' => $this_block_settings['block_wrapper'],
'#options' => $optional_wrapper_elements,
);
$form['clean_markup']['enable_inner_div'] = array(
'#type' => 'checkbox',
'#title' => t('Enable inner div'),
'#description' => t('Specify if you want an inner div element inside the main block wrapper.'),
'#default_value' => $this_block_settings['enable_inner_div'],
'#states' => array(
'invisible' => array(
':input[name="block_wrapper"]' => array(
'value' => CLEAN_MARKUP_BLOCK_NO_ELEMENT,
),
),
),
);
$form['clean_markup']['additional_block_classes'] = array(
'#type' => 'textfield',
'#title' => t('Additional block classes'),
'#description' => t('Additional classes to set on the block wrapper.'),
'#default_value' => $this_block_settings['additional_block_classes'],
);
$form['clean_markup']['block_html_id_as_class'] = array(
'#type' => 'checkbox',
'#title' => t("Output block's HTML ID as class"),
'#default_value' => $this_block_settings['block_html_id_as_class'],
);
// Controls for title markup.
$form['clean_markup']['title_wrapper'] = array(
'#type' => 'select',
'#title' => t('Title wrapper markup'),
'#description' => t('Choose the HTML to use to wrap the block title.'),
'#default_value' => $this_block_settings['title_wrapper'],
'#options' => $wrapper_elements,
);
$form['clean_markup']['title_hide'] = array(
'#type' => 'checkbox',
'#title' => t('Visually-hide block title'),
'#description' => t('Add the <code>element-invisible</code> CSS class to the block title. This hides it visually but leaves it visible to screenreaders.'),
'#default_value' => $this_block_settings['title_hide'],
);
// Controls for content markup.
$form['clean_markup']['content_wrapper'] = array(
'#type' => 'select',
'#title' => t('Content wrapper markup'),
'#description' => t('Choose the HTML to use to wrap the block content.'),
'#default_value' => $this_block_settings['content_wrapper'],
'#options' => $optional_wrapper_elements,
);
}
}
}