diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 11b72a5..1223930 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -170,39 +170,49 @@ function template_preprocess_status_report(&$variables) { } /** - * Returns HTML for the modules form. + * Prepares variables for the module details templates. + * + * Default template: system-modules-details.html.twig. * * @param $variables * An associative array containing: - * - form: A render element representing the form. - * - * @ingroup themeable + * - form: A render element representing the form. The main form element + * represents a package, and child elements of the form are individual + * projects. Each project (or module) is an associative array containing the + * following elements: + * - name: The name of the module. + * - description: (optional) A description of the module. + * - version: (optional) The version of the module. + * - links: (optional) Administration links provided by the module. + * - enable: A checkbox for enabling the module. + * - #requires: (optional) A list of modules that the project requires. + * - #required_by: (optional) A list of modules that require the project. */ -function theme_system_modules_details($variables) { +function template_preprocess_system_modules_details(&$variables) { $form = $variables['form']; - // Individual table headers. - $rows = array(); + $header = array( + 'installed' => $form['#header'][0]['data'], + 'name' => $form['#header'][1]['data'], + 'description' => $form['#header'][1]['data'], + ); + + $modules = array(); // Iterate through all the modules, which are children of this element. foreach (Element::children($form) as $key) { // Stick the key into $module for easier access. $module = $form[$key]; - // Create the row for the table. - $row = array(); - // Add the checkbox into the first cell. - unset($module['enable']['#title']); - $module['#requires'] = array_filter($module['#requires']); - $module['#required_by'] = array_filter($module['#required_by']); - $requires = !empty($module['#requires']); - $required_by = !empty($module['#required_by']); - $version = !empty($module['version']['#markup']); + // Create a new array for this module. + $item = array(); - $row[] = array('class' => array('checkbox'), 'data' => drupal_render($module['enable'])); + // Add the checkbox. + unset($module['enable']['#title']); + $item['checkbox'] = $module['enable']; // Add the module label and expand/collapse functionality. $id = Html::getUniqueId('module-' . $key); - $col2 = [ + $label = [ '#type' => 'inline_template', '#template' => '', '#context' => [ @@ -211,21 +221,29 @@ function theme_system_modules_details($variables) { 'module_name' => $module['name'], ], ]; - $row[] = ['class' => ['module'], 'data' => $col2]; + $item['name'] = $label; - // Add the description, along with any modules it requires. $description = ''; - $description .= '
'; + // Begin building out the description content for the module details. $renderer = \Drupal::service('renderer'); $machine_name_render = [ '#prefix' => '', '#plain_text' => $key, - '#suffix' => ' '', ]; - $description .= '
' . t('Machine name: @machine-name', array('@machine-name' => $renderer->render($machine_name_render))) . '
'; + $description .= t('Machine name: @machine-name', array('@machine-name' => $renderer->render($machine_name_render))); + + $version = !empty($module['version']['#markup']); if ($version) { $description .= '
' . t('Version: @module-version', array('@module-version' => $renderer->render($module['version']))) . '
'; } + + $module['#requires'] = array_filter($module['#requires']); + $module['#required_by'] = array_filter($module['#required_by']); + + $requires = !empty($module['#requires']); + $required_by = !empty($module['#required_by']); + if ($requires) { $requires = [ '#theme' => 'item_list', @@ -263,17 +281,14 @@ function theme_system_modules_details($variables) { '#attributes' => array('id' => $module['enable']['#id'] . '-description'), '#description' => $description, ); - $row[] = ['class' => ['description', 'expand'], 'data' => $details]; + $item['details'] = $details; - $rows[] = $module['#attributes'] + array('data' => $row); + $item['attributes'] = new Attribute($module['#attributes']); + $modules[] = $item; } - $table = array( - '#type' => 'table', - '#header' => $form['#header'], - '#rows' => $rows, - ); - return drupal_render($table); + $variables['header'] = $header; + $variables['modules'] = $modules; } /** diff --git a/core/modules/system/system.module b/core/modules/system/system.module index a8477d3..9be5618 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -186,7 +186,6 @@ function system_theme() { 'system_modules_details' => array( 'render element' => 'form', 'file' => 'system.admin.inc', - 'function' => 'theme_system_modules_details', ), 'system_modules_uninstall' => array( 'render element' => 'form', diff --git a/core/modules/system/templates/system-modules-details.html.twig b/core/modules/system/templates/system-modules-details.html.twig new file mode 100644 index 0000000..dafd807 --- /dev/null +++ b/core/modules/system/templates/system-modules-details.html.twig @@ -0,0 +1,54 @@ +{# +/** + * @file + * Default theme implementation for the modules listing page. + * + * Displays a list of all packages in a project. + * + * Available variables: + * - header: Table header containing the following cells: + * - installed: A localized string for the title of the Installed column. + * - namet: 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 enabling the module. + * - name: The name of the module. + * - details: Other details about the module. + * + * @see template_preprocess_system_modules_details() + * + * @ingroup themeable + */ +#} + + + + + + + + + + {% for module in modules %} + {% set zebra = cycle(['odd', 'even'], loop.index0) %} + + + + + + {% endfor %} + +
+ {{ header.installed }} + + {{ header.name }} + + {{ header.description }} +
+ {{ module.checkbox }} + + {{- module.name -}} + + {{ module.details }} +
\ No newline at end of file