Commit e8f1ce11 authored by webchick's avatar webchick
Browse files

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

parent a1ca5f6e
......@@ -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
* An associative array containing:
* - menu_items: An array of modules to be displayed.
*
* @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);
$admin_block = array(
$variables['containers'][$position][] = array(
'#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() {
'system_admin_index' => array(
'variables' => array('menu_items' => NULL),
'file' => 'system.admin.inc',
'template' => 'system-admin-index',
),
'system_compact_link' => array(
'variables' => array(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment