You are here

function biblio_parse_contributors in Bibliography Module 6

Same name and namespace in other branches
  1. 6.2 includes/biblio.contributors.inc \biblio_parse_contributors()
  2. 7.2 includes/biblio.contributors.inc \biblio_parse_contributors()

Parse initial contributor array and augment with additional info

Parameters

$contributors initial contributor array:

Return value

augmented contributor array

2 calls to biblio_parse_contributors()
_biblio_prepare_submit in ./biblio.module
Prepare a node for submit to database. Contains code common to insert and update.
_move_authors in ./biblio.install

File

./biblio.contributors.inc, line 68

Code

function biblio_parse_contributors($contributors) {
  $result = array();
  if (!count($contributors)) {
    return;
  }
  foreach ($contributors as $cat => $authors) {
    $etal = array();
    foreach ($authors as $author) {

      // remove any form of "et al" from name field, because it confuses biblio_parse_author
      $author_cleaned = preg_replace("/et\\.?\\s+al\\.?/", '', $author['name']);
      if ($author_cleaned != $author['name']) {

        // if "et al" was present:
        $author['name'] = $author_cleaned;

        // store cleaned name
        $etal[$author['auth_type']] = true;

        // mark it as "to be added" in $etal array
      }
      $author['name'] = trim($author['name']);
      if (strlen($author['name'])) {
        $result[$cat][] = biblio_parse_author($author, $cat);
      }
    }

    // add "et al" authors for all neccessary author types
    foreach ($etal as $type => $dummy) {
      if (isset($result[$cat])) {

        // add "et al" only if plain authors exists
        biblio_authors_add_etal($result[$cat], $type);
      }
    }
  }
  return $result;
}