You are here

function _biblio_update_field_link_data in Bibliography Module 7

Same name and namespace in other branches
  1. 6.2 biblio.install \_biblio_update_field_link_data()
  2. 7.2 biblio.install \_biblio_update_field_link_data()
2 calls to _biblio_update_field_link_data()
biblio_update_7005 in ./biblio.install
Add information to manage vtabs on input form.
biblio_update_7006 in ./biblio.install

File

./biblio.install, line 2049

Code

function _biblio_update_field_link_data($range, $vtabs = FALSE) {
  $csv_file = drupal_get_path('module', 'biblio') . '/misc/biblio.field.link.data.csv';
  if ($handle = fopen($csv_file, "r")) {

    // The first line has the field names.
    $header = fgetcsv($handle, 10000, ",");
    while (($row = fgetcsv($handle, 10000, ",")) !== FALSE) {
      if ($vtabs) {

        // Add link data for default biblio type (0) and all other defined types (100-130)
        foreach (array_merge(array(
          0,
        ), range($range[0], $range[1])) as $t) {
          db_update('biblio_field_type')
            ->fields(array(
            'vtab' => $row[12],
          ))
            ->condition(db_and()
            ->condition('tid', $t)
            ->condition('fid', $row[0]))
            ->execute();
        }
      }
      else {
        foreach (range($range[0], $range[1]) as $t) {
          db_insert('biblio_field_type')
            ->fields(array(
            'tid' => $t,
            'fid' => $row[0],
            'ftdid' => $row[0],
            'cust_tdid' => $row[0],
            'common' => $row[3],
            'autocomplete' => $row[4],
            'required' => $row[5],
            'weight' => $row[6],
            'visible' => $row[7],
            'vtab' => $row[12],
          ))
            ->execute();
        }
      }
    }
  }
}