Created
September 5, 2012 20:57
-
-
Save phayes/3644630 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For H10 style relations, we need to 'guesse' what the relation type is by examining the two endpoints | |
function getRelationType($relation, $atominstance) { | |
if ($relation['type'] != 'related') { | |
return $relation['type']; | |
} | |
$otherinstance = highwire_get_raw_data($relation['apath']); | |
if ($otherinstance['type'] != 'article') { | |
return 'related'; | |
} | |
// If the two article-types are different, we can likely examine their types to determine the relationships | |
if ($otherinstance['article-type'] != $atominstance['article-type'])) { | |
if ($otherinstance['article-type'] == 'correction') return 'Revision#correction'; | |
if ($otherinstance['article-type'] == 'letter') return 'Revision#correction'; | |
if ($otherinstance['article-type'] == 'retraction') return 'Revision#retraction'; | |
if ($otherinstance['article-type'] == 'addendum') return 'Revision#addendum'; | |
if ($atominstance['article-type'] == 'correction') return 'Revision#subject'; | |
if ($atominstance['article-type'] == 'retraction') return 'Revision#subject'; | |
if ($atominstance['article-type'] == 'letter') return 'Revision#subject'; | |
if ($atominstance['article-type'] == 'addendum') return 'Revision#subject'; | |
} | |
if (!isset($relation['prop']) { // If we don't have an hwp:property element, we have no way of knowing... | |
return 'related'; | |
} | |
// Okay, let's look at the prop to see if we can scry the answer | |
if (strcontains('rev_errata.atom', $relation['prop'])) return 'Revision#subject'; | |
if (strcontains('rev_correction.atom', $relation['prop'])) return 'Revision#correction'; | |
if (strcontains('rev_retraction.atom', $relation['prop'])) return 'Revision#retraction'; | |
if (strcontains('errata.atom', $relation['prop'])) return 'Revision#subject'; | |
if (strcontains('correction.atom', $relation['prop'])) return 'Revision#subject'; | |
if (strcontains('retraction.atom', $relation['prop'])) return 'Revision#subject'; | |
// Who knows?!?! | |
return 'related'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment