- Patch #635212 by sun, David_Rothstein, ryandekker, tstoeckler: fallback format is not configurable.
parent
5ca8621ba4
commit
4114d3ce58
|
@ -322,12 +322,25 @@ function filter_admin_format_form_submit($form, &$form_state) {
|
||||||
function filter_admin_delete($form, &$form_state, $format) {
|
function filter_admin_delete($form, &$form_state, $format) {
|
||||||
$form['#format'] = $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,
|
return confirm_form($form,
|
||||||
t('Are you sure you want to delete the text format %format?', array('%format' => $format->name)),
|
t('Are you sure you want to delete the text format %format?', array('%format' => $format->name)),
|
||||||
'admin/config/content/formats',
|
'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())),
|
NULL,
|
||||||
t('Delete'),
|
t('Delete')
|
||||||
t('Cancel')
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,7 +349,7 @@ function filter_admin_delete($form, &$form_state, $format) {
|
||||||
*/
|
*/
|
||||||
function filter_admin_delete_submit($form, &$form_state) {
|
function filter_admin_delete_submit($form, &$form_state) {
|
||||||
$format = $form['#format'];
|
$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)));
|
drupal_set_message(t('Deleted text format %format.', array('%format' => $format->name)));
|
||||||
|
|
||||||
$form_state['redirect'] = 'admin/config/content/formats';
|
$form_state['redirect'] = 'admin/config/content/formats';
|
||||||
|
|
|
@ -235,15 +235,15 @@ function hook_filter_format_update($format) {
|
||||||
/**
|
/**
|
||||||
* Perform actions when a text format has been deleted.
|
* Perform actions when a text format has been deleted.
|
||||||
*
|
*
|
||||||
* It is recommended for modules to implement this hook, when they store
|
* All modules storing references to text formats have to implement this hook.
|
||||||
* references to text formats to replace existing references to the deleted
|
*
|
||||||
* text format with the fallback format.
|
* 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
|
* @param $format
|
||||||
* The format object of the format being deleted.
|
* The format object of the format being deleted.
|
||||||
* @param $fallback
|
* @param $fallback
|
||||||
* The format object of the site's fallback format, which is always available
|
* The format object of the format to use as replacement.
|
||||||
* to all users.
|
|
||||||
*
|
*
|
||||||
* @see hook_filter_format_insert()
|
* @see hook_filter_format_insert()
|
||||||
* @see hook_filter_format_update()
|
* @see hook_filter_format_update()
|
||||||
|
|
|
@ -260,8 +260,12 @@ function filter_format_save(&$format) {
|
||||||
*
|
*
|
||||||
* @param $format
|
* @param $format
|
||||||
* The text format object to be deleted.
|
* 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')
|
db_delete('filter_format')
|
||||||
->condition('format', $format->format)
|
->condition('format', $format->format)
|
||||||
->execute();
|
->execute();
|
||||||
|
@ -270,7 +274,10 @@ function filter_format_delete($format) {
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
// Allow modules to react on text format deletion.
|
// 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);
|
module_invoke_all('filter_format_delete', $format, $fallback);
|
||||||
|
|
||||||
filter_formats_reset();
|
filter_formats_reset();
|
||||||
|
@ -488,11 +495,6 @@ function filter_default_format($account = NULL) {
|
||||||
* format is initialized to output plain text. Installation profiles and site
|
* format is initialized to output plain text. Installation profiles and site
|
||||||
* administrators have the freedom to configure it further.
|
* 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
|
* Note that the fallback format is completely distinct from the default
|
||||||
* format, which differs per user and is simply the first format which that
|
* 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
|
* user has access to. The default and fallback formats are only guaranteed to
|
||||||
|
|
Loading…
Reference in New Issue