Issue #2151095 by joelpittet, longwave, c4rl, IshaDakota, pplantinga, gnuget, jeanfei, sbudker1, Cottser: Convert theme_admin_page() to Twig
parent
64946d19e0
commit
55edf2ec55
|
@ -116,7 +116,9 @@ function template_preprocess_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:
|
||||
|
@ -127,40 +129,24 @@ function template_preprocess_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(
|
||||
foreach ($variables['blocks'] as $block) {
|
||||
if (!empty($block['content']['#content'])) {
|
||||
if (empty($block['position'])) {
|
||||
// Perform automatic striping.
|
||||
$block['position'] = ++$stripe % 2 ? 'left' : 'right';
|
||||
}
|
||||
$variables['containers'][$block['position']]['blocks'][] = array(
|
||||
'#theme' => 'admin_block',
|
||||
'#block' => $block,
|
||||
);
|
||||
if ($block_output = drupal_render($admin_block)) {
|
||||
if (empty($block['position'])) {
|
||||
// perform automatic striping.
|
||||
$block['position'] = ++$stripe % 2 ? 'left' : 'right';
|
||||
}
|
||||
if (!isset($container[$block['position']])) {
|
||||
$container[$block['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() {
|
|||
'admin_page' => array(
|
||||
'variables' => array('blocks' => NULL),
|
||||
'file' => 'system.admin.inc',
|
||||
'template' => 'admin-page',
|
||||
),
|
||||
'admin_block' => array(
|
||||
'variables' => array('block' => NULL),
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
{#
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
#}
|
||||
<div class="admin clearfix">
|
||||
{{ system_compact_link }}
|
||||
{% for position, container in containers %}
|
||||
<div class="{{ position }} clearfix">
|
||||
{% for block in container.blocks %}
|
||||
{{ block }}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
Loading…
Reference in New Issue