From de06bb7a8e17bb3fb3597f591461abf6c8c167ad Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 18 Jul 2007 14:08:08 +0000 Subject: - Patch #159936 by dvessel: tpl-ified the block.module. --- modules/block/block-admin-display.tpl.php | 65 ++++++++++++++++++++++++++++ modules/block/block.admin.inc | 59 +++++++++++++++++++++++++ modules/block/block.module | 71 +------------------------------ 3 files changed, 125 insertions(+), 70 deletions(-) create mode 100644 modules/block/block-admin-display.tpl.php (limited to 'modules') diff --git a/modules/block/block-admin-display.tpl.php b/modules/block/block-admin-display.tpl.php new file mode 100644 index 000000000..7c618e177 --- /dev/null +++ b/modules/block/block-admin-display.tpl.php @@ -0,0 +1,65 @@ +is_region_first: TRUE or FALSE depending on the listed blocks + * positioning. Used here to insert a region header. + * - $data->region_title: Region title for the listed block. + * - $data->block_title: Block title. + * - $data->region_select: Drop-down menu for assigning a region. + * - $data->weight_select: Drop-down menu for setting weights. + * - $data->throttle_check: Checkbox to enable throttling. + * - $data->configure_link: Block configuration link. + * - $data->delete_link: For deleting user added blocks. + * + * @see template_preprocess_block_admin_display() + * @see theme_block_admin_display() + */ +?> + + + + + + + + + + + + + + + + + + is_region_first): ?> + + + + + + + + + + + + + + + + + + +
region_title; ?>
block_title; ?>region_select; ?>weight_select; ?>throttle_check; ?>configure_link; ?>delete_link; ?>
+ + diff --git a/modules/block/block.admin.inc b/modules/block/block.admin.inc index 247ad9245..09bd955f8 100644 --- a/modules/block/block.admin.inc +++ b/modules/block/block.admin.inc @@ -300,3 +300,62 @@ function block_box_delete_submit($form, &$form_state) { 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, '
'. $value .'
'); + } + + // 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']); +} +drupal_rebuild_theme_registry(); diff --git a/modules/block/block.module b/modules/block/block.module index 2bbfcdbbe..223c380fd 100644 --- a/modules/block/block.module +++ b/modules/block/block.module @@ -54,6 +54,7 @@ function block_help($path, $arg) { function block_theme() { return array( 'block_admin_display' => array( + 'file' => 'block-admin-display', 'arguments' => array('form' => NULL), ), ); @@ -218,76 +219,6 @@ function _block_rehash() { return $blocks; } -/** - * Theme main block administration form submission. - * - * Note: the blocks are already sorted in the right order, - * grouped by status, region and weight. - */ -function theme_block_admin_display($form) { - global $theme_key; - - $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, '
'. $value .'
'); - } - - // Build rows - $rows = array(); - $last_region = ''; - $last_status = 1; - foreach (element_children($form) as $i) { - $block = &$form[$i]; - // Only take form elements that are blocks. - if (isset($block['info'])) { - // Fetch values - $region = $block['region']['#default_value']; - $status = $region != BLOCK_REGION_NONE; - - // Output region header - if ($status && $region != $last_region) { - $region_title = t('@region', array('@region' => drupal_ucfirst($block_regions[$region]))); - $rows[] = array(array('data' => $region_title, 'class' => 'region', 'colspan' => ($throttle ? 7 : 6))); - $last_region = $region; - } - // Output disabled header - elseif ($status != $last_status) { - $rows[] = array(array('data' => t('Disabled'), 'class' => 'region', 'colspan' => ($throttle ? 7 : 6))); - $last_status = $status; - } - - // Generate block row - $row = array( - array('data' => drupal_render($block['info']), 'class' => 'block'), - drupal_render($block['region']) . drupal_render($block['theme']), - drupal_render($block['weight']), - ); - if ($throttle) { - $row[] = drupal_render($block['throttle']); - } - $row[] = drupal_render($block['configure']); - $row[] = !empty($block['delete']) ? drupal_render($block['delete']) : ''; - $rows[] = $row; - } - } - - // Finish table - $header = array(t('Block'), t('Region'), t('Weight')); - if ($throttle) { - $header[] = t('Throttle'); - } - $header[] = array('data' => t('Operations'), 'colspan' => 2); - - $output = theme('table', $header, $rows, array('id' => 'blocks')); - - $output .= drupal_render($form); - - return $output; -} - function block_box_get($bid) { return db_fetch_array(db_query("SELECT bx.*, bl.title FROM {boxes} bx INNER JOIN {blocks} bl ON bx.bid = bl.delta WHERE bl.module = 'block' AND bx.bid = %d", $bid)); } -- cgit v1.2.3