You are here

function blocktheme_preprocess_block_admin_display_form in Block Theme 6

Same name and namespace in other branches
  1. 7 blocktheme.module \blocktheme_preprocess_block_admin_display_form()

Implementation of template_preprocess_block_admin_display_form().

File

./blocktheme.module, line 325
Provides a configuration option to select custom themes for blocks

Code

function blocktheme_preprocess_block_admin_display_form(&$variables) {
  if (variable_get('blocktheme_show_custom_block_theme', '')) {

    // Get blocks with custom templates.
    $blocktheme = blocktheme_get();

    // Get block theme names.
    $blocktheme_themes = blocktheme_get_blockthemes();
    foreach (element_children($variables['form']) as $i) {
      $block =& $variables['form'][$i];

      // Only take form elements that are blocks.
      if (isset($block['info'])) {

        // Fetch region for current block.
        $region = $block['region']['#default_value'];

        // Set block theme key for the current module.
        $var_name = $block['module']['#value'] . '-' . $block['delta']['#value'];
        $variables['block_listing'][$region][$i]->custom_block_theme = isset($blocktheme[$var_name]) ? $blocktheme_themes[$blocktheme[$var_name]] : '';
      }
    }
  }
}