switch ($_REQUEST['action']) { case 'manage_fields': manage_fields(); break; case 'add_field': add_field(); break; case 'edit_field': edit_field(); break; case 'drop_field': drop_field(); manage_fields(); break; case 'insert_field': $result = insert_field(); if ($result === TRUE) { manage_fields(); } else { add_field(); } break; case 'update_field': $result = update_field(); if ($result === TRUE) { manage_fields(); } else { edit_field($result); } break; case 'options':
function process_line($h) { global $glob; #if (!$h['image_files']) { return; } #if ($h['id'] != '75') { return; } printf("\n"); printf("Reading source id: %s\n", $h['id']); printf(" Title: %s\n", $h['title']); if (!validate_image_files($h)) { printf(" !! ERROR: %s\n", $h['image_files_error_message']); return; } if (!validate_data_files($h)) { printf(" !! ERROR: %s\n", $h['data_files_error_message']); return; } if (!validate_metadata_files($h)) { printf(" !! ERROR: %s\n", $h['metadata_files_error_message']); return; } if (!validate_doc_files($h)) { printf(" !! ERROR: %s\n", $h['doc_files_error_message']); return; } insert_node($h); printf(" inserted nid: %s\n", $h['nid']); printf(" vid: %s\n", $h['vid']); /* * input column(s): image_files * drupal field: image */ $delta = 0; foreach (preg_split("/,\\s*/", $h['image_files']) as $file) { if ($file) { list($width, $height) = getimagesize($glob['image_src_path'] . "/" . $file); printf(" attaching [%4d X %4d] image: %s\n", $width, $height, $file); $fid = insert_attached_file($h, $file); insert_field($h, "image", array('field_image_fid' => $fid, 'field_image_alt' => NULL, 'field_image_title' => NULL, 'field_image_width' => $width, 'field_image_height' => $height), $delta++); } } /* * input column(s): data_source_url, data_source_title * drupal field: background_link2 */ if ($h['data_source_url'] || $h['data_source_title']) { insert_field($h, "background_link2", array('field_background_link2_url' => $h['data_source_url'], 'field_background_link2_title' => $h['data_source_title'])); } else { // report missing link } /* * input column(s): description * drupal field: description */ insert_field($h, "description", array('field_description_value' => $h['description'], 'field_description_format' => NULL)); /* * input column(s): data_files * drupal field: data_file */ $delta = 0; foreach (preg_split("/,\\s*/", $h['data_files']) as $file) { if ($file) { printf(" attaching data_file: %s\n", $file); $fid = insert_attached_file($h, $file); insert_field($h, "data_file", array('field_data_file_fid' => $fid, 'field_data_file_display' => 1, 'field_data_file_description' => NULL), $delta++); } } /* * input column(s): associated_report * drupal field: associated_report */ $report_nid = report_title_to_nid($h['assoc_report']); if ($report_nid) { insert_field($h, "associated_report", array('field_associated_report_target_id' => $report_nid)); } else { printf(" WARNING: unknown report '%s'\n", $h['assoc_report']); } /* * input column(s): data_type * drupal field: data_type */ if (!$h['data_type']) { printf(" WARNING: empty data_type field\n"); } else { $delta = 0; if (preg_match('/^observ/i', $h['data_type'])) { insert_field($h, "data_type", array('field_data_type_value' => 'Observed'), $delta++); } if (preg_match('/^simul/i', $h['data_type'])) { insert_field($h, "data_type", array('field_data_type_value' => 'Simulated'), $delta++); } } /* * input column(s): metadata_files * drupal field: metadata_file */ $delta = 0; foreach (preg_split("/,\\s*/", $h['metadata_files']) as $file) { if ($file) { printf(" attaching metadata_file: %s\n", $file); $fid = insert_attached_file($h, $file); insert_field($h, "metadata_file", array('field_metadata_file_fid' => $fid, 'field_metadata_file_display' => 1, 'field_metadata_file_description' => NULL), $delta++); } } /* * input column(s): region * drupal field: region */ $region_nid = region_title_to_nid($h['region']); if ($region_nid) { insert_field($h, "region", array('field_region_target_id' => $region_nid)); } else { printf(" WARNING: unknown region '%s'\n", $h['region']); } /* * input column(s): image_source * drupal field: source */ if ($h['image_source']) { insert_field($h, "imgsrc", array('field_imgsrc_value' => $h['image_source'], 'field_imgsrc_format' => NULL)); } else { printf(" WARNING: empty image_source\n"); } /* * input column(s): doc_files * drupal field: supporting_document */ $delta = 0; foreach (preg_split("/,\\s*/", $h['doc_files']) as $file) { if ($file) { printf(" attaching supporting_document: %s\n", $file); $fid = insert_attached_file($h, $file); insert_field($h, "supporting_document", array('field_supporting_document_fid' => $fid, 'field_supporting_document_display' => 1, 'field_supporting_document_description' => NULL), $delta++); } } /* * input column(s): var_type * drupal field: variable_type */ $delta = 0; foreach (preg_split("/,\\s*/", $h['var_type']) as $var_type) { if ($var_type) { $tid = var_type_to_tid($var_type); if ($tid) { insert_field($h, "variable_type", array('field_variable_type_tid' => $tid), $delta++); } else { printf(" WARNING: Unknown var_type: '%s'\n", $var_type); } } } }