commit 0463cbf0983f433e31cadf891d175b202d84e910 Author: gnuget Date: Mon May 6 03:41:26 2013 -0500 removing twig table, using theme_table instead diff --git a/core/modules/simpletest/simpletest.pages.inc b/core/modules/simpletest/simpletest.pages.inc index 87acab5..102f992 100644 --- a/core/modules/simpletest/simpletest.pages.inc +++ b/core/modules/simpletest/simpletest.pages.inc @@ -5,8 +5,6 @@ * Page callbacks for simpletest module. */ -use Drupal\Core\Template\Attribute; - /** * List tests arranged in groups that can be selected and run. */ @@ -73,6 +71,13 @@ function template_preprocess_simpletest_test_table(&$variables) { drupal_add_library('simpletest', 'drupal.simpletest'); + // Create header for test selection table. + $header = array( + array('class' => array('select-all')), + array('data' => t('Test'), 'class' => array('simpletest_test')), + array('data' => t('Description'), 'class' => array('simpletest_description')), + ); + // Define the images used to expand/collapse the test groups. $js = array( 'images' => array( @@ -82,25 +87,36 @@ function template_preprocess_simpletest_test_table(&$variables) { ); // Cycle through each test group and create a row. - - $variables['test_groups'] = array(); + $rows = array(); foreach (element_children($table) as $key) { $element = &$table[$key]; - - $variables['test_groups'][$key] = new stdClass(); + $row = array(); // Make the class name safe for output on the page by replacing all // non-word/decimal characters with a dash (-). $test_class = strtolower(trim(preg_replace("/[^\w\d]/", "-", $key))); - $variables['test_groups'][$key]->test_class = $test_class; // Select the right "expand"/"collapse" image, depending on whether the // category is expanded (at least one test selected) or not. $collapsed = !empty($element['#collapsed']); $image_index = $collapsed ? 0 : 1; + // Place-holder for checkboxes to select group of tests. + $row[] = array('id' => $test_class, 'class' => array('simpletest-select-all')); + // Expand/collapse image and group title. - $variables['test_groups'][$key]->label = $key; + $row[] = array( + 'data' => '
' . + '', + 'class' => array('simpletest-group-label'), + ); + + $row[] = array( + 'data' => ' ', + 'class' => array('simpletest-group-description'), + ); + + $rows[] = array('data' => $row, 'class' => array('simpletest-group')); // Add individual tests to group. $current_js = array( @@ -113,40 +129,50 @@ function template_preprocess_simpletest_test_table(&$variables) { // Sorting $element by children's #title attribute instead of by class name. uasort($element, 'element_sort_by_title'); - $variables['test_groups'][$key]->tests = array(); - // Cycle through each test within the current group. foreach (element_children($element) as $test_name) { $test = $element[$test_name]; - $test_data = new stdClass(); - $test_data->attributes = new Attribute(array('class' => array())); - $test_data->id = $test['#id']; + $row = array(); $current_js['testNames'][] = $test['#id']; // Store test title and description so that checkbox won't render them. - $test_data->title = $test['#title']; - $test_data->description = $test['#description']; - unset($test['#description']); + $title = $test['#title']; + $description = $test['#description']; $test['#title_display'] = 'invisible'; // Test name is used to determine what tests to run. $test['#name'] = $test_name; - // Add the checkbox field. - $test_data->field = $test; - - $test_data->attributes['class'][] = $test_class . '-test'; - $test_data->attributes['class'][] = ($collapsed ? 'js-hide' : ''); + $row[] = array( + 'data' => drupal_render($test), + 'class' => array('simpletest-test-select'), + ); + $row[] = array( + 'data' => '', + 'class' => array('simpletest-test-label'), + ); + $row[] = array( + 'data' => '
' . $description . '
', + 'class' => array('simpletest-test-description'), + ); - $variables['test_groups'][$key]->tests[$test_name] = $test_data; + $rows[] = array('data' => $row, 'class' => array($test_class . '-test', ($collapsed ? 'js-hide' : ''))); } $js['simpletest-test-group-' . $test_class] = $current_js; + unset($table[$key]); } // Add js array of settings. drupal_add_js(array('simpleTest' => $js), 'setting'); + + if (empty($rows)) { + $variables['table'] = '' . t('No tests to display.') . ''; + } + else { + $variables['table'] = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'simpletest-form-table'))); + } } /** diff --git a/core/modules/simpletest/templates/simpletest-test-table.html.twig b/core/modules/simpletest/templates/simpletest-test-table.html.twig index f6a94be..7c920e6 100644 --- a/core/modules/simpletest/templates/simpletest-test-table.html.twig +++ b/core/modules/simpletest/templates/simpletest-test-table.html.twig @@ -12,35 +12,4 @@ * @ingroup themeable */ #} - - - - - - - - - - {% for test_group in test_groups %} - - - - - - {% for test in test_group.tests %} - - - - - - {% endfor %} - {% else %} - - - - {% endfor %} - -
{{ 'Test'|t }}{{ 'Description'|t }}
-
- -
 
{{ test.field }}
{{ test.description }}
{{ 'No tests to display.'|t }}
+{{ table }}