You are here

function globallink_save_field_collections in GlobalLink Connect for Drupal 7.7

Same name and namespace in other branches
  1. 7.5 globallink_node.inc \globallink_save_field_collections()
  2. 7.6 globallink_node.inc \globallink_save_field_collections()

Saves field collections.

Parameters

object $node: The original node.

object $tnode: The translated node.

array $t_arr: The translated array.

1 call to globallink_save_field_collections()
globallink_save_translated_node_with_fields in ./globallink_node.inc
Saves translated node with fields.

File

./globallink_node.inc, line 972

Code

function globallink_save_field_collections($node, $tnode, $t_arr, $target_locale) {
  $field_arr = field_info_instances(GLOBALLINK_ENTITY_TYPE_NODE, $node->type);
  $keys = array_keys($field_arr);
  foreach ($keys as $field) {
    $items = field_get_items(GLOBALLINK_ENTITY_TYPE_NODE, $node, $field);
    if ($items) {
      $field_def = field_read_field($field);
      if ($field_def['type'] == 'field_collection') {
        if (isset($t_arr['field_collection'][$field])) {
          foreach ($items as $entity_id_arr) {
            if (isset($entity_id_arr['value'])) {
              $fc_entity_id = $entity_id_arr['value'];
              globallink_save_field_collections_recursively(GLOBALLINK_ENTITY_TYPE_NODE, $tnode, $fc_entity_id, $t_arr['field_collection'][$field], $target_locale);
            }
          }
        }
      }
    }
  }
}