Commit 67317ecc authored by Dries's avatar Dries

- Patch #784832 by plach: fixed conflict with the session language provider...

- Patch #784832 by plach: fixed conflict with the session language provider while creating a translation.
parent 7175aab4
......@@ -209,7 +209,7 @@ function translation_node_prepare($node) {
user_access('translate content') &&
// And the $_GET variables are set properly.
isset($_GET['translation']) &&
isset($_GET['language']) &&
isset($_GET['target']) &&
is_numeric($_GET['translation'])) {
$source_node = node_load($_GET['translation']);
......@@ -221,7 +221,8 @@ function translation_node_prepare($node) {
}
$language_list = language_list();
if (!isset($language_list[$_GET['language']]) || ($source_node->language == $_GET['language'])) {
$langcode = $_GET['target'];
if (!isset($language_list[$langcode]) || ($source_node->language == $langcode)) {
// If not supported language, or same language as source node, break.
return;
}
......@@ -229,14 +230,14 @@ function translation_node_prepare($node) {
// Ensure we don't have an existing translation in this language.
if (!empty($source_node->tnid)) {
$translations = translation_node_get_translations($source_node->tnid);
if (isset($translations[$_GET['language']])) {
drupal_set_message(t('A translation of %title in %language already exists, a new %type will be created instead of a translation.', array('%title' => $source_node->title, '%language' => $language_list[$_GET['language']]->name, '%type' => $node->type)), 'error');
if (isset($translations[$langcode])) {
drupal_set_message(t('A translation of %title in %language already exists, a new %type will be created instead of a translation.', array('%title' => $source_node->title, '%language' => $language_list[$langcode]->name, '%type' => $node->type)), 'error');
return;
}
}
// Populate fields based on source node.
$node->language = $_GET['language'];
$node->language = $langcode;
$node->translation_source = $source_node;
$node->title = $source_node->title;
......
......@@ -47,7 +47,7 @@ function translation_node_overview($node) {
// No such translation in the set yet: help user to create it.
$title = t('n/a');
if (node_access('create', $node)) {
$options[] = l(t('add translation'), 'node/add/' . str_replace('_', '-', $node->type), array('query' => array('translation' => $node->nid, 'language' => $language->language)));
$options[] = l(t('add translation'), 'node/add/' . str_replace('_', '-', $node->type), array('query' => array('translation' => $node->nid, 'target' => $language->language)));
}
$status = t('Not translated');
}
......
......@@ -53,7 +53,7 @@ class TranslationTestCase extends DrupalWebTestCase {
// Attempt to submit a duplicate translation by visiting the node/add page
// with identical query string.
$languages = language_list();
$this->drupalGet('node/add/page', array('query' => array('translation' => $node->nid, 'language' => 'es')));
$this->drupalGet('node/add/page', array('query' => array('translation' => $node->nid, 'target' => 'es')));
$this->assertRaw(t('A translation of %title in %language already exists', array('%title' => $node_title, '%language' => $languages['es']->name)), t('Message regarding attempted duplicate translation is displayed.'));
// Attempt a resubmission of the form - this emulates using the back button
......@@ -154,7 +154,7 @@ class TranslationTestCase extends DrupalWebTestCase {
* @param string $language Language code.
*/
function createTranslation($node, $title, $body, $language) {
$this->drupalGet('node/add/page', array('query' => array('translation' => $node->nid, 'language' => $language)));
$this->drupalGet('node/add/page', array('query' => array('translation' => $node->nid, 'target' => $language)));
$body_key = "body[$language][0][value]";
$this->assertFieldByXPath('//input[@id="edit-title"]', $node->title, "Original title value correctly populated.");
......
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