function modify_biblio_field_link_data_csv in Bibliography Module 7.2
This function only exists because I'm lazy and don't want to manipulate CSV data by hand. Copy the above lines to call this function quickly @todo remove after development
File
- includes/
biblio.fields.inc, line 299
Code
function modify_biblio_field_link_data_csv() {
$csv_file = drupal_get_path('module', 'biblio') . '/misc/biblio.field.link.data.csv';
$handle = fopen($csv_file, 'r+');
$data = biblio_parse_field_link_data_csv();
$data_to_write[] = array_keys($data[1]);
foreach ($data as $value) {
$data_to_write[] = $value;
}
foreach ($data_to_write as $key => $row) {
if (isset($row[0])) {
// Modify headers here...
}
if (isset($row['fid'])) {
// Modify data here...
// get rid of unsupported field types listed in the CSV
// @todo clean up the CSV and replace with applicable field types
if ($row['type'] == 'contrib_widget' || $row['type'] == 'textfield' || $row['type'] == 'select') {
$data_to_write[$key]['type'] = 'text';
}
if ($row['type'] == 'text_format') {
$data_to_write[$key]['type'] = 'text_long';
}
if ($row['type'] == 'text') {
$data_to_write[$key]['type'] = 'biblio_text';
}
// change all field ids to the order in which they are placed in the file.
$data_to_write[$key]['fid'] = $key;
}
}
foreach ($data_to_write as $key => $value) {
if (isset($value['fid']) || isset($value[0])) {
fputcsv($handle, $value);
}
}
}