diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 11b72a5..88feb0e 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -277,83 +277,59 @@ function theme_system_modules_details($variables) { } /** - * Returns HTML for a table of currently disabled modules. + * Prepares variables for the module uninstall template. * + * @todo * @param $variables * An associative array containing: * - form: A render element representing the form. * * @ingroup themeable */ -function theme_system_modules_uninstall($variables) { +function template_preprocess_system_modules_uninstall(&$variables) { $form = $variables['form']; + $variables['modules'] = []; + + $variables['empty'] = t('No modules are available to uninstall.'); + + // Table headers. + $variables['header'] = array( + 'uninstall' => t('Uninstall'), + 'name' => t('Name'), + 'description' => t('Description'), + ); // No theming for the confirm form. if (isset($form['confirm'])) { return drupal_render($form); } - // Table headers. - $header = array(t('Uninstall'), - t('Name'), - t('Description'), - ); + // Iterate through all the modules, which are children of this element. + foreach (Element::children($form['modules']) as $key) { + $module = $form['modules'][$key]; + + $module['checkbox'] = $form['uninstall'][$key]; + $module['checkbox_id'] = $form['uninstall'][$key]['#id']; - // Display table. - $rows = array(); - foreach (Element::children($form['modules']) as $module) { - $disabled_header = ''; - $disabled_reasons = ''; // Add the modules requiring the module in question as a validation reason. - if (!empty($form['modules'][$module]['#required_by'])) { - $form['modules'][$module]['#validation_reasons'][] = \Drupal::translation()->translate('Required by: @modules', array('@modules' => implode(', ',$form['modules'][$module]['#required_by']))); + if (!empty($module['#required_by'])) { + $module['#validation_reasons'][] = \Drupal::translation() + ->translate('Required by: @modules', array('@modules' => implode(', ', $module['#required_by']))); } - if (!empty($form['modules'][$module]['#validation_reasons'])) { - $disabled_reasons = [ + if (!empty($module['#validation_reasons'])) { + $module['disabled_reasons'] = [ '#theme' => 'item_list', - '#items' => $form['modules'][$module]['#validation_reasons'], + '#items' => $module['#validation_reasons'], ]; - $disabled_reasons = drupal_render($disabled_reasons); - $disabled_header = \Drupal::translation()->formatPlural(count($form['modules'][$module]['#validation_reasons']), + $module['disabled_header'] = \Drupal::translation()->formatPlural(count($module['#validation_reasons']), 'The following reason prevents @module from being uninstalled:', 'The following reasons prevents @module from being uninstalled:', - array('@module' => $form['modules'][$module]['#module_name'])); + array('@module' => $module['#module_name'])); } - $rows[] = array( - array('data' => drupal_render($form['uninstall'][$module]), 'align' => 'center'), - array( - 'data' => array( - '#type' => 'inline_template', - '#template' => '', - '#context' => array('module_id' => $form['uninstall'][$module]['#id'], 'module_name' => drupal_render($form['modules'][$module]['name'])), - ) - ), - array( - 'data' => array( - '#type' => 'inline_template', - '#template' => '{{ module_description }}{% if disabled_header is not empty %}
{{ disabled_header }}{{ disabled_reasons }}
{% endif %}', - '#context' => array( - 'module_description' => drupal_render($form['modules'][$module]['description']), - 'disabled_header' => $disabled_header, - 'disabled_reasons' => $disabled_reasons, - ), - ), - 'class' => array('description'), - ), - ); - } - $table = array( - '#type' => 'table', - '#header' => $header, - '#rows' => $rows, - '#empty' => t('No modules are available to uninstall.'), - ); - $output = drupal_render($form['filters']); - $output .= drupal_render($table); - $output .= drupal_render_children($form); - - return $output; + $module['attributes'] = new Attribute($module['#attributes']); + $variables['modules'][] = $module; + } } /** diff --git a/core/modules/system/system.module b/core/modules/system/system.module index a8477d3..80af03d 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -191,7 +191,6 @@ function system_theme() { 'system_modules_uninstall' => array( 'render element' => 'form', 'file' => 'system.admin.inc', - 'function' => 'theme_system_modules_uninstall', ), 'status_report' => array( 'variables' => array('requirements' => NULL), diff --git a/core/modules/system/templates/system-modules-uninstall.html.twig b/core/modules/system/templates/system-modules-uninstall.html.twig new file mode 100644 index 0000000..f357b48 --- /dev/null +++ b/core/modules/system/templates/system-modules-uninstall.html.twig @@ -0,0 +1,77 @@ +{# +/** + * @file + * Default theme implementation for the modules uninstall page. + * + * Available variables: + * - form: + * - filters: + * - actions: + * - header: Table header containing the following cells: + * - uninstall: A localized string for the title of the 'uninstall' column. + * - name: A localized string for the title of the 'name' column. + * - description: A localized string for the title of the 'description' + * column. + * - modules: Contains multiple module instances. Each module contains: + * - attributes: Attributes on the row. + * - checkbox: A checkbox for uninstalling the module. + * - name: The human-readable name of the module. + * - id: A unqiue id for interacting with the details element. + * - uninstall_id: A unique id for interacting with the checkbox element. + * - description: The description of the module. + * - machine_name: The module's machine name. + * - disabled_header: (optional) A localized string for . + * - disabled_reasons: (optional) A list of reasons why this module cannot be + * uninstalled. + * + * @see template_preprocess_system_modules_uninstall() + * + * @ingroup themeable + */ +#} + +{{ form.filters }} + + + + + + + + + + + {% for module in modules %} + {% set zebra = cycle(['odd', 'even'], loop.index0) %} + + + + + {% else %} + + + + {% endfor %} + +
+ {{ header.uninstall }} + + {{ header.name }} + + {{ header.description }} +
+ {{ module.checkbox }} + + + + {{ module.description }} + {% if module.disabled_header is not empty %} +
{{ module.disabled_header }}{{ module.disabled_reasons }}
+ {% endif %} +
{{ empty }}
+ +{{ form|without( + 'filters', + 'modules', + 'uninstall' +) }}