|
|
@ -13,6 +13,7 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function udm_citeproc_convert_mods_to_citeproc_jsons_alter(&$output, $mods) { |
|
|
|
function udm_citeproc_convert_mods_to_citeproc_jsons_alter(&$output, $mods) { |
|
|
|
module_load_include('inc', 'citeproc', 'includes/converter'); |
|
|
|
module_load_include('inc', 'citeproc', 'includes/converter'); |
|
|
|
|
|
|
|
$output['type'] = udm_citeproc_local_to_csl_type($mods); |
|
|
|
if(empty($output['author'])){ |
|
|
|
if(empty($output['author'])){ |
|
|
|
$names = udm_convert_mods_to_citeproc_json_names($mods); |
|
|
|
$names = udm_convert_mods_to_citeproc_json_names($mods); |
|
|
|
$output = array_merge($output, $names); |
|
|
|
$output = array_merge($output, $names); |
|
|
@ -247,4 +248,39 @@ function udm_convert_mods_to_citeproc_json_name_role(SimpleXMLElement $name, arr |
|
|
|
return array_key_exists($role, $valid_roles) ? $valid_roles[$role] : FALSE; |
|
|
|
return array_key_exists($role, $valid_roles) ? $valid_roles[$role] : FALSE; |
|
|
|
} |
|
|
|
} |
|
|
|
return $default_role; |
|
|
|
return $default_role; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Converts our local types that mostly came from refworks to CSL types. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param SimpleXML $mods |
|
|
|
|
|
|
|
* @return string |
|
|
|
|
|
|
|
* The CSL type. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
function udm_citeproc_local_to_csl_type($mods) { |
|
|
|
|
|
|
|
$genre = $mods->xpath("//mods:mods[1]/mods:genre"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(empty($genre)){ |
|
|
|
|
|
|
|
return convert_mods_to_citeproc_json_type($mods); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$term = strtolower(trim((string)$genre[0])); |
|
|
|
|
|
|
|
switch ($term) { |
|
|
|
|
|
|
|
case 'article scientifique': |
|
|
|
|
|
|
|
case '': |
|
|
|
|
|
|
|
return 'article-journal'; |
|
|
|
|
|
|
|
case 'book chapter': |
|
|
|
|
|
|
|
case 'book section': |
|
|
|
|
|
|
|
case 'book, section': |
|
|
|
|
|
|
|
case 'chapitre de livre': |
|
|
|
|
|
|
|
return 'chapter'; |
|
|
|
|
|
|
|
case 'book, whole': |
|
|
|
|
|
|
|
case 'livre': |
|
|
|
|
|
|
|
return 'book'; |
|
|
|
|
|
|
|
case 'conference proceedings': |
|
|
|
|
|
|
|
case 'conference abstract': |
|
|
|
|
|
|
|
case 'Contribution à un congrès, un colloque, une conférence': |
|
|
|
|
|
|
|
return 'paper-conference'; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
return convert_mods_to_citeproc_json_type($mods); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|