diff --git a/modules/field/modules/text/text.test b/modules/field/modules/text/text.test index 5936937..e061a39 100644 --- a/modules/field/modules/text/text.test +++ b/modules/field/modules/text/text.test @@ -434,7 +434,7 @@ class TextTranslationTestCase extends DrupalWebTestCase { $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); // Set "Article" content type to use multilingual support with translation. - $edit = array('language_content_type' => 2); + $edit = array('node_type_language' => 2); $this->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type')); $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Article')), t('Article content type has been updated.')); } diff --git a/modules/locale/locale.install b/modules/locale/locale.install index a144813..51dc8f5 100644 --- a/modules/locale/locale.install +++ b/modules/locale/locale.install @@ -65,10 +65,6 @@ function locale_uninstall() { variable_del("locale_language_providers_weight_$type"); } - foreach (node_type_get_types() as $type => $content_type) { - $setting = variable_del("language_content_type_$type"); - } - // Switch back to English: with a $language->language value different from 'en' // successive calls of t() might result in calling locale(), which in turn might // try to query the unexisting {locales_source} and {locales_target} tables. diff --git a/modules/locale/locale.module b/modules/locale/locale.module index 871048b..8c47892 100644 --- a/modules/locale/locale.module +++ b/modules/locale/locale.module @@ -319,31 +319,6 @@ function locale_form_path_admin_form_alter(&$form, &$form_state) { } /** - * Implements hook_form_FORM_ID_alter(). - */ -function locale_form_node_type_form_alter(&$form, &$form_state) { - if (isset($form['type'])) { - $form['workflow']['language_content_type'] = array( - '#type' => 'radios', - '#title' => t('Multilingual support'), - '#default_value' => variable_get('language_content_type_' . $form['#node_type']->type, 0), - '#options' => array(t('Disabled'), t('Enabled')), - '#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. If disabled, new posts are saved with the default language. Existing content will not be affected by changing this option.', array('!languages' => url('admin/config/regional/language'))), - ); - } -} - -/** - * Return whether the given content type has multilingual support. - * - * @return - * True if multilingual support is enabled. - */ -function locale_multilingual_node_type($type_name) { - return (bool) variable_get('language_content_type_' . $type_name, 0); -} - -/** * Implements hook_form_alter(). * * Adds language fields to user forms. @@ -363,22 +338,6 @@ function locale_form_alter(&$form, &$form_state, $form_id) { * Implements hook_form_BASE_FORM_ID_alter(). */ function locale_form_node_form_alter(&$form, &$form_state) { - if (isset($form['#node']->type) && locale_multilingual_node_type($form['#node']->type)) { - $form['language'] = array( - '#type' => 'select', - '#title' => t('Language'), - '#default_value' => (isset($form['#node']->language) ? $form['#node']->language : ''), - '#options' => array(LANGUAGE_NONE => t('Language neutral')) + locale_language_list('name'), - ); - } - // Node type without language selector: assign the default for new nodes - elseif (!isset($form['#node']->nid)) { - $default = language_default(); - $form['language'] = array( - '#type' => 'value', - '#value' => $default->language - ); - } $form['#submit'][] = 'locale_field_node_form_submit'; } @@ -1031,7 +990,7 @@ function locale_url_outbound_alter(&$path, &$options, $original_path) { function locale_form_comment_form_alter(&$form, &$form_state, $form_id) { // If a content type has multilingual support we set the content language as // comment language. - if ($form['language']['#value'] == LANGUAGE_NONE && locale_multilingual_node_type($form['#node']->type)) { + if ($form['language']['#value'] == LANGUAGE_NONE && variable_get('node_type_language_' . $form['#node']->type, 0)) { global $language_content; $form['language']['#value'] = $language_content->language; } diff --git a/modules/locale/locale.test b/modules/locale/locale.test index 3ae6d91..34ab69e 100644 --- a/modules/locale/locale.test +++ b/modules/locale/locale.test @@ -1135,7 +1135,7 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase { $this->assertEqual($language->language, $this->language, t('Current language: %lang', array('%lang' => $language->language))); // Enable multilingual workflow option for articles. - variable_set('language_content_type_article', 1); + variable_set('node_type_language_article', 1); // Change JavaScript translations directory. variable_set('locale_js_directory', 'js_translations'); @@ -1206,7 +1206,7 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase { $this->assertEqual($javascript_parsed_count, 0, t('JavaScript parsed count: %count', array('%count' => $javascript_parsed_count))); // Check multilingual workflow option for articles. - $multilingual = variable_get('language_content_type_article', 0); + $multilingual = variable_get('node_type_language_article', 0); $this->assertEqual($multilingual, 0, t('Multilingual workflow option: %status', array('%status' => t($multilingual ? 'enabled': 'disabled')))); // Check JavaScript translations directory. @@ -1732,7 +1732,7 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase { $this->drupalGet('admin/structure/types/manage/page'); $this->assertText(t('Multilingual support'), t('Multilingual support fieldset present on content type configuration form.')); $edit = array( - 'language_content_type' => 1, + 'node_type_language' => 1, ); $this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type')); $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), t('Basic page content type has been updated.')); @@ -2133,7 +2133,7 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase { // Set "Basic page" content type to use multilingual support. $edit = array( - 'language_content_type' => 1, + 'node_type_language' => 1, ); $this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type')); $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), t('Basic page content type has been updated.')); @@ -2247,7 +2247,7 @@ class LocaleCommentLanguageFunctionalTest extends DrupalWebTestCase { $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language')); // Set "Article" content type to use multilingual support. - $edit = array('language_content_type' => 1); + $edit = array('node_type_language' => 1); $this->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type')); // Enable content language negotiation UI. diff --git a/modules/node/content_types.inc b/modules/node/content_types.inc index d58bc31..1bd45c1 100644 --- a/modules/node/content_types.inc +++ b/modules/node/content_types.inc @@ -183,6 +183,14 @@ function node_type_form($form, &$form_state, $type = NULL) { ), '#description' => t('Users with the Administer content permission will be able to override these options.'), ); + if (module_exists('locale')) { + $form['workflow']['node_type_language'] = array( + '#type' => 'checkbox', + '#title' => t('Multilingual support'), + '#default_value' => variable_get('node_type_language_' . $type->type, 0), + '#description' => t('Add a language selection field to the editing form, allowing you to select from one 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/international/language'))), + ); + } $form['display'] = array( '#type' => 'fieldset', '#title' => t('Display settings'), diff --git a/modules/node/node.install b/modules/node/node.install index 3f732a4..8bc26dd 100644 --- a/modules/node/node.install +++ b/modules/node/node.install @@ -444,6 +444,20 @@ function node_install() { } /** + * Implements hook_uninstall(). + */ +function node_uninstall() { + global $conf; + + $variables = db_query("SELECT name FROM {variable} WHERE name LIKE 'node_%'")->fetchCol(); + foreach ($variables as $variable) { + unset($conf[$variable]); + } + db_query("DELETE FROM {variable} WHERE name LIKE 'node_%'"); + cache_clear_all('variables', 'cache'); +} + +/** * Utility function: fetch the node types directly from the database. * * @ingroup update-api-7.x-to-8.x diff --git a/modules/node/node.js b/modules/node/node.js index ebf68eb..1f1eeef 100644 --- a/modules/node/node.js +++ b/modules/node/node.js @@ -37,6 +37,11 @@ Drupal.behaviors.nodeFieldsetSummaries = { } return vals.join(', '); }); + + $('fieldset#edit-language-information', context).setSummary(function (context) { + var element = $('#edit-language-1'); + return element.find('option[value=' + element.val() + ']').text(); + }); } }; diff --git a/modules/node/node.pages.inc b/modules/node/node.pages.inc index 89335be..dd44974 100644 --- a/modules/node/node.pages.inc +++ b/modules/node/node.pages.inc @@ -150,6 +150,31 @@ function node_form($form, &$form_state, $node) { '#weight' => 99, ); + if (variable_get('node_type_language_' . $node->type, 0) && module_exists('locale')) { + $form['language_information'] = array( + '#type' => 'fieldset', + '#title' => t('Language'), + '#collapsible' => TRUE, + '#collapsed' => isset($node->language), + '#group' => 'additional_settings', + '#attached_js' => array(drupal_get_path('module', 'node') . '/node.js'), + ); + $form['language_information']['language'] = array( + '#type' => 'select', + '#title' => t('Language'), + '#default_value' => (isset($node->language) ? $node->language : ''), + '#options' => array('' => t('Language neutral')) + locale_language_list('name'), + ); + } + else { + $form['language'] = array( + '#type' => 'value', + // New nodes without multilingual support get the default language, old + // nodes keep their language if locale is not available. + '#value' => !isset($form['#node']->nid) ? language_default()->language : $node->language, + ); + } + // Add a log field if the "Create new revision" option is checked, or if the // current user has the ability to check that option. $form['revision_information'] = array( diff --git a/modules/path/path.test b/modules/path/path.test index f42ec81..a99b3e4 100644 --- a/modules/path/path.test +++ b/modules/path/path.test @@ -260,7 +260,7 @@ class PathLanguageTestCase extends DrupalWebTestCase { */ function testAliasTranslation() { // Set 'page' content type to enable translation. - variable_set('language_content_type_page', 2); + variable_set('node_type_language_page', 2); $english_node = $this->drupalCreateNode(array('type' => 'page')); $english_alias = $this->randomName(); diff --git a/modules/translation/translation.module b/modules/translation/translation.module index 697929f..a157dac 100644 --- a/modules/translation/translation.module +++ b/modules/translation/translation.module @@ -111,9 +111,9 @@ function translation_permission() { */ 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'); + $form['workflow']['node_type_language']['#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 installed 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/config/regional/language'))); + $form['workflow']['node_type_language']['#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 installed 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/config/regional/language'))); } /** @@ -471,7 +471,7 @@ function translation_node_get_translations($tnid) { * Boolean value. */ function translation_supported_type($type) { - return variable_get('language_content_type_' . $type, 0) == TRANSLATION_ENABLED; + return variable_get('node_type_language_' . $type, 0) == TRANSLATION_ENABLED; } /** diff --git a/modules/translation/translation.test b/modules/translation/translation.test index fe320a9..7d6afd3 100644 --- a/modules/translation/translation.test +++ b/modules/translation/translation.test @@ -38,7 +38,7 @@ class TranslationTestCase extends DrupalWebTestCase { // translation. $this->drupalGet('admin/structure/types/manage/page'); $edit = array(); - $edit['language_content_type'] = 2; + $edit['node_type_language'] = 2; $this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type')); $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Basic page')), t('Basic page content type has been updated.')); @@ -233,7 +233,7 @@ class TranslationTestCase extends DrupalWebTestCase { // Disable translation support to check that the language switcher is left // untouched only for new nodes. $this->drupalLogin($this->admin_user); - $edit = array('language_content_type' => 0); + $edit = array('node_type_language' => 0); $this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type')); $this->drupalLogin($this->translator);