You are here

function _parse_author_array in Bibliography Module 5

3 calls to _parse_author_array()
author_test in ./biblio.module
biblio_contextObject in ./biblio.module
_endnote_tagged_export in ./biblio.module

File

./biblio.module, line 3292

Code

function _parse_author_array($authorArray) {

  //  $input = trim($input);
  // split on ' and '
  //  $authorArray = preg_split("/\s(and)\s/i", $input);
  // check if there's anything that looks like et. al
  $count = 1;
  foreach ($authorArray as $value) {
    $appellation = $prefix = $surname = $firstname = $initials = '';
    $author = explode(",", preg_replace("/\\s{2,}/", ' ', trim($value)));
    $size = sizeof($author);

    // No commas therefore something like Mark Grimshaw, Mark Nicholas Grimshaw, M N Grimshaw, Mark N. Grimshaw
    if ($size == 1) {
      $author = split(" ", $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 {

        // last of array is 'Jr.', 'IV' etc.
        $appellation = array_pop($author);

        // first of array is surname (perhaps with prefix)
        list($surname, $prefix) = _grabSurname(array_shift($author));
      }
    }
    $remainder = join(" ", $author);
    list($firstname, $initials) = _grabFirstnameInitials($remainder);
    $surname = $surname . ' ' . $appellation;
    $creators[] = array(
      'first_name' => trim("{$firstname}"),
      'initials' => trim("{$initials}"),
      'last_name' => trim("{$surname}"),
      'prefix' => trim("{$prefix}"),
      'order' => "{$count}",
    );
    $count++;
  }
  if (isset($creators)) {
    return $creators;
  }
  return FALSE;
}