diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc index 0b426e2..ea2dacb 100644 --- a/core/includes/theme.maintenance.inc +++ b/core/includes/theme.maintenance.inc @@ -5,6 +5,8 @@ * Theming for maintenance pages. */ +use Drupal\Core\Template\Attribute; + /** * Sets up the theming system for maintenance page. * @@ -136,6 +138,42 @@ function theme_task_list($variables) { } /** + * Preprocesses variables for a list of maintenance tasks to perform. + * + * @param $variables + * An associative array containing: + * - items: An associative array of maintenance tasks. + * - active: The key for the currently active maintenance task. + * + * @ingroup themeable + */ +function template_preprocess_task_list(&$variables) { + $t = get_t(); + $items = $variables['items']; + $active = $variables['active']; + + $done = isset($items[$active]) || $active == NULL; + $tasks = array(); + + foreach ($items as $k => $item) { + $tasks[$k]['item'] = $item; + $tasks[$k]['attributes'] = array('class' => array()); + if ($active == $k) { + $tasks[$k]['attributes']['class'][] = 'active'; + $tasks[$k]['status'] = '(' . $t('active') . ')'; + $done = FALSE; + } + else { + $tasks[$k]['attributes']['class'][] = $done ? 'done' : ''; + $tasks[$k]['status'] = $done ? '(' . $t('done') . ')' : ''; + } + $tasks[$k]['attributes'] = new Attribute($tasks[$k]['attributes']); + } + + $variables['tasks'] = $tasks; +} + +/** * Returns HTML for the installation page. * * Note: this function is not themeable. @@ -215,3 +253,35 @@ function theme_authorize_message($variables) { } return $item; } + +/** + * Preprocess variables for a report of the results from an operation run via authorize.php. + * + * @param $variables + * An associative array containing: + * - messages: An array of result messages. + * + * @ingroup themeable + */ +function template_preprocess_authorize_report(&$variables) { + $messages = $variables['messages']; + // Top level attributes. + $attributes = $variables['attributes'] ? $variables['attributes'] : array(); + $variables['attributes'] = new Attribute($attributes); + + if (!empty($messages)) { + $lists = array(); + $variables['attributes']['id'] = 'authorize-results'; + foreach ($messages as $heading => $logs) { + $items = array(); + foreach ($logs as $number => $log_message) { + if ($number === '#abort') { + continue; + } + $items[] = theme('authorize_message', array('message' => $log_message['message'], 'success' => $log_message['success'])); + } + $lists[] = theme('item_list', array('items' => $items, 'title' => $heading)); + } + $variables['report'] = $lists; + } +} diff --git a/core/modules/system/templates/authorize-message.html.twig b/core/modules/system/templates/authorize-message.html.twig new file mode 100644 index 0000000..d34179e --- /dev/null +++ b/core/modules/system/templates/authorize-message.html.twig @@ -0,0 +1,20 @@ +{# +/** + * @file + * Default theme implementation for a single log message from + * the authorize.php batch operation. + * + * Available variables: + * - message: The log message. + * - success: A boolean indicating failure or success. + * + * @see template_preprocess() + * + * @ingroup themeable + */ +#} +{% if success %} + {{ message }} +{% else %} + {{ message }} +{% endif %} diff --git a/core/modules/system/templates/authorize-report.html.twig b/core/modules/system/templates/authorize-report.html.twig new file mode 100644 index 0000000..f4bcf79 --- /dev/null +++ b/core/modules/system/templates/authorize-report.html.twig @@ -0,0 +1,22 @@ +{# +/** + * @file + * Default theme implementation for a report of the results from an operation run via authorize.php. + * + * Available variables: + * - attributes: HTML attributes for the element. + * - item_lists: An array of lists containing result message(s). + * + * @see template_preprocess() + * @see template_preprocess_authorize_report() + * + * @ingroup themeable + */ +#} +{% if report %} +