-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbibtexbrowser.local.php
More file actions
142 lines (108 loc) · 5.31 KB
/
bibtexbrowser.local.php
File metadata and controls
142 lines (108 loc) · 5.31 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
define('BIBLIOGRAPHYSTYLE','DSBibliographyStyle');
define('BIBTEXBROWSER_LINK_STYLE','DSBib2links');
function DsBibliographyStyle($bibentry) {
$title = $bibentry->getTitle();
$type = $bibentry->getType();
// later on, all values of $entry will be joined by a comma
$entry=array();
// title
// usually in bold: .bibtitle { font-weight:bold; }
$title = '<span class="bibtitle" itemprop="name">'.$title.'</span>';
if ($bibentry->hasField('doi')) $title = ' <a target="_blank" href="https://doi.org/'.$bibentry->getField('doi').'">'.$title.'</a>';
elseif ($bibentry->hasField('url')) $title = ' <a target="_blank" href="'.$bibentry->getField('url').'">'.$title.'</a>';
$coreInfo = $title;
// adding author info
if ($bibentry->hasField('author')) {
$coreInfo .= ' (<span class="bibauthor">';
$authors = array();
foreach ($bibentry->getFormattedAuthorsArray() as $a) {
$authors[]='<span itemprop="author" itemtype="http://schema.org/Person">'.$a.'</span>';
}
$coreInfo .= $bibentry->implodeAuthors($authors);
$coreInfo .= '</span>)';
}
// core info usually contains title + author
$entry[] = $coreInfo;
// now the book title
$booktitle = '';
if ($type=="inproceedings" || $type=="conference") {
$booktitle = __('In').' '.'<span itemprop="isPartOf">'.$bibentry->getField(BOOKTITLE).'</span>'; }
if ($type=="incollection") {
$booktitle = __('Chapter in').' '.'<span itemprop="isPartOf">'.$bibentry->getField(BOOKTITLE).'</span>';}
if ($type=="inbook") {
$booktitle = __('Chapter in').' '.$bibentry->getField('chapter');}
if ($type=="article") {
$booktitle = __('In').' '.'<span itemprop="isPartOf">'.$bibentry->getField("journal").'</span>';}
//// we may add the editor names to the booktitle
$editor='';
if ($bibentry->hasField(EDITOR)) {
$editor = $bibentry->getFormattedEditors();
}
if ($editor!='') $booktitle .=' ('.$editor.')';
// end editor section
// is the booktitle available
if ($booktitle!='') {
$entry[] = '<span class="bibbooktitle">'.$booktitle.'</span>';
}
$publisher='';
if ($type=="phdthesis") {
$publisher = __('PhD thesis').', '.$bibentry->getField(SCHOOL);
}
if ($type=="mastersthesis") {
$publisher = __('Master\'s thesis').', '.$bibentry->getField(SCHOOL);
}
if ($type=="bachelorsthesis") {
$publisher = __('Bachelor\'s thesis').', '.$bibentry->getField(SCHOOL);
}
if ($type=="techreport") {
$publisher = __('Technical report');
if ($bibentry->hasField("number")) {
$publisher .= ' '.$bibentry->getField("number");
}
$publisher .= ', '.$bibentry->getField("institution");
}
if ($type=="misc") {
$publisher = $bibentry->getField('howpublished');
}
if ($bibentry->hasField("publisher")) {
$publisher = $bibentry->getField("publisher");
}
if ($publisher!='') $entry[] = '<span class="bibpublisher">'.$publisher.'</span>';
if ($bibentry->hasField('volume')) $entry[] = __('volume').' '.$bibentry->getField("volume");
if ($bibentry->hasField(YEAR)) $entry[] = '<span itemprop="datePublished">'.$bibentry->getYear().'</span>';
$bibid = str_replace(":","-",$bibentry->getKey());
$collapse = '<a class="bibbtn collapsed" data-toggle="collapse" href="#bibentry'.$bibid.'" role="button" aria-expanded="false" aria-controls="bibentry'.$bibid.'"></a>';
$collapse .= '<div id="bibentry'.str_replace(":","-",$bibentry->getKey()).'" class="collapse"><div class="card"><div class="card-body">';
if ($bibentry->hasField('abstract')) {
$collapse .= '<h3 class="card-title">Abstract</h3>';
$collapse .= '<p class="card-text bibabstract">'.$bibentry->getField('abstract').'</p>';
if ($bibentry->hasField('keywords'))
$collapse .= '<p class="card-text bibkeywords"><br/><b class="bibkeyword">Keywords:</b> '.implode(", ", $bibentry->getKeywords()).'</p>';
$collapse .= '<hr>';
}
$collapse .= '<button class="btn btn-light bibcopy" data-clipboard-target="#ta-'.$bibid.'"></button>';
$collapse .= '<h3 class="card-title">BibTeX</h3></br>';
$collapse .= '<textarea id="ta-'.$bibid.'" class="bibtex">'.$bibentry->getText().'</textarea>';
$collapse .= '<hr>';
if ($bibentry->hasField('url'))
$collapse .= '<a'.get_target().' class="card-link biblink" target="_blank" href="'.$bibentry->getField('url').'">url</a>';
if ($bibentry->hasField('pdf'))
$collapse .= '<a'.get_target().' class="card-link biblink" target="_blank" href="'.$bibentry->getField('pdf').'">pdf</a>';
if ($bibentry->hasField('file'))
$collapse .= '<a'.get_target().' class="card-link biblink" target="_blank" href="'.$bibentry->getField('file').'">file</a>';
if ($bibentry->hasField('doi'))
$collapse .= '<a'.get_target().' class="card-link biblink" target="_blank" href="https://doi.org/'.$bibentry->getField('doi').'">doi</a>';
if ($bibentry->hasField('gsid'))
$collapse .= '<a'.get_target().' class="card-link biblink" target="_blank" href="https://scholar.google.com/scholar?cites='.$bibentry->getField('gsid').'">scholar</a>';
$collapse .= '</div></div></div>';
$result = implode(", ",$entry).'.';
$result .= $collapse;
// add the Coin URL
$result .= $bibentry->toCoins();
return '<span itemscope="" itemtype="http://schema.org/ScholarlyArticle">'.$result.'</span>';
}
function DSBib2links(&$bibentry) {
return '';
}
?>