diff --git a/core/modules/system/src/Tests/Form/ModulesListFormWebTest.php b/core/modules/system/src/Tests/Form/ModulesListFormWebTest.php index 489f6ff..dddf6d3 100644 --- a/core/modules/system/src/Tests/Form/ModulesListFormWebTest.php +++ b/core/modules/system/src/Tests/Form/ModulesListFormWebTest.php @@ -49,6 +49,11 @@ public function testModuleListForm() { // Check that system_test's help link was rendered correctly. $this->assertFieldByXPath("//a[contains(@href, '/admin/help/system_test') and @title='Help']"); + + // Ensure that the Testing module's machine name is printed. Testing module + // is used because its machine name is different than its human readable + // name. + $this->assertText('simpletest'); } } diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 11b72a5..101b154 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -170,110 +170,80 @@ 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. + * - 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. + * - enable: A checkbox for enabling the module. + * - description: A description of the module. + * - version: The version of the module. + * - links: Administration links provided by the module. + * - #requires: A list of modules that the project requires. + * - #required_by: A list of modules that require the project. + * - #attributes: A list of attributes for the module wrapper. * - * @ingroup themeable + * @see \Drupal\system\Form\ModulesListForm */ -function theme_system_modules_details($variables) { +function template_preprocess_system_modules_details(&$variables) { $form = $variables['form']; + $variables['header'] = [ + 'installed' => $form['#header'][0]['data'], + 'name' => $form['#header'][1]['data'], + 'description' => $form['#header'][2]['data'], + ]; - // Individual table headers. - $rows = array(); + $variables['modules'] = []; // 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']); - - $row[] = array('class' => array('checkbox'), 'data' => drupal_render($module['enable'])); + // Add the checkbox to allow installing new modules and to show the + // installation status of the module. + $module['checkbox'] = $module['enable']; // Add the module label and expand/collapse functionality. $id = Html::getUniqueId('module-' . $key); - $col2 = [ - '#type' => 'inline_template', - '#template' => '', - '#context' => [ - 'id' => $id, - 'enable_id' => $module['enable']['#id'], - 'module_name' => $module['name'], - ], - ]; - $row[] = ['class' => ['module'], 'data' => $col2]; + $module['id'] = $id; + $module['enable_id'] = $module['enable']['#id']; + $module['machine_name'] = $key; - // Add the description, along with any modules it requires. - $description = ''; - $description .= '
+ {{ header.installed }} + | ++ {{ header.name }} + | ++ {{ header.description }} + | +
---|---|---|
+ {{ module.checkbox }} + | ++ + | +
+
+
+ {{ module.description }}+
+
+
+
+ {{ 'Machine name: @machine-name'|t({'@machine-name': module.machine_name}) }}
+ {% if module.version %}
+ {{ 'Version: @module-version'|t({'@module-version': module.version|render}) }}
+ {% endif %}
+ {% if module.requires %}
+ {{ module.requires }}
+ {% endif %}
+ {% if module.required_by %}
+ {{ module.required_by }}
+ {% endif %}
+ {% if module.links %}
+
+ {% for link in module.links %}
+ {{ link }}
+ {% endfor %}
+
+ {% endif %}
+ |
+