$block->module, ':delta' => $block->delta))->fetchField(); return $ret ? $ret : ''; } /** * Alter block edit form */ function block_class_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'block_admin_configure' || $form_id == 'block_add_block_form') { $block->module = $form['module']['#value']; $block->delta = $form['delta']['#value']; $css_class = block_class($block); $form['block_class'] = array( '#type' => 'fieldset', '#title' => t('Block Class settings'), '#collapsible' => TRUE, '#weight' => -1, ); $form['block_class']['css_class'] = array( '#type' => 'textfield', '#title' => t('CSS class(es)'), '#default_value' => $css_class, '#description' => t('Separate classes with a space.'), ); $form['#submit'][] = 'block_class_form_submit'; } } /** * Save supplied class. */ function block_class_form_submit($form, &$form_state) { if ($form_state['values']['form_id'] == 'block_admin_configure' || $form_state['values']['form_id'] == 'block_add_block_form') { if (isset($form_state['values']['css_class']) && user_access('administer blocks')) { $module = $form_state['values']['module']; $delta = $form_state['values']['delta']; $class = $form_state['values']['css_class']; db_delete('block_class')->condition('module', $module)->condition('delta', $delta)->execute(); if (!empty($class)) { $id = db_insert('block_class')->fields(array('module' => $module, 'delta' => $delta, 'css_class' => $class))->execute(); } } } }