diff options
-rw-r--r-- | includes/locale.inc | 30 | ||||
-rw-r--r-- | modules/locale/locale.test | 2 |
2 files changed, 26 insertions, 6 deletions
diff --git a/includes/locale.inc b/includes/locale.inc index 783d17ed2..2dea9784f 100644 --- a/includes/locale.inc +++ b/includes/locale.inc @@ -871,16 +871,36 @@ function locale_translate_edit_form_submit($form, &$form_state) { */ /** - * Delete a language string. + * String deletion confirmation page. */ -function locale_translate_delete($lid) { - db_query('DELETE FROM {locales_source} WHERE lid = %d', $lid); - db_query('DELETE FROM {locales_target} WHERE lid = %d', $lid); +function locale_translate_delete_page($lid) { + if ($source = db_fetch_object(db_query('SELECT * FROM {locales_source} WHERE lid = %d', $lid))) { + return drupal_get_form('locale_translate_delete_form', $source); + } + else { + return drupal_not_found(); + } +} + +/** + * User interface for the string deletion confirmation screen. + */ +function locale_translate_delete_form(&$form_state, $source) { + $form['lid'] = array('#type' => 'value', '#value' => $source->lid); + return confirm_form($form, t('Are you sure you want to delete the string "%source"?', array('%source' => $source->source)), 'admin/build/translate/search', t('Deleting the string will remove all translations of this string in all languages. This action cannot be undone.'), t('Delete'), t('Cancel')); +} + +/** + * Process string deletion submissions. + */ +function locale_translate_delete_form_submit($form, &$form_state) { + db_query('DELETE FROM {locales_source} WHERE lid = %d', $form_state['values']['lid']); + db_query('DELETE FROM {locales_target} WHERE lid = %d', $form_state['values']['lid']); // Force JavaScript translation file recreation for all languages. _locale_invalidate_js(); cache_clear_all('locale:', 'cache', TRUE); drupal_set_message(t('The string has been removed.')); - drupal_goto('admin/build/translate/search'); + $form_state['redirect'] = 'admin/build/translate/search'; } /** * @} End of "locale-translate-delete" diff --git a/modules/locale/locale.test b/modules/locale/locale.test index 8dcb5f5a1..bdcfd7996 100644 --- a/modules/locale/locale.test +++ b/modules/locale/locale.test @@ -108,7 +108,7 @@ class LocaleTestCase extends DrupalWebTestCase { // Delete the name string. $this->drupalLogin($translate_user); - $this->drupalGet('admin/build/translate/delete/' . $lid); + $this->drupalPost('admin/build/translate/delete/' . $lid, array(), t('Delete')); $this->assertText(t('The string has been removed.'), 'The string has been removed message.'); $this->drupalPost('admin/build/translate/search', $search, t('Search')); $this->assertNoText($name, 'Search now can not find the name'); |