Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
229
Merge Requests
229
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
8e6d6e38
Commit
8e6d6e38
authored
Jun 28, 2010
by
Dries
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Patch
#362021
by plach: field_attach_prepare_translation() needs to be updated for D7 API.
parent
8ce1c80c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
3 deletions
+80
-3
modules/field/modules/text/text.module
modules/field/modules/text/text.module
+5
-3
modules/field/modules/text/text.test
modules/field/modules/text/text.test
+75
-0
No files found.
modules/field/modules/text/text.module
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
]);
}
}
}
modules/field/modules/text/text.test
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
)));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment