1 |
6657531f
|
Andreas Kohlbecker
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Module to provide a CDM Dataportal.
|
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 |
|
|
* @author
|
16 |
|
|
* - Andreas Kohlbecker <a.kohlbecker@BGBM.org>
|
17 |
|
|
* - Wouter Addink <w.addink@eti.uva.nl> (migration from Drupal 5 to Drupal7)
|
18 |
|
|
*/
|
19 |
|
|
|
20 |
38b27a36
|
Andreas Kohlbecker
|
module_load_include('php', 'cdm_dataportal', 'node_types');
|
21 |
|
|
module_load_include('php', 'cdm_dataportal', 'settings');
|
22 |
|
|
module_load_include('php', 'cdm_dataportal', 'help');
|
23 |
|
|
module_load_include('php', 'cdm_dataportal', 'cdm_dataportal.search');
|
24 |
|
|
|
25 |
|
|
module_load_include('inc', 'cdm_dataportal', 'includes/common');
|
26 |
e2617c7e
|
Andreas Kohlbecker
|
module_load_include('inc', 'cdm_dataportal', 'includes/agent');
|
27 |
2e31ea9e
|
Andreas Kohlbecker
|
module_load_include('inc', 'cdm_dataportal', 'includes/name');
|
28 |
b7a20282
|
Andreas Kohlbecker
|
module_load_include('inc', 'cdm_dataportal', 'includes/taxon');
|
29 |
bd56cbc1
|
Andreas Kohlbecker
|
module_load_include('inc', 'cdm_dataportal', 'includes/taxon-node');
|
30 |
b7a20282
|
Andreas Kohlbecker
|
module_load_include('inc', 'cdm_dataportal', 'includes/references');
|
31 |
38b27a36
|
Andreas Kohlbecker
|
module_load_include('inc', 'cdm_dataportal', 'includes/pages');
|
32 |
|
|
module_load_include('inc', 'cdm_dataportal', 'includes/media');
|
33 |
|
|
module_load_include('inc', 'cdm_dataportal', 'includes/maps');
|
34 |
|
|
module_load_include('inc', 'cdm_dataportal', 'includes/occurrences');
|
35 |
|
|
module_load_include('inc', 'cdm_dataportal', 'includes/descriptions');
|
36 |
|
|
module_load_include('inc', 'cdm_dataportal', 'includes/pre-drupal8');
|
37 |
|
|
|
38 |
|
|
module_load_include('inc', 'cdm_dataportal', 'theme/theme_registry');
|
39 |
|
|
module_load_include('theme', 'cdm_dataportal', 'theme/cdm_dataportal.common');
|
40 |
|
|
module_load_include('theme', 'cdm_dataportal', 'theme/cdm_dataportal.descriptions');
|
41 |
|
|
module_load_include('theme', 'cdm_dataportal', 'theme/cdm_dataportal.media');
|
42 |
|
|
module_load_include('theme', 'cdm_dataportal', 'theme/cdm_dataportal.occurrence');
|
43 |
|
|
module_load_include('theme', 'cdm_dataportal', 'theme/cdm_dataportal.page');
|
44 |
|
|
module_load_include('theme', 'cdm_dataportal', 'theme/cdm_dataportal.taxon');
|
45 |
|
|
module_load_include('theme', 'cdm_dataportal', 'theme/cdm_dataportal.name');
|
46 |
|
|
module_load_include('theme', 'cdm_dataportal', 'theme/cdm_dataportal.references');
|
47 |
|
|
|
48 |
|
|
module_load_include('php', 'cdm_dataportal', 'classes/footnotemanager');
|
49 |
|
|
module_load_include('php', 'cdm_dataportal', 'classes/footnote');
|
50 |
|
|
module_load_include('php', 'cdm_dataportal', 'classes/footnotekey');
|
51 |
|
|
module_load_include('php', 'cdm_dataportal', 'classes/renderhints');
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
/* ============================ java script functions ============================= */
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
/**
|
58 |
|
|
* loads external java script files asynchronously.
|
59 |
|
|
*
|
60 |
|
|
* @param unknown_type $script_url
|
61 |
|
|
*/
|
62 |
|
|
function drupal_add_js_async($script_url, $callback){
|
63 |
|
|
|
64 |
|
|
drupal_add_js("
|
65 |
|
|
jQuery(document).ready(function() {
|
66 |
|
|
jQuery.ajax({
|
67 |
|
|
url: '" . $script_url . "',
|
68 |
|
|
dataType: 'script',
|
69 |
|
|
cache: true, // otherwise will get fresh copy every page load
|
70 |
|
|
success: function() {
|
71 |
|
|
" . $callback . "
|
72 |
|
|
}
|
73 |
|
|
});
|
74 |
|
|
});"
|
75 |
|
|
, 'inline');
|
76 |
6657531f
|
Andreas Kohlbecker
|
}
|
77 |
|
|
|
78 |
38b27a36
|
Andreas Kohlbecker
|
/**
|
79 |
|
|
*/
|
80 |
|
|
function drupal_add_js_rowToggle($tableId){
|
81 |
6657531f
|
Andreas Kohlbecker
|
|
82 |
38b27a36
|
Andreas Kohlbecker
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/table_modification.js');
|
83 |
|
|
drupal_add_js('jQuery(document).ready(function(){
|
84 |
|
|
addRowToggle("' . $tableId . '");
|
85 |
6657531f
|
Andreas Kohlbecker
|
});
|
86 |
38b27a36
|
Andreas Kohlbecker
|
', array('type' => 'inline'));
|
87 |
|
|
}
|
88 |
d2fd2a4c
|
Andreas Kohlbecker
|
|
89 |
38b27a36
|
Andreas Kohlbecker
|
/**
|
90 |
|
|
* @param unknown_type $link_element_selector
|
91 |
|
|
* @param unknown_type $progress_element_selector
|
92 |
|
|
*/
|
93 |
|
|
function _add_js_cdm_ws_progressbar($link_element_selector, $progress_element_selector){
|
94 |
|
|
|
95 |
|
|
$callback = "jQuery('" . $link_element_selector . "').cdm_ws_progress('" . $progress_element_selector . "');";
|
96 |
|
|
|
97 |
|
|
drupal_add_js_async(variable_get('cdm_webservice_url', '').'js/cdm_ws_progress.js', $callback);
|
98 |
|
|
|
99 |
|
|
// drupal_add_js("
|
100 |
|
|
// if (Drupal.jsEnabled) {
|
101 |
|
|
// $(document).ready(function() {
|
102 |
|
|
// $('" . $link_element_selector . "').cdm_ws_progress('" . $progress_element_selector . "');
|
103 |
|
|
// });
|
104 |
|
|
// }", 'inline');
|
105 |
|
|
}
|
106 |
|
|
|
107 |
|
|
/**
|
108 |
|
|
* @todo Please document this function.
|
109 |
|
|
* @see http://drupal.org/node/1354
|
110 |
|
|
*/
|
111 |
|
|
function _add_js_treeselector() {
|
112 |
|
|
// drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/treeselector.js');
|
113 |
|
|
drupal_add_js("
|
114 |
|
|
jQuery(document).ready(function() {
|
115 |
|
|
jQuery('#cdm-taxonomictree-selector-form #edit-val').change(function () {
|
116 |
|
|
jQuery('#cdm-taxonomictree-selector-form').submit();
|
117 |
|
|
});
|
118 |
|
|
|
119 |
|
|
});
|
120 |
|
|
",
|
121 |
|
|
array(
|
122 |
|
|
'type' => 'inline',
|
123 |
|
|
'scope' => 'footer'
|
124 |
|
|
)
|
125 |
|
|
);
|
126 |
5ea8b301
|
Andreas Kohlbecker
|
}
|
127 |
|
|
|
128 |
6b605d3b
|
Andreas Kohlbecker
|
function _add_js_resizable_element($selector, $y_axis_only) {
|
129 |
|
|
|
130 |
|
|
_add_jquery_ui();
|
131 |
|
|
$options = "";
|
132 |
|
|
if($y_axis_only) {
|
133 |
|
|
$options = "resize: function(event, ui) {
|
134 |
|
|
ui.size.width = ui.originalSize.width;
|
135 |
|
|
},
|
136 |
|
|
handles: \"s\"";
|
137 |
|
|
|
138 |
|
|
}
|
139 |
|
|
drupal_add_js("
|
140 |
|
|
jQuery(document).ready(function() {
|
141 |
|
|
jQuery('" . $selector . "').resizable({". $options ."});
|
142 |
|
|
});
|
143 |
|
|
",
|
144 |
|
|
array(
|
145 |
|
|
'type' => 'inline',
|
146 |
|
|
'scope' => 'footer'
|
147 |
|
|
)
|
148 |
|
|
);
|
149 |
|
|
}
|
150 |
|
|
|
151 |
38b27a36
|
Andreas Kohlbecker
|
function _add_js_openlayers() {
|
152 |
|
|
|
153 |
|
|
$openlayers = '/js/map/OpenLayers-2.13.1/OpenLayers.js';
|
154 |
|
|
$proj4js = '/js/map/proj4js-1.1.0/proj4js-compressed.js';
|
155 |
|
|
|
156 |
|
|
if(variable_get('cdm_js_devel_mode', FALSE)){
|
157 |
|
|
// develooper mode libs
|
158 |
|
|
// $openlayers = '/js/map/OpenLayers-2.13.1/lib/OpenLayers.js';
|
159 |
|
|
$openlayers = '/js/map/OpenLayers-2.13.1/OpenLayers.debug.js';
|
160 |
|
|
$proj4js = '/js/map/proj4js-1.1.0/proj4js-combined.js';
|
161 |
|
|
}
|
162 |
|
|
|
163 |
|
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . $openlayers,
|
164 |
|
|
array(
|
165 |
|
|
'type' => 'file',
|
166 |
4c21ffdb
|
Andreas Kohlbecker
|
'group' => JS_LIBRARY,
|
167 |
|
|
'weight' => 0,
|
168 |
38b27a36
|
Andreas Kohlbecker
|
'cache' => TRUE,
|
169 |
|
|
'preprocess' => FALSE
|
170 |
|
|
)
|
171 |
|
|
);
|
172 |
2020828c
|
Andreas Kohlbecker
|
|
173 |
c1fc969a
|
Andreas Kohlbecker
|
|
174 |
38b27a36
|
Andreas Kohlbecker
|
// see https://github.com/proj4js/proj4js
|
175 |
|
|
// http://openlayers.org/dev/examples/using-proj4js.html
|
176 |
|
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . $proj4js,
|
177 |
|
|
array(
|
178 |
|
|
'type' => 'file',
|
179 |
4c21ffdb
|
Andreas Kohlbecker
|
'group' => JS_LIBRARY,
|
180 |
|
|
'weight' => -1, // before open layers
|
181 |
38b27a36
|
Andreas Kohlbecker
|
'cache' => TRUE,
|
182 |
|
|
)
|
183 |
|
|
);
|
184 |
|
|
|
185 |
|
|
// configure the theme
|
186 |
|
|
$openlayers_theme_path = drupal_get_path('module', 'cdm_dataportal') . '/js/map/OpenLayers-2.13.1/theme/default/';
|
187 |
|
|
$openlayers_imp_path = drupal_get_path('module', 'cdm_dataportal') . '/js/map/img/dark/';
|
188 |
|
|
drupal_add_js('OpenLayers.ImgPath="' . base_path() . $openlayers_imp_path . '";', array(
|
189 |
|
|
'type' => 'inline',
|
190 |
4c21ffdb
|
Andreas Kohlbecker
|
'group' => JS_LIBRARY,
|
191 |
|
|
'weight' => 1, // after openlayers
|
192 |
38b27a36
|
Andreas Kohlbecker
|
'cache' => TRUE,
|
193 |
|
|
'preprocess' => FALSE
|
194 |
|
|
));
|
195 |
|
|
|
196 |
|
|
drupal_add_css($openlayers_theme_path . 'style.tidy.css',
|
197 |
|
|
array(
|
198 |
|
|
'type' => 'file',
|
199 |
|
|
'cache' => TRUE,
|
200 |
|
|
'preprocess' => FALSE
|
201 |
|
|
)
|
202 |
|
|
);
|
203 |
e3026d72
|
Andreas Kohlbecker
|
|
204 |
38b27a36
|
Andreas Kohlbecker
|
}
|
205 |
e3026d72
|
Andreas Kohlbecker
|
|
206 |
38b27a36
|
Andreas Kohlbecker
|
/**
|
207 |
|
|
* @todo Please document this function.
|
208 |
|
|
* @see http://drupal.org/node/1354
|
209 |
|
|
*/
|
210 |
|
|
function _add_js_thickbox() {
|
211 |
|
|
// ---- jQuery thickbox:
|
212 |
|
|
/*
|
213 |
|
|
* bug: compat-1.0.js && thickbox.js line 237 .trigger("unload") -> event is
|
214 |
|
|
* not triggered because of problems with compat-1.0.js' see INSTALL.txt
|
215 |
|
|
*/
|
216 |
|
|
// drupal_add_js(drupal_get_path('module',
|
217 |
|
|
// 'cdm_dataportal').'/js/jquery.imagetool.min.js');
|
218 |
|
|
//
|
219 |
|
|
// Add a setting for the path to cdm_dataportal module, used to find the path
|
220 |
|
|
// for the loading animation image in thickbox.
|
221 |
|
|
drupal_add_js(array(
|
222 |
|
|
'cdm_dataportal' => array(
|
223 |
|
|
'cdm_dataportal_path' => base_path() . drupal_get_path('module', 'cdm_dataportal'),
|
224 |
10f6aa4b
|
Andreas Kohlbecker
|
)
|
225 |
38b27a36
|
Andreas Kohlbecker
|
),
|
226 |
|
|
'setting'
|
227 |
|
|
);
|
228 |
|
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/thickbox/thickbox.js');
|
229 |
|
|
drupal_add_css(drupal_get_path('module', 'cdm_dataportal') . '/js/thickbox/cdm_thickbox.css');
|
230 |
|
|
}
|
231 |
94550ff9
|
Andreas Kohlbecker
|
|
232 |
38b27a36
|
Andreas Kohlbecker
|
/**
|
233 |
|
|
* @todo Please document this function.
|
234 |
|
|
* @see http://drupal.org/node/1354
|
235 |
|
|
*/
|
236 |
|
|
function _add_js_lightbox($galleryID) {
|
237 |
|
|
/*
|
238 |
|
|
* Important Notice: The jquery.lightbox-0.5.js has been modified in order to
|
239 |
fe19a89b
|
Andreas Kohlbecker
|
* allow using the "alt" attribute for captions instead of the "title"
|
240 |
|
|
* attribute
|
241 |
|
|
*/
|
242 |
38b27a36
|
Andreas Kohlbecker
|
$lightbox_base_path = drupal_get_path('module', 'cdm_dataportal') . '/js/jquery-lightbox-0.5';
|
243 |
|
|
$lightbox_image_path = base_path() . $lightbox_base_path . '/images/';
|
244 |
|
|
drupal_add_js($lightbox_base_path . '/js/jquery.lightbox-0.5.js');
|
245 |
|
|
drupal_add_css($lightbox_base_path . '/css/jquery.lightbox-0.5.css');
|
246 |
|
|
drupal_add_js('jQuery(document).ready(function() {
|
247 |
|
|
jQuery(\'#' . $galleryID . ' a.lightbox\').lightBox({
|
248 |
|
|
fixedNavigation: true,
|
249 |
|
|
imageLoading: \'' . $lightbox_image_path . 'lightbox-ico-loading.gif\',
|
250 |
|
|
imageBtnPrev: \'' . $lightbox_image_path . 'lightbox-btn-prev.gif\',
|
251 |
|
|
imageBtnNext: \'' . $lightbox_image_path . 'lightbox-btn-next.gif\',
|
252 |
|
|
imageBtnClose: \'' . $lightbox_image_path . 'lightbox-btn-close.gif\',
|
253 |
|
|
imageBlank: \'' . $lightbox_image_path . 'lightbox-blank.gif\',
|
254 |
|
|
adjustToWindow: true
|
255 |
|
|
});
|
256 |
94550ff9
|
Andreas Kohlbecker
|
});
|
257 |
38b27a36
|
Andreas Kohlbecker
|
', array('type' => 'inline'));
|
258 |
|
|
}
|
259 |
94550ff9
|
Andreas Kohlbecker
|
|
260 |
38b27a36
|
Andreas Kohlbecker
|
/**
|
261 |
|
|
* @todo Please document this function.
|
262 |
|
|
* @see http://drupal.org/node/1354
|
263 |
|
|
*/
|
264 |
|
|
function _add_js_footnotes() {
|
265 |
|
|
_add_js_domEvent();
|
266 |
|
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/footnotes.js');
|
267 |
|
|
}
|
268 |
94550ff9
|
Andreas Kohlbecker
|
|
269 |
38b27a36
|
Andreas Kohlbecker
|
/**
|
270 |
|
|
* @todo Please document this function.
|
271 |
|
|
* @see http://drupal.org/node/1354
|
272 |
|
|
*/
|
273 |
|
|
function _add_js_ahah() {
|
274 |
b386ae48
|
Andreas Kohlbecker
|
|
275 |
38b27a36
|
Andreas Kohlbecker
|
_add_js_domEvent(); // requires domEvent.js
|
276 |
|
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/ahah-content.js');
|
277 |
|
|
}
|
278 |
94550ff9
|
Andreas Kohlbecker
|
|
279 |
d0d23caa
|
Andreas Kohlbecker
|
/**
|
280 |
|
|
* @todo Please document this function.
|
281 |
|
|
* @see http://drupal.org/node/1354
|
282 |
|
|
*/
|
283 |
|
|
function _add_js_taxonomic_children($jquery_selector) {
|
284 |
b0adfd32
|
Andreas Kohlbecker
|
|
285 |
|
|
global $base_url;
|
286 |
|
|
|
287 |
|
|
|
288 |
|
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/jquery.cdm.taxonomic_children.js');
|
289 |
faf4f771
|
Andreas Kohlbecker
|
|
290 |
d0d23caa
|
Andreas Kohlbecker
|
drupal_add_js('jQuery(document).ready(function() {
|
291 |
b0adfd32
|
Andreas Kohlbecker
|
jQuery(\'' . $jquery_selector . '\').taxonomic_children({
|
292 |
09edee9a
|
Andreas Kohlbecker
|
// hoverClass: "fa-rotate-90",
|
293 |
|
|
// activeClass: "fa-rotate-90",
|
294 |
b0adfd32
|
Andreas Kohlbecker
|
classificationUuid: "' . get_current_classification_uuid() . '",
|
295 |
0af3ce28
|
Andreas Kohlbecker
|
taxonUuid: "' . get_current_taxon_uuid() . '",
|
296 |
38da4e54
|
Andreas Kohlbecker
|
cdmWebappBaseUri: "' . variable_get('cdm_webservice_url', '') . '",
|
297 |
b0adfd32
|
Andreas Kohlbecker
|
proxyBaseUri: "' . $base_url . '",
|
298 |
|
|
|
299 |
|
|
});
|
300 |
d0d23caa
|
Andreas Kohlbecker
|
});
|
301 |
|
|
', array('type' => 'inline'));
|
302 |
|
|
}
|
303 |
|
|
|
304 |
38b27a36
|
Andreas Kohlbecker
|
/**
|
305 |
|
|
* Adds the external javascript file for domEvent.js.
|
306 |
|
|
*
|
307 |
|
|
* @see drupal_add_js()
|
308 |
|
|
*/
|
309 |
|
|
function _add_js_domEvent() {
|
310 |
|
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/domEvent.js');
|
311 |
|
|
}
|
312 |
b386ae48
|
Andreas Kohlbecker
|
|
313 |
087bb473
|
Andreas Kohlbecker
|
function _add_jquery_ui()
|
314 |
|
|
{
|
315 |
|
|
drupal_add_css(drupal_get_path('module',
|
316 |
|
|
'cdm_dataportal') . '/js/jquery-ui-1.8.24/themes/base/jquery.ui.all.css');
|
317 |
|
|
drupal_add_js(drupal_get_path('module',
|
318 |
|
|
'cdm_dataportal') . '/js/jquery-ui-1.8.24/ui/jquery-ui.js',
|
319 |
|
|
array(
|
320 |
|
|
'type' => 'file',
|
321 |
|
|
'weight' => JS_LIBRARY,
|
322 |
|
|
'cache' => TRUE,
|
323 |
|
|
'preprocess' => FALSE
|
324 |
|
|
)
|
325 |
|
|
);
|
326 |
|
|
}
|
327 |
|
|
|
328 |
b18d70f6
|
Andreas Kohlbecker
|
function _add_js_ui_accordion(){
|
329 |
|
|
_add_jquery_ui();
|
330 |
|
|
drupal_add_js('jQuery(document).ready(function() {
|
331 |
|
|
jQuery( "#accordion" ).accordion();
|
332 |
|
|
});',
|
333 |
|
|
array('type' => 'inline')
|
334 |
|
|
);
|
335 |
|
|
}
|
336 |
|
|
|
337 |
c05d1cfb
|
Andreas Kohlbecker
|
|
338 |
|
|
function _add_js_utis_client($jquery_selector){
|
339 |
|
|
|
340 |
|
|
drupal_add_js(drupal_get_path('module',
|
341 |
|
|
'cdm_dataportal') . '/js/utis-client/utis-client.js',
|
342 |
|
|
array(
|
343 |
|
|
'type' => 'file',
|
344 |
|
|
'weight' => JS_LIBRARY,
|
345 |
|
|
'cache' => TRUE,
|
346 |
|
|
'preprocess' => FALSE
|
347 |
|
|
)
|
348 |
|
|
);
|
349 |
|
|
|
350 |
|
|
drupal_add_js('jQuery(document).ready(function() {
|
351 |
|
|
jQuery( "' . $jquery_selector . '" ).utis_client(
|
352 |
|
|
{
|
353 |
e27e3ff2
|
Andreas Kohlbecker
|
spinnerIcon: \'' . font_awesome_icon_markup('fa-sync', array('class' => array('fa-3x', 'fa-spin'), 'style' => array('opacity: 0.3;'))) . '\',
|
354 |
|
|
externalLinkIcon: \'' . font_awesome_icon_markup('fa-external-link-alt') . '\'
|
355 |
c05d1cfb
|
Andreas Kohlbecker
|
});
|
356 |
|
|
});',
|
357 |
|
|
array('type' => 'inline')
|
358 |
|
|
);
|
359 |
|
|
}
|
360 |
|
|
|
361 |
4a462641
|
Andreas Kohlbecker
|
function _add_js_universalviewer($jquery_selector, $manifest_uri){
|
362 |
a1f7edc0
|
Andreas Kohlbecker
|
|
363 |
|
|
$universalviewer_path = drupal_get_path('module', 'cdm_dataportal') . '/js/universalviewer';
|
364 |
|
|
|
365 |
|
|
drupal_add_css($universalviewer_path . '/uv/uv.css');
|
366 |
a6f91032
|
Andreas Kohlbecker
|
drupal_add_css($universalviewer_path . '/uv-fix.css');
|
367 |
a1f7edc0
|
Andreas Kohlbecker
|
|
368 |
|
|
// offline.js is all of these dependencies concatenated (jQuery, CoreJS, and JSViews)
|
369 |
|
|
drupal_add_js($universalviewer_path . '/uv/lib/offline.js',
|
370 |
|
|
array(
|
371 |
|
|
'type' => 'file',
|
372 |
|
|
'group' => JS_LIBRARY,
|
373 |
|
|
'cache' => TRUE,
|
374 |
|
|
'preprocess' => FALSE
|
375 |
|
|
)
|
376 |
|
|
);
|
377 |
|
|
drupal_add_js($universalviewer_path . '/uv/helpers.js',
|
378 |
|
|
array(
|
379 |
|
|
'type' => 'file',
|
380 |
|
|
'group' => JS_LIBRARY,
|
381 |
|
|
'cache' => TRUE,
|
382 |
|
|
'preprocess' => FALSE
|
383 |
|
|
)
|
384 |
|
|
);
|
385 |
b45a8503
|
Andreas Kohlbecker
|
// from UV 3.x documentation:
|
386 |
|
|
// "root:
|
387 |
|
|
// The path to the uv directory. Use a relative path e.g. root: '../../uv'
|
388 |
|
|
// Don't start your path with a / otherwise requirejs will not append .js to
|
389 |
|
|
// dependencies and they won't load."
|
390 |
|
|
//
|
391 |
|
|
// universalviewerPath will be used to build the root config variable.
|
392 |
6c1a6712
|
Andreas Kohlbecker
|
$iCleanUrlRequest = strpos($_SERVER['REQUEST_URI'], 'q=cdm_dataportal/') === false;
|
393 |
|
|
if($iCleanUrlRequest){
|
394 |
|
|
$folders_up = preg_replace('/[^\/]+/', '..', $_GET['q']);
|
395 |
|
|
$folders_up = preg_replace('/\.\.$/', '', $folders_up);
|
396 |
|
|
} else {
|
397 |
|
|
$folders_up = '';
|
398 |
|
|
}
|
399 |
|
|
$basePath = base_path();
|
400 |
b45a8503
|
Andreas Kohlbecker
|
$config_file = 'uv-config.json';
|
401 |
a1f7edc0
|
Andreas Kohlbecker
|
drupal_add_js('
|
402 |
|
|
console.log(\'jQuery inline: \' + jQuery.fn.jquery);
|
403 |
|
|
jQuery(window).on(\'uvLoaded\', function() {
|
404 |
|
|
jQuery( "' . $jquery_selector . '" ).jqUniversalviewer(
|
405 |
|
|
{
|
406 |
b45a8503
|
Andreas Kohlbecker
|
root: \'' . $folders_up . $universalviewer_path . '/uv\',
|
407 |
6c1a6712
|
Andreas Kohlbecker
|
configUri: \'' . $basePath . $universalviewer_path . '/'. $config_file . '\',
|
408 |
4a462641
|
Andreas Kohlbecker
|
manifestUri: \'' . $manifest_uri . '\'
|
409 |
a1f7edc0
|
Andreas Kohlbecker
|
}
|
410 |
|
|
);
|
411 |
|
|
});',
|
412 |
|
|
array(
|
413 |
|
|
'type' => 'inline',
|
414 |
|
|
'scope' => 'footer',
|
415 |
|
|
'group' => JS_DEFAULT,
|
416 |
|
|
'weight' => 0,
|
417 |
|
|
)
|
418 |
|
|
);
|
419 |
|
|
drupal_add_js($universalviewer_path . '/jq-universalviewer.js',
|
420 |
|
|
array(
|
421 |
|
|
'type' => 'file',
|
422 |
|
|
'scope' => 'footer',
|
423 |
|
|
'group' => JS_DEFAULT,
|
424 |
|
|
'weight' => 10,
|
425 |
|
|
'cache' => TRUE,
|
426 |
|
|
'preprocess' => FALSE
|
427 |
|
|
)
|
428 |
|
|
);
|
429 |
|
|
// ui.js must be last
|
430 |
|
|
drupal_add_js($universalviewer_path . '/uv/uv.js',
|
431 |
|
|
array(
|
432 |
|
|
'type' => 'file',
|
433 |
|
|
'scope' => 'footer',
|
434 |
|
|
'group' => 300, // IMPORTANT!
|
435 |
|
|
'cache' => TRUE,
|
436 |
|
|
'preprocess' => FALSE
|
437 |
|
|
)
|
438 |
|
|
);
|
439 |
|
|
}
|
440 |
|
|
|
441 |
38b27a36
|
Andreas Kohlbecker
|
/**
|
442 |
|
|
* Provides the markup for an font awesome icon.
|
443 |
|
|
*
|
444 |
|
|
* The icons is created in default size without any extra features.
|
445 |
|
|
*
|
446 |
|
|
* The available icons are listed here http://fontawesome.io/cheatsheet/
|
447 |
ef12d0c6
|
Andreas Kohlbecker
|
* fontawesome icons have much more features than implemented here in this function,
|
448 |
|
|
* for spinning icons, fixed width icons, rotation, etc please checkout the
|
449 |
38b27a36
|
Andreas Kohlbecker
|
* examples at http://fontawesome.io/examples/
|
450 |
|
|
*
|
451 |
|
|
* @parameter $icon_name
|
452 |
|
|
* The name of the icon which starts with 'fa-'
|
453 |
|
|
*
|
454 |
|
|
* @return String
|
455 |
|
|
* the markup for the icon in an <i> tag
|
456 |
|
|
*
|
457 |
|
|
*/
|
458 |
b0aa9a8f
|
Andreas Kohlbecker
|
function font_awesome_icon_markup($icon_name = NULL, $attributes = array()){
|
459 |
6d9071b7
|
Andreas Kohlbecker
|
_add_font_awesome_font();
|
460 |
38b27a36
|
Andreas Kohlbecker
|
|
461 |
|
|
|
462 |
b0aa9a8f
|
Andreas Kohlbecker
|
if($icon_name){
|
463 |
|
|
if(!isset($attributes['class'])){
|
464 |
|
|
$attributes['class'] = array();
|
465 |
|
|
}
|
466 |
|
|
$attributes['class'][] = 'fa';
|
467 |
|
|
$attributes['class'][] = $icon_name;
|
468 |
|
|
|
469 |
|
|
return '<i ' . drupal_attributes($attributes) . '></i>';
|
470 |
38b27a36
|
Andreas Kohlbecker
|
}
|
471 |
|
|
|
472 |
b0aa9a8f
|
Andreas Kohlbecker
|
return '';
|
473 |
38b27a36
|
Andreas Kohlbecker
|
}
|
474 |
94550ff9
|
Andreas Kohlbecker
|
|
475 |
2ffe4d59
|
Andreas Kohlbecker
|
/**
|
476 |
|
|
* @param string $glyph_name
|
477 |
|
|
* The name of the gloyph (e.g. 'icon-interal-link-alt-solid') for the foll list please
|
478 |
|
|
* refer to modules/cdm_dataportal/fonts/custom-icon-font
|
479 |
|
|
* @param array $attributes
|
480 |
|
|
* @return string
|
481 |
|
|
*/
|
482 |
|
|
function custom_icon_font_markup($glyph_name = NULL, $attributes = array()){
|
483 |
|
|
_add_font_custom_icon_font();
|
484 |
|
|
|
485 |
|
|
|
486 |
|
|
if($glyph_name){
|
487 |
|
|
if(!isset($attributes['class'])){
|
488 |
|
|
$attributes['class'] = array();
|
489 |
|
|
}
|
490 |
|
|
$attributes['class'][] = $glyph_name;
|
491 |
|
|
|
492 |
|
|
return '<i ' . drupal_attributes($attributes) . '></i>';
|
493 |
|
|
}
|
494 |
|
|
|
495 |
|
|
return '';
|
496 |
|
|
}
|
497 |
|
|
|
498 |
6d9071b7
|
Andreas Kohlbecker
|
/**
|
499 |
|
|
* Adds the css containing the font awesome icons to the html header.
|
500 |
|
|
*/
|
501 |
|
|
function _add_font_awesome_font()
|
502 |
|
|
{
|
503 |
2393d9c5
|
Andreas Kohlbecker
|
// $fa_font_version = 'font-awesome-4.6.3/css/font-awesome.min.css';
|
504 |
|
|
$fa_font_version = 'fontawesome-free-5.9.0-web/css/all.css';
|
505 |
|
|
$font_awesome_css_uri = base_path() . drupal_get_path('module', 'cdm_dataportal') . '/fonts/' . $fa_font_version;
|
506 |
6d9071b7
|
Andreas Kohlbecker
|
|
507 |
|
|
drupal_add_html_head_link(
|
508 |
|
|
array(
|
509 |
|
|
'href' => $font_awesome_css_uri,
|
510 |
|
|
'rel' => 'stylesheet'
|
511 |
|
|
)
|
512 |
|
|
);
|
513 |
|
|
}
|
514 |
|
|
|
515 |
2ffe4d59
|
Andreas Kohlbecker
|
/**
|
516 |
|
|
* Adds the css containing the font awesome icons to the html header.
|
517 |
|
|
*/
|
518 |
|
|
function _add_font_custom_icon_font()
|
519 |
|
|
{
|
520 |
|
|
|
521 |
|
|
$custom_icon_font_css_uri = base_path() . drupal_get_path('module', 'cdm_dataportal') . '/fonts/custom-icon-font/style.css';
|
522 |
|
|
|
523 |
|
|
drupal_add_html_head_link(
|
524 |
|
|
array(
|
525 |
|
|
'href' => $custom_icon_font_css_uri,
|
526 |
|
|
'rel' => 'stylesheet'
|
527 |
|
|
)
|
528 |
|
|
);
|
529 |
|
|
}
|
530 |
38b27a36
|
Andreas Kohlbecker
|
|
531 |
6d9071b7
|
Andreas Kohlbecker
|
/* ====================== hook implementations ====================== */
|
532 |
38b27a36
|
Andreas Kohlbecker
|
/**
|
533 |
|
|
* Implements hook_permission().
|
534 |
|
|
*
|
535 |
|
|
* Valid permissions for this module.
|
536 |
|
|
*
|
537 |
|
|
* @return array
|
538 |
8385a9f2
|
Andreas Kohlbecker
|
* An array of valid permissions for the cdm_dataportal module.
|
539 |
38b27a36
|
Andreas Kohlbecker
|
*/
|
540 |
|
|
function cdm_dataportal_permission() {
|
541 |
|
|
return array(
|
542 |
|
|
'administer cdm_dataportal' => array(
|
543 |
8385a9f2
|
Andreas Kohlbecker
|
'title' => t('Administer CDM DataPortal settings'),
|
544 |
|
|
'description' => t("Access the settings pages specific for the cdm_dataportal module"),
|
545 |
c6fe437b
|
Andreas Kohlbecker
|
),
|
546 |
|
|
'access cdm content' => array(
|
547 |
|
|
'title' => t('Access CDM content'),
|
548 |
|
|
'description' => t("Access content (taxa, names, specimens, etc.) served by the CDM web service."),
|
549 |
|
|
),
|
550 |
38b27a36
|
Andreas Kohlbecker
|
);
|
551 |
|
|
}
|
552 |
6657531f
|
Andreas Kohlbecker
|
|
553 |
|
|
/**
|
554 |
f19f47fa
|
Andreas Kohlbecker
|
* Implements hook_menu().
|
555 |
|
|
*/
|
556 |
6657531f
|
Andreas Kohlbecker
|
function cdm_dataportal_menu() {
|
557 |
|
|
$items = array();
|
558 |
|
|
|
559 |
|
|
// @see settings.php.
|
560 |
|
|
cdm_dataportal_menu_admin($items);
|
561 |
|
|
cdm_dataportal_menu_help($items);
|
562 |
|
|
|
563 |
|
|
$items['cdm_dataportal/names'] = array(
|
564 |
|
|
'page callback' => 'cdm_dataportal_view_names',
|
565 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
566 |
6657531f
|
Andreas Kohlbecker
|
'type' => MENU_CALLBACK,
|
567 |
|
|
);
|
568 |
|
|
|
569 |
|
|
// Optional callback arguments: page.
|
570 |
|
|
$items['cdm_dataportal/taxon'] = array(
|
571 |
|
|
'page callback' => 'cdm_dataportal_taxon_page_view',
|
572 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
573 |
6657531f
|
Andreas Kohlbecker
|
'type' => MENU_CALLBACK,
|
574 |
|
|
// Expected callback arguments: uuid.
|
575 |
|
|
);
|
576 |
|
|
|
577 |
a1ce57ce
|
Katja Luther
|
$items['cdm_dataportal/occurrence'] = array(
|
578 |
6eaec849
|
Katja Luther
|
'page callback' => 'cdm_dataportal_specimen_page_view',
|
579 |
|
|
'access arguments' => array('access cdm content'),
|
580 |
|
|
'type' => MENU_CALLBACK,
|
581 |
|
|
// Expected callback arguments: uuid.
|
582 |
|
|
);
|
583 |
30845bda
|
Andreas Kohlbecker
|
|
584 |
e170a53e
|
Patrick Plitzner
|
$items['cdm_dataportal/description'] = array(
|
585 |
|
|
'page callback' => 'cdm_dataportal_description_page_view',
|
586 |
|
|
'access arguments' => array('access cdm content'),
|
587 |
|
|
'type' => MENU_CALLBACK,
|
588 |
|
|
// Expected callback arguments: uuid.
|
589 |
|
|
);
|
590 |
|
|
|
591 |
4c812e71
|
Katja Luther
|
$items['cdm_dataportal/specimen/accession_number'] = array(
|
592 |
6eaec849
|
Katja Luther
|
'page callback' => 'cdm_dataportal_specimen_by_accession_number_page_view',
|
593 |
|
|
'access arguments' => array('access cdm content'),
|
594 |
|
|
'type' => MENU_CALLBACK,
|
595 |
|
|
// Expected callback arguments: accession number.
|
596 |
|
|
);
|
597 |
30845bda
|
Andreas Kohlbecker
|
$items['cdm_dataportal/named_area'] = array(
|
598 |
|
|
'page callback' => 'cdm_dataportal_named_area_page_view',
|
599 |
|
|
'access arguments' => array('access cdm content'),
|
600 |
|
|
'type' => MENU_CALLBACK,
|
601 |
|
|
// Expected callback arguments: uuid.
|
602 |
|
|
);
|
603 |
9d37c9d9
|
Patric Plitzner
|
|
604 |
6657531f
|
Andreas Kohlbecker
|
$items['cdm_dataportal/name'] = array(
|
605 |
|
|
'page callback' => 'cdm_dataportal_name_page_view',
|
606 |
|
|
/*
|
607 |
|
|
'page arguments' => array(
|
608 |
|
|
'taxon_name_uuid',
|
609 |
|
|
'taxon_to_hide_uuid',
|
610 |
|
|
'synonym_uuid' => NULL
|
611 |
|
|
),
|
612 |
|
|
*/
|
613 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
614 |
6657531f
|
Andreas Kohlbecker
|
'type' => MENU_CALLBACK,
|
615 |
|
|
// Expected callback arguments: uuid.
|
616 |
|
|
);
|
617 |
|
|
|
618 |
|
|
$items['cdm_dataportal/reference'] = array(
|
619 |
|
|
'page callback' => 'cdm_dataportal_view_reference',
|
620 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
621 |
6657531f
|
Andreas Kohlbecker
|
'type' => MENU_CALLBACK,
|
622 |
|
|
// Expected callback arguments: uuid.
|
623 |
|
|
);
|
624 |
|
|
|
625 |
|
|
$items['cdm_dataportal/reference/list'] = array(
|
626 |
|
|
'page callback' => 'cdm_dataportal_view_reference_list',
|
627 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
628 |
6657531f
|
Andreas Kohlbecker
|
'type' => MENU_CALLBACK,
|
629 |
|
|
// Expected callback arguments: uuid.
|
630 |
|
|
);
|
631 |
|
|
|
632 |
|
|
$items['cdm_dataportal/media'] = array(
|
633 |
|
|
'page callback' => 'cdm_dataportal_view_media',
|
634 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
635 |
6657531f
|
Andreas Kohlbecker
|
'type' => MENU_CALLBACK,
|
636 |
|
|
// Expected callback arguments:
|
637 |
|
|
// uuid, mediarepresentation_uuid, part_uuid or part#.
|
638 |
|
|
);
|
639 |
|
|
|
640 |
|
|
$items['cdm_dataportal/polytomousKey'] = array(
|
641 |
|
|
'page callback' => 'cdm_dataportal_view_polytomousKey',
|
642 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
643 |
6657531f
|
Andreas Kohlbecker
|
'type' => MENU_CALLBACK,
|
644 |
|
|
// Expected callback arguments: polytomousKey->uuid.
|
645 |
|
|
);
|
646 |
|
|
|
647 |
|
|
$items['cdm_dataportal/search'] = array(
|
648 |
|
|
'page callback' => 'cdm_dataportal_view_search_advanced',
|
649 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
650 |
6657531f
|
Andreas Kohlbecker
|
'type' => MENU_CALLBACK,
|
651 |
|
|
);
|
652 |
|
|
|
653 |
7e219fcc
|
Andreas Kohlbecker
|
// Optional callback arguments: page.
|
654 |
|
|
$items['cdm_dataportal/registration'] = array(
|
655 |
|
|
'page callback' => 'cdm_dataportal_registration_page_view',
|
656 |
|
|
'access arguments' => array('access cdm content'),
|
657 |
|
|
'type' => MENU_CALLBACK,
|
658 |
|
|
// Expected callback arguments: uuid.
|
659 |
|
|
);
|
660 |
|
|
|
661 |
|
|
// ------------ SEARCH -----------
|
662 |
6657531f
|
Andreas Kohlbecker
|
$items['cdm_dataportal/search/advanced'] = array(
|
663 |
29077ee5
|
Andreas Kohlbecker
|
'title' => 'Advanced', // will be passed through t()
|
664 |
6657531f
|
Andreas Kohlbecker
|
'page callback' => 'cdm_dataportal_view_search_advanced',
|
665 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
666 |
6657531f
|
Andreas Kohlbecker
|
'type' => MENU_DEFAULT_LOCAL_TASK,
|
667 |
|
|
);
|
668 |
4c812e71
|
Katja Luther
|
$items['cdm_dataportal/search/blast'] = array(
|
669 |
|
|
'title' => 'Blast', // will be passed through t()
|
670 |
|
|
'page callback' => 'cdm_dataportal_view_search_blast',
|
671 |
|
|
'access arguments' => array('access cdm content'),
|
672 |
|
|
'type' => MENU_LOCAL_TASK,
|
673 |
|
|
);
|
674 |
|
|
|
675 |
6657531f
|
Andreas Kohlbecker
|
$items['cdm_dataportal/search/taxon_by_description'] = array(
|
676 |
579c485d
|
Andreas Kohlbecker
|
'title' => 'By content category', // will be passed through t()
|
677 |
6657531f
|
Andreas Kohlbecker
|
'page callback' => 'cdm_dataportal_view_search_taxon_by_description',
|
678 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
679 |
6657531f
|
Andreas Kohlbecker
|
'type' => MENU_LOCAL_TASK,
|
680 |
|
|
);
|
681 |
|
|
$items['cdm_dataportal/search/results/taxon'] = array(
|
682 |
|
|
'page callback' => 'cdm_dataportal_view_search_results_taxon',
|
683 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
684 |
6657531f
|
Andreas Kohlbecker
|
'type' => MENU_CALLBACK,
|
685 |
|
|
);
|
686 |
a1ce57ce
|
Katja Luther
|
|
687 |
2f30124c
|
Andreas Kohlbecker
|
$items['cdm_dataportal/search/results/specimen'] = array(
|
688 |
|
|
'page callback' => 'cdm_dataportal_view_search_results_specimen',
|
689 |
|
|
'access arguments' => array('access cdm content'),
|
690 |
|
|
'type' => MENU_CALLBACK,
|
691 |
|
|
);
|
692 |
|
|
|
693 |
efbff4b3
|
Andreas Kohlbecker
|
/*
|
694 |
|
|
* MENU_CALLBACK at cdm_dataportal/registration-search is needed to make the
|
695 |
|
|
* tabs in the subordinate paths work, accessing this 'page' will cause the
|
696 |
|
|
* MENU_DEFAULT_LOCAL_TASK being displayed
|
697 |
|
|
*/
|
698 |
|
|
$items['cdm_dataportal/registration-search'] = array(
|
699 |
|
|
'title' => 'Search', // will be passed through t()
|
700 |
a6ae799b
|
Andreas Kohlbecker
|
'page callback' => 'cdm_dataportal_view_search_registrations_results',
|
701 |
efbff4b3
|
Andreas Kohlbecker
|
'page arguments' => array("filter"),
|
702 |
a6ae799b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
703 |
|
|
'type' => MENU_CALLBACK,
|
704 |
|
|
);
|
705 |
efbff4b3
|
Andreas Kohlbecker
|
/*
|
706 |
|
|
* the MENU_DEFAULT_LOCAL_TASK creates a tab for the MENU_CALLBACK
|
707 |
|
|
* defined at a higher level of the path (cdm_dataportal/registration-search)
|
708 |
|
|
*/
|
709 |
|
|
$items['cdm_dataportal/registration-search/filter'] = array(
|
710 |
|
|
'title' => 'Search', // will be passed through t()
|
711 |
|
|
'page callback' => 'cdm_dataportal_view_search_registrations_results',
|
712 |
|
|
'page arguments' => array("filter"),
|
713 |
|
|
'access arguments' => array('access cdm content'),
|
714 |
|
|
'type' => MENU_DEFAULT_LOCAL_TASK,
|
715 |
|
|
);
|
716 |
|
|
/*
|
717 |
|
|
* the MENU_LOCAL_TASK creates another tab
|
718 |
|
|
*/
|
719 |
|
|
$items['cdm_dataportal/registration-search/taxongraph'] = array(
|
720 |
5087fadc
|
Andreas Kohlbecker
|
'title' => 'Taxon graph search', // will be passed through t()
|
721 |
efbff4b3
|
Andreas Kohlbecker
|
'page callback' => 'cdm_dataportal_view_search_registrations_results',
|
722 |
|
|
'page arguments' => array("taxongraph"),
|
723 |
|
|
'access arguments' => array('access cdm content'),
|
724 |
|
|
'type' => MENU_LOCAL_TASK,
|
725 |
|
|
);
|
726 |
|
|
|
727 |
e2617c7e
|
Andreas Kohlbecker
|
// Optional callback arguments: page.
|
728 |
|
|
$items['cdm_dataportal/search/agent'] = array(
|
729 |
|
|
'page callback' => 'cdm_dataportal_view_search_agent',
|
730 |
|
|
'access arguments' => array('access cdm content'),
|
731 |
|
|
'type' => MENU_CALLBACK,
|
732 |
|
|
// Expected callback arguments: uuid.
|
733 |
|
|
);
|
734 |
|
|
|
735 |
7e219fcc
|
Andreas Kohlbecker
|
// ------------ menu items with variable path elements -----------
|
736 |
6657531f
|
Andreas Kohlbecker
|
|
737 |
|
|
// 'May not cache' in D5.
|
738 |
|
|
$items['cdm_dataportal/name/%'] = array(
|
739 |
|
|
// 'page callback' => 'cdm_dataportal_view_name',
|
740 |
|
|
'page callback' => 'cdm_dataportal_name_page_view',
|
741 |
2f65af04
|
Andreas Kohlbecker
|
'page arguments' => array(2, 3, 4, 5),
|
742 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
743 |
6657531f
|
Andreas Kohlbecker
|
'type' => MENU_CALLBACK,
|
744 |
|
|
);
|
745 |
|
|
|
746 |
6f1a217c
|
Andreas Kohlbecker
|
// --- Local tasks for Taxon.
|
747 |
|
|
// --- tabbed taxon page
|
748 |
6657531f
|
Andreas Kohlbecker
|
if (variable_get('cdm_dataportal_taxonpage_tabs', 1)) {
|
749 |
|
|
$items['cdm_dataportal/taxon/%'] = array(
|
750 |
4feeabc7
|
Andreas Kohlbecker
|
'title' => cdm_taxonpage_tab_label('General'),
|
751 |
6657531f
|
Andreas Kohlbecker
|
'page callback' => 'cdm_dataportal_taxon_page_view',
|
752 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
753 |
6657531f
|
Andreas Kohlbecker
|
'type' => MENU_CALLBACK,
|
754 |
|
|
'weight' => 1,
|
755 |
|
|
'page arguments' => array(2, "description")
|
756 |
7663cd0b
|
Andreas Kohlbecker
|
, // Expected callback arguments: taxon_uuid.
|
757 |
6657531f
|
Andreas Kohlbecker
|
);
|
758 |
|
|
|
759 |
|
|
$items['cdm_dataportal/taxon/%/all'] = array(
|
760 |
4feeabc7
|
Andreas Kohlbecker
|
'title' => cdm_taxonpage_tab_label('General'),
|
761 |
6657531f
|
Andreas Kohlbecker
|
'page callback' => 'cdm_dataportal_taxon_page_view',
|
762 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
763 |
6657531f
|
Andreas Kohlbecker
|
'type' => MENU_CALLBACK,
|
764 |
|
|
'weight' => 2,
|
765 |
|
|
'page arguments' => array(2, "all")
|
766 |
7663cd0b
|
Andreas Kohlbecker
|
, // Expected callback arguments: taxon_uuid.
|
767 |
6657531f
|
Andreas Kohlbecker
|
);
|
768 |
|
|
|
769 |
|
|
$items['cdm_dataportal/taxon/%/description'] = array(
|
770 |
4feeabc7
|
Andreas Kohlbecker
|
'title' => cdm_taxonpage_tab_label('General'),
|
771 |
6657531f
|
Andreas Kohlbecker
|
'page callback' => 'cdm_dataportal_taxon_page_view',
|
772 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
773 |
6657531f
|
Andreas Kohlbecker
|
'type' => MENU_DEFAULT_LOCAL_TASK,
|
774 |
|
|
'weight' => 2,
|
775 |
|
|
'page arguments' => array(2, "description")
|
776 |
7663cd0b
|
Andreas Kohlbecker
|
, // Expected callback arguments: taxon_uuid.
|
777 |
6657531f
|
Andreas Kohlbecker
|
);
|
778 |
|
|
|
779 |
|
|
$items['cdm_dataportal/taxon/%/synonymy'] = array(
|
780 |
4feeabc7
|
Andreas Kohlbecker
|
'title' => cdm_taxonpage_tab_label('Synonymy'),
|
781 |
6657531f
|
Andreas Kohlbecker
|
'page callback' => 'cdm_dataportal_taxon_page_view',
|
782 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
783 |
6657531f
|
Andreas Kohlbecker
|
'type' => MENU_LOCAL_TASK,
|
784 |
|
|
'weight' => 4,
|
785 |
|
|
'page arguments' => array(2, "synonymy", 4)
|
786 |
7663cd0b
|
Andreas Kohlbecker
|
, // Expected callback arguments: taxon_uuid and ...
|
787 |
6657531f
|
Andreas Kohlbecker
|
);
|
788 |
7cc085da
|
Andreas Kohlbecker
|
$items['cdm_dataportal/taxon/%/images'] = array( // Images
|
789 |
4feeabc7
|
Andreas Kohlbecker
|
'title' => cdm_taxonpage_tab_label('Images'),
|
790 |
6657531f
|
Andreas Kohlbecker
|
'page callback' => 'cdm_dataportal_taxon_page_view',
|
791 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
792 |
6657531f
|
Andreas Kohlbecker
|
'type' => MENU_LOCAL_TASK,
|
793 |
|
|
'weight' => 5,
|
794 |
|
|
'page arguments' => array(2, "images")
|
795 |
7663cd0b
|
Andreas Kohlbecker
|
, // Expected callback arguments: taxon_uuid.
|
796 |
6657531f
|
Andreas Kohlbecker
|
);
|
797 |
|
|
|
798 |
7cc085da
|
Andreas Kohlbecker
|
$items['cdm_dataportal/taxon/%/specimens'] = array( // Specimens
|
799 |
4feeabc7
|
Andreas Kohlbecker
|
'title' => cdm_taxonpage_tab_label('Specimens'),
|
800 |
6657531f
|
Andreas Kohlbecker
|
'page callback' => 'cdm_dataportal_taxon_page_view',
|
801 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
802 |
6657531f
|
Andreas Kohlbecker
|
'type' => MENU_LOCAL_TASK,
|
803 |
|
|
'weight' => 6,
|
804 |
|
|
'page arguments' => array(2, "specimens")
|
805 |
7663cd0b
|
Andreas Kohlbecker
|
, // Expected callback arguments: taxon_uuid.
|
806 |
6657531f
|
Andreas Kohlbecker
|
);
|
807 |
|
|
|
808 |
7cc085da
|
Andreas Kohlbecker
|
$items['cdm_dataportal/taxon/%/keys'] = array( // Keys
|
809 |
4feeabc7
|
Andreas Kohlbecker
|
'title' => cdm_taxonpage_tab_label('Keys'),
|
810 |
6657531f
|
Andreas Kohlbecker
|
'page callback' => 'cdm_dataportal_taxon_page_view',
|
811 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
812 |
6657531f
|
Andreas Kohlbecker
|
'type' => MENU_LOCAL_TASK,
|
813 |
|
|
'weight' => 6,
|
814 |
|
|
'page arguments' => array(2, "keys")
|
815 |
7663cd0b
|
Andreas Kohlbecker
|
, // Expected callback arguments: taxon_uuid.
|
816 |
|
|
);
|
817 |
|
|
|
818 |
7cc085da
|
Andreas Kohlbecker
|
$items['cdm_dataportal/taxon/%/experts'] = array( // Experts
|
819 |
4feeabc7
|
Andreas Kohlbecker
|
'title' => cdm_taxonpage_tab_label('Experts'),
|
820 |
7663cd0b
|
Andreas Kohlbecker
|
'page callback' => 'cdm_dataportal_taxon_page_view',
|
821 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
822 |
7663cd0b
|
Andreas Kohlbecker
|
'type' => MENU_LOCAL_TASK,
|
823 |
|
|
'weight' => 6,
|
824 |
|
|
'page arguments' => array(2, "experts")
|
825 |
|
|
, // Expected callback arguments: taxon_uuid.
|
826 |
6657531f
|
Andreas Kohlbecker
|
);
|
827 |
93ae67cc
|
Patrick Plitzner
|
|
828 |
51cc509a
|
Patrick Plitzner
|
$items['cdm_dataportal/taxon/autosuggest/%/%/%/'] = array(
|
829 |
04a1d647
|
Patrick Plitzner
|
'page callback' => 'cdm_dataportal_taxon_autosuggest',
|
830 |
c6fe437b
|
Andreas Kohlbecker
|
'access arguments' => array('access cdm content'),
|
831 |
51cc509a
|
Patrick Plitzner
|
'page arguments' => array(3,4,5),
|
832 |
93ae67cc
|
Patrick Plitzner
|
'type' => MENU_CALLBACK
|
833 |
|
|
);
|
834 |
6657531f
|
Andreas Kohlbecker
|
}
|
835 |
|
|
|
836 |
6f1a217c
|
Andreas Kohlbecker
|
// --- refresh link for all cdmnode types
|
837 |
|
|
foreach (cdm_get_nodetypes() as $type=>$name) {
|
838 |
|
|
$items['cdm_dataportal/' . $name . '/%/refresh'] = array(
|
839 |
7cc085da
|
Andreas Kohlbecker
|
'title' => 'Refresh',
|
840 |
6f1a217c
|
Andreas Kohlbecker
|
'page callback' => 'cdm_dataportal_refresh_node',
|
841 |
3113db26
|
Andreas Kohlbecker
|
'access arguments' => array('administer cdm_dataportal'),
|
842 |
6f1a217c
|
Andreas Kohlbecker
|
'type' => MENU_LOCAL_TASK,
|
843 |
|
|
'weight' => 100,
|
844 |
|
|
'page arguments' => array($name, 2)
|
845 |
|
|
);
|
846 |
|
|
}
|
847 |
|
|
|
848 |
6657531f
|
Andreas Kohlbecker
|
return $items;
|
849 |
|
|
}
|
850 |
|
|
|
851 |
|
|
/**
|
852 |
b85ab055
|
Andreas Kohlbecker
|
* Implements hook_init().
|
853 |
|
|
*
|
854 |
6657531f
|
Andreas Kohlbecker
|
*/
|
855 |
|
|
function cdm_dataportal_init() {
|
856 |
8fc089e1
|
Saskia Gennrich
|
if (!path_is_admin(current_path())) {
|
857 |
|
|
//FIXME To add CSS or JS that should be present on all pages, modules
|
858 |
|
|
// should not implement this hook, but declare these files in their .info file.
|
859 |
|
|
drupal_add_css(drupal_get_path('module', 'cdm_dataportal') . '/cdm_dataportal.css');
|
860 |
|
|
// drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/cdm_dataportal_print.css', 'print');
|
861 |
|
|
drupal_add_css(drupal_get_path('module', 'cdm_dataportal') . '/cdm_dataportal_screen.css', array('type' => 'screen'));
|
862 |
63f6d312
|
Saskia Gennrich
|
} else {
|
863 |
|
|
drupal_add_css(drupal_get_path('module', 'cdm_dataportal') . '/cdm_dataportal_settings.css');
|
864 |
8fc089e1
|
Saskia Gennrich
|
}
|
865 |
2dd59bb5
|
Andreas Kohlbecker
|
|
866 |
|
|
if(variable_get('cdm_debug_mode', FALSE)){
|
867 |
|
|
$file = 'temporary://drupal_debug.txt';
|
868 |
|
|
file_put_contents($file, 'CDM DEBUG LOG for ' . $_GET['q']. "\n"); // will overwrite the file
|
869 |
|
|
}
|
870 |
5611d467
|
Andreas Kohlbecker
|
|
871 |
|
|
$bibliography_settings = get_bibliography_settings();
|
872 |
57d513cb
|
Andreas Kohlbecker
|
$enclosing_tag = $bibliography_settings['enabled'] == 1 ? 'div' : 'span';
|
873 |
|
|
FootnoteManager::registerFootnoteSet('BIBLIOGRAPHY', $enclosing_tag, $bibliography_settings['key_format']);
|
874 |
6657531f
|
Andreas Kohlbecker
|
}
|
875 |
|
|
|
876 |
6f1a217c
|
Andreas Kohlbecker
|
function cdm_dataportal_refresh_node($cdm_node_name, $uuid, $parameters = array()){
|
877 |
|
|
|
878 |
|
|
$base_path = 'cdm_dataportal/' . $cdm_node_name . '/' . $uuid;
|
879 |
|
|
|
880 |
|
|
if($cdm_node_name == 'taxon' && variable_get('cdm_dataportal_taxonpage_tabs', 1)){
|
881 |
|
|
// force reloading of all and notify user about this special loading
|
882 |
|
|
drupal_set_message(t('The level 2 cache has been cleared for all tabs of this taxon page at once, please click here to return to the tabbed page: ')
|
883 |
|
|
. l('Back to tabbed taxon page', $base_path));
|
884 |
|
|
$base_path .= '/all';
|
885 |
|
|
} else {
|
886 |
|
|
drupal_set_message(t('The level 2 cache has been cleared for this page'));
|
887 |
|
|
}
|
888 |
|
|
|
889 |
|
|
$parameters['cacheL2_refresh'] ='1';
|
890 |
|
|
|
891 |
|
|
|
892 |
|
|
drupal_goto($base_path, array('query' => $parameters));
|
893 |
|
|
}
|
894 |
|
|
|
895 |
102f8c26
|
Andreas Kohlbecker
|
/**
|
896 |
|
|
* Implements hook_requirements($phase)
|
897 |
|
|
*/
|
898 |
|
|
function cdm_dataportal_requirements($phase) {
|
899 |
|
|
$requirements = array();
|
900 |
|
|
if($phase == 'runtime'){
|
901 |
|
|
|
902 |
|
|
}
|
903 |
|
|
return $requirements;
|
904 |
|
|
}
|
905 |
|
|
|
906 |
6657531f
|
Andreas Kohlbecker
|
/**
|
907 |
|
|
* Implements hook_block_info().
|
908 |
|
|
*/
|
909 |
|
|
function cdm_dataportal_block_info() {
|
910 |
|
|
|
911 |
|
|
// $block[0]["info"] = t("CDM DataPortal DevLinks");
|
912 |
|
|
// $block[1]["info"] = t("CDM DataPortal Credits");
|
913 |
fc13aa30
|
Andreas Kohlbecker
|
$block["2"] = array(
|
914 |
beb914ef
|
Andreas Kohlbecker
|
"info" => t("CDM - Search Taxa"),
|
915 |
fc13aa30
|
Andreas Kohlbecker
|
"cache" => DRUPAL_NO_CACHE
|
916 |
|
|
);
|
917 |
6657531f
|
Andreas Kohlbecker
|
// $block[3]["info"] = t("CDM Filters");
|
918 |
beb914ef
|
Andreas Kohlbecker
|
$block["4"]["info"] = t("CDM - Dataportal Print");
|
919 |
|
|
$block["keys"]["info"] = t("CDM - Identification keys");
|
920 |
46a02272
|
Andreas Kohlbecker
|
$block["fundedByEDIT"]["info"] = t('CDM - Powered by EDIT');
|
921 |
f9a3d0f6
|
Andreas Kohlbecker
|
$block["classification_breadcrumbs"] = array(
|
922 |
beb914ef
|
Andreas Kohlbecker
|
'info' => t('CDM - Classification breadcrumbs'),
|
923 |
f9a3d0f6
|
Andreas Kohlbecker
|
'cache' => DRUPAL_CACHE_PER_PAGE
|
924 |
|
|
);
|
925 |
bc400a17
|
Andreas Kohlbecker
|
$block["taxonomic_children"] = array(
|
926 |
beb914ef
|
Andreas Kohlbecker
|
'info' => t('CDM - Taxonomic children'),
|
927 |
bc400a17
|
Andreas Kohlbecker
|
'cache' => DRUPAL_CACHE_PER_PAGE
|
928 |
|
|
);
|
929 |
beb914ef
|
Andreas Kohlbecker
|
$block["back_to_search_results"] = array(
|
930 |
|
|
'title' => '<none>',
|
931 |
|
|
'info' => t('CDM - Back to search Results'),
|
932 |
|
|
'cache' => DRUPAL_CACHE_PER_PAGE,
|
933 |
|
|
'visibility' => BLOCK_VISIBILITY_LISTED,
|
934 |
|
|
'pages' => "cdm_dataportal/taxon/*", // multiple page paths separated by "\n"!!!
|
935 |
|
|
);
|
936 |
a6ae799b
|
Andreas Kohlbecker
|
$block['registrations_search_filter'] = array(
|
937 |
b18d70f6
|
Andreas Kohlbecker
|
'title' => 'Filter registrations',
|
938 |
a6ae799b
|
Andreas Kohlbecker
|
'info' => t('CDM - Registrations search filter'),
|
939 |
|
|
'cache' => DRUPAL_CACHE_PER_PAGE,
|
940 |
810710a0
|
Andreas Kohlbecker
|
'visibility' => BLOCK_VISIBILITY_NOTLISTED,
|
941 |
b18d70f6
|
Andreas Kohlbecker
|
'pages' => "cdm_dataportal/registration-search\ncdm_dataportal/registration-search/*", // multiple page paths separated by "\n"!!!
|
942 |
a6ae799b
|
Andreas Kohlbecker
|
);
|
943 |
efbff4b3
|
Andreas Kohlbecker
|
$block['registrations_search_taxongraph'] = array(
|
944 |
|
|
'title' => 'Taxonomic registration search',
|
945 |
|
|
'info' => t('CDM - Registrations search by taxon graph'),
|
946 |
|
|
'cache' => DRUPAL_CACHE_PER_PAGE,
|
947 |
|
|
'visibility' => BLOCK_VISIBILITY_NOTLISTED,
|
948 |
b18d70f6
|
Andreas Kohlbecker
|
'pages' => "cdm_dataportal/registration-search\ncdm_dataportal/registration-search/*", // multiple page paths separated by "\n"!!!
|
949 |
|
|
);
|
950 |
|
|
$block['registrations_search'] = array(
|
951 |
|
|
'title' => 'Search',
|
952 |
|
|
'info' => t('CDM - Registrations search combining filter and taxon graph search' ),
|
953 |
|
|
'cache' => DRUPAL_CACHE_PER_PAGE,
|
954 |
|
|
'visibility' => BLOCK_VISIBILITY_NOTLISTED,
|
955 |
|
|
'pages' => "cdm_dataportal/registration-search\ncdm_dataportal/registration-search/*", // multiple page paths separated by "\n"!!!
|
956 |
efbff4b3
|
Andreas Kohlbecker
|
);
|
957 |
c05d1cfb
|
Andreas Kohlbecker
|
$block['utis_search'] = array(
|
958 |
|
|
'title' => 'UTIS Search',
|
959 |
|
|
'info' => t('Query the Unified Taxonomic Information Service (UTIS)' ),
|
960 |
|
|
'cache' => DRUPAL_CACHE_PER_PAGE,
|
961 |
|
|
'visibility' => BLOCK_VISIBILITY_NOTLISTED
|
962 |
|
|
);
|
963 |
efbff4b3
|
Andreas Kohlbecker
|
return $block;
|
964 |
6657531f
|
Andreas Kohlbecker
|
}
|
965 |
|
|
|
966 |
|
|
/**
|
967 |
|
|
* Implements hook_block_view().
|
968 |
|
|
*/
|
969 |
|
|
function cdm_dataportal_block_view($delta) {
|
970 |
|
|
// TODO Rename block deltas (e.g. '2') to readable strings.
|
971 |
|
|
switch ($delta) {
|
972 |
|
|
// case 'delta-1':
|
973 |
|
|
// $block['subject'] = t('Credits');
|
974 |
|
|
// $block['content'] = theme('cdm_credits');
|
975 |
|
|
// return $block;
|
976 |
|
|
case '2':
|
977 |
|
|
$block['subject'] = t('Search taxa');
|
978 |
191f88fd
|
Andreas Kohlbecker
|
$form = drupal_get_form('cdm_dataportal_search_taxon_form');
|
979 |
|
|
$block['content'] = drupal_render($form);
|
980 |
6657531f
|
Andreas Kohlbecker
|
|
981 |
|
|
if (variable_get('cdm_dataportal_show_advanced_search', 1)) {
|
982 |
|
|
$block['content'] .= '<div>' . l(t('Advanced Search'), 'cdm_dataportal/search') . '</div>';
|
983 |
6eaec849
|
Katja Luther
|
}
|
984 |
2f30124c
|
Andreas Kohlbecker
|
if (variable_get(CDM_SEARCH_BLAST_ENABLED)){
|
985 |
6eaec849
|
Katja Luther
|
$block['content'] .= '<div>' . l(t('Blast Search'), 'cdm_dataportal/search/blast') . '</div>';
|
986 |
6657531f
|
Andreas Kohlbecker
|
}
|
987 |
|
|
return $block;
|
988 |
|
|
case '4':
|
989 |
c8234bdf
|
Andreas Kohlbecker
|
$block['subject'] = '';
|
990 |
6657531f
|
Andreas Kohlbecker
|
$block['content'] = theme('cdm_print_button');
|
991 |
|
|
return $block;
|
992 |
|
|
case "keys":
|
993 |
|
|
$block['subject'] = t('Identification Keys');
|
994 |
|
|
$block['content'] = theme('cdm_block_IdentificationKeys', array('taxonUuid' => NULL));
|
995 |
|
|
return $block;
|
996 |
|
|
case "fundedByEDIT":
|
997 |
|
|
// t('Funded by EDIT');
|
998 |
|
|
$text = '<none>';
|
999 |
|
|
$block['subject'] = $text;
|
1000 |
889c74b7
|
Andreas Kohlbecker
|
$img_tag = '<img src="' . base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/powered_by_edit.png' . '" alt="' . $text . '"/>';
|
1001 |
|
|
$block['content'] = l($img_tag, "http://cybertaxonomy.org/", array(
|
1002 |
6657531f
|
Andreas Kohlbecker
|
'attributes' => array("target" => "EDIT"),
|
1003 |
|
|
'absolute' => TRUE,
|
1004 |
|
|
'html' => TRUE,
|
1005 |
|
|
));
|
1006 |
|
|
return $block;
|
1007 |
f9a3d0f6
|
Andreas Kohlbecker
|
case 'classification_breadcrumbs':
|
1008 |
0af3ce28
|
Andreas Kohlbecker
|
$taxon_uuid = get_current_taxon_uuid();
|
1009 |
38da4e54
|
Andreas Kohlbecker
|
$block['subject'] = '<none>';
|
1010 |
|
|
$block['content'] = compose_classification_breadcrumbs($taxon_uuid);
|
1011 |
|
|
return $block;
|
1012 |
bc400a17
|
Andreas Kohlbecker
|
case 'taxonomic_children':
|
1013 |
|
|
$taxon_uuid = get_current_taxon_uuid();
|
1014 |
|
|
$block['subject'] = '<none>';
|
1015 |
|
|
$block['content'] = compose_taxonomic_children($taxon_uuid);
|
1016 |
|
|
return $block;
|
1017 |
beb914ef
|
Andreas Kohlbecker
|
case 'back_to_search_results':
|
1018 |
|
|
$block['subject'] = '<none>';
|
1019 |
|
|
if (isset($_SESSION['cdm']['search'])) {
|
1020 |
|
|
$block['content'] = l(t('Back to search result'), "http://" . $_SERVER['SERVER_NAME'] . $_SESSION['cdm']['last_search']);
|
1021 |
|
|
}
|
1022 |
|
|
return $block;
|
1023 |
a6ae799b
|
Andreas Kohlbecker
|
case 'registrations_search_filter':
|
1024 |
|
|
$block['subject'] = '<none>';
|
1025 |
efbff4b3
|
Andreas Kohlbecker
|
$block['content'] = drupal_get_form('cdm_dataportal_search_registration_filter_form'); // see cdm_dataportal_search_registration_filter_form($form, &$form_state)
|
1026 |
|
|
return $block;
|
1027 |
|
|
case 'registrations_search_taxongraph':
|
1028 |
|
|
$block['subject'] = '<none>';
|
1029 |
|
|
$block['content'] = drupal_get_form('cdm_dataportal_search_registration_taxongraph_form'); // see cdm_dataportal_search_registration_taxongraph_form($form, &$form_state)
|
1030 |
a6ae799b
|
Andreas Kohlbecker
|
return $block;
|
1031 |
b18d70f6
|
Andreas Kohlbecker
|
case 'registrations_search':
|
1032 |
|
|
_add_js_ui_accordion();
|
1033 |
|
|
_add_font_awesome_font();
|
1034 |
|
|
$block['subject'] = '<none>';
|
1035 |
|
|
$filter_form = drupal_get_form('cdm_dataportal_search_registration_filter_form');
|
1036 |
|
|
$filter_form['#prefix'] = '<div>';
|
1037 |
|
|
$filter_form['#suffix'] = '</div>';
|
1038 |
|
|
$taxongraph_form = drupal_get_form('cdm_dataportal_search_registration_taxongraph_form');
|
1039 |
|
|
$taxongraph_form['#prefix'] = '<div>';
|
1040 |
|
|
$taxongraph_form['#suffix'] = '</div>';
|
1041 |
|
|
$block['content'] = array(
|
1042 |
|
|
'accordion' => array(
|
1043 |
|
|
'#markup' => '',
|
1044 |
|
|
'#prefix' => '<div id="accordion">',
|
1045 |
|
|
'#suffix' => '</div>',
|
1046 |
|
|
'content' => array(
|
1047 |
|
|
array('#markup' => '<h3>Filter</h3>'),
|
1048 |
|
|
$filter_form,
|
1049 |
|
|
array('#markup' => '<h3>Taxon graph</h3>'),
|
1050 |
|
|
$taxongraph_form,
|
1051 |
|
|
)
|
1052 |
|
|
)
|
1053 |
|
|
);
|
1054 |
|
|
return $block;
|
1055 |
c05d1cfb
|
Andreas Kohlbecker
|
case 'utis_search':
|
1056 |
|
|
_add_js_utis_client('.utis_client');
|
1057 |
|
|
$block['subject'] = '<none>';
|
1058 |
579bc6e3
|
Andreas Kohlbecker
|
$block['content'] = '<div class="utis_client"></div>';
|
1059 |
c05d1cfb
|
Andreas Kohlbecker
|
return $block;
|
1060 |
beb914ef
|
Andreas Kohlbecker
|
default:
|
1061 |
|
|
return null;
|
1062 |
6657531f
|
Andreas Kohlbecker
|
}
|
1063 |
|
|
}
|
1064 |
|
|
|
1065 |
e27e3ff2
|
Andreas Kohlbecker
|
|
1066 |
0af3ce28
|
Andreas Kohlbecker
|
/**
|
1067 |
|
|
* Provides the uuid of the taxon for pages with the path ./taxon/{taxon_uuid}
|
1068 |
|
|
*
|
1069 |
|
|
* @return string
|
1070 |
|
|
* the taxon uuid or NULL
|
1071 |
|
|
*/
|
1072 |
|
|
function get_current_taxon_uuid()
|
1073 |
|
|
{
|
1074 |
|
|
static $taxon_uuid;
|
1075 |
|
|
|
1076 |
|
|
if(!isset($taxon_uuid)){
|
1077 |
|
|
if(isset($_REQUEST['currentTaxon']) && is_uuid($_REQUEST['currentTaxon'])) {
|
1078 |
|
|
$taxon_uuid = $_REQUEST['currentTaxon'];
|
1079 |
|
|
} else if (arg(1) == 'taxon' && is_uuid(arg(2))) {
|
1080 |
|
|
$taxon_uuid = arg(2);
|
1081 |
|
|
} else {
|
1082 |
|
|
$taxon_uuid = null;
|
1083 |
|
|
}
|
1084 |
|
|
}
|
1085 |
|
|
|
1086 |
|
|
return $taxon_uuid;
|
1087 |
|
|
}
|
1088 |
|
|
|
1089 |
|
|
/**
|
1090 |
|
|
* Returns the currently classification tree in use.
|
1091 |
|
|
*
|
1092 |
|
|
* @return string
|
1093 |
|
|
* The uuid of the currently focused classification
|
1094 |
|
|
*/
|
1095 |
|
|
function get_current_classification_uuid() {
|
1096 |
|
|
if (isset($_SESSION['cdm']['taxonomictree_uuid']) && is_uuid($_SESSION['cdm']['taxonomictree_uuid'])) {
|
1097 |
|
|
return $_SESSION['cdm']['taxonomictree_uuid'];
|
1098 |
|
|
}
|
1099 |
|
|
else {
|
1100 |
|
|
return variable_get(CDM_TAXONOMICTREE_UUID, FALSE);
|
1101 |
|
|
}
|
1102 |
|
|
}
|
1103 |
|
|
|
1104 |
6657531f
|
Andreas Kohlbecker
|
/*
|
1105 |
|
|
function cdm_dataportal_session_clear($cdm_ws_uri_update = FALSE){
|
1106 |
|
|
$_SESSION['cdm'] = NULL;
|
1107 |
|
|
if(is_string($cdm_ws_uri_update)){
|
1108 |
|
|
$_SESSION['cdm'] = array('ws_uri'=>$cdm_ws_uri_update);
|
1109 |
|
|
}
|
1110 |
|
|
}
|
1111 |
|
|
|
1112 |
|
|
function cdm_dataportal_session_validate(){
|
1113 |
|
|
if(!isset($_SESSION['cdm']['ws_uri'])){
|
1114 |
|
|
$_SESSION['cdm'] = array('ws_uri'=>variable_get('cdm_webservice_url', FALSE));
|
1115 |
|
|
} else if($_SESSION['cdm']['ws_uri'] != variable_get('cdm_webservice_url', FALSE)){
|
1116 |
|
|
cdm_dataportal_session_clear(variable_get('cdm_webservice_url', FALSE));
|
1117 |
|
|
}
|
1118 |
|
|
}
|
1119 |
|
|
*/
|
1120 |
|
|
|
1121 |
|
|
/**
|
1122 |
d7588d36
|
Andreas Kohlbecker
|
* creates a selector form for taxonomic trees.
|
1123 |
|
|
*
|
1124 |
0af3ce28
|
Andreas Kohlbecker
|
* @return array
|
1125 |
|
|
* a drupal form array
|
1126 |
6657531f
|
Andreas Kohlbecker
|
*/
|
1127 |
|
|
function cdm_taxonomictree_selector() {
|
1128 |
|
|
_add_js_treeselector();
|
1129 |
|
|
|
1130 |
a8a8f23c
|
Andreas Kohlbecker
|
$form = drupal_get_form('cdm_taxonomictree_selector_form');
|
1131 |
d7588d36
|
Andreas Kohlbecker
|
return $form;
|
1132 |
6657531f
|
Andreas Kohlbecker
|
}
|
1133 |
|
|
|
1134 |
|
|
/**
|
1135 |
|
|
* @todo Please document this function.
|
1136 |
|
|
* @see http://drupal.org/node/1354
|
1137 |
0af3ce28
|
Andreas Kohlbecker
|
*
|
1138 |
|
|
* @deprecated use compose_classification_selector instead
|
1139 |
6657531f
|
Andreas Kohlbecker
|
*/
|
1140 |
|
|
function cdm_taxonomictree_selector_form($form, &$form_state) {
|
1141 |
|
|
|
1142 |
|
|
$url = url('cdm_api/setvalue/session', array('query' => NULL));
|
1143 |
|
|
$form['#action'] = $url;
|
1144 |
|
|
|
1145 |
|
|
$form['var'] = array(
|
1146 |
|
|
'#weight' => -3,
|
1147 |
|
|
'#type' => 'hidden',
|
1148 |
|
|
'#value' => '[cdm][taxonomictree_uuid]',
|
1149 |
|
|
);
|
1150 |
|
|
|
1151 |
|
|
$destination_array = drupal_get_destination();
|
1152 |
|
|
$destination = $destination_array['destination'];
|
1153 |
|
|
|
1154 |
|
|
$form['destination'] = array(
|
1155 |
|
|
'#weight' => -3,
|
1156 |
|
|
'#type' => 'hidden',
|
1157 |
|
|
'#value' => $destination,
|
1158 |
|
|
);
|
1159 |
|
|
|
1160 |
26fb3778
|
Andreas Kohlbecker
|
$options = cdm_get_taxontrees_as_options();
|
1161 |
|
|
$taxontree_includes = variable_get(CDM_TAXONTREE_INCLUDES, null);
|
1162 |
|
|
if($taxontree_includes){
|
1163 |
|
|
$filtered_options = array();
|
1164 |
|
|
foreach($options as $uuid=>$label){
|
1165 |
|
|
if(!empty($taxontree_includes[$uuid])){
|
1166 |
|
|
$filtered_options[$uuid] = $label;
|
1167 |
|
|
}
|
1168 |
|
|
}
|
1169 |
|
|
$options = $filtered_options;
|
1170 |
|
|
}
|
1171 |
|
|
|
1172 |
6657531f
|
Andreas Kohlbecker
|
$form['val'] = array(
|
1173 |
|
|
'#type' => 'select',
|
1174 |
|
|
'#title' => t('Available classifications'),
|
1175 |
7663cd0b
|
Andreas Kohlbecker
|
'#default_value' => get_current_classification_uuid(),
|
1176 |
26fb3778
|
Andreas Kohlbecker
|
'#options' => $options,
|
1177 |
0af3ce28
|
Andreas Kohlbecker
|
'#attributes' => array('class' => array('highlite-first-child')),
|
1178 |
6657531f
|
Andreas Kohlbecker
|
);
|
1179 |
|
|
|
1180 |
|
|
return $form;
|
1181 |
|
|
|
1182 |
|
|
}
|
1183 |
|
|
|
1184 |
0af3ce28
|
Andreas Kohlbecker
|
/**
|
1185 |
|
|
*
|
1186 |
|
|
* @ingroup compose
|
1187 |
|
|
*/
|
1188 |
|
|
function compose_classification_selector() {
|
1189 |
|
|
|
1190 |
|
|
$destination_array = drupal_get_destination();
|
1191 |
|
|
$destination = $destination_array['destination'];
|
1192 |
|
|
|
1193 |
|
|
$options = cdm_get_taxontrees_as_options();
|
1194 |
|
|
$items = array();
|
1195 |
|
|
$taxontree_includes = variable_get(CDM_TAXONTREE_INCLUDES, null);
|
1196 |
|
|
|
1197 |
|
|
$current_classification_uuid = get_current_classification_uuid();
|
1198 |
|
|
|
1199 |
|
|
|
1200 |
|
|
foreach($options as $uuid=>$label){
|
1201 |
|
|
if(!$taxontree_includes || !empty($taxontree_includes[$uuid])){
|
1202 |
|
|
|
1203 |
|
|
$class_attributes = '';
|
1204 |
|
|
if($current_classification_uuid == $uuid){
|
1205 |
|
|
$class_attributes = array('focused');
|
1206 |
|
|
}
|
1207 |
|
|
$items[] = array(
|
1208 |
|
|
'data' => l($label,
|
1209 |
|
|
'cdm_api/setvalue/session',
|
1210 |
|
|
array(
|
1211 |
|
|
'query' => array(
|
1212 |
|
|
'destination' => $destination,
|
1213 |
|
|
'val' => $uuid,
|
1214 |
|
|
'var' => '[cdm][taxonomictree_uuid]'
|
1215 |
|
|
),
|
1216 |
|
|
)
|
1217 |
|
|
),
|
1218 |
|
|
'class' => $class_attributes
|
1219 |
|
|
);
|
1220 |
|
|
}
|
1221 |
|
|
}
|
1222 |
|
|
|
1223 |
|
|
$render_array = array(
|
1224 |
|
|
'#theme' => 'item_list',
|
1225 |
|
|
'#type' => 'ul',
|
1226 |
|
|
'#items' => $items
|
1227 |
|
|
);
|
1228 |
|
|
|
1229 |
|
|
return $render_array;
|
1230 |
|
|
}
|
1231 |
|
|
|
1232 |
|
|
|
1233 |
6657531f
|
Andreas Kohlbecker
|
/* UNREACHABLE since action of form directly links to view.
|
1234 |
|
|
function cdm_dataportal_search_taxon_form_submit($form_id, $form_values) {
|
1235 |
|
|
|
1236 |
|
|
$_SESSION['cdm']['search'] = $form_values;
|
1237 |
|
|
//return '/cdm_dataportal/search/taxon/'.$form_values['queryString'].'/'.($form_values['vernacular']?'1':'0').'/'.$form_values['language'];
|
1238 |
|
|
return '/cdm_dataportal/search/taxon/'.$form_values['queryString'].'/'.($form_values['onlyAccepted']?'1':'0');
|
1239 |
|
|
//$paramstr = compose_url_prameterstr($form_values);
|
1240 |
|
|
//return url('/cdm_dataportal/search/taxon/', array('query' => $paramstr));
|
1241 |
|
|
}
|
1242 |
|
|
*/
|
1243 |
|
|
/* ====================== menu callback functions ====================== */
|
1244 |
|
|
/**
|
1245 |
|
|
* @todo Please document this function.
|
1246 |
|
|
* @see http://drupal.org/node/1354
|
1247 |
|
|
*/
|
1248 |
|
|
/*
|
1249 |
|
|
function cdm_dataportal_form_alter(&$form, &$form_state, $form_id) {
|
1250 |
|
|
static $comment_node_disabled = 0;
|
1251 |
|
|
static $comment_node_read_only = 1;
|
1252 |
|
|
static $comment_node_read_write = 2;
|
1253 |
|
|
|
1254 |
|
|
if ($form_id == 'node_type_form'
|
1255 |
|
|
&& isset($form['identity']['type'])
|
1256 |
|
|
&& array_key_exists($form['#node_type']->type, cdm_get_nodetypes())
|
1257 |
|
|
) {
|
1258 |
|
|
$form['workflow']['comment'] = array(
|
1259 |
|
|
'#type' => 'radios',
|
1260 |
|
|
'#title' => t('Default comment setting'),
|
1261 |
|
|
'#default_value' => variable_get('comment__' . $node->type . $form['#node_type']->type, $comment_node_disabled),
|
1262 |
|
|
'#options' => array(t('Disabled'), t('Read only'), t('Read/Write')),
|
1263 |
|
|
'#description' => t('Users with the <em>administer comments</em> permission will be able to override this setting.'),
|
1264 |
|
|
);
|
1265 |
|
|
}
|
1266 |
|
|
}
|
1267 |
|
|
*/
|
1268 |
|
|
|
1269 |
|
|
/**
|
1270 |
|
|
* Displays a list of the known taxonomic names.
|
1271 |
|
|
*
|
1272 |
|
|
* When the list of taxonomic names is displayed, long lists are split up into
|
1273 |
|
|
* multiple pages.
|
1274 |
|
|
*
|
1275 |
|
|
* TODO: Parameters are still preliminary.
|
1276 |
|
|
*
|
1277 |
|
|
* @param string $beginsWith
|
1278 |
|
|
* @param string $page
|
1279 |
|
|
* Page number to diplay defaults to page 1.
|
1280 |
|
|
* @param bool $onlyAccepted
|
1281 |
|
|
*/
|
1282 |
|
|
function cdm_dataportal_view_names($beginsWith = 'A', $page = 1, $onlyAccepted = FALSE) {
|
1283 |
|
|
|
1284 |
|
|
$out = t('<h3>Sorry, the name list feature is not yet available in this version of the DataPortal software<h3>');
|
1285 |
|
|
|
1286 |
|
|
/*
|
1287 |
|
|
// FIXME the filter for accepted names will be a form element, thus this
|
1288 |
|
|
// widget should be generated via form api preferably as block.
|
1289 |
|
|
$out = theme('cdm_dataportal_widget_filter_accepted', $onlyAccepted);
|
1290 |
|
|
$out .= theme('cdm_dataportal_widget_names_list', $names, $page);
|
1291 |
|
|
$out .= theme('cdm_listof_taxa', $taxonPager);
|
1292 |
|
|
return $out;
|
1293 |
|
|
*/
|
1294 |
|
|
}
|
1295 |
|
|
|
1296 |
|
|
/**
|
1297 |
|
|
* @todo Please document this function.
|
1298 |
|
|
* @see http://drupal.org/node/1354
|
1299 |
c0223d83
|
Andreas Kohlbecker
|
* @throws Exception
|
1300 |
6657531f
|
Andreas Kohlbecker
|
*/
|
1301 |
|
|
function cdm_dataportal_view_reference($uuid, $arg2 = NULL) {
|
1302 |
f26245c8
|
Andreas Kohlbecker
|
|
1303 |
|
|
cdm_check_valid_portal_page();
|
1304 |
|
|
|
1305 |
6cbefddc
|
Andreas Kohlbecker
|
return compose_cdm_reference_page($uuid);
|
1306 |
6657531f
|
Andreas Kohlbecker
|
}
|
1307 |
|
|
|
1308 |
|
|
/**
|
1309 |
b2ebf0d3
|
Andreas Kohlbecker
|
* Creates a view on a all references contained in the portal.
|
1310 |
b5dca1e2
|
Andreas Kohlbecker
|
*
|
1311 |
|
|
* This function is used at the path cdm_dataportal/reference/list
|
1312 |
6657531f
|
Andreas Kohlbecker
|
*/
|
1313 |
|
|
function cdm_dataportal_view_reference_list($pageNumber) {
|
1314 |
|
|
$referencePager = cdm_ws_page(CDM_WS_REFERENCE, variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE), $pageNumber);
|
1315 |
b2ebf0d3
|
Andreas Kohlbecker
|
cdm_reference_pager($referencePager, 'cdm_dataportal/reference/list/');
|
1316 |
6657531f
|
Andreas Kohlbecker
|
}
|
1317 |
|
|
|
1318 |
|
|
/**
|
1319 |
|
|
* @todo Please document this function.
|
1320 |
|
|
* @see http://drupal.org/node/1354
|
1321 |
|
|
*/
|
1322 |
|
|
function cdm_dataportal_view_media($mediaUuid, $mediarepresentation_uuid = FALSE, $part = 0) {
|
1323 |
f26245c8
|
Andreas Kohlbecker
|
|
1324 |
|
|
cdm_check_valid_portal_page();
|
1325 |
|
|
|
1326 |
6657531f
|
Andreas Kohlbecker
|
$media = cdm_ws_get(CDM_WS_PORTAL_MEDIA, $mediaUuid);
|
1327 |
4d9660ef
|
Andreas Kohlbecker
|
if (!$media) {
|
1328 |
|
|
drupal_set_title(t('Media does not exist'), PASS_THROUGH);
|
1329 |
de017852
|
Andreas Kohlbecker
|
return "";
|
1330 |
4d9660ef
|
Andreas Kohlbecker
|
}
|
1331 |
6657531f
|
Andreas Kohlbecker
|
return theme('cdm_media_page', array(
|
1332 |
|
|
'media' => $media,
|
1333 |
|
|
'mediarepresentation_uuid' => $mediarepresentation_uuid,
|
1334 |
|
|
'partId' => $part,
|
1335 |
|
|
));
|
1336 |
|
|
}
|
1337 |
|
|
|
1338 |
|
|
/**
|
1339 |
|
|
* @todo Please document this function.
|
1340 |
|
|
* @see http://drupal.org/node/1354
|
1341 |
|
|
*/
|
1342 |
|
|
function _load_taxonBase(&$taxonBase) {
|
1343 |
|
|
if (isset($taxonBase->uuid)) {
|
1344 |
|
|
$taxonBase->name = cdm_ws_get(CDM_WS_TAXON, array($taxonBase->uuid, "name"));
|
1345 |
|
|
$taxonBase->name->taggedName = cdm_ws_get(CDM_WS_NAME, array($taxonBase->name->uuid, "taggedName"));
|
1346 |
|
|
$taxonBase->name->nomenclaturalReference = cdm_ws_get(CDM_WS_NAME, array($taxonBase->name->uuid, "nomenclaturalReference"));
|
1347 |
|
|
}
|
1348 |
|
|
}
|
1349 |
|
|
|
1350 |
9438ad3a
|
Andreas Kohlbecker
|
/**
|
1351 |
|
|
* Loads the media associated to the given taxon from the cdm server.
|
1352 |
|
|
* The aggregation settings regarding taxon relathionships and
|
1353 |
|
|
* taxonnomic childen are taken into account.
|
1354 |
|
|
*
|
1355 |
|
|
* The media lists are cached in a static variable.
|
1356 |
|
|
*
|
1357 |
|
|
* @param Taxon $taxon
|
1358 |
4a462641
|
Andreas Kohlbecker
|
* A CDM Taxon entity
|
1359 |
9438ad3a
|
Andreas Kohlbecker
|
*
|
1360 |
|
|
* @return array
|
1361 |
|
|
* An array of CDM Media entities
|
1362 |
|
|
*
|
1363 |
|
|
*/
|
1364 |
4a462641
|
Andreas Kohlbecker
|
function _load_media_for_taxon($taxon) {
|
1365 |
9438ad3a
|
Andreas Kohlbecker
|
|
1366 |
|
|
static $media = NULL;
|
1367 |
|
|
|
1368 |
|
|
if(!isset($media)) {
|
1369 |
|
|
$media = array();
|
1370 |
|
|
}
|
1371 |
|
|
if (!isset($media[$taxon->uuid])) {
|
1372 |
|
|
|
1373 |
a950f2f9
|
Andreas Kohlbecker
|
|
1374 |
4a462641
|
Andreas Kohlbecker
|
$mediaQueryParameters = taxon_media_query_parameters();
|
1375 |
9438ad3a
|
Andreas Kohlbecker
|
|
1376 |
f19f47fa
|
Andreas Kohlbecker
|
$ws_endpoint = NULL;
|
1377 |
4a462641
|
Andreas Kohlbecker
|
if ( $mediaQueryParameters['includeTaxonomicChildren']) {
|
1378 |
9438ad3a
|
Andreas Kohlbecker
|
$ws_endpoint = CDM_WS_PORTAL_TAXON_SUBTREE_MEDIA;
|
1379 |
4a462641
|
Andreas Kohlbecker
|
} else {
|
1380 |
|
|
$ws_endpoint = CDM_WS_PORTAL_TAXON_MEDIA;
|
1381 |
9438ad3a
|
Andreas Kohlbecker
|
}
|
1382 |
4a462641
|
Andreas Kohlbecker
|
// this parameter is not yet used by the CDM_WS_PORTAL_TAXON_*MEDIA
|
1383 |
|
|
// services
|
1384 |
|
|
unset($mediaQueryParameters['includeTaxonomicChildren']);
|
1385 |
f19f47fa
|
Andreas Kohlbecker
|
|
1386 |
|
|
$media[$taxon->uuid] = cdm_ws_get($ws_endpoint,
|
1387 |
|
|
array(
|
1388 |
|
|
$taxon->uuid,
|
1389 |
|
|
),
|
1390 |
9438ad3a
|
Andreas Kohlbecker
|
queryString($mediaQueryParameters)
|
1391 |
|
|
);
|
1392 |
|
|
}
|
1393 |
|
|
|
1394 |
|
|
return $media[$taxon->uuid];
|
1395 |
|
|
}
|
1396 |
|
|
|
1397 |
|
|
/**
|
1398 |
|
|
*
|
1399 |
|
|
* @param Taxon $taxon
|
1400 |
|
|
* A CDM Taxon entitiy
|
1401 |
|
|
*
|
1402 |
|
|
* @return array
|
1403 |
|
|
* An array of CDM SpecimenOrObservation entities
|
1404 |
|
|
*
|
1405 |
|
|
function _load_occurences_for_taxon($taxon){
|
1406 |
|
|
|
1407 |
|
|
static $occurences = NULL;
|
1408 |
f19f47fa
|
Andreas Kohlbecker
|
|
1409 |
|
|
if(!isset($occurences)) {
|
1410 |
|
|
$occurences = array();
|
1411 |
|
|
}
|
1412 |
9438ad3a
|
Andreas Kohlbecker
|
|
1413 |
|
|
if (!isset($occurences[$taxon->uuid])){
|
1414 |
|
|
|
1415 |
|
|
$relationship_choice = variable_get(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS, unserialize(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT));
|
1416 |
|
|
$relationship_choice['direct'] = get_selection($relationship_choice['direct']);
|
1417 |
f19f47fa
|
Andreas Kohlbecker
|
$relationship_choice['invers'] = get_selection($relationship_choice['invers']);
|
1418 |
|
|
|
1419 |
|
|
$by_associatedtaxon_query = http_build_query(array(
|
1420 |
|
|
'relationshipsInvers' => implode(',', $relationship_choice['invers']),
|
1421 |
|
|
'relationships' => implode(',', $relationship_choice['direct']),
|
1422 |
|
|
'pageSize' => null // all hits in one page
|
1423 |
|
|
)
|
1424 |
|
|
);
|
1425 |
|
|
|
1426 |
|
|
$pager = cdm_ws_get(CDM_WS_OCCURRENCE_BY_ASSOCIATEDTAXON,
|
1427 |
|
|
null,
|
1428 |
|
|
$by_associatedtaxon_query . '&taxonUuid=' . $taxon->uuid
|
1429 |
|
|
);
|
1430 |
|
|
|
1431 |
|
|
|
1432 |
|
|
if(isset($pager->records[0])){
|
1433 |
|
|
$occurences[$taxon->uuid] = $pager->records;
|
1434 |
|
|
}
|
1435 |
|
|
}
|
1436 |
9438ad3a
|
Andreas Kohlbecker
|
return $occurences[$taxon->uuid];
|
1437 |
|
|
}
|
1438 |
|
|
*/
|
1439 |
|
|
|
1440 |
6657531f
|
Andreas Kohlbecker
|
/**
|
1441 |
|
|
* Gets a Drupal variable, string or array and returns it.
|
1442 |
|
|
*
|
1443 |
|
|
* Similar to the variable_get() function of Drupal, except that this function
|
1444 |
|
|
* is able to handle arrays correctly. This function is especially useful
|
1445 |
8c962983
|
Andreas Kohlbecker
|
* when dealing with collections of settings form elements (#tree = TRUE).
|
1446 |
6657531f
|
Andreas Kohlbecker
|
*
|
1447 |
|
|
* @param string $variableKey
|
1448 |
|
|
* The Unique key of the Drupal variable in the Drupal variables table.
|
1449 |
|
|
* @param string $defaultValueString
|
1450 |
|
|
* A string as for example derived from a CONSTANT.
|
1451 |
|
|
*
|
1452 |
|
|
* @return mixed
|
1453 |
8c962983
|
Andreas Kohlbecker
|
* usually an array, depending on the nature of the variable.
|
1454 |
|
|
*
|
1455 |
|
|
* TODO compare with get_array_variable_merged() duplicate functions?
|
1456 |
0f7c9d15
|
Andreas Kohlbecker
|
* @deprecated rather use get_array_variable_merged() since this function
|
1457 |
|
|
* used an array as second parameter
|
1458 |
6657531f
|
Andreas Kohlbecker
|
*/
|
1459 |
|
|
function mixed_variable_get($variableKey, $defaultValueString) {
|
1460 |
|
|
$systemDefaults = unserialize($defaultValueString);
|
1461 |
|
|
$storedSettings = variable_get($variableKey, array());
|
1462 |
|
|
if (is_array($storedSettings)) {
|
1463 |
8c962983
|
Andreas Kohlbecker
|
// TODO better use drupal_array_merge_deep() ?
|
1464 |
6657531f
|
Andreas Kohlbecker
|
$settings = array_merge($systemDefaults, $storedSettings);
|
1465 |
|
|
}
|
1466 |
|
|
else {
|
1467 |
|
|
$settings = $systemDefaults;
|
1468 |
|
|
}
|
1469 |
|
|
return $settings;
|
1470 |
|
|
}
|
1471 |
|
|
|
1472 |
b5519d3a
|
Andreas Kohlbecker
|
/**
|
1473 |
0f7c9d15
|
Andreas Kohlbecker
|
* Recursive function to convert an object into an array.
|
1474 |
b5519d3a
|
Andreas Kohlbecker
|
* also subordinate objects will be converted.
|
1475 |
|
|
*
|
1476 |
|
|
* @param object $object
|
1477 |
db725031
|
Andreas Kohlbecker
|
* the object to be converted
|
1478 |
|
|
* @return array
|
1479 |
|
|
* The array
|
1480 |
b5519d3a
|
Andreas Kohlbecker
|
*/
|
1481 |
db725031
|
Andreas Kohlbecker
|
function object_to_array($object) {
|
1482 |
b5519d3a
|
Andreas Kohlbecker
|
if(is_object($object) || is_array($object)) {
|
1483 |
|
|
$array = (array)$object;
|
1484 |
|
|
foreach ($array as $key=>$value){
|
1485 |
db725031
|
Andreas Kohlbecker
|
$array[$key] = object_to_array($value);
|
1486 |
b5519d3a
|
Andreas Kohlbecker
|
}
|
1487 |
|
|
return $array;
|
1488 |
|
|
} else {
|
1489 |
|
|
return $object;
|
1490 |
|
|
}
|
1491 |
|
|
}
|
1492 |
|
|
|
1493 |
2fd6da0b
|
Andreas Kohlbecker
|
/**
|
1494 |
|
|
* Searches the $collection for the cdm entitiy given as $element.
|
1495 |
|
|
*
|
1496 |
|
|
* The elements are compared by their UUID.
|
1497 |
|
|
*
|
1498 |
|
|
* @param $element
|
1499 |
|
|
* the CDM entitiy to search for
|
1500 |
|
|
* @param $collection
|
1501 |
|
|
* the list of CDM entities to search in
|
1502 |
|
|
*
|
1503 |
|
|
* @return boolean TRUE if the $collection contains the $element, otheriwse FALSE
|
1504 |
|
|
*
|
1505 |
|
|
*/
|
1506 |
|
|
function contains_cdm_entitiy($element, $collection) {
|
1507 |
|
|
$result = FALSE;
|
1508 |
|
|
foreach ($collection as $a) {
|
1509 |
|
|
if ($a->uuid == $element->uuid) {
|
1510 |
|
|
$result = TRUE;
|
1511 |
|
|
}
|
1512 |
|
|
}
|
1513 |
|
|
return $result;
|
1514 |
|
|
}
|
1515 |
|
|
|
1516 |
|
|
/**
|
1517 |
14076b88
|
Andreas Kohlbecker
|
* Filters the array $entity_list of CDM entities by the list
|
1518 |
2fd6da0b
|
Andreas Kohlbecker
|
* of $excludes. Any element contained in the $excludes will be removed
|
1519 |
14076b88
|
Andreas Kohlbecker
|
* from included int the returned list.
|
1520 |
2fd6da0b
|
Andreas Kohlbecker
|
*
|
1521 |
|
|
* If the $entity_list is not an array the $excludes will be returned.
|
1522 |
|
|
*/
|
1523 |
|
|
function filter_cdm_entity_list($entity_list, $excludes) {
|
1524 |
|
|
if (is_array($entity_list)) {
|
1525 |
|
|
$result = $entity_list;
|
1526 |
|
|
if ($excludes) {
|
1527 |
|
|
foreach ($excludes as $exclude) {
|
1528 |
|
|
if (!contains_cdm_entitiy($exclude, $entity_list)) {
|
1529 |
|
|
$result[] = $exclude;
|
1530 |
|
|
}
|
1531 |
|
|
}
|
1532 |
|
|
}
|
1533 |
|
|
}
|
1534 |
|
|
else {
|
1535 |
|
|
$result = $excludes;
|
1536 |
|
|
}
|
1537 |
|
|
return $result;
|
1538 |
|
|
}
|
1539 |
|
|
|
1540 |
0a1151a4
|
Andreas Kohlbecker
|
/**
|
1541 |
6f5c7f2a
|
Andreas Kohlbecker
|
* Wraps the given $html string into a render array suitable for drupal_render()
|
1542 |
0a1151a4
|
Andreas Kohlbecker
|
*
|
1543 |
65345976
|
Andreas Kohlbecker
|
* @param $html
|
1544 |
0a1151a4
|
Andreas Kohlbecker
|
* the html string, see
|
1545 |
|
|
* http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#markup
|
1546 |
65345976
|
Andreas Kohlbecker
|
* @param $weight
|
1547 |
0a1151a4
|
Andreas Kohlbecker
|
* A positive or negative number (integer or decimal).
|
1548 |
|
|
* see http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#weightval
|
1549 |
65345976
|
Andreas Kohlbecker
|
* @param $prefix
|
1550 |
|
|
* Optional markup for the '#prefix' element of the render array
|
1551 |
|
|
* @param $suffix
|
1552 |
|
|
* Optional markup for the '#suffix' element of the render array
|
1553 |
0a1151a4
|
Andreas Kohlbecker
|
*
|
1554 |
65345976
|
Andreas Kohlbecker
|
* @return array
|
1555 |
0a1151a4
|
Andreas Kohlbecker
|
* A render array
|
1556 |
|
|
*
|
1557 |
|
|
*/
|
1558 |
65345976
|
Andreas Kohlbecker
|
function markup_to_render_array($html, $weight = FALSE, $prefix = NULL, $suffix = NULL) {
|
1559 |
6f5c7f2a
|
Andreas Kohlbecker
|
$render_array = array(
|
1560 |
|
|
'#markup' => $html
|
1561 |
1ce9afb7
|
Patric Plitzner
|
);
|
1562 |
6f5c7f2a
|
Andreas Kohlbecker
|
if (is_numeric($weight)) {
|
1563 |
|
|
$render_array['#weight'] = $weight;
|
1564 |
65345976
|
Andreas Kohlbecker
|
}
|
1565 |
|
|
if($prefix){
|
1566 |
|
|
$render_array['#prefix'] = $prefix;
|
1567 |
|
|
}
|
1568 |
|
|
if($suffix) {
|
1569 |
|
|
$render_array['#suffix'] = $suffix;
|
1570 |
|
|
}
|
1571 |
6f5c7f2a
|
Andreas Kohlbecker
|
return $render_array;
|
1572 |
0a1151a4
|
Andreas Kohlbecker
|
}
|
1573 |
|
|
|
1574 |
6657531f
|
Andreas Kohlbecker
|
/**
|
1575 |
|
|
* Loads the subgraph of a given PolytomousKeyNode.
|
1576 |
|
|
*
|
1577 |
|
|
* Loads the subgraph of the given PolytomousKeyNode recursively from
|
1578 |
|
|
* the CDM REST service.
|
1579 |
|
|
*
|
1580 |
|
|
* @param mixed $polytomousKeyNode
|
1581 |
|
|
* PolytomousKeyNode passed by reference.
|
1582 |
|
|
*
|
1583 |
|
|
* @return void
|
1584 |
|
|
*/
|
1585 |
|
|
function _load_polytomousKeySubGraph(&$polytomousKeyNode) {
|
1586 |
|
|
|
1587 |
|
|
if (!$polytomousKeyNode) {
|
1588 |
|
|
return;
|
1589 |
|
|
}
|
1590 |
|
|
if ($polytomousKeyNode->class != "PolytomousKeyNode") {
|
1591 |
f19f47fa
|
Andreas Kohlbecker
|
drupal_set_message('_load_polytomousKeySubGraph(): ' . t('invalid type given.'), 'error');
|
1592 |
6657531f
|
Andreas Kohlbecker
|
return;
|
1593 |
|
|
}
|
1594 |
|
|
if (!is_uuid($polytomousKeyNode->uuid)) {
|
1595 |
f19f47fa
|
Andreas Kohlbecker
|
drupal_set_message('_load_polytomousKeySubGraph(): ' . t('invalid type given.'), 'error');
|
1596 |
6657531f
|
Andreas Kohlbecker
|
return;
|
1597 |
|
|
}
|
1598 |
|
|
|
1599 |
|
|
$polytomousKeyNode = cdm_ws_get(CDM_WS_POLYTOMOUSKEY_NODE, $polytomousKeyNode->uuid);
|
1600 |
|
|
|
1601 |
|
|
if (!$polytomousKeyNode) {
|
1602 |
|
|
// drupal_set_message("_load_polytomousKeyChildNodes() : could not load polytomousKeyNode", "error");
|
1603 |
|
|
return;
|
1604 |
|
|
}
|
1605 |
|
|
|
1606 |
|
|
// Load children.
|
1607 |
|
|
foreach ($polytomousKeyNode->children as &$childNode) {
|
1608 |
|
|
_load_polytomousKeySubGraph($childNode);
|
1609 |
|
|
}
|
1610 |
|
|
|
1611 |
|
|
// Load subkey.
|
1612 |
|
|
$polytomousKeyNode->subkey = cdm_ws_get(CDM_WS_POLYTOMOUSKEY_NODE, array($polytomousKeyNode->uuid, "subkey"));
|
1613 |
|
|
|
1614 |
|
|
// Load taxon.
|
1615 |
|
|
$polytomousKeyNode->taxon = cdm_ws_get(CDM_WS_POLYTOMOUSKEY_NODE, array($polytomousKeyNode->uuid, "taxon"));
|
1616 |
|
|
_load_taxonBase($polytomousKeyNode->taxon);
|
1617 |
|
|
return;
|
1618 |
|
|
}
|
1619 |
|
|
|
1620 |
|
|
/**
|
1621 |
|
|
* @todo Please document this function.
|
1622 |
|
|
* @see http://drupal.org/node/1354
|
1623 |
|
|
*/
|
1624 |
|
|
function cdm_dataportal_view_polytomousKey($polytomousKeyUuid) {
|
1625 |
f26245c8
|
Andreas Kohlbecker
|
|
1626 |
|
|
cdm_check_valid_portal_page();
|
1627 |
|
|
|
1628 |
6657531f
|
Andreas Kohlbecker
|
$polytomousKey = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, $polytomousKeyUuid);
|
1629 |
4d9660ef
|
Andreas Kohlbecker
|
if (!$polytomousKey) {
|
1630 |
|
|
drupal_set_title(t('Polytomous key does not exist'), PASS_THROUGH);
|
1631 |
de017852
|
Andreas Kohlbecker
|
return "";
|
1632 |
4d9660ef
|
Andreas Kohlbecker
|
}
|
1633 |
6657531f
|
Andreas Kohlbecker
|
|
1634 |
|
|
$sourcePager = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, array($polytomousKeyUuid, 'sources'));
|
1635 |
|
|
if (is_array($sourcePager->records)) {
|
1636 |
|
|
$polytomousKey->sources = $sourcePager->records;
|
1637 |
|
|
// $polytomousKey->sources->citation = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, array($polytomousKeyUuid, 'sources'));
|
1638 |
|
|
}
|
1639 |
|
|
|
1640 |
|
|
$annotationPager = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, array($polytomousKeyUuid, 'annotations'));
|
1641 |
|
|
if (is_array($annotationPager->records)) {
|
1642 |
|
|
$polytomousKey->annotations = $annotationPager->records;
|
1643 |
|
|
}
|
1644 |
|
|
|
1645 |
|
|
_load_polytomousKeySubGraph($polytomousKey->root);
|
1646 |
|
|
return theme('cdm_polytomousKey_page', array('polytomousKey' => $polytomousKey));
|
1647 |
|
|
}
|
1648 |
|
|
|
1649 |
|
|
/**
|
1650 |
|
|
* Creates a taxon page view or a chapter of it.
|
1651 |
|
|
*
|
1652 |
|
|
* The taxon page gives detailed information on a taxon, it shows:
|
1653 |
|
|
* - Taxon name.
|
1654 |
|
|
* - Full list of synonyms homotypic synonyms on top, followed by the
|
1655 |
|
|
* heterotypic and finally followed by misapplied names.
|
1656 |
|
|
* The list is ordered historically.
|
1657 |
|
|
* - All description associated with the taxon.
|
1658 |
|
|
*
|
1659 |
|
|
* @param string $uuid
|
1660 |
|
|
* @param string $chapter
|
1661 |
|
|
* Name of the part to display, valid values are:
|
1662 |
|
|
* 'description', 'images', 'synonymy', 'specimens', 'all'.
|
1663 |
|
|
*
|
1664 |
793dae0a
|
Andreas Kohlbecker
|
* @return string
|
1665 |
6657531f
|
Andreas Kohlbecker
|
*/
|
1666 |
0c5a23b6
|
Andreas Kohlbecker
|
function cdm_dataportal_taxon_page_view($uuid, $chapter = 'all') {
|
1667 |
5ea8b301
|
Andreas Kohlbecker
|
|
1668 |
f26245c8
|
Andreas Kohlbecker
|
cdm_check_valid_taxon_page($chapter);
|
1669 |
2dd59bb5
|
Andreas Kohlbecker
|
cdm_dd("START OF TAXON PAGE [" . $chapter . "] " . $uuid . ' for ' . $_GET['q']);
|
1670 |
b654a866
|
Andreas Kohlbecker
|
|
1671 |
5ea8b301
|
Andreas Kohlbecker
|
|
1672 |
6657531f
|
Andreas Kohlbecker
|
// Display the page for the taxon defined by $uuid.
|
1673 |
|
|
// set_last_taxon_page_tab(arg(3));
|
1674 |
0c5a23b6
|
Andreas Kohlbecker
|
$taxonpage = cdm_dataportal_taxon_view($uuid, $chapter);
|
1675 |
6657531f
|
Andreas Kohlbecker
|
if (!empty($taxonpage)) {
|
1676 |
2dd59bb5
|
Andreas Kohlbecker
|
cdm_dd("END OF TAXON PAGE [" . $chapter . "] " . $uuid);
|
1677 |
6657531f
|
Andreas Kohlbecker
|
return cdm_node_show(NODETYPE_TAXON, $uuid, $taxonpage->title, $taxonpage->content);
|
1678 |
|
|
}
|
1679 |
|
|
else {
|
1680 |
2dd59bb5
|
Andreas Kohlbecker
|
cdm_dd("END OF TAXON PAGE [" . $chapter . "] " . $uuid . ' !!! PAGE IS EMPTY !!!');
|
1681 |
6657531f
|
Andreas Kohlbecker
|
return '';
|
1682 |
|
|
}
|
1683 |
|
|
}
|
1684 |
|
|
|
1685 |
|
|
/**
|
1686 |
43d01429
|
Andreas Kohlbecker
|
* This function will generate the taxon page part ($chapter) and returns a taxonpage object
|
1687 |
59f6da42
|
Andreas Kohlbecker
|
* which has two fields, one for the page title and one for the content. Later on in the
|
1688 |
|
|
* process chain the value contained in these fields will be passed to the cdm_node_show()
|
1689 |
|
|
* function as the function parameters $title and $content.
|
1690 |
6657531f
|
Andreas Kohlbecker
|
*
|
1691 |
|
|
* @param string $uuid
|
1692 |
59f6da42
|
Andreas Kohlbecker
|
* the uuid of the taxon to show
|
1693 |
6657531f
|
Andreas Kohlbecker
|
* @param string $chapter
|
1694 |
|
|
* Name of the part to display, valid values are:
|
1695 |
|
|
* 'description', 'images', 'synonymy', 'all'.
|
1696 |
|
|
*
|
1697 |
0c5a23b6
|
Andreas Kohlbecker
|
* @return object with the following fields:
|
1698 |
59f6da42
|
Andreas Kohlbecker
|
* - title : the title of the page
|
1699 |
|
|
* - content: the content of the page
|
1700 |
|
|
*
|
1701 |
8a1b451e
|
Andreas Kohlbecker
|
* @throws Exception
|
1702 |
|
|
*
|
1703 |
6657531f
|
Andreas Kohlbecker
|
*/
|
1704 |
8cf9238f
|
Andreas Kohlbecker
|
function cdm_dataportal_taxon_view($uuid, $chapter = 'all') {
|
1705 |
6657531f
|
Andreas Kohlbecker
|
// Taxon object.
|
1706 |
|
|
$taxon = cdm_ws_get(CDM_WS_PORTAL_TAXON, $uuid);
|
1707 |
|
|
if (empty($taxon)) {
|
1708 |
|
|
drupal_set_title(t('Taxon does not exist'), PASS_THROUGH);
|
1709 |
8a1b451e
|
Andreas Kohlbecker
|
return null;
|
1710 |
6657531f
|
Andreas Kohlbecker
|
}
|
1711 |
|
|
$taxonpage = new stdClass();
|
1712 |
|
|
|
1713 |
|
|
$taxonpage->title = theme('cdm_taxon_page_title', array(
|
1714 |
8cf9238f
|
Andreas Kohlbecker
|
'taxon' => $taxon
|
1715 |
6657531f
|
Andreas Kohlbecker
|
));
|
1716 |
|
|
|
1717 |
|
|
// Check if the taxon id contained in the currently selected tree.
|
1718 |
7663cd0b
|
Andreas Kohlbecker
|
$taxon_in_current_classification = taxon_in_current_classification($uuid);
|
1719 |
61b6ee11
|
Andreas Kohlbecker
|
|
1720 |
7663cd0b
|
Andreas Kohlbecker
|
if (!$taxon_in_current_classification) {
|
1721 |
61b6ee11
|
Andreas Kohlbecker
|
$classifications = get_classifications_for_taxon($taxon);
|
1722 |
e24d373b
|
Andreas Kohlbecker
|
RenderHints::pushToRenderStack('not_in_current_classification');
|
1723 |
|
|
$taxon_name_markup = render_taxon_or_name($taxon);
|
1724 |
|
|
|
1725 |
61b6ee11
|
Andreas Kohlbecker
|
if (count($classifications) == 0) {
|
1726 |
e24d373b
|
Andreas Kohlbecker
|
drupal_set_message(t('This concept of the taxon !taxonname is not contained as an accepted taxon in the currently chosen classification.',
|
1727 |
fba00a4f
|
Andreas Kohlbecker
|
array(
|
1728 |
e24d373b
|
Andreas Kohlbecker
|
'!taxonname' => $taxon_name_markup,
|
1729 |
fba00a4f
|
Andreas Kohlbecker
|
)
|
1730 |
|
|
), 'warning');
|
1731 |
6657531f
|
Andreas Kohlbecker
|
}
|
1732 |
|
|
else {
|
1733 |
|
|
$trees = '';
|
1734 |
61b6ee11
|
Andreas Kohlbecker
|
foreach ($classifications as $classification) {
|
1735 |
|
|
if (isset($classification->titleCache)) {
|
1736 |
|
|
$trees .= ($trees ? ', ' : '') . '<strong>' . $classification->titleCache . '</strong>';
|
1737 |
6657531f
|
Andreas Kohlbecker
|
}
|
1738 |
|
|
}
|
1739 |
|
|
|
1740 |
15b7c460
|
Andreas Kohlbecker
|
drupal_set_message(format_plural(count($trees),
|
1741 |
e24d373b
|
Andreas Kohlbecker
|
'This concept of the taxon !taxonname is not contained as an accepted taxon in the currently chosen classification, but in this one: !trees',
|
1742 |
|
|
'This concept of the taxon !taxonname is not contained as an accepted taxon in the currently chosen classification, but in one of these: !trees',
|
1743 |
|
|
array('!taxonname' => $taxon_name_markup, '!trees' => $trees)
|
1744 |
fba00a4f
|
Andreas Kohlbecker
|
) ,
|
1745 |
|
|
'warning');
|
1746 |
6657531f
|
Andreas Kohlbecker
|
}
|
1747 |
e24d373b
|
Andreas Kohlbecker
|
RenderHints::popFromRenderStack();
|
1748 |
6657531f
|
Andreas Kohlbecker
|
}
|
1749 |
|
|
|
1750 |
|
|
// Render the taxon page.
|
1751 |
9a607f17
|
Andreas Kohlbecker
|
$render_array = compose_cdm_taxon_page($taxon, $chapter);
|
1752 |
|
|
$taxonpage->content = drupal_render($render_array);
|
1753 |
6657531f
|
Andreas Kohlbecker
|
|
1754 |
|
|
return $taxonpage;
|
1755 |
|
|
}
|
1756 |
961319fe
|
Andreas Kohlbecker
|
|
1757 |
|
|
|
1758 |
6eaec849
|
Katja Luther
|
function cdm_dataportal_specimen_by_accession_number_page_view($accession_number)
|
1759 |
|
|
{
|
1760 |
961319fe
|
Andreas Kohlbecker
|
cdm_check_valid_portal_page();
|
1761 |
6eaec849
|
Katja Luther
|
|
1762 |
961319fe
|
Andreas Kohlbecker
|
$specimenpage = specimen_by_accession_number_view($accession_number);
|
1763 |
|
|
|
1764 |
|
|
if (!empty($specimenpage)) {
|
1765 |
|
|
return cdm_node_show_simulate($specimenpage->content);
|
1766 |
|
|
}
|
1767 |
|
|
else {
|
1768 |
|
|
return '';
|
1769 |
|
|
}
|
1770 |
4c812e71
|
Katja Luther
|
|
1771 |
6657531f
|
Andreas Kohlbecker
|
|
1772 |
6eaec849
|
Katja Luther
|
}
|
1773 |
961319fe
|
Andreas Kohlbecker
|
|
1774 |
9d37c9d9
|
Patric Plitzner
|
/**
|
1775 |
|
|
* Creates a specimen page view.
|
1776 |
|
|
* @param string $uuid the UUID of the specimen
|
1777 |
|
|
* @return array|string
|
1778 |
|
|
*/
|
1779 |
961319fe
|
Andreas Kohlbecker
|
function cdm_dataportal_specimen_page_view($uuid) {
|
1780 |
9d37c9d9
|
Patric Plitzner
|
|
1781 |
b654a866
|
Andreas Kohlbecker
|
cdm_check_valid_portal_page();
|
1782 |
961319fe
|
Andreas Kohlbecker
|
$specimenpage = cdm_dataportal_specimen_view($uuid);
|
1783 |
|
|
if (!empty($specimenpage)) {
|
1784 |
|
|
return cdm_node_show_simulate($specimenpage->content);
|
1785 |
|
|
}
|
1786 |
|
|
else {
|
1787 |
|
|
return '';
|
1788 |
|
|
}
|
1789 |
|
|
}
|
1790 |
4c812e71
|
Katja Luther
|
|
1791 |
|
|
|
1792 |
961319fe
|
Andreas Kohlbecker
|
/**
|
1793 |
|
|
* Creates a specimen page view.
|
1794 |
|
|
* @param string $uuid the UUID of the specimen
|
1795 |
|
|
* @return object
|
1796 |
|
|
* The page object with the following fields:
|
1797 |
|
|
* - 'title': the page title
|
1798 |
|
|
* - 'content' : the page content rendered as markup
|
1799 |
|
|
*/
|
1800 |
ff51c1cd
|
Katja Luther
|
function specimen_by_accession_number_view($accession_number = null) {
|
1801 |
961319fe
|
Andreas Kohlbecker
|
|
1802 |
|
|
$field_unit_dto = cdm_ws_get(CDM_WS_OCCURRENCE_ACCESSION_NUMBER, null, 'accessionNumber=' . $accession_number);
|
1803 |
|
|
|
1804 |
|
|
// Display the page for the specimen defined by $uuid.
|
1805 |
|
|
if (isset($field_unit_dto)){
|
1806 |
|
|
$dto_array = array($field_unit_dto);
|
1807 |
|
|
$specimen_array = specimen_render_array_items($dto_array);
|
1808 |
|
|
$specimen_table = array(
|
1809 |
|
|
'#theme' => 'table',
|
1810 |
|
|
'#weight' => 2,
|
1811 |
|
|
// prefix attributes and rows with '#' to let it pass toF the theme function,
|
1812 |
|
|
// otherwise it is handled as child render array
|
1813 |
|
|
'#attributes' => array('class' => 'specimens'),
|
1814 |
|
|
'#rows' => array(),
|
1815 |
|
|
'#prefix' => '<div id="specimens">',
|
1816 |
|
|
'#suffix' => '</div>',
|
1817 |
|
|
);
|
1818 |
|
|
foreach($specimen_array as $value){
|
1819 |
|
|
$renderArray = array(
|
1820 |
|
|
'#theme' => 'item_list',
|
1821 |
|
|
'#items' => array($value),
|
1822 |
|
|
'#type' => 'ul');
|
1823 |
|
|
$output = drupal_render($renderArray);
|
1824 |
|
|
$specimen_table['#rows'][] = array(
|
1825 |
|
|
// An array of table rows. Every row is an array of cells, or an associative array
|
1826 |
|
|
'data' => array($output),
|
1827 |
|
|
'class' => array(
|
1828 |
|
|
'descriptionElement',
|
1829 |
|
|
'descriptionElement_IndividualsAssociation'
|
1830 |
|
|
),
|
1831 |
|
|
);
|
1832 |
4c812e71
|
Katja Luther
|
|
1833 |
|
|
|
1834 |
961319fe
|
Andreas Kohlbecker
|
}
|
1835 |
|
|
$specimenpage = new stdClass();
|
1836 |
4c812e71
|
Katja Luther
|
|
1837 |
961319fe
|
Andreas Kohlbecker
|
$specimenpage->title = theme('theme_cdm_specimen_dto_page_title', array(
|
1838 |
|
|
'specimen' => $field_unit_dto
|
1839 |
|
|
));
|
1840 |
4c812e71
|
Katja Luther
|
|
1841 |
ff51c1cd
|
Katja Luther
|
$render_array['markup'] = $specimen_table;
|
1842 |
|
|
$specimenpage->content = drupal_render($render_array);
|
1843 |
961319fe
|
Andreas Kohlbecker
|
}
|
1844 |
4c812e71
|
Katja Luther
|
|
1845 |
961319fe
|
Andreas Kohlbecker
|
return $specimenpage;
|
1846 |
9d37c9d9
|
Patric Plitzner
|
}
|
1847 |
|
|
|
1848 |
961319fe
|
Andreas Kohlbecker
|
|
1849 |
9d37c9d9
|
Patric Plitzner
|
/**
|
1850 |
|
|
*
|
1851 |
|
|
* Creates a specimen view.
|
1852 |
|
|
* @param string $uuid the UUID of the specimen
|
1853 |
961319fe
|
Andreas Kohlbecker
|
* @return object
|
1854 |
|
|
* Page object with the fields
|
1855 |
|
|
* - title
|
1856 |
|
|
* - content
|
1857 |
9d37c9d9
|
Patric Plitzner
|
*/
|
1858 |
|
|
function cdm_dataportal_specimen_view($uuid) {
|
1859 |
a2acff0a
|
Katja Luther
|
//TODO: get the derivateDTO and don't call the webservice a second time in compose_cdm_specimen_page
|
1860 |
907cc9b4
|
Patrick Plitzner
|
$specimen = cdm_ws_get(CDM_WS_PORTAL_OCCURRENCE, $uuid);
|
1861 |
9d37c9d9
|
Patric Plitzner
|
if (empty($specimen)) {
|
1862 |
|
|
drupal_set_title(t('Specimen does not exist'), PASS_THROUGH);
|
1863 |
|
|
return FALSE;
|
1864 |
|
|
}
|
1865 |
|
|
$specimenpage = new stdClass();
|
1866 |
|
|
|
1867 |
961319fe
|
Andreas Kohlbecker
|
$specimenpage->title = specimen_page_title($specimen);
|
1868 |
9d37c9d9
|
Patric Plitzner
|
|
1869 |
b810158e
|
Patric Plitzner
|
// Render the specimen page.
|
1870 |
a2acff0a
|
Katja Luther
|
$render_array = compose_cdm_specimen_page($specimen);
|
1871 |
9d37c9d9
|
Patric Plitzner
|
$specimenpage->content = drupal_render($render_array);
|
1872 |
|
|
|
1873 |
|
|
return $specimenpage;
|
1874 |
|
|
}
|
1875 |
|
|
|
1876 |
e170a53e
|
Patrick Plitzner
|
/**
|
1877 |
|
|
*
|
1878 |
|
|
* Creates a description view.
|
1879 |
ea0ae3c7
|
Patrick Plitzner
|
*
|
1880 |
e170a53e
|
Patrick Plitzner
|
* @param string $uuid the UUID of the description
|
1881 |
ea0ae3c7
|
Patrick Plitzner
|
* @param null $descriptive_dataset_uuid the uuid of the data set which defines
|
1882 |
|
|
* the display of the description detail page
|
1883 |
|
|
*
|
1884 |
|
|
* @return object Page object with the fields
|
1885 |
|
|
* Page object with the fields
|
1886 |
|
|
* - title
|
1887 |
|
|
* - content
|
1888 |
e170a53e
|
Patrick Plitzner
|
*/
|
1889 |
ea0ae3c7
|
Patrick Plitzner
|
function cdm_dataportal_description_view($uuid, $descriptive_dataset_uuid = NULL) {
|
1890 |
e170a53e
|
Patrick Plitzner
|
$description = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION, $uuid);
|
1891 |
de017852
|
Andreas Kohlbecker
|
$description_page = new stdClass();
|
1892 |
e170a53e
|
Patrick Plitzner
|
if (empty($description)) {
|
1893 |
de017852
|
Andreas Kohlbecker
|
$description_page->title = t('Description does not exist');
|
1894 |
|
|
drupal_set_title($description_page->title, PASS_THROUGH); // not necessary if correctly implemented as drupal node
|
1895 |
|
|
$description_page->content = "";
|
1896 |
e170a53e
|
Patrick Plitzner
|
|
1897 |
de017852
|
Andreas Kohlbecker
|
} else {
|
1898 |
|
|
$description_page->title = $description->titleCache;
|
1899 |
|
|
drupal_set_title($description_page->title); // not necessary if correctly implemented as drupal node
|
1900 |
e170a53e
|
Patrick Plitzner
|
|
1901 |
de017852
|
Andreas Kohlbecker
|
// Render the description page.
|
1902 |
fec3fd41
|
Andreas Kohlbecker
|
$render_array = compose_description_table($description->uuid, $descriptive_dataset_uuid);
|
1903 |
20bfe15b
|
Andreas Kohlbecker
|
if($render_array['title']){
|
1904 |
|
|
$page_title = strip_tags($render_array['title']['#markup']);
|
1905 |
|
|
drupal_set_title($page_title);
|
1906 |
|
|
unset($render_array['title']);
|
1907 |
|
|
}
|
1908 |
de017852
|
Andreas Kohlbecker
|
$description_page->content = drupal_render($render_array);
|
1909 |
|
|
}
|
1910 |
e170a53e
|
Patrick Plitzner
|
|
1911 |
de017852
|
Andreas Kohlbecker
|
return $description_page;
|
1912 |
e170a53e
|
Patrick Plitzner
|
}
|
1913 |
|
|
|
1914 |
ea0ae3c7
|
Patrick Plitzner
|
function cdm_dataportal_description_page_view($uuid, $descriptive_dataset_uuid = NULL) {
|
1915 |
e170a53e
|
Patrick Plitzner
|
|
1916 |
|
|
cdm_check_valid_portal_page();
|
1917 |
ea0ae3c7
|
Patrick Plitzner
|
$descriptionpage = cdm_dataportal_description_view($uuid, $descriptive_dataset_uuid);
|
1918 |
e170a53e
|
Patrick Plitzner
|
if (!empty($descriptionpage)) {
|
1919 |
|
|
return cdm_node_show_simulate($descriptionpage->content);
|
1920 |
|
|
}
|
1921 |
|
|
else {
|
1922 |
de017852
|
Andreas Kohlbecker
|
return NULL;
|
1923 |
e170a53e
|
Patrick Plitzner
|
}
|
1924 |
|
|
}
|
1925 |
|
|
|
1926 |
30845bda
|
Andreas Kohlbecker
|
/**
|
1927 |
|
|
*
|
1928 |
|
|
* Creates a named area view.
|
1929 |
|
|
* @param string $uuid the UUID of the specimen
|
1930 |
|
|
* * @return object
|
1931 |
|
|
* An object with two fields:
|
1932 |
|
|
* - title: the page title
|
1933 |
|
|
* - content: the page content
|
1934 |
|
|
*/
|
1935 |
|
|
|
1936 |
|
|
function cdm_dataportal_named_area_view($uuid) {
|
1937 |
|
|
$named_area = cdm_ws_get(CDM_WS_PORTAL_TERM, $uuid);
|
1938 |
|
|
if (empty($named_area) || $named_area->class !== 'NamedArea') {
|
1939 |
|
|
drupal_set_title(t('Named area does not exist'), PASS_THROUGH);
|
1940 |
4d9660ef
|
Andreas Kohlbecker
|
return null;
|
1941 |
30845bda
|
Andreas Kohlbecker
|
}
|
1942 |
|
|
$named_area_page = new stdClass();
|
1943 |
|
|
|
1944 |
|
|
$named_area_page->title = $named_area->representation_L10n;
|
1945 |
|
|
|
1946 |
|
|
// Render the specimen page.
|
1947 |
|
|
$render_array = compose_cdm_named_area_page($uuid);
|
1948 |
|
|
$named_area_page->content = drupal_render($render_array);
|
1949 |
|
|
|
1950 |
|
|
return $named_area_page;
|
1951 |
|
|
}
|
1952 |
|
|
|
1953 |
|
|
function cdm_dataportal_named_area_page_view($uuid) {
|
1954 |
|
|
|
1955 |
|
|
cdm_check_valid_portal_page();
|
1956 |
|
|
|
1957 |
|
|
$named_area_page = cdm_dataportal_named_area_view($uuid);
|
1958 |
|
|
if (!empty($named_area_page)) {
|
1959 |
|
|
return cdm_node_show(NODETYPE_NAME, $uuid, $named_area_page->title, $named_area_page->content);
|
1960 |
|
|
}
|
1961 |
|
|
else {
|
1962 |
|
|
return '';
|
1963 |
|
|
}
|
1964 |
|
|
|
1965 |
|
|
|
1966 |
|
|
}
|
1967 |
|
|
|
1968 |
6657531f
|
Andreas Kohlbecker
|
/**
|
1969 |
|
|
* Returns a name page as a Drupal node ready to be renderized by Drupal.
|
1970 |
|
|
*
|
1971 |
|
|
* The node page shows the taxon name title and the list of taxon related
|
1972 |
|
|
* with such taxon. Name on the tree already in use.
|
1973 |
|
|
*
|
1974 |
d4ea0dd9
|
Andreas Kohlbecker
|
* @param string $taxon_name_uuid
|
1975 |
102f8c26
|
Andreas Kohlbecker
|
* The uuid of the CDM TaxonName to show a name page for
|
1976 |
d4ea0dd9
|
Andreas Kohlbecker
|
* @param string $taxon_to_hide_uuid
|
1977 |
51b04faf
|
Andreas Kohlbecker
|
* A taxon which should not be displayed in the taxon list
|
1978 |
2f65af04
|
Andreas Kohlbecker
|
* @param $redirect_to_taxon
|
1979 |
|
|
* Automatically redirect to the related taxon if there is only one
|
1980 |
|
|
* accepted taxon for this name.
|
1981 |
d4ea0dd9
|
Andreas Kohlbecker
|
* @param string $highlite_synonym_uuid
|
1982 |
51b04faf
|
Andreas Kohlbecker
|
* Optinal parameter wich takes another taxon uuid, if given the
|
1983 |
|
|
* target taxon pages will show the syonymy tab where the taxon
|
1984 |
|
|
* refenrenced by the $highlite_synonym_uuid will be highlighted
|
1985 |
|
|
* in case it is found on this page.
|
1986 |
6657531f
|
Andreas Kohlbecker
|
*
|
1987 |
|
|
* @return mixed
|
1988 |
|
|
* The formatted name page as node.
|
1989 |
|
|
*/
|
1990 |
b648739e
|
Andreas Kohlbecker
|
function cdm_dataportal_name_page_view($taxon_name_uuid, $taxon_to_hide_uuid, $synonym_uuid = NULL, $redirect_to_taxon = false) {
|
1991 |
6657531f
|
Andreas Kohlbecker
|
|
1992 |
f26245c8
|
Andreas Kohlbecker
|
cdm_check_valid_portal_page();
|
1993 |
|
|
|
1994 |
b648739e
|
Andreas Kohlbecker
|
$taxonname_page = cdm_dataportal_name_view(
|
1995 |
|
|
is_uuid($taxon_name_uuid) ? $taxon_name_uuid : null,
|
1996 |
|
|
is_uuid($taxon_to_hide_uuid) ? $taxon_to_hide_uuid : null,
|
1997 |
|
|
$redirect_to_taxon == 'redirect_to_taxon',
|
1998 |
|
|
is_uuid($synonym_uuid) ? $synonym_uuid : null);
|
1999 |
6657531f
|
Andreas Kohlbecker
|
if (!empty($taxonname_page)) {
|
2000 |
|
|
return cdm_node_show(NODETYPE_NAME, $taxon_name_uuid, $taxonname_page->title, $taxonname_page->content);
|
2001 |
|
|
}
|
2002 |
|
|
else {
|
2003 |
|
|
return '';
|
2004 |
|
|
}
|
2005 |
|
|
}
|
2006 |
|
|
|
2007 |
|
|
/**
|
2008 |
102f8c26
|
Andreas Kohlbecker
|
* View function for a TaxonName page.
|
2009 |
6657531f
|
Andreas Kohlbecker
|
*
|
2010 |
e3001c8d
|
Andreas Kohlbecker
|
* The name page lists all taxa for which the name specified by the
|
2011 |
|
|
* $taxon_name_uuid is being used. I case there is only one name the
|
2012 |
|
|
* page automatically redirects ti the according taxon page. Otherwise
|
2013 |
|
|
* the list of names is displayed.
|
2014 |
6657531f
|
Andreas Kohlbecker
|
*
|
2015 |
e3001c8d
|
Andreas Kohlbecker
|
* The parameter $taxon_to_hide_uuid allows to exclude a taxon from the
|
2016 |
|
|
* list of taxa. This is useful for example when referencing from a taxon
|
2017 |
|
|
* to the name page and the referring taxon should not be repeaded in the
|
2018 |
|
|
* name page.
|
2019 |
6657531f
|
Andreas Kohlbecker
|
*
|
2020 |
e3001c8d
|
Andreas Kohlbecker
|
*
|
2021 |
d4ea0dd9
|
Andreas Kohlbecker
|
* @param string $taxon_name_uuid
|
2022 |
102f8c26
|
Andreas Kohlbecker
|
* The uuid of the CDM TaxonName to show a name page for
|
2023 |
d4ea0dd9
|
Andreas Kohlbecker
|
* @param string $taxon_to_hide_uuid
|
2024 |
e3001c8d
|
Andreas Kohlbecker
|
* A taxon which should not be displayed in the taxon list
|
2025 |
2f65af04
|
Andreas Kohlbecker
|
* @param $redirect_to_taxon
|
2026 |
|
|
* Automatically redirect to the related taxon if there is only one
|
2027 |
|
|
* accepted taxon for this name.
|
2028 |
d4ea0dd9
|
Andreas Kohlbecker
|
* @param string $highlite_synonym_uuid
|
2029 |
2f65af04
|
Andreas Kohlbecker
|
* Optional parameter which takes another taxon uuid, if given the
|
2030 |
|
|
* target taxon pages will show the synonymy tab where the taxon
|
2031 |
|
|
* referenced by the $highlite_synonym_uuid will be highlighted
|
2032 |
e3001c8d
|
Andreas Kohlbecker
|
* in case it is found on this page.
|
2033 |
|
|
*
|
2034 |
2f65af04
|
Andreas Kohlbecker
|
* @return object|boolean
|
2035 |
e3001c8d
|
Andreas Kohlbecker
|
* An object with two fields:
|
2036 |
|
|
* - title: the page title
|
2037 |
|
|
* - content: the page content
|
2038 |
2f65af04
|
Andreas Kohlbecker
|
* or FALSE
|
2039 |
|
|
*
|
2040 |
6657531f
|
Andreas Kohlbecker
|
*/
|
2041 |
2f65af04
|
Andreas Kohlbecker
|
function cdm_dataportal_name_view($taxon_name_uuid, $taxon_to_hide_uuid, $redirect_to_taxon, $highlite_synonym_uuid = NULL) {
|
2042 |
6657531f
|
Andreas Kohlbecker
|
// Getting the full taxonname object from the server.
|
2043 |
d0d068e9
|
Andreas Kohlbecker
|
$taxon_name = cdm_ws_get(CDM_WS_PORTAL_NAME, array($taxon_name_uuid));
|
2044 |
6657531f
|
Andreas Kohlbecker
|
if (!$taxon_name) {
|
2045 |
|
|
drupal_set_title(t('Taxon name does not exist'), PASS_THROUGH);
|
2046 |
|
|
return FALSE;
|
2047 |
|
|
}
|
2048 |
a7560a18
|
Andreas Kohlbecker
|
cdm_load_tagged_full_title($taxon_name);
|
2049 |
6657531f
|
Andreas Kohlbecker
|
// Searching for all the taxa connected with the taxon name on the tree
|
2050 |
|
|
// in use.
|
2051 |
fb308159
|
Andreas Kohlbecker
|
$name = cdm_ws_get(CDM_WS_NAME, array($taxon_name_uuid));
|
2052 |
|
|
$restrictions = array(new Restriction("name.titleCache","EXACT", array($name->titleCache), 'AND'));
|
2053 |
|
|
$init_strategy = array(
|
2054 |
|
|
"name.titleCache",
|
2055 |
|
|
"name.nomenclaturalReference.authorship",
|
2056 |
|
|
"name.nomenclaturalReference.inReference.authorship",
|
2057 |
|
|
"name.nomenclaturalReference.inReference.inReference.authorship",
|
2058 |
|
|
"name.nomenclaturalReference.inReference.inReference.inReference.authorship"
|
2059 |
|
|
);
|
2060 |
e2617c7e
|
Andreas Kohlbecker
|
$taxa = cdm_ws_fetch_all_by_restriction("Taxon", NULL, $restrictions, $init_strategy);
|
2061 |
6657531f
|
Andreas Kohlbecker
|
|
2062 |
d0d068e9
|
Andreas Kohlbecker
|
// Removing the name where we came from.
|
2063 |
fb308159
|
Andreas Kohlbecker
|
foreach ($taxa as $k => &$taxon) {
|
2064 |
6657531f
|
Andreas Kohlbecker
|
if ($taxon->uuid == $taxon_to_hide_uuid) {
|
2065 |
fb308159
|
Andreas Kohlbecker
|
unset($taxa[$k]);
|
2066 |
6657531f
|
Andreas Kohlbecker
|
}
|
2067 |
|
|
}
|
2068 |
|
|
// Show the taxa list or go to the singular taxon.
|
2069 |
fb308159
|
Andreas Kohlbecker
|
if (sizeof($taxa) == 1 && $redirect_to_taxon) {
|
2070 |
2f65af04
|
Andreas Kohlbecker
|
// redirect to the taxon if there is only one.
|
2071 |
fb308159
|
Andreas Kohlbecker
|
$singleTaxon = array_pop($taxa);
|
2072 |
6657531f
|
Andreas Kohlbecker
|
if ($singleTaxon->class != "Taxon") {
|
2073 |
|
|
// It is a Synonym -> look for the accepted.
|
2074 |
7635cc7d
|
Andreas Kohlbecker
|
$accepted_taxon = cdm_ws_get(CDM_WS_PORTAL_TAXON_ACCEPTED, array($singleTaxon->uuid), 'classificationFilter=' . get_current_classification_uuid());
|
2075 |
e3001c8d
|
Andreas Kohlbecker
|
if (!empty($highlite_synonym_uuid)) {
|
2076 |
7635cc7d
|
Andreas Kohlbecker
|
drupal_goto('cdm_dataportal/taxon/' . $accepted_taxon->uuid . '/synonymy', array('query' => array('highlite' => $highlite_synonym_uuid)));
|
2077 |
6657531f
|
Andreas Kohlbecker
|
}
|
2078 |
|
|
else {
|
2079 |
7635cc7d
|
Andreas Kohlbecker
|
drupal_goto('cdm_dataportal/taxon/' . $accepted_taxon->uuid . '/synonymy', array('query' => array('highlite' => $singleTaxon->uuid)));
|
2080 |
6657531f
|
Andreas Kohlbecker
|
}
|
2081 |
|
|
}
|
2082 |
|
|
else {
|
2083 |
|
|
// It is an accepted taxon.
|
2084 |
e3001c8d
|
Andreas Kohlbecker
|
if (!empty($highlite_synonym_uuid)) {
|
2085 |
|
|
drupal_goto('cdm_dataportal/taxon/' . $singleTaxon->uuid . '/synonymy', array('query' => array('highlite' => $highlite_synonym_uuid)));
|
2086 |
6657531f
|
Andreas Kohlbecker
|
}
|
2087 |
|
|
else {
|
2088 |
|
|
drupal_goto('cdm_dataportal/taxon/' . $singleTaxon->uuid);
|
2089 |
|
|
}
|
2090 |
|
|
}
|
2091 |
|
|
}
|
2092 |
2f65af04
|
Andreas Kohlbecker
|
else {
|
2093 |
|
|
// display the name page content
|
2094 |
6657531f
|
Andreas Kohlbecker
|
$taxon_name_page = new stdClass();
|
2095 |
4f225a0f
|
Andreas Kohlbecker
|
$taxon_name_page->title = theme('cdm_name_page_title', array('taxon_name' => $taxon_name));
|
2096 |
2f65af04
|
Andreas Kohlbecker
|
$content = array();
|
2097 |
|
|
|
2098 |
a7560a18
|
Andreas Kohlbecker
|
RenderHints::pushToRenderStack('name_page');
|
2099 |
222784c5
|
Andreas Kohlbecker
|
RenderHints::setFootnoteListKey('name_page');
|
2100 |
c040bba0
|
Andreas Kohlbecker
|
$content['taxon_name'] = markup_to_render_array(render_taxon_or_name($taxon_name), null, '<div class="name-page-name">', '</div>');
|
2101 |
d64f1d61
|
Andreas Kohlbecker
|
|
2102 |
a7560a18
|
Andreas Kohlbecker
|
|
2103 |
2f65af04
|
Andreas Kohlbecker
|
// name relationships
|
2104 |
d64f1d61
|
Andreas Kohlbecker
|
$name_relations = cdm_ws_fetch_all(str_replace("$0", $taxon_name->uuid, CDM_WS_PORTAL_NAME_NAME_RELATIONS));
|
2105 |
|
|
if(count($name_relations) > 0){
|
2106 |
|
|
$content['name_relationships'] = compose_name_relationships_list($name_relations, $taxon_name->uuid, null);
|
2107 |
|
|
}
|
2108 |
14076b88
|
Andreas Kohlbecker
|
|
2109 |
a9a04561
|
Andreas Kohlbecker
|
// type designations
|
2110 |
a44d210c
|
Andreas Kohlbecker
|
$type_designations_render_array = compose_type_designations($taxon_name->uuid);
|
2111 |
ae177dac
|
Andreas Kohlbecker
|
$content = array_merge($content, $type_designations_render_array);
|
2112 |
efff6ee1
|
Andreas Kohlbecker
|
// registrations
|
2113 |
|
|
$registrationDTOs= cdm_ws_fetch_all(CDM_WS_REGISTRATION_DTO, array('nameUuid' => $taxon_name_uuid));
|
2114 |
|
|
if(isset($registrationDTOs) && count($registrationDTOs ) > 0 ){
|
2115 |
|
|
$content['registrations'][] = markup_to_render_array('<h2>' . t("Registrations") . '</h2>') ;
|
2116 |
|
|
foreach ($registrationDTOs as $regDTO){
|
2117 |
|
|
$content['registrations'][] = compose_registration_dto_compact($regDTO);
|
2118 |
|
|
}
|
2119 |
|
|
}
|
2120 |
|
|
|
2121 |
|
|
|
2122 |
2f65af04
|
Andreas Kohlbecker
|
// related taxa
|
2123 |
c05ac190
|
Andreas Kohlbecker
|
$show_taxa_section = variable_get(CDM_NAME_PAGE_SECTION_TAXA, CDM_NAME_PAGE_SECTION_TAXA_DEFAULT);
|
2124 |
|
|
if($show_taxa_section){
|
2125 |
|
|
if ($taxa) {
|
2126 |
|
|
$content['related_taxa_header'] = markup_to_render_array("<h2>Taxa for this name</h2>");
|
2127 |
|
|
$content['related_taxa'] = compose_list_of_taxa($taxa);
|
2128 |
|
|
}
|
2129 |
|
|
else {
|
2130 |
|
|
$content['related_taxa'] = markup_to_render_array('This name is not assigned to a taxon.', null, '<div class="no-taxon-message">', '</div>');
|
2131 |
|
|
}
|
2132 |
6657531f
|
Andreas Kohlbecker
|
}
|
2133 |
a7560a18
|
Andreas Kohlbecker
|
|
2134 |
deb2fc24
|
Andreas Kohlbecker
|
$content['footnotes'] = markup_to_render_array(theme('cdm_footnotes', array('footnoteListKey' => RenderHints::getFootnoteListKey())));
|
2135 |
|
|
|
2136 |
2f65af04
|
Andreas Kohlbecker
|
$taxon_name_page->content = $content;
|
2137 |
a7560a18
|
Andreas Kohlbecker
|
RenderHints::popFromRenderStack();
|
2138 |
222784c5
|
Andreas Kohlbecker
|
RenderHints::clearFootnoteListKey();
|
2139 |
6657531f
|
Andreas Kohlbecker
|
return $taxon_name_page;
|
2140 |
|
|
}
|
2141 |
|
|
}
|
2142 |
|
|
|
2143 |
a9a04561
|
Andreas Kohlbecker
|
|
2144 |
e0d3e148
|
Andreas Kohlbecker
|
/**
|
2145 |
|
|
* Returns a registration page as a Drupal node to be rendered by Drupal.
|
2146 |
|
|
*
|
2147 |
|
|
* @param string $registration_identifier_encoded
|
2148 |
|
|
* The persistent identifier of the registration urlencoded.
|
2149 |
|
|
* @return mixed
|
2150 |
|
|
* The formatted registration page as node.
|
2151 |
|
|
*/
|
2152 |
|
|
function cdm_dataportal_registration_page_view($registration_identifier_encoded) {
|
2153 |
|
|
|
2154 |
|
|
cdm_check_valid_portal_page("/\/cdm_dataportal\/registration\/.*$/");
|
2155 |
|
|
$registration_page = cdm_dataportal_registration_view($registration_identifier_encoded);
|
2156 |
|
|
return cdm_node_show_simulate($registration_page);
|
2157 |
|
|
}
|
2158 |
|
|
|
2159 |
961319fe
|
Andreas Kohlbecker
|
/**
|
2160 |
|
|
* @param $registration_identifier_encoded
|
2161 |
|
|
* @return array
|
2162 |
|
|
* The drupal render array for the registration view.
|
2163 |
|
|
*/
|
2164 |
e0d3e148
|
Andreas Kohlbecker
|
function cdm_dataportal_registration_view($registration_identifier_encoded) {
|
2165 |
|
|
|
2166 |
|
|
$registration_identifier = urldecode($registration_identifier_encoded);
|
2167 |
|
|
|
2168 |
a7560a18
|
Andreas Kohlbecker
|
RenderHints::pushToRenderStack('registration_page');
|
2169 |
222784c5
|
Andreas Kohlbecker
|
RenderHints::setFootnoteListKey('registration_page');
|
2170 |
a7560a18
|
Andreas Kohlbecker
|
|
2171 |
6cbefddc
|
Andreas Kohlbecker
|
$render_array = array();
|
2172 |
1e7459da
|
Andreas Kohlbecker
|
$registration_dto = cdm_ws_get(CDM_WS_REGISTRATION_DTO_BY_IDENTIFIER . $registration_identifier_encoded);
|
2173 |
e0d3e148
|
Andreas Kohlbecker
|
if($registration_dto){
|
2174 |
|
|
|
2175 |
a7560a18
|
Andreas Kohlbecker
|
drupal_set_title(t('Registration Id:') . ' ' . $registration_identifier, PASS_THROUGH);
|
2176 |
26b8a1bc
|
Andreas Kohlbecker
|
$render_array = compose_registration_dto_full($registration_dto, true);
|
2177 |
e0d3e148
|
Andreas Kohlbecker
|
|
2178 |
|
|
} else {
|
2179 |
1e7459da
|
Andreas Kohlbecker
|
$status_text = cdm_ws_get(CDM_WS_REGISTRATION_STATUS_BY_IDENTIFIER, array($registration_identifier));
|
2180 |
6c9d417d
|
Andreas Kohlbecker
|
if(isset($status_text->String)) {
|
2181 |
1e7459da
|
Andreas Kohlbecker
|
$status_text = strtolower($status_text->String);
|
2182 |
|
|
if($status_text == 'preparation' || $status_text == 'curation'){
|
2183 |
|
|
$status_text = 'in ' . $status_text;
|
2184 |
|
|
}
|
2185 |
|
|
drupal_set_title(t('Registration ' . $status_text), PASS_THROUGH);
|
2186 |
|
|
//$status_message;
|
2187 |
5fdcad30
|
Andreas Kohlbecker
|
drupal_set_message("A registration with the identifier " . $registration_identifier . " is " . $status_text, "status");
|
2188 |
1e7459da
|
Andreas Kohlbecker
|
} else {
|
2189 |
|
|
drupal_set_title(t('Registration not found'), PASS_THROUGH);
|
2190 |
e42db5b0
|
Andreas Kohlbecker
|
drupal_set_message("A registration with the identifier " . $registration_identifier . " does not exist", "warning");
|
2191 |
1e7459da
|
Andreas Kohlbecker
|
}
|
2192 |
e0d3e148
|
Andreas Kohlbecker
|
}
|
2193 |
|
|
|
2194 |
5446f047
|
Andreas Kohlbecker
|
$render_array = array(
|
2195 |
5fdcad30
|
Andreas Kohlbecker
|
'#prefix' => '<div id="registration">',
|
2196 |
5446f047
|
Andreas Kohlbecker
|
'registration' => $render_array,
|
2197 |
|
|
'#suffix' => '</div>',
|
2198 |
|
|
);
|
2199 |
|
|
|
2200 |
a7560a18
|
Andreas Kohlbecker
|
RenderHints::popFromRenderStack();
|
2201 |
222784c5
|
Andreas Kohlbecker
|
RenderHints::clearFootnoteListKey();
|
2202 |
a7560a18
|
Andreas Kohlbecker
|
|
2203 |
e0d3e148
|
Andreas Kohlbecker
|
return $render_array ;
|
2204 |
|
|
}
|
2205 |
|
|
|
2206 |
|
|
|
2207 |
6657531f
|
Andreas Kohlbecker
|
/**
|
2208 |
84b13813
|
Andreas Kohlbecker
|
* Creates a page with the advance search form.
|
2209 |
|
|
*
|
2210 |
|
|
* NOTE: The advance search form allows searching for taxa.
|
2211 |
6657531f
|
Andreas Kohlbecker
|
*/
|
2212 |
2f30124c
|
Andreas Kohlbecker
|
function cdm_dataportal_view_search_advanced() {
|
2213 |
6657531f
|
Andreas Kohlbecker
|
drupal_set_title(t('Advanced search'), PASS_THROUGH);
|
2214 |
|
|
return drupal_get_form('cdm_dataportal_search_taxon_form_advanced');
|
2215 |
|
|
}
|
2216 |
|
|
|
2217 |
a1ce57ce
|
Katja Luther
|
/**
|
2218 |
|
|
* Creates a page with the blast search form.
|
2219 |
|
|
*
|
2220 |
|
|
* NOTE: The advance search form allows searching for specimen in blast DB.
|
2221 |
|
|
*/
|
2222 |
|
|
function cdm_dataportal_view_search_blast() {
|
2223 |
|
|
drupal_set_title(t('Blast search'), PASS_THROUGH);
|
2224 |
|
|
return drupal_get_form('cdm_dataportal_search_blast_form');
|
2225 |
|
|
}
|
2226 |
|
|
|
2227 |
6657531f
|
Andreas Kohlbecker
|
/**
|
2228 |
84b13813
|
Andreas Kohlbecker
|
* Creates a page with the search form for searching by taxon descriptions.
|
2229 |
6657531f
|
Andreas Kohlbecker
|
*/
|
2230 |
|
|
function cdm_dataportal_view_search_taxon_by_description() {
|
2231 |
6441ddfb
|
Andreas Kohlbecker
|
drupal_set_title(t('Search by factual data'), PASS_THROUGH);
|
2232 |
6657531f
|
Andreas Kohlbecker
|
return drupal_get_form('cdm_dataportal_search_taxon_by_description_form');
|
2233 |
|
|
}
|
2234 |
|
|
|
2235 |
|
|
/**
|
2236 |
|
|
* Executes the search and generates the result list of taxa.
|
2237 |
|
|
*/
|
2238 |
|
|
function cdm_dataportal_view_search_results_taxon() {
|
2239 |
|
|
|
2240 |
24797d7f
|
Andreas Kohlbecker
|
$taxonPager = cdm_dataportal_search_taxon_execute();
|
2241 |
6657531f
|
Andreas Kohlbecker
|
|
2242 |
f19f47fa
|
Andreas Kohlbecker
|
$showThumbnails = do_showThumbnails();
|
2243 |
|
|
|
2244 |
|
|
$setSessionUri = url('cdm_api/setvalue/session', array(
|
2245 |
|
|
'query' => array('var' => '[pageoption][searchtaxa][showThumbnails]', 'val' => ''),
|
2246 |
|
|
));
|
2247 |
|
|
|
2248 |
|
|
drupal_add_js('jQuery(document).ready(function() {
|
2249 |
|
|
|
2250 |
|
|
// init
|
2251 |
|
|
if(' . $showThumbnails . ' == 1){
|
2252 |
1d69a96c
|
Andreas Kohlbecker
|
jQuery(\'.media_gallery\').show(20);
|
2253 |
|
|
} else {
|
2254 |
|
|
jQuery(\'.media_gallery\').hide(20);
|
2255 |
|
|
}
|
2256 |
|
|
|
2257 |
|
|
// add change handler
|
2258 |
|
|
jQuery(\'#showThumbnails input.showThumbnails\').change(
|
2259 |
f19f47fa
|
Andreas Kohlbecker
|
function(event){
|
2260 |
1d69a96c
|
Andreas Kohlbecker
|
var state = 0;
|
2261 |
|
|
if(jQuery(this).is(\':checked\')){
|
2262 |
|
|
jQuery(\'.media_gallery\').show(20);
|
2263 |
|
|
state = 1;
|
2264 |
|
|
} else {
|
2265 |
|
|
jQuery(\'.media_gallery\').hide(20);
|
2266 |
|
|
}
|
2267 |
|
|
// store state in session variable
|
2268 |
|
|
var uri = \'' . $setSessionUri . '\' + state;
|
2269 |
|
|
jQuery.get(uri);
|
2270 |
|
|
});
|
2271 |
78e178e2
|
Andreas Kohlbecker
|
});',
|
2272 |
f19f47fa
|
Andreas Kohlbecker
|
array('type' => "inline", 'scope' => JS_DEFAULT));
|
2273 |
|
|
|
2274 |
78e178e2
|
Andreas Kohlbecker
|
drupal_set_title(t('Search results'), PASS_THROUGH);
|
2275 |
|
|
|
2276 |
0a1dc066
|
Andreas Kohlbecker
|
return theme('cdm_search_taxa_results', array(
|
2277 |
6657531f
|
Andreas Kohlbecker
|
'pager' => $taxonPager,
|
2278 |
|
|
'path' => 'cdm_dataportal/search/results/taxon',
|
2279 |
|
|
));
|
2280 |
|
|
}
|
2281 |
|
|
|
2282 |
a1ce57ce
|
Katja Luther
|
/**
|
2283 |
|
|
* Executes the blast search and generates the result list of specimen.
|
2284 |
|
|
*/
|
2285 |
|
|
function cdm_dataportal_view_search_results_specimen() {
|
2286 |
|
|
|
2287 |
|
|
$specimenPager = cdm_dataportal_search_blast_execute();
|
2288 |
|
|
|
2289 |
|
|
return theme('cdm_search_specimen_results', array(
|
2290 |
|
|
'pager' => $specimenPager,
|
2291 |
|
|
'path' => 'cdm_dataportal/search/results/specimen',
|
2292 |
|
|
));
|
2293 |
|
|
}
|
2294 |
|
|
|
2295 |
|
|
|
2296 |
a6ae799b
|
Andreas Kohlbecker
|
/**
|
2297 |
|
|
* Executes the search for registrations and generates the result list..
|
2298 |
|
|
*/
|
2299 |
efbff4b3
|
Andreas Kohlbecker
|
function cdm_dataportal_view_search_registrations_results($mode = 'filter') {
|
2300 |
|
|
|
2301 |
|
|
switch($mode ){
|
2302 |
|
|
case 'taxongraph':
|
2303 |
|
|
$block = block_load('cdm_dataportal', 'registrations_search_taxongraph');
|
2304 |
|
|
$registration_pager = cdm_dataportal_search_registrations_taxongraph_execute();
|
2305 |
|
|
break;
|
2306 |
|
|
case 'filter':
|
2307 |
|
|
default:
|
2308 |
|
|
$block = block_load('cdm_dataportal', 'registrations_search_filter');
|
2309 |
|
|
$registration_pager = cdm_dataportal_search_registrations_filter_execute();
|
2310 |
|
|
}
|
2311 |
|
|
$block->title = null;
|
2312 |
a6ae799b
|
Andreas Kohlbecker
|
|
2313 |
|
|
drupal_set_title(t('Search registrations'), PASS_THROUGH);
|
2314 |
|
|
|
2315 |
efbff4b3
|
Andreas Kohlbecker
|
$render_array = _block_get_renderable_array(_block_render_blocks(array($block)));
|
2316 |
e2617c7e
|
Andreas Kohlbecker
|
$registrations_pager_array = compose_search_results($registration_pager, new RegistrationDTOComposeHandler());
|
2317 |
a6ae799b
|
Andreas Kohlbecker
|
$render_array = array_merge($render_array, $registrations_pager_array);
|
2318 |
|
|
|
2319 |
|
|
return $render_array;
|
2320 |
|
|
}
|
2321 |
|
|
|
2322 |
e2617c7e
|
Andreas Kohlbecker
|
/**
|
2323 |
|
|
* Executes the search for registrations and generates the result list..
|
2324 |
|
|
*/
|
2325 |
|
|
function cdm_dataportal_view_search_agent() {
|
2326 |
|
|
|
2327 |
|
|
$render_array = [];
|
2328 |
|
|
$title = isset($_REQUEST['class']) && $_REQUEST['class'] ? $_REQUEST['class'] : 'Persons & Teams';
|
2329 |
|
|
drupal_set_title(t($title), PASS_THROUGH);
|
2330 |
|
|
// TODO $block = block_load('cdm_dataportal', 'search_agent_filter');
|
2331 |
|
|
// $block->title = null;
|
2332 |
|
|
// $render_array = _block_get_renderable_array(_block_render_blocks(array($block)));
|
2333 |
|
|
$pager = cdm_dataportal_search_agent_execute();
|
2334 |
|
|
$pager_render_array = compose_search_results($pager, new AgentComposeHandler());
|
2335 |
|
|
$render_array = array_merge($render_array, $pager_render_array);
|
2336 |
|
|
return $render_array;
|
2337 |
|
|
}
|
2338 |
|
|
|
2339 |
a6ae799b
|
Andreas Kohlbecker
|
|
2340 |
94550ff9
|
Andreas Kohlbecker
|
/**
|
2341 |
bb5a542c
|
Andreas Kohlbecker
|
* Provides the standard image which indicated a loading process
|
2342 |
94550ff9
|
Andreas Kohlbecker
|
*
|
2343 |
|
|
* @return string
|
2344 |
|
|
* The img html tag
|
2345 |
|
|
*/
|
2346 |
|
|
function loading_image_html() {
|
2347 |
|
|
return '<img class="loading" src="' . base_path() . drupal_get_path('module', 'cdm_dataportal')
|
2348 |
|
|
. '/images/loading_circle_grey_16.gif" style="display:none;">';
|
2349 |
|
|
}
|
2350 |
|
|
|
2351 |
78e178e2
|
Andreas Kohlbecker
|
/**
|
2352 |
|
|
* Returns the state of the the showThumbnails flag set in the
|
2353 |
|
|
* users session ($_SESSION['pageoption']['searchtaxa']['showThumbnails']).
|
2354 |
|
|
*
|
2355 |
c5ed6357
|
Andreas Kohlbecker
|
* @return boolean
|
2356 |
78e178e2
|
Andreas Kohlbecker
|
* returns 1 if the flag is set
|
2357 |
|
|
*/
|
2358 |
|
|
function do_showThumbnails() {
|
2359 |
|
|
static $showThumbnails = null;
|
2360 |
|
|
|
2361 |
|
|
if($showThumbnails == null) {
|
2362 |
c5ed6357
|
Andreas Kohlbecker
|
$showThumbnails = 0;
|
2363 |
|
|
if (!isset($_SESSION['pageoption']['searchtaxa']['showThumbnails'])) {
|
2364 |
|
|
$showThumbnails = 0;
|
2365 |
|
|
$search_gallery_settings = variable_get(CDM_DATAPORTAL_SEARCH_GALLERY_NAME, null);
|
2366 |
|
|
$showThumbnails = is_array($search_gallery_settings)
|
2367 |
|
|
&& isset($search_gallery_settings['cdm_dataportal_show_taxon_thumbnails'])
|
2368 |
|
|
&& (
|
2369 |
|
|
$search_gallery_settings['cdm_dataportal_show_taxon_thumbnails'] +
|
2370 |
|
|
$search_gallery_settings['cdm_dataportal_show_synonym_thumbnails'] +
|
2371 |
|
|
$search_gallery_settings['cdm_dataportal_show_thumbnail_captions'] > 0
|
2372 |
|
|
)
|
2373 |
|
|
? 1 : 0;
|
2374 |
f19f47fa
|
Andreas Kohlbecker
|
|
2375 |
c5ed6357
|
Andreas Kohlbecker
|
drupal_array_set_nested_value($_SESSION, array('pageoption', 'searchtaxa', 'showThumbnails'), $showThumbnails);
|
2376 |
|
|
}
|
2377 |
f19f47fa
|
Andreas Kohlbecker
|
$showThumbnails = $_SESSION['pageoption']['searchtaxa']['showThumbnails'];
|
2378 |
|
|
if (!is_numeric($showThumbnails)) {
|
2379 |
|
|
$showThumbnails = 1;
|
2380 |
|
|
}
|
2381 |
78e178e2
|
Andreas Kohlbecker
|
}
|
2382 |
|
|
|
2383 |
|
|
return $showThumbnails;
|
2384 |
|
|
}
|
2385 |
|
|
|
2386 |
6657531f
|
Andreas Kohlbecker
|
|
2387 |
a6ae799b
|
Andreas Kohlbecker
|
|
2388 |
6657531f
|
Andreas Kohlbecker
|
/* ====================== other functions ====================== */
|
2389 |
|
|
/**
|
2390 |
|
|
* Creates a URL to the taxon page specified by the $uuid parameter.
|
2391 |
|
|
*
|
2392 |
|
|
* The URL will be prepended with a path element to a specific taxon page tab.
|
2393 |
|
|
*
|
2394 |
|
|
* This tab is either taken from the CDM_DATAPORTAL_DEFAULT_TAXON_TAB which can
|
2395 |
|
|
* be set globally in the administrative settings or individually in the user
|
2396 |
|
|
* profile. If the CDM_DATAPORTAL_DEFAULT_TAXON_TAB value is set to LAST_VISITED_TAB
|
2397 |
|
|
* the last portal will stay on this last tab.
|
2398 |
|
|
*
|
2399 |
|
|
* A third option is offerered by the $page_tab parameter which allows overwriting this
|
2400 |
|
|
* internal mechanism by a specific value.
|
2401 |
|
|
*
|
2402 |
|
|
* @param string $uuid
|
2403 |
|
|
* The UUID of the taxon.
|
2404 |
|
|
* @param string $page_tab
|
2405 |
|
|
* Overwriting the preset mechanism by defining specific value for the
|
2406 |
|
|
* taxon page tab.
|
2407 |
|
|
* @return string
|
2408 |
|
|
* The created URL.
|
2409 |
|
|
*/
|
2410 |
|
|
function path_to_taxon($uuid, $page_tab = FALSE) {
|
2411 |
|
|
|
2412 |
|
|
$tab = get_default_taxon_tab();
|
2413 |
|
|
$values = unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB);
|
2414 |
|
|
|
2415 |
|
|
if (!$uuid) {
|
2416 |
|
|
return FALSE;
|
2417 |
|
|
}
|
2418 |
|
|
|
2419 |
|
|
if ($page_tab) {
|
2420 |
fec3fd41
|
Andreas Kohlbecker
|
$url = 'cdm_dataportal/taxon/' . $uuid . '/' . $page_tab;
|
2421 |
6657531f
|
Andreas Kohlbecker
|
}
|
2422 |
|
|
elseif (!$tab || strtolower($tab) == 'general') {
|
2423 |
fec3fd41
|
Andreas Kohlbecker
|
$url = 'cdm_dataportal/taxon/' . $uuid;
|
2424 |
6657531f
|
Andreas Kohlbecker
|
}
|
2425 |
|
|
elseif (get_last_taxon_page_tab() && $tab == $values[CDM_DATAPORTAL_LAST_VISITED_TAB_ARRAY_INDEX]) {
|
2426 |
fec3fd41
|
Andreas Kohlbecker
|
$url = 'cdm_dataportal/taxon/' . $uuid . '/' . get_last_taxon_page_tab();
|
2427 |
6657531f
|
Andreas Kohlbecker
|
}
|
2428 |
|
|
else {
|
2429 |
fec3fd41
|
Andreas Kohlbecker
|
$url = 'cdm_dataportal/taxon/' . $uuid . '/' . strtolower($tab);
|
2430 |
6657531f
|
Andreas Kohlbecker
|
}
|
2431 |
fec3fd41
|
Andreas Kohlbecker
|
return $url;
|
2432 |
6657531f
|
Andreas Kohlbecker
|
}
|
2433 |
|
|
|
2434 |
ea0ae3c7
|
Patrick Plitzner
|
function path_to_description($uuid, $descriptive_dataset_uuid = NULL) {
|
2435 |
e170a53e
|
Patrick Plitzner
|
|
2436 |
|
|
if (!$uuid) {
|
2437 |
|
|
return FALSE;
|
2438 |
|
|
}
|
2439 |
|
|
else {
|
2440 |
9705e44e
|
Patrick Plitzner
|
return 'cdm_dataportal/description/' . $uuid
|
2441 |
|
|
. (is_uuid($descriptive_dataset_uuid) ? '/' . $descriptive_dataset_uuid : '');
|
2442 |
e170a53e
|
Patrick Plitzner
|
}
|
2443 |
|
|
}
|
2444 |
|
|
|
2445 |
9d37c9d9
|
Patric Plitzner
|
function path_to_specimen($uuid) {
|
2446 |
|
|
|
2447 |
|
|
if (!$uuid) {
|
2448 |
|
|
return FALSE;
|
2449 |
|
|
}
|
2450 |
|
|
else {
|
2451 |
a1ce57ce
|
Katja Luther
|
return 'cdm_dataportal/occurrence/' . $uuid;
|
2452 |
9d37c9d9
|
Patric Plitzner
|
}
|
2453 |
|
|
}
|
2454 |
|
|
|
2455 |
6eaec849
|
Katja Luther
|
function path_to_specimen_by_accession_number($accession_number) {
|
2456 |
|
|
|
2457 |
|
|
if (!$accession_number) {
|
2458 |
|
|
return FALSE;
|
2459 |
|
|
}
|
2460 |
|
|
else {
|
2461 |
|
|
return 'cdm_dataportal/specimen/accession_number/' . $accession_number;
|
2462 |
|
|
}
|
2463 |
|
|
}
|
2464 |
|
|
|
2465 |
30845bda
|
Andreas Kohlbecker
|
function path_to_named_area($uuid) {
|
2466 |
|
|
|
2467 |
|
|
if (!$uuid) {
|
2468 |
|
|
return FALSE;
|
2469 |
|
|
}
|
2470 |
|
|
else {
|
2471 |
|
|
return 'cdm_dataportal/named_area/' . $uuid;
|
2472 |
|
|
}
|
2473 |
|
|
}
|
2474 |
|
|
|
2475 |
6657531f
|
Andreas Kohlbecker
|
/**
|
2476 |
630c7044
|
Andreas Kohlbecker
|
* Creates a URL to show a synonmy in the according taxon page.
|
2477 |
|
|
*
|
2478 |
|
|
* The URL will point to the synonymy tab of the taxon page of the accepted taxon given as parameter $acceptedUuid.
|
2479 |
|
|
* The resulting URI will include query parameters to highlight the synonym, and to optionally display
|
2480 |
|
|
* the accepted taxons name in aform like "Foo bar is accepted taxon for Ree doo". The URI will also
|
2481 |
|
|
* include the sysnonym uuid as fragment in order to let the browser scroll to the according location
|
2482 |
|
|
* in the page
|
2483 |
|
|
*
|
2484 |
|
|
* @param string $synonymUuid
|
2485 |
|
|
* The uuid of the synonym
|
2486 |
|
|
* @param string $acceptedUuid
|
2487 |
|
|
* The uuid of the according accepted taxon
|
2488 |
|
|
* @return string
|
2489 |
|
|
* The URL to show a synonmy in the according taxon page
|
2490 |
6657531f
|
Andreas Kohlbecker
|
*/
|
2491 |
|
|
function uri_to_synonym($synonymUuid, $acceptedUuid) {
|
2492 |
|
|
$acceptedPath = path_to_taxon($acceptedUuid, "synonymy");
|
2493 |
d071bed7
|
Andreas Kohlbecker
|
return url($acceptedPath, array(
|
2494 |
|
|
'query' => array(
|
2495 |
|
|
// highlite the synony in the synonymy
|
2496 |
|
|
'highlite' => $synonymUuid,
|
2497 |
|
|
// the taxon page is refered from a synonym and the synonym can optionally be named in the page title
|
2498 |
|
|
// see theme_taxon_page_title()
|
2499 |
|
|
'acceptedFor' => $synonymUuid
|
2500 |
630c7044
|
Andreas Kohlbecker
|
),
|
2501 |
|
|
'fragment' => $synonymUuid
|
2502 |
d071bed7
|
Andreas Kohlbecker
|
));
|
2503 |
|
|
|
2504 |
6657531f
|
Andreas Kohlbecker
|
}
|
2505 |
|
|
|
2506 |
|
|
/**
|
2507 |
e0d3e148
|
Andreas Kohlbecker
|
* Composes the drupal path to the key identified by the uuid.
|
2508 |
b8bfa4bd
|
Andreas Kohlbecker
|
*
|
2509 |
|
|
* @param string $keyType
|
2510 |
|
|
* the key typer corresponds to the specific class of the CDM
|
2511 |
|
|
* IdentificationKey. Possible values are
|
2512 |
|
|
* -PolytomousKey
|
2513 |
|
|
* -MultimediaKey
|
2514 |
|
|
* - ...
|
2515 |
e0d3e148
|
Andreas Kohlbecker
|
* @param string $keyUuid
|
2516 |
b8bfa4bd
|
Andreas Kohlbecker
|
* The UUID of the key
|
2517 |
6657531f
|
Andreas Kohlbecker
|
*/
|
2518 |
|
|
function path_to_key($keyType, $keyUuid) {
|
2519 |
|
|
if (!$keyUuid || !$keyType) {
|
2520 |
|
|
return FALSE;
|
2521 |
|
|
}
|
2522 |
|
|
$keyType{0} = strtolower($keyType{0});
|
2523 |
|
|
return "cdm_dataportal/" . $keyType . "/$keyUuid";
|
2524 |
|
|
}
|
2525 |
|
|
|
2526 |
|
|
/**
|
2527 |
e0d3e148
|
Andreas Kohlbecker
|
* Composes the drupal path to the reference identified by the uuid.
|
2528 |
|
|
*
|
2529 |
|
|
* @param $uuid string String representation of the registration entity uuid.
|
2530 |
|
|
*
|
2531 |
|
|
* @return string
|
2532 |
|
|
* The drupal path
|
2533 |
|
|
*
|
2534 |
6657531f
|
Andreas Kohlbecker
|
*/
|
2535 |
|
|
function path_to_reference($uuid) {
|
2536 |
|
|
if (!$uuid) {
|
2537 |
|
|
return FALSE;
|
2538 |
|
|
}
|
2539 |
|
|
return 'cdm_dataportal/reference/' . $uuid;
|
2540 |
|
|
}
|
2541 |
|
|
|
2542 |
e0d3e148
|
Andreas Kohlbecker
|
/**
|
2543 |
|
|
* Composes the drupal path to the reference identified by the uuid.
|
2544 |
|
|
*
|
2545 |
|
|
* @param string $identifier
|
2546 |
|
|
* The persistent identifier of the registration entity (Registration.identifier).
|
2547 |
|
|
* @return string
|
2548 |
|
|
* The drupal path
|
2549 |
|
|
*/
|
2550 |
|
|
function path_to_registration($identifier) {
|
2551 |
|
|
|
2552 |
977bba78
|
Andreas Kohlbecker
|
if(variable_get(CDM_REGISTRATION_PRESISTENT_IDENTIFIER_AS_LINK)){
|
2553 |
|
|
return $identifier;
|
2554 |
|
|
} else {
|
2555 |
|
|
return 'cdm_dataportal/registration/' . urlencode($identifier);
|
2556 |
|
|
}
|
2557 |
e0d3e148
|
Andreas Kohlbecker
|
}
|
2558 |
|
|
|
2559 |
6657531f
|
Andreas Kohlbecker
|
/**
|
2560 |
51b04faf
|
Andreas Kohlbecker
|
* Creates the path to a cdm_dataportal taxon name page.
|
2561 |
|
|
*
|
2562 |
e0d3e148
|
Andreas Kohlbecker
|
* @param string $taxon_name_uuid
|
2563 |
|
|
* The uuid as string of the CDM TaxonName to show a name page for
|
2564 |
|
|
* @param string $taxon_to_hide_uuid
|
2565 |
|
|
* The uuid as string of a taxon which should not be displayed in the taxon list
|
2566 |
d4ea0dd9
|
Andreas Kohlbecker
|
* @param string $highlited_synonym_uuid
|
2567 |
e0d3e148
|
Andreas Kohlbecker
|
* Optional parameter which takes another taxon uuid, if given the
|
2568 |
|
|
* target taxon pages will show the synonymy tab where the taxon
|
2569 |
|
|
* referenced by the $highlite_synonym_uuid will be highlighted
|
2570 |
51b04faf
|
Andreas Kohlbecker
|
* in case it is found on this page.
|
2571 |
2f65af04
|
Andreas Kohlbecker
|
* @param $redirect_to_taxon
|
2572 |
|
|
* If true, the name page will redirect to the related taxon if there is a single one
|
2573 |
|
|
* for this name only.
|
2574 |
51b04faf
|
Andreas Kohlbecker
|
*
|
2575 |
e0d3e148
|
Andreas Kohlbecker
|
* @return string
|
2576 |
|
|
* URI path element as string
|
2577 |
6657531f
|
Andreas Kohlbecker
|
*/
|
2578 |
2f65af04
|
Andreas Kohlbecker
|
function path_to_name($name_uuid, $taxon_to_hide_uuid = NULL, $highlited_synonym_uuid = NULL, $redirect_to_taxon = false) {
|
2579 |
6657531f
|
Andreas Kohlbecker
|
$res = FALSE;
|
2580 |
|
|
if ($name_uuid) {
|
2581 |
2f65af04
|
Andreas Kohlbecker
|
$res = 'cdm_dataportal/name/' . $name_uuid .
|
2582 |
|
|
'/' . (is_uuid($taxon_to_hide_uuid) ? $taxon_to_hide_uuid : "null") .
|
2583 |
|
|
'/' . (is_uuid($highlited_synonym_uuid) ? $highlited_synonym_uuid : "null") .
|
2584 |
14832ae9
|
Andreas Kohlbecker
|
'/' . ($redirect_to_taxon || variable_get(CDM_NAME_PAGE_AUTOREDIRECT, 0) ? "redirect_to_taxon" : "");
|
2585 |
51b04faf
|
Andreas Kohlbecker
|
}
|
2586 |
2f65af04
|
Andreas Kohlbecker
|
|
2587 |
6657531f
|
Andreas Kohlbecker
|
return $res;
|
2588 |
|
|
}
|
2589 |
|
|
|
2590 |
|
|
/**
|
2591 |
e0d3e148
|
Andreas Kohlbecker
|
* Composes the drupal path to the media entity identified by the uuid.
|
2592 |
|
|
*
|
2593 |
|
|
* @param string $uuid
|
2594 |
|
|
* The persistent identifier of the entity entity
|
2595 |
|
|
* @return string
|
2596 |
|
|
* The drupal path
|
2597 |
6657531f
|
Andreas Kohlbecker
|
*/
|
2598 |
|
|
function path_to_media($uuid, $representaion_uuid = FALSE, $partId = FALSE) {
|
2599 |
|
|
if (!$uuid) {
|
2600 |
|
|
return FALSE;
|
2601 |
|
|
}
|
2602 |
|
|
$out = 'cdm_dataportal/media/' . $uuid;
|
2603 |
|
|
if ($representaion_uuid) {
|
2604 |
|
|
$out .= '/' . $representaion_uuid;
|
2605 |
a867b774
|
Andreas Kohlbecker
|
if (is_numeric($partId)) {
|
2606 |
6657531f
|
Andreas Kohlbecker
|
$out .= '/' . $partId;
|
2607 |
|
|
}
|
2608 |
|
|
}
|
2609 |
|
|
return $out;
|
2610 |
|
|
}
|
2611 |
|
|
|
2612 |
|
|
/**
|
2613 |
|
|
* Compares thisRank with thatRank.
|
2614 |
|
|
*
|
2615 |
|
|
* Returns a negative integer, zero, or a positive integer
|
2616 |
|
|
* as the of thisRank is higher than, equal to, or lower than thatRank.
|
2617 |
|
|
* e.g:
|
2618 |
|
|
* <ul>
|
2619 |
|
|
* <li>rank_compare({species_uuid}, {genus_uuid}) = -1</li>
|
2620 |
|
|
* <li>rank_compare({genus_uuid}, {genus_uuid}) = 0</li>
|
2621 |
|
|
* <li>rank_compare({genus_uuid}, {tribus_uuid}) = 1</li>
|
2622 |
|
|
* </ul>
|
2623 |
|
|
* <p>
|
2624 |
|
|
* This compare logic of the underlying webservice is the
|
2625 |
|
|
* <b>inverse logic</b> of the the one implemented in
|
2626 |
|
|
* java.lang.Comparable#compareTo(java.lang.Object)
|
2627 |
|
|
*
|
2628 |
|
|
* @param $thisRankUuid
|
2629 |
|
|
* @param $thatRankUuid
|
2630 |
|
|
*
|
2631 |
|
|
* @return int
|
2632 |
|
|
* A negative integer, zero, or a positive integer
|
2633 |
|
|
* as the thisRank is lower than, equal to, or higher than thatRank.
|
2634 |
|
|
*/
|
2635 |
|
|
function rank_compare($thisRankUuid, $thatRankUuid) {
|
2636 |
|
|
$result = cdm_ws_get(CDM_WS_TERM_COMPARE, array($thisRankUuid, $thatRankUuid));
|
2637 |
|
|
return $result->Integer;
|
2638 |
|
|
}
|
2639 |
|
|
|
2640 |
|
|
/**
|
2641 |
a0e3ae5c
|
Andreas Kohlbecker
|
* Creates a short version of a taxonname.
|
2642 |
6657531f
|
Andreas Kohlbecker
|
*
|
2643 |
e90899ac
|
Andreas Kohlbecker
|
* The short name is created by using the taggedTitle field of
|
2644 |
a0e3ae5c
|
Andreas Kohlbecker
|
* TaxonNodeDTO instances.
|
2645 |
e90899ac
|
Andreas Kohlbecker
|
* If the taggedTitle if empty the fullname will be returned.
|
2646 |
6657531f
|
Andreas Kohlbecker
|
*
|
2647 |
a0e3ae5c
|
Andreas Kohlbecker
|
* @param object $taxonNodeDTO
|
2648 |
|
|
* A TaxonNodeDTO object
|
2649 |
6657531f
|
Andreas Kohlbecker
|
*
|
2650 |
|
|
* @return string
|
2651 |
|
|
*/
|
2652 |
a0e3ae5c
|
Andreas Kohlbecker
|
function cdm_dataportal_shortname_of($taxonNodeDTO) {
|
2653 |
|
|
|
2654 |
6657531f
|
Andreas Kohlbecker
|
$nameStr = '';
|
2655 |
|
|
|
2656 |
a0e3ae5c
|
Andreas Kohlbecker
|
normalize_tagged_text($taxonNodeDTO->taggedTitle);
|
2657 |
6657531f
|
Andreas Kohlbecker
|
|
2658 |
|
|
// Get all tagged text tokens of the scientific name.
|
2659 |
a0e3ae5c
|
Andreas Kohlbecker
|
foreach ($taxonNodeDTO->taggedTitle as $tagtxt) {
|
2660 |
6657531f
|
Andreas Kohlbecker
|
if ($tagtxt->type == 'name' || $tagtxt->type == 'rank') {
|
2661 |
|
|
$nameStr .= ($nameStr ? ' ' : '') . $tagtxt->text;
|
2662 |
|
|
}
|
2663 |
|
|
}
|
2664 |
|
|
$nameStr = trim($nameStr);
|
2665 |
|
|
|
2666 |
|
|
if ($nameStr) {
|
2667 |
64cfdac1
|
Andreas Kohlbecker
|
if(isset($taxonNodeDTO->nodeStatus->symbol)){
|
2668 |
|
|
$nameStr = $taxonNodeDTO->nodeStatus->symbol . ' ' . $nameStr;
|
2669 |
9282ac6e
|
Andreas Kohlbecker
|
}
|
2670 |
6657531f
|
Andreas Kohlbecker
|
// Do not return short names for these.
|
2671 |
a0e3ae5c
|
Andreas Kohlbecker
|
if ($taxonNodeDTO->unplaced || $taxonNodeDTO->excluded) {
|
2672 |
6657531f
|
Andreas Kohlbecker
|
return $nameStr;
|
2673 |
|
|
}
|
2674 |
|
|
|
2675 |
|
|
/*
|
2676 |
|
|
1st capture group (^[a-zA-Z]): First letter of uninomial.
|
2677 |
|
|
Second capture group ([\p{L}]+): remaining letters of uninomial ([\p{L} = an UTF-8 letter).
|
2678 |
|
|
Third capture group (\s+[^(\x2E]+\s+.+$|\s+[a-zA-Z]+$): letters of name,
|
2679 |
|
|
but only matching if no '(' or '.' in second word of name, ( \x2E = '.')
|
2680 |
|
|
OR only one specific epithet \s+[\p{L}\x22\x2D\xD7]+$ (\x22= '"', \x2D='-', \xD7='×' )
|
2681 |
|
|
*/
|
2682 |
|
|
$pattern = '/(^[a-zA-Z])([\p{L}]+)(\s+[^(\x2E]+\s+.+$|\s+[\p{L}\x22\x2D\xD7]+$)/u';
|
2683 |
|
|
if (preg_match($pattern, $nameStr, $matches, PREG_OFFSET_CAPTURE)) {
|
2684 |
|
|
return $matches[1][0] . "." . $matches[3][0];
|
2685 |
|
|
}
|
2686 |
|
|
else {
|
2687 |
|
|
return $nameStr;
|
2688 |
|
|
}
|
2689 |
|
|
}
|
2690 |
|
|
else {
|
2691 |
a0e3ae5c
|
Andreas Kohlbecker
|
return $taxonNodeDTO->titleCache;
|
2692 |
6657531f
|
Andreas Kohlbecker
|
}
|
2693 |
|
|
}
|
2694 |
|
|
|
2695 |
|
|
/**
|
2696 |
|
|
* Check if a taxon is accepted by the current taxonomic tree.
|
2697 |
|
|
*
|
2698 |
|
|
* @param mixed $taxon
|
2699 |
|
|
* The Taxon obkect to check.
|
2700 |
|
|
*
|
2701 |
|
|
* @return bool
|
2702 |
|
|
* Returns TRUE if $taxon is accepted, FALSE otherwise.
|
2703 |
|
|
*/
|
2704 |
|
|
function _cdm_dataportal_acceptedByCurrentView($taxon) {
|
2705 |
|
|
|
2706 |
7663cd0b
|
Andreas Kohlbecker
|
$defaultTreeUuid = get_current_classification_uuid();
|
2707 |
6657531f
|
Andreas Kohlbecker
|
|
2708 |
|
|
if (isset($taxon->taxonNodes)) {
|
2709 |
|
|
$taxonNodes = $taxon->taxonNodes;
|
2710 |
|
|
}
|
2711 |
|
|
else {
|
2712 |
|
|
$taxonNodes = cdm_ws_get(CDM_WS_PORTAL_TAXON_TAXONNODES, $taxon->uuid);
|
2713 |
|
|
}
|
2714 |
|
|
|
2715 |
|
|
if ($taxon->class == "Taxon" && isset($taxonNodes)) {
|
2716 |
|
|
foreach ($taxonNodes as $node) {
|
2717 |
64cfdac1
|
Andreas Kohlbecker
|
if (isset($node->classificationUUID)){
|
2718 |
|
|
if ($node->classificationUUID == $defaultTreeUuid) {
|
2719 |
|
|
return TRUE;
|
2720 |
6657531f
|
Andreas Kohlbecker
|
}
|
2721 |
64cfdac1
|
Andreas Kohlbecker
|
}
|
2722 |
|
|
else {
|
2723 |
|
|
if ($node->classification == $defaultTreeUuid) {
|
2724 |
|
|
return TRUE;
|
2725 |
6657531f
|
Andreas Kohlbecker
|
}
|
2726 |
|
|
}
|
2727 |
|
|
}
|
2728 |
|
|
}
|
2729 |
|
|
|
2730 |
|
|
return FALSE;
|
2731 |
|
|
}
|
2732 |
|
|
|
2733 |
|
|
/**
|
2734 |
54cfa718
|
Andreas Kohlbecker
|
* Checks is the source has one of the given types.
|
2735 |
|
|
*
|
2736 |
|
|
* @param object $source
|
2737 |
|
|
* The original source entity
|
2738 |
|
|
* @param array $types
|
2739 |
b08a856c
|
Andreas Kohlbecker
|
* An array of element of the OriginalSourceType enumeration
|
2740 |
54cfa718
|
Andreas Kohlbecker
|
* If not set the default will be used which is:
|
2741 |
|
|
* - Lineage
|
2742 |
|
|
* - PrimaryMediaSource
|
2743 |
|
|
* - PrimaryTaxonomicSource
|
2744 |
|
|
* - Unknown
|
2745 |
|
|
* - Other
|
2746 |
|
|
* @return boolean
|
2747 |
6657531f
|
Andreas Kohlbecker
|
*/
|
2748 |
54cfa718
|
Andreas Kohlbecker
|
function _is_original_source_type($source, $types = null) {
|
2749 |
|
|
// this is the default
|
2750 |
|
|
// maybe this should also be put into the settings
|
2751 |
|
|
static $default = array(
|
2752 |
|
|
OriginalSourceType::Lineage,
|
2753 |
|
|
OriginalSourceType::PrimaryMediaSource,
|
2754 |
|
|
OriginalSourceType::PrimaryTaxonomicSource,
|
2755 |
|
|
OriginalSourceType::Unknown,
|
2756 |
|
|
OriginalSourceType::Other,
|
2757 |
fe3a5674
|
Andreas Kohlbecker
|
OriginalSourceType::Aggregation
|
2758 |
54cfa718
|
Andreas Kohlbecker
|
);
|
2759 |
|
|
|
2760 |
|
|
if(!$types){
|
2761 |
|
|
$types = $default;
|
2762 |
|
|
}
|
2763 |
|
|
return isset($source->type) && in_array($source->type, $types);
|
2764 |
|
|
}
|
2765 |
6657531f
|
Andreas Kohlbecker
|
|
2766 |
|
|
/**
|
2767 |
|
|
* Collects all the media from a list of description elements.
|
2768 |
|
|
*
|
2769 |
|
|
* @param array $descriptionElements
|
2770 |
|
|
* The description elements from which to collect the media.
|
2771 |
|
|
*
|
2772 |
|
|
* @return array
|
2773 |
|
|
* The output with all the collected media.
|
2774 |
|
|
*/
|
2775 |
|
|
function cdm_dataportal_media_from_descriptionElements($descriptionElements) {
|
2776 |
|
|
|
2777 |
|
|
$outArrayOfMedia = array();
|
2778 |
|
|
|
2779 |
|
|
// Avoiding a warning box in Drupal for Flora Malesiana.
|
2780 |
|
|
if (isset($descriptionElements) && is_array($descriptionElements)) {
|
2781 |
|
|
foreach ($descriptionElements as $descriptionElement) {
|
2782 |
|
|
if (isset($descriptionElement->media) && is_array($descriptionElement->media)) {
|
2783 |
|
|
foreach ($descriptionElement->media as $media) {
|
2784 |
|
|
if (is_object($media)) {
|
2785 |
|
|
$outArrayOfMedia[] = $media;
|
2786 |
|
|
}
|
2787 |
|
|
}
|
2788 |
|
|
}
|
2789 |
|
|
}
|
2790 |
|
|
}
|
2791 |
|
|
return $outArrayOfMedia;
|
2792 |
|
|
}
|
2793 |
|
|
|
2794 |
|
|
/**
|
2795 |
7370f4f7
|
Andreas Kohlbecker
|
* Fetches the list of visible annotations for each of the cdm entities and returns the footnote keys for them.
|
2796 |
|
|
*
|
2797 |
|
|
* The footnotes are passed to the FootnoteManager in order to store the annotations and to create the footnote keys.
|
2798 |
|
|
*
|
2799 |
|
|
* @see cdm_fetch_visible_annotations()
|
2800 |
6657531f
|
Andreas Kohlbecker
|
*
|
2801 |
65345976
|
Andreas Kohlbecker
|
* @param array $cdm_entities
|
2802 |
6657531f
|
Andreas Kohlbecker
|
* An array of CdmBase instances or a single instance.
|
2803 |
f814b2cd
|
Andreas Kohlbecker
|
* @param $footnote_list_key_suggestion string
|
2804 |
|
|
* optional parameter. If this parameter is left empty (null, 0, "") the footnote key will be determined be set to
|
2805 |
|
|
* RenderHints::getFootnoteListKey().'-annotations' otherwise the supplied key will be used.
|
2806 |
6657531f
|
Andreas Kohlbecker
|
*
|
2807 |
7370f4f7
|
Andreas Kohlbecker
|
* @return array of footnote keys
|
2808 |
6657531f
|
Andreas Kohlbecker
|
*/
|
2809 |
178d1ae6
|
Andreas Kohlbecker
|
function cdm_annotations_as_footnotekeys(array $cdm_entities, $footnote_list_key_suggestion = NULL) {
|
2810 |
90597e37
|
Andreas Kohlbecker
|
|
2811 |
a6c4c53c
|
Andreas Kohlbecker
|
$foot_note_keys = array();
|
2812 |
6657531f
|
Andreas Kohlbecker
|
|
2813 |
|
|
// Is argument cdmBase an array?
|
2814 |
65345976
|
Andreas Kohlbecker
|
if (!is_array($cdm_entities)) {
|
2815 |
a6c4c53c
|
Andreas Kohlbecker
|
$enties = array();
|
2816 |
|
|
$enties[] = $cdm_entities;
|
2817 |
6657531f
|
Andreas Kohlbecker
|
}
|
2818 |
|
|
else {
|
2819 |
a6c4c53c
|
Andreas Kohlbecker
|
$enties = $cdm_entities;
|
2820 |
6657531f
|
Andreas Kohlbecker
|
}
|
2821 |
|
|
|
2822 |
|
|
// Getting the key for the footnotemanager.
|
2823 |
28c5c87a
|
Andreas Kohlbecker
|
if (isset($footnote_list_key_suggestion)) {
|
2824 |
|
|
$footnote_list_key = $footnote_list_key_suggestion;
|
2825 |
6657531f
|
Andreas Kohlbecker
|
}
|
2826 |
|
|
else {
|
2827 |
28c5c87a
|
Andreas Kohlbecker
|
$footnote_list_key = RenderHints::getFootnoteListKey() . '-annotations';
|
2828 |
6657531f
|
Andreas Kohlbecker
|
}
|
2829 |
|
|
|
2830 |
|
|
// Adding the footnotes keys.
|
2831 |
a6c4c53c
|
Andreas Kohlbecker
|
foreach ($enties as $cdm_entity) {
|
2832 |
|
|
$annotations = cdm_fetch_visible_annotations($cdm_entity);
|
2833 |
6657531f
|
Andreas Kohlbecker
|
if (is_array($annotations)) {
|
2834 |
|
|
foreach ($annotations as $annotation) {
|
2835 |
a6c4c53c
|
Andreas Kohlbecker
|
$foot_note_keys[] = FootnoteManager::addNewFootnote($footnote_list_key, $annotation->text);
|
2836 |
6657531f
|
Andreas Kohlbecker
|
}
|
2837 |
|
|
}
|
2838 |
|
|
}
|
2839 |
|
|
|
2840 |
a6c4c53c
|
Andreas Kohlbecker
|
return $foot_note_keys;
|
2841 |
6657531f
|
Andreas Kohlbecker
|
}
|
2842 |
|
|
|
2843 |
178d1ae6
|
Andreas Kohlbecker
|
/**
|
2844 |
|
|
* Fetches the list of visible annotations for each of the cdm entities and returns the footnote keys for them.
|
2845 |
|
|
*
|
2846 |
|
|
* The footnotes are passed to the FootnoteManager in order to store the annotations and to create the footnote keys.
|
2847 |
|
|
*
|
2848 |
|
|
* @see cdm_fetch_visible_annotations()
|
2849 |
|
|
*
|
2850 |
|
|
* @param array $cdm_entities
|
2851 |
|
|
* An array of CdmBase instances or a single instance.
|
2852 |
|
|
* @param $footnote_list_key_suggestion string
|
2853 |
|
|
* optional parameter. If this parameter is left empty (null, 0, "") the footnote key will be determined be set to
|
2854 |
|
|
* RenderHints::getFootnoteListKey().'-annotations' otherwise the supplied key will be used.
|
2855 |
|
|
*
|
2856 |
|
|
* @return array of footnote keys
|
2857 |
|
|
*/
|
2858 |
|
|
function cdm_entity_annotations_as_footnotekeys($cdm_entity, $footnote_list_key_suggestion = NULL) {
|
2859 |
|
|
|
2860 |
|
|
$foot_note_keys = array();
|
2861 |
|
|
|
2862 |
|
|
// Getting the key for the footnotemanager.
|
2863 |
|
|
if (isset($footnote_list_key_suggestion)) {
|
2864 |
|
|
$footnote_list_key = $footnote_list_key_suggestion;
|
2865 |
|
|
} else {
|
2866 |
|
|
$footnote_list_key = RenderHints::getFootnoteListKey() . '-annotations';
|
2867 |
|
|
}
|
2868 |
|
|
|
2869 |
|
|
// Adding the footnotes keys.
|
2870 |
|
|
$annotations = cdm_fetch_visible_annotations($cdm_entity);
|
2871 |
|
|
if (is_array($annotations)) {
|
2872 |
|
|
foreach ($annotations as $annotation) {
|
2873 |
|
|
$foot_note_keys[] = FootnoteManager::addNewFootnote($footnote_list_key, $annotation->text);
|
2874 |
|
|
}
|
2875 |
|
|
}
|
2876 |
|
|
|
2877 |
|
|
return $foot_note_keys;
|
2878 |
|
|
}
|
2879 |
|
|
|
2880 |
d9763fd3
|
Andreas Kohlbecker
|
|
2881 |
6657531f
|
Andreas Kohlbecker
|
/**
|
2882 |
d9763fd3
|
Andreas Kohlbecker
|
* Creates a CDM Dynabox.
|
2883 |
|
|
*
|
2884 |
c1f5d897
|
Andreas Kohlbecker
|
* @param string $dynabox_id
|
2885 |
d9763fd3
|
Andreas Kohlbecker
|
* a uninque name for tha dynabox, using a cdm entity uuid as id is good practice.
|
2886 |
6657531f
|
Andreas Kohlbecker
|
* @param string $label
|
2887 |
|
|
* The clickable text to show.
|
2888 |
|
|
* @param string $content_url
|
2889 |
|
|
* The cdm REST service request url wich will deliver the content to be shown
|
2890 |
|
|
* once the dynabox toggles open.
|
2891 |
|
|
* @param string $theme
|
2892 |
1ce9afb7
|
Patric Plitzner
|
* The theme to be used for rendering the cdm REST service response with is
|
2893 |
6657531f
|
Andreas Kohlbecker
|
* returned from the $content_url.
|
2894 |
|
|
* @param string $link_alt_text
|
2895 |
|
|
* The value for the alt attribute of the dynabox link.
|
2896 |
|
|
* @param array $enclosingtags
|
2897 |
|
|
* An array with two elements: $enclosingtags[0] will be used for the dynabox
|
2898 |
|
|
* element itself, $enclosingtags[1] is the tag to be used for the
|
2899 |
c1f5d897
|
Andreas Kohlbecker
|
* dynabox_content (optional)
|
2900 |
d9763fd3
|
Andreas Kohlbecker
|
* @param array $attributes
|
2901 |
|
|
* @param $content_element_selector
|
2902 |
|
|
* Optional jQuery selector which can be used to reference a dom element which should
|
2903 |
|
|
* be used as container for the content to be shown. The dynabox-<dynabox id>-content
|
2904 |
|
|
* element will be placed in this container.
|
2905 |
|
|
*
|
2906 |
c1f5d897
|
Andreas Kohlbecker
|
* @param string $open_callback
|
2907 |
1ce9afb7
|
Patric Plitzner
|
* optional javascript call back function to be triggered after toggling the box to
|
2908 |
c1f5d897
|
Andreas Kohlbecker
|
* the open state.
|
2909 |
|
|
* @param string $close_callback
|
2910 |
1ce9afb7
|
Patric Plitzner
|
* optional javascript call back function to be triggered after toggling the box to
|
2911 |
c1f5d897
|
Andreas Kohlbecker
|
* the closed state.
|
2912 |
d9763fd3
|
Andreas Kohlbecker
|
* @return string Returns HTML for a dynabox.
|
2913 |
|
|
* Returns HTML for a dynabox.
|
2914 |
6657531f
|
Andreas Kohlbecker
|
*/
|
2915 |
d9763fd3
|
Andreas Kohlbecker
|
function cdm_dynabox($dynabox_id, $label, $content_url, $theme, $link_alt_text,
|
2916 |
|
|
$enclosingtags = array('li', 'ul'), $attributes = array(),
|
2917 |
|
|
$content_element_selector = null,
|
2918 |
|
|
$open_callback = 'function(){}', $close_callback = 'function(){}' ) {
|
2919 |
6657531f
|
Andreas Kohlbecker
|
$out = '';
|
2920 |
c1f5d897
|
Andreas Kohlbecker
|
|
2921 |
|
|
// check for plain class attribute string
|
2922 |
|
|
$dynabox_id = preg_replace('/[^a-zA-Z0-9\-]/', '', $dynabox_id);
|
2923 |
|
|
|
2924 |
9c9d11f7
|
Andreas Kohlbecker
|
if(!array_key_exists('class', $attributes)) {
|
2925 |
|
|
$attributes['class'] = array();
|
2926 |
|
|
}
|
2927 |
d9763fd3
|
Andreas Kohlbecker
|
$attributes['id'][] = 'dynabox-' . $dynabox_id;
|
2928 |
9c9d11f7
|
Andreas Kohlbecker
|
$dynabox_attributes = drupal_attributes($attributes);
|
2929 |
|
|
|
2930 |
|
|
|
2931 |
b386ae48
|
Andreas Kohlbecker
|
_add_js_domEvent(); // requires domEvent.js
|
2932 |
6657531f
|
Andreas Kohlbecker
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/cdm_dynabox.js');
|
2933 |
c1f5d897
|
Andreas Kohlbecker
|
drupal_add_js("
|
2934 |
94bb8db6
|
Andreas Kohlbecker
|
jQuery(document).ready(
|
2935 |
|
|
function() {
|
2936 |
|
|
dynabox('". $dynabox_id ."',
|
2937 |
|
|
{
|
2938 |
|
|
open_callback: " . $open_callback .",
|
2939 |
d9763fd3
|
Andreas Kohlbecker
|
close_callback: " . $close_callback .
|
2940 |
|
|
($content_element_selector ? ",\n content_container_selector: '" . $content_element_selector . "'" : "") . "
|
2941 |
94bb8db6
|
Andreas Kohlbecker
|
}
|
2942 |
|
|
);
|
2943 |
|
|
}
|
2944 |
|
|
);",
|
2945 |
|
|
array(
|
2946 |
|
|
'type'=>'inline',
|
2947 |
|
|
'scope'=>'footer'
|
2948 |
|
|
)
|
2949 |
|
|
);
|
2950 |
6657531f
|
Andreas Kohlbecker
|
|
2951 |
9c9d11f7
|
Andreas Kohlbecker
|
|
2952 |
6657531f
|
Andreas Kohlbecker
|
$cdm_proxy_url = url('cdm_api/proxy/' . urlencode($content_url) . "/$theme");
|
2953 |
9c9d11f7
|
Andreas Kohlbecker
|
$out .= '<!-- dynabox for ' . $content_url . ' -->';
|
2954 |
7cc085da
|
Andreas Kohlbecker
|
$out .= '<' . $enclosingtags[0] . ' ' . $dynabox_attributes. '><a href="' . $cdm_proxy_url . '" class="label" alt="' . t('@link-alt-text', array('@link-alt-text' => $link_alt_text)) . '">' . $label . '</a>';
|
2955 |
d9763fd3
|
Andreas Kohlbecker
|
$out .= ' <' . $enclosingtags[1] . ' id="dynabox-' . $dynabox_id . '-content">';
|
2956 |
|
|
$out .= ' <' . $enclosingtags[0] . ' class="dynabox-content-inner">' . loading_image_html() . '</' . $enclosingtags[0] . '>';
|
2957 |
|
|
$out .= ' </' . $enclosingtags[1] . '>';
|
2958 |
|
|
$out .= ' </' . $enclosingtags[0] . '>';
|
2959 |
9c9d11f7
|
Andreas Kohlbecker
|
$out .= '<!-- dynabox end -->';
|
2960 |
6657531f
|
Andreas Kohlbecker
|
return $out;
|
2961 |
|
|
}
|
2962 |
|
|
|
2963 |
|
|
/**
|
2964 |
|
|
* Checks whether a feature has any description elements.
|
2965 |
|
|
*
|
2966 |
|
|
* @param mixed $featureNode
|
2967 |
|
|
* A feature node as produced by the function _mergeFeatureTreeDescriptions().
|
2968 |
|
|
*
|
2969 |
|
|
* @see _mergeFeatureTreeDescriptions()
|
2970 |
|
|
*
|
2971 |
|
|
* @return bool
|
2972 |
|
|
* Returns TRUE if the given $featureNode or any of its subordinate nodes
|
2973 |
|
|
* contains at least one non empty TextData or at least one DescriptionElement
|
2974 |
|
|
* of an other type. A TextData element holding a multilanguageText or a
|
2975 |
|
|
* source reference is considered to be not empty.
|
2976 |
159cd9bb
|
Andreas Kohlbecker
|
*
|
2977 |
|
|
* @TODO this function may have become obsolete by the new method of detecting empty blocks,
|
2978 |
1b756c5f
|
Andreas Kohlbecker
|
* see $block_content_is_not_empty in make_feature_block_list() and
|
2979 |
0ebb6efc
|
Andreas Kohlbecker
|
* $feature_block_has_content in compose_feature_block_items_generic
|
2980 |
6657531f
|
Andreas Kohlbecker
|
*/
|
2981 |
f19f47fa
|
Andreas Kohlbecker
|
function has_feature_node_description_elements($featureNode) {
|
2982 |
6657531f
|
Andreas Kohlbecker
|
|
2983 |
|
|
if (isset($featureNode->descriptionElements) && is_array($featureNode->descriptionElements) && count($featureNode->descriptionElements) > 0) {
|
2984 |
092744e1
|
Andreas Kohlbecker
|
if(!isset($featureNode->descriptionElements['#type'])){ // #type is used to identify e.g. DTO elements: '#type' => 'DTO'
|
2985 |
|
|
foreach ($featureNode->descriptionElements as $descriptionElement) {
|
2986 |
159cd9bb
|
Andreas Kohlbecker
|
if ($descriptionElement->class != "TextData" || isset($descriptionElement->multilanguageText_L10n->text)
|
2987 |
|
|
&& $descriptionElement->multilanguageText_L10n->text != ''
|
2988 |
|
|
|| isset($descriptionElement->sources[0])
|
2989 |
|
|
|| isset($descriptionElement->media[0]) ) {
|
2990 |
092744e1
|
Andreas Kohlbecker
|
return TRUE;
|
2991 |
|
|
}
|
2992 |
6657531f
|
Andreas Kohlbecker
|
}
|
2993 |
|
|
}
|
2994 |
|
|
}
|
2995 |
092744e1
|
Andreas Kohlbecker
|
else if (isset($featureNode->childNodes) && is_array($featureNode->childNodes)) {
|
2996 |
fae36a2a
|
Andreas Kohlbecker
|
foreach ($featureNode->childNodes as $child) {
|
2997 |
f19f47fa
|
Andreas Kohlbecker
|
if (has_feature_node_description_elements($child)) {
|
2998 |
6657531f
|
Andreas Kohlbecker
|
return TRUE;
|
2999 |
|
|
}
|
3000 |
|
|
}
|
3001 |
|
|
}
|
3002 |
|
|
return FALSE;
|
3003 |
|
|
}
|
3004 |
f26245c8
|
Andreas Kohlbecker
|
|
3005 |
|
|
/**
|
3006 |
|
|
* Checks if the current page is a valid taxon portal page and responds with HTTP status 404 (not found) otherwise
|
3007 |
|
|
*
|
3008 |
|
|
* @param $chapter
|
3009 |
|
|
* The taxon page chapter or part
|
3010 |
|
|
*/
|
3011 |
|
|
function cdm_check_valid_taxon_page($chapter){
|
3012 |
|
|
static $taxon_tabs = null;
|
3013 |
|
|
|
3014 |
|
|
cdm_check_valid_portal_page();
|
3015 |
|
|
|
3016 |
|
|
if($taxon_tabs == null){
|
3017 |
|
|
$taxon_tabs = array('all', 'description');
|
3018 |
|
|
foreach(get_taxon_tabs_list() as $tab){
|
3019 |
|
|
$taxon_tabs[] = strtolower($tab);
|
3020 |
|
|
}
|
3021 |
|
|
}
|
3022 |
|
|
|
3023 |
|
|
if(!in_array($chapter, $taxon_tabs)){
|
3024 |
|
|
// oops this is not a valid chapter name
|
3025 |
b4a5c2be
|
Andreas Kohlbecker
|
http_response_code(404); // 404 = Not Found
|
3026 |
f26245c8
|
Andreas Kohlbecker
|
}
|
3027 |
|
|
|
3028 |
|
|
}
|
3029 |
|
|
|
3030 |
b654a866
|
Andreas Kohlbecker
|
function check_js_devel_mode_disabled() {
|
3031 |
|
|
if(variable_get('cdm_js_devel_mode', FALSE)) {
|
3032 |
|
|
drupal_set_message(t('The !url1 is enabled.
|
3033 |
|
|
WARNING: this is a performance penalty and must be turned off on production websites.', array(
|
3034 |
|
|
'!url1' => l('java-script development mode', 'admin/config/cdm_dataportal/settings', array('fragment' => 'edit-cdm-js-devel-mode'))
|
3035 |
|
|
)),
|
3036 |
|
|
'warning'
|
3037 |
|
|
);
|
3038 |
|
|
}
|
3039 |
|
|
}
|
3040 |
|
|
|
3041 |
f26245c8
|
Andreas Kohlbecker
|
/**
|
3042 |
e0d3e148
|
Andreas Kohlbecker
|
* Checks if the current page is a valid portal page and responds with HTTP status 404 (not found) otherwise.
|
3043 |
|
|
* The test applied by default it a check for the query parameter 'q' ending with a file suffix like '*.*'
|
3044 |
f26245c8
|
Andreas Kohlbecker
|
*
|
3045 |
e0d3e148
|
Andreas Kohlbecker
|
* @param $preg_pattern
|
3046 |
|
|
* Optional regular expression pattern to be used in preg_match().
|
3047 |
f26245c8
|
Andreas Kohlbecker
|
*/
|
3048 |
e0d3e148
|
Andreas Kohlbecker
|
function cdm_check_valid_portal_page($preg_pattern = null){
|
3049 |
595de9f0
|
Andreas Kohlbecker
|
$ends_with_file_suffix_pattern = '/\/[^\.\/]*[\.][^\.\/]*$/';
|
3050 |
e0d3e148
|
Andreas Kohlbecker
|
if($preg_pattern === null){
|
3051 |
|
|
$preg_pattern = $ends_with_file_suffix_pattern;
|
3052 |
|
|
}
|
3053 |
|
|
if(preg_match($preg_pattern, $_GET['q'])){
|
3054 |
f26245c8
|
Andreas Kohlbecker
|
// oops this urls ends with a file_suffix and thus does not refer to a portal page
|
3055 |
b4a5c2be
|
Andreas Kohlbecker
|
http_response_code(404); // 404 = Not Found
|
3056 |
595de9f0
|
Andreas Kohlbecker
|
exit('HTTP 404');
|
3057 |
f26245c8
|
Andreas Kohlbecker
|
}
|
3058 |
b654a866
|
Andreas Kohlbecker
|
check_js_devel_mode_disabled();
|
3059 |
f26245c8
|
Andreas Kohlbecker
|
}
|
3060 |
b2b9e057
|
Andreas Kohlbecker
|
|
3061 |
|
|
/**
|
3062 |
|
|
* Generates the diff of the texts and presents it in a HTML diff viewer.
|
3063 |
|
|
*
|
3064 |
|
|
* @param $text_a
|
3065 |
|
|
* @param $text_b
|
3066 |
|
|
* @return string
|
3067 |
|
|
*/
|
3068 |
|
|
function diff_viewer($text_a, $text_b) {
|
3069 |
|
|
|
3070 |
|
|
static $diff_viewer_count = 0;
|
3071 |
|
|
|
3072 |
|
|
$element_id = 'part_definitions_diff_' . $diff_viewer_count++;
|
3073 |
|
|
|
3074 |
|
|
// http://code.stephenmorley.org/php/diff-implementation/
|
3075 |
|
|
module_load_include('php', 'cdm_dataportal', 'lib/class.Diff');
|
3076 |
|
|
drupal_add_css(drupal_get_path('module',
|
3077 |
|
|
'cdm_dataportal') . '/css/diff.css');
|
3078 |
087bb473
|
Andreas Kohlbecker
|
_add_jquery_ui();
|
3079 |
b2b9e057
|
Andreas Kohlbecker
|
drupal_add_js(
|
3080 |
|
|
'jQuery(document).ready( function(){
|
3081 |
|
|
jQuery(\'#' . $element_id . '\').accordion({
|
3082 |
|
|
collapsible: true,
|
3083 |
|
|
active: false,
|
3084 |
|
|
fillSpace: true,
|
3085 |
|
|
}).children(\'div\').css({ \'height\': \'auto\' });
|
3086 |
|
|
jQuery(\'#' . $element_id . ' table.diff\').prepend(\'<thead><tr><th>Default</th><th>User defined<th></th><tr></thead>\');
|
3087 |
|
|
});'
|
3088 |
|
|
, array(
|
3089 |
|
|
'type' => 'inline',
|
3090 |
|
|
'scope' => 'footer'
|
3091 |
|
|
));
|
3092 |
|
|
|
3093 |
|
|
$diff = Diff::compare($text_a,
|
3094 |
|
|
$text_b);
|
3095 |
|
|
$diff_viewer_markup = '<div id="' . $element_id . '"><h3>View Diff</h3><div>'
|
3096 |
|
|
. Diff::toTable($diff, '', '')
|
3097 |
|
|
. '</div></div>';
|
3098 |
|
|
return $diff_viewer_markup;
|
3099 |
|
|
}
|
3100 |
|
|
|