You are here

function biblio_contributor_create in Bibliography Module 7.2

Same name and namespace in other branches
  1. 7.3 biblio.module \biblio_contributor_create()

Create a contributor entity object

Parameters

string $name (optional) The name of the contributor. If given, this: function will parse out the author name and automatically fill in any associated fields (first name, last name, initials, etc.) and the type

string $type (optional) The contributor type (bundle) of the: contributor entity to create. ex: 'person' or 'organization'. Leave null to let this function parse the name (if passed in) and auto-generate the type.

array $values (optional):

Return value

object The contributor entity object

3 calls to biblio_contributor_create()
biblio_create_contributor_refs in ./biblio.module
Creates contributor reference fields based on user-entered contributor names and categories. Also creates Contributor entities for those contributors that don't already exist.
biblio_create_imported_contributors in includes/biblio.import.export.inc
biblio_get_contributor_by_name in ./biblio.module

File

./biblio.module, line 3304

Code

function biblio_contributor_create($name = NULL, $type = NULL, $values = array()) {
  module_load_include('inc', 'biblio', 'includes/biblio.contributors');
  if (variable_get('biblio_contributor_parser', 1) && isset($name)) {
    $parsed_contributor = biblio_contributor_initial_parse($name);
    if (isset($parsed_contributor->organization)) {
      $values['type'] = 'organization';
    }
    else {
      $values['type'] = 'person';
    }
    $contributor = entity_create('biblio_contributor', $values);
    $contributor->orig_name = $name;
    biblio_contributor_set_parsed_values($contributor, $parsed_contributor);
  }
  else {
    $values['type'] = $type;
    $contributor = entity_create('biblio_contributor', $values);
  }
  $contributor->md5 = _md5sum($contributor);
  return $contributor;
}