1 |
9cc1a3e2
|
Andreas Kohlbecker
|
<?php
|
2 |
e06884e4
|
Andreas Kohlbecker
|
// $Id$
|
3 |
9cc1a3e2
|
Andreas Kohlbecker
|
|
4 |
05fe0ad6
|
Andreas Kohlbecker
|
/*
|
5 |
|
|
* @file
|
6 |
|
|
* cdm_dataportal
|
7 |
67a4a4c6
|
Andreas Kohlbecker
|
*
|
8 |
05fe0ad6
|
Andreas Kohlbecker
|
* Copyright (C) 2007 EDIT
|
9 |
05166aee
|
f.revilla
|
* European Distributed Institute of Taxonomy
|
10 |
05fe0ad6
|
Andreas Kohlbecker
|
* http://www.e-taxonomy.eu
|
11 |
05166aee
|
f.revilla
|
*
|
12 |
806baeb2
|
Andreas Kohlbecker
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
13 |
|
|
* See http://www.mozilla.org/MPL/MPL-1.1.html for the full license terms.
|
14 |
05fe0ad6
|
Andreas Kohlbecker
|
*/
|
15 |
|
|
|
16 |
8ff851c6
|
Andreas Kohlbecker
|
require_once('node_types.php');
|
17 |
1322a06c
|
Andreas Kohlbecker
|
require_once('settings.php');
|
18 |
27b71dd0
|
f.revilla
|
require_once('help.php');
|
19 |
806baeb2
|
Andreas Kohlbecker
|
|
20 |
|
|
require_once('theme/cdm_dataportal.common.theme');
|
21 |
|
|
require_once('theme/cdm_dataportal.descriptions.theme');
|
22 |
|
|
require_once('theme/cdm_dataportal.media.theme');
|
23 |
|
|
require_once('theme/cdm_dataportal.occurrence.theme');
|
24 |
|
|
require_once('theme/cdm_dataportal.page.theme');
|
25 |
|
|
require_once('theme/cdm_dataportal.taxon.theme');
|
26 |
|
|
require_once('theme/cdm_dataportal.name.theme');
|
27 |
|
|
require_once('theme/cdm_dataportal.references.theme');
|
28 |
|
|
|
29 |
fbde64c6
|
Andreas Kohlbecker
|
require_once('classes/footnotemanager.php');
|
30 |
|
|
require_once('classes/footnote.php');
|
31 |
a973da5b
|
Andreas Kohlbecker
|
require_once('classes/footnotekey.php');
|
32 |
80e0aa8e
|
Andreas Kohlbecker
|
require_once('classes/renderhints.php');
|
33 |
9cc1a3e2
|
Andreas Kohlbecker
|
|
34 |
9538b2a1
|
Andreas Kohlbecker
|
function _add_js_progressbar(){
|
35 |
95944919
|
Andreas Kohlbecker
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/jquery.progressbar/js/jquery.progressbar.js');
|
36 |
9538b2a1
|
Andreas Kohlbecker
|
}
|
37 |
|
|
|
38 |
1956d9b9
|
Andreas Kohlbecker
|
function _add_js_treeselector(){
|
39 |
95944919
|
Andreas Kohlbecker
|
//drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/treeselector.js');
|
40 |
|
|
drupal_add_js("
|
41 |
|
|
if (Drupal.jsEnabled) {
|
42 |
|
|
$(document).ready(function() {
|
43 |
|
|
$('#cdm-taxonomictree-selector-form #edit-val').change(function () {
|
44 |
|
|
$('#cdm-taxonomictree-selector-form').submit();
|
45 |
|
|
});
|
46 |
|
|
|
47 |
|
|
});
|
48 |
|
|
}", 'inline');
|
49 |
1956d9b9
|
Andreas Kohlbecker
|
}
|
50 |
|
|
|
51 |
80922b30
|
Andreas Kohlbecker
|
function _add_js_openlayers_map(){
|
52 |
|
|
|
53 |
95944919
|
Andreas Kohlbecker
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/OpenLayers/OpenLayers.js', 'core', 'header');
|
54 |
|
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/openlayers_map.js');
|
55 |
|
|
|
56 |
|
|
$gmap_api_key = variable_get('gmap_api_key', 'ABQIAAAAFho6eHAcUOTHLmH9IYHAeBRi_j0U6kJrkFvY4-OX2XYmEAa76BTsyMmEq-tn6nFNtD2UdEGvfhvoCQ');
|
57 |
|
|
|
58 |
|
|
$baseLayers = variable_get('baselayers', array());
|
59 |
|
|
if(!is_array($baseLayers) || count($baseLayers) == 0){
|
60 |
|
|
$baseLayers = array('metacarta_vmap0' => 'Metacarta Vmap0', 'PREFERRED' => 'metacarta_vmap0');
|
61 |
|
|
}
|
62 |
|
|
$layerNames = '';
|
63 |
|
|
foreach($baseLayers as $layerName => $layerLabel){
|
64 |
|
|
if($layerName == 'PREFERRED'){
|
65 |
|
|
$preferredLayer = $baseLayers['PREFERRED'];
|
66 |
|
|
} else {
|
67 |
|
|
$layerNames .= ($layerNames ? ', ': '') . "'$layerName'";
|
68 |
|
|
}
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
if( isset($baseLayers['gmap']) || isset($baseLayers['gsat']) || isset($baseLayers['ghyb']) ){
|
72 |
|
|
drupal_set_html_head('<script src=http://maps.google.com/maps?file=api&v=2&sensor=false&key='.$gmap_api_key.'" type="text/javascript"></script>');
|
73 |
|
|
drupal_set_html_head('<script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1" type="text/javascript"></script>');
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
drupal_add_js("
|
77 |
80922b30
|
Andreas Kohlbecker
|
if (Drupal.jsEnabled) {
|
78 |
|
|
$(document).ready(function() {
|
79 |
|
|
$('#openlayers_map').cdm_openlayers_map('"
|
80 |
|
|
.getEDITMapServiceURI()."', {
|
81 |
|
|
legendPosition: 3,
|
82 |
|
|
displayWidth: '" . variable_get('cdm_dataportal_geoservice_display_width', false) . "',
|
83 |
|
|
boundingBox: '" . variable_get('cdm_dataportal_geoservice_bounding_box', false) . "',
|
84 |
|
|
distributionOpacity: '" . variable_get('cdm_dataportal_geoservice_distributionOpacity', '0.5') . "',
|
85 |
|
|
legendOpacity: '" . variable_get('cdm_dataportal_geoservice_legendOpacity', '0.5') . "',
|
86 |
|
|
showLayerSwitcher: " . (variable_get('cdm_dataportal_geoservice_showLayerSwitcher', TRUE) ? 'true':'false') . ",
|
87 |
|
|
baseLayerNames: [".$layerNames."],
|
88 |
|
|
defaultBaseLayerName: '".$preferredLayer."',
|
89 |
|
|
});
|
90 |
|
|
});
|
91 |
|
|
}", 'inline');
|
92 |
|
|
|
93 |
|
|
}
|
94 |
|
|
|
95 |
9538b2a1
|
Andreas Kohlbecker
|
|
96 |
90713556
|
Andreas Kohlbecker
|
function get_openlayers_map($width, $occurrenceQuery = false, $distributionQuery = false, $legendFormatQuery = false, $map_caption = false ){
|
97 |
|
|
|
98 |
95944919
|
Andreas Kohlbecker
|
_add_js_openlayers_map();
|
99 |
|
|
|
100 |
|
|
$out = '<div id="openlayers">';
|
101 |
|
|
$out .= '<div id="openlayers_map" class="smallmap"';
|
102 |
|
|
$out .= ' style="width: ' . $width . 'px; height:'.( $width / 2).'px"';
|
103 |
|
|
if($occurrenceQuery){
|
104 |
|
|
|
105 |
|
|
//fix $occurrenceQuery
|
106 |
|
|
$occurrenceQuery .= '&ms=400,350';
|
107 |
|
|
$occurrenceQuery .= '&l=v%3Aatbi%2Ce_w_0';
|
108 |
|
|
$occurrenceQuery .= '&legend=0'; //TODO add to cdm service?
|
109 |
|
|
|
110 |
|
|
$out .= ' occurrenceQuery="'.$occurrenceQuery.'"';
|
111 |
|
|
}
|
112 |
|
|
if($distributionQuery){
|
113 |
|
|
$out .= ' distributionQuery="'.$distributionQuery.'"';
|
114 |
|
|
}
|
115 |
|
|
if($legendFormatQuery){
|
116 |
|
|
$out .= ' legendFormatQuery="'.$legendFormatQuery.'"';
|
117 |
|
|
}
|
118 |
|
|
$out .= '></div></div>';
|
119 |
|
|
|
120 |
|
|
// showing map caption
|
121 |
|
|
if($map_caption){
|
122 |
|
|
$out .= '<div class="distribution_map_caption">' . $map_caption . '</div>' . '<br />'; //FIXME: replace <br> by according css style
|
123 |
|
|
$out .= '</div>';
|
124 |
|
|
}
|
125 |
|
|
return $out;
|
126 |
90713556
|
Andreas Kohlbecker
|
}
|
127 |
|
|
|
128 |
67a4a4c6
|
Andreas Kohlbecker
|
/* ====================== hook implementations ====================== */
|
129 |
9cc1a3e2
|
Andreas Kohlbecker
|
|
130 |
|
|
|
131 |
|
|
/**
|
132 |
bf910101
|
Andreas Kohlbecker
|
* Implementation of hook_perm()
|
133 |
67a4a4c6
|
Andreas Kohlbecker
|
*
|
134 |
9cc1a3e2
|
Andreas Kohlbecker
|
* Valid permissions for this module
|
135 |
|
|
* @return array An array of valid permissions for the portfolio module
|
136 |
|
|
*/
|
137 |
|
|
function cdm_dataportal_perm() {
|
138 |
95944919
|
Andreas Kohlbecker
|
return array(
|
139 |
|
|
'administer cdm_dataportal',
|
140 |
ba2bca28
|
Andreas Kohlbecker
|
'cdm_dataportal view notes',
|
141 |
95944919
|
Andreas Kohlbecker
|
//TODO which else permission are required? -> check the WP6 requirements document
|
142 |
|
|
);
|
143 |
9cc1a3e2
|
Andreas Kohlbecker
|
}
|
144 |
|
|
|
145 |
|
|
|
146 |
|
|
/**
|
147 |
bf910101
|
Andreas Kohlbecker
|
* Implementation of hook_menu()
|
148 |
9cc1a3e2
|
Andreas Kohlbecker
|
*/
|
149 |
|
|
function cdm_dataportal_menu($may_cache) {
|
150 |
95944919
|
Andreas Kohlbecker
|
$items = array();
|
151 |
67a4a4c6
|
Andreas Kohlbecker
|
|
152 |
95944919
|
Andreas Kohlbecker
|
cdm_dataportal_menu_admin($may_cache, $items);
|
153 |
|
|
cdm_dataportal_menu_help($may_cache, $items);
|
154 |
23f32680
|
f.revilla
|
|
155 |
95944919
|
Andreas Kohlbecker
|
if ($may_cache) {
|
156 |
23f32680
|
f.revilla
|
|
157 |
95944919
|
Andreas Kohlbecker
|
$items[] = array(
|
158 |
|
|
'path' => 'cdm_dataportal/names',
|
159 |
|
|
'callback' => 'cdm_dataportal_view_names',
|
160 |
|
|
'access' => true,
|
161 |
|
|
'type' => MENU_CALLBACK,
|
162 |
|
|
);
|
163 |
|
|
// optional callback arguments: page
|
164 |
90713556
|
Andreas Kohlbecker
|
|
165 |
95944919
|
Andreas Kohlbecker
|
$items[] = array(
|
166 |
4726aac7
|
Andreas Kohlbecker
|
'path' => 'cdm_dataportal/taxon',
|
167 |
8ff851c6
|
Andreas Kohlbecker
|
'callback' => 'cdm_dataportal_taxon_page_view',
|
168 |
4726aac7
|
Andreas Kohlbecker
|
'access' => true,
|
169 |
|
|
'type' => MENU_CALLBACK,
|
170 |
95944919
|
Andreas Kohlbecker
|
// expected callback arguments: uuid
|
171 |
|
|
);
|
172 |
05166aee
|
f.revilla
|
|
173 |
95944919
|
Andreas Kohlbecker
|
$items[] = array(
|
174 |
57e2ea1f
|
f.revilla
|
'path' => 'cdm_dataportal/name',
|
175 |
|
|
'callback' => 'cdm_dataportal_name_page_view',
|
176 |
|
|
'access' => true,
|
177 |
|
|
'type' => MENU_CALLBACK,
|
178 |
95944919
|
Andreas Kohlbecker
|
// expected callback arguments: uuid
|
179 |
|
|
);
|
180 |
63fe0c43
|
f.revilla
|
|
181 |
95944919
|
Andreas Kohlbecker
|
$items[] = array(
|
182 |
4726aac7
|
Andreas Kohlbecker
|
'path' => 'cdm_dataportal/reference',
|
183 |
|
|
'callback' => 'cdm_dataportal_view_reference',
|
184 |
|
|
'access' => true,
|
185 |
|
|
'type' => MENU_CALLBACK,
|
186 |
95944919
|
Andreas Kohlbecker
|
// expected callback arguments: uuid
|
187 |
|
|
);
|
188 |
63fe0c43
|
f.revilla
|
|
189 |
95944919
|
Andreas Kohlbecker
|
$items[] = array(
|
190 |
46a52efe
|
Andreas Kohlbecker
|
'path' => 'cdm_dataportal/reference/list',
|
191 |
|
|
'callback' => 'cdm_dataportal_view_reference_list',
|
192 |
|
|
'access' => true,
|
193 |
|
|
'type' => MENU_CALLBACK,
|
194 |
95944919
|
Andreas Kohlbecker
|
// expected callback arguments: uuid
|
195 |
|
|
);
|
196 |
63fe0c43
|
f.revilla
|
|
197 |
95944919
|
Andreas Kohlbecker
|
$items[] = array(
|
198 |
2cd9a3d6
|
Andreas Kohlbecker
|
'path' => 'cdm_dataportal/media',
|
199 |
|
|
'callback' => 'cdm_dataportal_view_media',
|
200 |
|
|
'access' => true,
|
201 |
|
|
'type' => MENU_CALLBACK,
|
202 |
95944919
|
Andreas Kohlbecker
|
// expected callback arguments: uuid, mediarepresentation_uuid, part_uuid or part#
|
203 |
|
|
);
|
204 |
63fe0c43
|
f.revilla
|
|
205 |
95944919
|
Andreas Kohlbecker
|
$items[] = array(
|
206 |
2264b60d
|
Andreas Kohlbecker
|
'path' => 'cdm_dataportal/polytomousKey',
|
207 |
|
|
'callback' => 'cdm_dataportal_view_polytomousKey',
|
208 |
|
|
'access' => true,
|
209 |
|
|
'type' => MENU_CALLBACK,
|
210 |
|
|
// expected callback arguments: polytomousKey->uuid
|
211 |
|
|
);
|
212 |
|
|
|
213 |
95944919
|
Andreas Kohlbecker
|
$items[] = array(
|
214 |
2447830d
|
Andreas Kohlbecker
|
'path' => 'cdm_dataportal/search',
|
215 |
|
|
'callback' => 'cdm_dataportal_view_search_advanced',
|
216 |
|
|
'access' => true,
|
217 |
|
|
'type' => MENU_CALLBACK,
|
218 |
95944919
|
Andreas Kohlbecker
|
);
|
219 |
63fe0c43
|
f.revilla
|
|
220 |
95944919
|
Andreas Kohlbecker
|
$items[] = array(
|
221 |
ee99abea
|
Andreas Kohlbecker
|
'path' => 'cdm_dataportal/search/taxon',
|
222 |
|
|
'callback' => 'cdm_dataportal_view_search_taxon',
|
223 |
|
|
'access' => true,
|
224 |
94112bee
|
n.hoffmann
|
'type' => MENU_CALLBACK,
|
225 |
95944919
|
Andreas Kohlbecker
|
);
|
226 |
05166aee
|
f.revilla
|
|
227 |
95944919
|
Andreas Kohlbecker
|
$items[] = array(
|
228 |
05fe0ad6
|
Andreas Kohlbecker
|
'path' => 'cdm/xml2json',
|
229 |
|
|
'callback' => 'cdm_view_xml2json',
|
230 |
|
|
'access' => true,
|
231 |
94112bee
|
n.hoffmann
|
'type' => MENU_CALLBACK,
|
232 |
95944919
|
Andreas Kohlbecker
|
);
|
233 |
63fe0c43
|
f.revilla
|
|
234 |
95944919
|
Andreas Kohlbecker
|
}elseif (arg(0)=='user' && ($uid=arg(1)) && is_numeric($uid)) {
|
235 |
|
|
//user configuration of cdm_dataportal
|
236 |
|
|
$items[] = array('path' => 'user/'.$uid.'/cdm_dataportal',
|
237 |
334d4cd4
|
f.revilla
|
'title' => t('cdm_dataportal'),
|
238 |
|
|
'access' => TRUE,
|
239 |
|
|
'callback' => 'drupal_get_form',
|
240 |
b1005644
|
f.revilla
|
'callback arguments' => array('cdm_dataportal_user_form'),
|
241 |
334d4cd4
|
f.revilla
|
'type' => MENU_LOCAL_TASK,
|
242 |
|
|
'weight' => 10,
|
243 |
|
|
);
|
244 |
95944919
|
Andreas Kohlbecker
|
} else {
|
245 |
|
|
// may not cache
|
246 |
|
|
// --- local tasks for Taxon
|
247 |
|
|
$items[] = array(
|
248 |
57e2ea1f
|
f.revilla
|
'path' => 'cdm_dataportal/name/'.arg(2),
|
249 |
95944919
|
Andreas Kohlbecker
|
//'callback' => 'cdm_dataportal_view_name',
|
250 |
|
|
'callback' => 'cdm_dataportal_name_page_view',
|
251 |
bd379106
|
f.revilla
|
'callback arguments' => array(arg(2), arg(3), arg(4)),
|
252 |
57e2ea1f
|
f.revilla
|
'access' => true,
|
253 |
|
|
'type' => MENU_CALLBACK,
|
254 |
95944919
|
Andreas Kohlbecker
|
);
|
255 |
05166aee
|
f.revilla
|
|
256 |
95944919
|
Andreas Kohlbecker
|
if(variable_get('cdm_dataportal_taxonpage_tabs', 1)) {
|
257 |
63fe0c43
|
f.revilla
|
|
258 |
95944919
|
Andreas Kohlbecker
|
$items[] = array(
|
259 |
4726aac7
|
Andreas Kohlbecker
|
'path' => 'cdm_dataportal/taxon/'.arg(2),
|
260 |
0d127818
|
Andreas Kohlbecker
|
'title' => theme('cdm_taxonpage_tab', 'General'),
|
261 |
8ff851c6
|
Andreas Kohlbecker
|
'callback' => 'cdm_dataportal_taxon_page_view',
|
262 |
4726aac7
|
Andreas Kohlbecker
|
'access' => true,
|
263 |
|
|
'type' => MENU_CALLBACK,
|
264 |
3cf0dec2
|
Andreas Kohlbecker
|
'weight' => 1,
|
265 |
24b09d7c
|
Andreas Kohlbecker
|
'callback arguments' => array(arg(2), "description")
|
266 |
95944919
|
Andreas Kohlbecker
|
// expected callback arguments: name_uuid
|
267 |
|
|
);
|
268 |
63fe0c43
|
f.revilla
|
|
269 |
95944919
|
Andreas Kohlbecker
|
$items[] = array(
|
270 |
9538b2a1
|
Andreas Kohlbecker
|
'path' => 'cdm_dataportal/taxon/'.arg(2).'/all',
|
271 |
|
|
'title' => theme('cdm_taxonpage_tab', 'General'),
|
272 |
|
|
'callback' => 'cdm_dataportal_taxon_page_view',
|
273 |
|
|
'access' => true,
|
274 |
|
|
'type' => MENU_CALLBACK,
|
275 |
|
|
'weight' => 2,
|
276 |
|
|
'callback arguments' => array(arg(2), "all")
|
277 |
95944919
|
Andreas Kohlbecker
|
// expected callback arguments: name_uuid
|
278 |
|
|
);
|
279 |
23f32680
|
f.revilla
|
|
280 |
95944919
|
Andreas Kohlbecker
|
$items[] = array(
|
281 |
4726aac7
|
Andreas Kohlbecker
|
'path' => 'cdm_dataportal/taxon/'.arg(2).'/description',
|
282 |
0d127818
|
Andreas Kohlbecker
|
'title' => theme('cdm_taxonpage_tab', 'General'),
|
283 |
8ff851c6
|
Andreas Kohlbecker
|
'callback' => 'cdm_dataportal_taxon_page_view',
|
284 |
4726aac7
|
Andreas Kohlbecker
|
'access' => true,
|
285 |
|
|
'type' => MENU_DEFAULT_LOCAL_TASK,
|
286 |
3cf0dec2
|
Andreas Kohlbecker
|
'weight' => 2,
|
287 |
4726aac7
|
Andreas Kohlbecker
|
'callback arguments' => array(arg(2), "description")
|
288 |
95944919
|
Andreas Kohlbecker
|
// expected callback arguments: name_uuid
|
289 |
|
|
);
|
290 |
63fe0c43
|
f.revilla
|
|
291 |
95944919
|
Andreas Kohlbecker
|
$items[] = array(
|
292 |
3cf0dec2
|
Andreas Kohlbecker
|
'path' => 'cdm_dataportal/taxon/'.arg(2).'/synonymy',
|
293 |
0d127818
|
Andreas Kohlbecker
|
'title' => theme('cdm_taxonpage_tab', 'Synonymy'),
|
294 |
8ff851c6
|
Andreas Kohlbecker
|
'callback' => 'cdm_dataportal_taxon_page_view',
|
295 |
4726aac7
|
Andreas Kohlbecker
|
'access' => true,
|
296 |
|
|
'type' => MENU_LOCAL_TASK,
|
297 |
27b71dd0
|
f.revilla
|
'weight' => 4,
|
298 |
|
|
'callback arguments' => array(arg(2), "synonymy", arg(4))
|
299 |
95944919
|
Andreas Kohlbecker
|
// expected callback arguments: name_uuid
|
300 |
|
|
);
|
301 |
|
|
$items[] = array(
|
302 |
3cf0dec2
|
Andreas Kohlbecker
|
'path' => 'cdm_dataportal/taxon/'.arg(2).'/images',
|
303 |
0d127818
|
Andreas Kohlbecker
|
'title' => theme('cdm_taxonpage_tab', 'Images'),
|
304 |
8ff851c6
|
Andreas Kohlbecker
|
'callback' => 'cdm_dataportal_taxon_page_view',
|
305 |
4726aac7
|
Andreas Kohlbecker
|
'access' => true,
|
306 |
|
|
'type' => MENU_LOCAL_TASK,
|
307 |
27b71dd0
|
f.revilla
|
'weight' => 5,
|
308 |
3cf0dec2
|
Andreas Kohlbecker
|
'callback arguments' => array(arg(2), "images")
|
309 |
95944919
|
Andreas Kohlbecker
|
// expected callback arguments: name_uuid
|
310 |
|
|
);
|
311 |
|
|
|
312 |
|
|
$items[] = array(
|
313 |
|
|
'path' => 'cdm_dataportal/taxon/'.arg(2).'/specimens',
|
314 |
|
|
'title' => theme('cdm_taxonpage_tab', 'Specimens'),
|
315 |
|
|
'callback' => 'cdm_dataportal_taxon_page_view',
|
316 |
|
|
'access' => true,
|
317 |
|
|
'type' => MENU_LOCAL_TASK,
|
318 |
|
|
'weight' => 6,
|
319 |
|
|
'callback arguments' => array(arg(2), "specimens")
|
320 |
|
|
// expected callback arguments: name_uuid
|
321 |
|
|
);
|
322 |
|
|
|
323 |
|
|
$items[] = array(
|
324 |
2d284a25
|
Andreas Kohlbecker
|
'path' => 'cdm_dataportal/taxon/'.arg(2).'/keys',
|
325 |
|
|
'title' => theme('cdm_taxonpage_tab', 'Keys'),
|
326 |
|
|
'callback' => 'cdm_dataportal_taxon_page_view',
|
327 |
|
|
'access' => true,
|
328 |
|
|
'type' => MENU_LOCAL_TASK,
|
329 |
|
|
'weight' => 6,
|
330 |
|
|
'callback arguments' => array(arg(2), "keys")
|
331 |
|
|
// expected callback arguments: name_uuid
|
332 |
|
|
);
|
333 |
95944919
|
Andreas Kohlbecker
|
}
|
334 |
|
|
}
|
335 |
63fe0c43
|
f.revilla
|
|
336 |
95944919
|
Andreas Kohlbecker
|
drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/cdm_dataportal.css');
|
337 |
|
|
//drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/cdm_dataportal_print.css', 'print');
|
338 |
|
|
drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/cdm_dataportal_screen.css', 'screen');
|
339 |
63fe0c43
|
f.revilla
|
|
340 |
95944919
|
Andreas Kohlbecker
|
return $items;
|
341 |
63fe0c43
|
f.revilla
|
|
342 |
9cc1a3e2
|
Andreas Kohlbecker
|
}
|
343 |
b1005644
|
f.revilla
|
/**
|
344 |
|
|
* The function generate form for own user cdm dataportal configurations
|
345 |
|
|
*/
|
346 |
|
|
function cdm_dataportal_user_form() {
|
347 |
6cb938a3
|
Andreas Kohlbecker
|
|
348 |
95944919
|
Andreas Kohlbecker
|
global $user;
|
349 |
d6627975
|
f.revilla
|
$checkbox_value = 'cdm_dataportal_' .$user->uid . '_default_tab_active';
|
350 |
6cb938a3
|
Andreas Kohlbecker
|
|
351 |
95944919
|
Andreas Kohlbecker
|
$form['check'] = array
|
352 |
d6627975
|
f.revilla
|
(
|
353 |
|
|
'#type' => 'checkbox',
|
354 |
|
|
'#title' => t('Activate user default configuration'),
|
355 |
|
|
'#default_value' => variable_get($checkbox_value, 0),
|
356 |
|
|
'#description' => t('Check this if you want configure your own default tab from the below menu.')
|
357 |
|
|
);
|
358 |
6cb938a3
|
Andreas Kohlbecker
|
|
359 |
95944919
|
Andreas Kohlbecker
|
$form['cdm_dataportal_user_form'] = array(
|
360 |
334d4cd4
|
f.revilla
|
'#type' => 'select',
|
361 |
|
|
'#title' => t('Default tab to display'),
|
362 |
95944919
|
Andreas Kohlbecker
|
'#default_value' => get_default_taxon_tab(true),
|
363 |
334d4cd4
|
f.revilla
|
'#options' => unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB),
|
364 |
|
|
'#description' => t('<p>Select the default tab to display when visiting a taxon page. Only available if Tabbed Taxon Page is enable.</p>
|
365 |
|
|
<strong>Note:</strong> After performing a search and clicking in any synonym, the taxon tab
|
366 |
|
|
to be renderized will be the synonymy of the accepted taxon and not the above selected tab.'),
|
367 |
95944919
|
Andreas Kohlbecker
|
);
|
368 |
34ad5ce6
|
Andreas Kohlbecker
|
|
369 |
95944919
|
Andreas Kohlbecker
|
$form['submit'] = array(
|
370 |
|
|
'#type' => 'submit',
|
371 |
|
|
'#value' => t('Submit')
|
372 |
|
|
);
|
373 |
34ad5ce6
|
Andreas Kohlbecker
|
|
374 |
95944919
|
Andreas Kohlbecker
|
return $form;
|
375 |
334d4cd4
|
f.revilla
|
}
|
376 |
|
|
|
377 |
b1005644
|
f.revilla
|
/**
|
378 |
34ad5ce6
|
Andreas Kohlbecker
|
* The function submit the user cdm dataportal configurations
|
379 |
b1005644
|
f.revilla
|
* @param unknown_type $form
|
380 |
|
|
* @param unknown_type $form_values
|
381 |
|
|
*/
|
382 |
95bcb485
|
f.revilla
|
function cdm_dataportal_user_form_submit($form, $form_values) {
|
383 |
95944919
|
Andreas Kohlbecker
|
global $user;
|
384 |
|
|
$msg_type = 'status';
|
385 |
|
|
$username = $user->name;
|
386 |
|
|
$variable_to_use = 'cdm_dataportal_' .$user->uid . '_default_tab';
|
387 |
|
|
|
388 |
|
|
//if is the right user the variables are setted
|
389 |
|
|
if (arg(0)=='user' && ($uid=arg(1)) && is_numeric($uid) && $user->uid==$uid){
|
390 |
|
|
$variable = unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB);
|
391 |
|
|
variable_set($variable_to_use . '_active', $form_values['check']);
|
392 |
|
|
variable_set($variable_to_use, $form_values['cdm_dataportal_user_form']);
|
393 |
|
|
if ($form_values['check']){
|
394 |
|
|
drupal_set_message('The user default tab will be used for the next taxon site visit.');
|
395 |
|
|
drupal_set_message('The user default tab have been changed to: '
|
396 |
d6627975
|
f.revilla
|
. $variable[variable_get($variable_to_use, 0)]
|
397 |
|
|
. ' for the user ' . $username, $msg_type);
|
398 |
95944919
|
Andreas Kohlbecker
|
}else{
|
399 |
|
|
drupal_set_message('The user default tab wont be used for the next taxon site, check the box if you want to use the user default configuration.');
|
400 |
|
|
}
|
401 |
|
|
//problem with the user id => variables wont be saved
|
402 |
|
|
}else{
|
403 |
|
|
$msg_type = 'warning';
|
404 |
|
|
drupal_set_message('Default tab have not been saved due to user id problems', $msg_type);
|
405 |
|
|
}
|
406 |
334d4cd4
|
f.revilla
|
}
|
407 |
|
|
|
408 |
d946105e
|
Andreas Kohlbecker
|
/**
|
409 |
|
|
* Implementation of hook_block()
|
410 |
67a4a4c6
|
Andreas Kohlbecker
|
*
|
411 |
d946105e
|
Andreas Kohlbecker
|
* Provides the following blocks:
|
412 |
|
|
* 0: list of links useful during development
|
413 |
|
|
*
|
414 |
|
|
* @param String $op
|
415 |
|
|
* @param int $delta
|
416 |
|
|
*/
|
417 |
|
|
function cdm_dataportal_block($op='list', $delta=0) {
|
418 |
95944919
|
Andreas Kohlbecker
|
// listing of blocks, such as on the admin/block page
|
419 |
|
|
if ($op == "list") {
|
420 |
|
|
//$block[0]["info"] = t("CDM DataPortal DevLinks");
|
421 |
|
|
// $block[1]["info"] = t("CDM DataPortal Credits");
|
422 |
|
|
$block[2]["info"] = t("CDM Search Taxa");
|
423 |
|
|
//$block[3]["info"] = t("CDM Filters");
|
424 |
|
|
$block[4]["info"] = t("CDM Dataportal Print");
|
425 |
|
|
$block["keys"]["info"] = t("CDM identification keys");
|
426 |
|
|
return $block;
|
427 |
|
|
}
|
428 |
|
|
else if ($op == 'view') {
|
429 |
|
|
switch($delta){
|
430 |
|
|
// case 1:
|
431 |
|
|
// $block['subject'] = t('Credits');
|
432 |
|
|
// $block['content'] = theme('cdm_credits');
|
433 |
|
|
// return $block;
|
434 |
|
|
case 2:
|
435 |
|
|
$block['subject'] = t('Search taxa');
|
436 |
|
|
$block['content'] = drupal_get_form('cdm_dataportal_search_taxon_form');
|
437 |
|
|
if (variable_get('cdm_dataportal_show_advanced_search', 1)){
|
438 |
|
|
$block['content'] .= '<div>'.l('Advanced Search', '/cdm_dataportal/search').'</div>';
|
439 |
|
|
}
|
440 |
|
|
return $block;
|
441 |
|
|
case 4:
|
442 |
|
|
$block['subject'] = t('<none>');
|
443 |
|
|
$block['content'] = theme('cdm_print_button');;
|
444 |
|
|
return $block;
|
445 |
|
|
case "keys":
|
446 |
|
|
$block['subject'] = t('Identification Keys');
|
447 |
2d284a25
|
Andreas Kohlbecker
|
$block['content'] = theme('cdm_block_IdentificationKeys');
|
448 |
|
|
return $block;
|
449 |
95944919
|
Andreas Kohlbecker
|
}
|
450 |
|
|
}
|
451 |
d946105e
|
Andreas Kohlbecker
|
}
|
452 |
|
|
|
453 |
9cc1a3e2
|
Andreas Kohlbecker
|
|
454 |
63fe0c43
|
f.revilla
|
|
455 |
|
|
/*
|
456 |
|
|
function cdm_dataportal_session_clear($cdm_ws_uri_update = false){
|
457 |
|
|
$_SESSION['cdm'] = null;
|
458 |
|
|
if(is_string($cdm_ws_uri_update)){
|
459 |
|
|
$_SESSION['cdm'] = array('ws_uri'=>$cdm_ws_uri_update);
|
460 |
|
|
}
|
461 |
|
|
}
|
462 |
|
|
|
463 |
|
|
function cdm_dataportal_session_validate(){
|
464 |
|
|
|
465 |
|
|
if(!isset($_SESSION['cdm']['ws_uri'])){
|
466 |
|
|
$_SESSION['cdm'] = array('ws_uri'=>variable_get('cdm_webservice_url', false));
|
467 |
|
|
} else if($_SESSION['cdm']['ws_uri'] != variable_get('cdm_webservice_url', false)){
|
468 |
|
|
cdm_dataportal_session_clear(variable_get('cdm_webservice_url', false));
|
469 |
|
|
}
|
470 |
|
|
}
|
471 |
|
|
*/
|
472 |
812a9c04
|
Andreas Kohlbecker
|
|
473 |
2447830d
|
Andreas Kohlbecker
|
function cdm_dataportal_search_taxon_form($advancedForm = false){
|
474 |
63fe0c43
|
f.revilla
|
|
475 |
95944919
|
Andreas Kohlbecker
|
$preset_query = (isset($_SESSION['cdm']['search']['query']) ? $_SESSION['cdm']['search']['query'] : '');
|
476 |
|
|
$preset_doTaxa = (isset($_SESSION['cdm']['search']['doTaxa']) ? 1 : 0);
|
477 |
|
|
$preset_doSynonyms = (isset($_SESSION['cdm']['search']['doSynonyms']) ? 1 : 0);
|
478 |
|
|
$preset_doTaxaByCommonNames = (isset($_SESSION['cdm']['search']['doTaxaByCommonNames']) ? 1 : 0);
|
479 |
|
|
$tdwg_level_select = (isset($_SESSION['cdm']['search']['tdwg_level_select']) ? $_SESSION['cdm']['search']['tdwg_level_select'] : 2);
|
480 |
|
|
$selected_areas = (isset($_SESSION['cdm']['search']['area']) ? $_SESSION['cdm']['search']['area'] : false);
|
481 |
63fe0c43
|
f.revilla
|
|
482 |
95944919
|
Andreas Kohlbecker
|
$url = 'cdm_dataportal/search/taxon';
|
483 |
|
|
$form['#method'] = 'get';
|
484 |
|
|
$form['#process'] = array('cdm_dataportal_search_process' => array());
|
485 |
|
|
$form['#action'] = url($url, NULL, NULL, true);
|
486 |
63fe0c43
|
f.revilla
|
|
487 |
95944919
|
Andreas Kohlbecker
|
$form['query'] = array(
|
488 |
2447830d
|
Andreas Kohlbecker
|
'#delta' => 0,
|
489 |
ee99abea
|
Andreas Kohlbecker
|
'#type' => 'textfield',
|
490 |
|
|
'#size' => 20,
|
491 |
304cdf42
|
Andreas Kohlbecker
|
'#attributes' => array('title' => t('Enter the name or part of a name you wish to search for. The asterisk character * can always be used as wildcard')),
|
492 |
2447830d
|
Andreas Kohlbecker
|
'#value' => $preset_query,
|
493 |
95944919
|
Andreas Kohlbecker
|
);
|
494 |
63fe0c43
|
f.revilla
|
|
495 |
95944919
|
Andreas Kohlbecker
|
$form['search'] = array(
|
496 |
2447830d
|
Andreas Kohlbecker
|
'#delta' => 1,
|
497 |
|
|
'#tree' => true,
|
498 |
95944919
|
Andreas Kohlbecker
|
//'#type' => $advancedForm ? 'fieldset': 'hidden',
|
499 |
2447830d
|
Andreas Kohlbecker
|
'#title' => t('Options')
|
500 |
95944919
|
Andreas Kohlbecker
|
);
|
501 |
63fe0c43
|
f.revilla
|
|
502 |
95944919
|
Andreas Kohlbecker
|
$form['search']['tree'] = array(
|
503 |
8934f97c
|
Andreas Kohlbecker
|
'#delta' => -1,
|
504 |
|
|
'#type' => 'hidden',
|
505 |
1956d9b9
|
Andreas Kohlbecker
|
'#value' => get_taxonomictree_uuid_selected()
|
506 |
95944919
|
Andreas Kohlbecker
|
);
|
507 |
63fe0c43
|
f.revilla
|
|
508 |
|
|
|
509 |
95944919
|
Andreas Kohlbecker
|
// clean URL get forms breaks if we don't give it a 'q'.
|
510 |
|
|
if (!(bool)variable_get('clean_url', '0')) {
|
511 |
|
|
$form['search']['q'] = array(
|
512 |
2447830d
|
Andreas Kohlbecker
|
'#delta' => -1,
|
513 |
6611904c
|
Andreas Kohlbecker
|
'#type' => 'hidden',
|
514 |
|
|
'#value' => $url,
|
515 |
|
|
'#name' => 'q',
|
516 |
95944919
|
Andreas Kohlbecker
|
);
|
517 |
|
|
}
|
518 |
63fe0c43
|
f.revilla
|
|
519 |
95944919
|
Andreas Kohlbecker
|
$form['search']['pageSize'] = array(
|
520 |
2447830d
|
Andreas Kohlbecker
|
'#delta' => -1,
|
521 |
|
|
'#type' => 'hidden',
|
522 |
|
|
'#value' => variable_get('cdm_dataportal_search_items_on_page', 25)
|
523 |
95944919
|
Andreas Kohlbecker
|
);
|
524 |
2447830d
|
Andreas Kohlbecker
|
|
525 |
95944919
|
Andreas Kohlbecker
|
$form['search']['pageNumber'] = array(
|
526 |
2d284a25
|
Andreas Kohlbecker
|
'#delta' => -1,
|
527 |
|
|
'#type' => 'hidden',
|
528 |
|
|
'#value' => 0
|
529 |
|
|
);
|
530 |
|
|
|
531 |
95944919
|
Andreas Kohlbecker
|
if($advancedForm){
|
532 |
|
|
// general search parameters
|
533 |
|
|
$form['search']['doTaxa'] = array(
|
534 |
2447830d
|
Andreas Kohlbecker
|
'#delta' => 2,
|
535 |
|
|
'#type' => 'checkbox',
|
536 |
|
|
'#title' => t('Search for accepted taxa'),
|
537 |
|
|
'#value' => $preset_doTaxa
|
538 |
95944919
|
Andreas Kohlbecker
|
);
|
539 |
|
|
$form['search']['doSynonyms'] = array(
|
540 |
2447830d
|
Andreas Kohlbecker
|
'#delta' => 3,
|
541 |
|
|
'#type' => 'checkbox',
|
542 |
|
|
'#title' => t('Search for synonyms'),
|
543 |
|
|
'#value' => $preset_doSynonyms
|
544 |
95944919
|
Andreas Kohlbecker
|
);
|
545 |
|
|
$form['search']['doTaxaByCommonNames'] = array(
|
546 |
2447830d
|
Andreas Kohlbecker
|
'#delta' => 4,
|
547 |
|
|
'#type' => 'checkbox',
|
548 |
|
|
'#title' => t('Search for common names'),
|
549 |
|
|
'#value' => $preset_doTaxaByCommonNames
|
550 |
95944919
|
Andreas Kohlbecker
|
);
|
551 |
90713556
|
Andreas Kohlbecker
|
|
552 |
95944919
|
Andreas Kohlbecker
|
// Geographic Range
|
553 |
|
|
$form['search']['geographic_range'] = array(
|
554 |
8934f97c
|
Andreas Kohlbecker
|
'#type' => 'fieldset',
|
555 |
|
|
'#delta' => 5,
|
556 |
|
|
'#tree' => true,
|
557 |
|
|
'#title' => t('Geographic range'),
|
558 |
95944919
|
Andreas Kohlbecker
|
);
|
559 |
63fe0c43
|
f.revilla
|
|
560 |
95944919
|
Andreas Kohlbecker
|
$form['search']['geographic_range']['tdwg_level_select'] = array(
|
561 |
8934f97c
|
Andreas Kohlbecker
|
'#type' => 'radios',
|
562 |
7e29aa4f
|
Andreas Kohlbecker
|
'#title' => t('Select a TDWG distribution level and code'),
|
563 |
8934f97c
|
Andreas Kohlbecker
|
'#default_value' => $tdwg_level_select,
|
564 |
|
|
'#options' => array(
|
565 |
95944919
|
Andreas Kohlbecker
|
t('TDWG level-1, i.e. a continent'),
|
566 |
|
|
t('TDWG level-2'),
|
567 |
|
|
t('TDWG level-3, i.e. a country'),
|
568 |
|
|
t('TDWG level-4')
|
569 |
|
|
)
|
570 |
|
|
);
|
571 |
|
|
$tdwg[1] = cdm_ws_get(CDM_WS_TDWG_LEVEL, '1');
|
572 |
|
|
$tdwg[2] = cdm_ws_get(CDM_WS_TDWG_LEVEL, '2');
|
573 |
|
|
$tdwg[3] = cdm_ws_get(CDM_WS_TDWG_LEVEL, '3');
|
574 |
|
|
$tdwg[4] = cdm_ws_get(CDM_WS_TDWG_LEVEL, '4');
|
575 |
|
|
|
576 |
|
|
$tdwg_js = '';
|
577 |
|
|
foreach($tdwg as $key=>$tdwg_level){
|
578 |
|
|
$tdwgOptions = array();
|
579 |
|
|
$tdwgOptionsSelected = array();
|
580 |
|
|
foreach($tdwg_level as $area){
|
581 |
|
|
$representation = $area->representations[0];
|
582 |
|
|
$tdwgOptions[$representation->abbreviatedLabel] = $area->representation_L10n;
|
583 |
|
|
if(is_array($selected_areas) && in_array($representation->abbreviatedLabel, $selected_areas)){
|
584 |
|
|
$tdwgOptionsSelected[] = $representation->abbreviatedLabel; //$area->uuid;
|
585 |
|
|
}
|
586 |
|
|
}
|
587 |
|
|
asort($tdwgOptions);
|
588 |
|
|
$form['search']['geographic_range']['tdwg_level_'.$key] = array(
|
589 |
8934f97c
|
Andreas Kohlbecker
|
'#type' => 'select',
|
590 |
|
|
'#title' => t('TDWG level').' '.$key,
|
591 |
|
|
'#default_value' => $tdwgOptionsSelected,
|
592 |
90713556
|
Andreas Kohlbecker
|
'#multiple' => TRUE,
|
593 |
8934f97c
|
Andreas Kohlbecker
|
'#options' => $tdwgOptions
|
594 |
95944919
|
Andreas Kohlbecker
|
);
|
595 |
|
|
$tdwg_js .= "$('#edit-search-geographic-range-tdwg-level-$key').parent()".($tdwg_level_select + 1 == $key ? '.show()' : '.hide()'). ";\n";
|
596 |
|
|
}
|
597 |
8934f97c
|
Andreas Kohlbecker
|
|
598 |
95944919
|
Andreas Kohlbecker
|
drupal_add_js(
|
599 |
8934f97c
|
Andreas Kohlbecker
|
"$(document).ready(function(){
|
600 |
90713556
|
Andreas Kohlbecker
|
|
601 |
|
|
$(\"input[@name='search[geographic_range][tdwg_level_select]']\").change(
|
602 |
8934f97c
|
Andreas Kohlbecker
|
function(event){
|
603 |
|
|
var selectId = $(\"input[@name='search[geographic_range][tdwg_level_select]']:checked\").val();
|
604 |
|
|
var i;
|
605 |
|
|
for(i = 0; i < 4; i++){
|
606 |
|
|
if(selectId == i){
|
607 |
|
|
$('#edit-search-geographic-range-tdwg-level-' + (i + 1) ).parent().fadeIn('slow');
|
608 |
|
|
$('#edit-search-geographic-range-tdwg-level-' + (i + 1)).children().removeAttr('selected');
|
609 |
|
|
} else {
|
610 |
|
|
$('#edit-search-geographic-range-tdwg-level-' + (i + 1)).parent().fadeOut('slow');
|
611 |
|
|
$('#edit-search-geographic-range-tdwg-level-' + (i + 1)).children().removeAttr('selected');
|
612 |
|
|
}
|
613 |
|
|
}
|
614 |
|
|
}
|
615 |
|
|
);
|
616 |
90713556
|
Andreas Kohlbecker
|
|
617 |
63fe0c43
|
f.revilla
|
$tdwg_js
|
618 |
8934f97c
|
Andreas Kohlbecker
|
});",
|
619 |
|
|
'inline');
|
620 |
63fe0c43
|
f.revilla
|
|
621 |
95944919
|
Andreas Kohlbecker
|
} else {
|
622 |
|
|
$form['search']['doTaxa'] = array(
|
623 |
|
|
'#delta' => -2,
|
624 |
|
|
'#type' => 'hidden',
|
625 |
|
|
'#value' => 1
|
626 |
|
|
);
|
627 |
|
|
$form['search']['doSynonyms'] = array(
|
628 |
|
|
'#delta' => -3,
|
629 |
|
|
'#type' => 'hidden',
|
630 |
|
|
'#value' => 1
|
631 |
|
|
);
|
632 |
|
|
$form['search']['doTaxaByCommonNames'] = array(
|
633 |
|
|
'#delta' => -4,
|
634 |
|
|
'#type' => 'hidden',
|
635 |
|
|
'#value' => 0
|
636 |
|
|
);
|
637 |
|
|
}
|
638 |
|
|
|
639 |
|
|
$form['submit'] = array(
|
640 |
|
|
'#delta' => 9,
|
641 |
|
|
'#type' => 'submit',
|
642 |
|
|
'#name' => '',
|
643 |
|
|
'#value' => t('Search')
|
644 |
|
|
);
|
645 |
|
|
|
646 |
|
|
return $form;
|
647 |
ee99abea
|
Andreas Kohlbecker
|
}
|
648 |
|
|
|
649 |
2447830d
|
Andreas Kohlbecker
|
function cdm_dataportal_search_taxon_form_advanced(){
|
650 |
95944919
|
Andreas Kohlbecker
|
return cdm_dataportal_search_taxon_form(true);
|
651 |
2447830d
|
Andreas Kohlbecker
|
}
|
652 |
|
|
|
653 |
1956d9b9
|
Andreas Kohlbecker
|
function cdm_taxonomictree_selector(){
|
654 |
95944919
|
Andreas Kohlbecker
|
_add_js_treeselector();
|
655 |
05166aee
|
f.revilla
|
|
656 |
95944919
|
Andreas Kohlbecker
|
$out = drupal_get_form('cdm_taxonomictree_selector_form');
|
657 |
05166aee
|
f.revilla
|
|
658 |
95944919
|
Andreas Kohlbecker
|
return $out;
|
659 |
1956d9b9
|
Andreas Kohlbecker
|
}
|
660 |
|
|
|
661 |
|
|
|
662 |
|
|
function cdm_taxonomictree_selector_form(){
|
663 |
05166aee
|
f.revilla
|
|
664 |
95944919
|
Andreas Kohlbecker
|
$url = url('cdm_api/setvalue/session', null);
|
665 |
|
|
$form['#action'] = $url;
|
666 |
05166aee
|
f.revilla
|
|
667 |
95944919
|
Andreas Kohlbecker
|
$form['var'] = array(
|
668 |
1956d9b9
|
Andreas Kohlbecker
|
'#delta' => -3,
|
669 |
|
|
'#type' => 'hidden',
|
670 |
90713556
|
Andreas Kohlbecker
|
'#value' => '[cdm][taxonomictree_uuid]'
|
671 |
05166aee
|
f.revilla
|
);
|
672 |
|
|
|
673 |
80922b30
|
Andreas Kohlbecker
|
$form['destination'] = array(
|
674 |
95944919
|
Andreas Kohlbecker
|
'#delta' => -3,
|
675 |
|
|
'#type' => 'hidden',
|
676 |
|
|
'#value' => substr(drupal_get_destination(), strlen('destination='))
|
677 |
80922b30
|
Andreas Kohlbecker
|
);
|
678 |
70e50578
|
Andreas Kohlbecker
|
|
679 |
80922b30
|
Andreas Kohlbecker
|
$form['val'] = array(
|
680 |
70e50578
|
Andreas Kohlbecker
|
'#type' => 'select',
|
681 |
|
|
'#title' => t('Available classifications'),
|
682 |
|
|
'#default_value' => get_taxonomictree_uuid_selected(),
|
683 |
|
|
'#options' => cdm_get_taxontrees_as_options()
|
684 |
80922b30
|
Andreas Kohlbecker
|
);
|
685 |
05166aee
|
f.revilla
|
|
686 |
|
|
return $form;
|
687 |
|
|
|
688 |
1956d9b9
|
Andreas Kohlbecker
|
}
|
689 |
|
|
|
690 |
24b09d7c
|
Andreas Kohlbecker
|
/**
|
691 |
|
|
* Implementation #process method call, see form_builder()
|
692 |
|
|
* <p>
|
693 |
|
|
* Removes Drupal internal form elements from query
|
694 |
|
|
* @param $form
|
695 |
|
|
* @return unknown_type
|
696 |
|
|
*/
|
697 |
6611904c
|
Andreas Kohlbecker
|
function cdm_dataportal_search_process($form) {
|
698 |
95944919
|
Andreas Kohlbecker
|
unset($form['form_id']);
|
699 |
|
|
unset($form['form_token']);
|
700 |
|
|
return $form;
|
701 |
6611904c
|
Andreas Kohlbecker
|
}
|
702 |
|
|
|
703 |
|
|
/**
|
704 |
|
|
* Filters $_REQUEST by a list of valid request parameters and also sets defaults if required.
|
705 |
|
|
* returns the processed request parameters submitted by the search form.
|
706 |
|
|
*/
|
707 |
24b09d7c
|
Andreas Kohlbecker
|
function cdm_dataportal_search_form_request(){
|
708 |
daba333b
|
Andreas Kohlbecker
|
|
709 |
63fe0c43
|
f.revilla
|
|
710 |
95944919
|
Andreas Kohlbecker
|
$form_params = array();
|
711 |
|
|
array_deep_copy($_REQUEST['search'], $form_params);
|
712 |
|
|
$form_params['query'] = trim($_REQUEST['query']);
|
713 |
63fe0c43
|
f.revilla
|
|
714 |
95944919
|
Andreas Kohlbecker
|
// split of geographic range
|
715 |
|
|
if(isset($_REQUEST['search']['geographic_range'])){
|
716 |
|
|
$geographicRange = $_REQUEST['search']['geographic_range'];
|
717 |
|
|
// remove
|
718 |
|
|
unset($form_params['geographic_range']);
|
719 |
|
|
}
|
720 |
63fe0c43
|
f.revilla
|
|
721 |
95944919
|
Andreas Kohlbecker
|
// add geographic range
|
722 |
|
|
if($geographicRange){
|
723 |
|
|
$form_params['tdwg_level_select'] = $geographicRange['tdwg_level_select'];
|
724 |
|
|
for($i = 1; $i < 5; $i++){
|
725 |
|
|
if(isset($geographicRange['tdwg_level_'.$i])){
|
726 |
|
|
$form_params['area'] = $geographicRange['tdwg_level_'.$i];
|
727 |
|
|
}
|
728 |
|
|
}
|
729 |
|
|
}
|
730 |
63fe0c43
|
f.revilla
|
|
731 |
95944919
|
Andreas Kohlbecker
|
// store in session
|
732 |
|
|
$_SESSION['cdm']['search'] = $form_params;
|
733 |
63fe0c43
|
f.revilla
|
|
734 |
95944919
|
Andreas Kohlbecker
|
return $form_params;
|
735 |
6611904c
|
Andreas Kohlbecker
|
}
|
736 |
63fe0c43
|
f.revilla
|
|
737 |
6611904c
|
Andreas Kohlbecker
|
|
738 |
81df545f
|
Andreas Kohlbecker
|
/* UNREACHABLE since action of form directly links to view
|
739 |
63fe0c43
|
f.revilla
|
function cdm_dataportal_search_taxon_form_submit($form_id, $form_values) {
|
740 |
|
|
|
741 |
|
|
$_SESSION['cdm']['search'] = $form_values;
|
742 |
|
|
//return '/cdm_dataportal/search/taxon/'.$form_values['queryString'].'/'.($form_values['vernacular']?'1':'0').'/'.$form_values['language'];
|
743 |
|
|
return '/cdm_dataportal/search/taxon/'.$form_values['queryString'].'/'.($form_values['onlyAccepted']?'1':'0');
|
744 |
|
|
//$paramstr = compose_url_prameterstr($form_values);
|
745 |
|
|
//return url('/cdm_dataportal/search/taxon/', $paramstr);
|
746 |
|
|
}
|
747 |
|
|
*/
|
748 |
9cc1a3e2
|
Andreas Kohlbecker
|
/* ====================== menu callback functions ====================== */
|
749 |
|
|
|
750 |
80047c07
|
Andreas Kohlbecker
|
|
751 |
63fe0c43
|
f.revilla
|
|
752 |
c7e36592
|
Andreas Kohlbecker
|
function cdm_dataportal_form_alter($form_id, &$form) {
|
753 |
05166aee
|
f.revilla
|
|
754 |
95944919
|
Andreas Kohlbecker
|
static $comment_node_disabled = 0;
|
755 |
|
|
static $comment_node_read_only = 1;
|
756 |
|
|
static $comment_node_read_write = 2;
|
757 |
1f5b7a24
|
f.revilla
|
|
758 |
05166aee
|
f.revilla
|
|
759 |
95944919
|
Andreas Kohlbecker
|
if ($form_id == 'node_type_form'
|
760 |
|
|
&& isset($form['identity']['type'])
|
761 |
|
|
&& array_key_exists($form['#node_type']->type, cdm_get_nodetypes())
|
762 |
|
|
) {
|
763 |
|
|
$form['workflow']['comment'] = array(
|
764 |
c7e36592
|
Andreas Kohlbecker
|
'#type' => 'radios',
|
765 |
|
|
'#title' => t('Default comment setting'),
|
766 |
|
|
'#default_value' => variable_get('comment_'. $form['#node_type']->type, $comment_node_disabled),
|
767 |
|
|
'#options' => array(t('Disabled'), t('Read only'), t('Read/Write')),
|
768 |
|
|
'#description' => t('Users with the <em>administer comments</em> permission will be able to override this setting.'),
|
769 |
95944919
|
Andreas Kohlbecker
|
);
|
770 |
|
|
}
|
771 |
c7e36592
|
Andreas Kohlbecker
|
}
|
772 |
|
|
|
773 |
f8e0e210
|
Andreas Kohlbecker
|
|
774 |
3b8004d7
|
f.revilla
|
|
775 |
5b9dbe7f
|
f.revilla
|
function cdm_dataportal_create_gallery_settings_form($form_name, $form_tittle, $collapsed, $form_description = ''){
|
776 |
d74a6e65
|
Andreas Kohlbecker
|
//TODO move into settings.php
|
777 |
95944919
|
Andreas Kohlbecker
|
$form[$form_name] = array(
|
778 |
3b8004d7
|
f.revilla
|
'#type' => 'fieldset',
|
779 |
|
|
'#title' => t($form_tittle),
|
780 |
|
|
'#collapsible' => TRUE,
|
781 |
|
|
'#collapsed' => $collapsed,
|
782 |
|
|
'#tree' => true,
|
783 |
95944919
|
Andreas Kohlbecker
|
'#description' => t($form_description),
|
784 |
|
|
);
|
785 |
|
|
|
786 |
|
|
$default_values = unserialize(CDM_DATAPORTAL_GALLERY_SETTINGS);
|
787 |
|
|
$gallery_settings = variable_get($form_name, $default_values);
|
788 |
|
|
//$test = variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE);
|
789 |
|
|
|
790 |
|
|
if($form_name == CDM_DATAPORTAL_SEARCH_GALLERY_NAME){
|
791 |
|
|
/* TODO: why cdm_dataportal_search_items_on_page does not save the value on $test???
|
792 |
|
|
$form[$form_name]['cdm_dataportal_search_items_on_page'] = array(
|
793 |
|
|
'#type' => 'textfield',
|
794 |
|
|
'#title' => t('Search Page Size'),
|
795 |
|
|
'#default_value' => $test,
|
796 |
|
|
'#description' => t('Number of Names to display per page in search results.')
|
797 |
|
|
);
|
798 |
|
|
*/
|
799 |
|
|
$form[$form_name]['cdm_dataportal_show_taxon_thumbnails'] = array(
|
800 |
5f8edac5
|
Andreas Kohlbecker
|
'#type' => 'checkbox',
|
801 |
|
|
'#title' => t('Show media thumbnails for accepted taxa'),
|
802 |
|
|
'#default_value' => $gallery_settings['cdm_dataportal_show_taxon_thumbnails'],
|
803 |
95944919
|
Andreas Kohlbecker
|
);
|
804 |
3b8004d7
|
f.revilla
|
|
805 |
95944919
|
Andreas Kohlbecker
|
$form[$form_name]['cdm_dataportal_show_synonym_thumbnails'] = array(
|
806 |
5f8edac5
|
Andreas Kohlbecker
|
'#type' => 'checkbox',
|
807 |
|
|
'#title' => t('Show media thumbnails for synonyms'),
|
808 |
|
|
'#default_value' => $gallery_settings['cdm_dataportal_show_synonym_thumbnails'],
|
809 |
|
|
'#description' => t('')
|
810 |
95944919
|
Andreas Kohlbecker
|
);
|
811 |
|
|
}
|
812 |
05166aee
|
f.revilla
|
|
813 |
95944919
|
Andreas Kohlbecker
|
//$showCaption = variable_get('cdm_dataportal_findtaxa_show_thumbnail_captions', 0);
|
814 |
|
|
$form[$form_name]['cdm_dataportal_show_thumbnail_captions'] = array(
|
815 |
3b8004d7
|
f.revilla
|
'#type' => 'checkbox',
|
816 |
|
|
'#title' => t('Show captions under thumbnails'),
|
817 |
|
|
'#default_value' => $gallery_settings['cdm_dataportal_show_thumbnail_captions'],
|
818 |
|
|
'#description' => t('')
|
819 |
95944919
|
Andreas Kohlbecker
|
);
|
820 |
3b8004d7
|
f.revilla
|
|
821 |
95944919
|
Andreas Kohlbecker
|
$form[$form_name]['cdm_dataportal_media_maxextend'] = array(
|
822 |
3b8004d7
|
f.revilla
|
'#type' => 'textfield',
|
823 |
5b9dbe7f
|
f.revilla
|
'#title' => t('Thumbnail size'),
|
824 |
3b8004d7
|
f.revilla
|
'#default_value' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
825 |
fd876325
|
f.revilla
|
'#description' => t('Select the size of each individual thumbnail.')
|
826 |
95944919
|
Andreas Kohlbecker
|
);
|
827 |
3b8004d7
|
f.revilla
|
|
828 |
95944919
|
Andreas Kohlbecker
|
if($form_name != CDM_DATAPORTAL_MEDIA_GALLERY_NAME){
|
829 |
|
|
$form[$form_name]['cdm_dataportal_media_cols'] = array(
|
830 |
fd876325
|
f.revilla
|
'#type' => 'textfield',
|
831 |
|
|
'#title' => t('Number of columns'),
|
832 |
|
|
'#default_value' => $gallery_settings['cdm_dataportal_media_cols'],
|
833 |
|
|
'#description' => t('Group the thumbnails in columns: select how many columns should the gallery display.')
|
834 |
95944919
|
Andreas Kohlbecker
|
);
|
835 |
|
|
}
|
836 |
3b8004d7
|
f.revilla
|
|
837 |
95944919
|
Andreas Kohlbecker
|
if($form_name == CDM_DATAPORTAL_SEARCH_GALLERY_NAME){
|
838 |
|
|
$form[$form_name]['cdm_dataportal_media_maxRows'] = array(
|
839 |
5f8edac5
|
Andreas Kohlbecker
|
'#type' => 'textfield',
|
840 |
|
|
'#title' => t('Maximum number of rows'),
|
841 |
|
|
'#default_value' => $gallery_settings['cdm_dataportal_media_maxRows'],
|
842 |
fd876325
|
f.revilla
|
'#description' => t('You can group the thumbnails in rows, select in how many rows should be the thumbnails grouped.<br>
|
843 |
2d24e311
|
f.revilla
|
<b>Note:</b> If you want an unlimited number of rows please set to 0')
|
844 |
95944919
|
Andreas Kohlbecker
|
);
|
845 |
|
|
}
|
846 |
23f32680
|
f.revilla
|
|
847 |
95944919
|
Andreas Kohlbecker
|
return $form;
|
848 |
b1e71fdc
|
f.revilla
|
}
|
849 |
63fe0c43
|
f.revilla
|
|
850 |
e38d39d6
|
Andreas Kohlbecker
|
|
851 |
9cc1a3e2
|
Andreas Kohlbecker
|
/**
|
852 |
|
|
* Displays a list of the known taxonomic names. Long lists are split up into multiple pages
|
853 |
|
|
*
|
854 |
55e5b62d
|
Andreas Kohlbecker
|
* TODO: parameters are still preliminar
|
855 |
9cc1a3e2
|
Andreas Kohlbecker
|
* @param String $page page number to diplay defaults to page 1
|
856 |
|
|
* @param boolean $hide_unaccepted whether to hide nams which are not accepted by the current view
|
857 |
|
|
*/
|
858 |
afbbba9e
|
Andreas Kohlbecker
|
function cdm_dataportal_view_names($beginsWith = 'A', $page = 1, $onlyAccepted = false ){
|
859 |
67a4a4c6
|
Andreas Kohlbecker
|
|
860 |
95944919
|
Andreas Kohlbecker
|
$request_params = array(
|
861 |
94112bee
|
n.hoffmann
|
'q' => $beginsWith,
|
862 |
95944919
|
Andreas Kohlbecker
|
//'sec' = '',
|
863 |
|
|
//'higherTaxa' => getFiters(),
|
864 |
|
|
// 'matchAnywhere' => false, // default is false
|
865 |
94112bee
|
n.hoffmann
|
'page' => $page,
|
866 |
|
|
'onlyAccepted' => $onlyAccepted,
|
867 |
ee99abea
|
Andreas Kohlbecker
|
'pagesize' => 20 /*$_SESSION['cdm']['namelist_pagesize'] */);
|
868 |
63fe0c43
|
f.revilla
|
|
869 |
95944919
|
Andreas Kohlbecker
|
$taxonPager = cdm_ws_find(CDM_WS_PORTAL_TAXON_FIND, $request_params);
|
870 |
|
|
/*
|
871 |
|
|
* FIXME the filter for accepted names will be a form element, thus this widget
|
872 |
|
|
* should be generated via form api preferably as block
|
873 |
|
|
*/
|
874 |
|
|
//$out = theme('cdm_dataportal_widget_filter_accepted', $onlyAccepted);
|
875 |
|
|
//$out .= theme('cdm_dataportal_widget_names_list', $names, $page);
|
876 |
|
|
$out .= theme('cdm_listof_taxa', $taxonPager);
|
877 |
|
|
return $out;
|
878 |
9cc1a3e2
|
Andreas Kohlbecker
|
}
|
879 |
|
|
|
880 |
4726aac7
|
Andreas Kohlbecker
|
function cdm_dataportal_view_reference($uuid, $arg2 = null){
|
881 |
95944919
|
Andreas Kohlbecker
|
$reference = cdm_ws_get(CDM_WS_REFERENCE, $uuid);
|
882 |
|
|
return theme('cdm_reference_page', $reference);
|
883 |
4726aac7
|
Andreas Kohlbecker
|
}
|
884 |
|
|
|
885 |
46a52efe
|
Andreas Kohlbecker
|
function cdm_dataportal_view_reference_list($pageNumber){
|
886 |
95944919
|
Andreas Kohlbecker
|
$referencePager = cdm_ws_page(CDM_WS_REFERENCE, variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE), $pageNumber);
|
887 |
|
|
return theme('cdm_reference_pager', $referencePager, 'cdm_dataportal/reference/list/');
|
888 |
46a52efe
|
Andreas Kohlbecker
|
}
|
889 |
|
|
|
890 |
b09e63fd
|
Andreas Kohlbecker
|
function cdm_dataportal_view_media($mediaUuid, $mediarepresentation_uuid = false, $part = 0){
|
891 |
95944919
|
Andreas Kohlbecker
|
$media = cdm_ws_get(CDM_WS_PORTAL_MEDIA, $mediaUuid);
|
892 |
|
|
return theme('cdm_media_page', $media, $mediarepresentation_uuid, $part);
|
893 |
2cd9a3d6
|
Andreas Kohlbecker
|
}
|
894 |
|
|
|
895 |
2264b60d
|
Andreas Kohlbecker
|
function _load_taxonBase(&$taxonBase){
|
896 |
95944919
|
Andreas Kohlbecker
|
if(isset($taxonBase->uuid)){
|
897 |
|
|
$taxonBase->name = cdm_ws_get(CDM_WS_TAXON, array($taxonBase->uuid, "name"));
|
898 |
|
|
$taxonBase->name->taggedName = cdm_ws_get(CDM_WS_NAME, array($taxonBase->name->uuid, "taggedName"));
|
899 |
|
|
$taxonBase->name->nomenclaturalReference = cdm_ws_get(CDM_WS_NAME, array($taxonBase->name->uuid, "nomenclaturalReference"));
|
900 |
|
|
}
|
901 |
2264b60d
|
Andreas Kohlbecker
|
}
|
902 |
|
|
|
903 |
0364559b
|
Andreas Kohlbecker
|
/**
|
904 |
|
|
* similar to the variable_get() function of Drupal, except of thst this function
|
905 |
|
|
* is able to handle arrays correctly. This function is especially useful
|
906 |
|
|
* when dealing with collections of setting form elemens (#tree = true)
|
907 |
|
|
*
|
908 |
|
|
* @param String $variableKey
|
909 |
|
|
* @param String $defaultValueString a sting as for example derived from a CONSTANT
|
910 |
|
|
* @return mixed, usually an array
|
911 |
|
|
*/
|
912 |
|
|
function mixed_variable_get($variableKey, $defaultValueString){
|
913 |
|
|
$systemDefaults = unserialize($defaultValueString);
|
914 |
|
|
$storedSettings = variable_get($variableKey, array());
|
915 |
|
|
if(is_array($storedSettings)){
|
916 |
|
|
$settings = array_merge($systemDefaults, $storedSettings);
|
917 |
|
|
} else {
|
918 |
|
|
$settings = $systemDefaults;
|
919 |
|
|
}
|
920 |
|
|
return $settings;
|
921 |
|
|
}
|
922 |
|
|
|
923 |
2264b60d
|
Andreas Kohlbecker
|
/**
|
924 |
|
|
* Loads the subgraph of the given PolytomousKeyNode recursively from the cdm REST service.
|
925 |
|
|
* @param PolytomousKeyNode $polytomousKeyNode passed by reference
|
926 |
|
|
* @return nothing
|
927 |
|
|
*/
|
928 |
|
|
function _load_polytomousKeySubGraph(&$polytomousKeyNode){
|
929 |
cafc7c3b
|
Andreas Kohlbecker
|
|
930 |
95944919
|
Andreas Kohlbecker
|
if(!$polytomousKeyNode){
|
931 |
|
|
return;
|
932 |
|
|
}
|
933 |
|
|
if($polytomousKeyNode->class != "PolytomousKeyNode"){
|
934 |
|
|
drupal_set_message("_load_polytomousKeySubGraph() invalid type given.", "error");
|
935 |
|
|
return;
|
936 |
|
|
}
|
937 |
cafc7c3b
|
Andreas Kohlbecker
|
if(!is_uuid($polytomousKeyNode->uuid)){
|
938 |
|
|
drupal_set_message("_load_polytomousKeySubGraph() invalid type given.", "error");
|
939 |
|
|
return;
|
940 |
|
|
}
|
941 |
|
|
|
942 |
95944919
|
Andreas Kohlbecker
|
$polytomousKeyNode = cdm_ws_get(CDM_WS_POLYTOMOUSKEY_NODE, $polytomousKeyNode->uuid);
|
943 |
2264b60d
|
Andreas Kohlbecker
|
|
944 |
|
|
if(!$polytomousKeyNode){
|
945 |
95944919
|
Andreas Kohlbecker
|
//drupal_set_message("_load_polytomousKeyChildNodes() : could not load polytomousKeyNode", "error");
|
946 |
|
|
return;
|
947 |
2264b60d
|
Andreas Kohlbecker
|
}
|
948 |
|
|
|
949 |
|
|
// load children
|
950 |
|
|
foreach($polytomousKeyNode->children as &$childNode){
|
951 |
|
|
_load_polytomousKeySubGraph($childNode);
|
952 |
|
|
}
|
953 |
|
|
|
954 |
|
|
// load subkey
|
955 |
|
|
$polytomousKeyNode->subkey = cdm_ws_get(CDM_WS_POLYTOMOUSKEY_NODE, array($polytomousKeyNode->uuid, "subkey"));
|
956 |
|
|
|
957 |
|
|
// load taxon
|
958 |
|
|
$polytomousKeyNode->taxon = cdm_ws_get(CDM_WS_POLYTOMOUSKEY_NODE, array($polytomousKeyNode->uuid, "taxon"));
|
959 |
|
|
_load_taxonBase($polytomousKeyNode->taxon);
|
960 |
|
|
return;
|
961 |
|
|
}
|
962 |
|
|
|
963 |
|
|
function cdm_dataportal_view_polytomousKey($polytomousKeyUuid){
|
964 |
|
|
$polytomousKey = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, $polytomousKeyUuid);
|
965 |
|
|
|
966 |
|
|
$sourcePager = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, array($polytomousKeyUuid, "sources"));
|
967 |
|
|
if(is_array($sourcePager->records)){
|
968 |
|
|
$polytomousKey->sources = $sourcePager->records;
|
969 |
cafc7c3b
|
Andreas Kohlbecker
|
//$polytomousKey->sources->citation = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, array($polytomousKeyUuid, "sources"));
|
970 |
2264b60d
|
Andreas Kohlbecker
|
}
|
971 |
|
|
|
972 |
|
|
$annotationPager = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, array($polytomousKeyUuid, "annotations"));
|
973 |
|
|
if(is_array($annotationPager->records)){
|
974 |
|
|
$polytomousKey->annotations = $annotationPager->records;
|
975 |
|
|
}
|
976 |
|
|
|
977 |
|
|
_load_polytomousKeySubGraph($polytomousKey->root);
|
978 |
|
|
return theme('cdm_polytomousKey_page', $polytomousKey);
|
979 |
|
|
}
|
980 |
|
|
|
981 |
9cc1a3e2
|
Andreas Kohlbecker
|
/**
|
982 |
|
|
* The taxon page gives detailed information on a taxon, it shows:
|
983 |
|
|
* - Taxon name
|
984 |
67a4a4c6
|
Andreas Kohlbecker
|
* - Full list of synonyms homotypic synonyms on top, followed by the
|
985 |
|
|
* heterotypic and finally followed by misapplied names.
|
986 |
afbbba9e
|
Andreas Kohlbecker
|
* The list is ordered historically.
|
987 |
8ff851c6
|
Andreas Kohlbecker
|
* - All description associated with the taxon.
|
988 |
9cc1a3e2
|
Andreas Kohlbecker
|
*
|
989 |
8ff851c6
|
Andreas Kohlbecker
|
* @param $uuid
|
990 |
|
|
* @param $chapter name of the part to display,
|
991 |
ecc6714f
|
f.revilla
|
* valid values are: 'description', 'images', 'synonymy', 'specimens', 'all'
|
992 |
8ff851c6
|
Andreas Kohlbecker
|
* @return unknown_type
|
993 |
9cc1a3e2
|
Andreas Kohlbecker
|
*/
|
994 |
27b71dd0
|
f.revilla
|
function cdm_dataportal_taxon_page_view($uuid, $chapter = 'all', $synonym_uuid = null){
|
995 |
95944919
|
Andreas Kohlbecker
|
// display the page for the taxon defined by $uuid
|
996 |
|
|
set_last_taxon_page_tab(arg(3));
|
997 |
|
|
$taxonpage = cdm_dataportal_taxon_view($uuid, $chapter, $synonym_uuid);
|
998 |
|
|
return cdm_node_show(NODETYPE_TAXON, $uuid, $taxonpage->title , $taxonpage->content);
|
999 |
8ff851c6
|
Andreas Kohlbecker
|
}
|
1000 |
|
|
|
1001 |
|
|
/**
|
1002 |
|
|
* @param $uuid
|
1003 |
|
|
* @param $chapter name of the part to display,
|
1004 |
|
|
* valid values are: 'description', 'images', 'synonymy', 'all'
|
1005 |
|
|
* @return unknown_type
|
1006 |
|
|
*/
|
1007 |
27b71dd0
|
f.revilla
|
function cdm_dataportal_taxon_view($uuid, $chapter = 'all', $synonym_uuid = null){
|
1008 |
95944919
|
Andreas Kohlbecker
|
$taxon = cdm_ws_get(CDM_WS_PORTAL_TAXON, $uuid);
|
1009 |
|
|
if(!$taxon){
|
1010 |
|
|
drupal_set_title(t('Taxon does not exist'));
|
1011 |
|
|
return false;
|
1012 |
|
|
}
|
1013 |
|
|
|
1014 |
|
|
$taxonpage->title = theme('cdm_taxon_page_title', $taxon, $uuid, $synonym_uuid);
|
1015 |
|
|
|
1016 |
|
|
// check if the taxon id contained in the currently selected tree
|
1017 |
|
|
$taxon_in_current_tree = taxon_in_current_tree($uuid);
|
1018 |
|
|
$taxon_nodes = cdm_ws_get(CDM_WS_PORTAL_TAXON_TAXONNODES, $uuid);
|
1019 |
|
|
if(!$taxon_in_current_tree){
|
1020 |
|
|
if(count($taxon_nodes) == 0){
|
1021 |
|
|
drupal_set_message('This concept of the taxon '.theme('cdm_taxonName', $taxon->name).' is not contained any classification.'
|
1022 |
|
|
,'warning');
|
1023 |
|
|
} else {
|
1024 |
|
|
$trees = '';
|
1025 |
|
|
foreach($taxon_nodes as $node){
|
1026 |
|
|
$trees .= ($trees?', ':'').'<strong>'.$node->classification->titleCache.'</strong>';
|
1027 |
|
|
|
1028 |
|
|
}
|
1029 |
|
|
drupal_set_message('This concept of the taxon '.theme('cdm_taxonName', $taxon->name).' is not contained in the currently chosen classification, but in '
|
1030 |
|
|
.(count($taxon_nodes) > 1? ' one of these: ' : ' this one: ') . $trees
|
1031 |
|
|
, 'warning');
|
1032 |
|
|
}
|
1033 |
|
|
}
|
1034 |
|
|
|
1035 |
|
|
// render the taxon page
|
1036 |
|
|
$taxonpage->content = theme('cdm_taxon_page', $taxon, $chapter);
|
1037 |
|
|
|
1038 |
|
|
return $taxonpage;
|
1039 |
53a13220
|
Andreas Kohlbecker
|
}
|
1040 |
67a4a4c6
|
Andreas Kohlbecker
|
|
1041 |
57e2ea1f
|
f.revilla
|
/**
|
1042 |
|
|
* The function returns a name page as a drupal node ready to be renderized by drupal.
|
1043 |
05166aee
|
f.revilla
|
* The node page show the taxon name title and the list of taxon related with such taxon
|
1044 |
|
|
* name on the tree already in used.
|
1045 |
57e2ea1f
|
f.revilla
|
* @param $taxon_name_uuid A taxon name uuid
|
1046 |
|
|
* @return The formatted name page as node
|
1047 |
|
|
*/
|
1048 |
bd379106
|
f.revilla
|
function cdm_dataportal_name_page_view($taxon_name_uuid, $taxon_to_hide_uuid, $synonym_uuid = null){
|
1049 |
95944919
|
Andreas Kohlbecker
|
$taxonname_page = cdm_dataportal_name_view($taxon_name_uuid, $taxon_to_hide_uuid, $synonym_uuid);
|
1050 |
|
|
return cdm_node_show(NODETYPE_NAME, $taxon_name_uuid, $taxonname_page->title , $taxonname_page->content);
|
1051 |
57e2ea1f
|
f.revilla
|
}
|
1052 |
|
|
|
1053 |
|
|
/**
|
1054 |
05166aee
|
f.revilla
|
* The function genates a object ready to be transformated to a node
|
1055 |
57e2ea1f
|
f.revilla
|
* in order to show as a drupal node
|
1056 |
|
|
* @param $taxon_name_uuid
|
1057 |
05166aee
|
f.revilla
|
* @return the object with the page content and title
|
1058 |
57e2ea1f
|
f.revilla
|
*/
|
1059 |
bd379106
|
f.revilla
|
function cdm_dataportal_name_view($taxon_name_uuid, $taxon_to_hide_uuid, $synonym_uuid = null){
|
1060 |
95944919
|
Andreas Kohlbecker
|
//getting the full taxonname object from the server
|
1061 |
|
|
$taxon_name = cdm_ws_get(CDM_WS_NAME, array($taxon_name_uuid));
|
1062 |
|
|
if(!$taxon_name){
|
1063 |
|
|
drupal_set_title(t('Taxon name does not exist'));
|
1064 |
|
|
return false;
|
1065 |
|
|
}
|
1066 |
|
|
//searching for all the taxa connected with the taxon name on the tree in used
|
1067 |
|
|
$name_cache = cdm_ws_get(CDM_WS_NAME_NAMECAHE, array($taxon_name_uuid));
|
1068 |
|
|
$request_params = array();
|
1069 |
|
|
$request_params['query'] = $name_cache;
|
1070 |
|
|
$request_params['tree'] = get_taxonomictree_uuid_selected();
|
1071 |
|
|
$request_params['doTaxa'] = 1;
|
1072 |
|
|
$request_params['doSynonyms'] = 1;
|
1073 |
|
|
$request_params['doTaxaByCommonNames'] = 0;
|
1074 |
|
|
$request_params['matchMode'] = "EXACT";
|
1075 |
|
|
$taxon_pager = cdm_ws_get(CDM_WS_PORTAL_TAXON_FIND, null, queryString($request_params));
|
1076 |
|
|
|
1077 |
|
|
//removing the name where we come from and
|
1078 |
|
|
foreach($taxon_pager->records as $k=>&$taxon){
|
1079 |
|
|
if($taxon->uuid == $taxon_to_hide_uuid){
|
1080 |
|
|
unset($taxon_pager->records[$k]);
|
1081 |
|
|
}
|
1082 |
|
|
}
|
1083 |
|
|
//show the taxa list or go to the singular taxon
|
1084 |
|
|
if (sizeof($taxon_pager->records) == 1){ //sigle taxon case
|
1085 |
|
|
reset($taxon_pager->records);
|
1086 |
|
|
$first_key = key($taxon_pager->records);
|
1087 |
|
|
if($taxon_pager->records[$first_key]->class != "Taxon"){
|
1088 |
|
|
$taxon = cdm_ws_get(CDM_WS_PORTAL_TAXON_ACCEPTED, array($taxon_pager->records[$first_key]->uuid, get_taxonomictree_uuid_selected()));
|
1089 |
|
|
if($synonym_uuid){
|
1090 |
|
|
drupal_goto('cdm_dataportal/taxon/' . $taxon[0]->uuid . '/synonymy', 'highlite=' . $synonym_uuid);
|
1091 |
|
|
}else{
|
1092 |
|
|
drupal_goto('cdm_dataportal/taxon/' . $taxon[0]->uuid);
|
1093 |
|
|
}
|
1094 |
|
|
}else{
|
1095 |
|
|
if($synonym_uuid){
|
1096 |
|
|
drupal_goto('cdm_dataportal/taxon/' . $taxon_pager->records[$first_key]->uuid . '/synonymy',
|
1097 |
bd379106
|
f.revilla
|
'highlite=' . $synonym_uuid);
|
1098 |
95944919
|
Andreas Kohlbecker
|
}else{
|
1099 |
|
|
drupal_goto('cdm_dataportal/taxon/' . $taxon_pager->records[$first_key]->uuid);
|
1100 |
|
|
}
|
1101 |
|
|
//drupal_goto('cdm_dataportal/taxon/' . $taxon_pager->records[$first_key]->uuid);
|
1102 |
|
|
}
|
1103 |
|
|
}else{ //more than one taxa case
|
1104 |
|
|
$taxon_name_page->title = theme('cdm_name_page_title', $taxon_name);
|
1105 |
|
|
if($taxon_pager->records){
|
1106 |
|
|
$taxon_name_page->content = theme_cdm_list_of_taxa($taxon_pager->records, false);
|
1107 |
|
|
}else{
|
1108 |
|
|
$taxon_name_page->content = 'This name has no taxa';
|
1109 |
|
|
}
|
1110 |
|
|
return $taxon_name_page;
|
1111 |
|
|
}
|
1112 |
57e2ea1f
|
f.revilla
|
}
|
1113 |
8ff851c6
|
Andreas Kohlbecker
|
|
1114 |
2447830d
|
Andreas Kohlbecker
|
function cdm_dataportal_view_search_advanced(){
|
1115 |
63fe0c43
|
f.revilla
|
|
1116 |
95944919
|
Andreas Kohlbecker
|
drupal_set_title(t('Advanced search'));
|
1117 |
63fe0c43
|
f.revilla
|
|
1118 |
95944919
|
Andreas Kohlbecker
|
$searchForm = cdm_dataportal_search_taxon_form(true);
|
1119 |
63fe0c43
|
f.revilla
|
|
1120 |
95944919
|
Andreas Kohlbecker
|
return drupal_get_form('cdm_dataportal_search_taxon_form_advanced');
|
1121 |
63fe0c43
|
f.revilla
|
|
1122 |
2447830d
|
Andreas Kohlbecker
|
}
|
1123 |
|
|
|
1124 |
ee99abea
|
Andreas Kohlbecker
|
/**
|
1125 |
94112bee
|
n.hoffmann
|
*
|
1126 |
ee99abea
|
Andreas Kohlbecker
|
* future extensions to meet palmweb mockup requirements:
|
1127 |
|
|
* - habitat
|
1128 |
|
|
* - uses
|
1129 |
|
|
* - conservation status
|
1130 |
|
|
* - locality / tdwg region
|
1131 |
|
|
*/
|
1132 |
24b09d7c
|
Andreas Kohlbecker
|
function cdm_dataportal_view_search_taxon(){
|
1133 |
63fe0c43
|
f.revilla
|
|
1134 |
95944919
|
Andreas Kohlbecker
|
$_SESSION['cdm']['last_search'] = $_SERVER['REQUEST_URI'];
|
1135 |
daba333b
|
Andreas Kohlbecker
|
|
1136 |
95944919
|
Andreas Kohlbecker
|
$request_params = cdm_dataportal_search_form_request();
|
1137 |
|
|
$taxonPager = cdm_ws_get(CDM_WS_PORTAL_TAXON_FIND, null, queryString($request_params));
|
1138 |
63fe0c43
|
f.revilla
|
|
1139 |
95944919
|
Andreas Kohlbecker
|
$search_params = $_REQUEST;
|
1140 |
|
|
unset($search_params['q']);
|
1141 |
|
|
return theme('cdm_search_results', $taxonPager, 'cdm_dataportal/search/taxon', $search_params);
|
1142 |
ee99abea
|
Andreas Kohlbecker
|
}
|
1143 |
|
|
|
1144 |
57e2ea1f
|
f.revilla
|
|
1145 |
05fe0ad6
|
Andreas Kohlbecker
|
function cdm_view_xml2json(){
|
1146 |
95944919
|
Andreas Kohlbecker
|
$file = arg(2);
|
1147 |
|
|
$datastr = get_content(variable_get('cdm_webservice_url', '').$file);
|
1148 |
|
|
return xml2json::transformXmlStringToJson($datastr);
|
1149 |
fa97cd20
|
Andreas Kohlbecker
|
}
|
1150 |
|
|
|
1151 |
47a8c0dd
|
Andreas Kohlbecker
|
/* ====================== other functions ====================== */
|
1152 |
|
|
|
1153 |
cafc7c3b
|
Andreas Kohlbecker
|
|
1154 |
ec0c70d2
|
Andreas Kohlbecker
|
/**
|
1155 |
|
|
* Enter description here...
|
1156 |
|
|
*
|
1157 |
|
|
* @param String $uuid the UUID of the taxon
|
1158 |
|
|
* @return the URL
|
1159 |
|
|
*/
|
1160 |
7dd9909f
|
f.revilla
|
function path_to_taxon($uuid, $no_tab = false){
|
1161 |
95944919
|
Andreas Kohlbecker
|
$tab = get_default_taxon_tab();
|
1162 |
|
|
$values = unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB);
|
1163 |
|
|
|
1164 |
|
|
if(!$uuid) return false;
|
1165 |
|
|
|
1166 |
|
|
if (!$tab){
|
1167 |
|
|
return 'cdm_dataportal/taxon/'.$uuid;
|
1168 |
|
|
}elseif(get_last_taxon_page_tab() &&
|
1169 |
|
|
$tab == $values[CDM_DATAPORTAL_LAST_VISITED_TAB_ARRAY_INDEX]){
|
1170 |
|
|
return 'cdm_dataportal/taxon/'.$uuid . '/' . get_last_taxon_page_tab();
|
1171 |
|
|
} else {
|
1172 |
|
|
return 'cdm_dataportal/taxon/'.$uuid . '/' . strtolower($tab);
|
1173 |
|
|
}
|
1174 |
ad497c90
|
Andreas Kohlbecker
|
}
|
1175 |
|
|
|
1176 |
2d284a25
|
Andreas Kohlbecker
|
function path_to_key($keyType, $keyUuid){
|
1177 |
95944919
|
Andreas Kohlbecker
|
if(!$keyUuid || !$keyType) return false;
|
1178 |
|
|
$keyType{0} = strtolower($keyType{0});
|
1179 |
2d284a25
|
Andreas Kohlbecker
|
return "cdm_dataportal/".$keyType."/$keyUuid";
|
1180 |
|
|
}
|
1181 |
|
|
|
1182 |
24b09d7c
|
Andreas Kohlbecker
|
function path_to_reference($uuid){
|
1183 |
95944919
|
Andreas Kohlbecker
|
if(!$uuid) return false;
|
1184 |
|
|
return 'cdm_dataportal/reference/'.$uuid;
|
1185 |
24b09d7c
|
Andreas Kohlbecker
|
}
|
1186 |
|
|
|
1187 |
57e2ea1f
|
f.revilla
|
function path_to_name($name_uuid){
|
1188 |
95944919
|
Andreas Kohlbecker
|
$res = false;
|
1189 |
|
|
if($name_uuid){
|
1190 |
|
|
$res = 'cdm_dataportal/name/'.$name_uuid;
|
1191 |
|
|
}
|
1192 |
|
|
return $res;
|
1193 |
57e2ea1f
|
f.revilla
|
}
|
1194 |
|
|
|
1195 |
b09e63fd
|
Andreas Kohlbecker
|
function path_to_media($uuid, $representaion_uuid = false, $partId = false){
|
1196 |
95944919
|
Andreas Kohlbecker
|
if(!$uuid) return false;
|
1197 |
|
|
$out = 'cdm_dataportal/media/'.$uuid;
|
1198 |
|
|
if($representaion_uuid){
|
1199 |
|
|
$out .= '/'.$representaion_uuid;
|
1200 |
|
|
if($partId !== false){
|
1201 |
|
|
$out .= '/'.$partId;
|
1202 |
|
|
}
|
1203 |
|
|
}
|
1204 |
|
|
return $out;
|
1205 |
2cd9a3d6
|
Andreas Kohlbecker
|
}
|
1206 |
|
|
|
1207 |
70fb5e15
|
Andreas Kohlbecker
|
/**
|
1208 |
|
|
* Compares thisRank with thatRank.
|
1209 |
63fe0c43
|
f.revilla
|
* Returns a negative integer, zero, or a positive integer
|
1210 |
70fb5e15
|
Andreas Kohlbecker
|
* as the of thisRank is higher than, equal to, or lower than thatRank.
|
1211 |
63fe0c43
|
f.revilla
|
* e.g:
|
1212 |
70fb5e15
|
Andreas Kohlbecker
|
* <ul>
|
1213 |
|
|
* <li>rank_compare({species_uuid}, {genus_uuid}) = -1</li>
|
1214 |
|
|
* <li>rank_compare({genus_uuid}, {genus_uuid}) = 0</li>
|
1215 |
|
|
* <li>rank_compare({genus_uuid}, {tribus_uuid}) = 1</li>
|
1216 |
|
|
* </ul>
|
1217 |
|
|
* <p>
|
1218 |
|
|
* This compare logic of the underlying webservice is the
|
1219 |
63fe0c43
|
f.revilla
|
* <b>inverse logic</b> of the the one implemented in
|
1220 |
70fb5e15
|
Andreas Kohlbecker
|
* java.lang.Comparable#compareTo(java.lang.Object)
|
1221 |
|
|
* @param $thisRankUuid
|
1222 |
|
|
* @param $thatRankUuid
|
1223 |
63fe0c43
|
f.revilla
|
* @return a negative integer, zero, or a positive integer
|
1224 |
|
|
* as the thisRank is lower than, equal to, or higher than thatRank
|
1225 |
70fb5e15
|
Andreas Kohlbecker
|
*/
|
1226 |
|
|
function rank_compare($thisRankUuid, $thatRankUuid){
|
1227 |
95944919
|
Andreas Kohlbecker
|
$result = cdm_ws_get(CDM_WS_TERM_COMPARE, array($thisRankUuid, $thatRankUuid));
|
1228 |
|
|
return $result->Integer;
|
1229 |
70fb5e15
|
Andreas Kohlbecker
|
}
|
1230 |
|
|
|
1231 |
54e498e3
|
Andreas Kohlbecker
|
/**
|
1232 |
|
|
* Composes an HTML element class attribute value composed of
|
1233 |
|
|
* the shortname of the cdm class and the uuid of the entity.
|
1234 |
|
|
* This class attribute should be used whereever an cdm-entity is rendered.
|
1235 |
|
|
*
|
1236 |
|
|
* These according class selectors in css must be escaped, eg:
|
1237 |
|
|
* .cdm\:TextData
|
1238 |
|
|
*
|
1239 |
|
|
* @param $cdmEntity
|
1240 |
|
|
*/
|
1241 |
|
|
function html_class_atttibute_ref($cdmEntity){
|
1242 |
|
|
|
1243 |
|
|
if(is_cdm_entity($cdmEntity)) {
|
1244 |
|
|
return "cdm:".$cdmEntity->class." uuid:".$cdmEntity->uuid;
|
1245 |
|
|
}
|
1246 |
|
|
}
|
1247 |
|
|
|
1248 |
27b71dd0
|
f.revilla
|
function theme_cdm_uri_to_synonym($synonymUuid, $acceptedUuid, $pagePart = null){
|
1249 |
95944919
|
Andreas Kohlbecker
|
$acceptedPath = path_to_taxon($acceptedUuid, true);
|
1250 |
|
|
return url($acceptedPath.($pagePart ? '/'.$pagePart : ''), 'highlite='.$synonymUuid.'&acceptedFor='.$synonymUuid, $synonymUuid);
|
1251 |
24b09d7c
|
Andreas Kohlbecker
|
}
|
1252 |
|
|
|
1253 |
ec0c70d2
|
Andreas Kohlbecker
|
/**
|
1254 |
|
|
* Creates a short taxonname by using the taggename field of NameSTO or NameTO instances.
|
1255 |
|
|
* If the taggename if empty the fullname will be returned.
|
1256 |
|
|
*
|
1257 |
30c5a6bd
|
Andreas Kohlbecker
|
* @param unknown_type $Name or TreeNode
|
1258 |
67a4a4c6
|
Andreas Kohlbecker
|
* @return string
|
1259 |
ec0c70d2
|
Andreas Kohlbecker
|
*/
|
1260 |
30c5a6bd
|
Andreas Kohlbecker
|
function cdm_dataportal_shortname_of($name){
|
1261 |
95944919
|
Andreas Kohlbecker
|
$nameStr = '';
|
1262 |
|
|
// get all tagged text tokens of the scientific name
|
1263 |
|
|
foreach($name->taggedTitle as $tagtxt){
|
1264 |
|
|
if($tagtxt->type == 'name' || $tagtxt->type == 'rank'){
|
1265 |
|
|
$nameStr .= ($nameStr ? ' ' : '').$tagtxt->text;
|
1266 |
|
|
}
|
1267 |
|
|
}
|
1268 |
|
|
$nameStr = trim($nameStr);
|
1269 |
|
|
if($nameStr){
|
1270 |
|
|
// do not return short names for these
|
1271 |
|
|
//if (stristr(strtolower($nameStr), 'incertae sedis') !== FALSE ||
|
1272 |
|
|
// stristr(strtolower($nameStr), 'nomina excludenda') !== FALSE) {
|
1273 |
|
|
if ($name->unplaced || $name->excluded){
|
1274 |
|
|
return $nameStr;
|
1275 |
|
|
}
|
1276 |
|
|
if($pos = stripos($nameStr, ' ')){
|
1277 |
|
|
return substr($nameStr, 0, 1).'. '.substr($nameStr, $pos);
|
1278 |
|
|
} else {
|
1279 |
|
|
return $nameStr;
|
1280 |
|
|
}
|
1281 |
|
|
} else {
|
1282 |
|
|
return $name->titleCache;
|
1283 |
|
|
}
|
1284 |
ec0c70d2
|
Andreas Kohlbecker
|
}
|
1285 |
47a8c0dd
|
Andreas Kohlbecker
|
|
1286 |
d93dad11
|
n.hoffmann
|
|
1287 |
|
|
/**
|
1288 |
9ee2882b
|
Andreas Kohlbecker
|
* Check if a taxon is accepted by the current taxonomic tree
|
1289 |
d93dad11
|
n.hoffmann
|
*
|
1290 |
9ee2882b
|
Andreas Kohlbecker
|
* @param Taxon $taxon
|
1291 |
|
|
* @return true if $taxon is accepted, false otherwise
|
1292 |
d93dad11
|
n.hoffmann
|
*/
|
1293 |
9ee2882b
|
Andreas Kohlbecker
|
|
1294 |
30c5a6bd
|
Andreas Kohlbecker
|
function _cdm_dataportal_acceptedByCurrentView($taxon){
|
1295 |
63fe0c43
|
f.revilla
|
|
1296 |
95944919
|
Andreas Kohlbecker
|
$defaultTreeUuid = get_taxonomictree_uuid_selected();
|
1297 |
|
|
if($taxon->class == "Taxon" && isset($taxon->taxonNodes)){
|
1298 |
|
|
foreach($taxon->taxonNodes as $node){
|
1299 |
|
|
if($node->classification == $defaultTreeUuid) {
|
1300 |
|
|
return true;
|
1301 |
|
|
}
|
1302 |
|
|
}
|
1303 |
|
|
}
|
1304 |
|
|
return false;
|
1305 |
81df545f
|
Andreas Kohlbecker
|
}
|
1306 |
44e02685
|
Andreas Kohlbecker
|
|
1307 |
daba333b
|
Andreas Kohlbecker
|
/**@Deprecated
|
1308 |
63fe0c43
|
f.revilla
|
*
|
1309 |
daba333b
|
Andreas Kohlbecker
|
*/
|
1310 |
|
|
function compose_url_prameterstr($parameters = array(), $parentPropertyName = false){
|
1311 |
95944919
|
Andreas Kohlbecker
|
$pstr = '';
|
1312 |
|
|
foreach($parameters as $key=>$value){
|
1313 |
|
|
if(is_array($value)){
|
1314 |
|
|
|
1315 |
|
|
} else {
|
1316 |
|
|
$pstr .= ($pstr ? '&' :'').$key.'='.urlencode($value);
|
1317 |
|
|
}
|
1318 |
|
|
}
|
1319 |
|
|
return $pstr;
|
1320 |
d93dad11
|
n.hoffmann
|
}
|
1321 |
6f4dd14a
|
Andreas Kohlbecker
|
|
1322 |
95134a7b
|
Andreas Kohlbecker
|
/**
|
1323 |
|
|
* workaround for missing original source type, idNamespace is always set in these cases
|
1324 |
|
|
* @param unknown_type $source
|
1325 |
|
|
* @return unknown_type
|
1326 |
|
|
*/
|
1327 |
|
|
function _is_original_source_type($source){
|
1328 |
95944919
|
Andreas Kohlbecker
|
return !$source->idNamespace && strlen($source->idNamespace) == 0;
|
1329 |
95134a7b
|
Andreas Kohlbecker
|
}
|
1330 |
24b09d7c
|
Andreas Kohlbecker
|
|
1331 |
1956d9b9
|
Andreas Kohlbecker
|
|
1332 |
46edbba8
|
f.revilla
|
|
1333 |
|
|
/**
|
1334 |
23f32680
|
f.revilla
|
* The function read the metadata info such title or artist of a media file. The
|
1335 |
|
|
* function tries at first to get all the info from the file metadata and if it is
|
1336 |
|
|
* not avaible look at the media file info stored at the database.
|
1337 |
|
|
* @param $media The media file
|
1338 |
|
|
* @return array The array with the avilable specified metadata info.
|
1339 |
46edbba8
|
f.revilla
|
* TODO rename to read_media_metadata() and move to *.module
|
1340 |
|
|
*/
|
1341 |
b7862d20
|
f.revilla
|
function cdm_read_media_metadata($media){
|
1342 |
63fe0c43
|
f.revilla
|
|
1343 |
95944919
|
Andreas Kohlbecker
|
$metadata_caption = array('title' => '', //media_metadata and media
|
1344 |
63fe0c43
|
f.revilla
|
'artist' => '', //media_metadata and media
|
1345 |
|
|
'rights', //media_metadata and media
|
1346 |
|
|
'location', //media_metadata
|
1347 |
|
|
'filename' => '', //media
|
1348 |
|
|
'mediacreated' => '', //media
|
1349 |
|
|
'description' => ''); //media
|
1350 |
|
|
|
1351 |
95944919
|
Andreas Kohlbecker
|
//getting the media metadata
|
1352 |
|
|
$media_metadata = cdm_ws_get(CDM_WS_MEDIA_METADATA, array($media->uuid));
|
1353 |
|
|
$media_metadata_aux = (array) $media_metadata;
|
1354 |
|
|
|
1355 |
|
|
//filename
|
1356 |
|
|
if(isset($media->representations[0]->parts[0]->uri)){
|
1357 |
|
|
$fileUri = $media->representations[0]->parts[0]->uri;
|
1358 |
|
|
$filename = substr($fileUri, strrpos($fileUri, "/")+1);
|
1359 |
|
|
$metadata_caption['filename'] = $filename;
|
1360 |
|
|
}
|
1361 |
|
|
else{
|
1362 |
|
|
$metadata_caption['filename'] = '';
|
1363 |
|
|
}
|
1364 |
|
|
|
1365 |
|
|
//title
|
1366 |
|
|
if ($media_metadata->ObjectName) {
|
1367 |
|
|
$metadata_caption['title'] = $media_metadata->ObjectName;
|
1368 |
|
|
} else if ($media_metadata_aux['Object Name']){
|
1369 |
|
|
$metadata_caption['title'] = $media_metadata_aux['Object Name'];
|
1370 |
|
|
} else if ($media->title_L10n){
|
1371 |
|
|
$metadata_caption['title'] = $media->title_L10n;
|
1372 |
|
|
} else if ($media->titleCache){
|
1373 |
|
|
$metadata_caption['title'] = $media->titleCache;
|
1374 |
|
|
}
|
1375 |
|
|
|
1376 |
|
|
// append description to title
|
1377 |
|
|
if ($media->description_L10n) {
|
1378 |
|
|
$metadata_caption['title'] .= '<span class="media-description">' . $media->description_L10n . '<span>';
|
1379 |
|
|
}
|
1380 |
|
|
|
1381 |
|
|
//artist
|
1382 |
|
|
if ($media_metadata->Artist){
|
1383 |
|
|
$metadata_caption['artist'] = ($media_metadata->Artist ? ''.$media_metadata->Artist : '');
|
1384 |
|
|
}
|
1385 |
|
|
elseif ($media->artist->titleCache){
|
1386 |
|
|
$metadata_caption['artist'] = $media->artist->titleCache;
|
1387 |
|
|
}
|
1388 |
|
|
|
1389 |
|
|
//copyright
|
1390 |
|
|
$metadata_caption['rights'] = array('copyright' => array('agentNames' => array()),
|
1391 |
23f32680
|
f.revilla
|
'license' => array('agentNames' => array(), 'types' => array(), 'abbreviatedTexts' => array(), 'uris' => array()));
|
1392 |
95944919
|
Andreas Kohlbecker
|
if ($media_metadata->Copyright)
|
1393 |
|
|
$metadata_caption['rights']['copyright']['agentNames'][] = $media_metadata->Copyright;
|
1394 |
|
|
elseif ($media->rights){
|
1395 |
|
|
foreach($media->rights as $right){
|
1396 |
|
|
switch($right->term->uuid){
|
1397 |
|
|
case UUID_RIGHTS_LICENCE:
|
1398 |
|
|
$metadata_caption['rights']['license']['agentNames'][] = ($right->agent ? ''.$right->agent->firstname.' '.$right->agent->lastname : '');
|
1399 |
|
|
$metadata_caption['rights']['license']['types'][] = ($right->representation_L10n ? ''.$right->representation_L10n : '');
|
1400 |
|
|
$metadata_caption['rights']['license']['abbreviatedTexts'][] = ($right->abbreviatedText ? ''.$right->abbreviatedText : '');
|
1401 |
|
|
$metadata_caption['rights']['license']['uris'][] = ($right->uri ? ''.$right->uri : '');
|
1402 |
|
|
break;
|
1403 |
|
|
case UUID_RIGHTS_COPYRIGHT:
|
1404 |
|
|
$metadata_caption['rights']['copyright']['agentNames'][] = $right->agent->firstname . ' ' . $right->agent->lastname;
|
1405 |
|
|
break;
|
1406 |
|
|
}
|
1407 |
|
|
}
|
1408 |
|
|
} else {
|
1409 |
|
|
$metadata_caption['rights']['agentNames'][] = '';
|
1410 |
|
|
}
|
1411 |
|
|
|
1412 |
|
|
//filling the description (though there is no description in the db???)
|
1413 |
|
|
//$metadata_caption['description'] = $media->description_L10n;
|
1414 |
|
|
|
1415 |
|
|
//location
|
1416 |
|
|
$metadata_caption['location'] = array();
|
1417 |
|
|
$metadata_caption['location']['sublocation'] = $media_metadata->Sublocation;
|
1418 |
|
|
$metadata_caption['location']['city'] = $media_metadata->City;
|
1419 |
|
|
$metadata_caption['location']['province'] = $media_metadata->Province;
|
1420 |
|
|
$metadata_caption['location']['country'] = $media_metadata->Country;
|
1421 |
|
|
|
1422 |
|
|
/*
|
1423 |
|
|
//creation date
|
1424 |
|
|
if($media_metadata["Modify Date"])
|
1425 |
|
|
$metadata_caption['mediacreated'] = $media_metadata["Modify Date"];
|
1426 |
|
|
else
|
1427 |
|
|
$metadata_caption['mediacreated'] = $media->created;
|
1428 |
|
|
*/
|
1429 |
|
|
//returned value
|
1430 |
|
|
return $metadata_caption;
|
1431 |
46edbba8
|
f.revilla
|
}
|
1432 |
806baeb2
|
Andreas Kohlbecker
|
|
1433 |
|
|
/**
|
1434 |
|
|
* This function collects all the media from a list of description elements
|
1435 |
|
|
* and return them as an Array.
|
1436 |
|
|
*
|
1437 |
|
|
* @param $descriptionElementes The description elements
|
1438 |
|
|
* @return Array The output with all the media
|
1439 |
|
|
*/
|
1440 |
|
|
function cdm_dataportal_media_from_descriptionElements($descriptionElements){
|
1441 |
95944919
|
Andreas Kohlbecker
|
//variables
|
1442 |
|
|
$outArrayOfMedia = array(); //return value
|
1443 |
|
|
//implementation
|
1444 |
|
|
if(is_array($descriptionElements)){//avoiding warning box in drupal for flora malesiana
|
1445 |
|
|
foreach($descriptionElements as $descriptionElement){
|
1446 |
|
|
if(is_array($descriptionElement->media)){
|
1447 |
|
|
foreach($descriptionElement->media as $media){
|
1448 |
|
|
if(is_object($media)){
|
1449 |
|
|
$outArrayOfMedia[] = $media;
|
1450 |
|
|
}
|
1451 |
|
|
}
|
1452 |
|
|
}
|
1453 |
|
|
}
|
1454 |
|
|
}
|
1455 |
|
|
return $outArrayOfMedia;
|
1456 |
806baeb2
|
Andreas Kohlbecker
|
}
|
1457 |
|
|
|
1458 |
c8b3ae89
|
Andreas Kohlbecker
|
function cdm_annotations_as_footnotekeys($cdmBase, $footnote_list_key = null){
|
1459 |
95944919
|
Andreas Kohlbecker
|
$footNoteKeys = array();
|
1460 |
|
|
//is argument cdmBase an array?
|
1461 |
|
|
if (!is_array($cdmBase)){
|
1462 |
|
|
$cdmBase_array = array();
|
1463 |
|
|
$cdmBase_array[] = $cdmBase;
|
1464 |
|
|
}else{
|
1465 |
|
|
$cdmBase_array = $cdmBase;
|
1466 |
|
|
}
|
1467 |
|
|
//getting the key for the footnotemanager
|
1468 |
c8b3ae89
|
Andreas Kohlbecker
|
if( $footnote_list_key ){
|
1469 |
95944919
|
Andreas Kohlbecker
|
$footnoteListKey = $footnote_list_key;
|
1470 |
|
|
}else{
|
1471 |
|
|
$footnoteListKey = RenderHints::getFootnoteListKey() . '-annotations';
|
1472 |
|
|
}
|
1473 |
|
|
//adding the footnotes keys
|
1474 |
|
|
foreach($cdmBase_array as $cdmBase_element){
|
1475 |
|
|
$annotations = cdm_ws_getAnnotationsFor($cdmBase_element);
|
1476 |
|
|
if(is_array($annotations)){
|
1477 |
|
|
foreach($annotations as $annotation){
|
1478 |
|
|
$footNoteKeys[] = FootnoteManager::addNewFootnote($footnoteListKey, $annotation->text);
|
1479 |
cafc7c3b
|
Andreas Kohlbecker
|
}
|
1480 |
|
|
}
|
1481 |
95944919
|
Andreas Kohlbecker
|
}
|
1482 |
|
|
return $footNoteKeys;
|
1483 |
a973da5b
|
Andreas Kohlbecker
|
}
|
1484 |
|
|
|
1485 |
614b1592
|
Andreas Kohlbecker
|
function cdm_dynabox($label, $content_url, $theme, $link_alt_text, $enclosingtags = array('li', 'ul')){
|
1486 |
a973da5b
|
Andreas Kohlbecker
|
|
1487 |
95944919
|
Andreas Kohlbecker
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cdm_dynabox.js');
|
1488 |
614b1592
|
Andreas Kohlbecker
|
|
1489 |
95944919
|
Andreas Kohlbecker
|
$cdm_proxy_url = url('cdm_api/proxy/'.urlencode($content_url)."/$theme");
|
1490 |
|
|
$out .= '<'. $enclosingtags[0]. ' class="dynabox"><a href="'.$content_url.'" class="label" alt="'.t($link_alt_text).'">'.$label.'</a>';
|
1491 |
|
|
$out .= '<'. $enclosingtags[1]. ' class="dynabox_content" title="'.$cdm_proxy_url.'"><'. $enclosingtags[0]. '><img class="loading" src="'.drupal_get_path('module', 'cdm_dataportal').'/images/loading_circle_grey_16.gif" style="display:none;"></'. $enclosingtags[0]. '></'. $enclosingtags[1]. '>';
|
1492 |
|
|
$out .= '</'. $enclosingtags[0]. '>';
|
1493 |
|
|
return $out;
|
1494 |
614b1592
|
Andreas Kohlbecker
|
}
|
1495 |
806baeb2
|
Andreas Kohlbecker
|
|
1496 |
294bea51
|
Andreas Kohlbecker
|
/**
|
1497 |
|
|
* returns true if the given $featureNode or any of its subordinate nodes contains at least one
|
1498 |
|
|
* DescriptionElement
|
1499 |
|
|
* @param unknown_type $featureNode A heature node as produced by the function _mergeFeatureTreeDescriptions()
|
1500 |
|
|
*/
|
1501 |
|
|
function hasFeatureNodeDescriptionElements($featureNode) {
|
1502 |
|
|
|
1503 |
|
|
if(is_array($featureNode->descriptionElements) && count($featureNode->descriptionElements) > 0) {
|
1504 |
|
|
return true;
|
1505 |
|
|
} else if(is_array($featureNode->children)) {
|
1506 |
|
|
foreach ($featureNode->children as $child) {
|
1507 |
|
|
if(hasFeatureNodeDescriptionElements($child)){
|
1508 |
|
|
return true;
|
1509 |
|
|
}
|
1510 |
8fe6b770
|
Andreas Kohlbecker
|
}
|
1511 |
|
|
return false;
|
1512 |
294bea51
|
Andreas Kohlbecker
|
}
|
1513 |
|
|
|
1514 |
|
|
}
|
1515 |
8fe6b770
|
Andreas Kohlbecker
|
|