summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Kirkpatrick2013-01-18 23:44:44 (GMT)
committer Tom Kirkpatrick2013-01-18 23:44:44 (GMT)
commitf243a4854a49a9657e82a3ada8e5fbd1686268df (patch)
tree0c71597ac87a9c0de43a4af156edafb94942a335
parentc2a3386ee83c7a2c9ff14c9b3930f6e37f585050 (diff)
Set entity field valies for all active languages
-rw-r--r--variable_config.module63
1 files changed, 34 insertions, 29 deletions
diff --git a/variable_config.module b/variable_config.module
index 2191c88..033063b 100644
--- a/variable_config.module
+++ b/variable_config.module
@@ -366,39 +366,44 @@ function variable_config_entity_load($entities, $type) {
// Get details of fields that have variable defaults.
$options = variable_config_fetch_all_variables();
+ // Get details of all enabled languages.
+ $languages = language_list();
+
foreach ($entities as $entity) {
if (!isset($entity->type)) {
continue;
}
- foreach ($options as $option) {
- $field_name =& $option->field_name;
- if ($type == $option->entity_type && $entity->type == $option->bundle && isset($entity->$field_name)) {
- $field =& $entity->$field_name;
- if (!isset($field[$language->language][0]['value']) || empty($field[$language->language][0]['value'])) {
- switch ($option->type) {
- case 'text':
- $value = variable_get_value($option->entity_type . '_' . $option->bundle . '_' . $option->field_name . '_' . $language->language);
- $field[$language->language][0]['value'] = $value;
- break;
- case 'number':
- $value = variable_get_value($option->entity_type . '_' . $option->bundle . '_' . $option->field_name . '_' . $language->language);
- $field[$language->language][0]['value'] = $value;
- break;
- case 'text_format':
- $value = variable_get_value($option->entity_type . '_' . $option->bundle . '_' . $option->field_name . '_' . $language->language);
- $text_format = isset($value['format']) && !empty($value['format']) ? $value['format'] : filter_default_format();
- $text = trim(check_markup($value['value'], $text_format));
- $field[$language->language][0]['value'] = $text;
- $field[$language->language][0]['format'] = $text_format;
- break;
- case 'mail_text':
- $value = variable_get_value($option->entity_type . '_' . $option->bundle . '_' . $option->field_name . '_' . $language->language . '_[mail_part]');
- $text_format = isset($value['body']['format']) && !empty($value['body']['format']) ? $value['body']['format'] : filter_default_format();
- $subject = trim(check_markup($value['subject'], $text_format));
- $body = trim(check_markup($value['body']['value'], $text_format));
- $field[$language->language][0]['first'] = $value['subject'];
- $field[$language->language][0]['second'] = $body;
- break;
+ foreach ($languages as $language) {
+ foreach ($options as $option) {
+ $field_name =& $option->field_name;
+ if ($type == $option->entity_type && $entity->type == $option->bundle && isset($entity->$field_name)) {
+ $field =& $entity->$field_name;
+ if (!isset($field[$language->language][0]['value']) || empty($field[$language->language][0]['value'])) {
+ switch ($option->type) {
+ case 'text':
+ $value = variable_get_value($option->entity_type . '_' . $option->bundle . '_' . $option->field_name . '_' . $language->language);
+ $field[$language->language][0]['value'] = $value;
+ break;
+ case 'number':
+ $value = variable_get_value($option->entity_type . '_' . $option->bundle . '_' . $option->field_name . '_' . $language->language);
+ $field[$language->language][0]['value'] = $value;
+ break;
+ case 'text_format':
+ $value = variable_get_value($option->entity_type . '_' . $option->bundle . '_' . $option->field_name . '_' . $language->language);
+ $text_format = isset($value['format']) && !empty($value['format']) ? $value['format'] : filter_default_format();
+ $text = trim(check_markup($value['value'], $text_format));
+ $field[$language->language][0]['value'] = $text;
+ $field[$language->language][0]['format'] = $text_format;
+ break;
+ case 'mail_text':
+ $value = variable_get_value($option->entity_type . '_' . $option->bundle . '_' . $option->field_name . '_' . $language->language . '_[mail_part]');
+ $text_format = isset($value['body']['format']) && !empty($value['body']['format']) ? $value['body']['format'] : filter_default_format();
+ $subject = trim(check_markup($value['subject'], $text_format));
+ $body = trim(check_markup($value['body']['value'], $text_format));
+ $field[$language->language][0]['first'] = $value['subject'];
+ $field[$language->language][0]['second'] = $body;
+ break;
+ }
}
}
}