function _regionclass_augment_blockgroup_edit_form in Region Class 7
Inject regionclass settings into blockgroup block edit form.
2 calls to _regionclass_augment_blockgroup_edit_form()
- regionclass_form_blockgroup_add_form_alter in ./
regionclass.module - Implements hook_form_FORM_ID_alter().
- regionclass_form_block_admin_configure_alter in ./
regionclass.module - Implements hook_form_FORM_ID_alter().
File
- ./
regionclass.module, line 92 - A module providing a simple method for adding CSS classes to regions.
Code
function _regionclass_augment_blockgroup_edit_form(&$form, &$form_state) {
// Region class settings.
$form['settings']['regionclass'] = array(
'#type' => 'fieldset',
'#title' => t('Region class'),
'#collapsible' => FALSE,
'#description' => t('Assign CSS-classes to the region provided by this block group. Use space as a separator when specifying multiple classes.'),
'#tree' => TRUE,
);
$theme_default = variable_get('theme_default', 'bartik');
$admin_theme = variable_get('admin_theme');
$region = blockgroup_get_region($form['delta']['#value']);
foreach (list_themes() as $key => $theme) {
// Only display enabled themes.
if ($theme->status) {
if (!empty($form['delta']['#value'])) {
$regionclass = theme_get_setting('regionclass', $key);
$default_value = isset($regionclass[$region]) ? $regionclass[$region] : array();
}
else {
$default_value = array();
}
// Use a meaningful title for the main site theme and administrative
// theme.
$theme_title = t('CSS classes for @theme', array(
'@theme' => $theme->info['name'],
));
if ($key == $theme_default) {
$theme_title = t('!prefix (default theme)', array(
'!prefix' => $theme_title,
));
}
elseif ($admin_theme && $key == $admin_theme) {
$theme_title = t('!prefix (administration theme)', array(
'!prefix' => $theme_title,
));
}
$form['settings']['regionclass'][$key] = array(
'#type' => 'textfield',
'#title' => $theme_title,
'#default_value' => implode(' ', $default_value),
'#weight' => $key == $theme_default ? 9 : 10,
);
}
}
$form['#validate'][] = 'regionclass_settings_validate';
// Our submit handler should be executed before blockgroup submit handler.
array_unshift($form['#submit'], 'regionclass_blockgroup_edit_form_submit');
}