Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3443915
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3443915
Commits
8e6d6e38
Commit
8e6d6e38
authored
14 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#362021
by plach: field_attach_prepare_translation() needs to be updated for D7 API.
parent
8ce1c80c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/field/modules/text/text.module
+5
-3
5 additions, 3 deletions
modules/field/modules/text/text.module
modules/field/modules/text/text.test
+75
-0
75 additions, 0 deletions
modules/field/modules/text/text.test
with
80 additions
and
3 deletions
modules/field/modules/text/text.module
+
5
−
3
View file @
8e6d6e38
...
...
@@ -601,8 +601,10 @@ function text_field_prepare_translation($entity_type, $entity, $field, $instance
// we must not expose the source values.
$field_name
=
$field
[
'field_name'
];
$formats
=
filter_formats
();
$format_id
=
$source_entity
->
{
$field_name
}[
$source_langcode
][
0
][
'format'
];
if
(
!
filter_access
(
$formats
[
$format_id
]))
{
$items
=
array
();
foreach
(
$source_entity
->
{
$field_name
}[
$source_langcode
]
as
$delta
=>
$item
)
{
$format_id
=
$item
[
'format'
];
if
(
!
filter_access
(
$formats
[
$format_id
]))
{
unset
(
$items
[
$delta
]);
}
}
}
This diff is collapsed.
Click to expand it.
modules/field/modules/text/text.test
+
75
−
0
View file @
8e6d6e38
...
...
@@ -373,3 +373,78 @@ class TextSummaryTestCase extends DrupalWebTestCase {
$this
->
assertIdentical
(
$summary
,
$expected
,
t
(
'Generated summary "@summary" matches expected "@expected".'
,
array
(
'@summary'
=>
$summary
,
'@expected'
=>
$expected
)));
}
}
class
TextTranslationTestCase
extends
DrupalWebTestCase
{
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Text translation'
,
'description'
=>
'Check if the text field is correctly prepared for translation.'
,
'group'
=>
'Field types'
,
);
}
function
setUp
()
{
parent
::
setUp
(
'locale'
,
'translation'
);
$this
->
format
=
3
;
$this
->
admin
=
$this
->
drupalCreateUser
(
array
(
'administer languages'
,
'administer content types'
,
'access administration pages'
,
'bypass node access'
,
"use text format
$this->format
"
));
$this
->
translator
=
$this
->
drupalCreateUser
(
array
(
'create article content'
,
'edit own article content'
,
'translate content'
));
// Enable an additional language.
$this
->
drupalLogin
(
$this
->
admin
);
$edit
=
array
(
'langcode'
=>
'fr'
);
$this
->
drupalPost
(
'admin/config/regional/language/add'
,
$edit
,
t
(
'Add language'
));
// Set "Article" content type to use multilingual support with translation.
$edit
=
array
(
'language_content_type'
=>
2
);
$this
->
drupalPost
(
'admin/structure/types/manage/article'
,
$edit
,
t
(
'Save content type'
));
$this
->
assertRaw
(
t
(
'The content type %type has been updated.'
,
array
(
'%type'
=>
'Article'
)),
t
(
'Article content type has been updated.'
));
}
/**
* Check that user that does not have access the field format cannot see the
* source value when creating a translation.
*/
function
testMultipleTextField
()
{
// Make node body multiple.
$edit
=
array
(
'field[cardinality]'
=>
-
1
);
$this
->
drupalPost
(
'admin/structure/types/manage/article/fields/body'
,
$edit
,
t
(
'Save settings'
));
$this
->
drupalGet
(
'node/add/article'
);
$this
->
assertFieldByXPath
(
"//input[@name='body_add_more']"
,
t
(
'Add another item'
),
t
(
'Body field cardinality set to multiple.'
));
$body
=
array
(
$this
->
randomName
(),
$this
->
randomName
(),
);
// Create an article with the first body input format set to "Full HTML".
$langcode
=
'en'
;
$edit
=
array
(
"title"
=>
$this
->
randomName
(),
'language'
=>
$langcode
,
);
$this
->
drupalPost
(
'node/add/article'
,
$edit
,
t
(
'Save'
));
// Populate the body field: the first item gets the "Full HTML" input
// format, the second one "Filtered HTML".
$format
=
$this
->
format
;
foreach
(
$body
as
$delta
=>
$value
)
{
$edit
=
array
(
"body[
$langcode
][
$delta
][value]"
=>
$value
,
"body[
$langcode
][
$delta
][format]"
=>
$format
--
,
);
$this
->
drupalPost
(
'node/1/edit'
,
$edit
,
t
(
'Save'
));
$this
->
assertText
(
$body
[
$delta
],
t
(
'The body field with delta @delta has been saved.'
,
array
(
'@delta'
=>
$delta
)));
}
// Login as translator.
$this
->
drupalLogout
();
$this
->
drupalLogin
(
$this
->
translator
);
// Translate the article in french.
$this
->
drupalGet
(
'node/1/translate'
);
$this
->
clickLink
(
t
(
'add translation'
));
$this
->
assertNoText
(
$body
[
0
],
t
(
'The body field with delta @delta is hidden.'
,
array
(
'@delta'
=>
0
)));
$this
->
assertText
(
$body
[
1
],
t
(
'The body field with delta @delta is shown.'
,
array
(
'@delta'
=>
1
)));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment