You are here

function filefield_filefield_paths_get_fields in File (Field) Paths 5

Same name and namespace in other branches
  1. 6 modules/filefield.inc \filefield_filefield_paths_get_fields()

Implementation of hook_filefield_paths_get_fields().

File

modules/filefield.inc, line 59
Provides FileField Paths integration with the FileField module.

Code

function filefield_filefield_paths_get_fields(&$node, &$ffp) {
  if (is_object($node)) {
    $content_type = content_types($node->type);
    foreach ($content_type['fields'] as $field) {
      if (preg_match('/\\bfile\\b|\\bimage\\b/', $field['type']) && isset($node->{$field}['field_name']) && is_array($node->{$field}['field_name'])) {
        foreach ($node->{$field}['field_name'] as &$file) {
          $ffp['#files'][] = array(
            'field' => &$file,
            'module' => $field['type'],
            'name' => $field['field_name'],
            'widget' => $field['widget']['type'],
            'new' => !empty($file['filepath']) && !empty($file['data']['process']) ? TRUE : FALSE,
          );
          $ffp['#types'][$field['field_name']] = TRUE;
        }
      }
    }
  }
}