diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 2786774..e662a0d 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1616,6 +1616,40 @@ function theme_task_list($variables) { } /** + * Prepares variables for maintenance task list templates. + * + * 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. + */ +function template_preprocess_task_list(&$variables) { + $items = $variables['items']; + $active = $variables['active']; + + $done = isset($items[$active]) || $active == NULL; + foreach ($items as $k => $item) { + $variables['tasks'][$k]['item'] = $item; + $variables['tasks'][$k]['attributes'] = new Attribute(); + if ($active == $k) { + $variables['tasks'][$k]['attributes']->addClass('active'); + $variables['tasks'][$k]['status'] = t('active'); + $done = FALSE; + } + else { + if ($done) { + $variables['tasks'][$k]['attributes']->addClass('done'); + $variables['tasks'][$k]['status'] = t('done'); + } + } + } +} + +/** * @} End of "addtogroup themeable". */ @@ -2376,6 +2410,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), diff --git a/core/modules/system/templates/task-list.html.twig b/core/modules/system/templates/task-list.html.twig new file mode 100644 index 0000000..649cfa6 --- /dev/null +++ b/core/modules/system/templates/task-list.html.twig @@ -0,0 +1,25 @@ +{# +/** + * @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 + */ +#} +