### Eclipse Workspace Patch 1.0 #P drupal Index: modules/filter/filter.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.admin.inc,v retrieving revision 1.69 diff -u -r1.69 filter.admin.inc --- modules/filter/filter.admin.inc 22 Oct 2010 16:36:14 -0000 1.69 +++ modules/filter/filter.admin.inc 5 Nov 2010 02:48:03 -0000 @@ -14,7 +14,13 @@ */ function filter_admin_overview($form) { // Overview of all formats. - $formats = filter_formats(); + $formats = db_select('filter_format', 'ff') + ->addTag('translatable') + ->fields('ff') + ->orderBy('weight') + ->execute() + ->fetchAllAssoc('format'); + $fallback_format = filter_fallback_format(); $form['#tree'] = TRUE; @@ -31,9 +37,15 @@ $roles = array_map('check_plain', filter_get_roles_by_format($format)); $roles_markup = $roles ? implode(', ', $roles) : t('No roles may use this format'); } + $form['formats'][$id]['status'] = array('#markup' => $format->status ? t('Enabled') : t('Disabled')); $form['formats'][$id]['roles'] = array('#markup' => $roles_markup); $form['formats'][$id]['configure'] = array('#type' => 'link', '#title' => t('configure'), '#href' => 'admin/config/content/formats/' . $id); - $form['formats'][$id]['disable'] = array('#type' => 'link', '#title' => t('disable'), '#href' => 'admin/config/content/formats/' . $id . '/disable', '#access' => !$form['formats'][$id]['#is_fallback']); + if ($format->status) { + $form['formats'][$id]['toggle'] = array('#type' => 'link', '#title' => t('disable'), '#href' => 'admin/config/content/formats/' . $id . '/disable', '#access' => !$form['formats'][$id]['#is_fallback']); + } + else { + $form['formats'][$id]['toggle'] = array('#type' => 'link', '#title' => t('enable'), '#href' => 'admin/config/content/formats/' . $id . '/enable'); + } $form['formats'][$id]['weight'] = array( '#type' => 'weight', '#title' => t('Weight for @title', array('@title' => $format->name)), @@ -79,14 +91,15 @@ 'data' => array( drupal_render($form['formats'][$id]['name']), drupal_render($form['formats'][$id]['roles']), + drupal_render($form['formats'][$id]['status']), drupal_render($form['formats'][$id]['weight']), drupal_render($form['formats'][$id]['configure']), - drupal_render($form['formats'][$id]['disable']), + drupal_render($form['formats'][$id]['toggle']), ), 'class' => array('draggable'), ); } - $header = array(t('Name'), t('Roles'), t('Weight'), array('data' => t('Operations'), 'colspan' => 2)); + $header = array(t('Name'), t('Roles'), t('Status'), t('Weight'), array('data' => t('Operations'), 'colspan' => 2)); $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'text-format-order'))); $output .= drupal_render_children($form); @@ -331,7 +344,7 @@ } /** - * Menu callback; confirm deletion of a format. + * Menu callback; confirm disable toggle of a format. * * @ingroup forms * @see filter_admin_disable_submit() @@ -342,7 +355,7 @@ return confirm_form($form, t('Are you sure you want to disable the text format %format?', array('%format' => $format->name)), 'admin/config/content/formats', - t('Disabled text formats are completely removed from the administrative interface, and any content stored with that format will not be displayed. This action cannot be undone.'), + t('Disabled text formats are completely removed from the administrative interface, and any content stored with that format will not be displayed.'), t('Disable') ); } @@ -358,3 +371,31 @@ $form_state['redirect'] = 'admin/config/content/formats'; } +/** + * Menu callback; confirm enable toggle of a format. + * + * @ingroup forms + * @see filter_admin_enable_submit() + */ +function filter_admin_enable($form, &$form_state, $format) { + $form['#format'] = $format; + + return confirm_form($form, + t('Are you sure you want to enable the text format %format?', array('%format' => $format->name)), + 'admin/config/content/formats', + t('Any content stored that used this format will be shown. When the format is disabled, this content will be hidden.'), + t('Enable') + ); +} + +/** + * Process filter enable form submission. + */ +function filter_admin_enable_submit($form, &$form_state) { + $format = $form['#format']; + filter_format_enable($format); + drupal_set_message(t('Enabled text format %format.', array('%format' => $format->name))); + + $form_state['redirect'] = 'admin/config/content/formats'; +} + Index: modules/filter/filter.module =================================================================== RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v retrieving revision 1.358 diff -u -r1.358 filter.module --- modules/filter/filter.module 31 Oct 2010 13:08:29 -0000 1.358 +++ modules/filter/filter.module 5 Nov 2010 02:48:04 -0000 @@ -113,7 +113,7 @@ 'weight' => 1, 'file' => 'filter.admin.inc', ); - $items['admin/config/content/formats/%filter_format'] = array( + $items['admin/config/content/formats/%filter_format_all'] = array( 'title callback' => 'filter_admin_format_title', 'title arguments' => array(4), 'page callback' => 'filter_admin_format_page', @@ -121,7 +121,7 @@ 'access arguments' => array('administer filters'), 'file' => 'filter.admin.inc', ); - $items['admin/config/content/formats/%filter_format/disable'] = array( + $items['admin/config/content/formats/%filter_format_all/disable'] = array( 'title' => 'Disable text format', 'page callback' => 'drupal_get_form', 'page arguments' => array('filter_admin_disable', 4), @@ -129,6 +129,13 @@ 'access arguments' => array(4), 'file' => 'filter.admin.inc', ); + $items['admin/config/content/formats/%filter_format_all/enable'] = array( + 'title' => 'Enable text format', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('filter_admin_enable', 4), + 'access arguments' => array('administer filters'), + 'file' => 'filter.admin.inc', + ); return $items; } @@ -165,6 +172,19 @@ } /** + * Menu load callback for any text format object. + */ +function filter_format_all_load($format_id) { + $formats = db_select('filter_format', 'ff') + ->addTag('translatable') + ->fields('ff') + ->orderBy('weight') + ->execute() + ->fetchAllAssoc('format'); + return isset($formats[$format_id]) ? $formats[$format_id] : FALSE; +} + +/** * Save a text format object to the database. * * @param $format @@ -270,10 +290,9 @@ /** * Disable a text format. * - * There is no core facility to re-enable a disabled format. It is not deleted - * to keep information for contrib and to make sure the format ID is never - * reused. As there might be content using the disabled format, this would lead - * to data corruption. + * It is not deleted to keep information for contrib and to make sure the format + * ID is never reused. As there might be content using the disabled format, this + * would lead to data corruption. * * @param $format * The text format object to be disabled. @@ -284,7 +303,7 @@ ->condition('format', $format->format) ->execute(); - // Allow modules to react on text format deletion. + // Allow modules to react on text format status change. module_invoke_all('filter_format_disable', $format); // Clear the filter cache whenever a text format is disabled. @@ -293,6 +312,26 @@ } /** + * Enable a text format. + * + * @param $format + * The text format object to be enabled. + */ +function filter_format_enable($format) { + db_update('filter_format') + ->fields(array('status' => 1)) + ->condition('format', $format->format) + ->execute(); + + // Allow modules to react on text format status change. + module_invoke_all('filter_format_enable', $format); + + // Clear the filter cache whenever a text format is disabled. + filter_formats_reset(); + cache_clear_all($format->format . ':', 'cache_filter', TRUE); +} + +/** * Determines if a text format exists. * * @param $format_id