You are here

function _biblio_update_field_link_data in Bibliography Module 6.2

Same name and namespace in other branches
  1. 7 biblio.install \_biblio_update_field_link_data()
  2. 7.2 biblio.install \_biblio_update_field_link_data()

Parameters

$range:

Return value

array An array of associaive arrays with 'success' and 'query' keys.

1 call to _biblio_update_field_link_data()
biblio_update_6035 in ./biblio.install
Update ...

File

./biblio.install, line 2693
Install, update, and uninstall functions for the biblio module.

Code

function _biblio_update_field_link_data($range) {
  $result = array();
  $schema = biblio_schema();
  $field_type_columns = array_keys($schema['biblio_field_type']['fields']);
  $csv_file = drupal_get_path('module', 'biblio') . '/misc/biblio.field.link.data.csv';
  if ($handle = fopen($csv_file, "r")) {
    $header = fgetcsv($handle, 10000, ",");

    // the first line has the field names
    while (($row = fgetcsv($handle, 10000, ",")) !== FALSE) {
      $column = 0;

      // add link data for default biblio type (0) and all other defined types (100-130)
      foreach (range($range[0], $range[1]) as $t) {
        $field_type_values = array(
          $t,
          $row[0],
          $row[0],
          $row[0],
          $row[3],
          $row[4],
          $row[5],
          $row[6],
          $row[7],
        );
        $result[] = update_sql("INSERT INTO {biblio_field_type} (" . implode(", ", $field_type_columns) . ") " . "VALUES ('" . implode("', '", $field_type_values) . "')");
      }
    }
  }
  return $result;
}