diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 8b124f7..2c349ee 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1843,7 +1843,7 @@ function comment_form($form, &$form_state, $comment) { // If a content type has multilingual support we set the comment to inherit the // content language. Otherwise mark the comment as language neutral. $comment_langcode = $comment->langcode; - if (($comment_langcode == LANGUAGE_NOT_SPECIFIED) && !variable_get('node_type_language_selectable_' . $node->type, 0)) { + if (($comment_langcode == LANGUAGE_NOT_SPECIFIED) && !variable_get('node_type_language_locked_' . $node->type, 0)) { $comment_langcode = $language_content->langcode; } $form['langcode'] = array( diff --git a/core/modules/field/modules/text/text.test b/core/modules/field/modules/text/text.test index 0b254d9..3922394 100644 --- a/core/modules/field/modules/text/text.test +++ b/core/modules/field/modules/text/text.test @@ -438,7 +438,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('node_type_language_selectable' => TRANSLATION_ENABLED); + $edit = array('node_type_language_locked' => FALSE, 'node_type_language_translation_enabled' => TRANSLATION_ENABLED); $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.test b/core/modules/locale/locale.test index 157d52e..cfcf879 100644 --- a/core/modules/locale/locale.test +++ b/core/modules/locale/locale.test @@ -1419,7 +1419,7 @@ class LocaleUninstallFunctionalTest extends DrupalWebTestCase { $this->assertEqual($GLOBALS['language_interface']->langcode, $this->langcode, t('Current language: %lang', array('%lang' => $GLOBALS['language_interface']->langcode))); // Enable multilingual workflow option for articles. - variable_set('node_type_language_selectable_article', 1); + variable_set('node_type_language_locked_article', FALSE); // Change JavaScript translations directory. variable_set('locale_js_directory', 'js_translations'); @@ -2141,7 +2141,7 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase { $this->drupalGet('admin/structure/types/manage/page'); $this->assertText(t('Language settings'), t('Multilingual support fieldset present on content type configuration form.')); $edit = array( - 'node_type_language_selectable' => 1, + 'node_type_language_locked' => FALSE, ); $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.')); @@ -2211,7 +2211,7 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase { // Set "Article" content type to use multilingual support. $this->drupalGet('admin/structure/types/manage/article'); $edit = array( - 'node_type_language_selectable' => 1, + 'node_type_language_locked' => FALSE, ); $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.')); @@ -2707,7 +2707,7 @@ class LocaleMultilingualFieldsFunctionalTest extends DrupalWebTestCase { // Set "Basic page" content type to use multilingual support. $edit = array( - 'node_type_language_selectable' => 1, + 'node_type_language_locked' => FALSE, ); $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.')); @@ -2823,7 +2823,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('node_type_language_selectable' => 1); + $edit = array('node_type_language_locked' => FALSE); $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 60477fb..0ccbfde 100644 --- a/core/modules/node/content_types.inc +++ b/core/modules/node/content_types.inc @@ -220,15 +220,12 @@ function node_type_form($form, &$form_state, $type = NULL) { '#options' => $lang_options, '#default_value' => variable_get('node_type_language_default_' . $type->type, 'site_default'), ); - $form['language']['node_type_language_selectable'] = array( - '#type' => 'radios', - '#title' => t('Language selection on node edit form'), - '#options' => array( - 0 => t('Locked'), - 1 => t('Selectable'), - ), - '#default_value' => variable_get('node_type_language_selectable_' . $type->type, 0), - ); + $form['language']['node_type_language_locked'] = array( + '#type' => 'checkbox', + '#title' => t('Lock language'), + '#default_value' => variable_get('node_type_language_locked_' . $type->type, TRUE), + '#description' => t('Users will not be able to change the default language on content of this type.'), + ); } $form['display'] = array( '#type' => 'fieldset', diff --git a/core/modules/node/content_types.js b/core/modules/node/content_types.js index a3ec87d..c5634c0 100644 --- a/core/modules/node/content_types.js +++ b/core/modules/node/content_types.js @@ -39,6 +39,15 @@ Drupal.behaviors.contentTypes = { } return vals.join(', '); }); + $('#edit-node-type-language-default, #edit-node-type-language-locked', context).change(function(context) { + if ($('#edit-node-type-language-default').val() == 'und' && $('#edit-node-type-language-locked').attr('checked')) { + $('#edit-node-type-language-translation-enabled').attr('disabled', true); + $('#edit-node-type-language-translation-enabled').removeAttr('checked'); + } else { + $('#edit-node-type-language-translation-enabled').removeAttr('disabled'); + } + }); + $('#edit-node-type-language-default', context).trigger('change'); } }; diff --git a/core/modules/node/node.install b/core/modules/node/node.install index 0f9c274..b5ff86b 100644 --- a/core/modules/node/node.install +++ b/core/modules/node/node.install @@ -459,9 +459,11 @@ function node_uninstall() { ->condition('name', 'node_submitted_' . $type) ->condition('name', 'node_permissions_' . $type) ->condition('name', 'node_type_language_default_' . $type) - ->condition('name', 'node_type_language_selectable_' . $type) + ->condition('name', 'node_type_language_locked_' . $type) ) ->execute(); + // TODO: node_type_language_translation_enabled_ in the translation module + // ->condition('name', 'node_type_language_translation_enabled_' . $type) } // Delete node search ranking variables. @@ -560,16 +562,17 @@ function node_update_8002() { /** * Rename node type language variable names. - * - * @see http://drupal.org/node/258785 */ function node_update_8003() { $types = db_query('SELECT type FROM {node_type}')->fetchCol(); foreach ($types as $type) { - $language = variable_get('node_type_language_' . $type, 0); - if (isset($language)) { - variable_set('node_type_language_default_' . $type, language_default()->langcode); - variable_set('node_type_language_selectable_' . $type, $language); + variable_set('node_type_language_default_' . $type, LANGUAGE_NOT_SPECIFIED); + $language = variable_get('node_type_language_' . $type, 0); + if ($language == 0) { + variable_set('node_type_language_locked_' . $type, TRUE); + } + if ($language == 2) { + variable_set('node_type_language_translation_enabled_' . $type, 2); } variable_del('node_type_language_' . $type); } diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc index 8554141..3f27428 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -192,7 +192,7 @@ function node_form($form, &$form_state, $node) { '#default_value' => (isset($node->langcode) ? $node->langcode : ''), '#options' => $language_options, '#empty_value' => LANGUAGE_NOT_SPECIFIED, - '#disabled' => !variable_get('node_type_language_selectable_' . $node->type, 0), + '#disabled' => variable_get('node_type_language_locked_' . $node->type, TRUE), ); } else { diff --git a/core/modules/path/path.test b/core/modules/path/path.test index 7e968f7..3aab64a 100644 --- a/core/modules/path/path.test +++ b/core/modules/path/path.test @@ -302,7 +302,8 @@ class PathLanguageTestCase extends PathTestCase { */ function testAliasTranslation() { // Set 'page' content type to enable translation. - variable_set('node_type_language_selectable_page', TRANSLATION_ENABLED); + variable_set('node_type_language_locked_page', FALSE); + variable_set('node_type_language_translation_enabled_page', TRANSLATION_ENABLED); $english_node = $this->drupalCreateNode(array('type' => 'page')); $english_alias = $this->randomName(); diff --git a/core/modules/poll/poll.test b/core/modules/poll/poll.test index 880057e..ae84ddd 100644 --- a/core/modules/poll/poll.test +++ b/core/modules/poll/poll.test @@ -833,7 +833,7 @@ class PollTranslateTestCase extends PollWebTestCase { // Set "Poll" content type to use multilingual support with translation. $this->drupalGet('admin/structure/types/manage/poll'); - $edit = array('node_type_language_selectable' => TRANSLATION_ENABLED); + $edit = array('node_type_language_locked' => FALSE, 'node_type_language_translation_enabled' => TRANSLATION_ENABLED); $this->drupalPost('admin/structure/types/manage/poll', $edit, t('Save content type')); $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Poll')), t('Poll content type has been updated.')); diff --git a/core/modules/translation/translation.install b/core/modules/translation/translation.install index 0204699..0c15c8e 100644 --- a/core/modules/translation/translation.install +++ b/core/modules/translation/translation.install @@ -13,9 +13,9 @@ function translation_uninstall() { // 'Selectable with translation support'. $types = db_query('SELECT type FROM {node_type}')->fetchCol(); foreach ($types as $type) { - $translatable = variable_get('node_type_language_selectable_' . $type, 0); - if ($translatable == TRANSLATION_ENABLED) { - variable_set('node_type_language_selectable_' . $type, 1); + $translatable = variable_get('node_type_language_locked_' . $type, FALSE); + if ($translatable) { + variable_set('node_type_language_locked_' . $type, 0); } } } diff --git a/core/modules/translation/translation.module b/core/modules/translation/translation.module index e72832f..009ab3d 100644 --- a/core/modules/translation/translation.module +++ b/core/modules/translation/translation.module @@ -118,7 +118,24 @@ function translation_permission() { */ function translation_form_node_type_form_alter(&$form, &$form_state) { // Add translation option to content type form. - $form['language']['node_type_language_selectable']['#options'][TRANSLATION_ENABLED] = t('Selectable with translation support'); + $form['language']['node_type_language_translation_enabled'] = array( + '#type' => 'checkbox', + '#title' => t('Enable translation'), + '#return_value' => TRANSLATION_ENABLED, + '#default_value' => variable_get('node_type_language_translation_enabled_' . $form['#node_type']->type, FALSE), + '#element_validate' => array('translation_node_type_language_translation_enabled_validate'), + '#prefix' => "", + ); +} + +/** + * Checks that translation is disabled when default language is none and + * default language is locked. + */ +function translation_node_type_language_translation_enabled_validate($element, &$form_state, $form){ + if ($form_state['values']['node_type_language_default'] == 'und' && $form_state['values']['node_type_language_locked'] && $form_state['values']['node_type_language_translation_enabled'] == TRANSLATION_ENABLED) { + form_set_error('node_type_language_translation_enabled', t('Translation cannot be enabled if no default language is None and locked.')); + } } /** @@ -485,7 +502,7 @@ function translation_node_get_translations($tnid) { * TRUE if translation is supported, and FALSE if not. */ function translation_supported_type($type) { - return variable_get('node_type_language_selectable_' . $type, 0) == TRANSLATION_ENABLED; + return variable_get('node_type_language_translation_enabled_' . $type, 0) == TRANSLATION_ENABLED; } /** diff --git a/core/modules/translation/translation.test b/core/modules/translation/translation.test index 9a6e779..2683ae9 100644 --- a/core/modules/translation/translation.test +++ b/core/modules/translation/translation.test @@ -42,7 +42,7 @@ class TranslationTestCase extends DrupalWebTestCase { // Set "Basic page" content type to use multilingual support with // translation. $this->drupalGet('admin/structure/types/manage/page'); - $edit = array('node_type_language_selectable' => TRANSLATION_ENABLED); + $edit = array('node_type_language_locked' => FALSE, 'node_type_language_translation_enabled' => TRANSLATION_ENABLED); $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('node_type_language_selectable' => 0); + $edit = array('node_type_language_locked' => TRUE, 'node_type_language_translation_enabled' => FALSE); $this->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type')); $this->drupalLogin($this->translator);