Commit 6ab877fa authored by Gábor Hojtsy's avatar Gábor Hojtsy

#206021 by dropcube and myself: language content type settings were not properly namespaced

parent 8ec14386
......@@ -162,6 +162,44 @@ function locale_update_6004() {
return $ret;
}
/**
* Change language setting variable of content types.
*
* Use language_content_type_<content_type> instead of language_<content_type>
* so content types such as 'default', 'count' or 'negotiation' will not
* interfer with language variables.
*/
function locale_update_6005() {
foreach (node_get_types() as $type => $content_type) {
// Default to NULL, so we can skip dealing with non-existent settings.
$setting = variable_get('language_'. $type, NULL);
if ($type == 'default' && is_numeric($setting)) {
// language_default was overwritten with the content type setting,
// so reset the default language and save the content type setting.
variable_set('language_content_type_default', $setting);
variable_del('language_default');
drupal_set_message('The default language setting has been reset to its default value. Check the '. l('language configuration page', 'admin/settings/language') .' to configure it correctly.');
}
elseif ($type == 'negotiation') {
// Either it is the negotiation setting or the content type setting, it
// is an integer. The language_negotiation setting is not reset, but
// the user is alerted that this setting possibly was overwritten
variable_set('language_content_type_negotiation', $setting);
drupal_set_message('The language negotiation setting was possibly overwritten by a content type of the same name. Check the '. l('language configuration page', 'admin/settings/language/configure') .' and the '. l('<em>'. $content_type->name ."</em> content type's multilingual support settings", 'admin/content/types/negotiation', array('html' => TRUE)) .' to configure them correctly.');
}
elseif (!is_null($setting)) {
// Change the language setting variable for any other content type.
// Do not worry about language_count, it will be updated below.
variable_set('language_content_type_'. $type, $setting);
variable_del('language_'. $type);
}
}
// Update language count variable that might be overwritten.
$count = db_result(db_query('SELECT COUNT(*) FROM {languages} WHERE enabled = 1'));
variable_set('language_count', $count);
return array();
}
/**
* @} End of "defgroup updates-5.x-to-6.x"
*/
......
......@@ -259,10 +259,10 @@ function locale_form_alter(&$form, $form_state, $form_id) {
// Language setting for content types
case 'node_type_form':
if (isset($form['identity']['type'])) {
$form['workflow']['language'] = array(
$form['workflow']['language_content_type'] = array(
'#type' => 'radios',
'#title' => t('Multilingual support'),
'#default_value' => variable_get('language_'. $form['#node_type']->type, 0),
'#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 <a href="!languages">enabled languages</a>. 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'))),
);
......@@ -272,7 +272,7 @@ function locale_form_alter(&$form, $form_state, $form_id) {
// Language field for nodes
default:
if (isset($form['#id']) && $form['#id'] == 'node-form') {
if (isset($form['#node']->type) && variable_get('language_'. $form['#node']->type, 0)) {
if (isset($form['#node']->type) && variable_get('language_content_type_'. $form['#node']->type, 0)) {
$form['language'] = array(
'#type' => 'select',
'#title' => t('Language'),
......
......@@ -99,9 +99,9 @@ function translation_perm() {
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']['#options'][TRANSLATION_ENABLED] = t('Enabled, with translation');
$form['workflow']['language_content_type']['#options'][TRANSLATION_ENABLED] = t('Enabled, with translation');
// Description based on text from locale.module.
$form['workflow']['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 <a href="!languages">enabled languages</a>. 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')));
$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 <a href="!languages">enabled languages</a>. 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)) {
$node = $form['#node'];
......@@ -294,7 +294,7 @@ function translation_node_get_translations($tnid) {
* Boolean value.
*/
function translation_supported_type($type) {
return variable_get('language_'. $type, 0) == TRANSLATION_ENABLED;
return variable_get('language_content_type_'. $type, 0) == TRANSLATION_ENABLED;
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment