You are here

function biblio_parse_contributors in Bibliography Module 7.2

Same name and namespace in other branches
  1. 6.2 includes/biblio.contributors.inc \biblio_parse_contributors()
  2. 6 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

File

includes/biblio.contributors.inc, line 103

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;
}