diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 697f8c7..ac380ef 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -207,7 +207,9 @@ function theme_admin_page($variables) { } /** - * Returns HTML for the output of the admin index page. + * Prepares variables for admin index template. + * + * Default template: system-admin-index.html.twig. * * @param $variables * An associative array containing: @@ -215,55 +217,35 @@ function theme_admin_page($variables) { * * @ingroup themeable */ -function theme_system_admin_index($variables) { - $menu_items = $variables['menu_items']; - - $container = array('left' => '', 'right' => ''); - $flip = array('left' => 'right', 'right' => 'left'); - $position = 'left'; - +function template_preprocess_system_admin_index(&$variables) { + $variables['system_compact_link'] = array( + '#theme' => 'system_compact_link' + ); + $variables['containers'] = array(); + $stripe = 0; // Iterate over all modules. - foreach ($menu_items as $module => $block) { + foreach ($variables['menu_items'] as $module => $block) { list($description, $items) = $block; - + $position = ++$stripe % 2 ? 'left' : 'right'; // Output links. if (count($items)) { - $admin_block_content = array( - '#theme' => 'admin_block_content', - '#content' => $items, - ); - $block = array(); - $block['title'] = $module; - $block['content'] = drupal_render($admin_block_content); - $block['description'] = t($description); - $block['show'] = TRUE; - $admin_block = array( + $variables['containers'][$position]['blocks'][] = array( '#theme' => 'admin_block', - '#block' => $block, + '#block' => array( + 'position' => $position, + 'title' => $module, + 'show' => TRUE, + 'content' => array( + '#theme' => 'admin_block_content', + '#content' => $items, + ), + 'description' => t($description), + ), ); - if ($block_output = drupal_render($admin_block)) { - if (!isset($block['position'])) { - // Perform automatic striping. - $block['position'] = $position; - $position = $flip[$position]; - } - $container[$block['position']] .= $block_output; - } - } - } - $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 fc6f61c..94dce21 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -193,6 +193,7 @@ function system_theme() { 'system_admin_index' => array( 'variables' => array('menu_items' => NULL), 'file' => 'system.admin.inc', + 'template' => 'system-admin-index', ), 'system_compact_link' => array( 'variables' => array(), diff --git a/core/modules/system/templates/system-admin-index.html.twig b/core/modules/system/templates/system-admin-index.html.twig new file mode 100644 index 0000000..9b3282f --- /dev/null +++ b/core/modules/system/templates/system-admin-index.html.twig @@ -0,0 +1,24 @@ +{# +/** + * @file + * Default theme implementation for the admin index page. + * + * Available variables: + * - system_compact_link: Themed link to toggle compact view. + * - container: Container for admin blocks. + * + * @see template_preprocess_system_admin_index() + * + * @ingroup themeable + */ +#} +
+ {{ system_compact_link }} + {% for position, container in containers %} +
+ {% for block in container.blocks %} + {{ block }} + {% endfor %} +
+ {% endfor %} +