You are here

function _grabSurname in Bibliography Module 7

Same name and namespace in other branches
  1. 5 biblio.module \_grabSurname()
  2. 6 biblio.contributors.inc \_grabSurname()
  3. 7.2 includes/biblio.contributors.inc \_grabSurname()

Surname may have title such as 'den', 'von', 'de la' etc. - characterised by first character lowercased. Any uppercased part means lowercased parts following are part of the surname (e.g. Van den Bussche)

Parameters

$input:

2 calls to _grabSurname()
BiblioContributorUnitTest::testGrabSurname in tests/BiblioContributorUnitTest.test
biblio_parse_author in includes/biblio.contributors.inc

File

includes/biblio.contributors.inc, line 642

Code

function _grabSurname($input) {
  $no_prefix = FALSE;
  $surname = FALSE;
  $prefix = FALSE;
  $surname_array = explode(" ", $input);
  foreach ($surname_array as $value) {
    $first_char = substr($value, 0, 1);
    if (!$no_prefix && ord($first_char) >= 97 && ord($first_char) <= 122) {
      $prefix[] = $value;
    }
    else {
      $surname[] = $value;
      $no_prefix = TRUE;
    }
  }
  if (!empty($surname)) {
    $surname = implode(" ", $surname);
  }
  if (!empty($prefix)) {
    $prefix = implode(" ", $prefix);
  }
  return array(
    $surname,
    $prefix,
  );
}