Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
feeds
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
feeds
Commits
48973a28
Commit
48973a28
authored
8 years ago
by
git
Committed by
MegaChriz
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue #2788125 by MegaChriz, PaulDinelle: Added support for i18n_node bundle language settings.
parent
08a51664
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
plugins/FeedsNodeProcessor.inc
+19
-0
19 additions, 0 deletions
plugins/FeedsNodeProcessor.inc
plugins/FeedsProcessor.inc
+27
-8
27 additions, 8 deletions
plugins/FeedsProcessor.inc
with
46 additions
and
8 deletions
plugins/FeedsNodeProcessor.inc
+
19
−
0
View file @
48973a28
...
...
@@ -32,6 +32,25 @@ class FeedsNodeProcessor extends FeedsProcessor {
return
$info
;
}
/**
* Overrides parent::languageOptions().
*/
public
function
languageOptions
()
{
// Content types can have "extended" language enabled, allowing all
// available languages, not just enabled. Account for this here.
if
(
module_exists
(
'i18n_node'
))
{
$node
=
new
stdClass
();
$node
->
type
=
$this
->
bundle
();
$node
->
is_new
=
TRUE
;
node_object_prepare
(
$node
);
$languages
=
array
(
LANGUAGE_NONE
=>
t
(
'Language neutral'
))
+
i18n_node_language_list
(
$node
);
return
$languages
;
}
// If i18n_node is not enabled, default to enabled languages.
return
parent
::
languageOptions
();
}
/**
* Creates a new node in memory and returns it.
*/
...
...
This diff is collapsed.
Click to expand it.
plugins/FeedsProcessor.inc
+
27
−
8
View file @
48973a28
...
...
@@ -83,6 +83,25 @@ abstract class FeedsProcessor extends FeedsPlugin {
return
$options
;
}
/**
* Provides a list of languages available on the site.
*
* @return array
* A keyed array of language_key => language_name (example: 'en' => 'English').
*/
public
function
languageOptions
()
{
$languages
=
array
(
LANGUAGE_NONE
=>
t
(
'Language neutral'
),
);
$language_list
=
language_list
(
'enabled'
);
if
(
!
empty
(
$language_list
[
1
]))
{
foreach
(
$language_list
[
1
]
as
$language
)
{
$languages
[
$language
->
language
]
=
$language
->
name
;
}
}
return
$languages
;
}
/**
* Create a new entity.
*
...
...
@@ -150,11 +169,11 @@ abstract class FeedsProcessor extends FeedsPlugin {
if
(
!
empty
(
$info
[
'entity keys'
][
'language'
]))
{
// Ensure that a valid language is always set.
$key
=
$info
[
'entity keys'
][
'language'
];
$languages
=
language
_list
(
'enabled'
);
$languages
=
$this
->
language
Options
(
);
if
(
empty
(
$entity
->
$key
)
||
!
isset
(
$languages
[
1
][
$entity
->
$key
]))
{
if
(
empty
(
$entity
->
$key
)
||
!
isset
(
$languages
[
$entity
->
$key
]))
{
$entity
->
$key
=
$this
->
entityLanguage
();
}
;
}
}
// Perform field validation if entity is fieldable.
...
...
@@ -281,9 +300,9 @@ abstract class FeedsProcessor extends FeedsPlugin {
return
LANGUAGE_NONE
;
}
$languages
=
language
_list
(
'enabled'
);
$languages
=
$this
->
language
Options
(
);
return
isset
(
$languages
[
1
][
$this
->
config
[
'language'
]])
?
$this
->
config
[
'language'
]
:
LANGUAGE_NONE
;
return
isset
(
$languages
[
$this
->
config
[
'language'
]])
?
$this
->
config
[
'language'
]
:
LANGUAGE_NONE
;
}
/**
...
...
@@ -919,7 +938,7 @@ abstract class FeedsProcessor extends FeedsPlugin {
if
(
module_exists
(
'locale'
)
&&
!
empty
(
$info
[
'entity keys'
][
'language'
]))
{
$form
[
'language'
]
=
array
(
'#type'
=>
'select'
,
'#options'
=>
array
(
LANGUAGE_NONE
=>
t
(
'Language neutral'
))
+
locale_language_list
(
'name'
),
'#options'
=>
$this
->
languageOptions
(
),
'#title'
=>
t
(
'Language'
),
'#required'
=>
TRUE
,
'#default_value'
=>
$this
->
config
[
'language'
],
...
...
@@ -995,7 +1014,7 @@ abstract class FeedsProcessor extends FeedsPlugin {
if
(
!
isset
(
$cache
[
$this
->
id
]))
{
$mappings
=
$this
->
config
[
'mappings'
];
$targets
=
$this
->
getCachedTargets
();
$languages
=
language
_list
(
'enabled'
);
$languages
=
$this
->
language
Options
(
);
foreach
(
$mappings
as
&
$mapping
)
{
...
...
@@ -1012,7 +1031,7 @@ abstract class FeedsProcessor extends FeedsPlugin {
else
{
// Check if the configured language is available. If not, fallback to
// LANGUAGE_NONE.
if
(
!
isset
(
$languages
[
1
][
$mapping
[
'language'
]]))
{
if
(
!
isset
(
$languages
[
$mapping
[
'language'
]]))
{
$mapping
[
'language'
]
=
LANGUAGE_NONE
;
}
}
...
...
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