function gathercontent_gathercontent_process_files_field in GatherContent 7.3
Parameters
EntityMetadataWrapper $node: Object of node.
string $local_field_name: Local field name.
string $gathercontent_field_name: Name of field in GatherContent.
bool $is_translatable: Indicator if node is translatable.
string $language: Language of translation if applicable.
array $files: Array of remote files.
1 call to gathercontent_gathercontent_process_files_field()
File
- ./
gathercontent.module, line 1040
Code
function gathercontent_gathercontent_process_files_field(EntityMetadataWrapper &$node, $local_field_name, $gathercontent_field_name, $is_translatable = FALSE, $language = 'und', $files) {
$content_obj = new Content();
$files_to_download = array();
$field_info = field_info_field($local_field_name);
foreach ($files as $file) {
if ($file->field === $gathercontent_field_name) {
$found = FALSE;
if (!is_null($node->{$local_field_name}
->value())) {
foreach ($node->{$local_field_name}
->value() as $local_file_field) {
if ($local_file_field['gathercontent_id'] === $file->id) {
$found = TRUE;
}
}
}
if (!$found) {
$files_to_download[] = $file;
}
}
}
$found_files = $content_obj
->downloadFiles($files_to_download, $field_info);
$is_multiple = $field_info['cardinality'] != 1;
if (!$is_multiple) {
$found_files = !empty($found_files) ? reset($found_files) : NULL;
}
if ($is_translatable) {
$node
->language($language)->{$local_field_name}
->set($found_files);
}
else {
$node->{$local_field_name}
->set($found_files);
}
}