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 |
67a4a4c6
|
Andreas Kohlbecker
|
* European Distributed Institute of Taxonomy
|
10 |
05fe0ad6
|
Andreas Kohlbecker
|
* http://www.e-taxonomy.eu
|
11 |
94112bee
|
n.hoffmann
|
*
|
12 |
05fe0ad6
|
Andreas Kohlbecker
|
*/
|
13 |
|
|
|
14 |
47a8c0dd
|
Andreas Kohlbecker
|
require_once('cdm_dataportal.theme.php');
|
15 |
9cc1a3e2
|
Andreas Kohlbecker
|
|
16 |
30c5a6bd
|
Andreas Kohlbecker
|
define(CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE, 25);
|
17 |
|
|
|
18 |
67a4a4c6
|
Andreas Kohlbecker
|
/* ====================== hook implementations ====================== */
|
19 |
9cc1a3e2
|
Andreas Kohlbecker
|
|
20 |
|
|
/**
|
21 |
bf910101
|
Andreas Kohlbecker
|
* Implementation of hook_help()
|
22 |
67a4a4c6
|
Andreas Kohlbecker
|
*
|
23 |
9cc1a3e2
|
Andreas Kohlbecker
|
* Display help and module information
|
24 |
|
|
* @param section which section of the site we're displaying help
|
25 |
|
|
* @return help text for section
|
26 |
|
|
*/
|
27 |
|
|
function cdm_dataportal_help($section='') {
|
28 |
|
|
|
29 |
67a4a4c6
|
Andreas Kohlbecker
|
$out = '';
|
30 |
|
|
switch ($section) {
|
31 |
|
|
case "admin/modules#description":
|
32 |
|
|
$out = t("The dataportal publishes CDM data hosted in a CommunityStore on the web.");
|
33 |
|
|
break;
|
34 |
|
|
}
|
35 |
|
|
return $out;
|
36 |
9cc1a3e2
|
Andreas Kohlbecker
|
}
|
37 |
|
|
|
38 |
|
|
|
39 |
|
|
/**
|
40 |
bf910101
|
Andreas Kohlbecker
|
* Implementation of hook_perm()
|
41 |
67a4a4c6
|
Andreas Kohlbecker
|
*
|
42 |
9cc1a3e2
|
Andreas Kohlbecker
|
* Valid permissions for this module
|
43 |
|
|
* @return array An array of valid permissions for the portfolio module
|
44 |
|
|
*/
|
45 |
|
|
function cdm_dataportal_perm() {
|
46 |
67a4a4c6
|
Andreas Kohlbecker
|
return array(
|
47 |
9cc1a3e2
|
Andreas Kohlbecker
|
'administer cdm_dataportal',
|
48 |
|
|
'cdm_dataportal view notes',
|
49 |
67a4a4c6
|
Andreas Kohlbecker
|
//TODO which else permission are required? -> check the WP6 requirements document
|
50 |
|
|
);
|
51 |
9cc1a3e2
|
Andreas Kohlbecker
|
}
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
/**
|
55 |
bf910101
|
Andreas Kohlbecker
|
* Implementation of hook_menu()
|
56 |
9cc1a3e2
|
Andreas Kohlbecker
|
*/
|
57 |
|
|
function cdm_dataportal_menu($may_cache) {
|
58 |
f5851190
|
n.hoffmann
|
$items = array();
|
59 |
|
|
|
60 |
9cc1a3e2
|
Andreas Kohlbecker
|
if ($may_cache) {
|
61 |
67a4a4c6
|
Andreas Kohlbecker
|
|
62 |
9cc1a3e2
|
Andreas Kohlbecker
|
$items[] = array(
|
63 |
|
|
'path' => 'admin/settings/cdm_dataportal',
|
64 |
|
|
'title' => t('CDM Dataportal'),
|
65 |
|
|
'description' => t('Setting for the CDM Dataportal'),
|
66 |
|
|
'access' => user_access('administer cdm_dataportal'),
|
67 |
|
|
'callback' => 'drupal_get_form',
|
68 |
|
|
'callback arguments' => 'cdm_dataportal_settings',
|
69 |
a22e3f38
|
Andreas Kohlbecker
|
);
|
70 |
|
|
|
71 |
812a9c04
|
Andreas Kohlbecker
|
/*$items[] = array(
|
72 |
a22e3f38
|
Andreas Kohlbecker
|
'path' => 'admin/settings/cdm_dataportal/ws',
|
73 |
|
|
'title' => t('Web Service'),
|
74 |
|
|
'description' => t('Setting for the CDM Dataportal'),
|
75 |
|
|
'access' => user_access('administer cdm_dataportal'),
|
76 |
|
|
'callback' => 'drupal_get_form',
|
77 |
|
|
'callback arguments' => 'cdm_dataportal_settings',
|
78 |
|
|
'weight' => 1,
|
79 |
|
|
'type' => MENU_DEFAULT_LOCAL_TASK,
|
80 |
812a9c04
|
Andreas Kohlbecker
|
);*/
|
81 |
a22e3f38
|
Andreas Kohlbecker
|
|
82 |
9cc1a3e2
|
Andreas Kohlbecker
|
$items[] = array(
|
83 |
|
|
'path' => 'cdm_dataportal/names',
|
84 |
|
|
'callback' => 'cdm_dataportal_view_names',
|
85 |
|
|
'access' => true,
|
86 |
94112bee
|
n.hoffmann
|
'type' => MENU_CALLBACK,
|
87 |
67a4a4c6
|
Andreas Kohlbecker
|
);
|
88 |
|
|
// optional callback arguments: page
|
89 |
4726aac7
|
Andreas Kohlbecker
|
|
90 |
67a4a4c6
|
Andreas Kohlbecker
|
$items[] = array(
|
91 |
4726aac7
|
Andreas Kohlbecker
|
'path' => 'cdm_dataportal/taxon',
|
92 |
|
|
'callback' => 'cdm_dataportal_view_taxon',
|
93 |
|
|
'access' => true,
|
94 |
|
|
'type' => MENU_CALLBACK,
|
95 |
|
|
// expected callback arguments: name_uuid
|
96 |
|
|
);
|
97 |
|
|
|
98 |
|
|
$items[] = array(
|
99 |
|
|
'path' => 'cdm_dataportal/reference',
|
100 |
|
|
'callback' => 'cdm_dataportal_view_reference',
|
101 |
|
|
'access' => true,
|
102 |
|
|
'type' => MENU_CALLBACK,
|
103 |
67a4a4c6
|
Andreas Kohlbecker
|
// expected callback arguments: name_uuid
|
104 |
|
|
);
|
105 |
ee99abea
|
Andreas Kohlbecker
|
|
106 |
46a52efe
|
Andreas Kohlbecker
|
$items[] = array(
|
107 |
|
|
'path' => 'cdm_dataportal/reference/list',
|
108 |
|
|
'callback' => 'cdm_dataportal_view_reference_list',
|
109 |
|
|
'access' => true,
|
110 |
|
|
'type' => MENU_CALLBACK,
|
111 |
|
|
// expected callback arguments: name_uuid
|
112 |
|
|
);
|
113 |
|
|
|
114 |
2cd9a3d6
|
Andreas Kohlbecker
|
$items[] = array(
|
115 |
|
|
'path' => 'cdm_dataportal/media',
|
116 |
|
|
'callback' => 'cdm_dataportal_view_media',
|
117 |
|
|
'access' => true,
|
118 |
|
|
'type' => MENU_CALLBACK,
|
119 |
b09e63fd
|
Andreas Kohlbecker
|
// expected callback arguments: media_uuid, mediarepresentation_uuid, part_uuid or part#
|
120 |
2cd9a3d6
|
Andreas Kohlbecker
|
);
|
121 |
|
|
|
122 |
2447830d
|
Andreas Kohlbecker
|
$items[] = array(
|
123 |
|
|
'path' => 'cdm_dataportal/search',
|
124 |
|
|
'callback' => 'cdm_dataportal_view_search_advanced',
|
125 |
|
|
'access' => true,
|
126 |
|
|
'type' => MENU_CALLBACK,
|
127 |
|
|
);
|
128 |
|
|
|
129 |
ee99abea
|
Andreas Kohlbecker
|
$items[] = array(
|
130 |
|
|
'path' => 'cdm_dataportal/search/taxon',
|
131 |
|
|
'callback' => 'cdm_dataportal_view_search_taxon',
|
132 |
|
|
'access' => true,
|
133 |
94112bee
|
n.hoffmann
|
'type' => MENU_CALLBACK,
|
134 |
f5851190
|
n.hoffmann
|
);
|
135 |
ee99abea
|
Andreas Kohlbecker
|
|
136 |
67a4a4c6
|
Andreas Kohlbecker
|
$items[] = array(
|
137 |
05fe0ad6
|
Andreas Kohlbecker
|
'path' => 'cdm/xml2json',
|
138 |
|
|
'callback' => 'cdm_view_xml2json',
|
139 |
|
|
'access' => true,
|
140 |
94112bee
|
n.hoffmann
|
'type' => MENU_CALLBACK,
|
141 |
67a4a4c6
|
Andreas Kohlbecker
|
);
|
142 |
f5851190
|
n.hoffmann
|
|
143 |
|
|
|
144 |
4726aac7
|
Andreas Kohlbecker
|
} else {
|
145 |
|
|
// may not cache
|
146 |
|
|
// --- local tasks for Taxon
|
147 |
|
|
if(variable_get('cdm_dataportal_taxonpage_tabs', 1)) {
|
148 |
|
|
|
149 |
|
|
$items[] = array(
|
150 |
|
|
'path' => 'cdm_dataportal/taxon/'.arg(2),
|
151 |
0d127818
|
Andreas Kohlbecker
|
'title' => theme('cdm_taxonpage_tab', 'General'),
|
152 |
4726aac7
|
Andreas Kohlbecker
|
'callback' => 'cdm_dataportal_view_taxon',
|
153 |
|
|
'access' => true,
|
154 |
|
|
'type' => MENU_CALLBACK,
|
155 |
3cf0dec2
|
Andreas Kohlbecker
|
'weight' => 1,
|
156 |
24b09d7c
|
Andreas Kohlbecker
|
'callback arguments' => array(arg(2), "description")
|
157 |
4726aac7
|
Andreas Kohlbecker
|
// expected callback arguments: name_uuid
|
158 |
|
|
);
|
159 |
|
|
|
160 |
|
|
$items[] = array(
|
161 |
|
|
'path' => 'cdm_dataportal/taxon/'.arg(2).'/description',
|
162 |
0d127818
|
Andreas Kohlbecker
|
'title' => theme('cdm_taxonpage_tab', 'General'),
|
163 |
4726aac7
|
Andreas Kohlbecker
|
'callback' => 'cdm_dataportal_view_taxon',
|
164 |
|
|
'access' => true,
|
165 |
|
|
'type' => MENU_DEFAULT_LOCAL_TASK,
|
166 |
3cf0dec2
|
Andreas Kohlbecker
|
'weight' => 2,
|
167 |
4726aac7
|
Andreas Kohlbecker
|
'callback arguments' => array(arg(2), "description")
|
168 |
|
|
// expected callback arguments: name_uuid
|
169 |
|
|
);
|
170 |
|
|
|
171 |
|
|
$items[] = array(
|
172 |
3cf0dec2
|
Andreas Kohlbecker
|
'path' => 'cdm_dataportal/taxon/'.arg(2).'/synonymy',
|
173 |
0d127818
|
Andreas Kohlbecker
|
'title' => theme('cdm_taxonpage_tab', 'Synonymy'),
|
174 |
4726aac7
|
Andreas Kohlbecker
|
'callback' => 'cdm_dataportal_view_taxon',
|
175 |
|
|
'access' => true,
|
176 |
|
|
'type' => MENU_LOCAL_TASK,
|
177 |
3cf0dec2
|
Andreas Kohlbecker
|
'weight' => 3,
|
178 |
|
|
'callback arguments' => array(arg(2), "synonymy")
|
179 |
4726aac7
|
Andreas Kohlbecker
|
// expected callback arguments: name_uuid
|
180 |
|
|
);
|
181 |
|
|
|
182 |
|
|
$items[] = array(
|
183 |
3cf0dec2
|
Andreas Kohlbecker
|
'path' => 'cdm_dataportal/taxon/'.arg(2).'/images',
|
184 |
0d127818
|
Andreas Kohlbecker
|
'title' => theme('cdm_taxonpage_tab', 'Images'),
|
185 |
4726aac7
|
Andreas Kohlbecker
|
'callback' => 'cdm_dataportal_view_taxon',
|
186 |
|
|
'access' => true,
|
187 |
|
|
'type' => MENU_LOCAL_TASK,
|
188 |
3cf0dec2
|
Andreas Kohlbecker
|
'weight' => 4,
|
189 |
|
|
'callback arguments' => array(arg(2), "images")
|
190 |
4726aac7
|
Andreas Kohlbecker
|
// expected callback arguments: name_uuid
|
191 |
|
|
);
|
192 |
|
|
}
|
193 |
f5851190
|
n.hoffmann
|
}
|
194 |
|
|
|
195 |
2189699f
|
Andreas Kohlbecker
|
drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/cdm_dataportal.css');
|
196 |
6611904c
|
Andreas Kohlbecker
|
//drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/cdm_dataportal_print.css', 'print');
|
197 |
|
|
drupal_add_css(drupal_get_path('module', 'cdm_dataportal').'/cdm_dataportal_screen.css', 'screen');
|
198 |
f5851190
|
n.hoffmann
|
|
199 |
9cc1a3e2
|
Andreas Kohlbecker
|
return $items;
|
200 |
c0ac3382
|
Andreas Kohlbecker
|
|
201 |
9cc1a3e2
|
Andreas Kohlbecker
|
}
|
202 |
|
|
|
203 |
d946105e
|
Andreas Kohlbecker
|
/**
|
204 |
|
|
* Implementation of hook_block()
|
205 |
67a4a4c6
|
Andreas Kohlbecker
|
*
|
206 |
d946105e
|
Andreas Kohlbecker
|
* Provides the following blocks:
|
207 |
|
|
* 0: list of links useful during development
|
208 |
|
|
*
|
209 |
|
|
* @param String $op
|
210 |
|
|
* @param int $delta
|
211 |
|
|
*/
|
212 |
|
|
function cdm_dataportal_block($op='list', $delta=0) {
|
213 |
|
|
// listing of blocks, such as on the admin/block page
|
214 |
|
|
if ($op == "list") {
|
215 |
|
|
$block[0]["info"] = t("CDM DataPortal DevLinks");
|
216 |
67a4a4c6
|
Andreas Kohlbecker
|
$block[1]["info"] = t("CDM DataPortal Credits");
|
217 |
ee99abea
|
Andreas Kohlbecker
|
$block[2]["info"] = t("CDM Search Taxa");
|
218 |
f5b3d74e
|
Andreas Kohlbecker
|
$block[3]["info"] = t("CDM Filters");
|
219 |
d946105e
|
Andreas Kohlbecker
|
return $block;
|
220 |
|
|
}
|
221 |
|
|
else if ($op == 'view') {
|
222 |
|
|
switch($delta){
|
223 |
67a4a4c6
|
Andreas Kohlbecker
|
case 1:
|
224 |
|
|
$block['subject'] = t('Credits');
|
225 |
c0ac3382
|
Andreas Kohlbecker
|
$block['content'] = theme('cdm_credits');
|
226 |
|
|
return $block;
|
227 |
ee99abea
|
Andreas Kohlbecker
|
case 2:
|
228 |
|
|
$block['subject'] = t('Search Taxa');
|
229 |
|
|
$block['content'] = drupal_get_form('cdm_dataportal_search_taxon_form');
|
230 |
8934f97c
|
Andreas Kohlbecker
|
$block['content'] .= '<div>'.l('Advanced Search', '/cdm_dataportal/search').'</div>';
|
231 |
ee99abea
|
Andreas Kohlbecker
|
return $block;
|
232 |
d946105e
|
Andreas Kohlbecker
|
}
|
233 |
|
|
}
|
234 |
|
|
}
|
235 |
|
|
|
236 |
9cc1a3e2
|
Andreas Kohlbecker
|
|
237 |
47a8c0dd
|
Andreas Kohlbecker
|
/**
|
238 |
|
|
* Implementation of hook_validate()
|
239 |
|
|
*
|
240 |
|
|
* @param $element
|
241 |
|
|
*/
|
242 |
afbbba9e
|
Andreas Kohlbecker
|
function cdm_dataportal_settings_validate($form_id, $form_values){
|
243 |
812a9c04
|
Andreas Kohlbecker
|
|
244 |
afbbba9e
|
Andreas Kohlbecker
|
if (!str_endsWith($form_values['cdm_webservice_url'], '/')) {
|
245 |
67a4a4c6
|
Andreas Kohlbecker
|
form_set_error('cdm_webservice_url', t("The URL to the CDM Web Service must end with a slash: '/'."));
|
246 |
|
|
}
|
247 |
812a9c04
|
Andreas Kohlbecker
|
|
248 |
|
|
$cdm_webservice_url_changed = variable_get('cdm_webservice_url', '') != $form_values['cdm_webservice_url'];
|
249 |
|
|
|
250 |
24b09d7c
|
Andreas Kohlbecker
|
$cdm_secUuid_default_changed = variable_get('cdm_secUuid_default', '') != $form_values['cdm_secUuid_default'];
|
251 |
|
|
|
252 |
|
|
if ($cdm_webservice_url_changed || $cdm_secUuid_default_changed) {
|
253 |
|
|
|
254 |
|
|
_cdm_dataportal_set_currentSecUuid($form_values['cdm_secUuid_default']);
|
255 |
812a9c04
|
Andreas Kohlbecker
|
// reset all cdm related data stored in the session
|
256 |
6e1ec3a4
|
Andreas Kohlbecker
|
// cdm_dataportal_session_clear($form_values['cdm_webservice_url']); // cdm_webservice_url is not further stored here
|
257 |
fa68c2c5
|
Andreas Kohlbecker
|
// clear the cdm webservice cache
|
258 |
|
|
cache_clear_all(NULL, 'cache_cdm_ws');
|
259 |
6e1ec3a4
|
Andreas Kohlbecker
|
// better clear secref_cache since i can not be sure if the cache has not be used during this response
|
260 |
|
|
cdm_api_secref_cache_clear();
|
261 |
812a9c04
|
Andreas Kohlbecker
|
}
|
262 |
5d53a642
|
Andreas Kohlbecker
|
if($form_values['cdm_webservice_cache'] != variable_get('cdm_webservice_cache', 1)){
|
263 |
|
|
cache_clear_all(NULL, 'cache_cdm_ws');
|
264 |
6e1ec3a4
|
Andreas Kohlbecker
|
// better clear secref_cache since i can not be sure if the cache has not be used during this response
|
265 |
|
|
cdm_api_secref_cache_clear();
|
266 |
5d53a642
|
Andreas Kohlbecker
|
}
|
267 |
812a9c04
|
Andreas Kohlbecker
|
|
268 |
47a8c0dd
|
Andreas Kohlbecker
|
}
|
269 |
|
|
|
270 |
94112bee
|
n.hoffmann
|
/*
|
271 |
a27e2588
|
Andreas Kohlbecker
|
function cdm_dataportal_session_clear($cdm_ws_uri_update = false){
|
272 |
|
|
$_SESSION['cdm'] = null;
|
273 |
|
|
if(is_string($cdm_ws_uri_update)){
|
274 |
|
|
$_SESSION['cdm'] = array('ws_uri'=>$cdm_ws_uri_update);
|
275 |
|
|
}
|
276 |
|
|
}
|
277 |
|
|
|
278 |
|
|
function cdm_dataportal_session_validate(){
|
279 |
|
|
|
280 |
|
|
if(!isset($_SESSION['cdm']['ws_uri'])){
|
281 |
|
|
$_SESSION['cdm'] = array('ws_uri'=>variable_get('cdm_webservice_url', false));
|
282 |
|
|
} else if($_SESSION['cdm']['ws_uri'] != variable_get('cdm_webservice_url', false)){
|
283 |
|
|
cdm_dataportal_session_clear(variable_get('cdm_webservice_url', false));
|
284 |
|
|
}
|
285 |
|
|
}
|
286 |
44e02685
|
Andreas Kohlbecker
|
*/
|
287 |
812a9c04
|
Andreas Kohlbecker
|
|
288 |
2447830d
|
Andreas Kohlbecker
|
function cdm_dataportal_search_taxon_form($advancedForm = false){
|
289 |
|
|
|
290 |
|
|
$preset_query = (isset($_SESSION['cdm']['search']['query']) ? $_SESSION['cdm']['search']['query'] : '');
|
291 |
fa650011
|
Andreas Kohlbecker
|
$preset_doTaxa = (isset($_SESSION['cdm']['search']['doTaxa']) ? 1 : 0);
|
292 |
abd0ab13
|
Andreas Kohlbecker
|
$preset_doSynonyms = (isset($_SESSION['cdm']['search']['doSynonyms']) ? 1 : 0);
|
293 |
|
|
$preset_doTaxaByCommonNames = (isset($_SESSION['cdm']['search']['doTaxaByCommonNames']) ? 1 : 0);
|
294 |
8934f97c
|
Andreas Kohlbecker
|
$tdwg_level_select = (isset($_SESSION['cdm']['search']['tdwg_level_select']) ? $_SESSION['cdm']['search']['tdwg_level_select'] : 2);
|
295 |
fa650011
|
Andreas Kohlbecker
|
$selected_areas = (isset($_SESSION['cdm']['search']['area']) ? $_SESSION['cdm']['search']['area'] : false);
|
296 |
ee99abea
|
Andreas Kohlbecker
|
|
297 |
6611904c
|
Andreas Kohlbecker
|
$url = 'cdm_dataportal/search/taxon';
|
298 |
|
|
$form['#method'] = 'get';
|
299 |
|
|
$form['#process'] = array('cdm_dataportal_search_process' => array());
|
300 |
|
|
$form['#action'] = url($url, NULL, NULL, true);
|
301 |
|
|
|
302 |
24b09d7c
|
Andreas Kohlbecker
|
$form['query'] = array(
|
303 |
2447830d
|
Andreas Kohlbecker
|
'#delta' => 0,
|
304 |
ee99abea
|
Andreas Kohlbecker
|
'#type' => 'textfield',
|
305 |
|
|
'#size' => 20,
|
306 |
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')),
|
307 |
2447830d
|
Andreas Kohlbecker
|
'#value' => $preset_query,
|
308 |
6611904c
|
Andreas Kohlbecker
|
);
|
309 |
|
|
|
310 |
2447830d
|
Andreas Kohlbecker
|
$form['search'] = array(
|
311 |
|
|
'#delta' => 1,
|
312 |
|
|
'#tree' => true,
|
313 |
|
|
//'#type' => $advancedForm ? 'fieldset': 'hidden',
|
314 |
|
|
'#title' => t('Options')
|
315 |
|
|
);
|
316 |
8934f97c
|
Andreas Kohlbecker
|
|
317 |
9ee2882b
|
Andreas Kohlbecker
|
$form['search']['tree'] = array(
|
318 |
8934f97c
|
Andreas Kohlbecker
|
'#delta' => -1,
|
319 |
|
|
'#type' => 'hidden',
|
320 |
9ee2882b
|
Andreas Kohlbecker
|
'#value' => variable_get('cdm_taxonomictree_uuid', false)
|
321 |
8934f97c
|
Andreas Kohlbecker
|
);
|
322 |
2447830d
|
Andreas Kohlbecker
|
|
323 |
6611904c
|
Andreas Kohlbecker
|
|
324 |
|
|
// clean URL get forms breaks if we don't give it a 'q'.
|
325 |
|
|
if (!(bool)variable_get('clean_url', '0')) {
|
326 |
2447830d
|
Andreas Kohlbecker
|
$form['search']['q'] = array(
|
327 |
|
|
'#delta' => -1,
|
328 |
6611904c
|
Andreas Kohlbecker
|
'#type' => 'hidden',
|
329 |
|
|
'#value' => $url,
|
330 |
|
|
'#name' => 'q',
|
331 |
|
|
);
|
332 |
|
|
}
|
333 |
2447830d
|
Andreas Kohlbecker
|
|
334 |
|
|
$form['search']['pageSize'] = array(
|
335 |
|
|
'#delta' => -1,
|
336 |
|
|
'#type' => 'hidden',
|
337 |
|
|
'#value' => variable_get('cdm_dataportal_search_items_on_page', 25)
|
338 |
|
|
);
|
339 |
|
|
|
340 |
|
|
if($advancedForm){
|
341 |
8934f97c
|
Andreas Kohlbecker
|
// general search parameters
|
342 |
|
|
$form['search']['doTaxa'] = array(
|
343 |
2447830d
|
Andreas Kohlbecker
|
'#delta' => 2,
|
344 |
|
|
'#type' => 'checkbox',
|
345 |
|
|
'#title' => t('Search for accepted taxa'),
|
346 |
|
|
'#value' => $preset_doTaxa
|
347 |
8934f97c
|
Andreas Kohlbecker
|
);
|
348 |
|
|
$form['search']['doSynonyms'] = array(
|
349 |
2447830d
|
Andreas Kohlbecker
|
'#delta' => 3,
|
350 |
|
|
'#type' => 'checkbox',
|
351 |
|
|
'#title' => t('Search for synonyms'),
|
352 |
|
|
'#value' => $preset_doSynonyms
|
353 |
8934f97c
|
Andreas Kohlbecker
|
);
|
354 |
|
|
$form['search']['doTaxaByCommonNames'] = array(
|
355 |
2447830d
|
Andreas Kohlbecker
|
'#delta' => 4,
|
356 |
|
|
'#type' => 'checkbox',
|
357 |
|
|
'#title' => t('Search for common names'),
|
358 |
|
|
'#value' => $preset_doTaxaByCommonNames
|
359 |
8934f97c
|
Andreas Kohlbecker
|
);
|
360 |
|
|
|
361 |
|
|
// Geographic Range
|
362 |
|
|
$form['search']['geographic_range'] = array(
|
363 |
|
|
'#type' => 'fieldset',
|
364 |
|
|
'#delta' => 5,
|
365 |
|
|
'#tree' => true,
|
366 |
|
|
'#title' => t('Geographic range'),
|
367 |
|
|
);
|
368 |
|
|
|
369 |
|
|
$form['search']['geographic_range']['tdwg_level_select'] = array(
|
370 |
|
|
'#type' => 'radios',
|
371 |
|
|
'#title' => t('Select a TDWG distribution level and code:'),
|
372 |
|
|
'#default_value' => $tdwg_level_select,
|
373 |
|
|
'#options' => array(
|
374 |
|
|
t('TDWG level-1, i.e. a continent'),
|
375 |
|
|
t('TDWG level-2'),
|
376 |
|
|
t('TDWG level-3, i.e. a country'),
|
377 |
|
|
t('TDWG level-4')
|
378 |
|
|
)
|
379 |
|
|
);
|
380 |
|
|
$tdwg[1] = cdm_ws_get(CDM_WS_TDWG_LEVEL, '1');
|
381 |
|
|
$tdwg[2] = cdm_ws_get(CDM_WS_TDWG_LEVEL, '2');
|
382 |
|
|
$tdwg[3] = cdm_ws_get(CDM_WS_TDWG_LEVEL, '3');
|
383 |
|
|
$tdwg[4] = cdm_ws_get(CDM_WS_TDWG_LEVEL, '4');
|
384 |
|
|
|
385 |
|
|
$tdwg_js = '';
|
386 |
|
|
foreach($tdwg as $key=>$tdwg_level){
|
387 |
|
|
$tdwgOptions = array();
|
388 |
|
|
$tdwgOptionsSelected = array();
|
389 |
|
|
foreach($tdwg_level as $area){
|
390 |
|
|
$representation = $area->representations[0];
|
391 |
|
|
$tdwgOptions[$representation->abbreviatedLabel] = $area->representation_L10n;
|
392 |
fa650011
|
Andreas Kohlbecker
|
if(is_array($selected_areas) && in_array($representation->abbreviatedLabel, $selected_areas)){
|
393 |
|
|
$tdwgOptionsSelected[] = $representation->abbreviatedLabel; //$area->uuid;
|
394 |
8934f97c
|
Andreas Kohlbecker
|
}
|
395 |
|
|
}
|
396 |
abd0ab13
|
Andreas Kohlbecker
|
asort($tdwgOptions);
|
397 |
8934f97c
|
Andreas Kohlbecker
|
$form['search']['geographic_range']['tdwg_level_'.$key] = array(
|
398 |
|
|
'#type' => 'select',
|
399 |
|
|
'#title' => t('TDWG level').' '.$key,
|
400 |
|
|
'#default_value' => $tdwgOptionsSelected,
|
401 |
|
|
'#multiple' => TRUE,
|
402 |
|
|
'#options' => $tdwgOptions
|
403 |
|
|
);
|
404 |
abd0ab13
|
Andreas Kohlbecker
|
$tdwg_js .= "$('#edit-search-geographic-range-tdwg-level-$key').parent()".($tdwg_level_select + 1 == $key ? '.show()' : '.hide()'). ";\n";
|
405 |
8934f97c
|
Andreas Kohlbecker
|
}
|
406 |
|
|
|
407 |
|
|
drupal_add_js(
|
408 |
|
|
"$(document).ready(function(){
|
409 |
|
|
|
410 |
|
|
$(\"input[@name='search[geographic_range][tdwg_level_select]']\").change(
|
411 |
|
|
function(event){
|
412 |
|
|
var selectId = $(\"input[@name='search[geographic_range][tdwg_level_select]']:checked\").val();
|
413 |
|
|
var i;
|
414 |
|
|
for(i = 0; i < 4; i++){
|
415 |
|
|
if(selectId == i){
|
416 |
|
|
$('#edit-search-geographic-range-tdwg-level-' + (i + 1) ).parent().fadeIn('slow');
|
417 |
|
|
$('#edit-search-geographic-range-tdwg-level-' + (i + 1)).children().removeAttr('selected');
|
418 |
|
|
} else {
|
419 |
|
|
$('#edit-search-geographic-range-tdwg-level-' + (i + 1)).parent().fadeOut('slow');
|
420 |
|
|
$('#edit-search-geographic-range-tdwg-level-' + (i + 1)).children().removeAttr('selected');
|
421 |
|
|
}
|
422 |
|
|
}
|
423 |
|
|
}
|
424 |
|
|
);
|
425 |
|
|
|
426 |
|
|
$tdwg_js
|
427 |
|
|
});",
|
428 |
|
|
'inline');
|
429 |
|
|
|
430 |
2447830d
|
Andreas Kohlbecker
|
} else {
|
431 |
|
|
$form['search']['doTaxa'] = array(
|
432 |
|
|
'#delta' => -2,
|
433 |
|
|
'#type' => 'hidden',
|
434 |
|
|
'#value' => 1
|
435 |
|
|
);
|
436 |
|
|
$form['search']['doSynonyms'] = array(
|
437 |
|
|
'#delta' => -3,
|
438 |
|
|
'#type' => 'hidden',
|
439 |
|
|
'#value' => 1
|
440 |
|
|
);
|
441 |
|
|
$form['search']['doTaxaByCommonNames'] = array(
|
442 |
|
|
'#delta' => -4,
|
443 |
|
|
'#type' => 'hidden',
|
444 |
|
|
'#value' => 1
|
445 |
|
|
);
|
446 |
|
|
}
|
447 |
|
|
|
448 |
|
|
$form['submit'] = array(
|
449 |
|
|
'#delta' => 9,
|
450 |
|
|
'#type' => 'submit',
|
451 |
|
|
'#name' => '',
|
452 |
|
|
'#value' => t('Search')
|
453 |
|
|
);
|
454 |
|
|
|
455 |
ee99abea
|
Andreas Kohlbecker
|
return $form;
|
456 |
|
|
}
|
457 |
|
|
|
458 |
2447830d
|
Andreas Kohlbecker
|
function cdm_dataportal_search_taxon_form_advanced(){
|
459 |
|
|
return cdm_dataportal_search_taxon_form(true);
|
460 |
|
|
}
|
461 |
|
|
|
462 |
24b09d7c
|
Andreas Kohlbecker
|
/**
|
463 |
|
|
* Implementation #process method call, see form_builder()
|
464 |
|
|
* <p>
|
465 |
|
|
* Removes Drupal internal form elements from query
|
466 |
|
|
* @param $form
|
467 |
|
|
* @return unknown_type
|
468 |
|
|
*/
|
469 |
6611904c
|
Andreas Kohlbecker
|
function cdm_dataportal_search_process($form) {
|
470 |
|
|
unset($form['form_id']);
|
471 |
|
|
unset($form['form_token']);
|
472 |
|
|
return $form;
|
473 |
|
|
}
|
474 |
|
|
|
475 |
|
|
/**
|
476 |
|
|
* Filters $_REQUEST by a list of valid request parameters and also sets defaults if required.
|
477 |
|
|
* returns the processed request parameters submitted by the search form.
|
478 |
|
|
*/
|
479 |
24b09d7c
|
Andreas Kohlbecker
|
function cdm_dataportal_search_form_request(){
|
480 |
daba333b
|
Andreas Kohlbecker
|
|
481 |
fa650011
|
Andreas Kohlbecker
|
|
482 |
|
|
$form_params = array();
|
483 |
|
|
array_deep_copy($_REQUEST['search'], $form_params);
|
484 |
|
|
$form_params['query'] = trim($_REQUEST['query']);
|
485 |
|
|
|
486 |
8934f97c
|
Andreas Kohlbecker
|
// split of geographic range
|
487 |
|
|
if(isset($_REQUEST['search']['geographic_range'])){
|
488 |
|
|
$geographicRange = $_REQUEST['search']['geographic_range'];
|
489 |
fa650011
|
Andreas Kohlbecker
|
// remove
|
490 |
|
|
unset($form_params['geographic_range']);
|
491 |
8934f97c
|
Andreas Kohlbecker
|
}
|
492 |
24b09d7c
|
Andreas Kohlbecker
|
|
493 |
8934f97c
|
Andreas Kohlbecker
|
// add geographic range
|
494 |
|
|
if($geographicRange){
|
495 |
|
|
$form_params['tdwg_level_select'] = $geographicRange['tdwg_level_select'];
|
496 |
|
|
for($i = 1; $i < 5; $i++){
|
497 |
|
|
if(isset($geographicRange['tdwg_level_'.$i])){
|
498 |
|
|
$form_params['area'] = $geographicRange['tdwg_level_'.$i];
|
499 |
|
|
}
|
500 |
|
|
}
|
501 |
|
|
}
|
502 |
|
|
|
503 |
|
|
// store in session
|
504 |
81df545f
|
Andreas Kohlbecker
|
$_SESSION['cdm']['search'] = $form_params;
|
505 |
24b09d7c
|
Andreas Kohlbecker
|
|
506 |
6611904c
|
Andreas Kohlbecker
|
return $form_params;
|
507 |
|
|
}
|
508 |
|
|
|
509 |
|
|
|
510 |
81df545f
|
Andreas Kohlbecker
|
/* UNREACHABLE since action of form directly links to view
|
511 |
ee99abea
|
Andreas Kohlbecker
|
function cdm_dataportal_search_taxon_form_submit($form_id, $form_values) {
|
512 |
|
|
|
513 |
|
|
$_SESSION['cdm']['search'] = $form_values;
|
514 |
94112bee
|
n.hoffmann
|
//return '/cdm_dataportal/search/taxon/'.$form_values['queryString'].'/'.($form_values['vernacular']?'1':'0').'/'.$form_values['language'];
|
515 |
|
|
return '/cdm_dataportal/search/taxon/'.$form_values['queryString'].'/'.($form_values['onlyAccepted']?'1':'0');
|
516 |
cacc1bbf
|
Andreas Kohlbecker
|
//$paramstr = compose_url_prameterstr($form_values);
|
517 |
|
|
//return url('/cdm_dataportal/search/taxon/', $paramstr);
|
518 |
ee99abea
|
Andreas Kohlbecker
|
}
|
519 |
6611904c
|
Andreas Kohlbecker
|
*/
|
520 |
9cc1a3e2
|
Andreas Kohlbecker
|
/* ====================== menu callback functions ====================== */
|
521 |
|
|
|
522 |
|
|
/**
|
523 |
|
|
* Generate main administration form.
|
524 |
|
|
*
|
525 |
|
|
* @return
|
526 |
|
|
* An array containing form items to place on the module settings page.
|
527 |
|
|
*/
|
528 |
|
|
function cdm_dataportal_settings(){
|
529 |
|
|
|
530 |
2e748209
|
Andreas Kohlbecker
|
$form = cdm_api_settings_form();
|
531 |
80047c07
|
Andreas Kohlbecker
|
|
532 |
2e748209
|
Andreas Kohlbecker
|
//TODO: settings are still incomplete, compare with trunk/dataportal/inc/config_default.php.inc
|
533 |
6ee322a7
|
Andreas Kohlbecker
|
$form['cdm_dataportal'] = array(
|
534 |
|
|
'#type' => 'fieldset',
|
535 |
|
|
'#title' => t('CDM DataPortal'),
|
536 |
|
|
'#collapsible' => FALSE,
|
537 |
|
|
'#collapsed' => TRUE,
|
538 |
|
|
);
|
539 |
30c5a6bd
|
Andreas Kohlbecker
|
|
540 |
2447830d
|
Andreas Kohlbecker
|
// $form['cdm_dataportal']['secuuid_widget'] = array(
|
541 |
|
|
// '#type' => 'select_secuuid', // => will be themed by theme_select_secuuid(...)
|
542 |
|
|
// '#title' => t('Default Concept References'),
|
543 |
|
|
// '#description' => t('The default \'sensu\' reference to start the CDM DataPortal with. Per user choices are possible and may override this value.'),
|
544 |
|
|
// '#varname' => 'cdm_secUuid_default',
|
545 |
|
|
// '#multiple' => false
|
546 |
|
|
// );
|
547 |
|
|
|
548 |
|
|
$taxonTrees = cdm_ws_get(CDM_WS_TAXONOMY);
|
549 |
|
|
foreach($taxonTrees as $tree){
|
550 |
|
|
$taxonomicTreeOptions[$tree->uuid] = $tree->titleCache;
|
551 |
|
|
}
|
552 |
|
|
$form['cdm_dataportal']['cdm_taxonomictree_uuid'] = array(
|
553 |
|
|
'#type' => 'select',
|
554 |
|
|
'#title' => t('Available taxonomic views'),
|
555 |
|
|
'#default_value' => variable_get('cdm_taxonomictree_uuid', false),
|
556 |
|
|
'#options' => $taxonomicTreeOptions,
|
557 |
|
|
'#description' => t('Select a taxonomic view for this webservice.')
|
558 |
|
|
);
|
559 |
94112bee
|
n.hoffmann
|
|
560 |
9d98a3c0
|
n.hoffmann
|
|
561 |
|
|
//------------------ FEATURE TREE --------------------//
|
562 |
|
|
|
563 |
|
|
$form['cdm_dataportal']['feature_tree'] = array(
|
564 |
|
|
'#type' => 'fieldset',
|
565 |
|
|
'#title' => t('Feature Tree'),
|
566 |
|
|
'#collapsible' => TRUE,
|
567 |
|
|
'#collapsed' => TRUE,
|
568 |
|
|
);
|
569 |
|
|
|
570 |
24b09d7c
|
Andreas Kohlbecker
|
$form['cdm_dataportal']['feature_tree']['cdm_dataportal_featuretree_uuid'] = array(
|
571 |
94112bee
|
n.hoffmann
|
'#type' => 'select',
|
572 |
d93dad11
|
n.hoffmann
|
'#title' => t('Available FeatureTrees'),
|
573 |
24b09d7c
|
Andreas Kohlbecker
|
'#default_value' => variable_get('cdm_dataportal_featuretree_uuid', false),
|
574 |
|
|
'#options' => _get_feature_trees(),
|
575 |
|
|
'#description' => t('Select a FeatureTree for this webservice.'
|
576 |
|
|
//.' If there is no applicable FeatureTree you can create a new one using the <a href="">FeatureTreeManager</a>'
|
577 |
|
|
)
|
578 |
94112bee
|
n.hoffmann
|
);
|
579 |
39ceedd6
|
n.hoffmann
|
|
580 |
d93dad11
|
n.hoffmann
|
//------------------ LAYOUT --------------------//
|
581 |
|
|
|
582 |
39ceedd6
|
n.hoffmann
|
$form['cdm_dataportal']['layout'] = array(
|
583 |
|
|
'#type' => 'fieldset',
|
584 |
|
|
'#title' => t('Layout'),
|
585 |
9d98a3c0
|
n.hoffmann
|
'#collapsible' => TRUE,
|
586 |
39ceedd6
|
n.hoffmann
|
'#collapsed' => TRUE,
|
587 |
ff6a8ea7
|
Andreas Kohlbecker
|
);
|
588 |
|
|
|
589 |
70fb5e15
|
Andreas Kohlbecker
|
$form['cdm_dataportal']['layout']['cdm_taxonname_type'] = array(
|
590 |
ff6a8ea7
|
Andreas Kohlbecker
|
'#type' => 'select',
|
591 |
|
|
'#title' => t('Taxon name type'),
|
592 |
|
|
'#default_value' => variable_get('cdm_taxonname_type', 'BotanicalName'),
|
593 |
|
|
'#options' => array( 'BotanicalName'=>t('BotanicalName'), 'ZoologicalName'=>t('ZoologicalName')),
|
594 |
|
|
'#description' => t('')
|
595 |
39ceedd6
|
n.hoffmann
|
);
|
596 |
|
|
|
597 |
|
|
$form['cdm_dataportal']['layout']['cdm_dataportal_nomref_in_title'] = array(
|
598 |
|
|
'#type' => 'checkbox',
|
599 |
72568f3e
|
Andreas Kohlbecker
|
'#title' => t('Hide full nomenclatural reference in title'),
|
600 |
39ceedd6
|
n.hoffmann
|
'#default_value' => variable_get('cdm_dataportal_nomref_in_title', 1),
|
601 |
72568f3e
|
Andreas Kohlbecker
|
'#description' => t('Uncheck this, if you want the title of a taxon page consisting of name and author plus publication year only.
|
602 |
39ceedd6
|
n.hoffmann
|
If not checked, the first homotypic taxon is a repetition of the accepted taxon with
|
603 |
|
|
the full nomenclatural reference.')
|
604 |
|
|
);
|
605 |
d93dad11
|
n.hoffmann
|
|
606 |
|
|
$form['cdm_dataportal']['layout']['cdm_dataportal_display_name_relations'] = array(
|
607 |
|
|
'#type' => 'checkbox',
|
608 |
|
|
'#title' => t('Show name relations of accepted taxa on taxon page'),
|
609 |
|
|
'#default_value' => variable_get('cdm_dataportal_display_name_relations', 1),
|
610 |
|
|
'#description' => t('')
|
611 |
4726aac7
|
Andreas Kohlbecker
|
);
|
612 |
|
|
|
613 |
24b09d7c
|
Andreas Kohlbecker
|
$form['cdm_dataportal']['layout']['cdm_dataportal_name_relations_skiptype_basionym'] = array(
|
614 |
|
|
'#type' => 'checkbox',
|
615 |
|
|
'#title' => t('Exclude the basionym relationship type from the taxon page'),
|
616 |
|
|
'#default_value' => variable_get('cdm_dataportal_name_relations_skiptype_basionym', 1),
|
617 |
|
|
'#description' => t('')
|
618 |
|
|
);
|
619 |
|
|
|
620 |
4726aac7
|
Andreas Kohlbecker
|
$form['cdm_dataportal']['layout']['cdm_dataportal_taxonpage_tabs'] = array(
|
621 |
|
|
'#type' => 'checkbox',
|
622 |
1c01d44e
|
Andreas Kohlbecker
|
'#title' => t('Tabbed taxon page'),
|
623 |
4726aac7
|
Andreas Kohlbecker
|
'#default_value' => variable_get('cdm_dataportal_taxonpage_tabs', 1),
|
624 |
24b09d7c
|
Andreas Kohlbecker
|
'#description' => t('Split the taxon page into individual tabs for description, images, synonymy')
|
625 |
d93dad11
|
n.hoffmann
|
);
|
626 |
|
|
|
627 |
|
|
$form['cdm_dataportal']['layout']['cdm_dataportal_search_items_on_page'] = array(
|
628 |
|
|
'#type' => 'textfield',
|
629 |
|
|
'#title' => t('Search Page Size'),
|
630 |
30c5a6bd
|
Andreas Kohlbecker
|
'#default_value' => variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE),
|
631 |
24b09d7c
|
Andreas Kohlbecker
|
'#description' => t('Number of Names to display per page in search results.')
|
632 |
|
|
);
|
633 |
|
|
|
634 |
|
|
$form['cdm_dataportal']['layout']['cdm_dataportal_descriptions_separated'] = array(
|
635 |
|
|
'#type' => 'checkbox',
|
636 |
|
|
'#title' => t('Separate Desriptions'),
|
637 |
|
|
'#default_value' => variable_get('cdm_dataportal_descriptions_separated', 0),
|
638 |
|
|
'#description' => t('By default corresponding elements of different descriptions are joined together'
|
639 |
|
|
.' into a common section per feature (i.e. type of description).'
|
640 |
|
|
.' Check this box to allow displaying all descriptions separately.')
|
641 |
9fcd1980
|
Andreas Kohlbecker
|
);
|
642 |
|
|
|
643 |
70fb5e15
|
Andreas Kohlbecker
|
$options = cdm_rankVocabulary_as_option();
|
644 |
|
|
array_unshift($options, '-- DISABLED --');
|
645 |
|
|
$form['cdm_dataportal']['layout']['image_hide_rank'] = array(
|
646 |
|
|
'#type' => 'select',
|
647 |
|
|
'#title' => t('Hide Images for Taxa above'),
|
648 |
|
|
'#default_value' => variable_get('image_hide_rank', '0'),
|
649 |
|
|
'#options' => $options,
|
650 |
|
|
'#description' => t(''),
|
651 |
|
|
);
|
652 |
|
|
|
653 |
|
|
// --- find taxa ---- //
|
654 |
784a4314
|
Andreas Kohlbecker
|
$form['cdm_dataportal']['layout']['findtaxa'] = array(
|
655 |
|
|
'#type' => 'fieldset',
|
656 |
|
|
'#title' => t('Search Taxa'),
|
657 |
|
|
'#collapsible' => TRUE,
|
658 |
|
|
'#collapsed' => TRUE,
|
659 |
|
|
);
|
660 |
|
|
|
661 |
9834a411
|
Andreas Kohlbecker
|
//variable_get('', 1);
|
662 |
|
|
$form['cdm_dataportal']['layout']['findtaxa']['cdm_dataportal_findtaxa_show_taxon_thumbnails'] = array(
|
663 |
784a4314
|
Andreas Kohlbecker
|
'#type' => 'checkbox',
|
664 |
9834a411
|
Andreas Kohlbecker
|
'#title' => t('Show media thumbnails for accepted taxa'),
|
665 |
|
|
'#default_value' => variable_get('cdm_dataportal_findtaxa_show_taxon_thumbnails', 1),
|
666 |
784a4314
|
Andreas Kohlbecker
|
'#description' => t('')
|
667 |
|
|
);
|
668 |
|
|
|
669 |
9834a411
|
Andreas Kohlbecker
|
$form['cdm_dataportal']['layout']['findtaxa']['cdm_dataportal_findtaxa_show_synonym_thumbnails'] = array(
|
670 |
784a4314
|
Andreas Kohlbecker
|
'#type' => 'checkbox',
|
671 |
9834a411
|
Andreas Kohlbecker
|
'#title' => t('Show media thumbnails for syonyms'),
|
672 |
|
|
'#default_value' => variable_get('cdm_dataportal_findtaxa_show_synonym_thumbnails', 0),
|
673 |
|
|
'#description' => t('')
|
674 |
|
|
);
|
675 |
|
|
|
676 |
|
|
// $showCaption = variable_get('cdm_dataportal_findtaxa_show_thumbnail_captions', 0);
|
677 |
|
|
$form['cdm_dataportal']['layout']['findtaxa']['cdm_dataportal_findtaxa_show_thumbnail_captions'] = array(
|
678 |
|
|
'#type' => 'checkbox',
|
679 |
|
|
'#title' => t('Show captions under thumbnails'),
|
680 |
|
|
'#default_value' => variable_get('cdm_dataportal_findtaxa_show_thumbnail_captions', 1),
|
681 |
784a4314
|
Andreas Kohlbecker
|
'#description' => t('')
|
682 |
|
|
);
|
683 |
|
|
|
684 |
|
|
$form['cdm_dataportal']['layout']['findtaxa']['cdm_dataportal_findtaxa_media_maxextend'] = array(
|
685 |
|
|
'#type' => 'textfield',
|
686 |
|
|
'#title' => t('Maximum extend of Images'),
|
687 |
|
|
'#default_value' => variable_get('cdm_dataportal_findtaxa_media_maxextend', 120),
|
688 |
|
|
'#description' => t('')
|
689 |
|
|
);
|
690 |
|
|
|
691 |
|
|
$form['cdm_dataportal']['layout']['findtaxa']['cdm_dataportal_findtaxa_media_cols'] = array(
|
692 |
|
|
'#type' => 'textfield',
|
693 |
|
|
'#title' => t('Number of columns'),
|
694 |
|
|
'#default_value' => variable_get('cdm_dataportal_findtaxa_media_cols', 3),
|
695 |
|
|
'#description' => t('')
|
696 |
|
|
);
|
697 |
|
|
|
698 |
|
|
$form['cdm_dataportal']['layout']['findtaxa']['cdm_dataportal_findtaxa_media_maxRows'] = array(
|
699 |
|
|
'#type' => 'textfield',
|
700 |
|
|
'#title' => t('Maximum number of rows'),
|
701 |
|
|
'#default_value' => variable_get('cdm_dataportal_findtaxa_media_maxRows', 1),
|
702 |
|
|
'#description' => t('')
|
703 |
|
|
);
|
704 |
|
|
|
705 |
|
|
|
706 |
9fcd1980
|
Andreas Kohlbecker
|
|
707 |
e4f58fa1
|
n.hoffmann
|
//---------------- GEOSERVICE ----------------//
|
708 |
|
|
|
709 |
|
|
$form['cdm_dataportal']['geoservice'] = array(
|
710 |
|
|
'#type' => 'fieldset',
|
711 |
|
|
'#title' => t('Geoservice'),
|
712 |
9d98a3c0
|
n.hoffmann
|
'#collapsible' => TRUE,
|
713 |
e4f58fa1
|
n.hoffmann
|
'#collapsed' => TRUE,
|
714 |
784a4314
|
Andreas Kohlbecker
|
);
|
715 |
|
|
|
716 |
|
|
$form['cdm_dataportal']['geoservice']['cdm_dataportal_map_openlayers'] = array(
|
717 |
|
|
'#type' => 'checkbox',
|
718 |
|
|
'#title' => t('OpenLayers Viewer'),
|
719 |
|
|
'#default_value' => variable_get('cdm_dataportal_map_openlayers', 1),
|
720 |
|
|
'#description' => t('Display the maps in an interactive viewer which allows zooming and panning.')
|
721 |
e4f58fa1
|
n.hoffmann
|
);
|
722 |
|
|
|
723 |
|
|
$form['cdm_dataportal']['geoservice']['cdm_dataportal_geoservice_access_point'] = array(
|
724 |
|
|
'#type' => 'textfield',
|
725 |
|
|
'#title' => t('Geoservice Access Point'),
|
726 |
|
|
'#default_value' => variable_get('cdm_dataportal_geoservice_access_point', ''),
|
727 |
|
|
'#description' => t('Base URL of the geoservice to be used by this portal')
|
728 |
|
|
);
|
729 |
|
|
|
730 |
|
|
$form['cdm_dataportal']['geoservice']['cdm_dataportal_geoservice_display_width'] = array(
|
731 |
|
|
'#type' => 'textfield',
|
732 |
|
|
'#title' => t('Geoservice Display Width'),
|
733 |
|
|
'#default_value' => variable_get('cdm_dataportal_geoservice_display_width', 390),
|
734 |
|
|
'#description' => t('Width of the image generated by geoservice')
|
735 |
|
|
);
|
736 |
|
|
|
737 |
|
|
$form['cdm_dataportal']['geoservice']['cdm_dataportal_geoservice_bounding_box'] = array(
|
738 |
|
|
'#type' => 'textfield',
|
739 |
9d47d187
|
Andreas Kohlbecker
|
'#title' => t('Fixed Geoservice Bounding Box'),
|
740 |
e4f58fa1
|
n.hoffmann
|
'#default_value' => variable_get('cdm_dataportal_geoservice_bounding_box', '-180,-90,180,90'),
|
741 |
9d47d187
|
Andreas Kohlbecker
|
'#description' => t('Define urrounding of area to be displayed in maps. Use "-180,-90,180,90" for the whole world. Leave <strong>empty</strong> to let the map <strong>automatically zoom</strong> to the distribution area.')
|
742 |
9fcd1980
|
Andreas Kohlbecker
|
);
|
743 |
|
|
|
744 |
|
|
//cdm_dataportal_geoservice_labels_on
|
745 |
|
|
$form['cdm_dataportal']['geoservice']['cdm_dataportal_geoservice_labels_on'] = array(
|
746 |
|
|
'#type' => 'checkbox',
|
747 |
|
|
'#title' => t('Display Country Labels'),
|
748 |
|
|
'#default_value' => variable_get('cdm_dataportal_geoservice_labels_on', FALSE),
|
749 |
|
|
'#description' => t('Check this if you like country names to be displayed in the maps. ')
|
750 |
2447830d
|
Andreas Kohlbecker
|
);
|
751 |
|
|
|
752 |
|
|
//cdm_dataportal_geoservice_legend_on
|
753 |
|
|
$form['cdm_dataportal']['geoservice']['cdm_dataportal_geoservice_legend_on'] = array(
|
754 |
|
|
'#type' => 'checkbox',
|
755 |
|
|
'#title' => t('Display a map legend'),
|
756 |
|
|
'#default_value' => variable_get('cdm_dataportal_geoservice_legend_on', TRUE),
|
757 |
|
|
'#description' => t('Check this if you like a legend to be displayed with the maps. ')
|
758 |
e4f58fa1
|
n.hoffmann
|
);
|
759 |
a22e3f38
|
Andreas Kohlbecker
|
|
760 |
e38d39d6
|
Andreas Kohlbecker
|
return system_settings_form($form);
|
761 |
|
|
}
|
762 |
|
|
|
763 |
|
|
/**
|
764 |
|
|
* Implementation of hook_elements().
|
765 |
|
|
*/
|
766 |
|
|
function cdm_dataportal_elements() {
|
767 |
|
|
$type['select_secuuid'] = array(
|
768 |
94112bee
|
n.hoffmann
|
'#input' => TRUE,
|
769 |
e38d39d6
|
Andreas Kohlbecker
|
'#process' => array('cdm_dataportal_select_secuuid_expand' => array()),
|
770 |
|
|
//'#validate' => array('cdm_dataportal_select_secuuid_validate' => array()),
|
771 |
|
|
//'#default_value' => array(),
|
772 |
e18349d4
|
Andreas Kohlbecker
|
);
|
773 |
e38d39d6
|
Andreas Kohlbecker
|
return $type;
|
774 |
|
|
}
|
775 |
|
|
|
776 |
|
|
/*
|
777 |
94112bee
|
n.hoffmann
|
*
|
778 |
e38d39d6
|
Andreas Kohlbecker
|
*/
|
779 |
|
|
function cdm_dataportal_select_secuuid_expand($element){
|
780 |
e18349d4
|
Andreas Kohlbecker
|
|
781 |
e38d39d6
|
Andreas Kohlbecker
|
$element['#tree'] = FALSE;
|
782 |
|
|
|
783 |
|
|
// any value submitted?
|
784 |
|
|
if(isset($element['#post'][$element['#varname']])){
|
785 |
|
|
$selected_values = $element['#post'][$element['#varname']];
|
786 |
|
|
} else {
|
787 |
|
|
// use those store in drupal
|
788 |
|
|
$selected_values = variable_get( $element['#varname'], array());
|
789 |
|
|
}
|
790 |
|
|
if(!is_array($selected_values)){
|
791 |
|
|
$selected_values = array($selected_values);
|
792 |
|
|
}
|
793 |
|
|
$options = array();
|
794 |
|
|
foreach($selected_values as $secUuid){
|
795 |
44e02685
|
Andreas Kohlbecker
|
$options[$secUuid] = cdm_taxontree_secRefTitle_for($secUuid);
|
796 |
e38d39d6
|
Andreas Kohlbecker
|
}
|
797 |
e18349d4
|
Andreas Kohlbecker
|
|
798 |
e38d39d6
|
Andreas Kohlbecker
|
$element[$element['#varname']] = array(
|
799 |
|
|
'#type' => 'select',
|
800 |
|
|
'#options' => $options,
|
801 |
|
|
'#default_value' => array_values($options),
|
802 |
|
|
'#size' => $element['#multiple'] ? 12 : 2,
|
803 |
|
|
'#multiple' => $element['#multiple'],
|
804 |
|
|
);
|
805 |
|
|
return $element;
|
806 |
|
|
}
|
807 |
|
|
|
808 |
|
|
|
809 |
|
|
|
810 |
9cc1a3e2
|
Andreas Kohlbecker
|
/**
|
811 |
|
|
* Displays a list of the known taxonomic names. Long lists are split up into multiple pages
|
812 |
|
|
*
|
813 |
55e5b62d
|
Andreas Kohlbecker
|
* TODO: parameters are still preliminar
|
814 |
9cc1a3e2
|
Andreas Kohlbecker
|
* @param String $page page number to diplay defaults to page 1
|
815 |
|
|
* @param boolean $hide_unaccepted whether to hide nams which are not accepted by the current view
|
816 |
|
|
*/
|
817 |
afbbba9e
|
Andreas Kohlbecker
|
function cdm_dataportal_view_names($beginsWith = 'A', $page = 1, $onlyAccepted = false ){
|
818 |
67a4a4c6
|
Andreas Kohlbecker
|
|
819 |
ee99abea
|
Andreas Kohlbecker
|
$request_params = array(
|
820 |
94112bee
|
n.hoffmann
|
'q' => $beginsWith,
|
821 |
ee99abea
|
Andreas Kohlbecker
|
//'sec' = '',
|
822 |
|
|
//'higherTaxa' => getFiters(),
|
823 |
|
|
// 'matchAnywhere' => false, // default is false
|
824 |
94112bee
|
n.hoffmann
|
'page' => $page,
|
825 |
|
|
'onlyAccepted' => $onlyAccepted,
|
826 |
ee99abea
|
Andreas Kohlbecker
|
'pagesize' => 20 /*$_SESSION['cdm']['namelist_pagesize'] */);
|
827 |
|
|
|
828 |
30c5a6bd
|
Andreas Kohlbecker
|
$taxonPager = cdm_ws_find(CDM_WS_FIND_TAXA, $request_params);
|
829 |
67a4a4c6
|
Andreas Kohlbecker
|
/*
|
830 |
|
|
* FIXME the filter for accepted names will be a form element, thus this widget
|
831 |
|
|
* should be generated via form api preferably as block
|
832 |
|
|
*/
|
833 |
|
|
//$out = theme('cdm_dataportal_widget_filter_accepted', $onlyAccepted);
|
834 |
|
|
//$out .= theme('cdm_dataportal_widget_names_list', $names, $page);
|
835 |
30c5a6bd
|
Andreas Kohlbecker
|
$out .= theme('cdm_listof_taxa', $taxonPager);
|
836 |
67a4a4c6
|
Andreas Kohlbecker
|
return $out;
|
837 |
9cc1a3e2
|
Andreas Kohlbecker
|
}
|
838 |
|
|
|
839 |
4726aac7
|
Andreas Kohlbecker
|
function cdm_dataportal_view_reference($uuid, $arg2 = null){
|
840 |
30c5a6bd
|
Andreas Kohlbecker
|
$reference = cdm_ws_get(CDM_WS_REFERENCE, $uuid);
|
841 |
|
|
return theme('cdm_reference_page', $reference);
|
842 |
4726aac7
|
Andreas Kohlbecker
|
}
|
843 |
|
|
|
844 |
46a52efe
|
Andreas Kohlbecker
|
function cdm_dataportal_view_reference_list($pageNumber){
|
845 |
30c5a6bd
|
Andreas Kohlbecker
|
$referencePager = cdm_ws_page(CDM_WS_REFERENCE, variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE), $pageNumber);
|
846 |
46a52efe
|
Andreas Kohlbecker
|
return theme('cdm_reference_pager', $referencePager, 'cdm_dataportal/reference/list/');
|
847 |
|
|
}
|
848 |
|
|
|
849 |
b09e63fd
|
Andreas Kohlbecker
|
function cdm_dataportal_view_media($mediaUuid, $mediarepresentation_uuid = false, $part = 0){
|
850 |
2cd9a3d6
|
Andreas Kohlbecker
|
$media = cdm_ws_get(CDM_WS_MEDIA, $mediaUuid);
|
851 |
b09e63fd
|
Andreas Kohlbecker
|
return theme('cdm_media_page', $media, $mediarepresentation_uuid, $part);
|
852 |
2cd9a3d6
|
Andreas Kohlbecker
|
}
|
853 |
|
|
|
854 |
9cc1a3e2
|
Andreas Kohlbecker
|
/**
|
855 |
|
|
* The taxon page gives detailed information on a taxon, it shows:
|
856 |
|
|
* - Taxon name
|
857 |
67a4a4c6
|
Andreas Kohlbecker
|
* - Full list of synonyms homotypic synonyms on top, followed by the
|
858 |
|
|
* heterotypic and finally followed by misapplied names.
|
859 |
afbbba9e
|
Andreas Kohlbecker
|
* The list is ordered historically.
|
860 |
67a4a4c6
|
Andreas Kohlbecker
|
* - All facts associated with the very taxon concept and taxon name.
|
861 |
9cc1a3e2
|
Andreas Kohlbecker
|
*
|
862 |
67a4a4c6
|
Andreas Kohlbecker
|
* @param String $uuid the UUID of the taxon
|
863 |
9cc1a3e2
|
Andreas Kohlbecker
|
*/
|
864 |
24b09d7c
|
Andreas Kohlbecker
|
function cdm_dataportal_view_taxon($uuid, $chapter = null){
|
865 |
53a13220
|
Andreas Kohlbecker
|
|
866 |
|
|
// display the page for the taxon defined by $uuid
|
867 |
30c5a6bd
|
Andreas Kohlbecker
|
$taxon = cdm_ws_get(CDM_WS_TAXON, $uuid);
|
868 |
|
|
if(!$taxon){
|
869 |
a27e2588
|
Andreas Kohlbecker
|
drupal_set_title(t('Taxon does not exist'));
|
870 |
94112bee
|
n.hoffmann
|
return false;
|
871 |
a27e2588
|
Andreas Kohlbecker
|
}
|
872 |
30c5a6bd
|
Andreas Kohlbecker
|
_cdm_dataportal_set_currentSecUuid($taxon->sec->uuid);
|
873 |
72568f3e
|
Andreas Kohlbecker
|
|
874 |
24b09d7c
|
Andreas Kohlbecker
|
drupal_set_title(theme('cdm_taxon_page_title', $taxon));
|
875 |
30c5a6bd
|
Andreas Kohlbecker
|
$out = theme('cdm_taxon_page_general', $taxon, $chapter);
|
876 |
72568f3e
|
Andreas Kohlbecker
|
|
877 |
53a13220
|
Andreas Kohlbecker
|
return $out;
|
878 |
4726aac7
|
Andreas Kohlbecker
|
/*}*/
|
879 |
53a13220
|
Andreas Kohlbecker
|
}
|
880 |
67a4a4c6
|
Andreas Kohlbecker
|
|
881 |
2447830d
|
Andreas Kohlbecker
|
function cdm_dataportal_view_search_advanced(){
|
882 |
|
|
|
883 |
|
|
drupal_set_title(t('Advanced Search'));
|
884 |
|
|
|
885 |
|
|
$searchForm = cdm_dataportal_search_taxon_form(true);
|
886 |
|
|
|
887 |
|
|
return drupal_get_form('cdm_dataportal_search_taxon_form_advanced');
|
888 |
|
|
|
889 |
|
|
}
|
890 |
|
|
|
891 |
ee99abea
|
Andreas Kohlbecker
|
/**
|
892 |
94112bee
|
n.hoffmann
|
*
|
893 |
ee99abea
|
Andreas Kohlbecker
|
* future extensions to meet palmweb mockup requirements:
|
894 |
|
|
* - habitat
|
895 |
|
|
* - uses
|
896 |
|
|
* - conservation status
|
897 |
|
|
* - locality / tdwg region
|
898 |
|
|
*/
|
899 |
24b09d7c
|
Andreas Kohlbecker
|
function cdm_dataportal_view_search_taxon(){
|
900 |
|
|
|
901 |
64c1bd2d
|
n.hoffmann
|
$_SESSION['cdm']['last_search'] = $_SERVER['REQUEST_URI'];
|
902 |
daba333b
|
Andreas Kohlbecker
|
|
903 |
6611904c
|
Andreas Kohlbecker
|
$request_params = cdm_dataportal_search_form_request();
|
904 |
8934f97c
|
Andreas Kohlbecker
|
$taxonPager = cdm_ws_get(CDM_WS_FIND_TAXA, null, queryString($request_params));
|
905 |
24b09d7c
|
Andreas Kohlbecker
|
|
906 |
daba333b
|
Andreas Kohlbecker
|
$search_params = $_REQUEST;
|
907 |
|
|
unset($search_params['q']);
|
908 |
|
|
return theme('cdm_search_results', $taxonPager, 'cdm_dataportal/search/taxon', $search_params);
|
909 |
ee99abea
|
Andreas Kohlbecker
|
}
|
910 |
|
|
|
911 |
05fe0ad6
|
Andreas Kohlbecker
|
function cdm_view_xml2json(){
|
912 |
|
|
$file = arg(2);
|
913 |
|
|
$datastr = get_content(variable_get('cdm_webservice_url', '').$file);
|
914 |
|
|
return xml2json::transformXmlStringToJson($datastr);
|
915 |
fa97cd20
|
Andreas Kohlbecker
|
}
|
916 |
|
|
|
917 |
47a8c0dd
|
Andreas Kohlbecker
|
/* ====================== other functions ====================== */
|
918 |
|
|
|
919 |
ec0c70d2
|
Andreas Kohlbecker
|
/**
|
920 |
|
|
* Enter description here...
|
921 |
|
|
*
|
922 |
|
|
* @param String $uuid the UUID of the taxon
|
923 |
|
|
* @return the URL
|
924 |
|
|
*/
|
925 |
24b09d7c
|
Andreas Kohlbecker
|
function path_to_taxon($uuid){
|
926 |
|
|
if(!$uuid) return false;
|
927 |
ec0c70d2
|
Andreas Kohlbecker
|
return 'cdm_dataportal/taxon/'.$uuid;
|
928 |
ad497c90
|
Andreas Kohlbecker
|
}
|
929 |
|
|
|
930 |
24b09d7c
|
Andreas Kohlbecker
|
function path_to_reference($uuid){
|
931 |
|
|
if(!$uuid) return false;
|
932 |
|
|
return 'cdm_dataportal/reference/'.$uuid;
|
933 |
|
|
}
|
934 |
|
|
|
935 |
b09e63fd
|
Andreas Kohlbecker
|
function path_to_media($uuid, $representaion_uuid = false, $partId = false){
|
936 |
2cd9a3d6
|
Andreas Kohlbecker
|
if(!$uuid) return false;
|
937 |
b09e63fd
|
Andreas Kohlbecker
|
$out = 'cdm_dataportal/media/'.$uuid;
|
938 |
|
|
if($representaion_uuid){
|
939 |
|
|
$out .= '/'.$representaion_uuid;
|
940 |
|
|
if($partId !== false){
|
941 |
|
|
$out .= '/'.$partId;
|
942 |
|
|
}
|
943 |
|
|
}
|
944 |
|
|
return $out;
|
945 |
2cd9a3d6
|
Andreas Kohlbecker
|
}
|
946 |
|
|
|
947 |
70fb5e15
|
Andreas Kohlbecker
|
/**
|
948 |
|
|
* Compares thisRank with thatRank.
|
949 |
|
|
* Returns a negative integer, zero, or a positive integer
|
950 |
|
|
* as the of thisRank is higher than, equal to, or lower than thatRank.
|
951 |
|
|
* e.g:
|
952 |
|
|
* <ul>
|
953 |
|
|
* <li>rank_compare({species_uuid}, {genus_uuid}) = -1</li>
|
954 |
|
|
* <li>rank_compare({genus_uuid}, {genus_uuid}) = 0</li>
|
955 |
|
|
* <li>rank_compare({genus_uuid}, {tribus_uuid}) = 1</li>
|
956 |
|
|
* </ul>
|
957 |
|
|
* <p>
|
958 |
|
|
* This compare logic of the underlying webservice is the
|
959 |
|
|
* <b>inverse logic</b> of the the one implemented in
|
960 |
|
|
* java.lang.Comparable#compareTo(java.lang.Object)
|
961 |
|
|
* @param $thisRankUuid
|
962 |
|
|
* @param $thatRankUuid
|
963 |
|
|
* @return a negative integer, zero, or a positive integer
|
964 |
|
|
* as the thisRank is lower than, equal to, or higher than thatRank
|
965 |
|
|
*/
|
966 |
|
|
function rank_compare($thisRankUuid, $thatRankUuid){
|
967 |
|
|
$result = cdm_ws_get(CDM_WS_TERM_COMPARE, array($thisRankUuid, $thatRankUuid));
|
968 |
|
|
return $result->Integer;
|
969 |
|
|
}
|
970 |
|
|
|
971 |
24b09d7c
|
Andreas Kohlbecker
|
function uri_to_synonym($synonymUuid, $acceptedUuid, $pagePart = null){
|
972 |
|
|
$acceptedPath = path_to_taxon($acceptedUuid);
|
973 |
|
|
return url($acceptedPath.($pagePart ? '/'.$pagePart : ''), 'highlite='.$synonymUuid.'&acceptedFor='.$synonymUuid);
|
974 |
|
|
}
|
975 |
|
|
|
976 |
ec0c70d2
|
Andreas Kohlbecker
|
/**
|
977 |
|
|
* Creates a short taxonname by using the taggename field of NameSTO or NameTO instances.
|
978 |
|
|
* If the taggename if empty the fullname will be returned.
|
979 |
|
|
*
|
980 |
30c5a6bd
|
Andreas Kohlbecker
|
* @param unknown_type $Name or TreeNode
|
981 |
67a4a4c6
|
Andreas Kohlbecker
|
* @return string
|
982 |
ec0c70d2
|
Andreas Kohlbecker
|
*/
|
983 |
30c5a6bd
|
Andreas Kohlbecker
|
function cdm_dataportal_shortname_of($name){
|
984 |
67a4a4c6
|
Andreas Kohlbecker
|
|
985 |
30c5a6bd
|
Andreas Kohlbecker
|
$nameStr = '';
|
986 |
fa68c2c5
|
Andreas Kohlbecker
|
// get all tagged text tokens of the scientific name
|
987 |
30c5a6bd
|
Andreas Kohlbecker
|
foreach($name->taggedTitle as $tagtxt){
|
988 |
fa68c2c5
|
Andreas Kohlbecker
|
if($tagtxt->type == 'name' || $tagtxt->type == 'rank'){
|
989 |
30c5a6bd
|
Andreas Kohlbecker
|
$nameStr .= ($nameStr ? ' ' : '').$tagtxt->text;
|
990 |
fa68c2c5
|
Andreas Kohlbecker
|
}
|
991 |
|
|
}
|
992 |
30c5a6bd
|
Andreas Kohlbecker
|
$nameStr = trim($nameStr);
|
993 |
|
|
if($nameStr){
|
994 |
bd4696a1
|
n.hoffmann
|
// do not return short names for these
|
995 |
30c5a6bd
|
Andreas Kohlbecker
|
if($nameStr == 'Incertae sedis' || $nameStr == 'Nomina excludenda'){
|
996 |
|
|
return $nameStr;
|
997 |
bd4696a1
|
n.hoffmann
|
}
|
998 |
30c5a6bd
|
Andreas Kohlbecker
|
if($pos = stripos($nameStr, ' ')){
|
999 |
|
|
return substr($nameStr, 0, 1).'. '.substr($nameStr, $pos);
|
1000 |
ec0c70d2
|
Andreas Kohlbecker
|
} else {
|
1001 |
30c5a6bd
|
Andreas Kohlbecker
|
return $nameStr;
|
1002 |
ec0c70d2
|
Andreas Kohlbecker
|
}
|
1003 |
|
|
} else {
|
1004 |
30c5a6bd
|
Andreas Kohlbecker
|
return $name->titleCache;
|
1005 |
ec0c70d2
|
Andreas Kohlbecker
|
}
|
1006 |
|
|
}
|
1007 |
47a8c0dd
|
Andreas Kohlbecker
|
|
1008 |
af7422cb
|
n.hoffmann
|
/**
|
1009 |
|
|
* TODO Add Comments. I don't get what
|
1010 |
|
|
*
|
1011 |
44e02685
|
Andreas Kohlbecker
|
* @param UUID $secUuid
|
1012 |
67a4a4c6
|
Andreas Kohlbecker
|
*/
|
1013 |
27c1d8ec
|
Andreas Kohlbecker
|
function _cdm_dataportal_set_currentSecUuid($secUuid){
|
1014 |
5ab248ac
|
Andreas Kohlbecker
|
|
1015 |
0d127818
|
Andreas Kohlbecker
|
// do not save in session but in database
|
1016 |
af7422cb
|
n.hoffmann
|
|
1017 |
|
|
if(is_array($secUuid)){
|
1018 |
|
|
$secUuid = $secUuid[0];
|
1019 |
|
|
}
|
1020 |
|
|
if(!$secUuid){
|
1021 |
|
|
variable_set('cdm_currentSecRef', null);
|
1022 |
|
|
} else {
|
1023 |
30c5a6bd
|
Andreas Kohlbecker
|
$secRef = cdm_ws_get(CDM_WS_REFERENCE, $secUuid);
|
1024 |
24b09d7c
|
Andreas Kohlbecker
|
if(isset($secRef)){
|
1025 |
|
|
variable_set('cdm_currentSecRef', (array)($secRef));
|
1026 |
af7422cb
|
n.hoffmann
|
}
|
1027 |
|
|
}
|
1028 |
|
|
|
1029 |
27c1d8ec
|
Andreas Kohlbecker
|
}
|
1030 |
|
|
|
1031 |
af7422cb
|
n.hoffmann
|
/**
|
1032 |
|
|
* TODO
|
1033 |
|
|
* This will not work with multiple instances of the dataportal running
|
1034 |
|
|
* under the same host as there is only one session for all instances.
|
1035 |
|
|
* In case you switch instances with the same client, you will definitely
|
1036 |
|
|
* run into trouble.
|
1037 |
|
|
* Also this is not handling multiple secs.
|
1038 |
|
|
*
|
1039 |
|
|
*
|
1040 |
24b09d7c
|
Andreas Kohlbecker
|
* returns the current secRef array.
|
1041 |
27c1d8ec
|
Andreas Kohlbecker
|
* If the according session variable is not jet set the default
|
1042 |
812a9c04
|
Andreas Kohlbecker
|
* as configured in the setting is used otherwise null.
|
1043 |
94112bee
|
n.hoffmann
|
*
|
1044 |
f5b3d74e
|
Andreas Kohlbecker
|
* currentSecRef['uuid']
|
1045 |
|
|
* currentSecRef[....
|
1046 |
27c1d8ec
|
Andreas Kohlbecker
|
*
|
1047 |
|
|
* @return array
|
1048 |
|
|
*/
|
1049 |
1dbc28d9
|
Andreas Kohlbecker
|
function _cdm_dataportal_currentSecRef_array(){
|
1050 |
24b09d7c
|
Andreas Kohlbecker
|
|
1051 |
3cf0dec2
|
Andreas Kohlbecker
|
// do not look in session but in database
|
1052 |
24b09d7c
|
Andreas Kohlbecker
|
if( variable_get('cdm_currentSecRef', null) == null){
|
1053 |
af7422cb
|
n.hoffmann
|
$secUuid = variable_get('cdm_secUuid_default', null);
|
1054 |
|
|
_cdm_dataportal_set_currentSecUuid($secUuid);
|
1055 |
|
|
}
|
1056 |
|
|
return variable_get('cdm_currentSecRef', null);
|
1057 |
|
|
|
1058 |
67a4a4c6
|
Andreas Kohlbecker
|
}
|
1059 |
d93dad11
|
n.hoffmann
|
|
1060 |
|
|
/**
|
1061 |
9ee2882b
|
Andreas Kohlbecker
|
* Check if a taxon is accepted by the current taxonomic tree
|
1062 |
d93dad11
|
n.hoffmann
|
*
|
1063 |
9ee2882b
|
Andreas Kohlbecker
|
* @param Taxon $taxon
|
1064 |
|
|
* @return true if $taxon is accepted, false otherwise
|
1065 |
d93dad11
|
n.hoffmann
|
*/
|
1066 |
9ee2882b
|
Andreas Kohlbecker
|
|
1067 |
30c5a6bd
|
Andreas Kohlbecker
|
function _cdm_dataportal_acceptedByCurrentView($taxon){
|
1068 |
81df545f
|
Andreas Kohlbecker
|
|
1069 |
9ee2882b
|
Andreas Kohlbecker
|
//$current_secref = _cdm_dataportal_currentSecRef_array();
|
1070 |
|
|
$defaultTreeUuid = variable_get('cdm_taxonomictree_uuid', false);
|
1071 |
|
|
if($taxon->class == "Taxon" && isset($taxon->taxonNodes)){
|
1072 |
|
|
foreach($taxon->taxonNodes as $node){
|
1073 |
|
|
if($node->taxonomicTree == $defaultTreeUuid) {
|
1074 |
|
|
return true;
|
1075 |
|
|
}
|
1076 |
|
|
}
|
1077 |
|
|
}
|
1078 |
|
|
return false;
|
1079 |
81df545f
|
Andreas Kohlbecker
|
}
|
1080 |
44e02685
|
Andreas Kohlbecker
|
|
1081 |
daba333b
|
Andreas Kohlbecker
|
/**@Deprecated
|
1082 |
|
|
*
|
1083 |
|
|
*/
|
1084 |
|
|
function compose_url_prameterstr($parameters = array(), $parentPropertyName = false){
|
1085 |
cacc1bbf
|
Andreas Kohlbecker
|
$pstr = '';
|
1086 |
|
|
foreach($parameters as $key=>$value){
|
1087 |
daba333b
|
Andreas Kohlbecker
|
if(is_array($value)){
|
1088 |
|
|
|
1089 |
|
|
} else {
|
1090 |
|
|
$pstr .= ($pstr ? '&' :'').$key.'='.urlencode($value);
|
1091 |
|
|
}
|
1092 |
cacc1bbf
|
Andreas Kohlbecker
|
}
|
1093 |
|
|
return $pstr;
|
1094 |
d93dad11
|
n.hoffmann
|
}
|
1095 |
|
|
|
1096 |
|
|
function _get_feature_trees(){
|
1097 |
|
|
$feature_trees = array();
|
1098 |
|
|
|
1099 |
|
|
// set tree that contains all features
|
1100 |
|
|
$feature_trees['0'] = 'No FeatureTree';
|
1101 |
|
|
|
1102 |
30c5a6bd
|
Andreas Kohlbecker
|
// get features from database
|
1103 |
24b09d7c
|
Andreas Kohlbecker
|
$persisted_trees = cdm_ws_get(CDM_WS_FEATURETREES);
|
1104 |
d93dad11
|
n.hoffmann
|
if(is_array($persisted_trees)){
|
1105 |
|
|
foreach($persisted_trees as $featureTree){
|
1106 |
|
|
|
1107 |
|
|
$featureLabels = array();
|
1108 |
24b09d7c
|
Andreas Kohlbecker
|
foreach ($featureTree->root->children as $featureNode){
|
1109 |
30c5a6bd
|
Andreas Kohlbecker
|
$featureLabels[] = $featureNode->feature->representation_L10n;
|
1110 |
d93dad11
|
n.hoffmann
|
}
|
1111 |
|
|
|
1112 |
|
|
$feature_trees[$featureTree->uuid] = implode(", ", $featureLabels);
|
1113 |
|
|
|
1114 |
|
|
}
|
1115 |
|
|
}
|
1116 |
|
|
return $feature_trees;
|
1117 |
cacc1bbf
|
Andreas Kohlbecker
|
}
|
1118 |
6f4dd14a
|
Andreas Kohlbecker
|
|
1119 |
24b09d7c
|
Andreas Kohlbecker
|
|
1120 |
|
|
function get_nameRenderTemplate($renderPath, $nameLink = NULL, $refenceLink = NULL){
|
1121 |
|
|
//TODO implement admin user interface to replace swicth statement
|
1122 |
|
|
// preliminar solution: using themes
|
1123 |
|
|
|
1124 |
|
|
$template = theme('get_nameRenderTemplate', $renderPath);
|
1125 |
|
|
|
1126 |
|
|
if(!is_array($template)){
|
1127 |
|
|
switch($renderPath){
|
1128 |
|
|
case 'list_of_taxa':
|
1129 |
|
|
case 'acceptedFor':
|
1130 |
|
|
case 'taxon_page_synonymy':
|
1131 |
|
|
case 'typedesignations':
|
1132 |
|
|
case 'taxon_page_title':
|
1133 |
|
|
case 'na': $template = array(
|
1134 |
8a60c8fc
|
Andreas Kohlbecker
|
'namePart' => array('#uri'=>true),
|
1135 |
24b09d7c
|
Andreas Kohlbecker
|
//'authorshipPart' => true,
|
1136 |
|
|
);
|
1137 |
|
|
break;
|
1138 |
|
|
case 'nar': $template = array(
|
1139 |
8a60c8fc
|
Andreas Kohlbecker
|
'namePart' => array('#uri'=>true),
|
1140 |
24b09d7c
|
Andreas Kohlbecker
|
//'authorshipPart' => true,
|
1141 |
8a60c8fc
|
Andreas Kohlbecker
|
'referencePart' => array('#uri'=>true),
|
1142 |
24b09d7c
|
Andreas Kohlbecker
|
'microreferencePart' => true,
|
1143 |
|
|
);
|
1144 |
|
|
break;
|
1145 |
|
|
default: $template = array(
|
1146 |
8a60c8fc
|
Andreas Kohlbecker
|
'namePart' => array('#uri'=>true),
|
1147 |
24b09d7c
|
Andreas Kohlbecker
|
'authorshipPart' => true,
|
1148 |
8a60c8fc
|
Andreas Kohlbecker
|
'referencePart' => array('#uri'=>true),
|
1149 |
24b09d7c
|
Andreas Kohlbecker
|
'microreferencePart' => true,
|
1150 |
|
|
'statusPart' => true,
|
1151 |
|
|
'descriptionPart' => true
|
1152 |
|
|
);
|
1153 |
|
|
}
|
1154 |
|
|
}
|
1155 |
70fb5e15
|
Andreas Kohlbecker
|
|
1156 |
|
|
if($nameLink && isset($template['nameAuthorPart']['#uri'])){
|
1157 |
|
|
$template['nameAuthorPart']['#uri'] = $nameLink;
|
1158 |
|
|
} else{
|
1159 |
|
|
unset($template['nameAuthorPart']['#uri']);
|
1160 |
|
|
}
|
1161 |
|
|
|
1162 |
8a60c8fc
|
Andreas Kohlbecker
|
if($nameLink && isset($template['namePart']['#uri'])){
|
1163 |
|
|
$template['namePart']['#uri'] = $nameLink;
|
1164 |
|
|
} else{
|
1165 |
|
|
unset($template['namePart']['#uri']);
|
1166 |
24b09d7c
|
Andreas Kohlbecker
|
}
|
1167 |
70fb5e15
|
Andreas Kohlbecker
|
|
1168 |
8a60c8fc
|
Andreas Kohlbecker
|
if($refenceLink && isset($template['referencePart']['#uri'])){
|
1169 |
|
|
$template['referencePart']['#uri'] = $refenceLink;
|
1170 |
|
|
}else{
|
1171 |
|
|
unset($template['referencePart']['#uri']);
|
1172 |
24b09d7c
|
Andreas Kohlbecker
|
}
|
1173 |
70fb5e15
|
Andreas Kohlbecker
|
|
1174 |
24b09d7c
|
Andreas Kohlbecker
|
return $template;
|
1175 |
|
|
}
|
1176 |
|
|
|
1177 |
|
|
function get_partDefinition($taxonNameType){
|
1178 |
|
|
//TODO implement admin user interface to allow specify the partdefinitions for any type
|
1179 |
|
|
// preliminar solution: using themes
|
1180 |
|
|
|
1181 |
|
|
$partdef = theme('get_partDefinition', $taxonNameType);
|
1182 |
|
|
|
1183 |
|
|
if(!is_array($partdef)){
|
1184 |
|
|
switch($taxonNameType){
|
1185 |
|
|
case 'ZoologicalName': $partdef = array(
|
1186 |
|
|
'namePart' => array(
|
1187 |
|
|
'name' => true,
|
1188 |
|
|
),
|
1189 |
|
|
'referencePart' => array(
|
1190 |
|
|
'authorTeam' => true
|
1191 |
|
|
),
|
1192 |
|
|
'microreferencePart' => array(
|
1193 |
|
|
'microreference' => true,
|
1194 |
|
|
),
|
1195 |
|
|
'statusPart' => array(
|
1196 |
|
|
'status' => true,
|
1197 |
|
|
),
|
1198 |
|
|
'descriptionPart' => array(
|
1199 |
|
|
'description' => true,
|
1200 |
|
|
),
|
1201 |
|
|
);
|
1202 |
|
|
break;
|
1203 |
|
|
case 'BotanicalName': $partdef = array(
|
1204 |
|
|
'namePart' => array(
|
1205 |
|
|
'name' => true
|
1206 |
|
|
),
|
1207 |
|
|
'authorTeamPart' => array(
|
1208 |
|
|
'authorTeam' => true,
|
1209 |
|
|
),
|
1210 |
|
|
'referencePart' => array(
|
1211 |
|
|
'reference' => true
|
1212 |
|
|
),
|
1213 |
|
|
'microreferencePart' => array(
|
1214 |
|
|
'microreference' => true,
|
1215 |
|
|
),
|
1216 |
|
|
'statusPart' => array(
|
1217 |
|
|
'status' => true,
|
1218 |
|
|
),
|
1219 |
|
|
'descriptionPart' => array(
|
1220 |
|
|
'description' => true,
|
1221 |
|
|
),
|
1222 |
|
|
);
|
1223 |
|
|
break;
|
1224 |
|
|
default: $partdef = array(
|
1225 |
|
|
'namePart' => array(
|
1226 |
|
|
'name' => true,
|
1227 |
|
|
),
|
1228 |
|
|
'authorTeamPart' => array(
|
1229 |
|
|
'authorTeam' => true,
|
1230 |
|
|
),
|
1231 |
|
|
'referencePart' => array(
|
1232 |
|
|
'reference' => true
|
1233 |
|
|
),
|
1234 |
|
|
'microreferencePart' => array(
|
1235 |
|
|
'microreference' => true,
|
1236 |
|
|
),
|
1237 |
|
|
'statusPart' => array(
|
1238 |
|
|
'status' => true,
|
1239 |
|
|
),
|
1240 |
|
|
'descriptionPart' => array(
|
1241 |
|
|
'description' => true,
|
1242 |
|
|
),
|
1243 |
|
|
);
|
1244 |
|
|
}
|
1245 |
|
|
}
|
1246 |
|
|
return $partdef;
|
1247 |
|
|
}
|