diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 3b156a5..cfbb818 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1770,17 +1770,10 @@ function drupal_common_theme() { 'maintenance_task_list' => array( 'variables' => array('items' => NULL, 'active' => NULL, 'variant' => NULL), ), - 'authorize_message' => array( - 'variables' => array('message' => NULL, 'success' => TRUE), - 'function' => 'theme_authorize_message', - 'path' => 'core/includes', - 'file' => 'theme.maintenance.inc', - ), 'authorize_report' => array( - 'variables' => array('messages' => array()), - 'function' => 'theme_authorize_report', - 'path' => 'core/includes', - 'file' => 'theme.maintenance.inc', + 'variables' => ['messages' => [], 'report' => [], 'attributes' => []], + 'includes' => ['core/includes/theme.maintenance.inc'], + 'template' => 'authorize-report', ), // From pager.inc. 'pager' => array( diff --git a/core/includes/theme.maintenance.inc b/core/includes/theme.maintenance.inc index 16779af..68aff41 100644 --- a/core/includes/theme.maintenance.inc +++ b/core/includes/theme.maintenance.inc @@ -100,64 +100,36 @@ function _drupal_maintenance_theme() { } /** - * Returns HTML for a results report of an operation run by authorize.php. + * Prepares variables for authorize.php operation report templates. * - * @param $variables + * This report displays the results of an operation run via authorize.php. + * + * 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 = ''; if (!empty($messages)) { - $output .= '
'; foreach ($messages as $heading => $logs) { - $items = array(); + $items = []; foreach ($logs as $number => $log_message) { if ($number === '#abort') { continue; } - $authorize_message = array( - '#theme' => 'authorize_message', - '#message' => $log_message['message'], - '#success' => $log_message['success'], - ); - $items[] = drupal_render($authorize_message); + $class = 'authorize-results__' . ($log_message['success'] ? 'success' : 'failure'); + $items[] = [ + '#wrapper_attributes' => ['class' => [$class]], + '#markup' => $log_message['message'], + ]; } - $item_list = array( + $variables['report'][] = [ '#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. - * It's the caller's responsibility to ensure this string contains no - * dangerous HTML such as SCRIPT tags. - * - 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' => array('#markup' => $message), 'class' => array('authorize-results__success')); - } - else { - $item = array('data' => array('#markup' => $message), 'class' => array('authorize-results__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..95c0809 --- /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 %}