function theme_biblio_format_authors in Bibliography Module 7.2
Same name and namespace in other branches
- 5 biblio.module \theme_biblio_format_authors()
- 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()
9 theme calls to theme_biblio_format_authors()
- biblio_format_authors in includes/biblio.theme.inc
- biblio_style_ama in styles/biblio_style_ama.inc
- biblio_style_apa in styles/biblio_style_apa.inc
- Apply a bibliographic style to the node
- biblio_style_chicago in styles/biblio_style_chicago.inc
- Apply a bibliographic style to the node
- biblio_style_classic in styles/biblio_style_classic.inc
- Apply a bibliographic style to the node
... See full list
File
- includes/biblio.theme.inc, line 445
Code
function theme_biblio_format_authors($variables) {
$contributions = $variables['contributions'];
$options = $variables['options'];
if (empty($contributions)) {
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);
$contributionCount = count($contributions);
$output = "";
$includeStringAfterFirstAuthor = FALSE;
if (empty($options['numberOfAuthorsTriggeringEtAl'])) {
$options['numberOfAuthorsTriggeringEtAl'] = $authorCount;
}
if (empty($options['includeNumberOfAuthors'])) {
$options['includeNumberOfAuthors'] = $authorCount;
}
static $rank = 0;
foreach ($contributions as $cnid => $contribution) {
$cn_wrap = biblio_wrapper($contribution, 'biblio_contribution');
$cr_wrap = biblio_wrapper($contribution->contributor, 'biblio_contributor');
$rank++;
if (!isset($contribution->lastname) && empty($contribution->literal)) {
module_load_include('inc', 'biblio', '/includes/biblio.contributors');
$category = $cn_wrap->biblio_contributor_category
->value();
$author = biblio_parse_author($contribution->contributor, (string) $category);
}
if (empty($author->literal)) {
if (!empty($author->firstname)) {
if ($options['shortenGivenNames']) {
$author->firstname = preg_replace("/([{$upper}])[{$lower}]+/{$patternModifiers}", '\\1', $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 ($options['shortenGivenNames'] && !empty($author->firstname)) {
$author->firstname = $author->firstname . $options['betweenInitialsDelim'] . $author->initials;
if ($shortenInitials) {
$author->firstname = drupal_substr($author->firstname, 0, $shortenInitials);
}
}
elseif (!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 ($cnid == 0) {
if ($options['initialsBeforeAuthorFirstAuthor']) {
$author->name = $author->firstname . $options['AuthorsInitialsDelimFirstAuthor'] . $author->lastname;
}
else {
$author->name = $author->lastname . $options['AuthorsInitialsDelimFirstAuthor'] . $author->firstname;
}
}
else {
if ($options['initialsBeforeAuthorStandard']) {
$author->name = $author->firstname . $options['AuthorsInitialsDelimStandard'] . $author->lastname;
}
else {
$author->name = $author->lastname . $options['AuthorsInitialsDelimStandard'] . $author->firstname;
}
}
}
else {
$author->name = $author->lastname;
}
}
if ($author_links) {
$author->name = theme('biblio_author_link', array(
'author' => $author,
));
}
else {
$author->name = check_plain($author->name);
}
if ($rank == 0 or $rank + 1 < $contributionCount) {
if ($rank == 0) {
$output .= $author->name;
}
else {
$output .= $options['BetweenAuthorsDelimStandard'] . $author->name;
}
if ($rank + 1 == $options['includeNumberOfAuthors'] and $contributionCount > $options['numberOfAuthorsTriggeringEtAl']) {
if (preg_match("/__NUMBER_OF_AUTHORS__/", $options['customStringAfterFirstAuthors'])) {
$customStringAfterFirstAuthors = preg_replace("/__NUMBER_OF_AUTHORS__/", $contributionCount - $options['includeNumberOfAuthors'], $options['customStringAfterFirstAuthors']);
}
$includeStringAfterFirstAuthor = TRUE;
break;
}
}
elseif ($contributionCount > 1 and $rank + 1 == $contributionCount) {
$output .= $options['BetweenAuthorsDelimLastAuthor'] . $author->name;
}
}
if ($includeStringAfterFirstAuthor) {
$output .= $options['customStringAfterFirstAuthors'];
}
$output = preg_replace("/ +/", " ", $output);
$output = preg_replace("/ +([,.;:?!()]|\$)/", "\\1", $output);
return $output;
}