function theme_biblio_format_authors in Bibliography Module 5
Same name and namespace in other branches
- 6.2 includes/biblio_theme.inc \theme_biblio_format_authors()
- 6 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()
4 theme calls to theme_biblio_format_authors()
- biblio_style_ama in ./biblio_style_ama.inc
- biblio_style_chicago in ./biblio_style_chicago.inc
- Apply a bibliographic style to the node
- biblio_style_mla in ./biblio_style_mla.inc
- Apply a bibliographic style to the node
- biblio_style_vancouver in ./biblio_style_vancouver.inc
File
- ./biblio.module, line 3974
Code
function theme_biblio_format_authors($contributors, $options, $inline = false) {
if (empty($contributors)) {
return;
}
$base = variable_get('biblio_base', 'biblio');
$author_links = variable_get('biblio_author_links', 1);
list($alnum, $alpha, $cntrl, $dash, $digit, $graph, $lower, $print, $punct, $space, $upper, $word, $patternModifiers) = _biblio_get_utf8_regex();
$auth_array = split(';', $contributors);
$authorCount = count($auth_array);
$output = "";
$includeStringAfterFirstAuthor = false;
if (empty($options['numberOfAuthorsTriggeringEtAl'])) {
$options['numberOfAuthorsTriggeringEtAl'] = $authorCount;
}
if (empty($options['includeNumberOfAuthors'])) {
$options['includeNumberOfAuthors'] = $authorCount;
}
$i = 0;
foreach ($auth_array as $rank => $author) {
$singleAuthorArray = split($options['oldAuthorsInitialsDelim'], $author);
if (isset($singleAuthorArray[1])) {
if ($options['shortenGivenNames']) {
$singleAuthorArray[1] = preg_replace("/([{$upper}])[{$lower}]+/{$patternModifiers}", "\\1", $singleAuthorArray[1]);
}
$singleAuthorArray[1] = preg_replace("/([{$upper}])\\.+/{$patternModifiers}", "\\1", $singleAuthorArray[1]);
$singleAuthorArray[1] = preg_replace("/(?<=[-{$upper}]) +(?=[-{$upper}])/{$patternModifiers}", "", $singleAuthorArray[1]);
if (ereg(" \$", $options['betweenInitialsDelim'])) {
$singleAuthorArray[1] = preg_replace("/-(?=[{$upper}])/{$patternModifiers}", "- ", $singleAuthorArray[1]);
}
$delim = $options['betweenInitialsDelim'];
$singleAuthorArray[1] = preg_replace("/([{$upper}])(?=[^{$lower}]+|\$)/{$patternModifiers}", "\\1{$delim}", $singleAuthorArray[1]);
}
if ($i == 0 and $options['initialsBeforeAuthorFirstAuthor'] or $i > 0 and $options['initialsBeforeAuthorStandard']) {
$singleAuthorArray = array_reverse($singleAuthorArray);
}
if ($i == 0) {
$singleAuthorString = implode($options['AuthorsInitialsDelimFirstAuthor'], $singleAuthorArray);
}
else {
$singleAuthorString = implode($options['AuthorsInitialsDelimStandard'], $singleAuthorArray);
}
if ($author_links) {
$singleAuthorString = _biblio_single_author_link($singleAuthorString, $base, $inline);
}
if ($i == 0 or $i + 1 < $authorCount) {
if ($i == 0) {
$output .= $singleAuthorString;
}
else {
$output .= $options['BetweenAuthorsDelimStandard'] . $singleAuthorString;
}
if ($i + 1 == $options['includeNumberOfAuthors'] and $authorCount > $options['numberOfAuthorsTriggeringEtAl']) {
if (ereg("__NUMBER_OF_AUTHORS__", $options['customStringAfterFirstAuthors'])) {
$options['customStringAfterFirstAuthors'] = preg_replace("/__NUMBER_OF_AUTHORS__/", $authorCount - $options['includeNumberOfAuthors'], $options['customStringAfterFirstAuthors']);
}
$includeStringAfterFirstAuthor = true;
break;
}
}
elseif ($authorCount > 1 and $i + 1 == $authorCount) {
$output .= $options['BetweenAuthorsDelimLastAuthor'] . $singleAuthorString;
}
$i++;
}
if ($options['encodeHTML']) {
if ($includeStringAfterFirstAuthor) {
$output .= $options['customStringAfterFirstAuthors'];
}
}
$output = preg_replace("/ +/", " ", $output);
$output = preg_replace("/ +([,.;:?!()]|\$)/", "\\1", $output);
return $output;
}