You are here

function biblio_parse_author in Bibliography Module 6

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

Parameters

$author_array:

Return value

unknown_type

5 calls to biblio_parse_author()
biblio_authors_add_etal in ./biblio.contributors.inc
Add separate author named "et al" to the end of the author array
biblio_parse_contributors in ./biblio.contributors.inc
Parse initial contributor array and augment with additional info
theme_biblio_authors in ./biblio_theme.inc
theme_biblio_format_authors in ./biblio_theme.inc
_save_contributors in ./biblio.contributors.inc
Save contributors to the database

File

./biblio.contributors.inc, line 268

Code

function biblio_parse_author($author_array, $cat = 0) {
  if ($cat == 5) {
    $author_array['firstname'] = '';
    $author_array['initials'] = '';
    $author_array['lastname'] = trim($author_array['name']);
    $author_array['prefix'] = '';
  }
  else {
    $value = trim($author_array['name']);
    $appellation = $prefix = $surname = $firstname = $initials = '';
    $prefix = "";
    $value = preg_replace("/\\s{2,}/", ' ', $value);

    // replace multiple white space by single space
    $author = explode(",", $value);
    $size = sizeof($author);

    // No commas therefore something like Mark Grimshaw, Mark Nicholas Grimshaw, M N Grimshaw, Mark N. Grimshaw
    if ($size == 1) {

      // Is complete surname enclosed in {...}, unless the string starts with a backslash (\) because then it is
      // probably a special latex-sign..
      // 2006.02.11 DR: in the last case, any NESTED curly braces should also be taken into account! so second
      // clause rules out things such as author="a{\"{o}}"
      //
      if (preg_match("/(.*){([^\\\\].*)}/", $value, $matches) && !preg_match("/(.*){\\\\.{.*}.*}/", $value, $matches2)) {
        $author = explode(" ", $matches[1]);
        $surname = $matches[2];
      }
      else {
        $author = explode(" ", $value);

        // last of array is surname (no prefix if entered correctly)
        $surname = array_pop($author);
      }
    }
    else {
      if ($size == 2) {

        // first of array is surname (perhaps with prefix)
        list($surname, $prefix) = _grabSurname(array_shift($author));
      }
      else {

        // middle of array is 'Jr.', 'IV' etc.
        $appellation = implode(' ', array_splice($author, 1, 1));

        // first of array is surname (perhaps with prefix)
        list($surname, $prefix) = _grabSurname(array_shift($author));
      }
    }
    $remainder = implode(" ", $author);
    list($firstname, $initials, $prefix2) = _grabFirstnameInitials($remainder);
    if (!empty($prefix2)) {
      $prefix .= $prefix2;
    }

    //var_dump($prefix);

    //$surname = $surname . ' ' . $appellation;
    $author_array['firstname'] = trim($firstname);
    $author_array['initials'] = trim($initials);
    $author_array['lastname'] = trim($surname);
    $author_array['prefix'] = trim($prefix);
    $author_array['suffix'] = trim($appellation);
  }
  $author_array['md5'] = _md5sum($author_array);
  return $author_array;
}