function om_block_classes in OM Tools 8.2
Same name and namespace in other branches
- 6.2 tools/block/block.inc \om_block_classes()
- 7.2 tools/block/block.inc \om_block_classes()
Block Classes Form
1 call to om_block_classes()
- om_block_tools in tools/
block/ block.inc - Block Tools Form
File
- tools/
block/ block.inc, line 113 - Block Tools
Code
function om_block_classes($block_defaults = array()) {
// Block Classes
$out = array();
// get new blocks
$block_defaults = om_block_classes_get($block_defaults, FALSE);
// reset block classes
if (isset($block_defaults['block_classes_reset']) && $block_defaults['block_classes_reset'] == 1) {
$block_defaults['block_classes_reset'] = 0;
$block_defaults = om_block_classes_get($block_defaults, TRUE);
}
$out['block_classes_switch'] = array(
'#type' => 'checkbox',
'#title' => t('Add custom block classes'),
'#default_value' => isset($block_defaults['block_classes_switch']) ? $block_defaults['block_classes_switch'] : 0,
);
$out['block_classes_settings'] = array(
'#type' => 'fieldset',
'#attributes' => array(
'id' => 'om-group-block-classes-settings',
),
'#title' => t('Block Classes Settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$excluded = array(
'block_classes_switch',
'block_classes_reset',
);
foreach ($block_defaults as $module => $blocks) {
if (!in_array($module, $excluded)) {
$out['block_classes_settings'][$module] = array(
'#type' => 'fieldset',
'#title' => t(ucwords($module)),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
foreach ($blocks as $name => $class) {
$block = explode('___', $name);
// '___' instead of '_' to distinguish it from other names, somehow space can't be used on array keys
$delta = $block[2];
$out['block_classes_settings'][$module]['block_classes___' . $module . '___' . $delta] = array(
'#type' => 'textfield',
'#title' => t('ID: ' . 'block-' . $module . '-' . $delta . ' <a href="' . base_path() . 'admin/structure/block/manage/' . $module . '/' . $delta . '/configure?destination=admin/config/system/om-tools">Edit</a>'),
'#default_value' => $class,
);
}
}
}
$out['block_classes_reset'] = array(
'#type' => 'checkbox',
'#title' => t('Reset to default values.'),
'#default_value' => isset($block_defaults['block_classes_reset']) ? $block_defaults['block_classes_reset'] : 0,
);
return $out;
}