diff --git a/core/includes/theme.inc b/core/includes/theme.inc
index b62ad74..2dacf98 100644
--- a/core/includes/theme.inc
+++ b/core/includes/theme.inc
@@ -2614,12 +2614,11 @@ function drupal_common_theme() {
),
'task_list' => array(
'variables' => array('items' => NULL, 'active' => NULL, 'variant' => NULL),
- ),
- 'authorize_message' => array(
- 'variables' => array('message' => NULL, 'success' => TRUE),
+ 'template' => 'task-list',
),
'authorize_report' => array(
- 'variables' => array('messages' => array()),
+ 'variables' => array('messages' => array(), 'attributes' => array()),
+ 'template' => 'authorize-report',
),
// From pager.inc.
'pager' => array(
diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc
index 8a19a49..bef5eff 100644
--- a/core/includes/theme.maintenance.inc
+++ b/core/includes/theme.maintenance.inc
@@ -7,6 +7,7 @@
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Site\Settings;
+use Drupal\Core\Template\Attribute;
/**
* Sets up the theming system for maintenance page.
@@ -105,100 +106,80 @@ function _drupal_maintenance_theme() {
}
/**
- * 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.
* - 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 = '
Installation tasks
';
- $output .= '';
+ $tasks = array();
foreach ($items as $k => $item) {
+ $tasks[$k]['item'] = $item;
+ $tasks[$k]['attributes'] = new Attribute(array('class' => array()));
if ($active == $k) {
- $class = 'active';
- $status = '(' . t('active') . ')';
+ $tasks[$k]['attributes']['class'][] = 'active';
+ $tasks[$k]['status'] = t('active');
$done = FALSE;
}
else {
- $class = $done ? 'done' : '';
- $status = $done ? '(' . t('done') . ')' : '';
+ $tasks[$k]['attributes']['class'][] = $done ? 'done' : '';
+ $tasks[$k]['status'] = $done ? t('done') : '';
}
- $output .= '- ';
- $output .= $item;
- $output .= ($status ? ' ' . $status . '' : '');
- $output .= '
';
}
- $output .= '
';
- return $output;
+ $variables['tasks'] = $tasks;
}
/**
- * Returns HTML for a results report of an operation run by authorize.php.
+ * Prepares variables for authorize.php operation report templates.
+ *
+ * This report displays the results of an operation run via authorize.php.
*
- * @param $variables
+ * Default template: authorize-report.html.twig.
+ *
+ * @param array $variables
* An associative array containing:
* - messages: An array of result messages.
*
- * @ingroup themeable
*/
-function theme_authorize_report($variables) {
+function template_preprocess_authorize_report(&$variables) {
$messages = $variables['messages'];
- $output = '';
+ $variables['report'] = array();
if (!empty($messages)) {
- $output .= '';
+ $variables['attributes']['id'] = 'authorize-results';
foreach ($messages as $heading => $logs) {
$items = array();
foreach ($logs as $number => $log_message) {
if ($number === '#abort') {
continue;
}
- $authorize_message = array(
- '#theme' => 'authorize_message',
- '#message' => $log_message['message'],
- '#success' => $log_message['success'],
+ if ($log_message['success']) {
+ $message = $log_message['message'];
+ $classes = array('success');
+ }
+ else {
+ $message = '' . $log_message['message'] . '';
+ $classes = array('failure');
+ }
+ $items[] = array(
+ '#wrapper_attributes' => array('class' => $classes),
+ '#markup' => $message,
);
- $items[] = drupal_render($authorize_message);
}
- $item_list = array(
+ $variables['report'][] = array(
'#theme' => 'item_list',
'#items' => $items,
'#title' => $heading,
);
- $output .= drupal_render($item_list);
}
- $output .= '
';
- }
- return $output;
-}
-
-/**
- * Returns HTML for a single log message from the authorize.php batch operation.
- *
- * @param $variables
- * An associative array containing:
- * - message: The log message.
- * - success: A boolean indicating failure or success.
- *
- * @ingroup themeable
- */
-function theme_authorize_message($variables) {
- $message = $variables['message'];
- $success = $variables['success'];
- if ($success) {
- $item = array('data' => $message, 'class' => array('success'));
- }
- else {
- $item = array('data' => '' . $message . '', 'class' => array('failure'));
}
- return $item;
}
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..e3c5dbb
--- /dev/null
+++ b/core/modules/system/templates/authorize-report.html.twig
@@ -0,0 +1,23 @@
+{#
+/**
+ * @file
+ * Default theme implementation for authorize.php operation report templates.
+ *
+ * This report displays the results of an operation run via authorize.php.
+ *
+ * Available variables:
+ * - report: A list of result messages.
+ * - attributes: HTML attributes for the element.
+ *
+ * @see template_preprocess_authorize_report()
+ *
+ * @ingroup themeable
+ */
+#}
+{% if report %}
+
+ {% for messages in report %}
+ {{ messages }}
+ {% endfor %}
+
+{% endif %}
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..400495c
--- /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
+ */
+#}
+Installation tasks
+
+{% for task in tasks %}
+ -
+ {{ task.item }}
+ {% if task.status %} ({{ task.status }}){% endif %}
+
+{% endfor %}
+