Commit bac3ed77 authored by Dries's avatar Dries

- Patch #1539072 by Gábor Hojtsy: Fixed Support for disabled languages broken, drop it.

parent 4ef74ecd
......@@ -2549,43 +2549,32 @@ function language_multilingual() {
/**
* Returns a list of configured languages.
*
* @param $only_enabled
* (optional) Whether to return only enabled languages.
*
* @return
* An associative array of languages, keyed by the language code, ordered by
* weight ascending and name ascending.
*/
function language_list($only_enabled = FALSE) {
function language_list() {
$languages = &drupal_static(__FUNCTION__);
// Initialize master language list.
if (!isset($languages)) {
// Initialize local language list caches.
$languages = array('all' => array(), 'enabled' => array());
// Fill in master language list based on current configuration.
$default = language_default();
if (language_multilingual() || module_exists('language')) {
// Use language module configuration if available.
$languages['all'] = db_query('SELECT * FROM {language} ORDER BY weight ASC, name ASC')->fetchAllAssoc('langcode');
$languages = db_query('SELECT * FROM {language} ORDER BY weight ASC, name ASC')->fetchAllAssoc('langcode');
}
else {
// No language module, so use the default language only.
$languages['all'][$default->langcode] = $default;
$languages = array($default->langcode => $default);
}
// Initialize default property so callers have an easy reference and can
// save the same object without data loss. Also fill in the filtered list
// of enabled languages only.
foreach ($languages['all'] as $langcode => $language) {
$languages['all'][$langcode]->default = ($langcode == $default->langcode);
if ($language->enabled) {
$languages['enabled'][$langcode] = $languages['all'][$langcode];
}
// save the same object without data loss.
foreach ($languages as $langcode => $language) {
$languages[$langcode]->default = ($langcode == $default->langcode);
}
}
return $only_enabled ? $languages['enabled'] : $languages['all'];
return $languages;
}
/**
......@@ -2636,7 +2625,6 @@ function language_default() {
'langcode' => 'en',
'name' => 'English',
'direction' => 0,
'enabled' => 1,
'weight' => 0,
));
$default->default = TRUE;
......
......@@ -342,8 +342,7 @@ function language_negotiation_method_invoke($method_id, $method = NULL) {
if (!isset($results[$method_id])) {
global $user;
// Get the enabled languages only.
$languages = language_list(TRUE);
$languages = language_list();
if (!isset($method)) {
$negotiation_info = language_negotiation_info();
......
......@@ -184,20 +184,42 @@ function update_prepare_d8_language() {
db_drop_field('languages', 'prefix');
db_drop_field('languages', 'domain');
db_drop_field('languages', 'native');
db_drop_field('languages', 'enabled');
// Update language count.
variable_set('language_count', db_query('SELECT COUNT(language) FROM {languages}')->fetchField());
// Rename the languages table to language.
db_rename_table('languages', 'language');
// Finally install/enable the language module. We need to use the update
// specific version of this function to ensure schema conflicts don't happen
// due to our updated data.
// Install/enable the language module. We need to use the update specific
// version of this function to ensure schema conflicts don't happen due to
// our updated data.
$modules = array('language');
update_module_add_to_system($modules);
update_module_enable($modules);
// Rename 'language' column to 'langcode'.
require_once DRUPAL_ROOT . '/core/modules/language/language.install';
language_update_8000();
db_drop_primary_key('language');
$langcode_spec = array(
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
'description' => "Language code, e.g. 'de' or 'en-US'.",
);
db_change_field('language', 'language', 'langcode', $langcode_spec, array('primary key' => array('langcode')));
// Update the 'language_default' system variable with the langcode change.
$language_default = variable_get('language_default');
if (!empty($language_default)) {
if (isset($language_default->language)) {
$language_default->langcode = $language_default->language;
unset($language_default->language);
}
unset($language_default->enabled);
variable_set('language_default', $language_default);
}
}
}
......
......@@ -19,7 +19,6 @@ function language_admin_overview_form($form, &$form_state) {
'#tree' => TRUE,
'#header' => array(
t('Name'),
t('Enabled'),
t('Default'),
t('Weight'),
t('Operations'),
......@@ -32,13 +31,6 @@ function language_admin_overview_form($form, &$form_state) {
$form['languages'][$langcode]['name'] = array(
'#markup' => check_plain($language->name),
);
$form['languages'][$langcode]['enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enable @title', array('@title' => $language->name)),
'#title_display' => 'invisible',
'#default_value' => (int) $language->enabled,
'#disabled' => $langcode == $default->langcode,
);
$form['languages'][$langcode]['default'] = array(
'#type' => 'radio',
'#parents' => array('site_default'),
......@@ -154,21 +146,6 @@ function language_admin_overview_form_submit($form, &$form_state) {
foreach ($languages as $langcode => $language) {
$language->default = ($form_state['values']['site_default'] == $langcode);
$language->weight = $form_state['values']['languages'][$langcode]['weight'];
if ($language->default || $old_default->langcode == $langcode) {
// Automatically enable the default language and the language which was
// default previously (because we will not get the value from that
// disabled checkbox).
$form_state['values']['languages'][$langcode]['enabled'] = 1;
}
$language->enabled = (int) !empty($form_state['values']['languages'][$langcode]['enabled']);
// If the interface language has been disabled make sure that the form
// redirect includes the new default language as a query parameter.
if ($language->enabled == FALSE && $langcode == $GLOBALS['language_interface']->langcode) {
$form_state['redirect'] = array('admin/config/regional/language', array('language' => $languages[$form_state['values']['site_default']]));
}
language_save($language);
}
......@@ -483,7 +460,6 @@ function language_negotiation_configure_form_table(&$form, $type) {
'#language_negotiation_info' => array(),
'#show_operations' => FALSE,
'weight' => array('#tree' => TRUE),
'enabled' => array('#tree' => TRUE),
);
$negotiation_info = $form['#language_negotiation_info'];
......@@ -694,8 +670,7 @@ function language_negotiation_configure_url_form($form, &$form_state) {
),
);
// Get the enabled languages only.
$languages = language_list(TRUE);
$languages = language_list();
$prefixes = language_negotiation_url_prefixes();
$domains = language_negotiation_url_domains();
foreach ($languages as $langcode => $language) {
......@@ -731,8 +706,7 @@ function language_negotiation_configure_url_form($form, &$form_state) {
* the prefix and domain are only blank for the default.
*/
function language_negotiation_configure_url_form_validate($form, &$form_state) {
// Get the enabled languages only.
$languages = language_list(TRUE);
$languages = language_list();
// Count repeated values for uniqueness check.
$count = array_count_values($form_state['values']['prefix']);
......
......@@ -76,12 +76,6 @@ function language_schema() {
'default' => 0,
'description' => 'Direction of language (Left-to-Right = 0, Right-to-Left = 1).',
),
'enabled' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Enabled flag (1 = Enabled, 0 = Disabled).',
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
......@@ -96,31 +90,3 @@ function language_schema() {
);
return $schema;
}
/**
* Rename {language}.language to {language}.langcode.
*
* @see update_prepare_d8_language()
*/
function language_update_8000() {
// Rename language column to langcode and set it again as the primary key.
if (db_field_exists('language', 'language')) {
db_drop_primary_key('language');
$langcode_spec = array(
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
'description' => "Language code, e.g. 'de' or 'en-US'.",
);
db_change_field('language', 'language', 'langcode', $langcode_spec, array('primary key' => array('langcode')));
}
// Update the 'language_default' system variable, if configured.
$language_default = variable_get('language_default');
if (!empty($language_default) && isset($language_default->language)) {
$language_default->langcode = $language_default->language;
unset($language_default->language);
variable_set('language_default', $language_default);
}
}
......@@ -165,10 +165,6 @@ function language_save($language) {
$language->direction = isset($predefined[$language->langcode][2]) ? $predefined[$language->langcode][2] : LANGUAGE_LTR;
}
// Set to enabled for the default language and unless specified otherwise.
if (!empty($language->default) || !isset($language->enabled)) {
$language->enabled = TRUE;
}
// Let other modules modify $language before saved.
module_invoke_all('language_presave', $language);
......@@ -192,7 +188,7 @@ function language_save($language) {
}
// Update language count based on enabled language count.
variable_set('language_count', db_query('SELECT COUNT(langcode) FROM {language} WHERE enabled = 1')->fetchField());
variable_set('language_count', db_query('SELECT COUNT(langcode) FROM {language}')->fetchField());
// Kill the static cache in language_list().
drupal_static_reset('language_list');
......@@ -220,9 +216,7 @@ function language_delete($langcode) {
->condition('langcode', $language->langcode)
->execute();
if ($language->enabled) {
variable_set('language_count', variable_get('language_count', 1) - 1);
}
variable_set('language_count', variable_get('language_count', 1) - 1);
drupal_static_reset('language_list');
......
......@@ -293,8 +293,7 @@ function language_url_fallback($language = NULL, $language_type = LANGUAGE_TYPE_
* Translation links may be provided by other modules.
*/
function language_switcher_url($type, $path) {
// Get the enabled languages only.
$languages = language_list(TRUE);
$languages = language_list();
$links = array();
foreach ($languages as $language) {
......@@ -316,8 +315,7 @@ function language_switcher_session($type, $path) {
$param = variable_get('language_negotiation_session_param', 'language');
$language_query = isset($_SESSION[$param]) ? $_SESSION[$param] : $GLOBALS[$type]->langcode;
// Get the enabled languages only.
$languages = language_list(TRUE);
$languages = language_list();
$links = array();
$query = $_GET;
......@@ -353,8 +351,7 @@ function language_url_rewrite_url(&$path, &$options) {
$languages = &$drupal_static_fast['languages'];
if (!isset($languages)) {
// Get the enabled languages only.
$languages = language_list(TRUE);
$languages = language_list();
$languages = array_flip(array_keys($languages));
}
......@@ -439,8 +436,7 @@ function language_url_rewrite_session(&$path, &$options) {
if (!isset($query_rewrite)) {
global $user;
if (!$user->uid) {
// Get the enabled languages only.
$languages = language_list(TRUE);
$languages = language_list();
$query_param = check_plain(variable_get('language_negotiation_session_param', 'language'));
$query_value = isset($_GET[$query_param]) ? check_plain($_GET[$query_param]) : NULL;
$query_rewrite = isset($languages[$query_value]) && language_negotiation_method_enabled(LANGUAGE_NEGOTIATION_SESSION);
......
......@@ -74,20 +74,6 @@ class LanguageListTest extends DrupalWebTestCase {
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
$this->assertText(t('The default language cannot be deleted.'), t('Failed to delete the default language.'));
// Check if we can disable a language.
$edit = array(
'languages[en][enabled]' => FALSE,
);
$this->drupalPost(NULL, $edit, t('Save configuration'));
$this->assertNoFieldChecked('edit-languages-en-enabled', t('Language disabled.'));
// Set disabled language to be the default and ensure it is re-enabled.
$edit = array(
'site_default' => 'en',
);
$this->drupalPost(NULL, $edit, t('Save configuration'));
$this->assertFieldChecked('edit-languages-en-enabled', t('Default language re-enabled.'));
// Ensure 'edit' link works.
$this->clickLink(t('edit'));
$this->assertTitle(t('Edit language | Drupal'), t('Page title is "Edit language".'));
......@@ -100,11 +86,16 @@ class LanguageListTest extends DrupalWebTestCase {
$this->assertRaw($name, t('The language has been updated.'));
$this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), t('Correct page redirection.'));
// Change back the default language.
$edit = array(
'site_default' => 'en',
);
$this->drupalPost(NULL, $edit, t('Save configuration'));
// Ensure 'delete' link works.
$this->drupalGet('admin/config/regional/language');
$this->clickLink(t('delete'));
$this->assertText(t('Are you sure you want to delete the language'), t('"delete" link is correct.'));
// Delete an enabled language.
// Delete a language.
$this->drupalGet('admin/config/regional/language/delete/' . $langcode);
// First test the 'cancel' link.
$this->clickLink(t('Cancel'));
......@@ -122,20 +113,13 @@ class LanguageListTest extends DrupalWebTestCase {
$this->assertResponse(404, t('Language no longer found.'));
// Make sure the "language_count" variable has been updated correctly.
drupal_static_reset('language_list');
$enabled_languages = language_list(TRUE);
$this->assertEqual(variable_get('language_count', 1), count($enabled_languages), t('Language count is correct.'));
// Delete a disabled language.
// Disable an enabled language.
$edit = array(
'languages[fr][enabled]' => FALSE,
);
$this->drupalPost($path, $edit, t('Save configuration'));
$this->assertNoFieldChecked('edit-languages-fr-enabled', t('French language disabled.'));
// Get the count of enabled languages.
drupal_static_reset('language_list');
$enabled_languages = language_list(TRUE);
// Delete the disabled language.
$languages = language_list();
$this->assertEqual(variable_get('language_count', 1), count($languages), t('Language count is correct.'));
// Delete French.
$this->drupalPost('admin/config/regional/language/delete/fr', array(), t('Delete'));
// Get the count of languages.
drupal_static_reset('language_list');
$languages = language_list();
// We need raw here because %language and %langcode will add HTML.
$t_args = array('%language' => 'French', '%langcode' => 'fr');
$this->assertRaw(t('The %language (%langcode) language has been removed.', $t_args), t('Disabled language has been removed.'));
......@@ -144,7 +128,7 @@ class LanguageListTest extends DrupalWebTestCase {
$this->drupalGet('admin/config/regional/language/delete/fr');
$this->assertResponse(404, t('Language no longer found.'));
// Make sure the "language_count" variable has not changed.
$this->assertEqual(variable_get('language_count', 1), count($enabled_languages), t('Language count is correct.'));
$this->assertEqual(variable_get('language_count', 1), count($languages), t('Language count is correct.'));
// Ensure we can delete the English language. Right now English is the only
// language so we must add a new language and make it the default before
......@@ -245,7 +229,6 @@ class LanguageDependencyInjectionTest extends DrupalWebTestCase {
'langcode' => 'fr',
'name' => 'French',
'direction' => 0,
'enabled' => 1,
'weight' => 0,
'default' => TRUE,
);
......
......@@ -45,9 +45,7 @@ function locale_date_format_language_overview_page() {
array('data' => t('Operations'), 'colspan' => '2'),
);
// Get the enabled languages only.
$languages = language_list(TRUE);
$languages = language_list();
foreach ($languages as $langcode => $language) {
$row = array();
$row[] = $language->name;
......
......@@ -12,7 +12,7 @@
*/
function locale_translate_import_form($form, &$form_state) {
drupal_static_reset('language_list');
$languages = language_list(TRUE);
$languages = language_list();
// Initialize a language list to the ones available, including English if we
// are to translate Drupal to English as well.
......@@ -127,7 +127,7 @@ function locale_translate_import_form_submit($form, &$form_state) {
* Builds form to export Gettext translation files.
*/
function locale_translate_export_form($form, &$form_state) {
$languages = language_list(TRUE);
$languages = language_list();
$language_options = array();
foreach ($languages as $langcode => $language) {
if ($langcode != 'en' || locale_translate_english()) {
......
......@@ -156,7 +156,7 @@ function locale_translation_filters() {
// Get all languages, except English
drupal_static_reset('language_list');
$languages = language_list(TRUE);
$languages = language_list();
$language_options = array();
foreach ($languages as $langcode => $language) {
if ($langcode != 'en' || locale_translate_english()) {
......
......@@ -1930,24 +1930,6 @@ class LocaleUserLanguageFunctionalTest extends DrupalWebTestCase {
'direction' => '0',
);
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
// Add custom language and disable it.
// Code for the language.
$langcode_disabled = 'xx-yy';
// The English name for the language. This will be translated.
$name_disabled = $this->randomName(16);
$edit = array(
'predefined_langcode' => 'custom',
'langcode' => $langcode_disabled,
'name' => $name_disabled,
'direction' => '0',
);
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
// Disable the language.
$edit = array(
'languages[' . $langcode_disabled . '][enabled]' => FALSE,
);
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
$this->drupalLogout();
// Login as normal user and edit account settings.
......@@ -1958,8 +1940,6 @@ class LocaleUserLanguageFunctionalTest extends DrupalWebTestCase {
$this->assertText(t('Language'), t('Language selector available.'));
// Ensure custom language is present.
$this->assertText($name, t('Language present on form.'));
// Ensure disabled language isn't present.
$this->assertNoText($name_disabled, t('Disabled language not present on form.'));
// Switch to our custom language.
$edit = array(
'preferred_langcode' => $langcode,
......@@ -2289,25 +2269,6 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase {
);
$this->drupalPost('admin/config/regional/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);
$edit = array(
'predefined_langcode' => 'custom',
'langcode' => $langcode_disabled,
'name' => $name_disabled,
'direction' => '0',
);
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add custom language'));
// Disable second custom language.
$path = 'admin/config/regional/language';
$edit = array(
'languages[' . $langcode_disabled . '][enabled]' => FALSE,
);
$this->drupalPost($path, $edit, t('Save configuration'));
// Set "Basic page" content type to use multilingual support.
$this->drupalGet('admin/structure/types/manage/page');
$this->assertText(t('Multilingual support'), t('Multilingual support fieldset present on content type configuration form.'));
......@@ -2328,10 +2289,8 @@ class LocaleContentFunctionalTest extends DrupalWebTestCase {
$this->drupalGet('node/add/page');
// Verify language select list is present.
$this->assertFieldByName('langcode', NULL, t('Language select present on add Basic 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.'));
// Ensure language appears.
$this->assertText($name, t('Language present.'));
// Create "Basic page" content.
$node_title = $this->randomName();
......@@ -2520,7 +2479,7 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase {
// is for some reason not found when doing translate search. This might
// be some bug.
drupal_static_reset('language_list');
$languages = language_list(TRUE);
$languages = language_list();
variable_set('language_default', $languages['vi']);
// First visit this page to make sure our target string is searchable.
$this->drupalGet('admin/config');
......@@ -2780,15 +2739,6 @@ class LocaleUrlRewritingTest extends DrupalWebTestCase {
$edit['predefined_langcode'] = 'fr';
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
// Install Italian language.
$edit = array();
$edit['predefined_langcode'] = 'it';
$this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
// Disable Italian language.
$edit = array('languages[it][enabled]' => FALSE);
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
// Enable URL language detection and selection.
$edit = array('language_interface[enabled][language-url]' => 1);
$this->drupalPost('admin/config/regional/language/detection', $edit, t('Save settings'));
......@@ -2800,13 +2750,9 @@ class LocaleUrlRewritingTest extends DrupalWebTestCase {
}
/**
* Check that disabled or non-installed languages are not considered.
* Check that non-installed languages are not considered.
*/
function testUrlRewritingEdgeCases() {
// Check URL rewriting with a disabled language.
$languages = language_list();
$this->checkUrl($languages['it'], t('Path language is ignored if language is disabled.'), t('URL language negotiation does not work with disabled languages'));
// Check URL rewriting with a non-installed language.
$non_existing = language_default();
$non_existing->langcode = $this->randomName();
......
......@@ -106,7 +106,7 @@ function node_filters() {
// Language filter if language support is present.
if (language_multilingual()) {
$languages = language_list(TRUE);
$languages = language_list();
$language_options = array(LANGUAGE_NOT_SPECIFIED => t('- None -'));
foreach ($languages as $langcode => $language) {
$language_options[$langcode] = $language->name;
......
......@@ -2857,7 +2857,7 @@ function node_form_search_form_alter(&$form, $form_state) {
// Languages:
$language_options = array();
foreach (language_list(TRUE) as $langcode => $language) {
foreach (language_list() as $langcode => $language) {
$language_options[$langcode] = $language->name;
}
if (count($language_options) > 1) {
......
......@@ -176,7 +176,7 @@ function node_form($form, &$form_state, $node) {
$form['#node'] = $node;
if (variable_get('node_type_language_' . $node->type, 0) && module_exists('language')) {
$languages = language_list(TRUE);
$languages = language_list();
$language_options = array();
foreach ($languages as $langcode => $language) {
$language_options[$langcode] = $language->name;
......
......@@ -263,7 +263,7 @@ function openid_form_user_register_form_alter(&$form, &$form_state) {
$candidate_langcodes[] = $parts[0] . '-' . $parts[2];
$candidate_langcodes[] = $parts[0] . '-' . $parts[1] . '-' . $parts[2];
}
$enabled_languages = language_list(TRUE);
$enabled_languages = language_list();
// Iterate over the generated permutations starting with the longest (most
// specific) strings.
foreach (array_reverse($candidate_langcodes) as $candidate_langcode) {
......
......@@ -145,7 +145,7 @@ function path_admin_form($form, &$form_state, $path = array('source' => '', 'ali
// A hidden value unless language.module is enabled.
if (module_exists('language')) {
$languages = language_list(TRUE);
$languages = language_list();
foreach ($languages as $langcode => $language) {
$language_options[$langcode] = $language->name;
}
......
......@@ -532,9 +532,8 @@ class PathMonolingualTestCase extends PathTestCase {
$edit = array('site_default' => 'fr');
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
// Disable English.
$edit = array('languages[en][enabled]' => FALSE);
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
// Delete English.
$this->drupalPost('admin/config/regional/language/delete/en', array(), t('Delete'));
// Verify that French is the only language.
$this->assertFalse(language_multilingual(), t('Site is mono-lingual'));
......
......@@ -1986,16 +1986,14 @@ class SearchLanguageTestCase extends SearchWebTestCase {
$this->drupalPost('search/node', $edit, t('Advanced search'));
$this->assertFieldByXPath('//input[@name="keys"]', 'language:fr', t('Language filter added to query.'));
// Change the default language and disable English.
// Change the default language and delete English.
$path = 'admin/config/regional/language';
$this->drupalGet($path);
$this->assertFieldChecked('edit-site-default-en', t('English is the default language.'));
$edit = array('site_default' => 'fr');
$this->drupalPost(NULL, $edit, t('Save configuration'));
$this->assertNoFieldChecked('edit-site-default-en', t('Default language updated.'));
$edit = array('languages[en][enabled]' => FALSE);
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
$this->assertNoFieldChecked('edit-languages-en-enabled', t('Language disabled.'));
$this->drupalPost('admin/config/regional/language/delete/en', array(), t('Delete'));
// Check that there are again no languages displayed.
$this->drupalGet('search/node');
......
......@@ -3921,17 +3921,15 @@ function system_date_format_save($date_format, $dfid = 0) {
drupal_write_record('date_formats', $info, $keys);
}
// Retrieve an array of language objects for enabled languages.
$languages = language_list(TRUE);
$languages = language_list();
$locale_format = array();
$locale_format['type'] = $date_format['type'];
$locale_format['format'] = $date_format['format'];
// Check if the suggested language codes are configured and enabled.
// Check if the suggested language codes are configured.
if (!empty($date_format['locales'])) {
foreach ($date_format['locales'] as $langcode) {
// Only proceed if language is enabled.
if (isset($languages[$langcode])) {
$is_existing = (bool) db_query_range('SELECT 1 FROM {date_format_locale} WHERE type = :type AND language = :language', 0, 1, array(':type' => $date_format['type'], ':language' => $langcode))->fetchField();
if (!$is_existing) {
......
......@@ -136,28 +136,6 @@ function translation_form_node_form_alter(&$form, &$form_state) {
if (translation_supported_type($form['#node']->type)) {
$node = $form['#node'];
// Build two lists with the disabled and enabled languages.
$languages = language_list();
$grouped_languages = array();
foreach ($languages as $langcode => $language) {
$grouped_languages[(int) $language->enabled][$langcode] = $language;
}
$translator_widget = !empty($grouped_languages[0]) && user_access('translate content');
$groups = array(t('Disabled'), t('Enabled'));
// Allow translators to enter content in disabled languages. Translators
// might need to distinguish between enabled and disabled languages, hence
// we divide them in two option groups.
if ($translator_widget) {
$options = array($groups[1] => array(LANGUAGE_NOT_SPECIFIED => t('- None -')));
foreach (array(1, 0) as $status) {
$group = $groups[$status];
foreach ($grouped_languages[$status] as $langcode => $language) {
$options[$group][$langcode] = $language->name;
}
}
$form['langcode']['#options'] = $options;
}
if (!empty($node->translation_source)) {
// We are creating a translation. Add values and lock language field.
$form['translation_source'] = array('#type' => 'value', '#value' => $node->translation_source);
......@@ -170,13 +148,7 @@ function translation_form_node_form_alter(&$form, &$form_state) {
unset($form['langcode']['#options'][LANGUAGE_NOT_SPECIFIED]);
foreach (translation_node_get_translations($node->tnid) as $langcode => $translation) {
if ($translation->nid != $node->nid) {
if ($translator_widget) {
$group = $groups[(int)!isset($disabled_languages[$langcode])];
unset($form['langcode']['#options'][$group][$langcode]);
}
else {
unset($form['langcode']['#options'][$langcode]);
}
unset($form['langcode']['#options'][$langcode]);
}
}
// Add translation values and workflow options.
......@@ -223,7 +195,7 @@ function translation_node_view($node, $view_mode) {
// If the site has no translations or is not multilingual we have no content
// translation links to display.
if (isset($node->tnid) && language_multilingual() && $translations = translation_node_get_translations($node->tnid)) {
$languages = language_list(TRUE);
$languages = language_list();
// There might be a language provider enabled defining custom language
// switch links which need to be taken into account while generating the
......@@ -236,8 +208,7 @@ function translation_node_view($node, $view_mode) {
$links = array();
foreach ($translations as $langcode => $translation) {
// Do not show links to the same node, to unpublished translations or to
// translations in disabled languages.
// Do not show links to the same node or to unpublished translations.
if ($translation->status && isset($languages[$langcode]) && $langcode != $node->langcode) {
$language = $languages[$langcode];
$key = "translation_$langcode";
......
......@@ -33,11 +33,6 @@ class TranslationTestCase extends DrupalWebTestCase {
// Add languages.
$this->addLanguage('en');
$this->addLanguage('es');
$this->addLanguage('it');
// Disable Italian to test the translation behavior with disabled languages.
$edit = array('languages[it][enabled]' => FALSE);
$this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));