From b4c737a2a5ed9bf9905c91107f94e42df36f2c44 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Thu, 22 Jan 2009 03:11:54 +0000 Subject: #287178 by justinrandell: Break up various hook_form_alter()s to hook_form_FORM_ID_alters(). --- modules/translation/translation.module | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'modules/translation') diff --git a/modules/translation/translation.module b/modules/translation/translation.module index 0057dfb82..35fe82582 100644 --- a/modules/translation/translation.module +++ b/modules/translation/translation.module @@ -93,6 +93,16 @@ function translation_perm() { ); } +/** + * Implementation of hook_form_FORM_ID_alter(). + */ +function translation_form_node_type_form_alter(&$form, &$form_state) { + // Add translation option to content type form. + $form['workflow']['language_content_type']['#options'][TRANSLATION_ENABLED] = t('Enabled, with translation'); + // Description based on text from locale.module. + $form['workflow']['language_content_type']['#description'] = t('Enable multilingual support for this content type. If enabled, a language selection field will be added to the editing form, allowing you to select from one of the enabled languages. You can also turn on translation for this content type, which lets you have content translated to any of the enabled languages. If disabled, new posts are saved with the default language. Existing content will not be affected by changing this option.', array('!languages' => url('admin/settings/language'))); +} + /** * Implementation of hook_form_alter(). * @@ -100,14 +110,8 @@ function translation_perm() { * - Alters language fields on node forms when a translation * is about to be created. */ -function translation_form_alter(&$form, $form_state, $form_id) { - if ($form_id == 'node_type_form') { - // Add translation option to content type form. - $form['workflow']['language_content_type']['#options'][TRANSLATION_ENABLED] = t('Enabled, with translation'); - // Description based on text from locale.module. - $form['workflow']['language_content_type']['#description'] = t('Enable multilingual support for this content type. If enabled, a language selection field will be added to the editing form, allowing you to select from one of the enabled languages. You can also turn on translation for this content type, which lets you have content translated to any of the enabled languages. If disabled, new posts are saved with the default language. Existing content will not be affected by changing this option.', array('!languages' => url('admin/settings/language'))); - } - elseif (isset($form['#id']) && $form['#id'] == 'node-form' && translation_supported_type($form['#node']->type)) { +function translation_form_alter(&$form, &$form_state, $form_id) { + if (isset($form['#id']) && $form['#id'] == 'node-form' && translation_supported_type($form['#node']->type)) { $node = $form['#node']; if (!empty($node->translation_source)) { // We are creating a translation. Add values and lock language field. -- cgit v1.2.3