Issue #2151089 by longwave, joelpittet, c4rl, IshaDakota, pplantinga, gnuget, jeanfei, sbudker1, Cottser: Convert theme_admin_block() to Twig.

8.0.x
webchick 2014-03-12 12:18:51 -07:00
parent 10af33ad15
commit c26bf7ba0a
4 changed files with 30 additions and 44 deletions

View File

@ -137,15 +137,13 @@ class SystemController extends ControllerBase {
); );
if (!empty($block['content']['#content'])) { if (!empty($block['content']['#content'])) {
$block['show'] = TRUE;
}
// Prepare for sorting as in function _menu_tree_check_access(). // Prepare for sorting as in function _menu_tree_check_access().
// The weight is offset so it is always positive, with a uniform 5-digits. // The weight is offset so it is always positive, with a uniform 5-digits.
$blocks[(50000 + $item['weight']) . ' ' . $item['title'] . ' ' . $item['mlid']] = $block; $blocks[(50000 + $item['weight']) . ' ' . $item['title'] . ' ' . $item['mlid']] = $block;
} }
} }
} }
}
if ($blocks) { if ($blocks) {
ksort($blocks); ksort($blocks);
return array( return array(

View File

@ -82,44 +82,6 @@ function _system_is_incompatible(&$incompatible, $files, Extension $file) {
} }
} }
/**
* Returns HTML for an administrative block for display.
*
* @param $variables
* An associative array containing:
* - block: An array containing information about the block:
* - show: A Boolean whether to output the block. Defaults to FALSE.
* - title: The block's title.
* - content: (optional) Formatted content for the block.
* - description: (optional) Description of the block. Only output if
* 'content' is not set.
*
* @ingroup themeable
*/
function theme_admin_block($variables) {
$block = $variables['block'];
$output = '';
// Don't display the block if it has no content to display.
if (empty($block['show'])) {
return $output;
}
$output .= '<div class="admin-panel">';
if (!empty($block['title'])) {
$output .= '<h3>' . $block['title'] . '</h3>';
}
if (!empty($block['content'])) {
$output .= '<div class="body">' . render($block['content']) . '</div>';
}
else {
$output .= '<div class="description">' . $block['description'] . '</div>';
}
$output .= '</div>';
return $output;
}
/** /**
* Prepares variables for administrative content block templates. * Prepares variables for administrative content block templates.
* *
@ -231,7 +193,6 @@ function theme_system_admin_index($variables) {
$block['title'] = $module; $block['title'] = $module;
$block['content'] = drupal_render($admin_block_content); $block['content'] = drupal_render($admin_block_content);
$block['description'] = t($description); $block['description'] = t($description);
$block['show'] = TRUE;
$admin_block = array( $admin_block = array(
'#theme' => 'admin_block', '#theme' => 'admin_block',

View File

@ -200,6 +200,7 @@ function system_theme() {
'admin_block' => array( 'admin_block' => array(
'variables' => array('block' => NULL), 'variables' => array('block' => NULL),
'file' => 'system.admin.inc', 'file' => 'system.admin.inc',
'template' => 'admin-block',
), ),
'admin_block_content' => array( 'admin_block_content' => array(
'variables' => array('content' => NULL), 'variables' => array('content' => NULL),

View File

@ -0,0 +1,26 @@
{#
/**
* @file
* Default theme implementation for an administrative block.
*
* Available variables:
* - block: An array of information about the block, including:
* - show: A flag indicating if the block should be displayed.
* - title: The block title.
* - content: (optional) The content of the block.
* - description: (optional) A description of the block.
* (Description should only be output if content is not available).
*
* @ingroup themeable
*/
#}
<div class="admin-panel">
{% if block.title %}
<h3>{{ block.title }}</h3>
{% endif %}
{% if block.content %}
<div class="body">{{ block.content }}</div>
{% elseif block.description %}
<div class="description">{{ block.description }}</div>
{% endif %}
</div>