Commit 3a7d3078 authored by Dries's avatar Dries
Browse files

- Patch #159936 by dvessel: tpl-ify block module.

parent 8b2f6947
......@@ -299,3 +299,62 @@ function block_box_delete_submit($form, &$form_state) {
$form_state['redirect'] = 'admin/build/block';
return;
}
/**
* Process variables for block-admin-display.tpl.php.
*
* The $variables array contains the following arguments:
* - $form
*
* @see block-admin-display.tpl.php
* @see theme_block_admin_display()
*/
function template_preprocess_block_admin_display(&$variables) {
global $theme_key;
$variables['throttle'] = module_exists('throttle');
$block_regions = system_region_list($theme_key);
// Highlight regions on page to provide visual reference.
foreach ($block_regions as $key => $value) {
drupal_set_content($key, '<div class="block-region">'. $value .'</div>');
}
// Setup to track previous region in loop.
$last_region = '';
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'];
// Track first block listing to insert region header inside block_admin_display.tpl.php.
$is_region_first = FALSE;
if ($last_region != $region) {
$is_region_first = TRUE;
// Set region title. Block regions already translated.
if ($region != BLOCK_REGION_NONE) {
$region_title = drupal_ucfirst($block_regions[$region]);
}
else {
$region_title = t('Disabled');
}
}
$variables['block_listing'][$i]->is_region_first = $is_region_first;
$variables['block_listing'][$i]->region_title = $region_title;
$variables['block_listing'][$i]->block_title = drupal_render($block['info']);
$variables['block_listing'][$i]->region_select = drupal_render($block['region']) . drupal_render($block['theme']);
$variables['block_listing'][$i]->weight_select = drupal_render($block['weight']);
$variables['block_listing'][$i]->throttle_check = $variables['throttle'] ? drupal_render($block['throttle']) : '';
$variables['block_listing'][$i]->configure_link = drupal_render($block['configure']);
$variables['block_listing'][$i]->delete_link = !empty($block['delete']) ? drupal_render($block['delete']) : '';
$last_region = $region;
}
}
$variables['form_submit'] = drupal_render($variables['form']);
}
......@@ -104,70 +104,12 @@ function block_theme() {
return array(
'block_admin_display' => array(
'template' => 'block-admin-display',
'file' => 'block.admin.inc',
'arguments' => array('form' => NULL),
),
);
}
/**
* Process variables for block-admin-display.tpl.php.
*
* The $variables array contains the following arguments:
* - $form
*
* @see block-admin-display.tpl.php
* @see theme_block_admin_display()
*/
function template_preprocess_block_admin_display(&$variables) {
global $theme_key;
$variables['throttle'] = module_exists('throttle');
$block_regions = system_region_list($theme_key);
// Highlight regions on page to provide visual reference.
foreach ($block_regions as $key => $value) {
drupal_set_content($key, '<div class="block-region">'. $value .'</div>');
}
// Setup to track previous region in loop.
$last_region = '';
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'];
// Track first block listing to insert region header inside block_admin_display.tpl.php.
$is_region_first = FALSE;
if ($last_region != $region) {
$is_region_first = TRUE;
// Set region title. Block regions already translated.
if ($region != BLOCK_REGION_NONE) {
$region_title = drupal_ucfirst($block_regions[$region]);
}
else {
$region_title = t('Disabled');
}
}
$variables['block_listing'][$i]->is_region_first = $is_region_first;
$variables['block_listing'][$i]->region_title = $region_title;
$variables['block_listing'][$i]->block_title = drupal_render($block['info']);
$variables['block_listing'][$i]->region_select = drupal_render($block['region']) . drupal_render($block['theme']);
$variables['block_listing'][$i]->weight_select = drupal_render($block['weight']);
$variables['block_listing'][$i]->throttle_check = $variables['throttle'] ? drupal_render($block['throttle']) : '';
$variables['block_listing'][$i]->configure_link = drupal_render($block['configure']);
$variables['block_listing'][$i]->delete_link = !empty($block['delete']) ? drupal_render($block['delete']) : '';
$last_region = $region;
}
}
$variables['form_submit'] = drupal_render($variables['form']);
}
/**
* Implementation of hook_perm().
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment