Project

General

Profile

Download (31 KB) Statistics
| Branch: | Tag: | Revision:
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, $uuid){
20
	RenderHints::pushToRenderStack('taxon_page_title');
21
	if(isset($taxon->name->nomenclaturalReference)){
22
		$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
23
	}
24
	$out = theme('cdm_taxonName', $taxon->name, null, $referenceUri, false);
25
	RenderHints::popFromRenderStack();
26

    
27
	return '<span class="'.$taxon->class.'">'.$out.'</span>';
28
}
29

    
30
/**
31
 * Default title for a name page
32
 * @param $taxon_name The taxon name object
33
 * @return the formatted name title
34
 */
35
function theme_cdm_name_page_title($taxon_name){
36
	RenderHints::pushToRenderStack('taxon_page_title');
37
	if(isset($taxon_name->nomenclaturalReference)){
38
		$referenceUri = url(path_to_reference($taxon_name->nomenclaturalReference->uuid));
39
	}
40

    
41
	$out = '<span class="'.$taxon_name->class.'">'.theme('cdm_taxonName', $taxon_name, null, $referenceUri, false).'</span>';
42
	RenderHints::popFromRenderStack();
43
	return $out;
44
}
45

    
46
/**
47
 * A wrapper function that groups available information to show by default, when
48
 * a taxon page is requested by the browser.
49
 * Individual themeing has to decide what this page should include (see methods beneath)
50
 * and what information should go into tabs or should not be shown at all.
51
 *
52
 * It is headed by the name of the accepted taxon without author and reference.
53
 * @param $taxonTO the taxon object
54
 * @param $page_part name of the part to display,
55
 *         valid values are: 'description', 'images', 'synonymy', 'all'
56
 */
57
function theme_cdm_taxon_page_general($taxon, $page_part = 'description') {
58

    
59
	global $theme;
60

    
61
	$page_part = variable_get('cdm_dataportal_taxonpage_tabs', 1) ? $page_part : 'all';
62
	$hideTabs = array();
63

    
64

    
65
	// get images
66
	$prefMimeTypeRegex = 'image:.*';
67
	$prefMediaQuality = '*';
68
	//$media =  cdm_ws_get(CDM_WS_PORTAL_TAXONOMY_MEDIA, array(variable_get('cdm_taxonomictree_uuid', false),$taxon->uuid));
69

    
70

    
71
	$selectShowMedia = variable_get('cdm_dataportal_show_media', 0);
72
	if ($selectShowMedia == 0){
73
		$media = cdm_ws_get(CDM_WS_PORTAL_TAXON_MEDIA, array($taxon->uuid, $prefMimeTypeRegex, $prefMediaQuality));
74
	}else{
75
		$media = cdm_ws_get(CDM_WS_PORTAL_TAXON_SUBTREE_MEDIA, array($taxon->uuid, $prefMimeTypeRegex, $prefMediaQuality));
76
	}
77
	/*
78
	 if(!isset($mediaList[0])) {
79
	 $hideTabs[] = theme('cdm_taxonpage_tab', 'Images');
80
	 }
81
	 */
82

    
83
	if(!isset($media[0])) {
84
		$hideTabs[] = theme('cdm_taxonpage_tab', 'Images');
85
	}
86

    
87
	$specimensOrObersvations = cdm_ws_get(CDM_WS_TAXON, array($taxon->uuid, 'specimensOrObersvations') );
88
	$specimensOrObersvationsCount = is_array($specimensOrObersvations) ? count($specimensOrObersvations) : 0;
89
	if($specimensOrObersvationsCount == 0) {
90
		$hideTabs[] = theme('cdm_taxonpage_tab', 'Specimens');
91
	}
92

    
93
	// hideImage flag depending on administative preset
94
	$hideImages = false;
95
	if(variable_get('image_hide_rank', '0') != '0'){
96
		$rankCompare = rank_compare($taxon->name->rank->uuid, variable_get('image_hide_rank', '-99'));
97
		$hideImages =  ($rankCompare > -1);
98
	}
99
	// $hideTabs[] = theme('cdm_taxonpage_tab', 'General');
100
	// $hideTabs[] = theme('cdm_taxonpage_tab', 'Synonymy')
101

    
102
	// hide tabs
103
	$tabhide_js = '';
104
	foreach($hideTabs as $tabText) {
105
		$tabhide_js .= "$('.tabs.primary').children('li').children('a:contains(\"$tabText\")').hide();\n";
106
	}
107
	drupal_add_js("
108
  $(document).ready(function(){
109
  $tabhide_js
110
    });", 'inline');
111

    
112
  $out = '';
113
  $out .= theme('cdm_back_to_search_result_button');
114
  if(variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR)){
115
  	$out .= theme('cdm_acceptedFor', 'page_general');
116
  }
117

    
118
  // --- DESCRIPTION --- //
119
  if($page_part == 'description' || $page_part == 'all'){
120

    
121
  	$featureTree = cdm_ws_get(CDM_WS_FEATURETREE, variable_get(CDM_DATAPORTAL_DEFAULT_FEATURETREE_UUID, UUID_DEFAULT_FEATURETREE));
122
  	$taxonDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxon->uuid); //retrieve all description for the taxon
123

    
124
  	$nonStructuredDescriptions = array();
125
  	if($taxonDescriptions != null){
126
  		foreach ($taxonDescriptions as $taxonDescription) {
127
  			// check if structured description
128
  			$hasStructuredData = cdm_ws_get(CDM_WS_DESCRIPTION_HAS_STRUCTRURED_DATA, $taxonDescription->uuid);
129
  			$hasStructuredData = $hasStructuredData->Boolean == 'true';
130
  			if($hasStructuredData){
131
  				$structured_description_featuretree_uuid = variable_get(CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID, false);
132
  				$naturallanguage_textData = cdm_ws_get(CDM_WS_DESCRIPTION_NATURALLANGUAGE_DESCRIPTION, array($taxonDescription->uuid, $structured_description_featuretree_uuid));
133
  				if(!$naturallanguage_textData){
134
  					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/taxon'), 'warning');
135
  				}
136
  				$taxonDescription->elements = null;
137
  				$taxonDescription->elements = array($naturallanguage_textData);
138
  			}
139
  			$nonStructuredDescriptions[] = $taxonDescription;
140
  		}
141
  		$taxonDescriptions = null; // release memory
142
  	}
143

    
144
  	$mergedTrees = cdm_ws_descriptions_by_featuretree($featureTree, $nonStructuredDescriptions, variable_get('cdm_dataportal_descriptions_separated', FALSE));
145

    
146
  	$out .= '<div id="general">';
147
  	$out .= theme('cdm_taxon_page_description', $taxon, $mergedTrees, $media, $hideImages);
148
  	$out .= '</div>';
149
  }
150

    
151
  // --- IMAGES --- //
152
  if(!$hideImages && $page_part == 'images' || $page_part == 'all'){
153
  	$out .= '<div id="images">';
154
  	if($page_part == 'all'){
155
  		$out .= '<h2>'.t('Images').'</h2>';
156
  	}
157

    
158
  	// get the image gallery as configured by the admin
159
  	$taxon_image_gallery = call_user_func_array( 'taxon_image_gallery_' . variable_get('image_gallery_viewer', 'default'),
160
  	array($taxon, $media));
161
  	$out .= $taxon_image_gallery;
162

    
163
  	$out .= '</div>';
164

    
165
  	if($theme == 'garland_cichorieae'){
166
  		$out .= theme('cdm_taxon_page_images_cichorieae_copyright');
167
  	}
168
  }
169

    
170
  // --- SYNONYMY --- //
171
  if($page_part == 'synonymy' || $page_part == 'all'){
172
  	$out .= '<div id="synonymy">';
173
  	if($page_part == 'all'){
174
  		$out .= '<h2>'.t('Synonymy').'</h2>';
175
  	}
176
  	$addAcceptedTaxon = variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE);
177
  	$out .= theme('cdm_taxon_page_synonymy', $taxon, $addAcceptedTaxon);
178

    
179
  	$out .= '</div>';
180
  }
181

    
182
  // --- SPECIMENS --- //
183
  if($specimensOrObersvationsCount > 0 && ($page_part == 'specimens' || $page_part == 'all') ){
184
  	$out .= '<div id="specimens">';
185
  	if($page_part == 'all'){
186
  		$out .= '<h2>'.t('Specimens').'</h2>';
187
  	}
188
  	$out .= theme('cdm_taxon_page_specimens', $taxon);
189
  	$out .= '</div>';
190
  }
191
  return $out;
192
}
193

    
194

    
195
/**
196
 * Outputs all descriptive data and shows the preferred picture of the
197
 * accepted taxon.
198
 *
199
 */
200
function theme_cdm_taxon_page_description($taxon, $mergedTrees, $media = null, $hideImages = false){
201

    
202
	if( variable_get('cdm_dataportal_show_default_image', false) && !$hideImages){
203
		// preferred image
204
		// hardcoded for testing;
205
		$defaultRepresentationPart = false;
206
		$defaultRepresentationPart->width = 184;
207
		$defaultRepresentationPart->height = 144;
208
		$defaultRepresentationPart->uri = drupal_get_path('theme', 'palmweb_2').'/images/no_picture.png';
209

    
210
		// preferred image size 184px × 144
211
		$imageMaxExtend = 184;
212
		$out .= '<div class="preferredImage">'.$defaultRepresentationPart->uri.theme('cdm_preferredImage', $media, $defaultRepresentationPart, $imageMaxExtend).'</div>';
213
	}
214
	// description TOC
215
	$out .= theme('cdm_featureTreeTOCs', $mergedTrees);
216
	// description
217
	$out .= theme('cdm_featureTrees', $mergedTrees, $taxon);
218
	return $out;
219
}
220

    
221

    
222
function theme_cdm_taxon_page_specimens($taxon){
223

    
224
	RenderHints::pushToRenderStack('taxon_page_specimens');
225

    
226
	$specimensOrObersvations = cdm_ws_get(CDM_WS_TAXON, array($taxon->uuid, 'specimensOrObersvations') );
227

    
228
	//collect media (fieldObjectMedia, derivedUnitMedia) and add as fields
229
	 foreach($specimensOrObersvations as $specimensOrObersvation) {
230
			$specimensOrObersvation->_fieldObjectMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array($specimensOrObersvation->uuid, 'fieldObjectMedia') );
231
			$specimensOrObersvation->_derivedUnitMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array($specimensOrObersvation->uuid, 'derivedUnitMedia') );
232
			//	  	$derivedUnitFacde = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array($descriptionElement->associatedSpecimenOrObservation->uuid) );
233
			//	  	$descriptionElement->_titleCache = $derivedUnitFacde->titleCache;
234
	}
235

    
236
	if(variable_get('cdm_dataportal_map_openlayers', 1)){
237
		$occurrenceQuery = cdm_ws_get(CDM_WS_GEOSERVICE_OCCURRENCEMAP, $taxon->uuid);
238
		$occurrenceQuery = $occurrenceQuery->String;
239
		$out .= get_openlayers_map(variable_get('cdm_dataportal_geoservice_display_width', false), $occurrenceQuery);
240
	}
241

    
242

    
243

    
244
	if($specimensOrObersvations){
245
		$out_specimenList = '<table class="specimens">';
246
		$i = 1;
247
		foreach($specimensOrObersvations as $specimensOrObersvation) {
248
			$i++;
249

    
250
				$mediaList = array();
251
				if(is_array($specimensOrObersvation->_fieldObjectMedia)){
252
					$mediaList = array_merge($mediaList, $specimensOrObersvation->_fieldObjectMedia);
253
				}
254
				if(is_array($specimensOrObersvation->_derivedUnitMedia)){
255
					$mediaList = array_merge($mediaList, $specimensOrObersvation->_derivedUnitMedia);
256
				}
257

    
258
				// --- render the title cache
259
				$out_row = '<tr class="descriptionElement descriptionElement_IndividualsAssociation '.($i%2?'odd':'even').'">';
260
				if($specimensOrObersvation->class != 'FieldObservation'){
261
          $label_html = cdm_dynabox($specimensOrObersvation->titleCache,
262
            cdm_compose_url('portal/'.CDM_WS_DERIVEDUNIT_FACADE, array($specimensOrObersvation->uuid)),
263
            'cdm_derivedUnitFacade',
264
            'Click for details',
265
            array('div', 'div'));
266
				} else {
267
				  $label_html = $specimensOrObersvation->titleCache;
268
				}
269
				$out_row .= '<td>' . $label_html . '</td>';
270

    
271
				// --- render associated media
272
				if(count($mediaList) > 0){
273
					$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
274
					$gallery_name =  $specimensOrObersvation->uuid;
275
					$captionElements = array('#uri'=>t('open media'));
276
					$gallery_html = theme(
277
	  			    'cdm_media_gallerie',
278
					$mediaList,
279
					$gallery_name ,
280
					$gallery_settings['cdm_dataportal_media_maxextend'],
281
					$gallery_settings['cdm_dataportal_media_cols'],
282
					$gallery_settings['cdm_dataportal_media_maxRows'],
283
					$captionElements, 'LIGHTBOX', null, null);
284
				} else {
285
					$gallery_html = '';
286
				}
287
				$out_row .= '<td>'.$gallery_html.'</td></tr>';
288
				$out_specimenList .= $out_row;
289
		}
290
		$out_specimenList .= '</table>';
291
	}
292

    
293
	$out .= $out_specimenList;
294

    
295

    
296
	RenderHints::popFromRenderStack();
297
	return $out;
298
}
299

    
300
function specimens_search_form() {
301

    
302
	//form select options
303
	$form['specimens_search_options'] = array(
304
    '#type' => 'value',
305
    '#value' => array(t('No sort'), t('Name'), t('CatalogNumber'), t('Gallery'))
306
	);
307

    
308
	//the form
309
	$form['specimens_search'] = array(
310
    '#title' => t('Speciments sort'),
311
	  '#type' => 'fieldset',
312
	  '#description' => t('Select your sort criteria.'),
313
	  '#collapsible' => TRUE,
314
    '#collapsed' => FALSE
315
	);
316

    
317
	//criteria
318
	$form['specimens_search']['first_criteria'] = array(
319
    '#title' => t('First criteria'),
320
    '#type' => 'select',
321
    '#options' => $form['specimens_search_options']['#value']
322
	);
323
	$form['specimens_search']['second_criteria'] = array(
324
    '#title' => t('Second criteria'),
325
    '#type' => 'select',
326
    '#options' => $form['specimens_search_options']['#value']
327
	);
328
	$form['specimens_search']['third_criteria'] = array(
329
    '#title' => t('Third criteria'),
330
    '#type' => 'select',
331
    '#options' => $form['specimens_search_options']['#value']
332
	);
333

    
334
	//submit button
335
	$form['specimens_search']['submit'] = array(
336
    '#type' => 'submit',
337
    '#value' => t('Sort')
338
	);
339

    
340
	/*
341
	//from properties
342
	$form['#method'] = 'post';
343
	$form['#action'] = 'http://example.com/?q=foo/bar';
344
	$form['#attributes'] = array(
345
    'enctype' => 'multipart/form-data',
346
    'target' => 'name_of_target_frame'
347
	);
348
	$form['#prefix'] = '<div class="my-form-class">';
349
	$form['#suffix'] = '</div>';
350
	*/
351

    
352
	//returning value
353
	return $form;
354
}
355

    
356
/**
357
 * Show whole synonymy for the accepted taxon. Synonymy list is headed by the complete scientific name
358
 * of the accepted taxon with nomenclatural reference.
359
 *
360
 */
361
function theme_cdm_taxon_page_synonymy($taxon, $addAcceptedTaxon){
362

    
363
	RenderHints::pushToRenderStack('taxon_page_synonymy');
364
	$synomymie = cdm_ws_get(CDM_WS_PORTAL_TAXON_SYNONYMY, $taxon->uuid);
365
	$skip = array(UUID_BASIONYM);
366

    
367
	//render full accepted taxon
368
	if($addAcceptedTaxon){
369
		if(isset($taxon->name->nomenclaturalReference)){
370
			$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
371
		}
372
		$out .= theme('cdm_taxonName', $taxon->name, null, $referenceUri);
373

    
374
		$special_annotations_array = array();
375
		$special_annotations_array[] = $taxon->name;
376
		$special_annotations_array[] = $taxon;
377
		$out .= theme('cdm_annotations_as_footnotekeys',
378
					$special_annotations_array,
379
					RenderHints::getRenderPath() . '-annotations');
380
					RenderHints::setFootnoteListKey(RenderHints::getRenderPath() . '-annotations');
381
	}
382
	//render accepted taxon homotypic synonymy groups or type desygnations
383
	//if(!isset($synomymie->homotypicSynonymsByHomotypicGroup[0])){
384
		//if($addAcceptedTaxon && !isset($synomymie->homotypicSynonymsByHomotypicGroup[0])){
385
		// display the type information for the added taxon
386
		$typeDesignations = cdm_ws_get(CDM_WS_PORTAL_TAXON_NAMETYPEDESIGNATIONS, $taxon->uuid);
387
		if($typeDesignations){
388
			$out .= theme('cdm_typedesignations', $typeDesignations);
389
		}
390
	//}
391
	if($synomymie->homotypicSynonymsByHomotypicGroup){
392
		// render the homotypicSynonymyGroup including the type information
393
    $out .= theme('cdm_homotypicSynonymyGroup', $synomymie->homotypicSynonymsByHomotypicGroup);
394
	}
395
	/*
396
	else{
397
		$out .= '<ul class="homotypicSynonyms"></ul>';
398
	}
399
	*/
400
	//render accepted taxon heterotypic synonymy groups
401
	if($synomymie->heterotypicSynonymyGroups) {
402
		foreach($synomymie->heterotypicSynonymyGroups as $homotypicalGroup){
403
			$out .= theme('cdm_heterotypicSynonymyGroup', $homotypicalGroup);
404
		}
405
	}
406
	//render taxon relationships
407
	if(variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT)){
408
		$taxonRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS, $taxon->uuid);
409
		$out .= theme('cdm_taxonRelationships', $taxonRelationships);
410
	}
411
	//render name relationships
412
	$name_rels_to_show = variable_get('name_relationships_to_show', null);
413
	$skip = array();
414
	if($name_rels_to_show){
415
		foreach ($name_rels_to_show as $key => $value){
416
			if ($value === 0){
417
				$skip[] = $key;
418
			}
419
		}
420
		if (sizeof($name_rels_to_show) != sizeof($skip)){
421
			$nameRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_TO_NAMERELATIONS, $taxon->uuid);
422
			$out .= theme('cdm_nameRelationships', $nameRelationships, $skip);
423
		}
424
	}
