diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 3af30c8..b909eb9 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -322,7 +322,9 @@ function theme_admin_block($variables) { } /** - * Returns HTML for the content of an administrative block. + * Prepares variables for administrative content block template. + * + * Default template: admin-block-content.html.twig. * * @param $variables * An associative array containing: @@ -333,25 +335,23 @@ function theme_admin_block($variables) { * * @ingroup themeable */ -function theme_admin_block_content($variables) { - $content = $variables['content']; - $output = ''; - - if (!empty($content)) { - $class = 'admin-list'; - if ($compact = system_admin_compact_mode()) { - $class .= ' compact'; +function template_preprocess_admin_block_content(&$variables) { + if (!empty($variables['content'])) { + $compact = system_admin_compact_mode(); + $variables['attributes'] = array('class' => array('admin-list')); + if ($compact) { + $variables['attributes']['class'][] = 'compact'; } - $output .= '
'; - foreach ($content as $item) { - $output .= '
' . l($item['title'], $item['href'], $item['localized_options']) . '
'; + foreach ($variables['content'] as $key => $item) { + $variables['content'][$key]['link'] = l($item['title'], $item['href'], $item['localized_options']); if (!$compact && isset($item['description'])) { - $output .= '
' . filter_xss_admin($item['description']) . '
'; + $variables['content'][$key]['description'] = filter_xss_admin($item['description']); + } + else { + $variables['content'][$key]['description'] = FALSE; } } - $output .= '
'; } - return $output; } /** diff --git a/core/modules/system/system.module b/core/modules/system/system.module index ee3466d..3ff8fb6 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -178,6 +178,7 @@ function system_theme() { 'admin_block_content' => array( 'variables' => array('content' => NULL), 'file' => 'system.admin.inc', + 'template' => 'admin-block-content', ), 'system_admin_index' => array( 'variables' => array('menu_items' => NULL), diff --git a/core/modules/system/templates/admin-block-content.html.twig b/core/modules/system/templates/admin-block-content.html.twig new file mode 100644 index 0000000..d3fbd5a --- /dev/null +++ b/core/modules/system/templates/admin-block-content.html.twig @@ -0,0 +1,28 @@ +{# +/** + * @file + * Default theme implementation for the content of an administrative block. + * + * Available variables: + * - content: A list containing information about the block. Each element + * of the array represents an administrative menu item, and must at least + * contain the keys 'title', 'href', and 'localized_options', which are + * passed to l(). A 'description' key may also be provided. + * - attributes: HTML attributes to be aded to the element. + * - is_compact_mode: It defines if compact mode is used. + * + * @see template_preprocess_admin_block_content() + * + * @ingroup themeable + */ +#} +{% if content %} + + {% for item in content %} +
{{ item.link }}
+ {% if item.description %} +
{{ item.description }}
+ {% endif %} + {% endfor %} + +{% endif %}