function biblio_calculate_contributor_hash in Bibliography Module 6.2
Creates an md5 hash string to ease contributor comparison logic.
Parameters
string|array $contributor: A string with a name or array with one or more of the following elements, at least one of which is not empty:
- firstname:
- intiials:
- prefix:
- lastname:
Return value
string An md5 hash string.
3 calls to biblio_calculate_contributor_hash()
- biblio_admin_author_edit_form_submit in includes/
biblio.admin.inc - biblio_parse_author in includes/
biblio.contributors.inc - Parses an author name into its component parts.
- HumanNameParser_Parser::getArray in includes/
Parser.php - returns all the parts of the name as an array
File
- includes/
biblio.contributors.inc, line 642 - Functions related to contributors in Drupal biblio module.
Code
function biblio_calculate_contributor_hash($contributor) {
$hash = '';
if (is_string($contributor)) {
$creator = biblio_parse_author(array(
'name' => trim($contributor),
));
}
elseif (is_array($contributor)) {
$creator = $contributor;
}
else {
return $hash;
}
$firstname = isset($creator['firstname']) ? $creator['firstname'] : '';
$initials = isset($creator['initials']) ? $creator['initials'] : '';
$prefix = isset($creator['prefix']) ? $creator['prefix'] : '';
$lastname = isset($creator['lastname']) ? $creator['lastname'] : '';
$string = $firstname . $initials . $prefix . $lastname;
$string = str_replace(' ', '', drupal_strtolower($string));
if (!empty($string)) {
$hash = md5($string);
}
return $hash;
}