You are here

function biblio_create_imported_contributors in Bibliography Module 7.2

1 call to biblio_create_imported_contributors()
biblio_save_node in includes/biblio.import.export.inc

File

includes/biblio.import.export.inc, line 690
Functions that are used to import and export biblio data.

Code

function biblio_create_imported_contributors(&$biblio) {
  module_load_include('inc', 'biblio', 'includes/biblio.contributors');
  module_load_include('inc', 'biblio', 'includes/biblio.fields');
  $categories = biblio_contributor_categories();
  $biblio_wrap = biblio_wrapper($biblio, 'biblio');
  foreach ($biblio->biblio_contributors as $delta => $contributor_data) {
    $contributor = biblio_get_contributor_by_name($contributor_data['name']);
    if (!$contributor) {
      $contributor = biblio_contributor_create($contributor_data['name']);
      $wrapper = biblio_wrapper($contributor, 'biblio_contributor');
      $wrapper->biblio_contributor_name
        ->set($contributor_data['name']);
      biblio_contributor_save($contributor);
    }
    $cid = $contributor->cid;

    // Add the CID to the list of contributors, in case we need it later
    $biblio->biblio_contributors[$delta]['cid'] = $cid;
    foreach ($categories as $category => $info) {

      // If imported contributor category matches one of our defined categories
      if ($contributor_data['category'] === $category) {

        // Create an entity reference pointing to a contributor entity for
        // the specified category
        $biblio_wrap->{$info['field']}[] = $cid;
      }
    }
  }
}