-
Notifications
You must be signed in to change notification settings - Fork 1
/
coins.php
55 lines (44 loc) · 1.24 KB
/
coins.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
$metadata_to_coins = array(
'title'=>'rft.atitle',
'secondary_title'=>'rft.jtitle',
'journal'=>'rft.stitle',
'year'=>'rft.date',
'volume'=>'rft.volume',
'pages'=>'rft.pages',
'authors'=>'rft.au'
);
$coins_output = array();
while(list($metadata, $coins) = each($metadata_to_coins)) {
if ($metadata == 'authors') {
$authors = array();
$authors = explode(";",$paper[$metadata]);
foreach($authors as $input) {
$output = '';
$input = trim($input);
$input = strtoupper(bin2hex($input));
$input = str_split($input,2);
foreach($input as $character) {
$output.= '%'.$character;
}
$coins_output[] = $coins.'='.$output;
}
} else {
$output = '';
$input = $paper[$metadata];
if (!empty($input)) {
$input = strtoupper(bin2hex($input));
$input = str_split($input,2);
foreach($input as $character) {
$output.= '%'.$character;
}
$coins_output[] = $coins.'='.$output;
}
}
}
$coins_output = join("&",$coins_output);
print PHP_EOL.'<span class="Z3988" title="ctx_ver=Z39.88-2004&rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&';
print $coins_output;
if (!empty($paper['doi'])) print "&rft_id=info:doi/".urlencode($paper['doi']);
print '"></span>'.PHP_EOL;
?>