425
	/*
426
	 if(variable_get(CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_DEFAULT)){
427
	 $nameRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_TO_NAMERELATIONS, $taxon->uuid);
428
	 // TODO is it correct to skip relationsFromThisName since all relationships are to be understood as 'is .... of'
429
	 if(variable_get('cdm_dataportal_name_relations_skiptype_basionym', 1)){
430
	 $skip = array(UUID_BASIONYM);
431
	 }
432
	 $out .= theme('cdm_nameRelationships', $nameRelationships, $skip);
433
	 }
434
	 */
435

    
436
	//render the annontations text for the accepted taxa
437
	if ($addAcceptedTaxon){
438
		$out .= theme('cdm_footnotes', RenderHints::getRenderPath() . '-annotations', 'li');
439
	}
440
	RenderHints::popFromRenderStack();
441

    
442
	return $out;
443
}
444

    
445

    
446
/**
447
 * TODO Implementation of Hook taxon_image_gallery()
448
 *
449
 * @param unknown_type $taxon
450
 * @param unknown_type $media
451
 * @return unknown_type
452
 */
453
function taxon_image_gallery_default($taxon, $media){
454

    
455
	$hasImages = isset($media[0]);
456

    
457
	if($hasImages){
458
		//
459
		$maxExtend = 150;
460
		$cols = 3;
461
		$maxRows = false;
462
		$alternativeMediaUri = null;
463
		$captionElements = array('title', 'rights', '#uri'=>t('open Image'));
464
		$gallery_name = $taxon->uuid;
465
		$mediaLinkType = 'LIGHTBOX';
466

    
467
		$gallery_settings = getGallerySettings(CDM_DATAPORTAL_MEDIA_GALLERY_NAME);
468

    
469
		$out = '<div class="image-gallerie">';
470
		$out .= theme('cdm_media_gallerie', 
471
		$media,
472
		$gallery_name,
473
		$gallery_settings['cdm_dataportal_media_maxextend'],
474
		$gallery_settings['cdm_dataportal_media_cols'],
475
		0, // ignore maxrows settings
476
		$captionElements,
477
		$mediaLinkType,
478
		null,
479
		null,
480
		$gallery_settings['cdm_dataportal_show_thumbnail_captions']);
481
		$out .= '</div>';
482
	}else{
483
		$out = 'No images available.';
484

    
485
	}
486
	return $out;
487

    
488
}
489

    
490
/**
491
 * TODO Implementation of Hook taxon_image_gallery()
492
 *
493
 * @param unknown_type $taxon
494
 * @param unknown_type $media
495
 * @return unknown_type
496
 */
497
function taxon_image_gallery_fsi($taxon, $media){
498

    
499
	$flashLink = isset($media[0]);
500

    
501
	if($flashLink){
502

    
503
		$taggedName = $taxon->name->taggedName;
504

    
505
		$nameArray = array();
506
		foreach($taggedName as $taggedText){
507
			if($taggedText->type == 'name'){
508
				$nameArray[] = $taggedText->text;
509
			}
510
		}
511

    
512
		$query = join("%5F", $nameArray) . '%20AND%20EditWP6%20AND%20jpg';
513

    
514
		$out = '
515

    
516
<script type="text/javascript" src="http://media.bgbm.org/erez/js/fsiwriter.js"></script>
517

    
518
<script type="text/javascript">
519
<!--
520
  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&param_backgroundcolor=454343&publishwmode=opaque&showcase_hscroll=true&showcase_basecolor=454343&plugins=textbox,fullscreen",
521
    "http://media.bgbm.org/erez/erez?src=erez-private/flashrequired.svg&tmp=Large&quality=97&width=620&height=400",
522
    "width=620;height=400;bgcolor=454343;wmode=opaque");
523
// -->
524
</script>
525
<noscript>
526
  <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">
527
    <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&param_backgroundcolor=454343&publishwmode=opaque&showcase_hscroll=true&showcase_basecolor=454343plugins=textbox,fullscreen"/>
528
    <param name="bgcolor" value="454343" />
529
    <param name="wmode" value="opaque" />
530
    <param name="allowscriptaccess" value="always" />
531
    <param name="allowfullscreen" value="true" />
532
    <param name="quality" value="high" />
533
    <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&param_backgroundcolor=454343&publishwmode=opaque&showcase_hscroll=true&showcase_basecolor=454343plugins=PrintSave,textbox,fullscreen"
534
      width="620"
535
      height="400"
536
      bgcolor="454343"
537
      wmode="opaque"
538
      allowscriptaccess="always"
539
      allowfullscreen="true"
540
      quality="high"
541
      type="application/x-shockwave-flash"
542
      pluginspage="http://www.adobe.com/go/getflashplayer">
543
    </embed>
544
  </object>
545

    
546
</noscript>';
547

    
548
	}else{
549
		$out = 'No images available.';
550

    
551
	}
552
	return $out;
553

    
554
}
555
/**
556
 * Show a reference in it's atomized form
557
 */
558
function theme_cdm_reference_page($referenceTO){
559

    
560
	/*
561
	 if($referenceTO->titleCache) {
562
		drupal_set_title($referenceTO->titleCache);
563
		} else {
564
		drupal_set_title($referenceTO->fullCitation);
565
		}
566
		*/
567

    
568
	$field_order = array(
569
    "title",
570
	//"titleCache",
571
	//"citation",
572
    "authorTeam",
573
    "editor",
574
    "publisher",
575
    "placePublished",
576
    "datePublished",
577
    "year",
578
    "edition",      // class Book
579
    "volume",       // class Article
580
    "seriesPart",
581
    "inReference",
582
	//"inJournal",     // class Article
583
	//"inBook",        // class BookSection
584
    "nomRefBase",    // class BookSection, Book, Article
585
	//"inProceedings", // class InProceedings
586
    "pages",         // class Article
587
    "series",        // class Article, PrintSeries
588
    "school",        // class Thesis
589
    "institution",   // class Report
590
    "organization",  // class Proceedings
591
    "nextVersion",
592
    "previousVersion",
593
    "isbn",         // class Book
594
    "issn",         // class Journal
595
    "uri",
596
	);
597
	/*
598
	 $table_rows = array();
599
	 foreach($field_order as $fieldname){
600

    
601
		if(isset($referenceTO->$fieldname)){
602

    
603
		if($fieldname == "datePublished") {
604
		$partial = $referenceTO->$fieldname;
605
		$datePublished = '';
606
		if($partial->start){
607
		//var_dump ($partial->start);
608
		$datePublishedYear = substr($partial->start, 0, 4);
609
		$datePublishedMonth = substr($partial->start, 5, 2);
610

    
611
		if (!(preg_match('#[0-9]#',$datePublishedMonth))){
612
		$datePublishedMonth = '00';
613
		}
614

    
615
		$datePublishedDay = substr($partial->start, 7, 2);
616
		if (!(preg_match('#[0-9]#',$datePublishedDay))){
617
		$datePublishedDay = '00';
618
		}
619
		$datePublished = $datePublishedYear.'-'.$datePublishedMonth.'-'.$datePublishedDay;
620
		}
621
		if($partial->end){
622
		$datePublished = (strlen($datePublished) > 0 ? ' '.t('to').' ' : '').substr($partial->end, 0, 4).'-'.substr($partial->end, 4, 2).'-'.substr($partial->end, 6, 2);
623
		}
624
		$table_rows[] = array(t(ucfirst(strtolower($fieldname))), $datePublished);
625
		//$datePublished = array(t(ucfirst(strtolower($fieldname))), $datePublished);
626
		} else if(is_object($referenceTO->$fieldname)){
627
		if ($fieldname == "authorTeam"){
628
		$dump = $referenceTO->$fieldname;
629
		$teammembers = "teamMembers";
630
		$team = $dump->$teammembers;
631
		$nameArray = array();
632

    
633
		foreach($team as $member){
634
		if (strlen($member->lastname)> 0){
635
		$nname = $member->lastname;
636
		$name = $nname;
637
		if (strlen($member->firstname)> 0){
638
		$vname = $member->firstname;
639
		$name =$vname." ". $nname;
640
		}
641
		$nameArray[] =$name;
642
		}else{
643
		if (strlen($member->titleCache)> 0){
644
		$nameArray[] = $member->titleCache;
645
		}
646
		}
647
		}
648
		$names = join($nameArray, ", ");
649
		}else if ($fieldname == "inReference"){
650
		$type = $referenceTO ->$fieldname-> type;
651
		$names = $referenceTO-> $fieldname-> titleCache;
652
		switch ($type) {
653
		case "Book":
654
		$fieldname = "in book";
655
		break;
656
		case "Journal":
657
		$fieldname = "in journal";
658
		break;
659
		case "Proceedings":
660
		$fieldname = "in proceedings";
661
		break;
662
		}
663

    
664
		}else{
665
		$names = $referenceTO->$fieldname-> titleCache;
666
		}
667
		$table_rows[] = array(t(ucfirst(strtolower($fieldname))), $names);
668
		//$name = array(t(ucfirst(strtolower($fieldname))), $names);
669

    
670
		} else {
671
		$table_rows[] = array(t(ucfirst(strtolower($fieldname))), $referenceTO->$fieldname);
672
		//$name = array(t(ucfirst(strtolower($fieldname))), $referenceTO->$fieldname);
673
		}
674
		}
675
		}
676
		*/
677

    
678
	//select the type of the reference and find the in Reference attribute
679

    
680
	$referenceData = array(
681
    "title" => NULL,
682
	//"titleCache",
683
	//"citation",
684
    "authorTeam" => NULL,
685
    "editor" => NULL,
686
    "publisher" => NULL,
687
    "placePublished" => NULL,
688
    "datePublished" => NULL,
689
    "year" => NULL,
690
    "edition" => NULL,      // class Book
691
    "volume" => NULL,       // class Article
692
    "seriesPart" => NULL,
693
    "inReference" => NULL,
694
	//"inJournal",     // class Article
695
	//"inBook",        // class BookSection
696
    "nomRefBase" => NULL,    // class BookSection, Book, Article
697
	//"inProceedings", // class InProceedings
698
    "pages" => NULL,         // class Article
699
    "series" => NULL,        // class Article, PrintSeries
700
    "school" => NULL,        // class Thesis
701
    "institution" => NULL,   // class Report
702
    "organization" => NULL,  // class Proceedings
703
    "nextVersion" => NULL,
704
    "previousVersion" => NULL,
705
    "isbn" => NULL,         // class Book
706
    "issn" => NULL,         // class Journal
707
    "uri" => NULL,
708
	);
709

    
710
	foreach($field_order as $fieldname){
711

    
712
		if(isset($referenceTO->$fieldname)){
713
			switch($fieldname){
714
				case "datePublished":
715
					$partial = $referenceTO->$fieldname;
716
					$datePublished = '';
717
					if($partial->start){
718
						$datePublishedYear = substr($partial->start, 0, 4);
719
						$datePublishedMonth = substr($partial->start, 5, 2);
720
						if (!(preg_match('#[0-9]#',$datePublishedMonth))){
721
							$datePublishedMonth = '00';
722
						}
723
						$datePublishedDay = substr($partial->start, 7, 2);
724
						if (!(preg_match('#[0-9]#',$datePublishedDay))){
725
							$datePublishedDay = '00';
726
						}
727
						$datePublished = $datePublishedYear.'-'.$datePublishedMonth.'-'.$datePublishedDay;
728
					}
729
					if($partial->end){
730
						$datePublished = (strlen($datePublished) > 0 ? ' '.t('to').' ' : '').substr($partial->end, 0, 4).'-'.substr($partial->end, 4, 2).'-'.substr($partial->end, 6, 2);
731
					}
732

    
733
					$referenceData[$fieldname] = $datePublishedYear;
734
					break;
735

    
736
				default:
737
					if(is_object($referenceTO->$fieldname)){
738
						if ($fieldname == "authorTeam"){
739
							$dump = $referenceTO->$fieldname;
740
							$teammembers = "teamMembers";
741
							$team = $dump->$teammembers;
742
							$nameArray = array();
743

    
744
							foreach($team as $member){
745
								if (strlen($member->lastname)> 0){
746
									$nname = $member->lastname;
747
									$name = $nname;
748
									if (strlen($member->firstname)> 0){
749
										$vname = $member->firstname;
750
										$name =$vname." ". $nname;
751
									}
752
									$nameArray[] =$name;
753
								}else{
754
									if (strlen($member->titleCache)> 0){
755
										$nameArray[] = $member->titleCache;
756
									}
757
								}
758
							}
759
							$names = join($nameArray, ", ");
760
							$referenceData[$fieldname] = $names;
761
						}else if ($fieldname == "inReference"){
762
							$names = $referenceTO->$fieldname->titleCache;
763
							$referenceData[$fieldname] = $names;
764
						}else{
765
							$names = $referenceTO->$fieldname->titleCache;
766
							$referenceData[$fieldname] = $names;
767
						}
768
					}else{
769
						$referenceData[$fieldname] = $referenceTO->$fieldname;
770
					}
771

    
772
			}
773
		}
774
	}
775
	$author_team =  cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $referenceTO->uuid);
776
	//return "" . ((strlen($referenceData["authorTeam"])>0) ? ($referenceData["authorTeam"] . '. ') : '')
777
	return "" . ((strlen($author_team->titleCache)>0) ? ($author_team->titleCache . '. ') : '')
778
	. ((strlen($referenceData["datePublished"])>0) ? ($referenceData["datePublished"] . '. ') : '')
779
	. ((strlen($referenceData["title"])>0) ? ($referenceData["title"] . '. ') : "")
780
	. ((strlen($referenceData["placePublished"])>0) ? ($referenceData["placePublished"] . '. ') : '')
781
	. ((strlen($referenceData["editor"])>0) ? ($referenceData["editor"] . '. ') : '')
782
	. ((strlen($referenceData["publisher"])>0) ? ($referenceData["publisher"] . '. ') : '')
783
	. ((strlen($referenceData["inReference"])>0) ? ($referenceData["inReference"] . '. ') : '')
784
	. ((strlen($referenceData["series"])>0) ? ($referenceData["series"] . '. ') : '')
785
	. ((strlen($referenceData["volume"])>0) ? ($referenceData["volume"] . '. ') : '')
786
	. ((strlen($referenceData["pages"])>0) ? ($referenceData["pages"] . '. ') : '')
787
	. ((strlen($referenceData["isbn"])>0) ? ($referenceData["isbn"] . '. ') : '')
