function _biblio_parse_authors in Bibliography Module 5
Same name and namespace in other branches
- 6.2 biblio.install \_biblio_parse_authors()
6 calls to _biblio_parse_authors()
- biblio_show_node in ./biblio.module
- biblio_style_apa in ./biblio_style_apa.inc
- Apply a bibliographic style to the node
- biblio_style_classic in ./biblio_style_classic.inc
- Apply a bibliographic style to the node
- biblio_style_cse in ./biblio_style_cse.inc
- Apply a bibliographic style to the node
- biblio_style_ieee in ./biblio_style_ieee.inc
- Apply a bibliographic style to the node
... See full list
File
- ./biblio.module, line 3196
Code
function _biblio_parse_authors($authors) {
$and = array(
" and ",
" And ",
" AND ",
);
$etal = "";
$author_array = array();
if (strpos($authors, 'et al')) {
if (strpos($authors, 'et al.')) {
$authors = str_replace('et al.', "", $authors);
}
else {
$authors = str_replace('et al', "", $authors);
}
$etal = 'et al.';
}
$authors = str_replace($and, "; ", $authors);
$authors = str_replace(" ,", ",", $authors);
$authors = str_replace(",,", ",", $authors);
$chunks = explode(";", $authors);
$num_chunks = count($chunks);
foreach ($chunks as $chunk) {
if (strlen(trim($chunk))) {
$suffix = _biblio_get_suffix($chunk);
$prefix = _biblio_get_prefix($chunk);
if (strstr($chunk, ",")) {
$subchunks = explode(",", trim($chunk));
$lastname = $subchunks[0];
$subchunks = explode(" ", trim($subchunks[1]));
$initials = "";
for ($j = 0; $j < count($subchunks); $j++) {
if (substr_count($subchunks[$j], '.')) {
$initials .= $subchunks[$j];
}
else {
$initials .= drupal_substr($subchunks[$j], 0, 1) . ".";
}
}
}
else {
$subchunks = explode(" ", trim($chunk));
$lastname = end($subchunks);
$initials = "";
for ($j = 0; $j < count($subchunks) - 1; $j++) {
if (substr_count($subchunks[$j], '.')) {
$initials .= $subchunks[$j];
}
else {
$initials .= drupal_substr($subchunks[$j], 0, 1) . ".";
}
}
}
$author_array[] = trim($prefix . $lastname . ', ' . $initials . ' ' . $suffix);
}
}
return implode("; ", $author_array) . " {$etal}";
}