1
|
<?php
|
2
|
// $Id$
|
3
|
|
4
|
/**
|
5
|
* Copyright (C) 2007 EDIT
|
6
|
* European Distributed Institute of Taxonomy
|
7
|
* http://www.e-taxonomy.eu
|
8
|
*
|
9
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
10
|
* See http://www.mozilla.org/MPL/MPL-1.1.html for the full license terms.
|
11
|
*/
|
12
|
|
13
|
/**
|
14
|
* default title for a taxon page
|
15
|
*
|
16
|
* @param NameTO $nameTO
|
17
|
* @return the formatted taxon name
|
18
|
*/
|
19
|
function theme_cdm_taxon_page_title($taxon){
|
20
|
|
21
|
RenderHints::pushToRenderStack('taxon_page_title');
|
22
|
if(isset($taxon->name->nomenclaturalReference)){
|
23
|
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
|
24
|
}
|
25
|
$out = theme('cdm_taxonName', $taxon->name, null, $referenceUri, false);
|
26
|
RenderHints::popFromRenderStack();
|
27
|
|
28
|
return '<span class="'.$taxon->class.'">'.$out.'</span>';
|
29
|
}
|
30
|
|
31
|
/**
|
32
|
* Default title for a name page
|
33
|
* @param $taxon_name The taxon name object
|
34
|
* @return the formatted name title
|
35
|
*/
|
36
|
function theme_cdm_name_page_title($taxon_name){
|
37
|
RenderHints::pushToRenderStack('taxon_page_title');
|
38
|
if(isset($taxon_name->nomenclaturalReference)){
|
39
|
$referenceUri = url(path_to_reference($taxon_name->nomenclaturalReference->uuid));
|
40
|
}
|
41
|
|
42
|
$out = '<span class="'.$taxon_name->class.'">'.theme('cdm_taxonName', $taxon_name, null, $referenceUri, false).'</span>';
|
43
|
RenderHints::popFromRenderStack();
|
44
|
return $out;
|
45
|
}
|
46
|
|
47
|
/**
|
48
|
* A wrapper function that groups available information to show by default, when
|
49
|
* a taxon page is requested by the browser.
|
50
|
* Individual themeing has to decide what this page should include (see methods beneath)
|
51
|
* and what information should go into tabs or should not be shown at all.
|
52
|
*
|
53
|
* It is headed by the name of the accepted taxon without author and reference.
|
54
|
* @param $taxonTO the taxon object
|
55
|
* @param $page_part name of the part to display,
|
56
|
* valid values are: 'description', 'images', 'synonymy', 'all'
|
57
|
*/
|
58
|
function theme_cdm_taxon_page_general($taxon, $page_part = 'description') {
|
59
|
|
60
|
global $theme;
|
61
|
|
62
|
$page_part = variable_get('cdm_dataportal_taxonpage_tabs', 1) ? $page_part : 'all';
|
63
|
$hideTabs = array();
|
64
|
|
65
|
|
66
|
// get images
|
67
|
$prefMimeTypeRegex = 'image:.*';
|
68
|
$prefMediaQuality = '*';
|
69
|
//$media = cdm_ws_get(CDM_WS_PORTAL_TAXONOMY_MEDIA, array(variable_get('cdm_taxonomictree_uuid', false),$taxon->uuid));
|
70
|
|
71
|
|
72
|
$selectShowMedia = variable_get('cdm_dataportal_show_media', 0);
|
73
|
if ($selectShowMedia == 0){
|
74
|
$media = cdm_ws_get(CDM_WS_PORTAL_TAXON_MEDIA, array($taxon->uuid, $prefMimeTypeRegex, $prefMediaQuality));
|
75
|
}else{
|
76
|
$media = cdm_ws_get(CDM_WS_PORTAL_TAXON_SUBTREE_MEDIA, array($taxon->uuid, $prefMimeTypeRegex, $prefMediaQuality));
|
77
|
}
|
78
|
/*
|
79
|
if(!isset($mediaList[0])) {
|
80
|
$hideTabs[] = theme('cdm_taxonpage_tab', 'Images');
|
81
|
}
|
82
|
*/
|
83
|
|
84
|
if(!isset($media[0])) {
|
85
|
$hideTabs[] = theme('cdm_taxonpage_tab', 'Images');
|
86
|
}
|
87
|
|
88
|
// $descriptionElementCount = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS_ELEMENTSBYTYPE, array($taxon->uuid, 'IndividualsAssociation'), "count=true");
|
89
|
// if($descriptionElementCount->Integer < 0) { //DEBUG HACK
|
90
|
// ### sending the same query twice is faster than two different ones, $descriptionElements will be retrieved again in the specimens page
|
91
|
$descriptionElements = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS_ELEMENTSBYTYPE, array($taxon->uuid, 'IndividualsAssociation'));
|
92
|
$descriptionElementCount = is_array($descriptionElements) ? count($descriptionElements) : 0;
|
93
|
if($descriptionElementCount == 0) {
|
94
|
$hideTabs[] = theme('cdm_taxonpage_tab', 'Specimens');
|
95
|
}
|
96
|
|
97
|
// hideImage flag depending on administative preset
|
98
|
$hideImages = false;
|
99
|
if(variable_get('image_hide_rank', '0') != '0'){
|
100
|
$rankCompare = rank_compare($taxon->name->rank->uuid, variable_get('image_hide_rank', '-99'));
|
101
|
$hideImages = ($rankCompare > -1);
|
102
|
}
|
103
|
// $hideTabs[] = theme('cdm_taxonpage_tab', 'General');
|
104
|
// $hideTabs[] = theme('cdm_taxonpage_tab', 'Synonymy')
|
105
|
|
106
|
// hide tabs
|
107
|
$tabhide_js = '';
|
108
|
foreach($hideTabs as $tabText) {
|
109
|
$tabhide_js .= "$('.tabs.primary').children('li').children('a:contains(\"$tabText\")').hide();\n";
|
110
|
}
|
111
|
drupal_add_js("
|
112
|
$(document).ready(function(){
|
113
|
$tabhide_js
|
114
|
});", 'inline');
|
115
|
|
116
|
$out = '';
|
117
|
$out .= theme('cdm_back_to_search_result_button');
|
118
|
if(variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR)){
|
119
|
$out .= theme('cdm_acceptedFor', 'page_general');
|
120
|
}
|
121
|
|
122
|
// --- DESCRIPTION --- //
|
123
|
if($page_part == 'description' || $page_part == 'all'){
|
124
|
|
125
|
$featureTree = cdm_ws_get(CDM_WS_FEATURETREE, variable_get(CDM_DATAPORTAL_DEFAULT_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE));
|
126
|
$taxonDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxon->uuid); //retrieve all description for the taxon
|
127
|
|
128
|
$nonStructuredDescriptions = array();
|
129
|
if($taxonDescriptions != null){
|
130
|
foreach ($taxonDescriptions as $taxonDescription) {
|
131
|
// check if structured description
|
132
|
$hasStructuredData = cdm_ws_get(CDM_WS_DESCRIPTION_HAS_STRUCTRURED_DATA, $taxonDescription->uuid);
|
133
|
$hasStructuredData = $hasStructuredData->Boolean == 'true';
|
134
|
if($hasStructuredData){
|
135
|
$structured_description_featuretree_uuid = variable_get(CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID, false);
|
136
|
$naturallanguage_textData = cdm_ws_get(CDM_WS_DESCRIPTION_NATURALLANGUAGE_DESCRIPTION, array($taxonDescription->uuid, $structured_description_featuretree_uuid));
|
137
|
if(!$naturallanguage_textData){
|
138
|
drupal_set_message('The \'FeatureTree\' for the generation of natural language representations is not configured correctly, please select a \'FeatureTree\' in the '.l('CDM Dataportal Settings', 'admin/settings/cdm_dataportal/layout'), 'warning');
|
139
|
}
|
140
|
$taxonDescription->elements = null;
|
141
|
$taxonDescription->elements = array($naturallanguage_textData);
|
142
|
}
|
143
|
$nonStructuredDescriptions[] = $taxonDescription;
|
144
|
}
|
145
|
$taxonDescriptions = null; // release memory
|
146
|
}
|
147
|
|
148
|
$mergedTrees = cdm_ws_descriptions_by_featuretree($featureTree, $nonStructuredDescriptions, variable_get('cdm_dataportal_descriptions_separated', FALSE));
|
149
|
|
150
|
$out .= '<div id="general">';
|
151
|
$out .= theme('cdm_taxon_page_description', $taxon, $mergedTrees, $media, $hideImages);
|
152
|
$out .= '</div>';
|
153
|
}
|
154
|
|
155
|
// --- IMAGES --- //
|
156
|
if(!$hideImages && $page_part == 'images' || $page_part == 'all'){
|
157
|
$out .= '<div id="images">';
|
158
|
if($page_part == 'all'){
|
159
|
$out .= '<h2>'.t('Images').'</h2>';
|
160
|
}
|
161
|
|
162
|
// get the image gallery as configured by the admin
|
163
|
$taxon_image_gallery = call_user_func_array(
|
164
|
'taxon_image_gallery_' . variable_get('image_gallery_viewer', 'default'),
|
165
|
array($taxon, $media));
|
166
|
$out .= $taxon_image_gallery;
|
167
|
|
168
|
$out .= '</div>';
|
169
|
|
170
|
if($theme == 'garland_cichorieae'){
|
171
|
$out .= theme('cdm_taxon_page_images_cichorieae_copyright');
|
172
|
}
|
173
|
}
|
174
|
|
175
|
// --- SYNONYMY --- //
|
176
|
if($page_part == 'synonymy' || $page_part == 'all'){
|
177
|
$out .= '<div id="synonymy">';
|
178
|
if($page_part == 'all'){
|
179
|
$out .= '<h2>'.t('Synonymy').'</h2>';
|
180
|
}
|
181
|
$addAcceptedTaxon = variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE);
|
182
|
$out .= theme('cdm_taxon_page_synonymy', $taxon, $addAcceptedTaxon);
|
183
|
|
184
|
$out .= '</div>';
|
185
|
}
|
186
|
|
187
|
// --- SPECIMENS --- //
|
188
|
if($descriptionElementCount > 0 && ($page_part == 'specimens' || $page_part == 'all') ){
|
189
|
$out .= '<div id="specimens">';
|
190
|
if($page_part == 'all'){
|
191
|
$out .= '<h2>'.t('Specimens').'</h2>';
|
192
|
}
|
193
|
$out .= theme('cdm_taxon_page_specimens', $taxon);
|
194
|
$out .= '</div>';
|
195
|
}
|
196
|
return $out;
|
197
|
}
|
198
|
|
199
|
|
200
|
/**
|
201
|
* Outputs all descriptive data and shows the preferred picture of the
|
202
|
* accepted taxon.
|
203
|
*
|
204
|
*/
|
205
|
function theme_cdm_taxon_page_description($taxon, $mergedTrees, $media = null, $hideImages = false){
|
206
|
|
207
|
if( variable_get('cdm_dataportal_show_default_image', false) && !$hideImages){
|
208
|
// preferred image
|
209
|
// hardcoded for testing;
|
210
|
$defaultRepresentationPart = false;
|
211
|
$defaultRepresentationPart->width = 184;
|
212
|
$defaultRepresentationPart->height = 144;
|
213
|
$defaultRepresentationPart->uri = drupal_get_path('theme', 'palmweb_2').'/images/no_picture.png';
|
214
|
|
215
|
// preferred image size 184px × 144
|
216
|
$imageMaxExtend = 184;
|
217
|
$out .= '<div class="preferredImage">'.$defaultRepresentationPart->uri.theme('cdm_preferredImage', $media, $defaultRepresentationPart, $imageMaxExtend).'</div>';
|
218
|
}
|
219
|
// description TOC
|
220
|
$out .= theme('cdm_featureTreeTOCs', $mergedTrees);
|
221
|
// description
|
222
|
$out .= theme('cdm_featureTrees', $mergedTrees, $taxon);
|
223
|
return $out;
|
224
|
}
|
225
|
|
226
|
|
227
|
function theme_cdm_taxon_page_specimens($taxon){
|
228
|
|
229
|
RenderHints::pushToRenderStack('taxon_page_specimens');
|
230
|
|
231
|
$descriptionElements = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS_ELEMENTSBYTYPE, array($taxon->uuid, 'IndividualsAssociation') );
|
232
|
|
233
|
//collect media (fieldObjectMedia, derivedUnitMedia) and add as fields
|
234
|
foreach($descriptionElements as $descriptionElement) {
|
235
|
if($descriptionElement->associatedSpecimenOrObservation){
|
236
|
$descriptionElement->_fieldObjectMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array($descriptionElement->associatedSpecimenOrObservation->uuid, 'fieldObjectMedia') );
|
237
|
$descriptionElement->_derivedUnitMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array($descriptionElement->associatedSpecimenOrObservation->uuid, 'derivedUnitMedia') );
|
238
|
// $derivedUnitFacde = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array($descriptionElement->associatedSpecimenOrObservation->uuid) );
|
239
|
// $descriptionElement->_titleCache = $derivedUnitFacde->titleCache;
|
240
|
}
|
241
|
}
|
242
|
|
243
|
if(variable_get('cdm_dataportal_map_openlayers', 1)){
|
244
|
$occurrenceQuery = cdm_ws_get(CDM_WS_GEOSERVICE_OCCURRENCEMAP, $taxon->uuid);
|
245
|
$occurrenceQuery = $occurrenceQuery->String;
|
246
|
$out .= get_openlayers_map(variable_get('cdm_dataportal_geoservice_display_width', false), $occurrenceQuery);
|
247
|
}
|
248
|
|
249
|
|
250
|
|
251
|
if($descriptionElements){
|
252
|
$out_specimenList = '<table class="specimens">';
|
253
|
$i = 1;
|
254
|
foreach($descriptionElements as $descriptionElement) {
|
255
|
$i++;
|
256
|
if($descriptionElement->associatedSpecimenOrObservation){
|
257
|
|
258
|
$mediaList = array();
|
259
|
if(is_array($descriptionElement->_fieldObjectMedia)){
|
260
|
$mediaList = array_merge($mediaList, $descriptionElement->_fieldObjectMedia);
|
261
|
}
|
262
|
if(is_array($descriptionElement->_derivedUnitMedia)){
|
263
|
$mediaList = array_merge($mediaList, $descriptionElement->_derivedUnitMedia);
|
264
|
}
|
265
|
$li = '<tr class="descriptionElement descriptionElement_IndividualsAssociation '.($i%2?'odd':'even').'"><td>' . $descriptionElement->associatedSpecimenOrObservation->titleCache;
|
266
|
if(count($mediaList) > 0){
|
267
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
|
268
|
$gallery_name = $descriptionElement->associatedSpecimenOrObservation->uuid;
|
269
|
$captionElements = array('#uri'=>t('open media'));
|
270
|
$gallery_html = theme(
|
271
|
'cdm_media_gallerie',
|
272
|
$mediaList,
|
273
|
$gallery_name ,
|
274
|
$gallery_settings['cdm_dataportal_media_maxextend'],
|
275
|
$gallery_settings['cdm_dataportal_media_cols'],
|
276
|
$gallery_settings['cdm_dataportal_media_maxRows'],
|
277
|
$captionElements, 'LIGHTBOX', null, null);
|
278
|
} else {
|
279
|
$gallery_html = '';
|
280
|
}
|
281
|
$li .= '</td><td>'.$gallery_html.'</td></tr>';
|
282
|
$out_specimenList .= $li;
|
283
|
}
|
284
|
}
|
285
|
$out_specimenList .= '</table>';
|
286
|
}
|
287
|
|
288
|
$out .= drupal_get_form('specimens_search_form');
|
289
|
//$test = specimens_table($descriptionElements);
|
290
|
//$out .= $test;
|
291
|
|
292
|
$out .= $out_specimenList;
|
293
|
|
294
|
|
295
|
RenderHints::popFromRenderStack();
|
296
|
return $out;
|
297
|
}
|
298
|
|
299
|
function specimens_search_form() {
|
300
|
|
301
|
//form select options
|
302
|
$form['specimens_search_options'] = array(
|
303
|
'#type' => 'value',
|
304
|
'#value' => array(t('No sort'), t('Name'), t('CatalogNumber'), t('Gallery'))
|
305
|
);
|
306
|
|
307
|
//the form
|
308
|
$form['specimens_search'] = array(
|
309
|
'#title' => t('Speciments sort'),
|
310
|
'#type' => 'fieldset',
|
311
|
'#description' => t('Select your sort criteria.'),
|
312
|
'#collapsible' => TRUE,
|
313
|
'#collapsed' => FALSE
|
314
|
);
|
315
|
|
316
|
//criteria
|
317
|
$form['specimens_search']['first_criteria'] = array(
|
318
|
'#title' => t('First criteria'),
|
319
|
'#type' => 'select',
|
320
|
'#options' => $form['specimens_search_options']['#value']
|
321
|
);
|
322
|
$form['specimens_search']['second_criteria'] = array(
|
323
|
'#title' => t('Second criteria'),
|
324
|
'#type' => 'select',
|
325
|
'#options' => $form['specimens_search_options']['#value']
|
326
|
);
|
327
|
$form['specimens_search']['third_criteria'] = array(
|
328
|
'#title' => t('Third criteria'),
|
329
|
'#type' => 'select',
|
330
|
'#options' => $form['specimens_search_options']['#value']
|
331
|
);
|
332
|
|
333
|
//submit button
|
334
|
$form['specimens_search']['submit'] = array(
|
335
|
'#type' => 'submit',
|
336
|
'#value' => t('Sort')
|
337
|
);
|
338
|
|
339
|
/*
|
340
|
//from properties
|
341
|
$form['#method'] = 'post';
|
342
|
$form['#action'] = 'http://example.com/?q=foo/bar';
|
343
|
$form['#attributes'] = array(
|
344
|
'enctype' => 'multipart/form-data',
|
345
|
'target' => 'name_of_target_frame'
|
346
|
);
|
347
|
$form['#prefix'] = '<div class="my-form-class">';
|
348
|
$form['#suffix'] = '</div>';
|
349
|
*/
|
350
|
|
351
|
//returning value
|
352
|
return $form;
|
353
|
}
|
354
|
|
355
|
/**
|
356
|
* Show whole synonymy for the accepted taxon. Synonymy list is headed by the complete scientific name
|
357
|
* of the accepted taxon with nomenclatural reference.
|
358
|
*
|
359
|
*/
|
360
|
function theme_cdm_taxon_page_synonymy($taxon, $addAcceptedTaxon){
|
361
|
|
362
|
RenderHints::pushToRenderStack('taxon_page_synonymy');
|
363
|
$synomymie = cdm_ws_get(CDM_WS_PORTAL_TAXON_SYNONYMY, $taxon->uuid);
|
364
|
$skip = array(UUID_BASIONYM);
|
365
|
|
366
|
//render full accepted taxon
|
367
|
if($addAcceptedTaxon){
|
368
|
if(isset($taxon->name->nomenclaturalReference)){
|
369
|
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
|
370
|
}
|
371
|
$out .= theme('cdm_taxonName', $taxon->name, null, $referenceUri);
|
372
|
|
373
|
$special_annotations_array = array();
|
374
|
$special_annotations_array[] = $taxon->name;
|
375
|
$special_annotations_array[] = $taxon;
|
376
|
$out .= theme('cdm_annotations_as_footnotekeys',
|
377
|
$special_annotations_array,
|
378
|
RenderHints::getRenderPath() . '-annotations');
|
379
|
RenderHints::setFootnoteListKey(RenderHints::getRenderPath() . '-annotations');
|
380
|
}
|
381
|
//render accepted taxon homotypic synonymy groups or type desygnations
|
382
|
//if(!isset($synomymie->homotypicSynonymsByHomotypicGroup[0])){
|
383
|
//if($addAcceptedTaxon && !isset($synomymie->homotypicSynonymsByHomotypicGroup[0])){
|
384
|
// display the type information for the added taxon
|
385
|
$typeDesignations = cdm_ws_get(CDM_WS_PORTAL_TAXON_NAMETYPEDESIGNATIONS, $taxon->uuid);
|
386
|
if($typeDesignations){
|
387
|
$out .= theme('cdm_typedesignations', $typeDesignations);
|
388
|
}
|
389
|
//}
|
390
|
if($synomymie->homotypicSynonymsByHomotypicGroup){
|
391
|
// render the homotypicSynonymyGroup including the type information
|
392
|
$out .= theme('cdm_homotypicSynonymyGroup', $synomymie->homotypicSynonymsByHomotypicGroup);
|
393
|
}
|
394
|
//render accepted taxon heterotypic synonymy groups
|
395
|
if($synomymie->heterotypicSynonymyGroups) {
|
396
|
foreach($synomymie->heterotypicSynonymyGroups as $homotypicalGroup){
|
397
|
$out .= theme('cdm_heterotypicSynonymyGroup', $homotypicalGroup);
|
398
|
}
|
399
|
}
|
400
|
//render taxon relationships
|
401
|
if(variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT)){
|
402
|
$taxonRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS, $taxon->uuid);
|
403
|
$out .= theme('cdm_taxonRelationships', $taxonRelationships);
|
404
|
}
|
405
|
//render name relationships
|
406
|
$name_rels_to_show = variable_get('name_relationships_to_show', null);
|
407
|
$skip = array();
|
408
|
if($name_rels_to_show){
|
409
|
foreach ($name_rels_to_show as $key => $value){
|
410
|
if ($value === 0){
|
411
|
$skip[] = $key;
|
412
|
}
|
413
|
}
|
414
|
if (sizeof($name_rels_to_show) != sizeof($skip)){
|
415
|
$nameRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_TO_NAMERELATIONS, $taxon->uuid);
|
416
|
$out .= theme('cdm_nameRelationships', $nameRelationships, $skip);
|
417
|
}
|
418
|
}
|
419
|
/*
|
420
|
if(variable_get(CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_DEFAULT)){
|
421
|
$nameRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_TO_NAMERELATIONS, $taxon->uuid);
|
422
|
// TODO is it correct to skip relationsFromThisName since all relationships are to be understood as 'is .... of'
|
423
|
if(variable_get('cdm_dataportal_name_relations_skiptype_basionym', 1)){
|
424
|
$skip = array(UUID_BASIONYM);
|
425
|
}
|
426
|
$out .= theme('cdm_nameRelationships', $nameRelationships, $skip);
|
427
|
}
|
428
|
*/
|
429
|
RenderHints::popFromRenderStack();
|
430
|
|
431
|
return $out;
|
432
|
}
|
433
|
|
434
|
|
435
|
/**
|
436
|
* TODO Implementation of Hook taxon_image_gallery()
|
437
|
*
|
438
|
* @param unknown_type $taxon
|
439
|
* @param unknown_type $media
|
440
|
* @return unknown_type
|
441
|
*/
|
442
|
function taxon_image_gallery_default($taxon, $media){
|
443
|
|
444
|
$hasImages = isset($media[0]);
|
445
|
|
446
|
if($hasImages){
|
447
|
//
|
448
|
$maxExtend = 150;
|
449
|
$cols = 3;
|
450
|
$maxRows = false;
|
451
|
$alternativeMediaUri = null;
|
452
|
$captionElements = array('title', 'rights', '#uri'=>t('open Image'));
|
453
|
$gallery_name = $taxon->uuid;
|
454
|
$mediaLinkType = 'LIGHTBOX';
|
455
|
|
456
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_MEDIA_GALLERY_NAME);
|
457
|
|
458
|
$out = '<div class="image-gallerie">';
|
459
|
$out .= theme('cdm_media_gallerie', $media,
|
460
|
$gallery_name,
|
461
|
$gallery_settings['cdm_dataportal_media_maxextend'],
|
462
|
$gallery_settings['cdm_dataportal_media_cols'],
|
463
|
0, // ignore maxrows settings
|
464
|
$captionElements,
|
465
|
$mediaLinkType,
|
466
|
null);
|
467
|
$out .= '</div>';
|
468
|
}else{
|
469
|
$out = 'No images available.';
|
470
|
|
471
|
}
|
472
|
return $out;
|
473
|
|
474
|
}
|
475
|
|
476
|
/**
|
477
|
* TODO Implementation of Hook taxon_image_gallery()
|
478
|
*
|
479
|
* @param unknown_type $taxon
|
480
|
* @param unknown_type $media
|
481
|
* @return unknown_type
|
482
|
*/
|
483
|
function taxon_image_gallery_fsi($taxon, $media){
|
484
|
|
485
|
$flashLink = isset($media[0]);
|
486
|
|
487
|
if($flashLink){
|
488
|
|
489
|
$taggedName = $taxon->name->taggedName;
|
490
|
|
491
|
$nameArray = array();
|
492
|
foreach($taggedName as $taggedText){
|
493
|
if($taggedText->type == 'name'){
|
494
|
$nameArray[] = $taggedText->text;
|
495
|
}
|
496
|
}
|
497
|
|
498
|
$query = join("%5F", $nameArray) . '%20AND%20EditWP6%20AND%20jpg';
|
499
|
|
500
|
$out = '
|
501
|
|
502
|
<script type="text/javascript" src="http://media.bgbm.org/erez/js/fsiwriter.js"></script>
|
503
|
|
504
|
<script type="text/javascript">
|
505
|
<!--
|
506
|
writeFlashCode( "http://media.bgbm.org/erez/fsi/fsi.swf?&cfg=showcase_presets/showcase_info.fsi&effects=%26quality%3D95&showcase_query='.$query.'&skin=silver&showcase_labeltextheight=50&textbox_textfrom=IPTC_WP6&textbox_height=50¶m_backgroundcolor=454343&publishwmode=opaque&showcase_hscroll=true&showcase_basecolor=454343&plugins=textbox,fullscreen",
|
507
|
"http://media.bgbm.org/erez/erez?src=erez-private/flashrequired.svg&tmp=Large&quality=97&width=620&height=400",
|
508
|
"width=620;height=400;bgcolor=454343;wmode=opaque");
|
509
|
// -->
|
510
|
</script>
|
511
|
<noscript>
|
512
|
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,65,0" width="470" height="400">
|
513
|
<param name="movie" value="http://media.bgbm.org/erez/fsi/fsi.swf?&cfg=showcase_presets/showcase_info.fsi&effects=%26quality%3D95&showcase_query='.$query.'&skin=silver&showcase_labeltextheight=50&textbox_textfrom=IPTC_WP6&textbox_height=50¶m_backgroundcolor=454343&publishwmode=opaque&showcase_hscroll=true&showcase_basecolor=454343plugins=textbox,fullscreen"/>
|
514
|
<param name="bgcolor" value="454343" />
|
515
|
<param name="wmode" value="opaque" />
|
516
|
<param name="allowscriptaccess" value="always" />
|
517
|
<param name="allowfullscreen" value="true" />
|
518
|
<param name="quality" value="high" />
|
519
|
<embed src="http://media.bgbm.org/erez/fsi/fsi.swf?&cfg=showcase_presets/showcase_info.fsi&effects=%26quality%3D95&showcase_query='.$query.'&skin=silver&showcase_labeltextheight=50&textbox_textfrom=IPTC_WP6&textbox_height=50¶m_backgroundcolor=454343&publishwmode=opaque&showcase_hscroll=true&showcase_basecolor=454343plugins=PrintSave,textbox,fullscreen"
|
520
|
width="620"
|
521
|
height="400"
|
522
|
bgcolor="454343"
|
523
|
wmode="opaque"
|
524
|
allowscriptaccess="always"
|
525
|
allowfullscreen="true"
|
526
|
quality="high"
|
527
|
type="application/x-shockwave-flash"
|
528
|
pluginspage="http://www.adobe.com/go/getflashplayer">
|
529
|
</embed>
|
530
|
</object>
|
531
|
|
532
|
</noscript>';
|
533
|
|
534
|
}else{
|
535
|
$out = 'No images available.';
|
536
|
|
537
|
}
|
538
|
return $out;
|
539
|
|
540
|
}
|
541
|
/**
|
542
|
* Show a reference in it's atomized form
|
543
|
*/
|
544
|
function theme_cdm_reference_page($referenceTO){
|
545
|
|
546
|
/*
|
547
|
if($referenceTO->titleCache) {
|
548
|
drupal_set_title($referenceTO->titleCache);
|
549
|
} else {
|
550
|
drupal_set_title($referenceTO->fullCitation);
|
551
|
}
|
552
|
*/
|
553
|
|
554
|
$field_order = array(
|
555
|
"title",
|
556
|
//"titleCache",
|
557
|
//"citation",
|
558
|
"authorTeam",
|
559
|
"editor",
|
560
|
"publisher",
|
561
|
"placePublished",
|
562
|
"datePublished",
|
563
|
"year",
|
564
|
"edition", // class Book
|
565
|
"volume", // class Article
|
566
|
"seriesPart",
|
567
|
"inReference",
|
568
|
//"inJournal", // class Article
|
569
|
//"inBook", // class BookSection
|
570
|
"nomRefBase", // class BookSection, Book, Article
|
571
|
//"inProceedings", // class InProceedings
|
572
|
"pages", // class Article
|
573
|
"series", // class Article, PrintSeries
|
574
|
"school", // class Thesis
|
575
|
"institution", // class Report
|
576
|
"organization", // class Proceedings
|
577
|
"nextVersion",
|
578
|
"previousVersion",
|
579
|
"isbn", // class Book
|
580
|
"issn", // class Journal
|
581
|
"uri",
|
582
|
);
|
583
|
/*
|
584
|
$table_rows = array();
|
585
|
foreach($field_order as $fieldname){
|
586
|
|
587
|
if(isset($referenceTO->$fieldname)){
|
588
|
|
589
|
if($fieldname == "datePublished") {
|
590
|
$partial = $referenceTO->$fieldname;
|
591
|
$datePublished = '';
|
592
|
if($partial->start){
|
593
|
//var_dump ($partial->start);
|
594
|
$datePublishedYear = substr($partial->start, 0, 4);
|
595
|
$datePublishedMonth = substr($partial->start, 5, 2);
|
596
|
|
597
|
if (!(preg_match('#[0-9]#',$datePublishedMonth))){
|
598
|
$datePublishedMonth = '00';
|
599
|
}
|
600
|
|
601
|
$datePublishedDay = substr($partial->start, 7, 2);
|
602
|
if (!(preg_match('#[0-9]#',$datePublishedDay))){
|
603
|
$datePublishedDay = '00';
|
604
|
}
|
605
|
$datePublished = $datePublishedYear.'-'.$datePublishedMonth.'-'.$datePublishedDay;
|
606
|
}
|
607
|
if($partial->end){
|
608
|
$datePublished = (strlen($datePublished) > 0 ? ' '.t('to').' ' : '').substr($partial->end, 0, 4).'-'.substr($partial->end, 4, 2).'-'.substr($partial->end, 6, 2);
|
609
|
}
|
610
|
$table_rows[] = array(t(ucfirst(strtolower($fieldname))), $datePublished);
|
611
|
//$datePublished = array(t(ucfirst(strtolower($fieldname))), $datePublished);
|
612
|
} else if(is_object($referenceTO->$fieldname)){
|
613
|
if ($fieldname == "authorTeam"){
|
614
|
$dump = $referenceTO->$fieldname;
|
615
|
$teammembers = "teamMembers";
|
616
|
$team = $dump->$teammembers;
|
617
|
$nameArray = array();
|
618
|
|
619
|
foreach($team as $member){
|
620
|
if (strlen($member->lastname)> 0){
|
621
|
$nname = $member->lastname;
|
622
|
$name = $nname;
|
623
|
if (strlen($member->firstname)> 0){
|
624
|
$vname = $member->firstname;
|
625
|
$name =$vname." ". $nname;
|
626
|
}
|
627
|
$nameArray[] =$name;
|
628
|
}else{
|
629
|
if (strlen($member->titleCache)> 0){
|
630
|
$nameArray[] = $member->titleCache;
|
631
|
}
|
632
|
}
|
633
|
}
|
634
|
$names = join($nameArray, ", ");
|
635
|
}else if ($fieldname == "inReference"){
|
636
|
$type = $referenceTO ->$fieldname-> type;
|
637
|
$names = $referenceTO-> $fieldname-> titleCache;
|
638
|
switch ($type) {
|
639
|
case "Book":
|
640
|
$fieldname = "in book";
|
641
|
break;
|
642
|
case "Journal":
|
643
|
$fieldname = "in journal";
|
644
|
break;
|
645
|
case "Proceedings":
|
646
|
$fieldname = "in proceedings";
|
647
|
break;
|
648
|
}
|
649
|
|
650
|
}else{
|
651
|
$names = $referenceTO->$fieldname-> titleCache;
|
652
|
}
|
653
|
$table_rows[] = array(t(ucfirst(strtolower($fieldname))), $names);
|
654
|
//$name = array(t(ucfirst(strtolower($fieldname))), $names);
|
655
|
|
656
|
} else {
|
657
|
$table_rows[] = array(t(ucfirst(strtolower($fieldname))), $referenceTO->$fieldname);
|
658
|
//$name = array(t(ucfirst(strtolower($fieldname))), $referenceTO->$fieldname);
|
659
|
}
|
660
|
}
|
661
|
}
|
662
|
*/
|
663
|
|
664
|
//select the type of the reference and find the in Reference attribute
|
665
|
|
666
|
$referenceData = array(
|
667
|
"title" => NULL,
|
668
|
//"titleCache",
|
669
|
//"citation",
|
670
|
"authorTeam" => NULL,
|
671
|
"editor" => NULL,
|
672
|
"publisher" => NULL,
|
673
|
"placePublished" => NULL,
|
674
|
"datePublished" => NULL,
|
675
|
"year" => NULL,
|
676
|
"edition" => NULL, // class Book
|
677
|
"volume" => NULL, // class Article
|
678
|
"seriesPart" => NULL,
|
679
|
"inReference" => NULL,
|
680
|
//"inJournal", // class Article
|
681
|
//"inBook", // class BookSection
|
682
|
"nomRefBase" => NULL, // class BookSection, Book, Article
|
683
|
//"inProceedings", // class InProceedings
|
684
|
"pages" => NULL, // class Article
|
685
|
"series" => NULL, // class Article, PrintSeries
|
686
|
"school" => NULL, // class Thesis
|
687
|
"institution" => NULL, // class Report
|
688
|
"organization" => NULL, // class Proceedings
|
689
|
"nextVersion" => NULL,
|
690
|
"previousVersion" => NULL,
|
691
|
"isbn" => NULL, // class Book
|
692
|
"issn" => NULL, // class Journal
|
693
|
"uri" => NULL,
|
694
|
);
|
695
|
|
696
|
foreach($field_order as $fieldname){
|
697
|
|
698
|
if(isset($referenceTO->$fieldname)){
|
699
|
switch($fieldname){
|
700
|
case "datePublished":
|
701
|
$partial = $referenceTO->$fieldname;
|
702
|
$datePublished = '';
|
703
|
if($partial->start){
|
704
|
$datePublishedYear = substr($partial->start, 0, 4);
|
705
|
$datePublishedMonth = substr($partial->start, 5, 2);
|
706
|
if (!(preg_match('#[0-9]#',$datePublishedMonth))){
|
707
|
$datePublishedMonth = '00';
|
708
|
}
|
709
|
$datePublishedDay = substr($partial->start, 7, 2);
|
710
|
if (!(preg_match('#[0-9]#',$datePublishedDay))){
|
711
|
$datePublishedDay = '00';
|
712
|
}
|
713
|
$datePublished = $datePublishedYear.'-'.$datePublishedMonth.'-'.$datePublishedDay;
|
714
|
}
|
715
|
if($partial->end){
|
716
|
$datePublished = (strlen($datePublished) > 0 ? ' '.t('to').' ' : '').substr($partial->end, 0, 4).'-'.substr($partial->end, 4, 2).'-'.substr($partial->end, 6, 2);
|
717
|
}
|
718
|
|
719
|
$referenceData[$fieldname] = $datePublishedYear;
|
720
|
break;
|
721
|
|
722
|
default:
|
723
|
if(is_object($referenceTO->$fieldname)){
|
724
|
if ($fieldname == "authorTeam"){
|
725
|
$dump = $referenceTO->$fieldname;
|
726
|
$teammembers = "teamMembers";
|
727
|
$team = $dump->$teammembers;
|
728
|
$nameArray = array();
|
729
|
|
730
|
foreach($team as $member){
|
731
|
if (strlen($member->lastname)> 0){
|
732
|
$nname = $member->lastname;
|
733
|
$name = $nname;
|
734
|
if (strlen($member->firstname)> 0){
|
735
|
$vname = $member->firstname;
|
736
|
$name =$vname." ". $nname;
|
737
|
}
|
738
|
$nameArray[] =$name;
|
739
|
}else{
|
740
|
if (strlen($member->titleCache)> 0){
|
741
|
$nameArray[] = $member->titleCache;
|
742
|
}
|
743
|
}
|
744
|
}
|
745
|
$names = join($nameArray, ", ");
|
746
|
$referenceData[$fieldname] = $names;
|
747
|
}else if ($fieldname == "inReference"){
|
748
|
$names = $referenceTO->$fieldname->titleCache;
|
749
|
$referenceData[$fieldname] = $names;
|
750
|
}else{
|
751
|
$names = $referenceTO->$fieldname->titleCache;
|
752
|
$referenceData[$fieldname] = $names;
|
753
|
}
|
754
|
}else{
|
755
|
$referenceData[$fieldname] = $referenceTO->$fieldname;
|
756
|
}
|
757
|
|
758
|
}
|
759
|
}
|
760
|
}
|
761
|
$author_team = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $referenceTO->uuid);
|
762
|
//return "" . ((strlen($referenceData["authorTeam"])>0) ? ($referenceData["authorTeam"] . '. ') : '')
|
763
|
return "" . ((strlen($author_team->titleCache)>0) ? ($author_team->titleCache . '. ') : '')
|
764
|
. ((strlen($referenceData["datePublished"])>0) ? ($referenceData["datePublished"] . '. ') : '')
|
765
|
. ((strlen($referenceData["title"])>0) ? ($referenceData["title"] . '. ') : "")
|
766
|
. ((strlen($referenceData["placePublished"])>0) ? ($referenceData["placePublished"] . '. ') : '')
|
767
|
. ((strlen($referenceData["editor"])>0) ? ($referenceData["editor"] . '. ') : '')
|
768
|
. ((strlen($referenceData["publisher"])>0) ? ($referenceData["publisher"] . '. ') : '')
|
769
|
. ((strlen($referenceData["inReference"])>0) ? ($referenceData["inReference"] . '. ') : '')
|
770
|
. ((strlen($referenceData["series"])>0) ? ($referenceData["series"] . '. ') : '')
|
771
|
. ((strlen($referenceData["volume"])>0) ? ($referenceData["volume"] . '. ') : '')
|
772
|
. ((strlen($referenceData["pages"])>0) ? ($referenceData["pages"] . '. ') : '')
|
773
|
. ((strlen($referenceData["isbn"])>0) ? ($referenceData["isbn"] . '. ') : '')
|
774
|
. ((strlen($referenceData["issn"])>0) ? ($referenceData["issn"] . '. ') : '')
|
775
|
. ((strlen($referenceData["uri"])>0) ? ($referenceData["uri"] . '. ') : '');
|
776
|
|
777
|
}
|
778
|
|
779
|
|
780
|
function theme_cdm_media_page($media, $mediarepresentation_uuid = false, $partId = false){
|
781
|
$out = '';
|
782
|
// determine which reprresentation and which part to show
|
783
|
$representationIdx = 0;
|
784
|
if($mediarepresentation_uuid){
|
785
|
$i = 0;
|
786
|
foreach($media->representations as $representation) {
|
787
|
if($representation->uuid == $mediarepresentation_uuid){
|
788
|
$representationIdx = $i;
|
789
|
}
|
790
|
$i++;
|
791
|
}
|
792
|
} else {
|
793
|
$mediarepresentation_uuid = $media->representations[0]->uuid;
|
794
|
}
|
795
|
|
796
|
$partIdx = 0;
|
797
|
if(!is_numeric($partId)){
|
798
|
// assuming it is an uuid
|
799
|
$i = 0;
|
800
|
foreach($media->representations[$representationIdx]->parts as $part) {
|
801
|
if($part->uuid == $partId){
|
802
|
$partIdx = $i;
|
803
|
}
|
804
|
$i++;
|
805
|
}
|
806
|
} else {
|
807
|
// assuming it is an index
|
808
|
$partIdx = $partId;
|
809
|
}
|
810
|
|
811
|
$media_metadata = cdm_read_media_metadata($media);
|
812
|
//$title = $media->titleCache;
|
813
|
$title = $media_metadata['title'];
|
814
|
|
815
|
$imageMaxExtend = variable_get('image-page-maxextend', 400);
|
816
|
|
817
|
if(!$title){
|
818
|
$title = 'Media '.$media->uuid.'';
|
819
|
}
|
820
|
|
821
|
drupal_set_title($title);
|
822
|
|
823
|
|
824
|
$out .= '<div class="media">';
|
825
|
|
826
|
//$out .= '<div class="viewer">';
|
827
|
$out .= theme(cdm_back_to_image_gallery_button);
|
828
|
$out .= '<div class="viewer">';
|
829
|
//$out .= theme('cdm_media_gallerie_image', $representation->parts[$partIdx], $imageMaxExtend);
|
830
|
$out .= theme('cdm_openlayers_image', $media->representations[$representationIdx]->parts[$partIdx], $imageMaxExtend);
|
831
|
$out .= '</div>';
|
832
|
|
833
|
// general media metadata
|
834
|
//$media_metadata = cdm_ws_get(CDM_WS_MEDIA_METADATA, array($media->uuid));
|
835
|
//vardump("PRINTING MEDIA METADATA");
|
836
|
//vardump($media_metadata);
|
837
|
//vardump("PRINTING MEDIA");
|
838
|
//vardump($media);
|
839
|
$metadataToPrint = theme('cdm_media_caption', $media);
|
840
|
$out .= $metadataToPrint;
|
841
|
|
842
|
|
843
|
//tabs for the different representations
|
844
|
//ul.secondary
|
845
|
$out .= '<ul class="primary">';
|
846
|
foreach($media->representations as $representation){
|
847
|
$out .= '<li>'.l($media->representations[$representationIdx]->mimeType, path_to_media($media->uuid, $mediarepresentation_uuid, $partIdx)).'</li>';
|
848
|
}
|
849
|
$out .= '</ul>';
|
850
|
|
851
|
// representation(-part) specific metadata
|
852
|
$thumbnailMaxExtend = 100;
|
853
|
$out .= '<table>';
|
854
|
//$out .= '<tr><th colspan="3">'.t('MimeType').': '.$media->representations[$representationIdx]->mimeType.'</th></tr>';
|
855
|
$i = 0;
|
856
|
foreach($media->representations[$representationIdx]->parts as $part){
|
857
|
$out .= '<tr><th>'.t('Part').' '.($i + 1).'</th><td>';
|
858
|
switch($part->class){
|
859
|
case 'ImageFile': $out .= $part->width.' x '.$part->height.' - '.$part->size.'k'; break;
|
860
|
case 'AudioFile':
|
861
|
case 'MovieFile': $out .= t('Duration').': '.$part->duration.'s - '.$part->size.'k'; break;
|
862
|
default: $out .= $part->size.'k';
|
863
|
}
|
864
|
$out .= '</td><td><a href="'.url(path_to_media($media->uuid, $mediarepresentation_uuid, $i)).'">'.theme('cdm_media_gallerie_image', $part, $thumbnailMaxExtend, true);'</a></td><tr>';
|
865
|
$i++;
|
866
|
}
|
867
|
$out .= '</table>';
|
868
|
$out .= '</div>';
|
869
|
|
870
|
return $out;
|
871
|
}
|
872
|
|
873
|
/**
|
874
|
* Allows theming of the taxon page tabs
|
875
|
*
|
876
|
* @param $tabname
|
877
|
* @return unknown_type
|
878
|
*/
|
879
|
function theme_cdm_taxonpage_tab($tabname){
|
880
|
//TODO replace by using translations or theme the menue tabs itself instead?
|
881
|
switch($tabname){
|
882
|
default: return t($tabname);
|
883
|
}
|
884
|
}
|
885
|
|