1 |
6657531f
|
Andreas Kohlbecker
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* CDM Dataportal settings.
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
// TODO Genus UUID.
|
8 |
|
|
define('DEFAULT_TAXONTREE_RANKLIMIT', '1b11c34c-48a8-4efa-98d5-84f7f66ef43a');
|
9 |
|
|
define('CDM_TAXONOMICTREE_UUID', 'cdm_taxonomictree_uuid');
|
10 |
|
|
|
11 |
|
|
define('CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE', 25);
|
12 |
|
|
define('CDM_DATAPORTAL_NOMREF_IN_TITLE', 1);
|
13 |
|
|
define('CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR', 0);
|
14 |
|
|
define('CDM_DATAPORTAL_ALL_FOOTNOTES', 0);
|
15 |
|
|
define('CDM_DATAPORTAL_ANNOTATIONS_FOOTNOTES', 0);
|
16 |
|
|
define('CDM_DATAPORTAL_LAST_VISITED_TAB_ARRAY_INDEX', 999);
|
17 |
|
|
|
18 |
|
|
/* annotationTypeKeys */
|
19 |
|
|
$annotationTypeKeys = array_keys(cdm_Vocabulary_as_option(UUID_ANNOTATION_TYPE));
|
20 |
|
|
if (in_array(UUID_ANNOTATION_TYPE_TECHNICAL, $annotationTypeKeys)) {
|
21 |
|
|
$annotationTypeKeys = array_flip($annotationTypeKeys);
|
22 |
|
|
|
23 |
|
|
// Technical annotation are off by default.
|
24 |
|
|
unset($annotationTypeKeys[UUID_ANNOTATION_TYPE_TECHNICAL]);
|
25 |
|
|
$annotationTypeKeys = array_flip($annotationTypeKeys);
|
26 |
|
|
// Additional value for the NULL case.
|
27 |
|
|
$annotationTypeKeys[] = 'NULL_VALUE';
|
28 |
|
|
}
|
29 |
|
|
define('ANNOTATIONS_TYPES_AS_FOOTNOTES_DEFAULT', serialize($annotationTypeKeys));
|
30 |
|
|
|
31 |
|
|
/* taxonRelationshipTypes */
|
32 |
|
|
define('CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT', serialize(array(UUID_MISAPPLIED_NAME_FOR, UUID_INVALID_DESIGNATION_FOR)));
|
33 |
|
|
|
34 |
|
|
/* Gallery variables. */
|
35 |
|
|
$gallery_settings = array(
|
36 |
|
|
"cdm_dataportal_show_taxon_thumbnails" => 1,
|
37 |
|
|
"cdm_dataportal_show_synonym_thumbnails" => 0,
|
38 |
|
|
"cdm_dataportal_show_thumbnail_captions" => 1,
|
39 |
|
|
"cdm_dataportal_media_maxextend" => 120,
|
40 |
|
|
"cdm_dataportal_media_cols" => 3,
|
41 |
|
|
"cdm_dataportal_media_maxRows" => 1,
|
42 |
|
|
);
|
43 |
|
|
|
44 |
ba706bf0
|
Andreas Kohlbecker
|
/* ---- MAP SETTING CONSTANTS ---- */
|
45 |
|
|
/**
|
46 |
|
|
* @var array of URIs eg. http://edit.africamuseum.be"
|
47 |
|
|
* An options array
|
48 |
|
|
*/
|
49 |
|
|
define('EDIT_MAPSERVER_URI', serialize(
|
50 |
|
|
array(
|
51 |
|
|
'http://edit.africamuseum.be'=>'Primary (http://edit.africamuseum.be)',
|
52 |
|
|
'http://edit.br.fgov.be'=>'Secondary (http://edit.br.fgov.be)',
|
53 |
|
|
)
|
54 |
|
|
)
|
55 |
|
|
);
|
56 |
|
|
define('EDIT_MAPSERVER_PATH', '/edit_wp5');
|
57 |
|
|
/**
|
58 |
|
|
* @var array of versions eg. "v1.2"
|
59 |
|
|
* An options array
|
60 |
|
|
*/
|
61 |
|
|
define('EDIT_MAPSERVER_VERSION', serialize(
|
62 |
|
|
array(
|
63 |
|
|
'v1' => 'v1' ,
|
64 |
|
|
'v1.1' => 'v1.1',
|
65 |
|
|
'v1.2_dev' => 'v1.2_dev'
|
66 |
|
|
)
|
67 |
|
|
)
|
68 |
|
|
);
|
69 |
|
|
define('EDIT_MAPSERVER_URI_DEFAULT', 'http://edit.africamuseum.be');
|
70 |
|
|
define('EDIT_MAPSERVER_VERSION_DEFAULT', 'v1.1');
|
71 |
6657531f
|
Andreas Kohlbecker
|
|
72 |
|
|
// --- Taxon profile settings --- /
|
73 |
|
|
define('LAYOUT_SETTING_PREFIX', 'layout_');
|
74 |
|
|
define('FEATURE_TREE_LAYOUT_DEFAULTS', serialize(
|
75 |
|
|
array(
|
76 |
|
|
'enabled' => FALSE,
|
77 |
|
|
'enclosingTag' => 'ul',
|
78 |
|
|
'entryEnclosingTag' => 'li',
|
79 |
|
|
'glue' => ' ',
|
80 |
|
|
)));
|
81 |
|
|
|
82 |
ba706bf0
|
Andreas Kohlbecker
|
define('DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP', 'distribution_textdata_on_top');
|
83 |
9c92cd84
|
Andreas Kohlbecker
|
define('CDM_TAXON_PROFILE_IMAGE', 'cdm_taxon_profile_image');
|
84 |
|
|
define('CDM_TAXON_PROFILE_IMAGE_DEFAULT', serialize(
|
85 |
|
|
array(
|
86 |
|
|
'show' => 1,
|
87 |
|
|
'maxextend' => 184,
|
88 |
053a92ec
|
Andreas Kohlbecker
|
'media_uri_query' => '',
|
89 |
9c92cd84
|
Andreas Kohlbecker
|
'custom_placeholder_image_on' => 0,
|
90 |
|
|
'custom_placeholder_image_fid' => ''
|
91 |
|
|
)
|
92 |
|
|
)
|
93 |
|
|
);
|
94 |
ba706bf0
|
Andreas Kohlbecker
|
|
95 |
6657531f
|
Andreas Kohlbecker
|
/**
|
96 |
|
|
* @todo document this function
|
97 |
|
|
*/
|
98 |
|
|
function get_taxon_tabs_list() {
|
99 |
|
|
return array(
|
100 |
|
|
0 => 'General',
|
101 |
|
|
1 => 'Synonymy',
|
102 |
|
|
2 => 'Images',
|
103 |
|
|
3 => 'Specimens',
|
104 |
|
|
4 => 'Keys',
|
105 |
|
|
);
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
$taxon_tab_options = get_taxon_tabs_list();
|
109 |
|
|
$taxon_tab_options[CDM_DATAPORTAL_LAST_VISITED_TAB_ARRAY_INDEX] = 'Last visited tab';
|
110 |
|
|
|
111 |
|
|
define('CDM_DATAPORTAL_DEFAULT_TAXON_TAB', serialize($taxon_tab_options));
|
112 |
|
|
|
113 |
|
|
/**
|
114 |
|
|
* @todo document this function.
|
115 |
|
|
*/
|
116 |
|
|
function get_taxon_options_list() {
|
117 |
|
|
$taxon_tab_options = array_flip(get_taxon_tabs_list());
|
118 |
|
|
foreach ($taxon_tab_options as $key => $value) {
|
119 |
|
|
$taxon_tab_options[$key] = t($key);
|
120 |
|
|
}
|
121 |
|
|
return $taxon_tab_options;
|
122 |
|
|
|
123 |
|
|
}
|
124 |
|
|
|
125 |
0f5f1c12
|
Andreas Kohlbecker
|
define('CDM_PART_DEFINITIONS', 'cdm-part-definitions');
|
126 |
|
|
define('CDM_PART_DEFINITIONS_DEFAULT', serialize(
|
127 |
|
|
array(
|
128 |
|
|
'ZoologicalName' => array(
|
129 |
501347df
|
Andreas Kohlbecker
|
'namePart' => array('name' => TRUE),
|
130 |
|
|
'nameAuthorPart' => array('name' => TRUE),
|
131 |
|
|
'referencePart' => array('authors' => TRUE),
|
132 |
|
|
'microreferencePart' => array('microreference' => TRUE),
|
133 |
|
|
'statusPart' => array('status' => TRUE),
|
134 |
|
|
'descriptionPart' => array('description' => TRUE),
|
135 |
0f5f1c12
|
Andreas Kohlbecker
|
),
|
136 |
|
|
'BotanicalName'=> array(
|
137 |
|
|
'namePart' => array('name' => TRUE),
|
138 |
|
|
'nameAuthorPart' => array('name' => TRUE, 'authors' => TRUE),
|
139 |
|
|
'referencePart' => array('reference' => TRUE, 'microreference' => TRUE),
|
140 |
|
|
'statusPart' => array('status' => TRUE),
|
141 |
|
|
'descriptionPart' => array('description' => TRUE),
|
142 |
|
|
),
|
143 |
|
|
'#DEFAULT' => array(
|
144 |
501347df
|
Andreas Kohlbecker
|
'namePart' => array(
|
145 |
|
|
'name' => TRUE
|
146 |
|
|
),
|
147 |
|
|
'nameAuthorPart' => array(
|
148 |
|
|
'name' => TRUE,
|
149 |
|
|
'authors' => TRUE
|
150 |
|
|
),
|
151 |
|
|
'referencePart' => array(
|
152 |
|
|
'reference' => TRUE
|
153 |
|
|
),
|
154 |
|
|
'microreferencePart' => array(
|
155 |
|
|
'microreference' => TRUE,
|
156 |
|
|
),
|
157 |
|
|
'statusPart' => array(
|
158 |
|
|
'status' => TRUE,
|
159 |
|
|
),
|
160 |
|
|
'descriptionPart' => array(
|
161 |
|
|
'description' => TRUE,
|
162 |
|
|
),
|
163 |
0f5f1c12
|
Andreas Kohlbecker
|
)
|
164 |
|
|
)
|
165 |
|
|
)
|
166 |
|
|
);
|
167 |
|
|
define('CDM_NAME_RENDER_TEMPLATES', 'cdm-name-render-templates');
|
168 |
|
|
define('CDM_NAME_RENDER_TEMPLATES_DEFAULT', serialize(
|
169 |
5972ca1a
|
Andreas Kohlbecker
|
array (
|
170 |
|
|
'taxon_page_title,polytomousKey'=> array(
|
171 |
|
|
'namePart' => array('#uri' => TRUE),
|
172 |
|
|
),
|
173 |
|
|
'taxon_page_synonymy,related_taxon'=> array(
|
174 |
|
|
'nameAuthorPart' => array('#uri' => TRUE),
|
175 |
|
|
'referencePart' => TRUE,
|
176 |
|
|
'statusPart' => TRUE,
|
177 |
|
|
'descriptionPart' => TRUE,
|
178 |
|
|
),
|
179 |
|
|
'acceptedFor,typedesignations,list_of_taxa' => array(
|
180 |
|
|
'nameAuthorPart' => array('#uri' => TRUE),
|
181 |
|
|
'referencePart' => TRUE,
|
182 |
|
|
),
|
183 |
|
|
'#DEFAULT' => array(
|
184 |
|
|
'nameAuthorPart' => array('#uri' => TRUE),
|
185 |
|
|
'referencePart' => TRUE,
|
186 |
|
|
)
|
187 |
0f5f1c12
|
Andreas Kohlbecker
|
)
|
188 |
|
|
));
|
189 |
|
|
|
190 |
6657531f
|
Andreas Kohlbecker
|
define('TAXONPAGE_VISIBILITY_OPTIONS_DEFAULT', serialize(get_taxon_options_list()));
|
191 |
|
|
define('CDM_DATAPORTAL_GALLERY_SETTINGS', serialize($gallery_settings));
|
192 |
|
|
define('CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME', 'specimen_gallery');
|
193 |
|
|
define('CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME', "description_gallery");
|
194 |
|
|
define('CDM_DATAPORTAL_MEDIA_GALLERY_NAME', "media_gallery");
|
195 |
|
|
define('CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB', "taxon_tab_media_gallery");
|
196 |
|
|
define('CDM_DATAPORTAL_SEARCH_GALLERY_NAME', "search_gallery");
|
197 |
|
|
define('CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS', 'cdm_dataportal_display_taxon_relationships');
|
198 |
|
|
define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS', 'cdm_dataportal_display_name_relations');
|
199 |
|
|
// define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_2', array("default" => t('Display all')));
|
200 |
|
|
define('CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT', 1);
|
201 |
|
|
define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_DEFAULT', 1);
|
202 |
30f78c59
|
Andreas Kohlbecker
|
/**
|
203 |
|
|
* The drupal variable key for the array containing the uuids of the taxon relationship types to display in
|
204 |
|
|
* the snonymy.
|
205 |
|
|
*
|
206 |
|
|
* @var string
|
207 |
|
|
*/
|
208 |
6657531f
|
Andreas Kohlbecker
|
define('CDM_TAXON_RELATIONSHIP_TYPES', 'cdm_taxon_relationship_types');
|
209 |
30f78c59
|
Andreas Kohlbecker
|
/**
|
210 |
|
|
* The drupal variable for the configuration of the information aggregation along
|
211 |
|
|
* the taxon relation ships. The mapped arrayis associative and holds two elements:
|
212 |
|
|
* - direct: the uuids of the taxon relationship types to take into account in invers
|
213 |
|
|
* direction.
|
214 |
|
|
* - invers: the uuids of the taxon relationship types to take into account in direct
|
215 |
|
|
* direction.
|
216 |
|
|
*
|
217 |
|
|
* @var String
|
218 |
|
|
*/
|
219 |
|
|
define('CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS', 'cdm_aggregate_by_taxon_relationships');
|
220 |
|
|
define('CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT', serialize(
|
221 |
|
|
array(
|
222 |
|
|
'direct'=>array(),
|
223 |
|
|
'invers'=>array()
|
224 |
|
|
)
|
225 |
|
|
));
|
226 |
6657531f
|
Andreas Kohlbecker
|
define('CDM_PROFILE_FEATURETREE_UUID', 'cdm_dataportal_featuretree_uuid');
|
227 |
bfb2b81a
|
Andreas Kohlbecker
|
define('CDM_OCCURRENCE_FEATURETREE_UUID', 'cdm_occurrence_featuretree_uuid');
|
228 |
6657531f
|
Andreas Kohlbecker
|
define('CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID', 'cdm_dataportal_structdesc_featuretree_uuid');
|
229 |
|
|
|
230 |
a950f2f9
|
Andreas Kohlbecker
|
define('CDM_TAXON_MEDIA_FILTER', 'cdm_taxon_media_filter');
|
231 |
|
|
define('CDM_TAXON_MEDIA_FILTER_DEFAULT', serialize(
|
232 |
|
|
array(
|
233 |
|
|
'includeTaxonDescriptions' => 'includeTaxonDescriptions',
|
234 |
|
|
'includeOccurrences' => 0,
|
235 |
|
|
'includeTaxonNameDescriptions' => 0
|
236 |
|
|
)
|
237 |
|
|
));
|
238 |
|
|
|
239 |
6657531f
|
Andreas Kohlbecker
|
/**
|
240 |
|
|
* @todo document this function.
|
241 |
|
|
*/
|
242 |
|
|
function getGallerySettings($gallery_config_form_name) {
|
243 |
|
|
$default_values = unserialize(CDM_DATAPORTAL_GALLERY_SETTINGS);
|
244 |
|
|
return variable_get($gallery_config_form_name, $default_values);
|
245 |
|
|
}
|
246 |
|
|
|
247 |
|
|
/**
|
248 |
|
|
* Returns the string representation of the default tab.
|
249 |
|
|
*
|
250 |
|
|
* @param bool $returnTabIndex
|
251 |
|
|
* Defaults to FALSE, if set true this function will return the index number
|
252 |
|
|
* of the default tab. (used to supply default values to form elements).
|
253 |
|
|
*/
|
254 |
|
|
function get_default_taxon_tab($returnTabIndex = FALSE) {
|
255 |
|
|
|
256 |
|
|
global $user;
|
257 |
|
|
$values = unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB);
|
258 |
|
|
$user_tab_active = 'cdm_dataportal_' . $user->uid . '_default_tab_active';
|
259 |
|
|
$user_tab = 'cdm_dataportal_' . $user->uid . '_default_tab';
|
260 |
|
|
// Get the user value if the used has chosen to overwrite the system settings.
|
261 |
|
|
$user_tab_on = variable_get($user_tab_active, FALSE);
|
262 |
|
|
if ($user_tab_on) {
|
263 |
|
|
$user_value = variable_get($user_tab, 0);
|
264 |
|
|
$index_value = $user_value;
|
265 |
|
|
// Get the system value.
|
266 |
|
|
}
|
267 |
|
|
else {
|
268 |
|
|
$system_value = variable_get('cdm_dataportal_default_tab', 0);
|
269 |
|
|
$index_value = $system_value;
|
270 |
|
|
}
|
271 |
|
|
|
272 |
|
|
// Return the index value or the string representation.
|
273 |
|
|
if ($returnTabIndex) {
|
274 |
|
|
return $index_value;
|
275 |
|
|
}
|
276 |
|
|
else {
|
277 |
|
|
return ($values[$index_value]);
|
278 |
|
|
}
|
279 |
|
|
|
280 |
|
|
}
|
281 |
|
|
|
282 |
|
|
/**
|
283 |
|
|
* @todo Please document this function.
|
284 |
|
|
* @see http://drupal.org/node/1354
|
285 |
|
|
*/
|
286 |
|
|
function cdm_dataportal_menu_admin(&$items) {
|
287 |
|
|
// Display section on admin/config page.
|
288 |
|
|
$items['admin/config/cdm_dataportal'] = array(
|
289 |
|
|
'title' => 'CDM Dataportal',
|
290 |
|
|
'description' => 'Settings for the CDM DataPortal.',
|
291 |
|
|
'position' => 'right',
|
292 |
|
|
'weight' => 10,
|
293 |
|
|
'page callback' => 'system_admin_menu_block_page',
|
294 |
e014414c
|
Andreas Kohlbecker
|
'access arguments' => array('administer cdm_dataportal'),
|
295 |
6657531f
|
Andreas Kohlbecker
|
'file' => 'system.admin.inc',
|
296 |
|
|
'file path' => drupal_get_path('module', 'system'),
|
297 |
|
|
);
|
298 |
|
|
$items['admin/config/cdm_dataportal/settings'] = array(
|
299 |
|
|
'title' => 'Settings',
|
300 |
|
|
'description' => 'Settings for the CDM DataPortal.',
|
301 |
|
|
'weight' => 0,
|
302 |
|
|
'page callback' => 'drupal_get_form',
|
303 |
|
|
'page arguments' => array('cdm_settings_general'),
|
304 |
|
|
'access arguments' => array('administer cdm_dataportal'),
|
305 |
|
|
'type' => MENU_NORMAL_ITEM,
|
306 |
|
|
);
|
307 |
|
|
$items['admin/config/cdm_dataportal/settings/general'] = array(
|
308 |
|
|
'title' => 'General',
|
309 |
|
|
'description' => 'General',
|
310 |
|
|
'weight' => 0,
|
311 |
|
|
'page callback' => 'drupal_get_form',
|
312 |
|
|
'page arguments' => array('cdm_settings_general'),
|
313 |
|
|
'access arguments' => array('administer cdm_dataportal'),
|
314 |
|
|
'type' => MENU_DEFAULT_LOCAL_TASK,
|
315 |
|
|
);
|
316 |
|
|
|
317 |
|
|
$items['admin/config/cdm_dataportal/settings/cachesite'] = array(
|
318 |
|
|
'title' => 'Cache',
|
319 |
|
|
'description' => 'Cache',
|
320 |
|
|
'access arguments' => array('administer cdm_dataportal'),
|
321 |
|
|
'page callback' => 'drupal_get_form',
|
322 |
|
|
'page arguments' => array('cdm_settings_cache'),
|
323 |
|
|
'weight' => 10,
|
324 |
|
|
'type' => MENU_LOCAL_TASK,
|
325 |
|
|
);
|
326 |
|
|
|
327 |
|
|
$items['admin/config/cdm_dataportal/settings/geo'] = array(
|
328 |
|
|
'title' => 'Geo & Map',
|
329 |
|
|
'description' => 'Geo & Map',
|
330 |
|
|
'access arguments' => array('administer cdm_dataportal'),
|
331 |
|
|
'page callback' => 'drupal_get_form',
|
332 |
|
|
'page arguments' => array('cdm_settings_geo'),
|
333 |
|
|
'weight' => 1,
|
334 |
|
|
'type' => MENU_LOCAL_TASK,
|
335 |
|
|
);
|
336 |
|
|
|
337 |
|
|
$items['admin/config/cdm_dataportal/settings/layout'] = array(
|
338 |
|
|
'title' => 'Layout',
|
339 |
|
|
'description' => 'Configure and adjust the layout of your DataPortal ',
|
340 |
|
|
'access arguments' => array('administer cdm_dataportal'),
|
341 |
|
|
'page callback' => 'drupal_get_form',
|
342 |
|
|
'page arguments' => array('cdm_settings_layout'),
|
343 |
|
|
'weight' => 2,
|
344 |
|
|
'type' => MENU_LOCAL_TASK,
|
345 |
|
|
);
|
346 |
|
|
|
347 |
|
|
$items['admin/config/cdm_dataportal/settings/layout/taxon'] = array(
|
348 |
|
|
'title' => 'Taxon',
|
349 |
|
|
'description' => 'Configure and adjust the layout of your DataPortal ',
|
350 |
|
|
'access arguments' => array('administer cdm_dataportal'),
|
351 |
|
|
'page callback' => 'drupal_get_form',
|
352 |
|
|
'page arguments' => array('cdm_settings_layout_taxon'),
|
353 |
|
|
'weight' => 1,
|
354 |
|
|
'type' => MENU_LOCAL_TASK,
|
355 |
|
|
);
|
356 |
|
|
/*
|
357 |
|
|
$items[] = array(
|
358 |
|
|
'path' => 'admin/config/cdm_dataportal/layout/synonymy',
|
359 |
|
|
'title' => t('Synonymy'),
|
360 |
|
|
'description' => t('Configure and adjust the layout of your DataPortal '),
|
361 |
|
|
'access' => user_access('administer cdm_dataportal'),
|
362 |
|
|
'callback' => 'drupal_get_form',
|
363 |
|
|
'callback arguments' => array('cdm_settings_layout_synonymy'),
|
364 |
|
|
'weight' => 1,
|
365 |
|
|
'type' => MENU_LOCAL_TASK,
|
366 |
|
|
);
|
367 |
|
|
|
368 |
|
|
$items[] = array(
|
369 |
|
|
'path' => 'admin/config/cdm_dataportal/layout/specimens',
|
370 |
|
|
'title' => t('Specimens'),
|
371 |
|
|
'description' => t('Configure and adjust the layout of your DataPortal '),
|
372 |
|
|
'access' => user_access('administer cdm_dataportal'),
|
373 |
|
|
'callback' => 'drupal_get_form',
|
374 |
|
|
'callback arguments' => array('cdm_settings_layout_specimens'),
|
375 |
|
|
'weight' => 1,
|
376 |
|
|
'type' => MENU_LOCAL_TASK,
|
377 |
|
|
);
|
378 |
|
|
*/
|
379 |
|
|
$items['admin/config/cdm_dataportal/settings/layout/search'] = array(
|
380 |
|
|
'title' => 'Search',
|
381 |
|
|
'description' => 'Configure and adjust the layout of your DataPortal ',
|
382 |
|
|
'access arguments' => array('administer cdm_dataportal'),
|
383 |
|
|
'page callback' => 'drupal_get_form',
|
384 |
|
|
'page arguments' => array('cdm_settings_layout_search'),
|
385 |
|
|
'weight' => 2,
|
386 |
|
|
'type' => MENU_LOCAL_TASK,
|
387 |
|
|
);
|
388 |
|
|
|
389 |
|
|
$items['admin/config/cdm_dataportal/settings/layout/media'] = array(
|
390 |
|
|
'title' => 'Media',
|
391 |
|
|
'description' => 'Configure and adjust the layout of your DataPortal ',
|
392 |
|
|
'access arguments' => array('administer cdm_dataportal'),
|
393 |
|
|
'page callback' => 'drupal_get_form',
|
394 |
|
|
'page arguments' => array('cdm_settings_layout_media'),
|
395 |
|
|
'weight' => 3,
|
396 |
|
|
'type' => MENU_LOCAL_TASK,
|
397 |
|
|
);
|
398 |
947c6a8d
|
Andreas Kohlbecker
|
|
399 |
6657531f
|
Andreas Kohlbecker
|
}
|
400 |
|
|
|
401 |
|
|
/**
|
402 |
|
|
* @todo document this function.
|
403 |
|
|
*/
|
404 |
|
|
function cdm_help_general_cache() {
|
405 |
|
|
$form = array();
|
406 |
|
|
$form['cache_help'] = array(
|
407 |
|
|
'#type' => 'fieldset',
|
408 |
|
|
'#title' => t('Help'),
|
409 |
|
|
'#collapsible' => TRUE,
|
410 |
|
|
'#collapsed' => TRUE,
|
411 |
|
|
);
|
412 |
|
|
$form['cache_help']['test'] = array('#value' => t('probando'));
|
413 |
|
|
return drupal_render($form);
|
414 |
|
|
$res = array();
|
415 |
|
|
$res['default'] = drupal_render($help);
|
416 |
|
|
return $res;
|
417 |
|
|
}
|
418 |
|
|
|
419 |
|
|
/**
|
420 |
|
|
* Configures the settings form for the CDM-API module.
|
421 |
|
|
*
|
422 |
|
|
* @return array
|
423 |
|
|
* Drupal settings form.
|
424 |
|
|
*/
|
425 |
|
|
function cdm_settings_general() {
|
426 |
|
|
|
427 |
|
|
$form['cdm_webservice'] = array(
|
428 |
|
|
'#type' => 'fieldset',
|
429 |
|
|
'#title' => t('CDM Server'),
|
430 |
|
|
'#collapsible' => FALSE,
|
431 |
|
|
'#collapsed' => FALSE,
|
432 |
9438ad3a
|
Andreas Kohlbecker
|
'#description' => t('The <em>CDM Server</em> exposes data stored in a
|
433 |
|
|
CDM data base to the web via RESTful web services and thus is the source of the data
|
434 |
|
|
to be displayed by a CDM DataPotal.'),
|
435 |
6657531f
|
Andreas Kohlbecker
|
);
|
436 |
|
|
|
437 |
|
|
$form['cdm_webservice']['cdm_webservice_url'] = array(
|
438 |
|
|
'#type' => 'textfield',
|
439 |
|
|
'#title' => t('CDM web service URL') . ':',
|
440 |
|
|
'#description' => t('This is the URL to the CDM-Server exposing your data
|
441 |
|
|
e.g. <em>"http://localhost:8080/cichorieae/"</em> The URL <strong>must end
|
442 |
|
|
with a slash</strong> character!'),
|
443 |
|
|
'#default_value' => variable_get('cdm_webservice_url', NULL),
|
444 |
|
|
);
|
445 |
|
|
|
446 |
|
|
$form['cdm_webservice']['cdm_webservice_debug'] = array(
|
447 |
|
|
'#type' => 'checkbox',
|
448 |
|
|
'#title' => t('<b>Debug CDM Web Service</b>'),
|
449 |
|
|
'#default_value' => variable_get('cdm_webservice_debug', 1),
|
450 |
|
|
'#description' => t('The black web service debug box will appear at the top
|
451 |
|
|
of each page. When clicked it toggles open and provides a list of all HTTP
|
452 |
|
|
requests which have been made while building of this page.<br />
|
453 |
|
|
<strong>Note:</strong> this is a feature dedicated to developers. It will
|
454 |
|
|
only be visible when logged in and if the user has suffucicient rights to
|
455 |
|
|
see this debug box.'),
|
456 |
|
|
);
|
457 |
|
|
|
458 |
|
|
$form['cdm_webservice']['freetext_index'] = array(
|
459 |
|
|
'#type' => 'fieldset',
|
460 |
|
|
'#title' => t('Freetext index'),
|
461 |
|
|
'#collapsible' => FALSE,
|
462 |
|
|
'#collapsed' => FALSE,
|
463 |
|
|
);
|
464 |
|
|
|
465 |
|
|
// Check the cdmserver port number and display a waring if it is not port 80
|
466 |
|
|
preg_match("#http[s]?://[0-9\p{L}\.]*:([0-9]*)/.*#u", variable_get('cdm_webservice_url', ''), $portNumberMatch, PREG_OFFSET_CAPTURE);
|
467 |
|
|
if (isset($portNumberMatch[1]) && $portNumberMatch[1] != '80') {
|
468 |
|
|
$form['cdm_webservice']['freetext_index']['message'] = array(
|
469 |
|
|
'#markup' => "<div class=\"description\">"
|
470 |
|
|
. t("The CDM web service URL contains a portnumber other than standart HTTP port 80: '!port'."
|
471 |
|
|
. " Due to this the reindex and purge fuctions may not be working if there is a firewall in between you and the CDM Server."
|
472 |
|
|
. " You may want to contact the maintainer of the according CDM Server in order to solve this problem.", array('!port' => $portNumberMatch[1][0]))
|
473 |
|
|
. "</div>",
|
474 |
|
|
);
|
475 |
|
|
};
|
476 |
|
|
|
477 |
|
|
$frontentURL = urlencode(variable_get('cdm_webservice_url', ''));
|
478 |
|
|
$trigger_link_options = array(
|
479 |
|
|
'attributes' => array(
|
480 |
|
|
'class' => 'index-trigger',
|
481 |
|
|
),
|
482 |
|
|
);
|
483 |
|
|
$form['cdm_webservice']['freetext_index']['operations'] = array(
|
484 |
|
|
'#markup' => "<div>" . t('Operations: !url1 !url2', array(
|
485 |
|
|
'!url1' => l(t("Purge"), cdm_compose_url(CDM_WS_MANAGE_PURGE, NULL, 'frontendBaseUrl=' . $frontentURL), $trigger_link_options),
|
486 |
|
|
'!url2' => l(t("Reindex"), cdm_compose_url(CDM_WS_MANAGE_REINDEX, NULL, 'frontendBaseUrl=' . $frontentURL), $trigger_link_options),
|
487 |
|
|
))
|
488 |
|
|
. '<div id="index-progress"></div></div>',
|
489 |
|
|
);
|
490 |
|
|
_add_js_cdm_ws_progressbar(".index-trigger", "#index-progress");
|
491 |
|
|
|
492 |
|
|
$form['cdm_webservice']['proxy'] = array(
|
493 |
|
|
'#type' => 'fieldset',
|
494 |
|
|
'#title' => t('Proxy'),
|
495 |
|
|
'#collapsible' => TRUE,
|
496 |
|
|
'#collapsed' => TRUE,
|
497 |
|
|
);
|
498 |
|
|
|
499 |
|
|
$form['cdm_webservice']['proxy']['cdm_webservice_proxy_url'] = array(
|
500 |
|
|
'#type' => 'textfield',
|
501 |
|
|
'#title' => t('Proxy URL') . ':',
|
502 |
|
|
'#description' => t('If this proxy url is set the cdm api tries
|
503 |
|
|
to connect the web service over the given proxy server.
|
504 |
|
|
Otherwise proxy usage is deactivated.'),
|
505 |
|
|
'#default_value' => variable_get('cdm_webservice_proxy_url', FALSE),
|
506 |
|
|
);
|
507 |
|
|
|
508 |
|
|
$form['cdm_webservice']['proxy']['cdm_webservice_proxy_port'] = array(
|
509 |
|
|
'#type' => 'textfield',
|
510 |
|
|
'#title' => t('Proxy port') . ':',
|
511 |
|
|
'#default_value' => variable_get('cdm_webservice_proxy_port', '80'),
|
512 |
|
|
);
|
513 |
|
|
|
514 |
|
|
$form['cdm_webservice']['proxy']['cdm_webservice_proxy_usr'] = array(
|
515 |
|
|
'#type' => 'textfield',
|
516 |
|
|
'#title' => t('Login') . ':',
|
517 |
|
|
'#default_value' => variable_get('cdm_webservice_proxy_usr', FALSE),
|
518 |
|
|
);
|
519 |
|
|
|
520 |
|
|
$form['cdm_webservice']['proxy']['cdm_webservice_proxy_pwd'] = array(
|
521 |
|
|
'#type' => 'textfield',
|
522 |
|
|
'#title' => t('Password') . ':',
|
523 |
|
|
'#default_value' => variable_get('cdm_webservice_proxy_pwd', FALSE),
|
524 |
|
|
);
|
525 |
|
|
|
526 |
|
|
// TODO: settings are still incomplete, compare with
|
527 |
|
|
// trunk/dataportal/inc/config_default.php.inc.
|
528 |
9438ad3a
|
Andreas Kohlbecker
|
$form['taxon_tree'] = array(
|
529 |
6657531f
|
Andreas Kohlbecker
|
'#type' => 'fieldset',
|
530 |
|
|
'#title' => t('Taxon Tree'),
|
531 |
|
|
'#collapsible' => FALSE,
|
532 |
|
|
'#collapsed' => TRUE,
|
533 |
|
|
'#description' => t('<p>When you explore your collection, you can navigate
|
534 |
|
|
it through a tree structure also called <em>Taxon Tree</em>.</p><p>To be
|
535 |
|
|
able to navigate through your collection the
|
536 |
|
|
<a href="http://drupal.org/handbook/blocks">drupal block</a>
|
537 |
|
|
<em>CDM Taxon Tree</em> should be visible for users. Enable the block at
|
538 |
|
|
<a href="./?q=admin/build/block">Administer->Site building->Blocks
|
539 |
|
|
</a></p>'),
|
540 |
|
|
);
|
541 |
|
|
|
542 |
9438ad3a
|
Andreas Kohlbecker
|
$form['taxon_tree'][CDM_TAXONOMICTREE_UUID] = array(
|
543 |
6657531f
|
Andreas Kohlbecker
|
'#type' => 'select',
|
544 |
|
|
'#title' => t('Available classifications') . ':',
|
545 |
|
|
'#default_value' => variable_get(CDM_TAXONOMICTREE_UUID, FALSE),
|
546 |
|
|
'#options' => cdm_get_taxontrees_as_options(),
|
547 |
|
|
'#description' => t('Select the default taxa classification for your
|
548 |
|
|
<em>taxon tree</em>, the other classifications will be also available but
|
549 |
|
|
with a manual user change.'),
|
550 |
|
|
);
|
551 |
|
|
|
552 |
9438ad3a
|
Andreas Kohlbecker
|
$form['taxon_tree']['taxontree_ranklimit'] = array(
|
553 |
6657531f
|
Andreas Kohlbecker
|
'#type' => 'select',
|
554 |
|
|
'#title' => t('Rank of highest displayed taxon') . ':',
|
555 |
|
|
// Before DEFAULT_TAXONTREE_RANKLIMIT_UUID.
|
556 |
|
|
'#default_value' => variable_get('taxontree_ranklimit', DEFAULT_TAXONTREE_RANKLIMIT),
|
557 |
|
|
'#options' => cdm_rankVocabulary_as_option(),
|
558 |
|
|
'#description' => t('This is the rank of the highest displayed taxon in the
|
559 |
|
|
<em>taxon tree</em>. You can select here which rank should be at the top
|
560 |
|
|
level of the tree structure.'),
|
561 |
|
|
);
|
562 |
|
|
|
563 |
9438ad3a
|
Andreas Kohlbecker
|
$form['aggregation'] = array(
|
564 |
|
|
'#type' => 'fieldset',
|
565 |
|
|
'#title' => t('Aggregation of data'),
|
566 |
|
|
'#collapsible' => FALSE,
|
567 |
|
|
'#description' => t("This section covers the different aspects of aggregating information.
|
568 |
|
|
<p>
|
569 |
ccde8251
|
Andreas Kohlbecker
|
</p>"),
|
570 |
9438ad3a
|
Andreas Kohlbecker
|
|
571 |
|
|
);
|
572 |
|
|
|
573 |
ccde8251
|
Andreas Kohlbecker
|
$form['aggregation'][CDM_TAXON_MEDIA_FILTER] = array(
|
574 |
|
|
'#type' => 'checkboxes',
|
575 |
|
|
'#title' => 'Taxon media filter',
|
576 |
|
|
'#default_value' => variable_get(CDM_TAXON_MEDIA_FILTER, unserialize(CDM_TAXON_MEDIA_FILTER_DEFAULT)),
|
577 |
|
|
'#options' => array(
|
578 |
|
|
'includeTaxonDescriptions' => 'Media in taxon descriptions',
|
579 |
|
|
'includeTaxonNameDescriptions' => 'Media in name descriptions',
|
580 |
|
|
'includeOccurrences' => 'Media related to specimens and occurrences',
|
581 |
|
|
),
|
582 |
|
|
'#description' => 'This filter configures which images should be taken into account.',
|
583 |
|
|
);
|
584 |
|
|
|
585 |
|
|
$form['aggregation']['notice'] = array(
|
586 |
3a874294
|
Andreas Kohlbecker
|
'#markup' => '<strong>NOTICE:</strong> The below aggregation settings can slow down the data portal, so you may want to sensibly apply these setting and you may also
|
587 |
ccde8251
|
Andreas Kohlbecker
|
want to make use of the caching capabilities of the dataportal.',
|
588 |
|
|
);
|
589 |
|
|
|
590 |
9438ad3a
|
Andreas Kohlbecker
|
$form['aggregation']['media_aggregation'] = array(
|
591 |
|
|
'#type' => 'fieldset',
|
592 |
|
|
'#title' => t('Media aggregation'),
|
593 |
|
|
'#collapsible' => FALSE,
|
594 |
|
|
'#collapsed' => TRUE,
|
595 |
|
|
'#description' => t("The media aggregation is also affected by the settigs in \"<strong>Aggregation via taxon relationsships</strong>\" below."),
|
596 |
|
|
|
597 |
|
|
);
|
598 |
|
|
$form['aggregation']['media_aggregation']['cdm_images_include_children'] = array(
|
599 |
|
|
'#type' => 'select',
|
600 |
|
|
'#title' => t('Aggregation of taxon pictures') . ':',
|
601 |
|
|
'#default_value' => variable_get('cdm_images_include_children', FALSE),
|
602 |
|
|
'#options' => array(
|
603 |
|
|
0 => "Show only pictures of the current taxon",
|
604 |
|
|
1 => "Include pictures of taxonomic children",
|
605 |
|
|
),
|
606 |
|
|
'#description' => t("Choose whether to include the images of the taxonomic children. This will affect the <em>Images</em> tab and image tumbnails like in the search results."),
|
607 |
|
|
);
|
608 |
|
|
|
609 |
|
|
$form['aggregation']['aggregate_by_taxon_relationships'][CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS] = array(
|
610 |
30f78c59
|
Andreas Kohlbecker
|
'#type' => 'fieldset',
|
611 |
|
|
'#attributes' => array('class'=>array('clearfix')),
|
612 |
9438ad3a
|
Andreas Kohlbecker
|
'#title' => t('Aggregation via taxon relationsships'),
|
613 |
30f78c59
|
Andreas Kohlbecker
|
'#collapsible' => TRUE,
|
614 |
|
|
'#collapsed' => TRUE,
|
615 |
|
|
'#tree' => TRUE,
|
616 |
|
|
'#description' => t('Information on taxa will be aggregated along the below chosen
|
617 |
|
|
taxon relation ships. This will affect images and occurrences (specimens).
|
618 |
|
|
Taxon relation ships are directed and point form one taxon to another. The taxon
|
619 |
|
|
relationships to be taken into accunt can therefore configured for the direct direction
|
620 |
|
|
and for the inverse.'),
|
621 |
|
|
);
|
622 |
|
|
|
623 |
|
|
$taxonRelationshipTypeOptions = cdm_Vocabulary_as_option(UUID_TAXON_RELATIONSHIP_TYPE, '_cdm_relationship_type_term_label_callback');
|
624 |
|
|
$aggregate_by_taxon_relationships = variable_get(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS, unserialize(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT));
|
625 |
|
|
|
626 |
9438ad3a
|
Andreas Kohlbecker
|
$form['aggregation']['aggregate_by_taxon_relationships'][CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS]['direct'] = array(
|
627 |
30f78c59
|
Andreas Kohlbecker
|
'#type' => 'checkboxes',
|
628 |
|
|
'#title' => t('Direct'),
|
629 |
|
|
'#options' => $taxonRelationshipTypeOptions,
|
630 |
|
|
'#default_value' => $aggregate_by_taxon_relationships['direct'],
|
631 |
|
|
);
|
632 |
9438ad3a
|
Andreas Kohlbecker
|
$form['aggregation']['aggregate_by_taxon_relationships'][CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS]['invers'] = array(
|
633 |
30f78c59
|
Andreas Kohlbecker
|
'#type' => 'checkboxes',
|
634 |
|
|
'#title' => t('Invers'),
|
635 |
|
|
'#options' => $taxonRelationshipTypeOptions,
|
636 |
|
|
'#default_value' => $aggregate_by_taxon_relationships['invers'],
|
637 |
|
|
);
|
638 |
|
|
|
639 |
6657531f
|
Andreas Kohlbecker
|
// Comment @WA: D7 form api does not support reset buttons,
|
640 |
|
|
// so to mimic the D5 reset button we add one like this.
|
641 |
|
|
$form['actions']['reset'] = array(
|
642 |
|
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
643 |
|
|
'#weight' => 1000,
|
644 |
|
|
);
|
645 |
|
|
|
646 |
|
|
return system_settings_form($form);
|
647 |
|
|
}
|
648 |
|
|
|
649 |
|
|
|
650 |
|
|
/**
|
651 |
|
|
* LAYOUT settings
|
652 |
|
|
* @return unknown_type
|
653 |
|
|
* todo
|
654 |
|
|
*/
|
655 |
|
|
function cdm_settings_layout() {
|
656 |
|
|
|
657 |
|
|
$form = array();
|
658 |
0f5f1c12
|
Andreas Kohlbecker
|
|
659 |
|
|
$form['about'] = array(
|
660 |
|
|
'#markup' => '<h4>' . t('Portal Layout') . '</h4><p>' . t('This settings contains the general configurations
|
661 |
6657531f
|
Andreas Kohlbecker
|
layout. If you want to configure the specific sites layout visit the
|
662 |
0f5f1c12
|
Andreas Kohlbecker
|
respective configuration site for taxon, search or media.') . '</p>',
|
663 |
6657531f
|
Andreas Kohlbecker
|
);
|
664 |
|
|
|
665 |
|
|
// ---- footnotes --- //
|
666 |
0f5f1c12
|
Andreas Kohlbecker
|
$form['footnotes'] = array(
|
667 |
6657531f
|
Andreas Kohlbecker
|
'#type' => 'fieldset',
|
668 |
|
|
'#title' => t('Footnotes'),
|
669 |
|
|
'#collapsible' => FALSE,
|
670 |
|
|
'#collapsed' => FALSE,
|
671 |
|
|
'#description' => t('Taxa data such authors, synonyms names, descriptions,
|
672 |
|
|
media or distribution areas may have annotations or footnotes. When the
|
673 |
|
|
footnotes are enabled they will be visible (if they exist).'),
|
674 |
|
|
);
|
675 |
|
|
|
676 |
0f5f1c12
|
Andreas Kohlbecker
|
$form['footnotes']['cdm_dataportal_all_footnotes'] = array(
|
677 |
6657531f
|
Andreas Kohlbecker
|
'#type' => 'checkbox',
|
678 |
|
|
'#title' => t('Do not show footnotes'),
|
679 |
|
|
'#default_value' => variable_get('cdm_dataportal_all_footnotes', CDM_DATAPORTAL_ALL_FOOTNOTES),
|
680 |
|
|
'#description' => t('Check this if you do not want to show any footnotes'),
|
681 |
|
|
);
|
682 |
|
|
|
683 |
0f5f1c12
|
Andreas Kohlbecker
|
$form['footnotes']['cdm_dataportal_annotations_footnotes'] = array(
|
684 |
6657531f
|
Andreas Kohlbecker
|
'#type' => 'checkbox',
|
685 |
|
|
'#title' => t('Do not show annotations footnotes'),
|
686 |
|
|
'#default_value' => variable_get('cdm_dataportal_annotations_footnotes', CDM_DATAPORTAL_ANNOTATIONS_FOOTNOTES),
|
687 |
|
|
'#description' => t('Check this if you do not want to show annotation footnotes'),
|
688 |
|
|
);
|
689 |
|
|
|
690 |
|
|
$annotationTypeOptions = cdm_Vocabulary_as_option(UUID_ANNOTATION_TYPE);
|
691 |
|
|
// Additional option for the NULL case.
|
692 |
|
|
$annotationTypeOptions['NULL_VALUE'] = t('untyped');
|
693 |
0f5f1c12
|
Andreas Kohlbecker
|
$form['footnotes']['annotations_types_as_footnotes'] = array(
|
694 |
6657531f
|
Andreas Kohlbecker
|
'#type' => 'checkboxes',
|
695 |
|
|
'#title' => t('Annotation types as footnotes'),
|
696 |
|
|
'#description' => t("Only annotations of the selected type will be displayed
|
697 |
|
|
as footnotes. You may want to turn 'technical annotations' off."),
|
698 |
|
|
'#options' => $annotationTypeOptions,
|
699 |
|
|
);
|
700 |
|
|
$annotationsTypesAsFootnotes = variable_get('annotations_types_as_footnotes', unserialize(ANNOTATIONS_TYPES_AS_FOOTNOTES_DEFAULT));
|
701 |
|
|
if (!empty($annotationsTypesAsFootnotes)) {
|
702 |
0f5f1c12
|
Andreas Kohlbecker
|
$form['footnotes']['annotations_types_as_footnotes']['#default_value'] = $annotationsTypesAsFootnotes;
|
703 |
6657531f
|
Andreas Kohlbecker
|
}
|
704 |
|
|
|
705 |
0f5f1c12
|
Andreas Kohlbecker
|
// --- Advanced Search --- //
|
706 |
|
|
$form['asearch'] = array(
|
707 |
|
|
'#type' => 'fieldset',
|
708 |
|
|
'#title' => t('Advanced search'),
|
709 |
|
|
'#collapsible' => FALSE,
|
710 |
|
|
'#collapsed' => FALSE,
|
711 |
|
|
);
|
712 |
|
|
$form['asearch']['cdm_dataportal_show_advanced_search'] = array(
|
713 |
|
|
'#type' => 'checkbox',
|
714 |
|
|
'#title' => t('Show advanced search link'),
|
715 |
|
|
'#default_value' => variable_get('cdm_dataportal_show_advanced_search', 1),
|
716 |
|
|
'#description' => t('Check this box if the link to advanced search should be show below the search box.'),
|
717 |
|
|
);
|
718 |
|
|
|
719 |
|
|
// ---- Taxon Name Rendering --- //
|
720 |
|
|
$form['taxon_name'] = array(
|
721 |
|
|
'#type' => 'fieldset',
|
722 |
|
|
'#title' => t('Taxon name display'),
|
723 |
|
|
'#collapsible' => TRUE,
|
724 |
|
|
'#collapsed' => TRUE,
|
725 |
|
|
'#description' => t('The display of taxon names is configured by two parts.'
|
726 |
|
|
. 'The <srong>name render templates</strong> define the parts of the name to be displayed in the different areas of the data portal pages.'
|
727 |
|
|
. 'The name parts are defined in the <stong>part definitions</strong>'),
|
728 |
|
|
);
|
729 |
|
|
|
730 |
|
|
drupal_add_js(
|
731 |
|
|
'jQuery(document).ready( function( ) {
|
732 |
|
|
// pretty print json
|
733 |
|
|
var json_text = jQuery(\'#edit-' . CDM_PART_DEFINITIONS . '\').val();
|
734 |
|
|
var obj = JSON.parse(json_text);
|
735 |
|
|
jQuery(\'#edit-' . CDM_PART_DEFINITIONS . '\').val(JSON.stringify(obj, undefined, 2));
|
736 |
|
|
|
737 |
|
|
json_text = jQuery(\'#edit-' . CDM_NAME_RENDER_TEMPLATES . '\').val();
|
738 |
|
|
obj = JSON.parse(json_text);
|
739 |
|
|
jQuery(\'#edit-' . CDM_NAME_RENDER_TEMPLATES . '\').val(JSON.stringify(obj, undefined, 2));
|
740 |
|
|
});'
|
741 |
|
|
,array(
|
742 |
|
|
'type' => 'inline',
|
743 |
|
|
'scope' => 'footer'
|
744 |
|
|
)
|
745 |
6657531f
|
Andreas Kohlbecker
|
);
|
746 |
0f5f1c12
|
Andreas Kohlbecker
|
|
747 |
|
|
//TODO remove after all portals are using the settings
|
748 |
|
|
$default_part_definitions = theme('get_partDefinition', array());
|
749 |
|
|
if(!is_array($default_part_definitions)) {
|
750 |
|
|
$default_part_definitions = unserialize(CDM_PART_DEFINITIONS_DEFAULT);
|
751 |
|
|
}
|
752 |
|
|
|
753 |
|
|
$form['taxon_name'][CDM_PART_DEFINITIONS] = array(
|
754 |
|
|
'#type' => 'textarea',
|
755 |
|
|
'#title' => t('Part definitions'),
|
756 |
|
|
'#element_validate' => array('form_element_validate_json'),
|
757 |
|
|
'#default_value' => json_encode(variable_get(CDM_PART_DEFINITIONS, $default_part_definitions)),
|
758 |
|
|
'#description' => '
|
759 |
|
|
<p>
|
760 |
|
|
(Clearing the text area will reset it to the default)
|
761 |
|
|
</p>
|
762 |
|
|
<p>
|
763 |
|
|
The part definitions define the specific parts of which a rendered taxon name plus additional information will consist.
|
764 |
|
|
</p>
|
765 |
|
|
<p>
|
766 |
|
|
A full taxon name plus additional information can consist of the following elements:
|
767 |
|
|
<ul>
|
768 |
|
|
<li>name: the taxon name inclugin rank nbut without author</li>
|
769 |
|
|
<li>authors: The authors of a reference, also used in taxon names</li>
|
770 |
|
|
<li>reference: the nomenclatural reference,</li>
|
771 |
|
|
<li>microreference: Volume, page number etc.</li>
|
772 |
|
|
<li>status: The nomenclatural status of a name</li>
|
773 |
|
|
<li>description: name descriptions like protologues etc ...</li>
|
774 |
|
|
</ul>
|
775 |
|
|
</p>
|
776 |
|
|
<p>
|
777 |
|
|
These elements are combined in the part definitions array to from the specific parts to be rendered.
|
778 |
|
|
(The taxon name "Lapsana communis L., Sp. Pl.: 811. 1753" shall be an example in the following)
|
779 |
|
|
Usually the following parts are formed:
|
780 |
|
|
<ul>
|
781 |
|
|
<li>namePart: the name and rank (in example: "Lapsana communis")</li>
|
782 |
|
|
<li>authorshipPart: the author (in example: "L.")</li>
|
783 |
|
|
<li>nameAuthorPart: the combination of name and author part (in example: "Lapsana communis L.").</li>
|
784 |
|
|
This is useful for zoological names where the authorshipPart belongs to the name and both should</li>
|
785 |
|
|
be combined when a link to the taxon is rendered.</li>
|
786 |
|
|
<li>referencePart: the nomencaltural reference (in example: "Sp. Pl. 1753")</li>
|
787 |
|
|
<li>microreferencePart: usually the page number (in example ": 811.")</li>
|
788 |
|
|
<li>statusPart: the nomenclatorical status</li>
|
789 |
|
|
<li>descriptionPart: name descriptions like protologues etc ...</li>
|
790 |
|
|
</ul>
|
791 |
|
|
</p>
|
792 |
|
|
<p>
|
793 |
|
|
Each set of parts is dedicated to render a specific TaxonName type, the type names are used as keys for the
|
794 |
|
|
specific parts part definitions:
|
795 |
|
|
<ul>
|
796 |
|
|
<li>BotanicalName</li>
|
797 |
|
|
<li>ZoologicalName</li>
|
798 |
|
|
<li>#DEFAULT: covers ViralNames and other NonViralNames
|
799 |
|
|
</ul>
|
800 |
|
|
An example:
|
801 |
|
|
<pre>
|
802 |
|
|
{
|
803 |
|
|
"ZoologicalName": {
|
804 |
|
|
"namePart": {
|
805 |
|
|
"name": true
|
806 |
|
|
},
|
807 |
|
|
"referencePart": {
|
808 |
b5519d3a
|
Andreas Kohlbecker
|
"authors": true
|
809 |
0f5f1c12
|
Andreas Kohlbecker
|
},
|
810 |
|
|
"microreferencePart": {
|
811 |
|
|
"microreference": true
|
812 |
|
|
},
|
813 |
|
|
"statusPart": {
|
814 |
|
|
"status": true
|
815 |
|
|
},
|
816 |
|
|
"descriptionPart": {
|
817 |
|
|
"description": true
|
818 |
|
|
}
|
819 |
|
|
},
|
820 |
|
|
"BotanicalName": {
|
821 |
|
|
"namePart": {
|
822 |
|
|
"name": true,
|
823 |
|
|
"authors": true
|
824 |
|
|
},
|
825 |
|
|
"referencePart": {
|
826 |
|
|
"reference": true,
|
827 |
|
|
"microreference": true
|
828 |
|
|
},
|
829 |
|
|
"statusPart": {
|
830 |
|
|
"status": true
|
831 |
|
|
},
|
832 |
|
|
"descriptionPart": {
|
833 |
|
|
"description": true
|
834 |
|
|
}
|
835 |
|
|
}
|
836 |
|
|
}
|
837 |
|
|
</pre>',
|
838 |
|
|
);
|
839 |
|
|
|
840 |
|
|
//TODO remove after all portals are using the settings
|
841 |
|
|
$default_render_templates = theme('get_nameRenderTemplate', array());
|
842 |
|
|
if(!is_array($default_render_templates)) {
|
843 |
|
|
$default_render_templates = unserialize(CDM_NAME_RENDER_TEMPLATES_DEFAULT);
|
844 |
|
|
}
|
845 |
|
|
|
846 |
|
|
$form['taxon_name'][CDM_NAME_RENDER_TEMPLATES] = array(
|
847 |
|
|
'#type' => 'textarea',
|
848 |
|
|
'#title' => t('Name render templates'),
|
849 |
|
|
'#element_validate' => array('form_element_validate_json'),
|
850 |
|
|
'#default_value' => json_encode(variable_get(CDM_NAME_RENDER_TEMPLATES, $default_render_templates)),
|
851 |
|
|
'#description' => '
|
852 |
|
|
<p>
|
853 |
|
|
(Clearing the text area will reset it to the default)
|
854 |
|
|
</p>
|
855 |
|
|
<p>
|
856 |
|
|
The render templates array contains one or more name render templates to be used within the page areas identified by the
|
857 |
|
|
render path. The render path is used as key of the array sub subelements whereas the name render template array is set as value.
|
858 |
|
|
The following render Path keys are curretly recognized:
|
859 |
|
|
<ul>
|
860 |
a950f2f9
|
Andreas Kohlbecker
|
<li>list_of_taxa:</li>
|
861 |
0f5f1c12
|
Andreas Kohlbecker
|
<li>acceptedFor:</li>
|
862 |
|
|
<li>taxon_page_synonymy</li>
|
863 |
|
|
<li>typedesignations</li>
|
864 |
|
|
<li>taxon_page_title</li>
|
865 |
|
|
<li>polytomousKey</li>
|
866 |
|
|
<li>na: name + authorship</li>
|
867 |
|
|
<li>nar:name + authorship + reference</li>
|
868 |
|
|
<li>#DEFAULT</li>
|
869 |
|
|
</ul>
|
870 |
|
|
A single render template can be used for multiple render paths. In this case the according key of the render templates
|
871 |
|
|
array element should be a comma separated list of render paths, without any whitespace!.
|
872 |
|
|
</p>
|
873 |
|
|
<p>
|
874 |
|
|
A render template is an associative array. The keys of this array are referring to the keys as defined in the part
|
875 |
|
|
definitions array. See <a href="#edit-cdm-part-definitions">Part definitions</a> above for more information.
|
876 |
|
|
<p>
|
877 |
|
|
The value of the render template element must be set to TRUE in order to let this part being rendered.
|
878 |
|
|
The namePart, nameAuthorPart and referencePart can also hold an associative array with a single
|
879 |
|
|
element: array(\'#uri\' => TRUE). The value of the #uri element will be replaced by the according
|
880 |
|
|
links if the paramters $nameLink or $refenceLink are given to the name render function
|
881 |
|
|
(this is hard coded and cannot be configured here).',
|
882 |
6657531f
|
Andreas Kohlbecker
|
);
|
883 |
|
|
|
884 |
|
|
// @WA: D7 form api does not support reset buttons,
|
885 |
|
|
// so to mimic the D5 reset button we add one like this.
|
886 |
|
|
$form['actions']['reset'] = array(
|
887 |
|
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
888 |
|
|
'#weight' => 1000,
|
889 |
|
|
);
|
890 |
0f5f1c12
|
Andreas Kohlbecker
|
|
891 |
|
|
$form['#submit'] = array('submit_json_as_php_array');
|
892 |
|
|
// #json_elements especially defined for submit_json_as_php_array()
|
893 |
|
|
$form['#json_elements'] = array(CDM_NAME_RENDER_TEMPLATES, CDM_PART_DEFINITIONS);
|
894 |
6657531f
|
Andreas Kohlbecker
|
return system_settings_form($form);
|
895 |
|
|
}
|
896 |
|
|
|
897 |
|
|
|
898 |
|
|
/**
|
899 |
|
|
* @todo Please document this function.
|
900 |
|
|
* @see http://drupal.org/node/1354
|
901 |
|
|
*/
|
902 |
|
|
function cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description = '') {
|
903 |
|
|
$form[$form_name] = array(
|
904 |
|
|
'#type' => 'fieldset',
|
905 |
|
|
'#title' => t($form_title),
|
906 |
|
|
'#collapsible' => TRUE,
|
907 |
|
|
'#collapsed' => $collapsed,
|
908 |
|
|
'#tree' => TRUE,
|
909 |
|
|
'#description' => t($form_description),
|
910 |
|
|
);
|
911 |
|
|
|
912 |
|
|
$default_values = unserialize(CDM_DATAPORTAL_GALLERY_SETTINGS);
|
913 |
|
|
$gallery_settings = variable_get($form_name, $default_values);
|
914 |
|
|
// $test = variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE);
|
915 |
|
|
if ($form_name == CDM_DATAPORTAL_SEARCH_GALLERY_NAME) {
|
916 |
|
|
/*
|
917 |
|
|
TODO: why cdm_dataportal_search_items_on_page does not save the value on $test???
|
918 |
|
|
$form[$form_name]['cdm_dataportal_search_items_on_page'] = array(
|
919 |
|
|
'#type' => 'textfield',
|
920 |
|
|
'#title' => t('Search Page Size'),
|
921 |
|
|
'#default_value' => $test,
|
922 |
|
|
'#description' => t('Number of Names to display per page in search results.')
|
923 |
|
|
);
|
924 |
|
|
*/
|
925 |
|
|
$form[$form_name]['cdm_dataportal_show_taxon_thumbnails'] = array(
|
926 |
|
|
'#type' => 'checkbox',
|
927 |
|
|
'#title' => t('Show media thumbnails for accepted taxa'),
|
928 |
|
|
'#default_value' => $gallery_settings['cdm_dataportal_show_taxon_thumbnails'],
|
929 |
|
|
);
|
930 |
|
|
|
931 |
|
|
$form[$form_name]['cdm_dataportal_show_synonym_thumbnails'] = array(
|
932 |
|
|
'#type' => 'checkbox',
|
933 |
|
|
'#title' => t('Show media thumbnails for synonyms'),
|
934 |
|
|
'#default_value' => $gallery_settings['cdm_dataportal_show_synonym_thumbnails'],
|
935 |
|
|
'#description' => '',
|
936 |
|
|
);
|
937 |
|
|
}
|
938 |
|
|
|
939 |
|
|
// $showCaption = variable_get('cdm_dataportal_findtaxa_show_thumbnail_captions', 0);
|
940 |
|
|
$form[$form_name]['cdm_dataportal_show_thumbnail_captions'] = array(
|
941 |
|
|
'#type' => 'checkbox',
|
942 |
|
|
'#title' => t('Show captions under thumbnails'),
|
943 |
|
|
'#default_value' => $gallery_settings['cdm_dataportal_show_thumbnail_captions'],
|
944 |
|
|
'#description' => '',
|
945 |
|
|
);
|
946 |
|
|
|
947 |
|
|
$form[$form_name]['cdm_dataportal_media_maxextend'] = array(
|
948 |
|
|
'#type' => 'textfield',
|
949 |
|
|
'#title' => t('Thumbnail size') . ':',
|
950 |
|
|
'#default_value' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
951 |
|
|
'#description' => t('Select the size of each individual thumbnail.'),
|
952 |
|
|
);
|
953 |
|
|
|
954 |
|
|
if ($form_name != CDM_DATAPORTAL_MEDIA_GALLERY_NAME) {
|
955 |
|
|
$form[$form_name]['cdm_dataportal_media_cols'] = array(
|
956 |
|
|
'#type' => 'textfield',
|
957 |
|
|
'#title' => t('Number of columns') . ':',
|
958 |
|
|
'#default_value' => $gallery_settings['cdm_dataportal_media_cols'],
|
959 |
|
|
'#description' => t('Group the thumbnails in columns: select how many
|
960 |
|
|
columns the gallery should display.'),
|
961 |
|
|
);
|
962 |
|
|
}
|
963 |
|
|
|
964 |
|
|
if ($form_name == CDM_DATAPORTAL_SEARCH_GALLERY_NAME) {
|
965 |
|
|
$form[$form_name]['cdm_dataportal_media_maxRows'] = array(
|
966 |
|
|
'#type' => 'textfield',
|
967 |
|
|
'#title' => t('Maximum number of rows') . ':',
|
968 |
|
|
'#default_value' => $gallery_settings['cdm_dataportal_media_maxRows'],
|
969 |
|
|
'#description' => t('You can group the thumbnails in rows, select in how
|
970 |
|
|
many rows should be the thumbnails grouped.<br/><strong>Note:</strong>
|
971 |
|
|
If you want an unlimited number of rows please set to 0.'),
|
972 |
|
|
);
|
973 |
|
|
}
|
974 |
|
|
|
975 |
|
|
return $form;
|
976 |
|
|
}
|
977 |
|
|
|
978 |
|
|
/**
|
979 |
|
|
* @todo document this function.
|
980 |
|
|
*/
|
981 |
|
|
function cdm_settings_layout_taxon() {
|
982 |
|
|
$collapsed = FALSE;
|
983 |
|
|
$form = array();
|
984 |
|
|
|
985 |
7df1be04
|
Andreas Kohlbecker
|
$form['#submit'][] = 'cdm_settings_layout_taxon_submit';
|
986 |
|
|
|
987 |
d9c55e6c
|
Andreas Kohlbecker
|
$form['cdm_dataportal_show_back_to_search_results'] = array(
|
988 |
|
|
'#type' => 'checkbox',
|
989 |
|
|
'#title' => t('Show <em>Back to search results</em> link at the taxon site.'),
|
990 |
|
|
'#default_value' => variable_get('cdm_dataportal_show_back_to_search_results', 1),
|
991 |
|
|
'#description' => t('<p>If checked the link to search results is rendered at
|
992 |
|
|
the top of the taxon site. Clicking on the link the last search performed
|
993 |
|
|
is rendered again.</p>'),
|
994 |
|
|
);
|
995 |
|
|
|
996 |
6657531f
|
Andreas Kohlbecker
|
// --------- TABBED TAXON ------- //
|
997 |
|
|
$form['taxon_tabs'] = array(
|
998 |
|
|
'#type' => 'fieldset',
|
999 |
|
|
'#title' => t('Taxon tabs'),
|
1000 |
|
|
'#collapsible' => TRUE,
|
1001 |
|
|
'#collapsed' => FALSE,
|
1002 |
|
|
'#description' => t('If tabbed taxon page is enabled the taxon profile will
|
1003 |
|
|
be splitted in four diferent tabs; General, Synonymy, Images and
|
1004 |
|
|
Specimens. If the taxon has no information for any of the tabs/sections
|
1005 |
|
|
such tab will be not displayed.'),
|
1006 |
|
|
);
|
1007 |
|
|
|
1008 |
|
|
$form['taxon_tabs']['cdm_dataportal_taxonpage_tabs'] = array(
|
1009 |
|
|
'#type' => 'checkbox',
|
1010 |
|
|
'#title' => t('Tabbed taxon page'),
|
1011 |
|
|
'#default_value' => variable_get('cdm_dataportal_taxonpage_tabs', 1),
|
1012 |
|
|
'#description' => t('<p>If selected split the taxon page into individual
|
1013 |
|
|
tabs for description, images, synonymy and specimens. If not the taxon
|
1014 |
|
|
data is rendered as a long single page without tabs.</p>'),
|
1015 |
|
|
);
|
1016 |
|
|
|
1017 |
|
|
$form['taxon_tabs']['cdm_taxonpage_tabs_visibility'] = array(
|
1018 |
|
|
'#type' => 'checkboxes',
|
1019 |
|
|
'#title' => t('Tabs visibility options') . ':',
|
1020 |
|
|
'#default_value' => variable_get('cdm_taxonpage_tabs_visibility', get_taxon_options_list()),
|
1021 |
|
|
'#options' => get_taxon_options_list(),
|
1022 |
|
|
'#description' => t('Enable or disable Tabs in the Tabbed page display'),
|
1023 |
|
|
);
|
1024 |
|
|
|
1025 |
|
|
$form['taxon_tabs']['cdm_dataportal_default_tab'] = array(
|
1026 |
|
|
'#type' => 'select',
|
1027 |
|
|
'#title' => t('Default tab to display') . ':',
|
1028 |
|
|
'#default_value' => variable_get('cdm_dataportal_default_tab', 0),
|
1029 |
|
|
'#options' => unserialize(CDM_DATAPORTAL_DEFAULT_TAXON_TAB),
|
1030 |
|
|
'#description' => t('<p>Select the default tab to display when visiting a
|
1031 |
|
|
taxon page. Only available if Tabbed Taxon Page is enable.</p>
|
1032 |
|
|
<strong>Note:</strong> After performing a search and clicking in any
|
1033 |
|
|
synonym, the taxon tab to be rendered will be the synonymy of the accepted
|
1034 |
|
|
taxon and not the above selected tab.'),
|
1035 |
|
|
);
|
1036 |
|
|
|
1037 |
|
|
/* ====== TAXON_PROFILE ====== */
|
1038 |
|
|
$form['taxon_profile'] = array(
|
1039 |
|
|
'#type' => 'fieldset',
|
1040 |
|
|
'#title' => t('Taxon profile (tab)'),
|
1041 |
9438ad3a
|
Andreas Kohlbecker
|
'#description' => t('<p>This section covers the settings related to the taxon
|
1042 |
6657531f
|
Andreas Kohlbecker
|
profile tab, also known as the <strong>"General"</strong> tab.</p>'),
|
1043 |
|
|
'#collapsible' => TRUE,
|
1044 |
|
|
'#collapsed' => TRUE,
|
1045 |
|
|
);
|
1046 |
|
|
|
1047 |
|
|
// ---- PROFILE PICTURE ----//
|
1048 |
9c92cd84
|
Andreas Kohlbecker
|
|
1049 |
|
|
$form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE] = array(
|
1050 |
6657531f
|
Andreas Kohlbecker
|
'#type' => 'fieldset',
|
1051 |
9c92cd84
|
Andreas Kohlbecker
|
'#tree' => TRUE,
|
1052 |
9438ad3a
|
Andreas Kohlbecker
|
'#title' => t('Taxon profile picture'),
|
1053 |
6657531f
|
Andreas Kohlbecker
|
'#collapsible' => TRUE,
|
1054 |
|
|
'#collapsed' => FALSE,
|
1055 |
9438ad3a
|
Andreas Kohlbecker
|
'#description' => t('This sections allows configuring the display of the so called taxon profile image which is displayed in the taxon profile tab.'),
|
1056 |
6657531f
|
Andreas Kohlbecker
|
);
|
1057 |
|
|
|
1058 |
9c92cd84
|
Andreas Kohlbecker
|
//FIXME migrate variables:
|
1059 |
|
|
// cdm_dataportal_show_default_image ---> CDM_TAXON_PROFILE_IMAGE['show']
|
1060 |
|
|
// FIXME
|
1061 |
|
|
// eanable file modul in profile and in update
|
1062 |
|
|
|
1063 |
|
|
$taxon_profile_image_settings = variable_get(CDM_TAXON_PROFILE_IMAGE, unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT));
|
1064 |
|
|
/*
|
1065 |
|
|
* 'show' => 1,
|
1066 |
|
|
* 'maxextend' => 184,
|
1067 |
053a92ec
|
Andreas Kohlbecker
|
* 'media_uri_query' => ''
|
1068 |
9c92cd84
|
Andreas Kohlbecker
|
* 'custom_placeholder_image_on' => 1,
|
1069 |
|
|
* 'custom_placeholder_image_fid' => ''
|
1070 |
|
|
*/
|
1071 |
|
|
$form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['show'] = array(
|
1072 |
6657531f
|
Andreas Kohlbecker
|
'#type' => 'checkbox',
|
1073 |
|
|
'#title' => t('Enable profil picture'),
|
1074 |
|
|
'#description' => t('Show the profil picture.'),
|
1075 |
9c92cd84
|
Andreas Kohlbecker
|
'#default_value' => $taxon_profile_image_settings['show'],
|
1076 |
6657531f
|
Andreas Kohlbecker
|
);
|
1077 |
|
|
|
1078 |
9c92cd84
|
Andreas Kohlbecker
|
$form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['maxextend'] = array(
|
1079 |
d9c55e6c
|
Andreas Kohlbecker
|
'#type' => 'textfield',
|
1080 |
|
|
'#tree' => TRUE,
|
1081 |
|
|
'#title' => t('Profil picture maximum extend'),
|
1082 |
9c92cd84
|
Andreas Kohlbecker
|
'#default_value' => $taxon_profile_image_settings['maxextend'],
|
1083 |
d9c55e6c
|
Andreas Kohlbecker
|
'#field_suffix' => 'px',
|
1084 |
|
|
'#maxlength' => 4,
|
1085 |
|
|
'#size' => 4,
|
1086 |
|
|
'#description' => t('The maximum extend in either dimension, width or height, of the profil picture in pixels.')
|
1087 |
|
|
);
|
1088 |
|
|
|
1089 |
053a92ec
|
Andreas Kohlbecker
|
$form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['media_uri_query'] = array(
|
1090 |
|
|
'#type' => 'textfield',
|
1091 |
|
|
'#tree' => TRUE,
|
1092 |
|
|
'#title' => t('Additional URI query parameter'),
|
1093 |
|
|
'#default_value' => $taxon_profile_image_settings['media_uri_query'],
|
1094 |
|
|
'#maxlength' => 1024,
|
1095 |
|
|
'#size' => 60,
|
1096 |
|
|
'#description' => t('Additional query parameters to be used when requesting for the '
|
1097 |
|
|
. 'profile image. E.g.: <code>width=400&height=300&quality=95&format=jpeg</code>.'
|
1098 |
|
|
. 'The query parameters will be appendend to the uri of the media representation part'
|
1099 |
|
|
. ' as stored in the cdm. The query parameter string must not start with a \'&\' or \'?\'')
|
1100 |
|
|
);
|
1101 |
|
|
|
1102 |
9c92cd84
|
Andreas Kohlbecker
|
$form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_on'] = array(
|
1103 |
|
|
'#type' => 'checkbox',
|
1104 |
|
|
'#title' => t('Use a custom placeholder image'),
|
1105 |
7df1be04
|
Andreas Kohlbecker
|
'#description' => t("This image is shown as replacement if no image of the taxon is available."),
|
1106 |
9c92cd84
|
Andreas Kohlbecker
|
'#default_value' => $taxon_profile_image_settings['custom_placeholder_image_on']
|
1107 |
7df1be04
|
Andreas Kohlbecker
|
);
|
1108 |
|
|
|
1109 |
9c92cd84
|
Andreas Kohlbecker
|
if($taxon_profile_image_settings['custom_placeholder_image_on'] == 1){
|
1110 |
|
|
$form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_fid'] = array(
|
1111 |
|
|
'#type' => 'managed_file',
|
1112 |
|
|
'#title' => t('Custom placeholder image file'),
|
1113 |
|
|
'#progress_indicator' => 'bar',
|
1114 |
|
|
'#default_value' => $taxon_profile_image_settings['custom_placeholder_image_fid'],
|
1115 |
|
|
// '#name' => 'custom_placeholder_image',
|
1116 |
|
|
'#upload_location' => 'public://' . CDM_TAXON_PROFILE_IMAGE .'/'
|
1117 |
|
|
);
|
1118 |
|
|
|
1119 |
|
|
if($taxon_profile_image_settings['custom_placeholder_image_fid']){
|
1120 |
|
|
$profile_image_file = file_load($taxon_profile_image_settings['custom_placeholder_image_fid']);
|
1121 |
|
|
$url = file_create_url($profile_image_file->uri);
|
1122 |
|
|
$form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['preview'] = array(
|
1123 |
|
|
'#type' => 'item',
|
1124 |
|
|
'#markup' => '<div class="image-preview"><img src="' . $url . '"/></div>',
|
1125 |
|
|
);
|
1126 |
|
|
}
|
1127 |
|
|
} else {
|
1128 |
|
|
$form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_fid'] = array(
|
1129 |
|
|
'#type' => 'hidden',
|
1130 |
|
|
'#default_value' => $taxon_profile_image_settings['custom_placeholder_image_fid']
|
1131 |
|
|
);
|
1132 |
|
|
}
|
1133 |
|
|
|
1134 |
|
|
|
1135 |
|
|
|
1136 |
6657531f
|
Andreas Kohlbecker
|
$options = cdm_rankVocabulary_as_option();
|
1137 |
|
|
array_unshift($options, '-- DISABLED --');
|
1138 |
|
|
$form['taxon_profile']['picture']['image_hide_rank'] = array(
|
1139 |
|
|
'#type' => 'select',
|
1140 |
9438ad3a
|
Andreas Kohlbecker
|
'#title' => t('Hide profile picture for higher ranks') . ':',
|
1141 |
6657531f
|
Andreas Kohlbecker
|
'#default_value' => variable_get('image_hide_rank', '0'),
|
1142 |
|
|
'#options' => $options,
|
1143 |
9438ad3a
|
Andreas Kohlbecker
|
'#description' => t('The taxon profile picture will not be shown for taxa with rank higher that the selected.'),
|
1144 |
6657531f
|
Andreas Kohlbecker
|
);
|
1145 |
|
|
|
1146 |
|
|
// -- MEDIA THUMBNAILS -- //
|
1147 |
|
|
$form_name = CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME;
|
1148 |
|
|
$form_title = 'Taxon Profile Images';
|
1149 |
|
|
$form_description = '<p>The different section in the taxon profile can have images associated with them. These images are displayed in a gallery of thumbnails wich can be configuered here:</p>';
|
1150 |
|
|
$form['taxon_profile'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description);
|
1151 |
|
|
|
1152 |
|
|
// ---- FEATURE TREE ---- //
|
1153 |
8127188a
|
Alexander Oppermann
|
$form['taxon_profile']['feature_trees'] = array(
|
1154 |
6657531f
|
Andreas Kohlbecker
|
'#type' => 'fieldset',
|
1155 |
|
|
'#title' => t('Features'),
|
1156 |
|
|
'#collapsible' => TRUE,
|
1157 |
|
|
'#collapsed' => FALSE,
|
1158 |
|
|
'#description' => t("This section covers settings related to the taxon's
|
1159 |
|
|
<em>Feature Tree</em>. The <em>feature tree</em> are the taxon's
|
1160 |
|
|
features such as description, distribution, common names, etc. that Drupal
|
1161 |
|
|
will render at the taxon profile page."),
|
1162 |
|
|
);
|
1163 |
|
|
$featureTrees = cdm_get_featureTrees_as_options(TRUE);
|
1164 |
854e1d99
|
Andreas Kohlbecker
|
$saved_uuid = variable_get(CDM_PROFILE_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE);
|
1165 |
|
|
if(!isset($featureTrees['options'][$saved_uuid])) {
|
1166 |
|
|
$saved_uuid = UUID_DEFAULT_FEATURETREE;
|
1167 |
|
|
}
|
1168 |
6657531f
|
Andreas Kohlbecker
|
$form['taxon_profile']['feature_trees'][CDM_PROFILE_FEATURETREE_UUID] = array(
|
1169 |
|
|
'#type' => 'radios',
|
1170 |
|
|
'#title' => t('Taxon profile sections') . ':',
|
1171 |
854e1d99
|
Andreas Kohlbecker
|
'#default_value' => $saved_uuid,
|
1172 |
6657531f
|
Andreas Kohlbecker
|
'#options' => $featureTrees['options'],
|
1173 |
3f485c6d
|
Andreas Kohlbecker
|
'#pre_render' => array('form_pre_render_conditional_form_element', 'radios_prepare_options_suffix'),
|
1174 |
|
|
'#options_suffixes' => $featureTrees['treeRepresentations'],
|
1175 |
6657531f
|
Andreas Kohlbecker
|
'#description' => t('Select the Feature Tree to be displayed at the taxon
|
1176 |
|
|
profile. Click "Show Details" to see the Feature Tree elements.'
|
1177 |
|
|
),
|
1178 |
|
|
);
|
1179 |
|
|
$featureTrees = cdm_get_featureTrees_as_options();
|
1180 |
854e1d99
|
Andreas Kohlbecker
|
$saved_uuid = variable_get(CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE);
|
1181 |
|
|
if(!isset($featureTrees['options'][$saved_uuid])) {
|
1182 |
|
|
$saved_uuid = NULL;
|
1183 |
|
|
}
|
1184 |
6657531f
|
Andreas Kohlbecker
|
$form['taxon_profile']['feature_trees'][CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID] = array(
|
1185 |
|
|
'#type' => 'radios',
|
1186 |
|
|
'#title' => t('Natural language representation of structured descriptions') . ':',
|
1187 |
854e1d99
|
Andreas Kohlbecker
|
'#default_value' => $saved_uuid,
|
1188 |
6657531f
|
Andreas Kohlbecker
|
'#options' => $featureTrees['options'],
|
1189 |
3f485c6d
|
Andreas Kohlbecker
|
'#pre_render' => array('form_pre_render_conditional_form_element', 'radios_prepare_options_suffix'),
|
1190 |
|
|
'#options_suffixes' => $featureTrees['treeRepresentations'],
|
1191 |
6657531f
|
Andreas Kohlbecker
|
'#description' => t('Taxon descriptions can be stored in a highly structured
|
1192 |
|
|
form. The feature tree selected here will be used to generate textual
|
1193 |
|
|
representation in natural language.'
|
1194 |
|
|
),
|
1195 |
|
|
);
|
1196 |
|
|
|
1197 |
|
|
// ---- LAYOUT PER FEATURE ---- //
|
1198 |
|
|
$feature_tree = get_profile_featureTree();
|
1199 |
|
|
if (isset($feature_tree->root->children)) {
|
1200 |
|
|
|
1201 |
|
|
$form_feature_list_layout = array(
|
1202 |
|
|
'#title' => t('Taxon profile layout'),
|
1203 |
|
|
'#collapsible' => TRUE,
|
1204 |
|
|
'#collapsed' => FALSE,
|
1205 |
|
|
'#type' => 'fieldset',
|
1206 |
|
|
'#description' => t('Will be available in a future release.'),
|
1207 |
|
|
);
|
1208 |
|
|
|
1209 |
|
|
$feature_list_layout_settings_disabled = TRUE;
|
1210 |
|
|
foreach ($feature_tree->root->children as $featureNode) {
|
1211 |
|
|
|
1212 |
|
|
if (!$feature_list_layout_settings_disabled && isset($featureNode->feature)) {
|
1213 |
|
|
// Must not exceed 45 characters !!!
|
1214 |
|
|
$subform_id = LAYOUT_SETTING_PREFIX . $featureNode->feature->uuid;
|
1215 |
|
|
|
1216 |
|
|
$settings = mixed_variable_get($subform_id, FEATURE_TREE_LAYOUT_DEFAULTS);
|
1217 |
|
|
$systemDefaults = unserialize(FEATURE_TREE_LAYOUT_DEFAULTS);
|
1218 |
|
|
|
1219 |
|
|
$form_feature_list_layout[$subform_id] = array(
|
1220 |
|
|
'#tree' => TRUE,
|
1221 |
|
|
'#title' => 'test' . $featureNode->feature->representation_L10n,
|
1222 |
|
|
'#collapsible' => FALSE,
|
1223 |
|
|
'#collapsed' => FALSE,
|
1224 |
|
|
'#type' => 'fieldset',
|
1225 |
|
|
'#description' => t(''),
|
1226 |
|
|
);
|
1227 |
|
|
|
1228 |
|
|
$form_feature_list_layout[$subform_id]['enabled'] = array(
|
1229 |
|
|
'#type' => 'checkbox',
|
1230 |
|
|
'#title' => t('Enable'),
|
1231 |
|
|
'#default_value' => $settings['enabled'],
|
1232 |
|
|
'#description' => t('Enable user defined layout for this feature'),
|
1233 |
|
|
);
|
1234 |
|
|
|
1235 |
|
|
$form_feature_list_layout[$subform_id]['enclosingTag'] = array(
|
1236 |
|
|
'#type' => 'textfield',
|
1237 |
|
|
'#title' => t('Enclosing tag'),
|
1238 |
|
|
'#disabled' => !$settings['enabled'],
|
1239 |
|
|
'#default_value' => $settings['enclosingTag'],
|
1240 |
|
|
'#description' => t('Default is: ') . "'<code>" . $systemDefaults['enclosingTag'] . "</code>'",
|
1241 |
|
|
);
|
1242 |
|
|
|
1243 |
|
|
$form_feature_list_layout[$subform_id]['entryEnclosingTag'] = array(
|
1244 |
|
|
'#type' => 'textfield',
|
1245 |
|
|
'#title' => t('Entry enclosing tag'),
|
1246 |
|
|
'#disabled' => !$settings['enabled'],
|
1247 |
|
|
'#default_value' => $settings['entryEnclosingTag'],
|
1248 |
|
|
'#description' => t('Default is: ') . "'<code>" . $systemDefaults['entryEnclosingTag'] . "</code>'",
|
1249 |
|
|
);
|
1250 |
|
|
|
1251 |
|
|
$form_feature_list_layout[$subform_id]['glue'] = array(
|
1252 |
|
|
'#type' => 'textfield',
|
1253 |
|
|
'#title' => t('Glue'),
|
1254 |
|
|
'#disabled' => !$settings['enabled'],
|
1255 |
|
|
'#default_value' => $settings['glue'],
|
1256 |
|
|
'#description' => t('Default is: ') . "'<code>" . $systemDefaults['glue'] . "</code>'",
|
1257 |
|
|
);
|
1258 |
|
|
|
1259 |
|
|
}
|
1260 |
|
|
|
1261 |
|
|
$form['taxon_profile']['feature_list_layout'] = $form_feature_list_layout;
|
1262 |
|
|
}
|
1263 |
|
|
}
|
1264 |
|
|
|
1265 |
|
|
// ---- DISTRIBUTION LAYOUT ---- //
|
1266 |
|
|
$form['taxon_profile']['distribution_layout'] = array(
|
1267 |
|
|
'#title' => t('Distribution'),
|
1268 |
|
|
'#collapsible' => TRUE,
|
1269 |
|
|
'#collapsed' => FALSE,
|
1270 |
|
|
'#type' => 'fieldset',
|
1271 |
|
|
'#description' => t('Select if you want to sort or not the distribution text
|
1272 |
|
|
located below the distribution map.'),
|
1273 |
|
|
);
|
1274 |
|
|
|
1275 |
|
|
$form['taxon_profile']['distribution_layout']['distribution_sort'] = array(
|
1276 |
|
|
'#type' => 'radios',
|
1277 |
|
|
'#title' => t('Sort') . ':',
|
1278 |
|
|
'#default_value' => variable_get('distribution_sort', 'NO_SORT'),
|
1279 |
|
|
'#options' => array(
|
1280 |
|
|
'NO_SORT' => t('Standard (No sort)'),
|
1281 |
|
|
'HIDE_TDWG2' => t('Sorted without TDWG Level 2'),
|
1282 |
|
|
),
|
1283 |
|
|
);
|
1284 |
|
|
|
1285 |
|
|
$form['taxon_profile']['distribution_layout'][DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP] = array(
|
1286 |
|
|
'#type' => 'checkbox',
|
1287 |
|
|
'#title' => t('Show TextData elements on top of the map'),
|
1288 |
|
|
'#default_value' => variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0),
|
1289 |
|
|
'#description' => t('Check this if you want to appear all <code>TextData</code>
|
1290 |
|
|
elements on top of the map. Otherwise all <code>TextData</code>
|
1291 |
|
|
distribution elements will be listed below the other area elements.
|
1292 |
|
|
This option is useful if you need to have descriptive texts for each
|
1293 |
|
|
distribution map.'),
|
1294 |
|
|
);
|
1295 |
|
|
|
1296 |
|
|
|
1297 |
|
|
/* ====== SYNONYMY ====== */
|
1298 |
|
|
$form['taxon_synonymy'] = array(
|
1299 |
|
|
'#type' => 'fieldset',
|
1300 |
|
|
'#title' => t('Taxon synonymy (tab)'),
|
1301 |
|
|
'#collapsible' => TRUE,
|
1302 |
|
|
'#collapsed' => TRUE,
|
1303 |
|
|
'#description' => t('This section covers the settings related to the taxon
|
1304 |
501347df
|
Andreas Kohlbecker
|
<strong>synonymy</strong> tab.'),
|
1305 |
6657531f
|
Andreas Kohlbecker
|
);
|
1306 |
|
|
|
1307 |
|
|
$form['taxon_synonymy']['cdm_dataportal_nomref_in_title'] = array(
|
1308 |
|
|
'#type' => 'checkbox',
|
1309 |
|
|
'#title' => t('Show accepted taxon on top of the synonymy'),
|
1310 |
|
|
'#default_value' => variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE),
|
1311 |
|
|
'#description' => t('If checked, the first homotypic taxon is a repetition
|
1312 |
|
|
of the accepted taxon most likely with the full nomenclatural reference
|
1313 |
|
|
(depending on the currently chosen theme).'),
|
1314 |
|
|
);
|
1315 |
|
|
|
1316 |
|
|
$form['taxon_synonymy']['cdm_dataportal_display_is_accepted_for'] = array(
|
1317 |
|
|
'#type' => 'checkbox',
|
1318 |
|
|
'#title' => t('Display <em>is accepted for ...</em> on taxon pages when
|
1319 |
|
|
coming from a synonym link.'),
|
1320 |
|
|
'#default_value' => variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR),
|
1321 |
|
|
'#description' => t('Check this if after doing a search and clicking on a
|
1322 |
|
|
synonym you want to see the "accept of" text for the accepted synonym.'),
|
1323 |
|
|
);
|
1324 |
|
|
|
1325 |
|
|
$nameRelationshipTypeOptions = cdm_Vocabulary_as_option(UUID_NAME_RELATIONSHIP_TYPE);
|
1326 |
5014bf09
|
Andreas Kohlbecker
|
$form['taxon_synonymy']['name_relationships']['name_relationships_to_show'] = array(
|
1327 |
6657531f
|
Andreas Kohlbecker
|
'#type' => 'checkboxes',
|
1328 |
|
|
'#title' => t('Display name relationships') . ':',
|
1329 |
|
|
'#default_value' => variable_get('name_relationships_to_show', 0),
|
1330 |
|
|
'#options' => $nameRelationshipTypeOptions,
|
1331 |
|
|
'#description' => t('Select the name relationships you want to show for the
|
1332 |
|
|
accepted taxa.'),
|
1333 |
|
|
);
|
1334 |
|
|
|
1335 |
5014bf09
|
Andreas Kohlbecker
|
$form['taxon_synonymy'][CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS] = array(
|
1336 |
6657531f
|
Andreas Kohlbecker
|
'#type' => 'checkbox',
|
1337 |
|
|
'#title' => t('Show taxon relations ships of accepted taxon'),
|
1338 |
|
|
'#default_value' => variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT),
|
1339 |
|
|
'#description' => t('If this option is enabled the synonymy will show the
|
1340 |
|
|
below selected taxon relationships of accepted taxa.'),
|
1341 |
|
|
);
|
1342 |
|
|
|
1343 |
|
|
$taxonRelationshipTypeOptions = cdm_Vocabulary_as_option(UUID_TAXON_RELATIONSHIP_TYPE, '_cdm_relationship_type_term_label_callback');
|
1344 |
5014bf09
|
Andreas Kohlbecker
|
$form['taxon_synonymy'][CDM_TAXON_RELATIONSHIP_TYPES] = array(
|
1345 |
6657531f
|
Andreas Kohlbecker
|
'#type' => 'checkboxes',
|
1346 |
|
|
'#title' => t('Taxon relationship types') . ':',
|
1347 |
|
|
'#description' => t('Only taxon relationships of the selected type will be
|
1348 |
|
|
displayed'),
|
1349 |
|
|
'#options' => $taxonRelationshipTypeOptions,
|
1350 |
|
|
'#default_value' => variable_get(CDM_TAXON_RELATIONSHIP_TYPES, unserialize(CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT)),
|
1351 |
|
|
'#disabled' => !variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT),
|
1352 |
|
|
);
|
1353 |
|
|
|
1354 |
|
|
// ====== SPECIMENS ====== //
|
1355 |
|
|
$form['taxon_specimens'] = array(
|
1356 |
|
|
'#type' => 'fieldset',
|
1357 |
|
|
'#title' => t('Taxon specimens (tab)'),
|
1358 |
|
|
'#collapsible' => TRUE,
|
1359 |
|
|
'#collapsed' => TRUE,
|
1360 |
|
|
'#description' => t('This section covers the settings related to the taxon
|
1361 |
|
|
<strong>specimens</strong> tab.'),
|
1362 |
|
|
);
|
1363 |
|
|
|
1364 |
854e1d99
|
Andreas Kohlbecker
|
$featureTrees = cdm_get_featureTrees_as_options(TRUE);
|
1365 |
|
|
$saved_uuid = variable_get(CDM_OCCURRENCE_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE);
|
1366 |
|
|
if(!isset($featureTrees['options'][$saved_uuid])) {
|
1367 |
|
|
$saved_uuid = UUID_DEFAULT_FEATURETREE;
|
1368 |
|
|
}
|
1369 |
bfb2b81a
|
Andreas Kohlbecker
|
$form['taxon_specimens']['feature_trees'][CDM_OCCURRENCE_FEATURETREE_UUID] = array(
|
1370 |
|
|
'#type' => 'radios',
|
1371 |
|
|
'#title' => t('Specimen description feature tree') . ':',
|
1372 |
854e1d99
|
Andreas Kohlbecker
|
'#default_value' => $saved_uuid,
|
1373 |
bfb2b81a
|
Andreas Kohlbecker
|
'#options' => $featureTrees['options'],
|
1374 |
3f485c6d
|
Andreas Kohlbecker
|
'#pre_render' => array('form_pre_render_conditional_form_element', 'radios_prepare_options_suffix'),
|
1375 |
|
|
'#options_suffixes' => $featureTrees['treeRepresentations'],
|
1376 |
bfb2b81a
|
Andreas Kohlbecker
|
'#description' => t('Select the feature tree to be used for displaying specimen descriptions. Click "Show Details" to see the Feature Tree elements.'
|
1377 |
|
|
),
|
1378 |
|
|
);
|
1379 |
|
|
|
1380 |
6657531f
|
Andreas Kohlbecker
|
$form_name = CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME;
|
1381 |
|
|
$form_title = t('Specimen media');
|
1382 |
|
|
$form_description = t('Specimens may have media which is displayed at the
|
1383 |
|
|
Specimen tab/section as a gallery. It is possible to configure the
|
1384 |
|
|
thumbnails gallery here, however for configuring how a single media should
|
1385 |
|
|
be displayed please go to !url.</p>',
|
1386 |
|
|
array(
|
1387 |
|
|
'!url' => l(t('Layout -> Media'), 'admin/config/cdm_dataportal/settings/layout/media'),
|
1388 |
|
|
));
|
1389 |
|
|
$form['taxon_specimens'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, FALSE, $form_description);
|
1390 |
|
|
|
1391 |
|
|
// --- MEDIA GALLERY ---- //
|
1392 |
|
|
$form_name = CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB;
|
1393 |
|
|
$form_title = 'Media gallery (tab)';
|
1394 |
|
|
$form_description = '<p>This section covers the settings related to the taxon <strong>media</strong> tab.
|
1395 |
|
|
Taxa may have media (usually images) and they are as thumbnails displayed. It is possible to configure
|
1396 |
|
|
the thumbnails gallery here, however for configuring how a single media should be displayed please go to
|
1397 |
|
|
<a href="./?q=admin/settings/cdm_dataportal/layout/media">Layout -> Media</a></p>
|
1398 |
|
|
<p><strong>Note:</strong> These settings are only taken into account when the standard
|
1399 |
|
|
gallery viewer is selected at <a href="./?q=admin/settings/cdm_dataportal/layout/media">Layout -> Media</a>.</p>';
|
1400 |
|
|
$form['taxon_media'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, TRUE, $form_description);
|
1401 |
|
|
|
1402 |
|
|
// Comment @WA: D7 form api does not support reset buttons,
|
1403 |
|
|
// so to mimic the D5 reset button we add one like this.
|
1404 |
|
|
$form['actions']['reset'] = array(
|
1405 |
|
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
1406 |
|
|
'#weight' => 1000,
|
1407 |
|
|
);
|
1408 |
|
|
return system_settings_form($form);
|
1409 |
|
|
}
|
1410 |
|
|
|
1411 |
|
|
/**
|
1412 |
|
|
* @todo document this function.
|
1413 |
|
|
*/
|
1414 |
|
|
function cdm_settings_layout_search() {
|
1415 |
|
|
|
1416 |
|
|
$form = array();
|
1417 |
|
|
|
1418 |
|
|
$form['search_settings'] = array(
|
1419 |
|
|
'#type' => 'fieldset',
|
1420 |
|
|
'#title' => t('Taxa Search'),
|
1421 |
61b6ee11
|
Andreas Kohlbecker
|
'#collapsible' => FALSE,
|
1422 |
|
|
'#collapsed' => FALSE,
|
1423 |
6657531f
|
Andreas Kohlbecker
|
'#description' => t('<p>The data portal allows the users to perform searchs.</p><p>To perform searchs
|
1424 |
|
|
the block <em>CDM Taxon Search</em> should be enabled and visible for users
|
1425 |
|
|
where they can write the text to be searched. You can find Drupal block configuration
|
1426 |
|
|
site at <a href="./?q=admin/build/block">Administer->Site building->Blocks</a></p> '),
|
1427 |
|
|
);
|
1428 |
|
|
|
1429 |
61b6ee11
|
Andreas Kohlbecker
|
$form['search_settings']['simple_search_ignore_classification'] = array(
|
1430 |
|
|
'#type' => 'checkbox',
|
1431 |
|
|
'#title' => t('Ignore the chosen classification in simple search'),
|
1432 |
|
|
'#default_value' => variable_get('simple_search_ignore_classification', TRUE),
|
1433 |
|
|
'#description' => t('The simple search, which can be executed via the search block,
|
1434 |
|
|
will by default search on all classifications. Remove the tick if you want your
|
1435 |
|
|
portal to search on the classification selected in the classification browser
|
1436 |
|
|
selector.'),
|
1437 |
|
|
);
|
1438 |
|
|
|
1439 |
6657531f
|
Andreas Kohlbecker
|
$form['search_settings']['cdm_dataportal_search_items_on_page'] = array(
|
1440 |
|
|
'#type' => 'textfield',
|
1441 |
|
|
'#title' => t('Results per page') . ':',
|
1442 |
|
|
'#default_value' => variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE),
|
1443 |
|
|
'#description' => t('Number of results to display per page.'),
|
1444 |
|
|
);
|
1445 |
|
|
|
1446 |
|
|
$form['search_settings']['cdm_search_taxa'] = array(
|
1447 |
|
|
'#type' => 'checkbox',
|
1448 |
|
|
'#title' => t('Sets the default value of <em>Search for accepted taxa</em> in the advanced search form.'),
|
1449 |
|
|
'#default_value' => variable_get('cdm_search_taxa', 1),
|
1450 |
|
|
'#description' => t('<p>If checked the <em>Search for accepted taxa </em> option will be enabled in the advanced form.</p>'),
|
1451 |
|
|
);
|
1452 |
|
|
|
1453 |
|
|
$form['search_settings']['cdm_search_synonyms'] = array(
|
1454 |
|
|
'#type' => 'checkbox',
|
1455 |
|
|
'#title' => t('Sets the default value of <em>Search for synonyms</em> in the advanced search form.'),
|
1456 |
|
|
'#default_value' => variable_get('cdm_search_synonyms', 1),
|
1457 |
|
|
'#description' => t('<p>If checked the <em>Search for synonyms</em> option will be enabled in the advanced form.</p>'),
|
1458 |
|
|
);
|
1459 |
|
|
|
1460 |
|
|
$form['search_settings']['cdm_search_common_names'] = array(
|
1461 |
|
|
'#type' => 'checkbox',
|
1462 |
|
|
'#title' => t('Sets the default value of <em>Search for common names</em> in the advanced search form.'),
|
1463 |
|
|
'#default_value' => variable_get('cdm_search_common_names', 0),
|
1464 |
|
|
'#description' => t('<p>If checked the <em>Search for common names</em> option will be enabled in the advanced form.</p>'),
|
1465 |
|
|
);
|
1466 |
|
|
|
1467 |
|
|
$form['search_settings']['cdm_search_use_default_values'] = array(
|
1468 |
|
|
'#type' => 'checkbox',
|
1469 |
|
|
'#title' => t('Sets use of default values in the advanced search form.'),
|
1470 |
|
|
'#default_value' => variable_get('cdm_search_use_default_values', 1),
|
1471 |
|
|
'#description' => t('<p>If checked the defqult values set abovewill be used for the search.</p>'),
|
1472 |
|
|
);
|
1473 |
|
|
|
1474 |
|
|
|
1475 |
|
|
// --- SEARCH TAXA GALLERY ---- //
|
1476 |
|
|
$items = variable_get('cdm_dataportal_search_items_on_page', CDM_DATAPORTAL_SEARCH_ITEMS_ON_PAGE);
|
1477 |
|
|
$collapsed = FALSE;
|
1478 |
|
|
$form_name = CDM_DATAPORTAL_SEARCH_GALLERY_NAME;
|
1479 |
|
|
$form_title = 'Taxa Search thumbnails';
|
1480 |
|
|
$form_description = 'Search results may show thumbnails. ';
|
1481 |
|
|
$form[] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed, $form_description);
|
1482 |
|
|
|
1483 |
|
|
// Comment @WA: D7 form api does not support reset buttons,
|
1484 |
|
|
// so to mimic the D5 reset button we add one like this.
|
1485 |
|
|
$form['actions']['reset'] = array(
|
1486 |
|
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
1487 |
|
|
'#weight' => 1000,
|
1488 |
|
|
);
|
1489 |
|
|
return system_settings_form($form);
|
1490 |
|
|
}
|
1491 |
|
|
|
1492 |
|
|
/**
|
1493 |
|
|
* @todo document this function.
|
1494 |
|
|
*/
|
1495 |
|
|
function cdm_settings_layout_media() {
|
1496 |
|
|
|
1497 |
|
|
$form = array();
|
1498 |
|
|
|
1499 |
|
|
$form['media_settings'] = array(
|
1500 |
|
|
'#type' => 'fieldset',
|
1501 |
a950f2f9
|
Andreas Kohlbecker
|
'#title' => t('Media settings'),
|
1502 |
|
|
'#collapsible' => FALSE,
|
1503 |
6657531f
|
Andreas Kohlbecker
|
'#collapsed' => FALSE,
|
1504 |
ccde8251
|
Andreas Kohlbecker
|
'#description' => 'This section covers layout settings for media pages.'
|
1505 |
|
|
. 'Further media related settings may be found under the taxon layout settings and on the general settings.',
|
1506 |
6657531f
|
Andreas Kohlbecker
|
);
|
1507 |
|
|
|
1508 |
|
|
$form['media_settings']['image_gallery_viewer'] = array(
|
1509 |
|
|
'#type' => 'select',
|
1510 |
|
|
'#title' => t('Image viewer') . ':',
|
1511 |
|
|
'#default_value' => variable_get('image_gallery_viewer', 'default'),
|
1512 |
|
|
'#options' => array(
|
1513 |
|
|
'default' => t('Standard image viewer'),
|
1514 |
|
|
'fsi' => t('FSI viewer (requires FSI server!)'),
|
1515 |
|
|
),
|
1516 |
|
|
);
|
1517 |
|
|
|
1518 |
|
|
// --- MEDIA GALLERY ---- //
|
1519 |
|
|
$form_name = CDM_DATAPORTAL_MEDIA_GALLERY_NAME;
|
1520 |
|
|
$form_title = 'Standard viewer';
|
1521 |
|
|
$form_description = '<p>Configure the standard image viewer.</p><p><strong>Note:</strong> the image viewer should selected otherwise settings are not taking into account.</p>';
|
1522 |
|
|
// $form[] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, $collapsed);
|
1523 |
|
|
$form['media_settings'][] = cdm_dataportal_create_gallery_settings_form($form_name, $form_title, FALSE, $form_description);
|
1524 |
|
|
|
1525 |
|
|
// @WA: D7 form api does not support reset buttons,
|
1526 |
|
|
// so to mimic the D5 reset button we add one like this.
|
1527 |
|
|
$form['actions']['reset'] = array(
|
1528 |
|
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
1529 |
|
|
'#weight' => 1000,
|
1530 |
|
|
);
|
1531 |
|
|
return system_settings_form($form);
|
1532 |
|
|
}
|
1533 |
|
|
|
1534 |
|
|
/**
|
1535 |
|
|
* GEOSERVICE and Map settings.
|
1536 |
|
|
*/
|
1537 |
1d39ec64
|
w.addink
|
function cdm_settings_geo($form, &$form_state) {
|
1538 |
6657531f
|
Andreas Kohlbecker
|
|
1539 |
|
|
$form = array();
|
1540 |
|
|
|
1541 |
|
|
/*
|
1542 |
|
|
GEO SERVER
|
1543 |
|
|
*/
|
1544 |
ba706bf0
|
Andreas Kohlbecker
|
$form['edit_map_server'] = array(
|
1545 |
6657531f
|
Andreas Kohlbecker
|
'#type' => 'fieldset',
|
1546 |
ba706bf0
|
Andreas Kohlbecker
|
'#tree' => true,
|
1547 |
|
|
'#title' => t('EDIT map service'),
|
1548 |
6657531f
|
Andreas Kohlbecker
|
'#collapsible' => TRUE,
|
1549 |
|
|
'#collapsed' => TRUE,
|
1550 |
|
|
'#description' => t('Configuration and selection of your geo server.
|
1551 |
|
|
The Geo Server is responsible for generating the maps.'),
|
1552 |
|
|
);
|
1553 |
|
|
|
1554 |
ba706bf0
|
Andreas Kohlbecker
|
$current_geoserver_settings = get_edit_map_service_settings();
|
1555 |
|
|
|
1556 |
|
|
$form['edit_map_server']['base_uri'] = array(
|
1557 |
6657531f
|
Andreas Kohlbecker
|
'#type' => 'select',
|
1558 |
ba706bf0
|
Andreas Kohlbecker
|
'#title' => t('EDIT map service') . ':',
|
1559 |
|
|
'#default_value' => $current_geoserver_settings['base_uri'],
|
1560 |
|
|
'#options' => unserialize(EDIT_MAPSERVER_URI),
|
1561 |
|
|
'#description' => t('Select the EDIT map server you want to use within your data portal.'),
|
1562 |
6657531f
|
Andreas Kohlbecker
|
);
|
1563 |
ba706bf0
|
Andreas Kohlbecker
|
$form['edit_map_server']['version'] = array(
|
1564 |
|
|
'#type' => 'select',
|
1565 |
|
|
'#title' => t('Version') . ':',
|
1566 |
|
|
'#default_value' => $current_geoserver_settings['version'],
|
1567 |
|
|
'#options' => unserialize(EDIT_MAPSERVER_VERSION),
|
1568 |
|
|
'#description' => t('The version of the EDIT map services'),
|
1569 |
6657531f
|
Andreas Kohlbecker
|
);
|
1570 |
|
|
|
1571 |
|
|
/*
|
1572 |
|
|
MAP SETTINGS
|
1573 |
|
|
*/
|
1574 |
|
|
$form['map_settings'] = array(
|
1575 |
|
|
'#type' => 'fieldset',
|
1576 |
|
|
'#title' => t('Maps settings'),
|
1577 |
|
|
'#collapsible' => TRUE,
|
1578 |
|
|
'#collapsed' => TRUE,
|
1579 |
|
|
'#description' => t('General configuration for all map types.'),
|
1580 |
|
|
);
|
1581 |
|
|
|
1582 |
|
|
$form['map_settings']['cdm_dataportal_geoservice_display_width'] = array(
|
1583 |
|
|
'#type' => 'textfield',
|
1584 |
|
|
'#title' => t('Maps width') . ':',
|
1585 |
|
|
'#default_value' => variable_get('cdm_dataportal_geoservice_display_width', 390),
|
1586 |
|
|
'#description' => t('Choose the width of your maps, the height will always
|
1587 |
|
|
be the half of the width. A value of 500 means the size will be 500 pixels
|
1588 |
|
|
width and 250 pixels height.'),
|
1589 |
|
|
);
|
1590 |
|
|
|
1591 |
|
|
$form['map_settings']['cdm_dataportal_geoservice_bounding_box'] = array(
|
1592 |
|
|
'#type' => 'textfield',
|
1593 |
|
|
'#title' => t('Fixed bounding box') . ':',
|
1594 |
|
|
'#default_value' => variable_get('cdm_dataportal_geoservice_bounding_box', '-180,-90,180,90'),
|
1595 |
|
|
'#description' => t('Define surrounding of area to be displayed in maps.
|
1596 |
|
|
Use "-180,-90,180,90" for the whole world. Leave <strong>empty</strong>
|
1597 |
|
|
to let the map <strong>automatically zoom</strong> to the distribution
|
1598 |
|
|
area.'),
|
1599 |
|
|
);
|
1600 |
|
|
|
1601 |
|
|
$form['map_settings']['cdm_dataportal_geoservice_labels_on'] = array(
|
1602 |
|
|
'#type' => 'checkbox',
|
1603 |
|
|
'#title' => '<b>' . t('Display area labels') . '</b>',
|
1604 |
|
|
'#default_value' => variable_get('cdm_dataportal_geoservice_labels_on', FALSE),
|
1605 |
|
|
'#description' => t('Check this if you like area names to be displayed in the maps. DOES IT WORK???? '),
|
1606 |
|
|
);
|
1607 |
|
|
|
1608 |
|
|
$form['map_settings']['cdm_dataportal_geoservice_map_caption'] = array(
|
1609 |
|
|
'#type' => 'textfield',
|
1610 |
|
|
'#title' => t('Map caption') . ':',
|
1611 |
|
|
'#default_value' => variable_get('cdm_dataportal_geoservice_map_caption', ''),
|
1612 |
|
|
'#description' => t('Define a caption for the map.'),
|
1613 |
|
|
);
|
1614 |
|
|
|
1615 |
|
|
$form['map_settings']['cdm_dataportal_geoservice_distributionOpacity'] = array(
|
1616 |
|
|
'#type' => 'textfield',
|
1617 |
|
|
'#title' => t('Distribution layer opacity') . ':',
|
1618 |
|
|
'#default_value' => variable_get('cdm_dataportal_geoservice_distributionOpacity', '0.5'),
|
1619 |
|
|
'#description' => t('Valid values range from 0.0 to 1.0. Value 1.0 means the distributions (the countries or regions) will
|
1620 |
|
|
fully visible, while a value near to 0.0 will be not much visible.'),
|
1621 |
|
|
);
|
1622 |
|
|
|
1623 |
|
|
$form['map_settings']['cdm_dataportal_map_openlayers'] = array(
|
1624 |
|
|
'#type' => 'radios',
|
1625 |
|
|
'#title' => t('Map Viewer') . ':',
|
1626 |
|
|
'#options' => array(
|
1627 |
|
|
1 => "OpenLayers dynamic mapviewer",
|
1628 |
|
|
0 => "Plain image",
|
1629 |
|
|
),
|
1630 |
|
|
'#default_value' => variable_get('cdm_dataportal_map_openlayers', 1),
|
1631 |
|
|
'#description' => t('You can choose from two different map viewers:
|
1632 |
|
|
<ul><li><em>OpenLayers</em> displays the maps in an interactive viewer
|
1633 |
|
|
which allows zooming and panning. If not enabled the maps will consist
|
1634 |
|
|
on a static image. If enabled you can configure the default layer
|
1635 |
|
|
(background of your maps) below. Only one of them will be rendered.</li>
|
1636 |
|
|
<li><em>Plain image</em> displays the map as a plain non interactive
|
1637 |
|
|
image.</li></ul>'),
|
1638 |
|
|
);
|
1639 |
|
|
|
1640 |
|
|
$openLayersEnabled = variable_get('cdm_dataportal_map_openlayers', 1) == 1;
|
1641 |
|
|
|
1642 |
|
|
|
1643 |
|
|
// --- Plain Image Settings --- //
|
1644 |
|
|
$form['map_image'] = array(
|
1645 |
|
|
'#type' => 'fieldset',
|
1646 |
|
|
'#title' => t('Plain image map settings'),
|
1647 |
|
|
'#collapsible' => TRUE,
|
1648 |
|
|
'#collapsed' => $openLayersEnabled,
|
1649 |
|
|
'#description' => t('The settings in this section are still expertimental
|
1650 |
|
|
and can only be used with the EDIT map service version 1.1 or above.'),
|
1651 |
|
|
);
|
1652 |
|
|
|
1653 |
ba706bf0
|
Andreas Kohlbecker
|
$edit_mapserver_version = get_edit_map_service_version_number();
|
1654 |
6657531f
|
Andreas Kohlbecker
|
if ($edit_mapserver_version < 1.1) {
|
1655 |
|
|
$form['map_image']['#description'] = '<div class="messages warning">' . t("The selected EDIT map service version has to small version number: $edit_mapserver_version") . '</div>'
|
1656 |
|
|
. $form['map_image']['#description'];
|
1657 |
|
|
}
|
1658 |
|
|
|
1659 |
|
|
$form['map_image']['map_base_layer'] = array(
|
1660 |
|
|
'#type' => 'textfield',
|
1661 |
|
|
'#title' => t('Background layer') . ':',
|
1662 |
|
|
'#default_value' => variable_get('map_base_layer', 'cyprusdivs'),
|
1663 |
|
|
'#description' => t('Background layer. For available layers inspect !url1 or !url2.', array(
|
1664 |
5260ff5f
|
Andreas Kohlbecker
|
'!url1' => l(t('deegree-csw'), 'http://edit.africamuseum.be:8080/deegree-csw/md_search.jsp'),
|
1665 |
|
|
'!url2' => l(t('geoserver layers'), 'http://edit.africamuseum.be/geoserver/web/'), // http://edit.africamuseum.be/geoserver/rest/layers
|
1666 |
6657531f
|
Andreas Kohlbecker
|
)),
|
1667 |
|
|
);
|
1668 |
|
|
|
1669 |
|
|
$form['map_image']['map_bg_color'] = array(
|
1670 |
|
|
'#type' => 'textfield',
|
1671 |
|
|
'#title' => t('Background color') . ':',
|
1672 |
|
|
'#default_value' => variable_get('map_bg_color', '1874CD'),
|
1673 |
|
|
);
|
1674 |
|
|
|
1675 |
|
|
$form['map_image']['map_base_layer_style'] = array(
|
1676 |
|
|
'#type' => 'textfield',
|
1677 |
|
|
'#title' => t('Background layer area style') . ':',
|
1678 |
|
|
// Only line color by now.
|
1679 |
|
|
'#default_value' => variable_get('map_base_layer_style', 'ffffff,606060,,'),
|
1680 |
|
|
'#description' => t('Syntax: {Area fill color},{Area stroke color},{Area stroke width},{Area stroke dash style}'),
|
1681 |
|
|
);
|
1682 |
|
|
|
1683 |
|
|
|
1684 |
|
|
// --- OpenLayers Settings --- //
|
1685 |
|
|
$form['openlayers'] = array(
|
1686 |
|
|
'#type' => 'fieldset',
|
1687 |
|
|
'#title' => t('OpenLayers settings'),
|
1688 |
|
|
'#collapsible' => TRUE,
|
1689 |
|
|
'#collapsed' => !$openLayersEnabled,
|
1690 |
|
|
'#description' => '',
|
1691 |
|
|
);
|
1692 |
|
|
|
1693 |
|
|
if (!$openLayersEnabled) {
|
1694 |
|
|
$form['openlayers']['#description'] = '<div class="messages warning">' . t('The Openlayers viewer is currently not enabled! (see section Maps settings above )') . '</div>'
|
1695 |
|
|
. $form['openlayers']['#description'];
|
1696 |
|
|
}
|
1697 |
|
|
|
1698 |
|
|
$baselayer_options = array(
|
1699 |
|
|
/*
|
1700 |
|
|
NOTICE: must correspond to the layers defined in
|
1701 |
|
|
js/openlayers_,ap.js#getLayersByName()
|
1702 |
|
|
*/
|
1703 |
1d39ec64
|
w.addink
|
'osgeo_vmap0' => "Metacarta Vmap0 (OSGeo server)", // EPSG:4326: EPSG:900913
|
1704 |
|
|
'metacarta_vmap0' => "Metacarta Vmap0 (MetaCarta Labs server)", // EPSG:4326, EPSG:900913
|
1705 |
6657531f
|
Andreas Kohlbecker
|
// all others EPSG:900913
|
1706 |
|
|
// 'edit-vmap0_world_basic' => 'EDIT Vmap0',
|
1707 |
|
|
'edit-etopo1' => "ETOPO1 Global Relief Model",
|
1708 |
|
|
'mapnik' => 'OpenStreetMap',
|
1709 |
|
|
'osmarender' => 'OpenStreetMap (Tiles@home)',
|
1710 |
|
|
'gmap' => 'Google Streets',
|
1711 |
|
|
'gsat' => 'Google Satellite',
|
1712 |
|
|
'ghyb' => 'Google Hybrid',
|
1713 |
|
|
'veroad' => 'Virtual Earth Roads',
|
1714 |
|
|
'veaer' => 'Virtual Earth Aerial',
|
1715 |
|
|
'vehyb' => 'Virtual Earth Hybrid',
|
1716 |
|
|
// 'yahoo' => 'Yahoo Street',
|
1717 |
|
|
// 'yahoosat' => 'Yahoo Satellite',
|
1718 |
|
|
// 'yahoohyb' => 'Yahoo Hybrid',
|
1719 |
|
|
);
|
1720 |
|
|
|
1721 |
|
|
$form['openlayers']['baselayers'] = array(
|
1722 |
|
|
'#type' => 'checkboxes_preferred',
|
1723 |
|
|
'#title' => t('Base Layers') . ':',
|
1724 |
|
|
'#options' => $baselayer_options,
|
1725 |
|
|
'#default_value' => variable_get('baselayers', array('metacarta_vmap0' => "metacarta_vmap0", 'PREFERRED' => 'metacarta_vmap0')),
|
1726 |
|
|
'#description' => t('Choose the baselayer layer you prefer to use as map background in the OpenLayers dynamic mapviewer.'),
|
1727 |
|
|
);
|
1728 |
|
|
|
1729 |
|
|
// cdm_dataportal_geoservice_showLayerSwitcher
|
1730 |
|
|
$form['openlayers']['cdm_dataportal_geoservice_showLayerSwitcher'] = array(
|
1731 |
|
|
'#type' => 'checkbox',
|
1732 |
|
|
'#title' => '<b>' . t('Show Layer Switcher') . '</b>',
|
1733 |
|
|
'#default_value' => variable_get('cdm_dataportal_geoservice_showLayerSwitcher', TRUE),
|
1734 |
|
|
'#description' => t('
|
1735 |
|
|
The Layer Switcher control displays a table of contents
|
1736 |
|
|
for the map. This allows the user interface to switch between
|
1737 |
|
|
BaseLayers and to show or hide Overlays. By default the switcher is
|
1738 |
|
|
shown minimized on the right edge of the map, the user may expand it
|
1739 |
|
|
by clicking on the handle.'
|
1740 |
|
|
),
|
1741 |
|
|
);
|
1742 |
|
|
|
1743 |
|
|
$localhostkey = 'ABQIAAAAFho6eHAcUOTHLmH9IYHAeBRi_j0U6kJrkFvY4-OX2XYmEAa76BTsyMmEq-tn6nFNtD2UdEGvfhvoCQ';
|
1744 |
|
|
$gmap_api_key = variable_get('gmap_api_key', 'ABQIAAAAFho6eHAcUOTHLmH9IYHAeBRi_j0U6kJrkFvY4-OX2XYmEAa76BTsyMmEq-tn6nFNtD2UdEGvfhvoCQ');
|
1745 |
|
|
$form['openlayers']['gmap_api_key'] = array(
|
1746 |
|
|
'#type' => 'textfield',
|
1747 |
|
|
'#title' => t('Google maps API key') . ':',
|
1748 |
|
|
'#default_value' => variable_get('gmap_api_key', $gmap_api_key),
|
1749 |
|
|
'#description' => t('If you want to use the Google Maps Layer, a key is
|
1750 |
|
|
needed. If you need a key, visit
|
1751 |
|
|
<a href="http://code.google.com/intl/en/apis/maps/signup.html">google maps api key</a>.
|
1752 |
|
|
<br/><strong>Note:</strong> The following key: <code>!localhostkey</code>
|
1753 |
|
|
is the default key for the localhost (127.0.0.1). The key in use is the
|
1754 |
|
|
one above this text.', array('!localhostkey' => $localhostkey)),
|
1755 |
|
|
);
|
1756 |
|
|
|
1757 |
|
|
$form['cdm_dataportal_geoservice_map_legend'] = array(
|
1758 |
|
|
'#type' => 'fieldset',
|
1759 |
|
|
'#title' => t('Map legend'),
|
1760 |
|
|
'#collapsible' => TRUE,
|
1761 |
|
|
'#collapsed' => TRUE,
|
1762 |
|
|
'#description' => t('Configure the maps legend.'),
|
1763 |
|
|
);
|
1764 |
|
|
|
1765 |
|
|
$form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_on'] = array(
|
1766 |
|
|
'#type' => 'checkbox',
|
1767 |
|
|
'#title' => '<b>' . t('Display a map legend') . '</b>',
|
1768 |
|
|
'#default_value' => variable_get('cdm_dataportal_geoservice_legend_on', TRUE),
|
1769 |
|
|
'#description' => t('Check this if you like a legend to be displayed with the maps.'),
|
1770 |
|
|
);
|
1771 |
|
|
|
1772 |
|
|
$form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legendOpacity'] = array(
|
1773 |
|
|
'#type' => 'textfield',
|
1774 |
|
|
'#title' => t('Legend opacity'),
|
1775 |
|
|
'#default_value' => variable_get('cdm_dataportal_geoservice_legendOpacity', '0.5'),
|
1776 |
|
|
'#description' => t('Valid values range from 0.0 to 1.0. Value 1.0 means the legend will be fully visible, while a value near
|
1777 |
|
|
to 0.0 will be not much visible.'),
|
1778 |
|
|
);
|
1779 |
|
|
|
1780 |
|
|
$form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_font_size'] = array(
|
1781 |
|
|
'#type' => 'textfield',
|
1782 |
|
|
'#title' => t('Font size'),
|
1783 |
|
|
'#default_value' => variable_get('cdm_dataportal_geoservice_legend_font_size', 10),
|
1784 |
|
|
'#description' => t('Font size in pixels.'),
|
1785 |
|
|
);
|
1786 |
|
|
|
1787 |
|
|
$fontStyles = array(
|
1788 |
|
|
0 => "plane",
|
1789 |
|
|
1 => "italic",
|
1790 |
|
|
);
|
1791 |
|
|
$form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_font_style'] = array(
|
1792 |
|
|
'#type' => 'select',
|
1793 |
|
|
'#title' => t('Available font styles'),
|
1794 |
|
|
'#default_value' => variable_get('cdm_dataportal_geoservice_legend_font_style', FALSE),
|
1795 |
|
|
'#options' => $fontStyles,
|
1796 |
|
|
'#description' => t('Select a font style for the map legend.'),
|
1797 |
|
|
);
|
1798 |
|
|
|
1799 |
|
|
$form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_icon_width'] = array(
|
1800 |
|
|
'#type' => 'textfield',
|
1801 |
|
|
'#title' => t('Legend icon width'),
|
1802 |
|
|
'#default_value' => variable_get('cdm_dataportal_geoservice_legend_icon_width', 35),
|
1803 |
|
|
'#description' => t('Legend icon width in pixels.'),
|
1804 |
|
|
);
|
1805 |
|
|
$form['cdm_dataportal_geoservice_map_legend']['cdm_dataportal_geoservice_legend_icon_height'] = array(
|
1806 |
|
|
'#type' => 'textfield',
|
1807 |
|
|
'#title' => t('Legend icon height'),
|
1808 |
|
|
'#default_value' => variable_get('cdm_dataportal_geoservice_legend_icon_height', 15),
|
1809 |
|
|
'#description' => t('Legend icon height in pixels.'),
|
1810 |
|
|
);
|
1811 |
|
|
|
1812 |
|
|
// @WA: D7 form api does not support reset buttons,
|
1813 |
|
|
// so to mimic the D5 reset button we add one like this.
|
1814 |
|
|
$form['actions']['reset'] = array(
|
1815 |
|
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
1816 |
|
|
'#weight' => 1000,
|
1817 |
|
|
);
|
1818 |
1d39ec64
|
w.addink
|
|
1819 |
6657531f
|
Andreas Kohlbecker
|
return system_settings_form($form);
|
1820 |
|
|
}
|
1821 |
|
|
|
1822 |
|
|
/**
|
1823 |
|
|
* @todo document this function.
|
1824 |
|
|
*/
|
1825 |
|
|
function cdm_settings_cache() {
|
1826 |
|
|
|
1827 |
|
|
$form = array();
|
1828 |
|
|
|
1829 |
|
|
$form['cache_settings'] = array(
|
1830 |
|
|
'#type' => 'fieldset',
|
1831 |
|
|
'#title' => t('Cache Settings'),
|
1832 |
|
|
'#collapsible' => FALSE,
|
1833 |
|
|
'#collapsed' => FALSE,
|
1834 |
|
|
'#description' => t('<p>When caching is enabled all single taxon sites are
|
1835 |
|
|
stored in an internal drupal cache doing the portal response of taxa pages
|
1836 |
|
|
faster. This is possible because the sites are loaded from the cache and
|
1837 |
|
|
are not created from scratch.</p>'),
|
1838 |
|
|
);
|
1839 |
|
|
|
1840 |
|
|
$form['cache_settings']['cdm_webservice_cache'] = array(
|
1841 |
|
|
'#type' => 'checkbox',
|
1842 |
|
|
'#title' => t('<strong>Enable caching</strong>'),
|
1843 |
|
|
'#options' => cdm_help_general_cache(),
|
1844 |
|
|
'#default_value' => variable_get('cdm_webservice_cache', 1),
|
1845 |
|
|
'#description' => t('<p>Enable drupal to load taxa pages from the cache.</p>
|
1846 |
|
|
<p><strong>Note:</strong> If taxa are modified by the editor or any other
|
1847 |
|
|
application the changes will be not visible till the cache is erased.
|
1848 |
|
|
Therefore developers should deactived this feature when they are working
|
1849 |
|
|
on the CDM Dataportal Module.</p>'),
|
1850 |
|
|
);
|
1851 |
|
|
|
1852 |
|
|
$form['cache_settings']['cdm_run_cache'] = array(
|
1853 |
|
|
'#markup' => cdm_view_cache_site(),
|
1854 |
|
|
);
|
1855 |
|
|
|
1856 |
|
|
// @WA: D7 form api does not support reset buttons,
|
1857 |
|
|
// so to mimic the D5 reset button we add one like this.
|
1858 |
|
|
$form['actions']['reset'] = array(
|
1859 |
|
|
'#markup' => '<input id="reset" type="reset" class="form-submit" value="' . t('Reset to defaults') . '" />',
|
1860 |
|
|
'#weight' => 1000,
|
1861 |
|
|
);
|
1862 |
|
|
return system_settings_form($form);
|
1863 |
|
|
}
|
1864 |
|
|
|
1865 |
|
|
/**
|
1866 |
|
|
* Walk and cache all taxon pages.
|
1867 |
|
|
*/
|
1868 |
|
|
function cdm_view_cache_site() {
|
1869 |
|
|
|
1870 |
|
|
$out = '';
|
1871 |
|
|
|
1872 |
|
|
drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/cache_all_taxa.js');
|
1873 |
|
|
|
1874 |
|
|
$request_params = array();
|
1875 |
7d828d59
|
Andreas Kohlbecker
|
$request_params['class'] = "Taxon";
|
1876 |
6657531f
|
Andreas Kohlbecker
|
|
1877 |
7d828d59
|
Andreas Kohlbecker
|
$cdm_ws_page_taxa_url = cdm_compose_url(CDM_WS_TAXON . ".json", NULL, queryString($request_params));
|
1878 |
|
|
$cdm_ws_page_taxa_url = uri_uriByProxy($cdm_ws_page_taxa_url);
|
1879 |
|
|
$cdm_ws_page_taxa_url = rtrim($cdm_ws_page_taxa_url, '/');
|
1880 |
6657531f
|
Andreas Kohlbecker
|
|
1881 |
|
|
$out .= t('<p><strong>Cache all taxon pages</strong></p>');
|
1882 |
|
|
$out .= '<p>When you launch the cache process the cache is filled and ready to be enabled.<br/>
|
1883 |
|
|
Remember that when you load the taxa from the cache last changes on taxa will be not visible till you erase
|
1884 |
|
|
the cache and fill it again.</p>';
|
1885 |
|
|
$out .= '<p>Before running the cache bot you have to empty the cache manually.</p>';
|
1886 |
|
|
|
1887 |
|
|
$out .= '<div>' . t('This caching process may take long time and could cause heavy load on your server') . '</div>';
|
1888 |
|
|
$out .= '<div id="progress"></div>';
|
1889 |
|
|
|
1890 |
|
|
// Comment @WA: A form within a form is not valid html and not needed here.
|
1891 |
|
|
// Also, it would be recommended just to include this part of the form in the
|
1892 |
|
|
// rest of the form array in cdm_settings_cache().
|
1893 |
|
|
// $out .= '<form id="cache_site">';
|
1894 |
0516e3d0
|
Andreas Kohlbecker
|
$out .= '<input type="hidden" name="pageTaxaUrl" value="' . $cdm_ws_page_taxa_url . '"/>';
|
1895 |
7d828d59
|
Andreas Kohlbecker
|
$out .= '<input type="hidden" name="taxonPageUrl" value="' . url('cdm_dataportal/taxon/') . '"/>';
|
1896 |
6657531f
|
Andreas Kohlbecker
|
$out .= '<input type="button" name="start" value="' . t('Start') . '"/>';
|
1897 |
|
|
$out .= '<input type="button" name="stop" value="' . t('Stop') . '"/>';
|
1898 |
|
|
// $out .= '</form>';
|
1899 |
|
|
$out .= '</div>';
|
1900 |
|
|
/*
|
1901 |
|
|
foreach($taxonPager->records as $taxon){
|
1902 |
|
|
cdm_dataportal_taxon_view($uuid);
|
1903 |
|
|
}
|
1904 |
|
|
*/
|
1905 |
|
|
return $out;
|
1906 |
|
|
}
|
1907 |
|
|
|
1908 |
7df1be04
|
Andreas Kohlbecker
|
|
1909 |
|
|
function cdm_settings_layout_taxon_submit($form, &$form_state){
|
1910 |
9c92cd84
|
Andreas Kohlbecker
|
if (isset($form_state['values'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_fid'])) {
|
1911 |
|
|
$file = file_load($form_state['values'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_fid']);
|
1912 |
|
|
if(is_object($file)){
|
1913 |
|
|
$file->status = FILE_STATUS_PERMANENT;
|
1914 |
|
|
file_save($file);
|
1915 |
|
|
file_usage_add($file, 'cdm_dataportal', CDM_TAXON_PROFILE_IMAGE, 0);
|
1916 |
|
|
}
|
1917 |
7df1be04
|
Andreas Kohlbecker
|
}
|
1918 |
|
|
}
|
1919 |
|
|
|
1920 |
6657531f
|
Andreas Kohlbecker
|
/**
|
1921 |
|
|
* Form validation handler for ?
|
1922 |
|
|
*
|
1923 |
|
|
* Comment @WA: currently this handler is not used.
|
1924 |
|
|
* It seems partly for cdm_settings_general en partly for cdm_settings_cache?
|
1925 |
|
|
* Then you can change the name into cdm_settings_general_validate() or
|
1926 |
|
|
* cdm_settings_cache_validate().
|
1927 |
|
|
* But cdm_api_secref_cache_clear is not doing anything (yet)?
|
1928 |
|
|
*/
|
1929 |
|
|
function cdm_settings_validate($form, &$form_state) {
|
1930 |
|
|
|
1931 |
|
|
if (!str_endsWith($form_state['values']['cdm_webservice_url'], '/')) {
|
1932 |
|
|
// form_set_error('cdm_webservice_url', t("The URL to the CDM Web Service must end with a slash: '/'."));
|
1933 |
|
|
$form_state['values']['cdm_webservice_url'] .= '/';
|
1934 |
|
|
}
|
1935 |
|
|
|
1936 |
|
|
if ($form_state['values']['cdm_webservice_cache'] != variable_get('cdm_webservice_cache', 1)) {
|
1937 |
|
|
cache_clear_all(NULL, 'cache_cdm_ws');
|
1938 |
|
|
// Better clear secref_cache since I can not be sure if the cache has not
|
1939 |
|
|
// be used during this response.
|
1940 |
|
|
cdm_api_secref_cache_clear();
|
1941 |
|
|
}
|
1942 |
|
|
}
|
1943 |
|
|
|
1944 |
|
|
/**
|
1945 |
ba706bf0
|
Andreas Kohlbecker
|
* Returns an associative array of the currently chosen settings for the EDIT map service or the defaults as
|
1946 |
|
|
* specified in EDIT_MAPSERVER_URI_DEFAULT and EDIT_MAPSERVER_VERSION_DEFAULT:
|
1947 |
|
|
* - base_uri: the protocol and host part , e.g.: http://edit.africamuseum.be
|
1948 |
|
|
* - version: the version, e.g.: v1.1
|
1949 |
|
|
*
|
1950 |
|
|
* @return array
|
1951 |
|
|
* An associative array of the currently chosen settings for the EDIT map service or the defaults.
|
1952 |
6657531f
|
Andreas Kohlbecker
|
*/
|
1953 |
ba706bf0
|
Andreas Kohlbecker
|
function get_edit_map_service_settings() {
|
1954 |
|
|
|
1955 |
|
|
$settings = variable_get('edit_map_server', array(
|
1956 |
|
|
'base_uri' => EDIT_MAPSERVER_URI_DEFAULT,
|
1957 |
|
|
'version' => EDIT_MAPSERVER_VERSION_DEFAULT
|
1958 |
|
|
)
|
1959 |
|
|
);
|
1960 |
|
|
// replace old non tree like settings by default
|
1961 |
|
|
// TODO to be removed after release 3.1.5
|
1962 |
|
|
if(!is_array($settings)){
|
1963 |
|
|
variable_del('edit_map_server');
|
1964 |
|
|
return get_edit_map_service_settings();
|
1965 |
6657531f
|
Andreas Kohlbecker
|
}
|
1966 |
|
|
|
1967 |
ba706bf0
|
Andreas Kohlbecker
|
return $settings;
|
1968 |
6657531f
|
Andreas Kohlbecker
|
}
|
1969 |
|
|
|
1970 |
|
|
/**
|
1971 |
ba706bf0
|
Andreas Kohlbecker
|
* Returns the full edit map service URI e.g.: http://edit.africamuseum.be/edit_wp5/v1.1
|
1972 |
|
|
*
|
1973 |
|
|
* @return string
|
1974 |
|
|
* The full edit map service URI e.g.: http://edit.africamuseum.be/edit_wp5/v1.1
|
1975 |
|
|
*/
|
1976 |
|
|
function get_edit_map_service_full_uri() {
|
1977 |
|
|
$settings = get_edit_map_service_settings();
|
1978 |
|
|
return $settings['base_uri'] . EDIT_MAPSERVER_PATH . '/' . $settings['version'];
|
1979 |
|
|
}
|
1980 |
|
|
|
1981 |
|
|
|
1982 |
|
|
/**
|
1983 |
|
|
* Returns the version number of the currently selected edit mapserver as a float
|
1984 |
6657531f
|
Andreas Kohlbecker
|
*
|
1985 |
|
|
* @return float
|
1986 |
|
|
* The version number of the currently selected edit mapserver as a float.
|
1987 |
|
|
* Returns 0 on error.
|
1988 |
|
|
*/
|
1989 |
ba706bf0
|
Andreas Kohlbecker
|
function get_edit_map_service_version_number() {
|
1990 |
6657531f
|
Andreas Kohlbecker
|
|
1991 |
ba706bf0
|
Andreas Kohlbecker
|
$pattern = '/v([\d\.]+).*$/';
|
1992 |
6657531f
|
Andreas Kohlbecker
|
|
1993 |
ba706bf0
|
Andreas Kohlbecker
|
$settings = get_edit_map_service_settings();
|
1994 |
|
|
preg_match($pattern, $settings['version'], $matches, PREG_OFFSET_CAPTURE);
|
1995 |
6657531f
|
Andreas Kohlbecker
|
if (isset($matches[1])) {
|
1996 |
|
|
// Convert string to float.
|
1997 |
|
|
$version = 1 + $matches[1][0] - 1;
|
1998 |
|
|
return $version;
|
1999 |
|
|
}
|
2000 |
|
|
else {
|
2001 |
|
|
// Report error.
|
2002 |
ba706bf0
|
Andreas Kohlbecker
|
drupal_set_message(t(" Invalid EDIT map service version number: '!version'",
|
2003 |
|
|
array(
|
2004 |
|
|
'!version' => $settings['version'],
|
2005 |
|
|
'warning')
|
2006 |
|
|
)
|
2007 |
|
|
);
|
2008 |
6657531f
|
Andreas Kohlbecker
|
return 0;
|
2009 |
|
|
}
|
2010 |
|
|
}
|
2011 |
|
|
|
2012 |
30f78c59
|
Andreas Kohlbecker
|
/**
|
2013 |
ba706bf0
|
Andreas Kohlbecker
|
* Returns the array of selected items in a options array
|
2014 |
30f78c59
|
Andreas Kohlbecker
|
*
|
2015 |
|
|
* @param array $options
|
2016 |
|
|
* An options array as generated by a form element like checkoxes, select ...,
|
2017 |
|
|
*/
|
2018 |
|
|
function get_selection($options) {
|
2019 |
|
|
$selection = array();
|
2020 |
|
|
foreach ($options as $key=>$val) {
|
2021 |
|
|
if (!empty($val)) {
|
2022 |
|
|
$selection[] = $val;
|
2023 |
|
|
}
|
2024 |
|
|
}
|
2025 |
|
|
return $selection;
|
2026 |
|
|
}
|
2027 |
|
|
|
2028 |
bfb2b81a
|
Andreas Kohlbecker
|
|
2029 |
6657531f
|
Andreas Kohlbecker
|
/**
|
2030 |
|
|
* Implements hook_element_info().
|
2031 |
|
|
*
|
2032 |
14feebe9
|
Andreas Kohlbecker
|
* Allows modules to declare their own Form API element types and specify their default values.
|
2033 |
|
|
*
|
2034 |
|
|
* @see http://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_element_info/7
|
2035 |
6657531f
|
Andreas Kohlbecker
|
*/
|
2036 |
|
|
function cdm_dataportal_element_info() {
|
2037 |
|
|
$type['checkboxes_preferred'] = array(
|
2038 |
|
|
'#input' => TRUE,
|
2039 |
14feebe9
|
Andreas Kohlbecker
|
'#process' => array('checkboxes_preferred_expand'),
|
2040 |
6657531f
|
Andreas Kohlbecker
|
'#after_build' => array('checkboxes_preferred_after_build'),
|
2041 |
|
|
'#theme' => array('checkboxes_preferred'),
|
2042 |
|
|
// '#theme_wrapper' => array('form_element'),
|
2043 |
|
|
);
|
2044 |
|
|
return $type;
|
2045 |
|
|
}
|
2046 |
|
|
|
2047 |
|
|
/**
|
2048 |
14feebe9
|
Andreas Kohlbecker
|
* #process callback function for the custom form element type 'checkbox_preferred'
|
2049 |
|
|
*
|
2050 |
|
|
*
|
2051 |
6657531f
|
Andreas Kohlbecker
|
*/
|
2052 |
14feebe9
|
Andreas Kohlbecker
|
function checkboxes_preferred_expand($element, &$form_state, $form) {
|
2053 |
|
|
|
2054 |
|
|
// First of all create checkboxes for each of the elements
|
2055 |
6657531f
|
Andreas Kohlbecker
|
$element = form_process_checkboxes($element);
|
2056 |
|
|
|
2057 |
|
|
$children = element_children($element);
|
2058 |
|
|
|
2059 |
|
|
$element['table_start'] = array(
|
2060 |
|
|
'#markup' => '<table class="checkboxes_preferred"><tr><th></th><th>' . t('Enabled') . '</th><th>' . t('Default') . '</th></tr>',
|
2061 |
|
|
'#weight' => -1,
|
2062 |
|
|
);
|
2063 |
|
|
|
2064 |
14feebe9
|
Andreas Kohlbecker
|
// prepare first part each of the table rows which contains the row label
|
2065 |
6657531f
|
Andreas Kohlbecker
|
$weight = 0;
|
2066 |
|
|
foreach ($children as $key) {
|
2067 |
|
|
$odd_even = $weight % 4 == 0 ? 'odd' : 'even';
|
2068 |
|
|
$element[$key]['#weight'] = $weight;
|
2069 |
|
|
$element[$key]['#prefix'] = '<tr class="' . $odd_even . '"><td>' . t($element['#options'][$key]) . '</td><td>';
|
2070 |
|
|
$element[$key]['#suffix'] = '</td>';
|
2071 |
|
|
unset($element[$key]['#title']);
|
2072 |
|
|
$weight += 2;
|
2073 |
|
|
}
|
2074 |
|
|
$weight = 0;
|
2075 |
|
|
|
2076 |
14feebe9
|
Andreas Kohlbecker
|
// add a radio button to each of the checkboxes, the
|
2077 |
|
|
// check boxes have already been created at the beginning
|
2078 |
|
|
// of this function
|
2079 |
6657531f
|
Andreas Kohlbecker
|
if (count($element['#options']) > 0) {
|
2080 |
|
|
foreach ($element['#options'] as $key => $choice) {
|
2081 |
|
|
if (!isset($element[$key . '_preferred'])) {
|
2082 |
|
|
$element[$key . '_preferred'] = array(
|
2083 |
|
|
'#type' => 'radio',
|
2084 |
|
|
'#name' => $element['#parents'][0] . '_preferred',
|
2085 |
|
|
'#return_value' => check_plain($key),
|
2086 |
|
|
'#default_value' => empty($element['#default_value_2']) ? NULL : $element['#default_value_2'],
|
2087 |
|
|
'#attributes' => $element['#attributes'],
|
2088 |
1d39ec64
|
w.addink
|
'#parents' => $element['#parents'],
|
2089 |
6657531f
|
Andreas Kohlbecker
|
// '#spawned' => TRUE,
|
2090 |
|
|
'#weight' => $weight + 1,
|
2091 |
14feebe9
|
Andreas Kohlbecker
|
'#prefix' => '<td>', // add a prefix to start a new table cell
|
2092 |
|
|
'#suffix' => '</td></tr>', // add a prefix to close the tabel row
|
2093 |
6657531f
|
Andreas Kohlbecker
|
);
|
2094 |
|
|
}
|
2095 |
|
|
$weight += 2;
|
2096 |
|
|
}
|
2097 |
|
|
}
|
2098 |
|
|
|
2099 |
14feebe9
|
Andreas Kohlbecker
|
// end the table
|
2100 |
6657531f
|
Andreas Kohlbecker
|
$element['table_end'] = array(
|
2101 |
|
|
'#markup' => '</table>',
|
2102 |
|
|
'#weight' => $weight++,
|
2103 |
|
|
);
|
2104 |
|
|
|
2105 |
|
|
return $element;
|
2106 |
|
|
}
|
2107 |
|
|
|
2108 |
|
|
/**
|
2109 |
|
|
* Theme function for the custom form field 'checkboxes_preferred'.
|
2110 |
|
|
*/
|
2111 |
|
|
function theme_checkboxes_preferred($variables) {
|
2112 |
|
|
$element = $variables['element'];
|
2113 |
|
|
$out = '<div id="edit-baselayers-wrapper" class="form-item">';
|
2114 |
|
|
$out .= '<label for="edit-baselayers">' . $element['#title'] . '</label>';
|
2115 |
|
|
$out .= drupal_render_children($element);
|
2116 |
|
|
$out .= '<div class="description">' . $element['#description'] . '</div>';
|
2117 |
|
|
$out .= '</div>';
|
2118 |
|
|
return $out;
|
2119 |
|
|
}
|
2120 |
|
|
|
2121 |
|
|
/**
|
2122 |
14feebe9
|
Andreas Kohlbecker
|
* Callback for checkboxes preferred for widget which will
|
2123 |
|
|
* be called after the form or element is built. The call
|
2124 |
|
|
* back is configured in the form element by setting it as
|
2125 |
|
|
* #after_build parameter.
|
2126 |
|
|
*
|
2127 |
|
|
* @see http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#after_build
|
2128 |
|
|
*
|
2129 |
|
|
* @param $form
|
2130 |
|
|
* Nested array of form elements that comprise the form.
|
2131 |
|
|
* @param $form_state
|
2132 |
|
|
* A keyed array containing the current state of the form.
|
2133 |
|
|
*
|
2134 |
|
|
* @return the modified form array
|
2135 |
6657531f
|
Andreas Kohlbecker
|
*/
|
2136 |
|
|
function checkboxes_preferred_after_build($form, &$form_state) {
|
2137 |
|
|
|
2138 |
|
|
$parent_id = $form['#parents'][0];
|
2139 |
|
|
|
2140 |
|
|
if ($_POST && count($_POST) > 0) {
|
2141 |
|
|
// First pass of form processing.
|
2142 |
|
|
$preferred_layer = $_POST[$parent_id . '_preferred'];
|
2143 |
|
|
$form['#value']['PREFERRED'] = $preferred_layer;
|
2144 |
|
|
$form_state[$parent_id] = $form['#value'];
|
2145 |
1d39ec64
|
w.addink
|
$form_state['values']['baselayers'] = $form['#value'];
|
2146 |
6657531f
|
Andreas Kohlbecker
|
}
|
2147 |
|
|
else {
|
2148 |
|
|
// Second pass of form processing.
|
2149 |
|
|
$preferred_layer = $form['#value']['PREFERRED'];
|
2150 |
|
|
}
|
2151 |
|
|
|
2152 |
|
|
// Also set the chosen value (not sure if this is good Drupal style ....).
|
2153 |
|
|
foreach ($children = element_children($form) as $key) {
|
2154 |
|
|
if (!empty($form[$key]['#type']) && $form[$key]['#type'] == 'radio') {
|
2155 |
|
|
$form[$key]['#value'] = $preferred_layer;
|
2156 |
|
|
}
|
2157 |
|
|
}
|
2158 |
|
|
// The default layer must always be enabled.
|
2159 |
|
|
$form[$preferred_layer]['#value'] = $preferred_layer;
|
2160 |
|
|
|
2161 |
|
|
return $form;
|
2162 |
|
|
}
|
2163 |
0f5f1c12
|
Andreas Kohlbecker
|
|
2164 |
3f485c6d
|
Andreas Kohlbecker
|
function radios_prepare_options_suffix(&$elements){
|
2165 |
|
|
|
2166 |
|
|
$childrenKeys = element_children($elements);
|
2167 |
|
|
foreach($childrenKeys as $key){
|
2168 |
|
|
if(!is_array($elements[$key]['#theme_wrappers'])){
|
2169 |
|
|
$elements[$key]['#theme_wrappers'] = array();
|
2170 |
|
|
}
|
2171 |
|
|
if(isset($elements['#options_suffixes'][$key])){
|
2172 |
|
|
$elements[$key]['#theme_wrappers'][] = 'radio_options_suffix';
|
2173 |
|
|
$elements[$key]['#options_suffix'] = $elements['#options_suffixes'][$key];
|
2174 |
|
|
}
|
2175 |
|
|
}
|
2176 |
|
|
return $elements;
|
2177 |
|
|
|
2178 |
|
|
}
|
2179 |
|
|
|
2180 |
|
|
/**
|
2181 |
|
|
* TODO
|
2182 |
|
|
* @param unknown $variables
|
2183 |
|
|
*/
|
2184 |
|
|
function theme_radio_options_suffix($variables) {
|
2185 |
|
|
$element = $variables['element'];
|
2186 |
|
|
if(isset($element['#options_suffix'])) {
|
2187 |
|
|
$element['#children'] .= $element['#options_suffix'];
|
2188 |
|
|
}
|
2189 |
|
|
return $element['#children'];
|
2190 |
|
|
}
|
2191 |
|
|
|
2192 |
|
|
|
2193 |
0f5f1c12
|
Andreas Kohlbecker
|
/**
|
2194 |
|
|
* Element validate callback for text field and arrays containing json.
|
2195 |
|
|
*
|
2196 |
|
|
* @param $element
|
2197 |
|
|
* The form element to validate
|
2198 |
|
|
* @param $form
|
2199 |
|
|
* Nested array of form elements that comprise the form.
|
2200 |
|
|
* @param $form_state
|
2201 |
|
|
* A keyed array containing the current state of the form.
|
2202 |
|
|
*/
|
2203 |
|
|
function form_element_validate_json($element, &$form_state, $form) {
|
2204 |
|
|
if (!empty($element['#value'])) {
|
2205 |
|
|
json_decode($element['#value']);
|
2206 |
|
|
if(json_last_error() != JSON_ERROR_NONE){
|
2207 |
|
|
form_error($element, t('The form element %title contains invalid JSON. You can check the syntax with ', array('%title' => $element['#title'])) . l('JSONLint', 'http://jsonlint.com/'));
|
2208 |
|
|
}
|
2209 |
|
|
}
|
2210 |
|
|
}
|
2211 |
|
|
|
2212 |
|
|
/**
|
2213 |
|
|
* Form submission handler for textareas and textfields containing JSON.
|
2214 |
|
|
*
|
2215 |
|
|
* The contained JSON will be converted into an php array
|
2216 |
|
|
* or object and will be stores in the variables as such.
|
2217 |
|
|
*
|
2218 |
|
|
* @see http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#submit
|
2219 |
|
|
*
|
2220 |
|
|
* @param $form
|
2221 |
|
|
* Nested array of form elements that comprise the form.
|
2222 |
|
|
* @param $form_state
|
2223 |
|
|
* A keyed array containing the current state of the form.
|
2224 |
|
|
*
|
2225 |
|
|
*/
|
2226 |
|
|
function submit_json_as_php_array($form, &$form_state) {
|
2227 |
|
|
if (is_array($form['#json_elements'])) {
|
2228 |
|
|
foreach ($form['#json_elements'] as $element){
|
2229 |
80370786
|
Andreas Kohlbecker
|
if (trim($form_state['values'][$element])) {
|
2230 |
|
|
$form_state['values'][$element] = (array) json_decode($form_state['values'][$element]);
|
2231 |
|
|
} else {
|
2232 |
|
|
$form_state['values'][$element] = NULL;
|
2233 |
|
|
}
|
2234 |
0f5f1c12
|
Andreas Kohlbecker
|
}
|
2235 |
|
|
}
|
2236 |
|
|
}
|