summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/filter/filter.admin.inc21
-rw-r--r--modules/filter/filter.api.php10
-rw-r--r--modules/filter/filter.module16
3 files changed, 31 insertions, 16 deletions
diff --git a/modules/filter/filter.admin.inc b/modules/filter/filter.admin.inc
index 3254bef57..816bedc5a 100644
--- a/modules/filter/filter.admin.inc
+++ b/modules/filter/filter.admin.inc
@@ -322,12 +322,25 @@ function filter_admin_format_form_submit($form, &$form_state) {
function filter_admin_delete($form, &$form_state, $format) {
$form['#format'] = $format;
+ $fallback_options = array();
+ foreach (filter_formats() as $id => $fallback_format) {
+ if ($id != $format->format) {
+ $fallback_options[$id] = $fallback_format->name;
+ }
+ }
+ $form['fallback'] = array(
+ '#type' => 'select',
+ '#title' => t('Replacement text format'),
+ '#options' => $fallback_options,
+ '#default_value' => filter_fallback_format(),
+ '#description' => t('Content assigned to the deleted text format will be reassigned to the chosen one.'),
+ );
+
return confirm_form($form,
t('Are you sure you want to delete the text format %format?', array('%format' => $format->name)),
'admin/config/content/formats',
- t('If you have any content left in this text format, it will be switched to the %fallback text format. This action cannot be undone.', array('%fallback' => filter_fallback_format_title())),
- t('Delete'),
- t('Cancel')
+ NULL,
+ t('Delete')
);
}
@@ -336,7 +349,7 @@ function filter_admin_delete($form, &$form_state, $format) {
*/
function filter_admin_delete_submit($form, &$form_state) {
$format = $form['#format'];
- filter_format_delete($format);
+ filter_format_delete($format, $form_state['values']['fallback']);
drupal_set_message(t('Deleted text format %format.', array('%format' => $format->name)));
$form_state['redirect'] = 'admin/config/content/formats';
diff --git a/modules/filter/filter.api.php b/modules/filter/filter.api.php
index 4b7e0a3c3..cffcf272e 100644
--- a/modules/filter/filter.api.php
+++ b/modules/filter/filter.api.php
@@ -235,15 +235,15 @@ function hook_filter_format_update($format) {
/**
* Perform actions when a text format has been deleted.
*
- * It is recommended for modules to implement this hook, when they store
- * references to text formats to replace existing references to the deleted
- * text format with the fallback format.
+ * All modules storing references to text formats have to implement this hook.
+ *
+ * When a text format is deleted, all content that previously had that format
+ * assigned needs to be switched to the passed fallback format.
*
* @param $format
* The format object of the format being deleted.
* @param $fallback
- * The format object of the site's fallback format, which is always available
- * to all users.
+ * The format object of the format to use as replacement.
*
* @see hook_filter_format_insert()
* @see hook_filter_format_update()
diff --git a/modules/filter/filter.module b/modules/filter/filter.module
index 874a84fa0..3ee343c67 100644
--- a/modules/filter/filter.module
+++ b/modules/filter/filter.module
@@ -260,8 +260,12 @@ function filter_format_save(&$format) {
*
* @param $format
* The text format object to be deleted.
+ * @param $fallback_id
+ * (optional) The ID of the text format to use to reassign content that is
+ * currently using $format. If omitted, the currently stored
+ * filter_fallback_format() is used.
*/
-function filter_format_delete($format) {
+function filter_format_delete($format, $fallback_id = NULL) {
db_delete('filter_format')
->condition('format', $format->format)
->execute();
@@ -270,7 +274,10 @@ function filter_format_delete($format) {
->execute();
// Allow modules to react on text format deletion.
- $fallback = filter_format_load(filter_fallback_format());
+ if (empty($fallback_id)) {
+ $fallback_id = filter_fallback_format();
+ }
+ $fallback = filter_format_load($fallback_id);
module_invoke_all('filter_format_delete', $format, $fallback);
filter_formats_reset();
@@ -488,11 +495,6 @@ function filter_default_format($account = NULL) {
* format is initialized to output plain text. Installation profiles and site
* administrators have the freedom to configure it further.
*
- * When a text format is deleted, all content that previously had that format
- * assigned should be switched to the fallback format. To facilitate this,
- * Drupal passes in the fallback format object as one of the parameters of
- * hook_filter_format_delete().
- *
* Note that the fallback format is completely distinct from the default
* format, which differs per user and is simply the first format which that
* user has access to. The default and fallback formats are only guaranteed to