? .DS_Store ? make_node_optional_14.patch ? node_decouple_locale_00.patch ? node_decouple_locale_01.patch ? node_decouple_locale_02.patch ? node_decouple_locale_03.patch ? node_decouple_locale_04.patch ? node_decouple_locale_05.patch ? modules/.DS_Store ? sites/.DS_Store ? sites/default/files ? sites/default/settings.php Index: modules/locale/locale.install =================================================================== RCS file: /cvs/drupal/drupal/modules/locale/locale.install,v retrieving revision 1.46 diff -u -p -r1.46 locale.install --- modules/locale/locale.install 14 Jul 2009 10:22:17 -0000 1.46 +++ modules/locale/locale.install 5 Aug 2009 11:40:40 -0000 @@ -74,10 +74,6 @@ function locale_uninstall() { variable_del('locale_cache_strings'); variable_del('locale_js_directory'); - 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. Index: modules/locale/locale.module =================================================================== RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v retrieving revision 1.246 diff -u -p -r1.246 locale.module --- modules/locale/locale.module 2 Aug 2009 15:44:08 -0000 1.246 +++ modules/locale/locale.module 5 Aug 2009 11:40:40 -0000 @@ -277,45 +277,6 @@ function locale_form_path_admin_form_alt } /** - * Implement hook_form_FORM_ID_alter(). - */ -function locale_form_node_type_form_alter(&$form, &$form_state) { - if (isset($form['identity']['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/international/language'))), - ); - } -} - -/** - * Implement hook_form_alter(). Adds language fields to forms. - */ -function locale_form_alter(&$form, &$form_state, $form_id) { - if (isset($form['#id']) && $form['#id'] == 'node-form') { - if (isset($form['#node']->type) && variable_get('language_content_type_' . $form['#node']->type, 0)) { - $form['language'] = array( - '#type' => 'select', - '#title' => t('Language'), - '#default_value' => (isset($form['#node']->language) ? $form['#node']->language : ''), - '#options' => array('' => 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 - ); - } - } -} - -/** * Implement hook_theme(). */ function locale_theme() { Index: modules/locale/locale.test =================================================================== RCS file: /cvs/drupal/drupal/modules/locale/locale.test,v retrieving revision 1.33 diff -u -p -r1.33 locale.test --- modules/locale/locale.test 3 Aug 2009 03:04:33 -0000 1.33 +++ modules/locale/locale.test 5 Aug 2009 11:40:41 -0000 @@ -941,7 +941,7 @@ class LocaleUninstallFunctionalTest exte variable_set('language_negotiation', LANGUAGE_NEGOTIATION_PATH_DEFAULT); // 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'); @@ -990,10 +990,6 @@ class LocaleUninstallFunctionalTest exte $javascript_parsed_count = count(variable_get('javascript_parsed', array())); $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); - $this->assertEqual($multilingual, 0, t('Multilingual workflow option: %status', array('%status' => t($multilingual ? 'enabled': 'disabled')))); - // Check JavaScript translations directory. $locale_js_directory = variable_get('locale_js_directory', 'languages'); $this->assertEqual($locale_js_directory, 'languages', t('JavaScript translations directory: %dir', array('%dir' => $locale_js_directory))); @@ -1216,7 +1212,7 @@ class LocalePathFunctionalTest extends D } function setUp() { - parent::setUp('locale', 'path'); + parent::setUp('node', 'locale', 'path'); } /** @@ -1286,130 +1282,3 @@ class LocalePathFunctionalTest extends D $this->drupalLogout(); } } -/** - * Functional tests for multilingual support on nodes. - */ -class LocaleContentFunctionalTest extends DrupalWebTestCase { - public static function getInfo() { - return array( - 'name' => 'Content language settings', - 'description' => 'Checks you can enable multilingual support on content types and configure a language for a node.', - 'group' => 'Locale', - ); - } - - function setUp() { - parent::setUp('locale'); - } - - /** - * Test if a content type can be set to multilingual and language setting is - * present on node add and edit forms. - */ - function testContentTypeLanguageConfiguration() { - global $base_url; - - // User to add and remove language. - $admin_user = $this->drupalCreateUser(array('administer languages', 'administer content types', 'access administration pages')); - // User to create a node. - $web_user = $this->drupalCreateUser(array('create page content', 'edit any page content')); - - // Add custom language. - $this->drupalLogin($admin_user); - // Code for the language. - $langcode = 'xx'; - // The English name for the language. - $name = $this->randomName(16); - // The native name for the language. - $native = $this->randomName(16); - // The domain prefix. - $prefix = $langcode; - $edit = array( - 'langcode' => $langcode, - 'name' => $name, - 'native' => $native, - 'prefix' => $prefix, - 'direction' => '0', - ); - $this->drupalPost('admin/international/language/add', $edit, t('Add custom language')); - - // Add disabled custom language. - // Code for the language. - $langcode_disabled = 'xx-yy'; - // The English name for the language. - $name_disabled = $this->randomName(16); - // The native name for the language. - $native_disabled = $this->randomName(16); - // The domain prefix. - $prefix_disabled = $langcode_disabled; - $edit = array( - 'langcode' => $langcode_disabled, - 'name' => $name_disabled, - 'native' => $native_disabled, - 'prefix' => $prefix_disabled, - 'direction' => '0', - ); - $this->drupalPost('admin/international/language/add', $edit, t('Add custom language')); - // Disable second custom language. - $path = 'admin/international/language'; - $edit = array( - 'enabled[' . $langcode_disabled . ']' => FALSE, - ); - $this->drupalPost($path, $edit, t('Save configuration')); - - // Set language negotiation. - $edit = array( - 'language_negotiation' => LANGUAGE_NEGOTIATION_PATH_DEFAULT, - ); - $this->drupalPost('admin/international/language/configure', $edit, t('Save settings')); - - // Set page content type to use multilingual support. - $this->drupalGet('admin/structure/node-type/page'); - $this->assertText(t('Multilingual support'), t('Multilingual support fieldset present on content type configuration form.')); - $edit = array( - 'language_content_type' => 1, - ); - $this->drupalPost('admin/structure/node-type/page', $edit, t('Save content type')); - $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Page')), t('Page content type has been updated.')); - $this->drupalLogout(); - - // Verify language selection is not present on add article form. - $this->drupalLogin($web_user); - $this->drupalGet('node/add/article'); - // Verify language select list is not present. - $this->assertNoRaw('', t('Language select present on add page form.')); - // Ensure enabled language appears. - $this->assertText($name, t('Enabled language present.')); - // Ensure disabled language doesn't appear. - $this->assertNoText($name_disabled, t('Disabled language not present.')); - - // Create page content. - $node_title = $this->randomName(); - $node_body = $this->randomName(); - $edit = array( - 'type' => 'page', - 'title' => $node_title, - 'body' => array(array('value' => $node_body)), - 'language' => $langcode, - ); - $node = $this->drupalCreateNode($edit); - // Edit the page content and ensure correct language is selected. - $path = 'node/' . $node->nid . '/edit'; - $this->drupalGet($path); - $this->assertRaw('', t('Correct language selected.')); - // Ensure we can change the node language. - $edit = array( - 'language' => 'en', - ); - $this->drupalPost($path, $edit, t('Save')); - $this->assertRaw(t('Page %title has been updated.', array('%title' => $node_title)), t('Page updated.')); - - $this->drupalLogout(); - } -} - Index: modules/node/content_types.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/content_types.inc,v retrieving revision 1.84 diff -u -p -r1.84 content_types.inc --- modules/node/content_types.inc 29 Jul 2009 06:39:34 -0000 1.84 +++ modules/node/content_types.inc 5 Aug 2009 11:40:41 -0000 @@ -169,6 +169,14 @@ function node_type_form(&$form_state, $t ), '#description' => t('Users with the administer nodes 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_' . $form['#node_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'), Index: modules/node/node.install =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.install,v retrieving revision 1.25 diff -u -p -r1.25 node.install --- modules/node/node.install 27 Jul 2009 19:26:31 -0000 1.25 +++ modules/node/node.install 5 Aug 2009 11:40:41 -0000 @@ -335,6 +335,20 @@ function node_schema() { } /** + * Implementation of 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'); +} + +/** * @defgroup updates-6.x-to-7.x System updates from 6.x to 7.x * @{ */ Index: modules/node/node.js =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.js,v retrieving revision 1.4 diff -u -p -r1.4 node.js --- modules/node/node.js 27 Apr 2009 20:19:37 -0000 1.4 +++ modules/node/node.js 5 Aug 2009 11:40:41 -0000 @@ -29,6 +29,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(); + }); } }; Index: modules/node/node.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.pages.inc,v retrieving revision 1.73 diff -u -p -r1.73 node.pages.inc --- modules/node/node.pages.inc 4 Aug 2009 06:44:48 -0000 1.73 +++ modules/node/node.pages.inc 5 Aug 2009 11:40:42 -0000 @@ -161,6 +161,30 @@ function node_form(&$form_state, $node) '#type' => 'vertical_tabs', ); + if (variable_get('node_type_language_' . $node->type, 0)) { + $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'), + ); + } + // Node type without language selector: assign the default for new nodes + elseif (!isset($form['#node']->nid)) { + $form['language'] = array( + '#type' => 'value', + '#value' => language_default()->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. if (!empty($node->revision) || user_access('administer nodes')) { Index: modules/node/node.test =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.test,v retrieving revision 1.38 diff -u -p -r1.38 node.test --- modules/node/node.test 28 Jul 2009 19:18:06 -0000 1.38 +++ modules/node/node.test 5 Aug 2009 11:40:43 -0000 @@ -840,3 +840,130 @@ class NodeAccessRebuildTestCase extends $this->assertText(t('Content permissions have been rebuilt.')); } } + +/** + * Functional tests for multilingual support on nodes. + */ +class NodeLanguageFunctionalTest extends DrupalWebTestCase { + public static function getInfo() { + return array( + 'name' => 'Content language settings', + 'description' => 'Checks you can enable multilingual support on content types and configure a language for a node.', + 'group' => 'Node', + ); + } + + function setUp() { + parent::setUp('node', 'locale'); + } + + /** + * Test if a content type can be set to multilingual and language setting is + * present on node add and edit forms. + */ + function testContentTypeLanguageConfiguration() { + global $base_url; + + // User to add and remove language. + $admin_user = $this->drupalCreateUser(array('administer languages', 'administer content types', 'access administration pages')); + // User to create a node. + $web_user = $this->drupalCreateUser(array('create page content', 'edit any page content')); + + // Add custom language. + $this->drupalLogin($admin_user); + // Code for the language. + $langcode = 'xx'; + // The English name for the language. + $name = $this->randomName(16); + // The native name for the language. + $native = $this->randomName(16); + // The domain prefix. + $prefix = $langcode; + $edit = array( + 'langcode' => $langcode, + 'name' => $name, + 'native' => $native, + 'prefix' => $prefix, + 'direction' => '0', + ); + $this->drupalPost('admin/international/language/add', $edit, t('Add custom language')); + + // Add disabled custom language. + // Code for the language. + $langcode_disabled = 'xx-yy'; + // The English name for the language. + $name_disabled = $this->randomName(16); + // The native name for the language. + $native_disabled = $this->randomName(16); + // The domain prefix. + $prefix_disabled = $langcode_disabled; + $edit = array( + 'langcode' => $langcode_disabled, + 'name' => $name_disabled, + 'native' => $native_disabled, + 'prefix' => $prefix_disabled, + 'direction' => '0', + ); + $this->drupalPost('admin/international/language/add', $edit, t('Add custom language')); + // Disable second custom language. + $path = 'admin/international/language'; + $edit = array( + 'enabled[' . $langcode_disabled . ']' => FALSE, + ); + $this->drupalPost($path, $edit, t('Save configuration')); + + // Set language negotiation. + $edit = array( + 'language_negotiation' => LANGUAGE_NEGOTIATION_PATH_DEFAULT, + ); + $this->drupalPost('admin/international/language/configure', $edit, t('Save settings')); + + // Set page content type to use multilingual support. + $this->drupalGet('admin/structure/node-type/page'); + $this->assertText(t('Multilingual support'), t('Multilingual support fieldset present on content type configuration form.')); + $edit = array( + 'node_type_language' => 1, + ); + $this->drupalPost('admin/structure/node-type/page', $edit, t('Save content type')); + $this->assertRaw(t('The content type %type has been updated.', array('%type' => 'Page')), t('Page content type has been updated.')); + $this->drupalLogout(); + + // Verify language selection is not present on add article form. + $this->drupalLogin($web_user); + $this->drupalGet('node/add/article'); + // Verify language select list is not present. + $this->assertNoRaw('', t('Language select present on add page form.')); + // Ensure enabled language appears. + $this->assertText($name, t('Enabled language present.')); + // Ensure disabled language doesn't appear. + $this->assertNoText($name_disabled, t('Disabled language not present.')); + + // Create page content. + $node_title = $this->randomName(); + $node_body = $this->randomName(); + $edit = array( + 'type' => 'page', + 'title' => $node_title, + 'body' => array(array('value' => $node_body)), + 'language' => $langcode, + ); + $node = $this->drupalCreateNode($edit); + // Edit the page content and ensure correct language is selected. + $path = 'node/' . $node->nid . '/edit'; + $this->drupalGet($path); + $this->assertRaw('', t('Correct language selected.')); + // Ensure we can change the node language. + $edit = array( + 'language' => 'en', + ); + $this->drupalPost($path, $edit, t('Save')); + $this->assertRaw(t('Page %title has been updated.', array('%title' => $node_title)), t('Page updated.')); + + $this->drupalLogout(); + } +} \ No newline at end of file Index: modules/path/path.test =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.test,v retrieving revision 1.16 diff -u -p -r1.16 path.test --- modules/path/path.test 14 Jul 2009 10:22:17 -0000 1.16 +++ modules/path/path.test 5 Aug 2009 11:40:43 -0000 @@ -169,7 +169,7 @@ class PathLanguageTestCase extends Drupa * Create user, setup permissions, log user in, and create a node. */ function setUp() { - parent::setUp('path', 'locale', 'translation'); + parent::setUp('node', 'path', 'locale', 'translation'); // Create and login user. $web_user = $this->drupalCreateUser(array('edit any page content', 'create page content', 'administer url aliases', 'create url aliases', 'administer languages', 'translate content', 'access administration pages')); @@ -193,7 +193,7 @@ class PathLanguageTestCase extends Drupa */ 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'));