Skip to content
Snippets Groups Projects
Commit e8f1ce11 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2151105 by Cottser, longwave, joelpittet: Convert theme_system_admin_index() to Twig.

parent a1ca5f6e
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -102,62 +102,40 @@ function template_preprocess_admin_page(&$variables) { ...@@ -102,62 +102,40 @@ function template_preprocess_admin_page(&$variables) {
} }
/** /**
* Returns HTML for the output of the admin index page. * Prepares variables for admin index templates.
*
* Default template: system-admin-index.html.twig.
* *
* @param $variables * @param $variables
* An associative array containing: * An associative array containing:
* - menu_items: An array of modules to be displayed. * - menu_items: An array of modules to be displayed.
*
* @ingroup themeable
*/ */
function theme_system_admin_index($variables) { function template_preprocess_system_admin_index(&$variables) {
$menu_items = $variables['menu_items']; $variables['system_compact_link'] = array(
'#theme' => 'system_compact_link',
$container = array('left' => '', 'right' => ''); );
$flip = array('left' => 'right', 'right' => 'left'); $variables['containers'] = array();
$position = 'left'; $stripe = 0;
// Iterate over all modules. // Iterate over all modules.
foreach ($menu_items as $module => $block) { foreach ($variables['menu_items'] as $module => $block) {
list($description, $items) = $block; list($description, $items) = $block;
$position = ++$stripe % 2 ? 'left' : 'right';
// Output links. // Output links.
if (count($items)) { if (count($items)) {
$admin_block_content = array( $variables['containers'][$position][] = array(
'#theme' => 'admin_block_content',
'#content' => $items,
);
$block = array();
$block['title'] = $module;
$block['content'] = drupal_render($admin_block_content);
$block['description'] = t($description);
$admin_block = array(
'#theme' => 'admin_block', '#theme' => 'admin_block',
'#block' => $block, '#block' => array(
'position' => $position,
'title' => $module,
'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 = '<div class="admin clearfix">';
$output .= drupal_render($system_compact_link);
foreach ($container as $id => $data) {
$output .= '<div class="' . $id . ' clearfix">';
$output .= $data;
$output .= '</div>';
}
$output .= '</div>';
return $output;
} }
/** /**
......
...@@ -196,6 +196,7 @@ function system_theme() { ...@@ -196,6 +196,7 @@ function system_theme() {
'system_admin_index' => array( 'system_admin_index' => array(
'variables' => array('menu_items' => NULL), 'variables' => array('menu_items' => NULL),
'file' => 'system.admin.inc', 'file' => 'system.admin.inc',
'template' => 'system-admin-index',
), ),
'system_compact_link' => array( 'system_compact_link' => array(
'variables' => array(), 'variables' => array(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment