diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc index a3500fd..f1cd93a 100644 --- a/core/modules/language/language.admin.inc +++ b/core/modules/language/language.admin.inc @@ -356,7 +356,6 @@ function language_negotiation_configure_form() { $form = array( '#submit' => array('language_negotiation_configure_form_submit'), - '#theme' => 'language_negotiation_configure_form', '#language_types' => language_types_get_configurable(FALSE), '#language_types_info' => language_types_info(), '#language_negotiation_info' => language_negotiation_info(), @@ -382,12 +381,20 @@ function language_negotiation_configure_form_table(&$form, $type) { $info = $form['#language_types_info'][$type]; $table_form = array( - '#title' => t('@type language detection', array('@type' => $info['name'])), - '#tree' => TRUE, - '#description' => $info['description'], + '#prefix' => '

' . t('@type language detection', array('@type' => $info['name'])) . '

' . + '
' . $info['description'] . '
', + '#type' => 'table', '#language_negotiation_info' => array(), - '#show_operations' => FALSE, - 'weight' => array('#tree' => TRUE), + '#header' => array( + t('Detection method'), + t('Description'), + t('Enabled'), + t('Weight'), + ), + '#attributes' => array('id' => "language-negotiation-methods-$type"), + '#tabledrag' => array( + array('order', 'sibling', "language-method-weight-$type"), + ), ); $negotiation_info = $form['#language_negotiation_info']; @@ -404,6 +411,7 @@ function language_negotiation_configure_form_table(&$form, $type) { // Order methods list by weight. asort($methods_weight); + $show_operations = FALSE; foreach ($methods_weight as $method_id => $weight) { // A language method might be no more available if the defining module has // been disabled after the last configuration saving. @@ -422,113 +430,63 @@ function language_negotiation_configure_form_table(&$form, $type) { $table_form['#language_negotiation_info'][$method_id] = $method; $method_name = check_plain($method['name']); - $table_form['weight'][$method_id] = array( - '#type' => 'weight', - '#title' => t('Weight for !title language detection method', array('!title' => drupal_strtolower($method_name))), - '#title_display' => 'invisible', - '#default_value' => $weight, - '#attributes' => array('class' => array("language-method-weight-$type")), - '#delta' => 20, + $table_form[$method_id]['#attributes']['class'][] = 'draggable'; + $table_form[$method_id]['title'] = array( + '#prefix' => '', + '#markup' => $method_name, + '#suffix' => '', ); - $table_form['title'][$method_id] = array('#markup' => $method_name); + $table_form[$method_id]['description'] = array('#markup' => filter_xss_admin($method['description'])); - $table_form['enabled'][$method_id] = array( + $table_form[$method_id]['enabled'] = array( '#type' => 'checkbox', '#title' => t('Enable !title language detection method', array('!title' => drupal_strtolower($method_name))), '#title_display' => 'invisible', '#default_value' => $enabled, ); if ($method_id === LANGUAGE_NEGOTIATION_SELECTED) { - $table_form['enabled'][$method_id]['#default_value'] = TRUE; - $table_form['enabled'][$method_id]['#attributes'] = array('disabled' => 'disabled'); + $table_form[$method_id]['enabled']['#default_value'] = TRUE; + $table_form[$method_id]['enabled']['#attributes'] = array('disabled' => 'disabled'); } - $table_form['description'][$method_id] = array('#markup' => filter_xss_admin($method['description'])); + $table_form[$method_id]['weight'] = array( + '#type' => 'weight', + '#title' => t('Weight for !title language detection method', array('!title' => drupal_strtolower($method_name))), + '#title_display' => 'invisible', + '#default_value' => $weight, + '#attributes' => array('class' => array("language-method-weight-$type")), + '#delta' => 20, + ); $config_op = array(); if (isset($method['config'])) { - $config_op['configure'] = array( - 'title' => t('Configure'), - 'href' => $method['config'], + $table_form[$method_id]['operation'] = array( + '#type' => 'operations', + '#links' => array( + 'configure' => array( + 'title' => t('Configure'), + 'href' => $method['config'], + ), + ), ); - // If there is at least one operation enabled show the operation column. - $table_form['#show_operations'] = TRUE; + $show_operations = TRUE; } - $table_form['operation'][$method_id] = array( - '#type' => 'operations', - '#links' => $config_op, - ); } } - $form[$type] = $table_form; -} + if ($show_operations) { + $table_form['#header'][] = t('Operations'); -/** - * Returns HTML for the language negotiation configuration form. - * - * @param $variables - * An associative array containing: - * - form: A render element representing the form. - * - * @ingroup themeable - */ -function theme_language_negotiation_configure_form($variables) { - $form = $variables['form']; - $output = ''; - - foreach ($form['#language_types'] as $type) { - $rows = array(); - $title = '

' . $form[$type]['#title'] . '

'; - $description = '
' . $form[$type]['#description'] . '
'; - - foreach ($form[$type]['title'] as $id => $element) { - // Do not take form control structures. - if (is_array($element) && element_child($id)) { - $row = array( - 'data' => array( - '' . drupal_render($form[$type]['title'][$id]) . '', - drupal_render($form[$type]['description'][$id]), - drupal_render($form[$type]['enabled'][$id]), - drupal_render($form[$type]['weight'][$id]), - ), - 'class' => array('draggable'), - ); - if ($form[$type]['#show_operations']) { - $row['data'][] = drupal_render($form[$type]['operation'][$id]); - } - $rows[] = $row; + // Ensure each row as an operation column. + foreach ($methods_weight as $method_id => $weight) { + if (isset($table_form[$method_id]) && !isset($table_form[$method_id]['operation'])) { + $table_form[$method_id]['operation'] = array(); } } - - $header = array( - array('data' => t('Detection method')), - array('data' => t('Description')), - array('data' => t('Enabled')), - array('data' => t('Weight')), - ); - - // If there is at least one operation enabled show the operation column. - if ($form[$type]['#show_operations']) { - $header[] = array('data' => t('Operations')); - } - - $variables = array( - 'header' => $header, - 'rows' => $rows, - 'attributes' => array('id' => "language-negotiation-methods-$type"), - ); - $table = theme('table', $variables); - $table .= drupal_render_children($form[$type]); - - drupal_add_tabledrag("language-negotiation-methods-$type", 'order', 'sibling', "language-method-weight-$type"); - - $output .= '
' . $title . $description . $table . '
'; } - $output .= drupal_render_children($form); - return $output; + $form[$type] = $table_form; } /** @@ -539,13 +497,12 @@ function language_negotiation_configure_form_submit($form, &$form_state) { foreach ($configurable_types as $type) { $method_weights = array(); - $enabled_methods = $form_state['values'][$type]['enabled']; - $enabled_methods[LANGUAGE_NEGOTIATION_SELECTED] = TRUE; - $method_weights_input = $form_state['values'][$type]['weight']; + $method_weights_input = array(); - foreach ($method_weights_input as $method_id => $weight) { - if ($enabled_methods[$method_id]) { - $method_weights[$method_id] = $weight; + foreach ($form_state['values'][$type] as $method_id => $values) { + $method_weights_input[$method_id] = $values['weight']; + if ($values['enabled'] || $method_id == LANGUAGE_NEGOTIATION_SELECTED) { + $method_weights[$method_id] = $values['weight']; } } @@ -785,13 +742,20 @@ function language_negotiation_configure_browser_form($form, &$form_state) { $default = key($existing_languages); $language_options = array( t('Existing languages') => $existing_languages, - t('Languages not yet added') => language_admin_predefined_list() + t('Languages not yet added') => language_admin_predefined_list(), ); } $form['mappings'] = array( - '#tree' => TRUE, - '#theme' => 'language_negotiation_configure_browser_form_table', + '#type' => 'table', + '#header' => array( + t('Browser language code'), + t('Drupal language'), + t('Operations'), + ), + '#attributes' => array( + 'id' => 'lang-neg-browser', + ), ); $mappings = language_get_browser_drupal_langcode_mappings(); @@ -809,6 +773,18 @@ function language_negotiation_configure_browser_form($form, &$form_state) { '#default_value' => $drupal_langcode, '#required' => TRUE, ), + 'operations' => array( + '#type' => 'operations', + '#links' => array( + array( + 'title' => t('Delete'), + 'href' => "admin/config/regional/language/detection/browser/delete/$browser_langcode", + 'attributes' => array( + 'class' => array('image-style-link'), + ), + ), + ), + ), ); } @@ -843,51 +819,6 @@ function language_negotiation_configure_browser_form($form, &$form_state) { } /** - * Theme browser configuration form as table. - * - * @param $variables - * An associative array containing: - * - form: A render element representing the form. - * - * @ingroup themeable - */ -function theme_language_negotiation_configure_browser_form_table($variables) { - $form = $variables['form']; - $rows = array(); - foreach (element_children($form, TRUE) as $key) { - $row = array(); - $row[] = drupal_render($form[$key]['browser_langcode']); - $row[] = drupal_render($form[$key]['drupal_langcode']); - $links = array(); - $links['delete'] = array( - 'title' => t('Delete'), - 'href' => "admin/config/regional/language/detection/browser/delete/$key", - 'attributes' => array( - 'class' => array('image-style-link'), - ), - ); - $row[] = array( - 'data' => array( - '#type' => 'operations', - '#links' => $links, - ), - ); - - $rows[] = $row; - } - - $header = array( - t('Browser language code'), - t('Drupal language'), - t('Operations'), - ); - - $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'lang-neg-browser'))); - - return $output; -} - -/** * Browser language negotiation form validation. */ function language_negotiation_configure_browser_form_validate($form, &$form_state) { @@ -1018,21 +949,45 @@ function language_content_settings_form(array $form, array $form_state, array $s foreach ($supported as $entity_type) { $info = $entity_info[$entity_type]; + // Table form types do not support states, but container types do, so the + // table has to be wrapped in a container form type. $form['settings'][$entity_type] = array( - '#title' => $labels[$entity_type], '#type' => 'container', '#entity_type' => $entity_type, - '#theme' => 'language_content_settings_table', - '#bundle_label' => isset($info['bundle_label']) ? $info['bundle_label'] : $labels[$entity_type], '#states' => array( 'visible' => array( ':input[name="entity_types[' . $entity_type . ']"]' => array('checked' => TRUE), ), ), ); + $form['settings'][$entity_type]['table'] = array( + '#prefix' => '

' . $labels[$entity_type] . '

', + '#type' => 'table', + '#entity_type' => $entity_type, + '#states' => array( + 'visible' => array( + ':input[name="entity_types[' . $entity_type . ']"]' => array('checked' => TRUE), + ), + ), + '#header' => array( + array( + 'data' => isset($info['bundle_label']) ? $info['bundle_label'] : $labels[$entity_type], + 'class' => array('bundle'), + ), + array( + 'data' => t('Configuration'), + 'class' => array('operations'), + ), + ), + ); foreach (entity_get_bundles($entity_type) as $bundle => $bundle_info) { - $form['settings'][$entity_type][$bundle]['settings'] = array( + $form['settings'][$entity_type]['table'][$bundle]['label'] = array( + '#prefix' => '', + '#markup' => $bundle_info['label'], + ); + $form['settings'][$entity_type]['table'][$bundle]['settings'] = array( '#type' => 'item', '#label' => $bundle_info['label'], 'language' => array( @@ -1057,74 +1012,13 @@ function language_content_settings_form(array $form, array $form_state, array $s } /** - * Implements hook_preprocess_HOOK() for theme_language_content_settings_table(). - */ -function template_preprocess_language_content_settings_table(&$variables) { - // Add a render element representing the bundle language settings table. - $element = $variables['element']; - - $header = array( - array( - 'data' => $element['#bundle_label'], - 'class' => array('bundle'), - ), - array( - 'data' => t('Configuration'), - 'class' => array('operations'), - ), - ); - - $rows = array(); - foreach (element_children($element) as $bundle) { - $rows[$bundle] = array( - 'data' => array( - array( - 'data' => array( - '#prefix' => '', - '#markup' => check_plain($element[$bundle]['settings']['#label']), - ), - 'class' => array('bundle'), - ), - array( - 'data' => $element[$bundle]['settings'], - 'class' => array('operations'), - ), - ), - 'class' => array('bundle-settings'), - ); - } - - $variables['build'] = array( - '#title' => $element['#title'], - '#header' => $header, - '#rows' => $rows, - '#theme' => 'table', - ); -} - -/** - * Returns HTML for an administration settings table. - * - * @param array $variables - * An associative array containing: - * - build: A render element representing a table of bundle content language - * settings for a particular entity type. - * - * @ingroup themable - */ -function theme_language_content_settings_table($variables) { - return '

' . $variables['build']['#title'] . '

' . drupal_render($variables['build']); -} - -/** * Form submission handler for language_content_settings_form(). */ function language_content_settings_form_submit(array $form, array &$form_state) { $entity_types = $form_state['values']['entity_types']; $settings = &$form_state['values']['settings']; foreach ($settings as $entity_type => $entity_settings) { - foreach ($entity_settings as $bundle => $bundle_settings) { + foreach ($entity_settings['table'] as $bundle => $bundle_settings) { language_save_default_configuration($entity_type, $bundle, $bundle_settings['settings']['language']); } } diff --git a/core/modules/language/language.module b/core/modules/language/language.module index 81b9715..1961c12 100644 --- a/core/modules/language/language.module +++ b/core/modules/language/language.module @@ -183,25 +183,6 @@ function language_permission() { } /** - * Implements hook_theme(). - */ -function language_theme() { - return array( - 'language_negotiation_configure_form' => array( - 'render element' => 'form', - ), - 'language_negotiation_configure_browser_form_table' => array( - 'render element' => 'form', - 'file' => 'language.admin.inc', - ), - 'language_content_settings_table' => array( - 'render element' => 'element', - 'file' => 'language.admin.inc', - ), - ); -} - -/** * Returns a list of supported entity types. * * @return array diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php index 8aea763..bd58c9a 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageNegotiationInfoTest.php @@ -63,11 +63,11 @@ function testInfoAlterations() { $test_type = 'test_language_type'; $interface_method_id = LANGUAGE_NEGOTIATION_INTERFACE; $test_method_id = 'test_language_negotiation_method'; - $form_field = $type . '[enabled]['. $interface_method_id .']'; + $form_field = $type . '['. $interface_method_id .'][enabled]'; $edit = array( $form_field => TRUE, - $type . '[enabled][' . $test_method_id . ']' => TRUE, - $test_type . '[enabled][' . $test_method_id . ']' => TRUE, + $type . '[' . $test_method_id . '][enabled]' => TRUE, + $test_type . '[' . $test_method_id . '][enabled]' => TRUE, ); $this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings')); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php index 89a1bd6..f8c76df 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguagePathMonolingualTest.php @@ -55,7 +55,7 @@ function setUp() { $this->assertEqual(language_default()->langcode, 'fr', 'French is the default language'); // Set language detection to URL. - $edit = array('language_interface[enabled][language-url]' => TRUE); + $edit = array('language_interface[language-url][enabled]' => TRUE); $this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings')); // Force languages to be initialized. diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php index ac834d1..11b122b 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageSwitchingTest.php @@ -51,7 +51,7 @@ function testLanguageBlock() { $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); // Enable URL language detection and selection. - $edit = array('language_interface[enabled][language-url]' => '1'); + $edit = array('language_interface[language-url][enabled]' => '1'); $this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings')); // Assert that the language switching block is displayed on the frontpage. diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php index e614da2..2f6f25c 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUILanguageNegotiationTest.php @@ -395,10 +395,10 @@ function testUrlLanguageFallback() { // Enable browser and URL language detection. $edit = array( - 'language_interface[enabled][language-browser]' => TRUE, - 'language_interface[enabled][language-url]' => TRUE, - 'language_interface[weight][language-browser]' => -8, - 'language_interface[weight][language-url]' => -10, + 'language_interface[language-browser][enabled]' => TRUE, + 'language_interface[language-url][enabled]' => TRUE, + 'language_interface[language-browser][weight]' => -8, + 'language_interface[language-url][weight]' => -10, ); $this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings')); $this->drupalGet('admin/config/regional/language/detection'); @@ -437,8 +437,8 @@ function testLanguageDomain() { // Enable browser and URL language detection. $edit = array( - 'language_interface[enabled][language-url]' => TRUE, - 'language_interface[weight][language-url]' => -10, + 'language_interface[language-url][enabled]' => TRUE, + 'language_interface[language-url][weight]' => -10, ); $this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings')); diff --git a/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php b/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php index 3effed4..3742e2d 100644 --- a/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php +++ b/core/modules/language/lib/Drupal/language/Tests/LanguageUrlRewritingTest.php @@ -42,7 +42,7 @@ function setUp() { $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); // Enable URL language detection and selection. - $edit = array('language_interface[enabled][language-url]' => 1); + $edit = array('language_interface[language-url][enabled]' => 1); $this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings')); // Reset static caching. diff --git a/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php b/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php index ff16e61..193d690 100644 --- a/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/System/DateFormatsLanguageTest.php @@ -79,17 +79,17 @@ function testLocalizeDateFormats() { $this->drupalGet('admin/config/regional/date-time/locale'); $this->assertText('French', 'Configured languages appear.'); $edit = array( - 'date_format_long' => 'example_style_fr', - 'date_format_medium' => 'example_style_fr', - 'date_format_short' => 'example_style_fr', + 'date_formats[long][pattern]' => 'example_style_fr', + 'date_formats[medium][pattern]' => 'example_style_fr', + 'date_formats[short][pattern]' => 'example_style_fr', ); $this->drupalPost('admin/config/regional/date-time/locale/fr/edit', $edit, t('Save configuration')); $this->assertText(t('Configuration saved.'), 'French date formats updated.'); $edit = array( - 'date_format_long' => 'example_style_en', - 'date_format_medium' => 'example_style_en', - 'date_format_short' => 'example_style_en', + 'date_formats[long][pattern]' => 'example_style_en', + 'date_formats[medium][pattern]' => 'example_style_en', + 'date_formats[short][pattern]' => 'example_style_en', ); $this->drupalPost('admin/config/regional/date-time/locale/en/edit', $edit, t('Save configuration')); $this->assertText(t('Configuration saved.'), 'English date formats updated.'); diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 4a4ba0e..c4a6517 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -1291,20 +1291,23 @@ function system_modules_uninstall($form, $form_state = NULL) { if (!empty($disabled_modules)) { $profile = drupal_get_profile(); uasort($disabled_modules, 'system_sort_modules_by_info_name'); - $form['uninstall'] = array('#tree' => TRUE); + $form['uninstall'] = array( + '#type' => 'table', + '#header' => array(t('Uninstall'), t('Name'), t('Description')), + '#empty' => t('There are no items yet. Disable a module', array( + '@add-url' => url('admin/modules'), + )), + '#tableselect' => TRUE, + ); foreach ($disabled_modules as $module) { $module_name = $module->info['name'] ? $module->info['name'] : $module->name; - $form['modules'][$module->name]['#module_name'] = $module_name; - $form['modules'][$module->name]['name']['#markup'] = $module_name; - $form['modules'][$module->name]['description']['#markup'] = t($module->info['description']); - $form['uninstall'][$module->name] = array( - '#type' => 'checkbox', - '#title' => t('Uninstall @module module', array('@module' => $module_name)), - '#title_display' => 'invisible', - ); + $form['uninstall'][$module->name]['name']['#markup'] = $module_name; + $form['uninstall'][$module->name]['description']['#markup'] = t($module->info['description']); + // All modules which depend on this one must be uninstalled first, before // we can allow this module to be uninstalled. (The installation profile // is excluded from this list.) + $required_modules = array(); foreach (array_keys($module->required_by) as $dependent) { if ($dependent != $profile && drupal_get_installed_schema_version($dependent) != SCHEMA_UNINSTALLED) { $dependent_name = isset($all_modules[$dependent]->info['name']) ? $all_modules[$dependent]->info['name'] : $dependent; @@ -1312,11 +1315,24 @@ function system_modules_uninstall($form, $form_state = NULL) { $form['uninstall'][$module->name]['#disabled'] = TRUE; } } + if (!empty($required_modules)) { + $disabled_message = format_plural(count($required_modules), + 'To uninstall @module, the following module must be uninstalled first: @required_modules', + 'To uninstall @module, the following modules must be uninstalled first: @required_modules', + array('@module' => $module_name, '@required_modules' => implode(', ', $required_modules))); + $disabled_message = '
' . $disabled_message . '
'; + } + else { + $disabled_message = ''; + } + $form['uninstall'][$module->name]['uninstall']['#markup'] = t($disabled_message); + } $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array( '#type' => 'submit', '#value' => t('Uninstall'), + '#tableselect' => TRUE, ); $form['#action'] = url('admin/modules/uninstall/confirm'); } @@ -2448,55 +2464,6 @@ function theme_system_modules_incompatible($variables) { } /** - * Returns HTML for a table of currently disabled modules. - * - * @param $variables - * An associative array containing: - * - form: A render element representing the form. - * - * @ingroup themeable - */ -function theme_system_modules_uninstall($variables) { - $form = $variables['form']; - - // No theming for the confirm form. - if (isset($form['confirm'])) { - return drupal_render($form); - } - - // Table headers. - $header = array(t('Uninstall'), - t('Name'), - t('Description'), - ); - - // Display table. - $rows = array(); - foreach (element_children($form['modules']) as $module) { - if (!empty($form['modules'][$module]['#required_by'])) { - $disabled_message = format_plural(count($form['modules'][$module]['#required_by']), - 'To uninstall @module, the following module must be uninstalled first: @required_modules', - 'To uninstall @module, the following modules must be uninstalled first: @required_modules', - array('@module' => $form['modules'][$module]['#module_name'], '@required_modules' => implode(', ', $form['modules'][$module]['#required_by']))); - $disabled_message = '
' . $disabled_message . '
'; - } - else { - $disabled_message = ''; - } - $rows[] = array( - array('data' => drupal_render($form['uninstall'][$module]), 'align' => 'center'), - '', - array('data' => drupal_render($form['modules'][$module]['description']) . $disabled_message, 'class' => array('description')), - ); - } - - $output = theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No modules are available to uninstall.'))); - $output .= drupal_render_children($form); - - return $output; -} - -/** * Returns HTML for the Appearance page. * * @param $variables @@ -2861,12 +2828,23 @@ function system_date_format_localize_form($form, &$form_state, $langcode) { } } + $form['date_formats'] = array( + '#type' => 'table', + '#header' => array( + 'machine_name' => t('Machine Name'), + 'pattern' => t('Format'), + ), + ); + // Display a form field for each format type. foreach ($formats as $date_format_id => $format_info) { + $form['date_formats'][$date_format_id]['machine_name'] = array( + '#markup' => check_plain($format_info['name']), + ); + // Show date format select list. - $form['date_formats']['date_format_' . $date_format_id] = array( + $form['date_formats'][$date_format_id]['pattern'] = array( '#type' => 'select', - '#title' => check_plain($format_info['name']), '#attributes' => array('class' => array('date-format')), '#default_value' => isset($choices[$date_format_id]) ? $date_format_id : 'custom', '#options' => $choices, @@ -2905,8 +2883,8 @@ function system_date_format_localize_form_submit($form, &$form_state) { $formats = system_get_date_formats(); foreach ($formats as $date_format_id => $format_info) { - if (isset($form_state['values']['date_format_' . $date_format_id])) { - $format = $form_state['values']['date_format_' . $date_format_id]; + if (isset($form_state['values']['date_formats'][$date_format_id])) { + $format = $form_state['values']['date_formats'][$date_format_id]['pattern']; system_date_format_localize_form_save($langcode, $date_format_id, $formats[$format]['pattern']); } } @@ -2915,37 +2893,6 @@ function system_date_format_localize_form_submit($form, &$form_state) { } /** - * Returns HTML for a locale date format form. - * - * @param $variables - * An associative array containing: - * - form: A render element representing the form. - * - * @ingroup themeable - */ -function theme_system_date_format_localize_form($variables) { - $form = $variables['form']; - $header = array( - 'machine_name' => t('Machine Name'), - 'pattern' => t('Format'), - ); - - foreach (element_children($form['date_formats']) as $key) { - $row = array(); - $row[] = $form['date_formats'][$key]['#title']; - unset($form['date_formats'][$key]['#title']); - $row[] = array('data' => drupal_render($form['date_formats'][$key])); - $rows[] = $row; - } - - $output = drupal_render($form['language']); - $output .= theme('table', array('header' => $header, 'rows' => $rows)); - $output .= drupal_render_children($form); - - return $output; -} - -/** * Form constructor for the reset date format form. * * @param $langcode diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 2c51ae0..169e01a 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -152,10 +152,6 @@ function system_theme() { 'variables' => array('message' => NULL), 'file' => 'system.admin.inc', ), - 'system_modules_uninstall' => array( - 'render element' => 'form', - 'file' => 'system.admin.inc', - ), 'status_report' => array( 'render element' => 'requirements', 'file' => 'system.admin.inc', @@ -182,9 +178,6 @@ function system_theme() { 'system_compact_link' => array( 'variables' => array(), ), - 'system_date_format_localize_form' => array( - 'render element' => 'form', - ), 'system_plugin_ui_form' => array( 'template' => 'system-plugin-ui-form', 'render element' => 'form', diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php index 93cc8d4..08f9e98 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php @@ -374,18 +374,18 @@ function testTermReorder() { // term3, term1 by setting weight property, make term3 a child of term2 by // setting the parent and depth properties, and update all hidden fields. $edit = array( - 'tid:' . $term2->tid . ':0[tid]' => $term2->tid, - 'tid:' . $term2->tid . ':0[parent]' => 0, - 'tid:' . $term2->tid . ':0[depth]' => 0, - 'tid:' . $term2->tid . ':0[weight]' => 0, - 'tid:' . $term3->tid . ':0[tid]' => $term3->tid, - 'tid:' . $term3->tid . ':0[parent]' => $term2->tid, - 'tid:' . $term3->tid . ':0[depth]' => 1, - 'tid:' . $term3->tid . ':0[weight]' => 1, - 'tid:' . $term1->tid . ':0[tid]' => $term1->tid, - 'tid:' . $term1->tid . ':0[parent]' => 0, - 'tid:' . $term1->tid . ':0[depth]' => 0, - 'tid:' . $term1->tid . ':0[weight]' => 2, + 'table[tid:' . $term2->tid . ':0][term][tid]' => $term2->tid, + 'table[tid:' . $term2->tid . ':0][term][parent]' => 0, + 'table[tid:' . $term2->tid . ':0][term][depth]' => 0, + 'table[tid:' . $term2->tid . ':0][weight]' => 0, + 'table[tid:' . $term3->tid . ':0][term][tid]' => $term3->tid, + 'table[tid:' . $term3->tid . ':0][term][parent]' => $term2->tid, + 'table[tid:' . $term3->tid . ':0][term][depth]' => 1, + 'table[tid:' . $term3->tid . ':0][weight]' => 1, + 'table[tid:' . $term1->tid . ':0][term][tid]' => $term1->tid, + 'table[tid:' . $term1->tid . ':0][term][parent]' => 0, + 'table[tid:' . $term1->tid . ':0][term][depth]' => 0, + 'table[tid:' . $term1->tid . ':0][weight]' => 2, ); $this->drupalPost(NULL, $edit, t('Save')); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php index 8d05f64..990164b 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/VocabularyTest.php @@ -90,7 +90,7 @@ function testTaxonomyAdminChangingWeights() { foreach ($vocabularies as $key => $vocabulary) { $weight = -$vocabulary->weight; $vocabularies[$key]->weight = $weight; - $edit[$key . '[weight]'] = $weight; + $edit['table[' . $key . '][weight]'] = $weight; } // Saving the new weights via the interface. $this->drupalPost('admin/structure/taxonomy', $edit, t('Save')); diff --git a/core/modules/taxonomy/taxonomy.admin.inc b/core/modules/taxonomy/taxonomy.admin.inc index 6305e48..84fce4f 100644 --- a/core/modules/taxonomy/taxonomy.admin.inc +++ b/core/modules/taxonomy/taxonomy.admin.inc @@ -18,16 +18,26 @@ function taxonomy_overview_vocabularies($form) { $vocabularies = taxonomy_vocabulary_load_multiple(); taxonomy_vocabulary_sort($vocabularies); - $form['#tree'] = TRUE; + $form['table'] = array( + '#type' => 'table', + '#empty' => t('No vocabularies available. Add vocabulary.', array('@link' => url('admin/structure/taxonomy/add'))), + '#attributes' => array( + 'id' => 'taxonomy', + ), + ); foreach ($vocabularies as $vocabulary) { - $form[$vocabulary->id()]['#vocabulary'] = $vocabulary; - $form[$vocabulary->id()]['name'] = array('#markup' => check_plain($vocabulary->name)); - $form[$vocabulary->id()]['weight'] = array( + $form['table'][$vocabulary->id()]['#vocabulary'] = $vocabulary; + $form['table'][$vocabulary->id()]['#attributes']['class'][] = 'draggable'; + $form['table'][$vocabulary->id()]['name'] = array('#markup' => check_plain($vocabulary->name)); + $form['table'][$vocabulary->id()]['weight'] = array( '#type' => 'weight', '#title' => t('Weight for @title', array('@title' => $vocabulary->name)), '#title_display' => 'invisible', '#delta' => 10, '#default_value' => $vocabulary->weight, + '#attributes' => array( + 'class' => array('vocabulary-weight'), + ), ); $links = array(); $links['edit'] = array( @@ -42,21 +52,26 @@ function taxonomy_overview_vocabularies($form) { 'title' => t('add terms'), 'href' => "admin/structure/taxonomy/{$vocabulary->id()}/add", ); - $form[$vocabulary->id()]['operations'] = array( + $form['table'][$vocabulary->id()]['operations'] = array( '#type' => 'operations', '#links' => $links, ); } + $form['table']['#header'] = array(t('Vocabulary name')); + // Only make this form include a submit button and weight if more than one // vocabulary exists. if (count($vocabularies) > 1) { + $form['table']['#tabledrag'][] = array('order', 'sibling', 'vocabulary-weight'); + $form['table']['#header'][] = t('Weight'); $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save'), '#button_type' => 'primary'); } elseif (isset($vocabulary)) { - unset($form[$vocabulary->id()]['weight']); + unset($form['table'][$vocabulary->id()]['weight']); } + $form['table']['#header'][] = t('Operations'); return $form; } @@ -66,55 +81,16 @@ function taxonomy_overview_vocabularies($form) { * @see taxonomy_overview_vocabularies() */ function taxonomy_overview_vocabularies_submit($form, &$form_state) { - foreach ($form_state['values'] as $vid => $vocabulary) { - if (isset($form[$vid]['#vocabulary']) && $form[$vid]['#vocabulary']->weight != $form_state['values'][$vid]['weight']) { - $form[$vid]['#vocabulary']->weight = $form_state['values'][$vid]['weight']; - taxonomy_vocabulary_save($form[$vid]['#vocabulary']); + foreach ($form_state['values']['table'] as $vid => $vocabulary) { + if (isset($form['table'][$vid]['#vocabulary']) && $form['table'][$vid]['#vocabulary']->weight != $form_state['values']['table'][$vid]['weight']) { + $form['table'][$vid]['#vocabulary']->weight = $form_state['values']['table'][$vid]['weight']; + taxonomy_vocabulary_save($form['table'][$vid]['#vocabulary']); } } drupal_set_message(t('The configuration options have been saved.')); } /** - * Returns HTML for the vocabulary overview form as a sortable list of vocabularies. - * - * @param $variables - * An associative array containing: - * - form: A render element representing the form. - * - * @see taxonomy_overview_vocabularies() - * @ingroup themeable - */ -function theme_taxonomy_overview_vocabularies($variables) { - $form = $variables['form']; - - $rows = array(); - - foreach (element_children($form) as $key) { - if (isset($form[$key]['name'])) { - $vocabulary = &$form[$key]; - - $row = array(); - $row[] = drupal_render($vocabulary['name']); - if (isset($vocabulary['weight'])) { - $vocabulary['weight']['#attributes']['class'] = array('vocabulary-weight'); - $row[] = drupal_render($vocabulary['weight']); - } - $row[] = drupal_render($vocabulary['operations']); - $rows[] = array('data' => $row, 'class' => array('draggable')); - } - } - - $header = array(t('Vocabulary name')); - if (isset($form['actions'])) { - $header[] = t('Weight'); - drupal_add_tabledrag('taxonomy', 'order', 'sibling', 'vocabulary-weight'); - } - $header[] = t('Operations'); - return theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No vocabularies available. Add vocabulary.', array('@link' => url('admin/structure/taxonomy/add'))), 'attributes' => array('id' => 'taxonomy'))) . drupal_render_children($form); -} - -/** * Page callback: provides the vocabulary creation form. */ function taxonomy_vocabulary_add() { @@ -148,8 +124,7 @@ function taxonomy_overview_terms($form, &$form_state, Vocabulary $vocabulary) { } $form_state['taxonomy']['vocabulary'] = $vocabulary; - $form['#tree'] = TRUE; - $form['#parent_fields'] = FALSE; + $parent_fields = FALSE; $page = isset($_GET['page']) ? $_GET['page'] : 0; $page_increment = config('taxonomy.settings')->get('terms_per_page_admin'); // Number of terms per page. @@ -238,56 +213,96 @@ function taxonomy_overview_terms($form, &$form_state, Vocabulary $vocabulary) { // If this form was already submitted once, it's probably hit a validation // error. Ensure the form is rebuilt in the same order as the user submitted. if (!empty($form_state['input'])) { - $order = array_flip(array_keys($form_state['input'])); // Get the $_POST order. + $order = array_flip(array_keys($form_state['input']['table'])); // Get the $_POST order. $current_page = array_merge($order, $current_page); // Update our form with the new order. foreach ($current_page as $key => $term) { - // Verify this is a term for the current page and set at the current depth. - if (is_array($form_state['input'][$key]) && is_numeric($form_state['input'][$key]['tid'])) { - $current_page[$key]->depth = $form_state['input'][$key]['depth']; + // Verify this is a term for the current page and set at the current + // depth. + if (is_array($form_state['input']['table'][$key]) && is_numeric($form_state['input']['table'][$key]['term']['tid'])) { + $current_page[$key]->depth = $form_state['input']['table'][$key]['term']['depth']; } else { unset($current_page[$key]); } } } + + $errors = form_get_errors() != FALSE ? form_get_errors() : array(); $destination = drupal_get_destination(); + $row_position = 0; // Build the actual form. + $form['table'] = array( + '#type' => 'table', + '#header' => array(t('Name'), t('Weight'), t('Operations')), + '#empty' => t('No terms available. Add term.', array('@link' => url('admin/structure/taxonomy/' . $vocabulary->id() . '/add'))), + '#attributes' => array( + 'id' => 'taxonomy', + ), + ); foreach ($current_page as $key => $term) { - // Save the term for the current page so we don't have to load it a second time. - $form[$key]['#term'] = (array) $term; + // Save the term for the current page so we don't have to load it a second + // time. + $form['table'][$key]['#term'] = (array) $term; if (isset($term->parents)) { - $form[$key]['#term']['parent'] = $term->parent = $term->parents[0]; - unset($form[$key]['#term']['parents'], $term->parents); + $form['table'][$key]['#term']['parent'] = $term->parent = $term->parents[0]; + unset($form['table'][$key]['#term']['parents'], $term->parents); } - $form[$key]['view'] = array('#type' => 'link', '#title' => $term->label(), '#href' => "taxonomy/term/$term->tid"); + $form['table'][$key]['term'] = array( + '#prefix' => isset($term->depth) && $term->depth > 0 ? theme('indentation', array('size' => $term->depth)) : '', + '#type' => 'link', + '#title' => $term->label(), + '#href' => "taxonomy/term/$term->tid", + ); if ($vocabulary->hierarchy != TAXONOMY_HIERARCHY_MULTIPLE && count($tree) > 1) { - $form['#parent_fields'] = TRUE; - $form[$key]['tid'] = array( + $parent_fields = TRUE; + $form['table'][$key]['term']['tid'] = array( '#type' => 'hidden', - '#value' => $term->tid + '#value' => $term->tid, + '#attributes' => array( + 'class' => array('term-id'), + ), ); - $form[$key]['parent'] = array( + $form['table'][$key]['term']['parent'] = array( '#type' => 'hidden', - // Yes, default_value on a hidden. It needs to be changeable by the javascript. + // Yes, default_value on a hidden. It needs to be changeable by the + // javascript. '#default_value' => $term->parent, + '#attributes' => array( + 'class' => array('term-parent'), + ), ); - $form[$key]['depth'] = array( + $form['table'][$key]['term']['depth'] = array( '#type' => 'hidden', - // Same as above, the depth is modified by javascript, so it's a default_value. + // Same as above, the depth is modified by javascript, so it's a + // default_value. '#default_value' => $term->depth, - ); - $form[$key]['weight'] = array( - '#type' => 'weight', - '#delta' => $delta, - '#title_display' => 'invisible', - '#title' => t('Weight for added term'), - '#default_value' => $term->weight, + '#attributes' => array( + 'class' => array('term-depth'), + ), ); } + $form['table'][$key]['weight'] = array( + '#type' => 'weight', + '#delta' => $delta, + '#title_display' => 'invisible', + '#title' => t('Weight for added term'), + '#default_value' => $term->weight, + '#attributes' => array( + 'class' => array('term-weight'), + ), + ); $operations = array( - 'edit' => array('title' => t('edit'), 'href' => 'taxonomy/term/' . $term->tid . '/edit', 'query' => $destination), - 'delete' => array('title' => t('delete'), 'href' => 'taxonomy/term/' . $term->tid . '/delete', 'query' => $destination), + 'edit' => array( + 'title' => t('edit'), + 'href' => 'taxonomy/term/' . $term->tid . '/edit', + 'query' => $destination, + ), + 'delete' => array( + 'title' => t('delete'), + 'href' => 'taxonomy/term/' . $term->tid . '/delete', + 'query' => $destination, + ), ); if (module_invoke('translation_entity', 'translate_access', $term)) { $operations['translate'] = array( @@ -296,18 +311,50 @@ function taxonomy_overview_terms($form, &$form_state, Vocabulary $vocabulary) { 'query' => $destination, ); } - $form[$key]['operations'] = array( + $form['table'][$key]['operations'] = array( '#type' => 'operations', '#links' => $operations, ); + + $form['table'][$key]['#attributes']['class'] = array(); + if ($parent_fields) { + $form['table'][$key]['#attributes']['class'][] = 'draggable'; + } + + // Add classes that mark which terms belong to previous and next pages. + if ($row_position < $back_step || $row_position >= $page_entries - $forward_step) { + $form['table'][$key]['#attributes']['class'][] = 'taxonomy-term-preview'; + } + + if ($row_position !== 0 && $row_position !== count($tree) - 1) { + if ($row_position == $back_step - 1 || $row_position == $page_entries - $forward_step - 1) { + $form['table'][$key]['#attributes']['class'][] = 'taxonomy-term-divider-top'; + } + elseif ($row_position == $back_step || $row_position == $page_entries - $forward_step) { + $form['table'][$key]['#attributes']['class'][] = 'taxonomy-term-divider-bottom'; + } + } + + // Add an error class if this row contains a form error. + foreach ($errors as $error_key => $error) { + if (strpos($error_key, $key) === 0) { + $form['table'][$key]['#attributes']['class'][] = 'error'; + } + } + $row_position++; } - $form['#total_entries'] = $total_entries; - $form['#page_increment'] = $page_increment; - $form['#page_entries'] = $page_entries; - $form['#back_step'] = $back_step; - $form['#forward_step'] = $forward_step; - $form['#empty_text'] = t('No terms available. Add term.', array('@link' => url('admin/structure/taxonomy/' . $vocabulary->id() . '/add'))); + + if ($parent_fields) { + $form['table']['#tabledrag'][] = array('match', 'parent', 'term-parent', 'term-parent', 'term-id', FALSE); + $form['table']['#tabledrag'][] = array('depth', 'group', 'term-depth', NULL, NULL, FALSE); + $form['table']['#attached']['library'][] = array('taxonomy', 'drupal.taxonomy'); + $form['table']['#attached']['js'][] = array( + 'data' => array('taxonomy' => array('backStep' => $back_step, 'forwardStep' => $forward_step)), + 'type' => 'setting', + ); + } + $form['table']['#tabledrag'][] = array('order', 'sibling', 'term-weight'); if ($vocabulary->hierarchy != TAXONOMY_HIERARCHY_MULTIPLE && count($tree) > 1) { $form['actions'] = array('#type' => 'actions', '#tree' => FALSE); @@ -354,7 +401,7 @@ function taxonomy_overview_terms_submit($form, &$form_state) { } // Sort term order based on weight. - uasort($form_state['values'], 'drupal_sort_weight'); + uasort($form_state['values']['table'], 'drupal_sort_weight'); $vocabulary = $form_state['taxonomy']['vocabulary']; // Update the current hierarchy type as we go. @@ -383,25 +430,25 @@ function taxonomy_overview_terms_submit($form, &$form_state) { // Renumber the current page weights and assign any new parents. $level_weights = array(); - foreach ($form_state['values'] as $tid => $values) { - if (isset($form[$tid]['#term'])) { - $term = $form[$tid]['#term']; + foreach ($form_state['values']['table'] as $tid => $values) { + if (isset($form['table'][$tid]['#term'])) { + $term = $form['table'][$tid]['#term']; // Give terms at the root level a weight in sequence with terms on previous pages. - if ($values['parent'] == 0 && $term['weight'] != $weight) { + if ($values['term']['parent'] == 0 && $term['weight'] != $weight) { $term['weight'] = $weight; $changed_terms[$term['tid']] = $term; } // Terms not at the root level can safely start from 0 because they're all on this page. - elseif ($values['parent'] > 0) { - $level_weights[$values['parent']] = isset($level_weights[$values['parent']]) ? $level_weights[$values['parent']] + 1 : 0; - if ($level_weights[$values['parent']] != $term['weight']) { - $term['weight'] = $level_weights[$values['parent']]; + elseif ($values['term']['parent'] > 0) { + $level_weights[$values['term']['parent']] = isset($level_weights[$values['term']['parent']]) ? $level_weights[$values['term']['parent']] + 1 : 0; + if ($level_weights[$values['term']['parent']] != $term['weight']) { + $term['weight'] = $level_weights[$values['term']['parent']]; $changed_terms[$term['tid']] = $term; } } // Update any changed parents. - if ($values['parent'] != $term['parent']) { - $term['parent'] = $values['parent']; + if ($values['term']['parent'] != $term['parent']) { + $term['parent'] = $values['term']['parent']; $changed_terms[$term['tid']] = $term; } $hierarchy = $term['parent'] != 0 ? TAXONOMY_HIERARCHY_SINGLE : $hierarchy; diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index f894d6c..7ef6f95 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -238,12 +238,6 @@ function taxonomy_select_nodes($tid, $pager = TRUE, $limit = FALSE, $order = arr */ function taxonomy_theme() { return array( - 'taxonomy_overview_vocabularies' => array( - 'render element' => 'form', - ), - 'taxonomy_overview_terms' => array( - 'render element' => 'form', - ), 'taxonomy_term' => array( 'render element' => 'elements', 'template' => 'taxonomy-term', diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc index c3931d8..a493b15 100644 --- a/core/modules/user/user.admin.inc +++ b/core/modules/user/user.admin.inc @@ -858,10 +858,16 @@ function user_admin_roles($form, $form_state) { $roles = user_roles(); $form['roles'] = array( + '#type' => 'table', '#tree' => TRUE, + '#header' => array(t('Name'), t('Weight'), t('Operations')), + '#tabledrag' => array( + array('order', 'sibling', 'role-weight'), + ), ); foreach ($roles as $rid => $role) { + $form['roles'][$rid]['#attributes']['class'][] = 'draggable'; $form['roles'][$rid]['#role'] = $role; $form['roles'][$rid]['#weight'] = $role->weight; $form['roles'][$rid]['name'] = array( @@ -896,11 +902,23 @@ function user_admin_roles($form, $form_state) { 'id' => NULL, 'label' => NULL, )); + $add_form = user_admin_role(array(), $form_state, $add_role); $add_form['actions']['submit']['#submit'] = array('user_admin_role_submit'); - $add_form['role']['actions'] = $add_form['actions']; - unset($add_form['actions']); - $form += $add_form; + $actions = $add_form['actions']; + unset($form['role']['weight']); + + // Distribute the role add form into table columns. + $add_form['role']['label']['#title_display'] = 'invisible'; + unset($add_form['role']['label']['#description']); + unset($add_form['role']['rid']['#description']); + + // Ensure the machine name is connected to the role label field. + $add_form['role']['id']['#machine_name']['source'] = array('roles', 'add', 'name', 'label'); + + $form['roles']['add']['name'] = $add_form['role']; + $form['roles']['add']['weight'] = array(); + $form['roles']['add']['operations'] = $actions; $form['actions']['#type'] = 'actions'; $form['actions']['submit'] = array( @@ -919,55 +937,13 @@ function user_admin_roles($form, $form_state) { */ function user_admin_roles_order_submit($form, &$form_state) { foreach ($form_state['values']['roles'] as $rid => $role_values) { - $role = $form['roles'][$rid]['#role']; - $role->weight = $role_values['weight']; - $role->save(); - } - drupal_set_message(t('The role settings have been updated.')); -} - -/** - * Returns HTML for the role order and new role form. - * - * @param $variables - * An associative array containing: - * - form: A render element representing the form. - * - * @ingroup themeable - */ -function theme_user_admin_roles($variables) { - $form = $variables['form']; - - $header = array(t('Name'), t('Weight'), t('Operations')); - foreach (element_children($form['roles']) as $rid) { - $row = array(); - foreach (element_children($form['roles'][$rid]) as $column) { - $row[] = drupal_render($form['roles'][$rid][$column]); + if (isset($form['roles'][$rid]['#role'])) { + $role = $form['roles'][$rid]['#role']; + $role->weight = $role_values['weight']; + $role->save(); } - $rows[] = array('data' => $row, 'class' => array('draggable')); } - - // Distribute the role add form into table columns. - $form['role']['name']['#title_display'] = 'invisible'; - unset($form['role']['name']['#description']); - unset($form['role']['rid']['#description']); - - $actions = $form['role']['actions']; - unset($form['role']['actions']); - unset($form['role']['weight']); - $row = array(); - $row[] = drupal_render($form['role']); - // Empty placeholder for the weight column. - $row[] = ''; - $row[] = array('data' => drupal_render($actions), 'colspan' => 2); - $rows[] = array('data' => $row); - - drupal_add_tabledrag('user-roles', 'order', 'sibling', 'role-weight'); - - $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'user-roles'))); - $output .= drupal_render_children($form); - - return $output; + drupal_set_message(t('The role settings have been updated.')); } /** diff --git a/core/modules/user/user.module b/core/modules/user/user.module index bdf5862..e5f3389 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -99,10 +99,6 @@ function user_theme() { 'render element' => 'form', 'file' => 'user.admin.inc', ), - 'user_admin_roles' => array( - 'render element' => 'form', - 'file' => 'user.admin.inc', - ), 'user_permission_description' => array( 'variables' => array('permission_item' => NULL, 'hide' => NULL), 'file' => 'user.admin.inc',