1
|
<?php
|
2
|
/**
|
3
|
* @file
|
4
|
* Reference theming functions.
|
5
|
*
|
6
|
* @copyright
|
7
|
* (C) 2007-2012 EDIT
|
8
|
* European Distributed Institute of Taxonomy
|
9
|
* http://www.e-taxonomy.eu
|
10
|
*
|
11
|
* The contents of this module are subject to the Mozilla
|
12
|
* Public License Version 1.1.
|
13
|
* @see http://www.mozilla.org/MPL/MPL-1.1.html
|
14
|
*/
|
15
|
|
16
|
/**
|
17
|
* @todo Please document this function.
|
18
|
* @see http://drupal.org/node/1354
|
19
|
*/
|
20
|
function theme_cdm_reference_pager($variables) {
|
21
|
$referencePager = $variables['referencePager'];
|
22
|
$path = $variables['path'];
|
23
|
$parameters = $variables['parameters'];
|
24
|
drupal_set_title(t('Bibliographic index'), PASS_THROUGH);
|
25
|
$out = '';
|
26
|
if (count($referencePager->records) > 0) {
|
27
|
$out .= '<ul>';
|
28
|
foreach ($referencePager->records as $reference) {
|
29
|
// FIXME remove hack.
|
30
|
$reference->fullCitation = $reference->titleCache;
|
31
|
// For matching cdm entity to STO.
|
32
|
$out .= '<li>' . theme('cdm_reference', array(
|
33
|
'reference' => $reference,
|
34
|
'microReference' => NULL,
|
35
|
'doLink' => TRUE,
|
36
|
)) . '</li>';
|
37
|
}
|
38
|
$out .= '</ul>';
|
39
|
$out .= theme('cdm_pager', array(
|
40
|
'pager' => $referencePager,
|
41
|
'path' => $path,
|
42
|
'parameters' => $parameters,
|
43
|
));
|
44
|
}
|
45
|
else {
|
46
|
$out = '<h4 class="error">Sorry, this page contains not entries.</h4>';
|
47
|
}
|
48
|
return $out;
|
49
|
}
|
50
|
|
51
|
/**
|
52
|
* Creates a HTML representations for a CDM Reference instance..
|
53
|
*
|
54
|
* Used by:
|
55
|
* - theme_cdm_typedesignations
|
56
|
* - theme_cdm_reference_pager
|
57
|
* - theme_cdm_taxonRelationships
|
58
|
*
|
59
|
* @param array $variables
|
60
|
* An associative array containing:
|
61
|
* - reference
|
62
|
* - microReference
|
63
|
* - doLink:
|
64
|
* Whether to create a link to the reference page, links to the reference URI or DOI are always
|
65
|
* created when this data is available
|
66
|
* - referenceStyle: the value "zoology" will cause a specific rendeting of the
|
67
|
* reference suitable for zoological publications.
|
68
|
*
|
69
|
* @return string
|
70
|
* the markup for the reference
|
71
|
*
|
72
|
* @ingroup themeable
|
73
|
*/
|
74
|
function theme_cdm_reference($variables) {
|
75
|
$reference = $variables['reference'];
|
76
|
$microReference = $variables['microReference'];
|
77
|
$doLink = $variables['doLink'];
|
78
|
$referenceStyle = $variables['referenceStyle'];
|
79
|
|
80
|
if (!isset($reference->authorship)) {
|
81
|
$author_team = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $reference->uuid);
|
82
|
}
|
83
|
else {
|
84
|
$author_team = $reference->authorship;
|
85
|
}
|
86
|
|
87
|
if ($referenceStyle == "zoology") {
|
88
|
$year = '';
|
89
|
if (isset($reference->datePublished->start)) {
|
90
|
$year = partialToYear($reference->datePublished->start);
|
91
|
}
|
92
|
$citation = $author_team->titleCache . (!empty($year) ? '. ' . $year : '');
|
93
|
}
|
94
|
else {
|
95
|
$citation = $reference->titleCache;
|
96
|
}
|
97
|
|
98
|
if (isset($doLink) && $doLink === TRUE) {
|
99
|
$out = '<span class="reference">';
|
100
|
$out .= l($citation, path_to_reference($reference->uuid), array(
|
101
|
'attributes' => array(
|
102
|
"class" => "reference",
|
103
|
),
|
104
|
'absolute' => TRUE,
|
105
|
'html' => TRUE,
|
106
|
));
|
107
|
$out .= '</span>';
|
108
|
}
|
109
|
else {
|
110
|
$out = '<span class="reference">' . $citation . '</span>';
|
111
|
}
|
112
|
|
113
|
if (!empty($microReference)) {
|
114
|
$out .= ": " . $microReference;
|
115
|
}
|
116
|
|
117
|
if (isset($reference->doi) && !empty($reference->doi)) {
|
118
|
$doi_resolve_uri = str_replace('doi:', 'http://doi.org/', $reference->doi);
|
119
|
$out .= l(font_awesome_icon_markup('fa-external-link-square', array('class' => array('superscript'))), $doi_resolve_uri, array('html' => TRUE));
|
120
|
}
|
121
|
if (isset($reference->uri) && !empty($reference->uri)) {
|
122
|
$out .= l(font_awesome_icon_markup('fa-external-link', array('class' => array('superscript'))), $reference->uri, array('html' => TRUE));
|
123
|
}
|
124
|
|
125
|
return $out;
|
126
|
}
|
127
|
|
128
|
/**
|
129
|
* @todo Please document this function.
|
130
|
* @see http://drupal.org/node/1354
|
131
|
*/
|
132
|
function _short_form_of_author_team($author_team) {
|
133
|
$number_of_authors = substr_count($author_team, ' & ') + 1;
|
134
|
// var_dump($author_team);
|
135
|
// var_dump($number_of_authors);
|
136
|
switch ($number_of_authors) {
|
137
|
case 1:
|
138
|
$result = $author_team;
|
139
|
break;
|
140
|
|
141
|
case 2:
|
142
|
$result = str_replace(' & ', ' and ', $author_team);
|
143
|
break;
|
144
|
|
145
|
default:
|
146
|
$result_parts = explode(' & ', $author_team);
|
147
|
$result = $result_parts[0] . ' et al.';
|
148
|
}
|
149
|
return $result;
|
150
|
}
|
151
|
|
152
|
/**
|
153
|
* @todo Please document this function.
|
154
|
* @see http://drupal.org/node/1354
|
155
|
*/
|
156
|
function theme_cdm_OriginalSource($variables) {
|
157
|
$out = '';
|
158
|
$source = $variables['source'];
|
159
|
$do_link_to_reference = $variables['doLink'];
|
160
|
$do_link_to_name_used_in_source = $variables['do_link_to_name_used_in_source'];
|
161
|
|
162
|
if (isset($source->citation)) {
|
163
|
$out = theme('cdm_reference', array(
|
164
|
'reference' => $source->citation,
|
165
|
'microReference' => $source->citationMicroReference,
|
166
|
'doLink' => $do_link_to_reference,
|
167
|
));
|
168
|
|
169
|
$name_in_source_render_array = compose_name_in_source($source, $do_link_to_name_used_in_source);
|
170
|
if(!empty($name_in_source_render_array)) {
|
171
|
$out .= ' <span class="nameUsedInSource">(' . t('as') . ' ' . $name_in_source_render_array['#markup'] . ')</span>';
|
172
|
}
|
173
|
|
174
|
$id_with_namespace = '';
|
175
|
if( isset($source->idNamespace) && $source->idNamespace ) {
|
176
|
$id_with_namespace = $source->idNamespace . '/';
|
177
|
}
|
178
|
if( isset($source->idInSource) && $source->idInSource ) {
|
179
|
$id_with_namespace .= $source->idInSource;
|
180
|
} else {
|
181
|
$id_with_namespace = NULL;
|
182
|
}
|
183
|
|
184
|
if($id_with_namespace){
|
185
|
$out .= ' <span class="idInSource">[' . $id_with_namespace . ']</span>';
|
186
|
}
|
187
|
}
|
188
|
return $out;
|
189
|
}
|