summaryrefslogtreecommitdiff
path: root/modules/translation
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-06-06 00:24:16 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-06-06 00:24:16 +0000
commitcf30c78b42058488fb8fb4f535a469285ca31a31 (patch)
tree4a26806c2eaead66fcf39f3f0665916d5a333a89 /modules/translation
parent8fb6adbc21302e896b1019aad2edd5c87a518a98 (diff)
downloadbrdo-cf30c78b42058488fb8fb4f535a469285ca31a31.tar.gz
brdo-cf30c78b42058488fb8fb4f535a469285ca31a31.tar.bz2
#362021 by plach, yched, sun: Update field_attach_prepare_translation() for D7 entity API.
Diffstat (limited to 'modules/translation')
-rw-r--r--modules/translation/translation.module10
-rw-r--r--modules/translation/translation.test13
2 files changed, 11 insertions, 12 deletions
diff --git a/modules/translation/translation.module b/modules/translation/translation.module
index c79f75254..cb2731bd8 100644
--- a/modules/translation/translation.module
+++ b/modules/translation/translation.module
@@ -240,13 +240,9 @@ function translation_node_prepare($node) {
$node->translation_source = $source_node;
$node->title = $source_node->title;
- // If user has no access to the filter used for the body, Drupal core
- // does not let the edit form to appear, so we should avoid exposing
- // the source text here too.
- $formats = filter_formats();
- $node->body = (filter_access($formats[$source_node->body[$source_node->language][0]['format']])) ? $source_node->body : '';
- // Let every module add custom translated fields.
- module_invoke_all('node_prepare_translation', $node);
+ // Add field translations and let other modules module add custom translated
+ // fields.
+ field_attach_prepare_translation('node', $node, $node->language, $source_node, $source_node->language);
}
}
diff --git a/modules/translation/translation.test b/modules/translation/translation.test
index 19b421df8..ffcbd5466 100644
--- a/modules/translation/translation.test
+++ b/modules/translation/translation.test
@@ -48,7 +48,7 @@ class TranslationTestCase extends DrupalWebTestCase {
// Submit translation in Spanish.
$node_translation_title = $this->randomName();
$node_translation_body = $this->randomName();
- $node_translation = $this->createTranslation($node->nid, $node_translation_title, $node_translation_body, 'es');
+ $node_translation = $this->createTranslation($node, $node_translation_title, $node_translation_body, 'es');
// Attempt to submit a duplicate translation by visiting the node/add page
// with identical query string.
@@ -153,13 +153,16 @@ class TranslationTestCase extends DrupalWebTestCase {
* @param string $body Body of basic page in specified language.
* @param string $language Language code.
*/
- function createTranslation($nid, $title, $body, $language) {
- $this->drupalGet('node/add/page', array('query' => array('translation' => $nid, 'language' => $language)));
+ function createTranslation($node, $title, $body, $language) {
+ $this->drupalGet('node/add/page', array('query' => array('translation' => $node->nid, 'language' => $language)));
+
+ $body_key = "body[$language][0][value]";
+ $this->assertFieldByXPath('//input[@id="edit-title"]', $node->title, "Original title value correctly populated.");
+ $this->assertFieldByXPath("//textarea[@name='$body_key']", $node->body[$node->language][0]['value'], "Original body value correctly populated.");
$edit = array();
- $langcode = LANGUAGE_NONE;
$edit["title"] = $title;
- $edit["body[$language][0][value]"] = $body;
+ $edit[$body_key] = $body;
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertRaw(t('Basic page %title has been created.', array('%title' => $title)), t('Translation created.'));