Commit 511d9f79 authored by webchick's avatar webchick

Issue #1885564 by Cottser, SebCorbin, joelpittet, drupalninja99, jenlampton,...

Issue #1885564 by Cottser, SebCorbin, joelpittet, drupalninja99, jenlampton, longwave, aboros, trevorkjorlien, socketwench, shanethehat, mbrett5062, rteijeiro: Convert theme_task_list to Twig template.
parent 32336d58
......@@ -1574,45 +1574,38 @@ function template_preprocess_container(&$variables) {
$variables['attributes'] = $element['#attributes'];
}
/**
* Returns HTML for a list of maintenance tasks to perform.
* Prepares variables for maintenance task list templates.
*
* @param $variables
* Default template: task-list.html.twig.
*
* @param array $variables
* An associative array containing:
* - items: An associative array of maintenance tasks.
* It's the caller's responsibility to ensure this array's items contain no
* dangerous HTML such as SCRIPT tags.
* - active: The key for the currently active maintenance task.
*
* @ingroup themeable
*/
function theme_task_list($variables) {
function template_preprocess_task_list(&$variables) {
$items = $variables['items'];
$active = $variables['active'];
$done = isset($items[$active]) || $active == NULL;
$output = '<h2 class="visually-hidden">Installation tasks</h2>';
$output .= '<ol class="task-list">';
foreach ($items as $k => $item) {
$variables['tasks'][$k]['item'] = $item;
$variables['tasks'][$k]['attributes'] = new Attribute();
if ($active == $k) {
$class = 'active';
$status = '(' . t('active') . ')';
$variables['tasks'][$k]['attributes']->addClass('active');
$variables['tasks'][$k]['status'] = t('active');
$done = FALSE;
}
else {
$class = $done ? 'done' : '';
$status = $done ? '(' . t('done') . ')' : '';
if ($done) {
$variables['tasks'][$k]['attributes']->addClass('done');
$variables['tasks'][$k]['status'] = t('done');
}
}
$output .= '<li';
$output .= ($class ? ' class="' . $class . '"' : '') . '>';
$output .= $item;
$output .= ($status ? '<span class="visually-hidden"> ' . $status . '</span>' : '');
$output .= '</li>';
}
$output .= '</ol>';
return $output;
}
/**
......@@ -2376,6 +2369,7 @@ function drupal_common_theme() {
),
'task_list' => array(
'variables' => array('items' => NULL, 'active' => NULL, 'variant' => NULL),
'template' => 'task-list',
),
'authorize_message' => array(
'variables' => array('message' => NULL, 'success' => TRUE),
......
{#
/**
* @file
* Default theme implementation for a list of maintenance tasks to perform.
*
* Available variables:
* - tasks: A list of maintenance tasks to perform. Each item in the list has
* the following variables:
* - item: The maintenance task.
* - attributes: HTML attributes for the maintenance task.
* - status: (optional) Text describing the status of the maintenance task,
* 'active' or 'done'.
*
* @ingroup themeable
*/
#}
<h2 class="visually-hidden">Installation tasks</h2>
<ol class="task-list">
{% for task in tasks %}
<li{{ task.attributes }}>
{{ task.item }}
{% if task.status %}<span class="visually-hidden"> ({{ task.status }})</span>{% endif %}
</li>
{% endfor %}
</ol>
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