Issue #2151093 by Cottser, quietone, joelpittet, InternetDevels: Convert theme_admin_block_content() to Twig.
parent
8f546e5c33
commit
f674cd24d2
|
@ -125,36 +125,36 @@ function theme_admin_block($variables) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns HTML for the content of an administrative block.
|
* Prepares variables for administrative content block templates.
|
||||||
|
*
|
||||||
|
* Default template: admin-block-content.html.twig.
|
||||||
*
|
*
|
||||||
* @param $variables
|
* @param $variables
|
||||||
* An associative array containing:
|
* An associative array containing:
|
||||||
* - content: An array containing information about the block. Each element
|
* - content: An array containing information about the block. Each element
|
||||||
* of the array represents an administrative menu item, and must at least
|
* of the array represents an administrative menu item, and must at least
|
||||||
* contain the keys 'title', 'href', and 'localized_options', which are
|
* contain the keys 'title', 'link_path', and 'localized_options', which are
|
||||||
* passed to l(). A 'description' key may also be provided.
|
* passed to l(). A 'description' key may also be provided.
|
||||||
*
|
*
|
||||||
* @ingroup themeable
|
* @ingroup themeable
|
||||||
*/
|
*/
|
||||||
function theme_admin_block_content($variables) {
|
function template_preprocess_admin_block_content(&$variables) {
|
||||||
$content = $variables['content'];
|
if (!empty($variables['content'])) {
|
||||||
$output = '';
|
$compact = system_admin_compact_mode();
|
||||||
|
$variables['attributes'] = array('class' => array('admin-list'));
|
||||||
if (!empty($content)) {
|
if ($compact) {
|
||||||
$class = 'admin-list';
|
$variables['attributes']['class'][] = 'compact';
|
||||||
if ($compact = system_admin_compact_mode()) {
|
|
||||||
$class .= ' compact';
|
|
||||||
}
|
}
|
||||||
$output .= '<dl class="' . $class . '">';
|
foreach ($variables['content'] as $key => $item) {
|
||||||
foreach ($content as $item) {
|
$variables['content'][$key]['link'] = l($item['title'], $item['link_path'], $item['localized_options']);
|
||||||
$output .= '<dt>' . l($item['title'], $item['link_path'], $item['localized_options']) . '</dt>';
|
|
||||||
if (!$compact && isset($item['description'])) {
|
if (!$compact && isset($item['description'])) {
|
||||||
$output .= '<dd>' . filter_xss_admin($item['description']) . '</dd>';
|
$variables['content'][$key]['description'] = filter_xss_admin($item['description']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$variables['content'][$key]['description'] = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$output .= '</dl>';
|
|
||||||
}
|
}
|
||||||
return $output;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -193,6 +193,7 @@ function system_theme() {
|
||||||
'admin_block_content' => array(
|
'admin_block_content' => array(
|
||||||
'variables' => array('content' => NULL),
|
'variables' => array('content' => NULL),
|
||||||
'file' => 'system.admin.inc',
|
'file' => 'system.admin.inc',
|
||||||
|
'template' => 'admin-block-content',
|
||||||
),
|
),
|
||||||
'system_admin_index' => array(
|
'system_admin_index' => array(
|
||||||
'variables' => array('menu_items' => NULL),
|
'variables' => array('menu_items' => NULL),
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
{#
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Default theme implementation for the content of an administrative block.
|
||||||
|
*
|
||||||
|
* Available variables:
|
||||||
|
* - content: A list containing information about the block. Each element
|
||||||
|
* of the array represents an administrative menu item, and must at least
|
||||||
|
* contain the keys 'title', 'link_path', and 'localized_options', which are
|
||||||
|
* passed to l(). A 'description' key may also be provided.
|
||||||
|
* - attributes: HTML attributes to be added to the element.
|
||||||
|
*
|
||||||
|
* @see template_preprocess_admin_block_content()
|
||||||
|
*
|
||||||
|
* @ingroup themeable
|
||||||
|
*/
|
||||||
|
#}
|
||||||
|
{% if content %}
|
||||||
|
<dl{{ attributes }}>
|
||||||
|
{% for item in content %}
|
||||||
|
<dt>{{ item.link }}</dt>
|
||||||
|
{% if item.description %}
|
||||||
|
<dd>{{ item.description }}</dd>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</dl>
|
||||||
|
{% endif %}
|
Loading…
Reference in New Issue