diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 3af30c8..0516510 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -355,7 +355,9 @@ function theme_admin_block_content($variables) { } /** - * Returns HTML for an administrative page. + * Prepares variables for administrative index page templates. + * + * Default template: admin-page.html.twig. * * @param $variables * An associative array containing: @@ -366,40 +368,28 @@ function theme_admin_block_content($variables) { * * @ingroup themeable */ -function theme_admin_page($variables) { - $blocks = $variables['blocks']; - +function template_preprocess_admin_page(&$variables) { + $variables['system_compact_link'] = array( + '#theme' => 'system_compact_link', + ); + $variables['containers'] = array(); $stripe = 0; - $container = array(); - - foreach ($blocks as $block) { - $admin_block = array( - '#theme' => 'admin_block', - '#block' => $block, - ); - if ($block_output = drupal_render($admin_block)) { + foreach ($variables['blocks'] as $block) { + $block = (array) $block; + if ($block['show'] = !empty($block['content'])) { if (empty($block['position'])) { - // perform automatic striping. + // Perform automatic striping. $block['position'] = ++$stripe % 2 ? 'left' : 'right'; } - if (!isset($container[$block['position']])) { - $container[$block['position']] = ''; + if (!isset($variables['containers'][$block['position']])) { + $variables['containers'][$block['position']] = array('blocks' => array()); } - $container[$block['position']] .= $block_output; + $variables['containers'][$block['position']]['blocks'][] = array( + '#theme' => 'admin_block', + '#block' => $block, + ); } } - - $system_compact_link = array('#theme' => 'system_compact_link'); - $output = '
'; - $output .= drupal_render($system_compact_link); - - foreach ($container as $id => $data) { - $output .= '
'; - $output .= $data; - $output .= '
'; - } - $output .= '
'; - return $output; } /** diff --git a/core/modules/system/system.module b/core/modules/system/system.module index ee3466d..eb75db6 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -170,6 +170,7 @@ function system_theme() { 'admin_page' => array( 'variables' => array('blocks' => NULL), 'file' => 'system.admin.inc', + 'template' => 'admin-page', ), 'admin_block' => array( 'variables' => array('block' => NULL), diff --git a/core/modules/system/templates/admin-page.html.twig b/core/modules/system/templates/admin-page.html.twig new file mode 100644 index 0000000..5a7d9b1 --- /dev/null +++ b/core/modules/system/templates/admin-page.html.twig @@ -0,0 +1,27 @@ +{# +/** + * @file + * Default theme implementation for an administrative page. + * + * Available variables: + * - system_compact_link: Themed link to toggle compact view. + * - containers: An list of administrative blocks keyed by position: left or + * right. Contains: + * - blocks: A list of blocks within a container. + * + * + * @see template_preprocess_admin_page() + * + * @ingroup themeable + */ +#} +
+ {{ system_compact_link }} + {% for position, container in containers %} +
+ {% for block in container.blocks %} + {{ block }} + {% endfor %} +
+ {% endfor %} +