diff --git a/core/modules/field/modules/text/text.test b/core/modules/field/modules/text/text.test index 5936937..e061a39 100644 --- a/core/modules/field/modules/text/text.test +++ b/core/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/core/modules/locale/locale.install b/core/modules/locale/locale.install index 77da39c..95437d0 100644 --- a/core/modules/locale/locale.install +++ b/core/modules/locale/locale.install @@ -53,10 +53,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/core/modules/locale/locale.module b/core/modules/locale/locale.module index 18cf99d..d627197 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -305,31 +305,6 @@ function locale_language_selector_form($user) { } /** - * 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. @@ -353,22 +328,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'; } @@ -1076,7 +1035,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/core/modules/locale/locale.test b/core/modules/locale/locale.test index 7506242..ed08fee 100644 --- a/core/modules/locale/locale.test +++ b/core/modules/locale/locale.test @@ -1218,7 +1218,7 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase { $this->assertEqual($GLOBALS['language']->language, $this->language, t('Current language: %lang', array('%lang' => $GLOBALS['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'); @@ -1288,7 +1288,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. @@ -1915,7 +1915,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.')); @@ -2330,7 +2330,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.')); @@ -2444,7 +2444,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/core/modules/node/content_types.inc b/core/modules/node/content_types.inc index d58bc31..1bd45c1 100644 --- a/core/modules/node/content_types.inc +++ b/core/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/core/modules/node/node.install b/core/modules/node/node.install index 3f732a4..898655d 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -444,6 +444,22 @@ 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_delete('variable') + ->condition('name', 'node_%', 'LIKE') + ->execute(); + 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/core/modules/node/node.js b/core/modules/node/node.js index ebf68eb..1f1eeef 100644 --- a/core/modules/node/node.js +++ b/core/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/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc index c7b26e7..033ca39 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -149,6 +149,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/core/modules/path/path.test b/core/modules/path/path.test index 8f0406e..47bff87 100644 --- a/core/modules/path/path.test +++ b/core/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/core/modules/translation/translation.module b/core/modules/translation/translation.module index 7d47a6d..a1d0b76 100644 --- a/core/modules/translation/translation.module +++ b/core/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/core/modules/translation/translation.test b/core/modules/translation/translation.test index c8a1ccd..89c918d 100644 --- a/core/modules/translation/translation.test +++ b/core/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);