function om_block_classes in OM Tools 6.2
Same name and namespace in other branches
- 8.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 111 - Block Tools
Code
function om_block_classes($block_defaults = array()) {
// get new blocks
$block_defaults = om_block_classes_get($block_defaults, FALSE);
// Block Classes
$out = array();
// 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' => $block_defaults['block_classes_switch'],
);
$out['block_classes_settings'] = array(
'#type' => 'fieldset',
'#attributes' => array(
'id' => 'om-group-block-classes-settings',
),
'#title' => t('Block Classes Settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('If you\'re not using <strong>OM Base Theme 2</strong>, you need to add this to your <strong>block.tpl.php</strong>, ... class="block block-<?php print $block->module ?> <strong><?php print $om_block_classes; ?></strong>">'),
);
$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/build/block/configure/' . $module . '/' . $delta . '?destination=admin/settings/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;
}