function om_block_classes_get in OM Tools 7.2
Same name and namespace in other branches
- 8.2 tools/block/block.inc \om_block_classes_get()
- 6.2 tools/block/block.inc \om_block_classes_get()
default blocks classes
1 call to om_block_classes_get()
- om_block_classes in tools/
block/ block.inc - Block Classes Form
File
- tools/
block/ block.inc, line 60 - Block Tools
Code
function om_block_classes_get($block_defaults = array(), $reset = FALSE) {
$theme_default = variable_get('theme_default', 'garland');
// boxes table is for custom blocks
$custom_sql = "SELECT bid, info FROM {block_custom} ORDER BY info ASC";
$custom_result = db_query($custom_sql);
$custom_classes = array();
while ($custom_record = $custom_result
->fetchObject()) {
$custom_classes[$custom_record->bid] = om_tools_class_safe($custom_record->info);
}
// default, module generated blocks
$block_sql = "SELECT module, delta FROM {block} WHERE theme = :theme_default ORDER BY module, delta ASC";
$block_result = db_query($block_sql, array(
'theme_default' => $theme_default,
));
$new_blocks = 0;
$current_blocks = array();
while ($block_record = $block_result
->fetchObject()) {
// new blocks
if (!isset($block_defaults['block_classes___' . $block_record->module . '___' . $block_record->delta]) || $reset == TRUE) {
$new_blocks++;
if ($block_record->module == 'block') {
$classes = 'block-' . $custom_classes[$block_record->delta];
}
else {
$classes = 'block-' . $block_record->module . '-' . $block_record->delta;
}
}
else {
$classes = $block_defaults['block_classes___' . $block_record->module . '___' . $block_record->delta];
}
// this will ignore non-existing blocks
$current_blocks[$block_record->module]['block_classes___' . $block_record->module . '___' . $block_record->delta] = $classes;
}
$new_blocks > 1 ? $message = 'There are ' . $new_blocks . ' new blocks, save your settings to add these new blocks.' : ($message = 'There is ' . $new_blocks . ' new block, save your settings to add this new block.');
if ($new_blocks) {
drupal_set_message(t('%message', array(
'%message' => check_plain($message),
)));
}
$current_blocks['block_classes_switch'] = isset($block_defaults['block_classes_switch']) ? $block_defaults['block_classes_switch'] : 0;
$current_blocks['block_classes_reset'] = isset($block_defaults['block_classes_reset']) ? $block_defaults['block_classes_reset'] : 0;
ksort($current_blocks);
return $current_blocks;
}