You are here

function imagefield_node_import_defaults in Node import 6

Implementation of hook_node_import_defaults().

File

supported/imagefield/imagefield.inc, line 40
Support file for the CCK ImageField module.

Code

function imagefield_node_import_defaults($type, $defaults, $fields, $map) {
  $form = array();
  foreach (node_import_cck_fields($type, 'filefield') as $fieldname => $fieldinfo) {
    if ($fieldinfo['widget']['module'] == 'imagefield') {
      $cck_fieldname = node_import_cck_name($fieldname, 'data');
      foreach (imagefield_filefield_data_info() as $key => $datainfo) {
        $data_fieldname = $cck_fieldname . ':' . $key;
        if (isset($fields[$data_fieldname]) && $fields[$data_fieldname]['is_mappable']) {
          switch ($key) {
            case 'alt':
              $form[$data_fieldname] = array(
                '#title' => $fields[$data_fieldname]['title'],
                '#type' => 'textfield',
                '#default_value' => isset($defaults[$data_fieldname]) ? $defaults[$data_fieldname] : $fields[$data_fieldname]['default_value'],
              );
              break;
            case 'title':
              $form[$data_fieldname] = array(
                '#title' => $fields[$data_fieldname]['title'],
                '#type' => 'textfield',
                '#default_value' => isset($defaults[$data_fieldname]) ? $defaults[$data_fieldname] : $fields[$data_fieldname]['default_value'],
              );
              break;
          }
        }
      }
    }
  }
  return $form;
}