788
	. ((strlen($referenceData["issn"])>0) ? ($referenceData["issn"] . '. ') : '')
789
	. ((strlen($referenceData["uri"])>0) ? ($referenceData["uri"] . '. ') : '');
790

    
791
}
792

    
793

    
794
function theme_cdm_media_page($media, $mediarepresentation_uuid = false, $partId = false){
795
	$out = '';
796
	// determine which reprresentation and which part to show
797
	$representationIdx = 0;
798
	if($mediarepresentation_uuid){
799
		$i = 0;
800
		foreach($media->representations as $representation) {
801
			if($representation->uuid == $mediarepresentation_uuid){
802
				$representationIdx = $i;
803
			}
804
			$i++;
805
		}
806
	} else {
807
		$mediarepresentation_uuid = $media->representations[0]->uuid;
808
	}
809

    
810
	$partIdx  = 0;
811
	if(!is_numeric($partId)){
812
		// assuming it is an uuid
813
		$i = 0;
814
		foreach($media->representations[$representationIdx]->parts as $part) {
815
			if($part->uuid == $partId){
816
				$partIdx = $i;
817
			}
818
			$i++;
819
		}
820
	} else {
821
		// assuming it is an index
822
		$partIdx = $partId;
823
	}
824

    
825
	$media_metadata = cdm_read_media_metadata($media);
826
	//$title = $media->titleCache;
827
	$title = $media_metadata['title'];
828

    
829
	$imageMaxExtend = variable_get('image-page-maxextend', 400);
830

    
831
	if(!$title){
832
		$title = 'Media '.$media->uuid.'';
833
	}
834

    
835
	drupal_set_title($title);
836

    
837

    
838
	$out .= '<div class="media">';
839

    
840
	//$out .= '<div class="viewer">';
841
	$out .= theme(cdm_back_to_image_gallery_button);
842
	$out .= '<div class="viewer">';
843
	//$out .= theme('cdm_media_gallerie_image', $representation->parts[$partIdx], $imageMaxExtend);
844
	$out .= theme('cdm_openlayers_image', $media->representations[$representationIdx]->parts[$partIdx], $imageMaxExtend);
845
	$out .= '</div>';
846

    
847
	// general media metadata
848
	//$media_metadata = cdm_ws_get(CDM_WS_MEDIA_METADATA, array($media->uuid));
849
	//vardump("PRINTING MEDIA METADATA");
850
	//vardump($media_metadata);
851
	//vardump("PRINTING MEDIA");
852
	//vardump($media);
853
	$metadataToPrint = theme('cdm_media_caption', $media);
854
	$out .= $metadataToPrint;
855

    
856

    
857
	//tabs for the different representations
858
	//ul.secondary
859
	$out .= '<ul class="primary">';
860
	foreach($media->representations as $representation){
861
		$out .= '<li>'.l($media->representations[$representationIdx]->mimeType, path_to_media($media->uuid, $mediarepresentation_uuid, $partIdx)).'</li>';
862
	}
863
	$out .= '</ul>';
864

    
865
	// representation(-part) specific metadata
866
	$thumbnailMaxExtend = 100;
867
	$out .= '<table>';
868
	//$out .= '<tr><th colspan="3">'.t('MimeType').': '.$media->representations[$representationIdx]->mimeType.'</th></tr>';
869
	$i = 0;
870
	foreach($media->representations[$representationIdx]->parts as $part){
871
		$out .= '<tr><th>'.t('Part').' '.($i + 1).'</th><td>';
872
		switch($part->class){
873
			case 'ImageFile': $out .= $part->width.' x '.$part->height.' - '.$part->size.'k'; break;
874
			case 'AudioFile':
875
			case 'MovieFile': $out .= t('Duration').': '.$part->duration.'s - '.$part->size.'k'; break;
876
			default: $out .= $part->size.'k';
877
		}
878
		$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>';
879
		$i++;
880
	}
881
	$out .= '</table>';
882
	$out .= '</div>';
883

    
884
	return $out;
885
}
886

    
887
/**
888
 * Allows theming of the taxon page tabs
889
 *
890
 * @param $tabname
891
 * @return unknown_type
892
 */
893
function theme_cdm_taxonpage_tab($tabname){
894
	//TODO replace by using translations or theme the menue tabs itself instead?
895
	switch($tabname){
896
		default: return t($tabname);
897
	}
898
}
899

    
(6-6/8)