? order-input-formats-1.patch ? order-input-formats.patch ? sites/all/modules ? sites/default/files ? sites/default/settings.php Index: CHANGELOG.txt =================================================================== RCS file: /cvs/drupal/drupal/CHANGELOG.txt,v retrieving revision 1.254 diff -u -p -r1.254 CHANGELOG.txt --- CHANGELOG.txt 17 Feb 2008 19:34:28 -0000 1.254 +++ CHANGELOG.txt 18 Feb 2008 23:56:56 -0000 @@ -2,7 +2,8 @@ Drupal 7.0, xxxx-xx-xx (development version) ---------------------- - +- Usability: + * Implemented drag-and-drop positioning for input format listings. Drupal 6.0, 2008-02-13 ---------------------- Index: modules/filter/filter.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.admin.inc,v retrieving revision 1.9 diff -u -p -r1.9 filter.admin.inc --- modules/filter/filter.admin.inc 14 Feb 2008 18:39:18 -0000 1.9 +++ modules/filter/filter.admin.inc 18 Feb 2008 23:56:56 -0000 @@ -19,6 +19,7 @@ function filter_admin_overview() { $formats = filter_formats(); $error = FALSE; + $form = array('#tree' => TRUE); foreach ($formats as $id => $format) { $roles = array(); foreach (user_roles() as $rid => $name) { @@ -29,13 +30,14 @@ function filter_admin_overview() { } $default = ($id == variable_get('filter_default_format', 1)); $options[$id] = ''; - $form[$format->name]['id'] = array('#value' => $id); - $form[$format->name]['roles'] = array('#value' => $default ? t('All roles may use default format') : ($roles ? implode(', ', $roles) : t('No roles may use this format'))); - $form[$format->name]['configure'] = array('#value' => l(t('configure'), 'admin/settings/filters/'. $id)); - $form[$format->name]['delete'] = array('#value' => $default ? '' : l(t('delete'), 'admin/settings/filters/delete/'. $id)); + $form[$id]['name'] = array('#value' => $format->name); + $form[$id]['roles'] = array('#value' => $default ? t('All roles may use default format') : ($roles ? implode(', ', $roles) : t('No roles may use this format'))); + $form[$id]['configure'] = array('#value' => l(t('configure'), 'admin/settings/filters/'. $id)); + $form[$id]['delete'] = array('#value' => $default ? '' : l(t('delete'), 'admin/settings/filters/delete/'. $id)); + $form[$id]['weight'] = array('#type' => 'weight', '#default_value' => $format->weight); } $form['default'] = array('#type' => 'radios', '#options' => $options, '#default_value' => variable_get('filter_default_format', 1)); - $form['submit'] = array('#type' => 'submit', '#value' => t('Set default format')); + $form['submit'] = array('#type' => 'submit', '#value' => t('Save changes')); return $form; } @@ -45,6 +47,13 @@ function filter_admin_overview_submit($f drupal_set_message(t('Default format updated.')); variable_set('filter_default_format', $form_state['values']['default']); } + foreach ($form_state['values'] as $id => $data) { + if (is_array($data) && isset($data['weight'])) { + // Only update if this is a form element with weight. + db_query("UPDATE {filter_formats} SET weight = %d WHERE format = %d", $data['weight'], $id); + } + } + drupal_set_message(t('The input format ordering has been saved.')); } /** @@ -54,22 +63,29 @@ function filter_admin_overview_submit($f */ function theme_filter_admin_overview($form) { $rows = array(); - foreach ($form as $name => $element) { + foreach ($form as $id => $element) { if (isset($element['roles']) && is_array($element['roles'])) { + $element['weight']['#attributes']['class'] = 'input-format-order-weight'; $rows[] = array( - drupal_render($form['default'][$element['id']['#value']]), - check_plain($name), - drupal_render($element['roles']), - drupal_render($element['configure']), - drupal_render($element['delete']) + 'data' => array( + check_plain($element['name']['#value']), + drupal_render($element['roles']), + drupal_render($form['default'][$id]), + drupal_render($element['weight']), + drupal_render($element['configure']), + drupal_render($element['delete']), + ), + 'class' => 'draggable', ); - unset($form[$name]); + unset($form[$id]); } } - $header = array(t('Default'), t('Name'), t('Roles'), array('data' => t('Operations'), 'colspan' => 2)); - $output = theme('table', $header, $rows); + $header = array(t('Name'), t('Roles'), t('Default'), t('Weight'), array('data' => t('Operations'), 'colspan' => 2)); + $output = theme('table', $header, $rows, array('id' => 'input-format-order')); $output .= drupal_render($form); + drupal_add_tabledrag('input-format-order', 'order', 'sibling', 'input-format-order-weight'); + return $output; } Index: modules/filter/filter.install =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.install,v retrieving revision 1.5 diff -u -p -r1.5 filter.install --- modules/filter/filter.install 18 Dec 2007 12:59:21 -0000 1.5 +++ modules/filter/filter.install 18 Feb 2008 23:56:56 -0000 @@ -78,6 +78,13 @@ function filter_schema() { 'size' => 'tiny', 'description' => t('Flag to indicate whether format is cachable. (1 = cachable, 0 = not cachable)'), ), + 'weight' => array( + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + 'size' => 'tiny', + 'description' => t('Weight of input format to use when listing.'), + ) ), 'primary key' => array('format'), 'unique keys' => array('name' => array('name')), @@ -89,3 +96,11 @@ function filter_schema() { return $schema; } +/** + * Add a weight column to the filter formats table. + */ +function filter_update_7000() { + $ret = array(); + db_add_field($ret, 'filter_formats', 'weight', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'tiny')); + return $ret; +} Index: modules/filter/filter.module =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v retrieving revision 1.204 diff -u -p -r1.204 filter.module --- modules/filter/filter.module 21 Jan 2008 15:08:24 -0000 1.204 +++ modules/filter/filter.module 18 Feb 2008 23:56:57 -0000 @@ -22,12 +22,12 @@ function filter_help($path, $arg) { case 'admin/help#filter': $output = '

'. t("The filter module allows administrators to configure text input formats for use on your site. An input format defines the HTML tags, codes, and other input allowed in both content and comments, and is a key feature in guarding against potentially damaging input from malicious users. Two input formats included by default are Filtered HTML (which allows only an administrator-approved subset of HTML tags) and Full HTML (which allows the full set of HTML tags). Additional input formats may be created by an administrator.") .'

'; $output .= '

'. t('Each input format uses filters to manipulate text, and most input formats apply several different filters to text in a specific order. Each filter is designed for a specific purpose, and generally either adds, removes or transforms elements within user-entered text before it is displayed. A filter does not change the actual content of a post, but instead, modifies it temporarily before it is displayed. A filter may remove unapproved HTML tags, for instance, while another automatically adds HTML to make links referenced in text clickable.') .'

'; - $output .= '

'. t('Users can choose between the available input formats when creating or editing content. Administrators can configure which input formats are available to which user roles, as well as choose a default input format.') .'

'; + $output .= '

'. t('Users with access to more than one input format can use the Input format fieldset to choose between available input formats when creating or editing multi-line content. Administrators determine the input formats available to each user role, select a default input format, and control the order of formats listed in the Input format fieldset.') .'

'; $output .= '

'. t('For more information, see the online handbook entry for Filter module.', array('@filter' => 'http://drupal.org/handbook/modules/filter/')) .'

'; return $output; case 'admin/settings/filters': - $output = '

'. t('Input formats define a way of processing user-supplied text in Drupal. Each input format uses filters to manipulate text, and most input formats apply several different filters to text, in a specific order. Each filter is designed to accomplish a specific purpose, and generally either removes elements from or adds elements to text before it is displayed. Users can choose between the available input formats when submitting content.') .'

'; - $output .= '

'. t('Use the list below to configure which input formats are available to which roles, as well as choose a default input format (used for imported content, for example). The default format is always available to users. All input formats are available to users in a role with the "administer filters" permission.') .'

'; + $output = '

'. t('Use the list below to review the input formats available to each user role, to select a default input format, and to control the order of formats listed in the Input format fieldset. (The Input format fieldset is displayed below textareas when users with access to more than one input format create multi-line content.) The input format selected as Default is available to all users and, unless another format is selected, is applied to all content. All input formats are available to users in roles with the "administer filters" permission.') .'

'; + $output .= '

'. t('Since input formats, if available, are presented in the same order as the list below, it may be helpful to arrange the formats in descending order of your preference for their use. To change the order of an input format, grab a drag-and-drop handle under the Name column and drag to a new location in the list. (Grab a handle by clicking and holding the mouse while hovering over a handle icon.) Remember that your changes will not be saved until you click the Save changes button at the bottom of the page.') .'

'; return $output; case 'admin/settings/filters/%': return '

'. t('Every filter performs one particular change on the user input, for example stripping out malicious HTML or making URLs clickable. Choose which filters you want to apply to text in this input format. If you notice some filters are causing conflicts in the output, you can rearrange them.', array('@rearrange' => url('admin/settings/filters/'. $arg[3] .'/order'))) .'

'; @@ -308,7 +308,7 @@ function filter_formats($index = NULL) { $args[] = variable_get('filter_default_format', 1); } - $result = db_query($query, $args); + $result = db_query($query .' ORDER by weight', $args); while ($format = db_fetch_object($result)) { $formats[$format->format] = $format; }