You are here

function filefield_node_import_fields in Node import 6

Implementation of hook_node_import_fields().

File

supported/filefield/filefield.inc, line 11
Support file for the CCK FileField module.

Code

function filefield_node_import_fields($type) {
  $fields = array();
  foreach (node_import_cck_fields($type, 'filefield') as $fieldname => $fieldinfo) {
    foreach ($fieldinfo['columns'] as $colname => $colinfo) {
      $cck_fieldname = node_import_cck_name($fieldname, $colname);
      $fields[$cck_fieldname] = node_import_cck_field_defaults($fieldinfo);
      switch ($colname) {
        case 'fid':
          $fields[$cck_fieldname]['title'] = $fieldinfo['widget']['label'];
          $fields[$cck_fieldname]['input_format'] = 'filepath';
          $fields[$cck_fieldname]['to_directory'] = $fieldinfo['widget']['file_path'];
          $fields[$cck_fieldname]['map_required'] = $fieldinfo['required'];
          break;
        case 'list':
          $fields[$cck_fieldname]['title'] = $fieldinfo['widget']['label'] . ' - ' . t('List');
          $fields[$cck_fieldname]['is_mappable'] = $fieldinfo['list_field'];
          $fields[$cck_fieldname]['input_format'] = 'boolean';
          $fields[$cck_fieldname]['default_value'] = $fieldinfo['list_default'];
          break;
        case 'data':

          // The data column stores a number of values, each needing a separate
          // field! Only 'description' is supported by filefield module, we
          // make the others unmappable by default.
          foreach (filefield_data_info() as $key => $datainfo) {
            $data_fieldname = $cck_fieldname . ':' . $key;
            $fields[$data_fieldname] = $fields[$cck_fieldname];
            switch ($key) {
              case 'description':
                $fields[$data_fieldname]['title'] = $fieldinfo['widget']['label'] . ' - ' . t('Description');
                $fields[$data_fieldname]['is_mappable'] = $fieldinfo['description_field'];
                $fields[$data_fieldname]['default_value'] = '';
                break;
              default:
                $fields[$data_fieldname]['title'] = t('Unsupported: ') . $fieldinfo['widget']['label'] . ' - ' . $datainfo['title'];
                $fields[$data_fieldname]['is_mappable'] = FALSE;
                break;
            }
          }

          // Hide the data field.
          $fields[$cck_fieldname]['is_mappable'] = FALSE;
          break;
        default:
          $fields[$cck_fieldname]['title'] = t('Unsupported: ') . $fieldinfo['widget']['label'] . ' - ' . $colname;
          break;
      }
    }
  }
  return $fields;
}