function theme_biblio_format_authors in Bibliography Module 6
Same name and namespace in other branches
- 5 biblio.module \theme_biblio_format_authors()
- 6.2 includes/biblio_theme.inc \theme_biblio_format_authors()
- 7 includes/biblio_theme.inc \theme_biblio_format_authors()
- 7.2 includes/biblio.theme.inc \theme_biblio_format_authors()
11 theme calls to theme_biblio_format_authors()
- biblio_handler_field_contributor::render in views/biblio_handler_field_contributor.inc
- biblio_style_ama in ./biblio_style_ama.inc
- biblio_style_apa in ./biblio_style_apa.inc
- Apply a bibliographic style to the node
- biblio_style_chicago in ./biblio_style_chicago.inc
- Apply a bibliographic style to the node
- biblio_style_classic in ./biblio_style_classic.inc
- Apply a bibliographic style to the node
... See full list
File
- ./biblio_theme.inc, line 429
Code
function theme_biblio_format_authors($contributors, $options, $inline = false) {
if (empty($contributors)) {
return;
}
list($alnum, $alpha, $cntrl, $dash, $digit, $graph, $lower, $print, $punct, $space, $upper, $word, $patternModifiers) = _biblio_get_regex_patterns();
$base = variable_get('biblio_base', 'biblio');
$author_links = variable_get('biblio_author_links', 1);
$authorCount = count($contributors);
$output = "";
$includeStringAfterFirstAuthor = false;
if (empty($options['numberOfAuthorsTriggeringEtAl'])) {
$options['numberOfAuthorsTriggeringEtAl'] = $authorCount;
}
if (empty($options['includeNumberOfAuthors'])) {
$options['includeNumberOfAuthors'] = $authorCount;
}
foreach ($contributors as $rank => $author) {
if (empty($author['name'])) {
continue;
}
if (!isset($author['lastname'])) {
module_load_include('inc', 'biblio', "biblio.contributors");
$author = biblio_parse_author($author, $author['auth_type']);
}
if (!empty($author['firstname'])) {
if ($options['shortenGivenNames']) {
$author['firstname'] = preg_replace("/([{$upper}])[{$lower}]+/{$patternModifiers}", '\\1', $author['firstname']);
$author['initials'] = $author['firstname'] . $author['initials'];
unset($author['firstname']);
}
}
if (isset($author['initials'])) {
$author['initials'] = preg_replace("/([{$upper}])\\.+/{$patternModifiers}", "\\1", $author['initials']);
$author['initials'] = preg_replace("/(?<=[-{$upper}]) +(?=[-{$upper}])/{$patternModifiers}", "", $author['initials']);
if (preg_match('/ $/', $options['betweenInitialsDelim'])) {
$author['initials'] = preg_replace("/-(?=[{$upper}])/{$patternModifiers}", "- ", $author['initials']);
}
$delim = $options['betweenInitialsDelim'];
$author['initials'] = preg_replace("/([{$upper}])(?=[^{$lower}]+|\$)/{$patternModifiers}", "\\1{$delim}", $author['initials']);
$shortenInitials = isset($options['numberOfInitialsToKeep']) ? $options['numberOfInitialsToKeep'] : FALSE;
if ($shortenInitials) {
$author['initials'] = drupal_substr($author['initials'], 0, $shortenInitials);
}
if (!empty($author['firstname'])) {
$author['firstname'] = $author['firstname'] . ' ' . $author['initials'];
}
elseif (empty($author['firstname'])) {
$author['firstname'] = $author['initials'];
}
}
if (!empty($author['prefix'])) {
$author['lastname'] = $author['prefix'] . ' ' . $author['lastname'];
}
if (!empty($author['suffix'])) {
$author['lastname'] = $author['lastname'] . ', ' . $author['suffix'];
}
if (!empty($author['firstname'])) {
if ($rank == 0) {
if ($options['initialsBeforeAuthorFirstAuthor']) {
$singleAuthorString = $author['firstname'] . $options['AuthorsInitialsDelimFirstAuthor'] . $author['lastname'];
}
else {
$singleAuthorString = $author['lastname'] . $options['AuthorsInitialsDelimFirstAuthor'] . $author['firstname'];
}
}
else {
if ($options['initialsBeforeAuthorStandard']) {
$singleAuthorString = $author['firstname'] . $options['AuthorsInitialsDelimStandard'] . $author['lastname'];
}
else {
$singleAuthorString = $author['lastname'] . $options['AuthorsInitialsDelimStandard'] . $author['firstname'];
}
}
}
else {
$singleAuthorString = $author['lastname'];
}
if ($author_links) {
$author['name'] = $singleAuthorString;
$singleAuthorString = theme('biblio_author_link', $author);
}
else {
$singleAuthorString = check_plain($singleAuthorString);
}
if ($rank == 0 or $rank + 1 < $authorCount) {
if ($rank == 0) {
$output .= $singleAuthorString;
}
else {
$output .= $options['BetweenAuthorsDelimStandard'] . $singleAuthorString;
}
if ($rank + 1 == $options['includeNumberOfAuthors'] and $authorCount > $options['numberOfAuthorsTriggeringEtAl']) {
if (ereg("__NUMBER_OF_AUTHORS__", $options['customStringAfterFirstAuthors'])) {
$customStringAfterFirstAuthors = preg_replace("/__NUMBER_OF_AUTHORS__/", $authorCount - $options['includeNumberOfAuthors'], $options['customStringAfterFirstAuthors']);
}
$includeStringAfterFirstAuthor = true;
break;
}
}
elseif ($authorCount > 1 and $rank + 1 == $authorCount) {
$output .= $options['BetweenAuthorsDelimLastAuthor'] . $singleAuthorString;
}
}
if ($options['encodeHTML']) {
if ($includeStringAfterFirstAuthor) {
$output .= $options['customStringAfterFirstAuthors'];
}
}
$output = preg_replace("/ +/", " ", $output);
$output = preg_replace("/ +([,.;:?!()]|\$)/", "\\1", $output);
return $output;
}