You are here

public function PARSECREATORS::grabSurname in Bibliography Module 7

Same name and namespace in other branches
  1. 5 bibtexParse/PARSECREATORS.php \PARSECREATORS::grabSurname()
  2. 6.2 modules/bibtexParse/PARSECREATORS.php \PARSECREATORS::grabSurname()
  3. 6 bibtexParse/PARSECREATORS.php \PARSECREATORS::grabSurname()
  4. 7.3 plugins/biblio_style/bibtex/PARSECREATORS.php \PARSECREATORS::grabSurname()
  5. 7.2 modules/bibtexParse/PARSECREATORS.php \PARSECREATORS::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)

1 call to PARSECREATORS::grabSurname()
PARSECREATORS::parseAuthor in modules/bibtexParse/PARSECREATORS.php
Create writer arrays from bibtex input.

File

modules/bibtexParse/PARSECREATORS.php, line 318
Classes Creators and PARSECREATORS.

Class

PARSECREATORS
Released through http://bibliophile.sourceforge.net under the GPL licence. Do whatever you like with this -- some credit to the author(s) would be appreciated.

Code

public function grabSurname($input) {
  $surnameArray = preg_split(" ", $input);
  $noPrefix = $surname = FALSE;
  foreach ($surnameArray as $value) {
    $firstChar = substr($value, 0, 1);
    if (!$noPrefix && ord($firstChar) >= 97 && ord($firstChar) <= 122) {
      $prefix[] = $value;
    }
    else {
      $surname[] = $value;
      $noPrefix = TRUE;
    }
  }
  if ($surname) {
    $surname = join(" ", $surname);
  }
  if (isset($prefix)) {
    $prefix = join(" ", $prefix);
    return array(
      $surname,
      $prefix,
    );
  }
  return array(
    $surname,
    FALSE,
  );
}