Project

General

Profile

Download (30.7 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){
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
	$specimensOrObersvations = cdm_ws_get(CDM_WS_TAXON, array($taxon->uuid, 'specimensOrObersvations') );
89
	$specimensOrObersvationsCount = is_array($specimensOrObersvations) ? count($specimensOrObersvations) : 0;
90
	if($specimensOrObersvationsCount == 0) {
91
		$hideTabs[] = theme('cdm_taxonpage_tab', 'Specimens');
92
	}
93

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

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

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

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

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

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

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

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

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

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

    
165
  	$out .= '</div>';
166

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

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

    
181
  	$out .= '</div>';
182
  }
183

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

    
196

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

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

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

    
223

    
224
function theme_cdm_taxon_page_specimens($taxon){
225

    
226
	RenderHints::pushToRenderStack('taxon_page_specimens');
227

    
228
	$specimensOrObersvations = cdm_ws_get(CDM_WS_TAXON, array($taxon->uuid, 'specimensOrObersvations') );
229

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

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

    
244

    
245

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

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

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

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

    
295
	$out .= $out_specimenList;
296

    
297

    
298
	RenderHints::popFromRenderStack();
299
	return $out;
300
}
301

    
302
function specimens_search_form() {
303

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

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

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

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

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

    
354
	//returning value
355
	return $form;
356
}
357

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

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

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

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

    
434
	return $out;
435
}
436

    
437

    
438
/**
439
 * TODO Implementation of Hook taxon_image_gallery()
440
 *
441
 * @param unknown_type $taxon
442
 * @param unknown_type $media
443
 * @return unknown_type
444
 */
445
function taxon_image_gallery_default($taxon, $media){
446

    
447
	$hasImages = isset($media[0]);
448

    
449
	if($hasImages){
450
		//
451
		$maxExtend = 150;
452
		$cols = 3;
453
		$maxRows = false;
454
		$alternativeMediaUri = null;
455
		$captionElements = array('title', 'rights', '#uri'=>t('open Image'));
456
		$gallery_name = $taxon->uuid;
457
		$mediaLinkType = 'LIGHTBOX';
458

    
459
		$gallery_settings = getGallerySettings(CDM_DATAPORTAL_MEDIA_GALLERY_NAME);
460

    
461
		$out = '<div class="image-gallerie">';
462
		$out .= theme('cdm_media_gallerie', $media,
463
		$gallery_name,
464
		$gallery_settings['cdm_dataportal_media_maxextend'],
465
		$gallery_settings['cdm_dataportal_media_cols'],
466
		0, // ignore maxrows settings
467
		$captionElements,
468
		$mediaLinkType,
469
		null);
470
		$out .= '</div>';
471
	}else{
472
		$out = 'No images available.';
473

    
474
	}
475
	return $out;
476

    
477
}
478

    
479
/**
480
 * TODO Implementation of Hook taxon_image_gallery()
481
 *
482
 * @param unknown_type $taxon
483
 * @param unknown_type $media
484
 * @return unknown_type
485
 */
486
function taxon_image_gallery_fsi($taxon, $media){
487

    
488
	$flashLink = isset($media[0]);
489

    
490
	if($flashLink){
491

    
492
		$taggedName = $taxon->name->taggedName;
493

    
494
		$nameArray = array();
495
		foreach($taggedName as $taggedText){
496
			if($taggedText->type == 'name'){
497
				$nameArray[] = $taggedText->text;
498
			}
499
		}
500

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

    
503
		$out = '
504

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

    
507
<script type="text/javascript">
508
<!--
509
  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",
510
    "http://media.bgbm.org/erez/erez?src=erez-private/flashrequired.svg&tmp=Large&quality=97&width=620&height=400",
511
    "width=620;height=400;bgcolor=454343;wmode=opaque");
512
// -->
513
</script>
514
<noscript>
515
  <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">
516
    <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"/>
517
    <param name="bgcolor" value="454343" />
518
    <param name="wmode" value="opaque" />
519
    <param name="allowscriptaccess" value="always" />
520
    <param name="allowfullscreen" value="true" />
521
    <param name="quality" value="high" />
522
    <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"
523
      width="620"
524
      height="400"
525
      bgcolor="454343"
526
      wmode="opaque"
527
      allowscriptaccess="always"
528
      allowfullscreen="true"
529
      quality="high"
530
      type="application/x-shockwave-flash"
531
      pluginspage="http://www.adobe.com/go/getflashplayer">
532
    </embed>
533
  </object>
534

    
535
</noscript>';
536

    
537
	}else{
538
		$out = 'No images available.';
539

    
540
	}
541
	return $out;
542

    
543
}
544
/**
545
 * Show a reference in it's atomized form
546
 */
547
function theme_cdm_reference_page($referenceTO){
548

    
549
	/*
550
	 if($referenceTO->titleCache) {
551
		drupal_set_title($referenceTO->titleCache);
552
		} else {
553
		drupal_set_title($referenceTO->fullCitation);
554
		}
555
		*/
556

    
557
	$field_order = array(
558
    "title",
559
	//"titleCache",
560
	//"citation",
561
    "authorTeam",
562
    "editor",
563
    "publisher",
564
    "placePublished",
565
    "datePublished",
566
    "year",
567
    "edition",      // class Book
568
    "volume",       // class Article
569
    "seriesPart",
570
    "inReference",
571
	//"inJournal",     // class Article
572
	//"inBook",        // class BookSection
573
    "nomRefBase",    // class BookSection, Book, Article
574
	//"inProceedings", // class InProceedings
575
    "pages",         // class Article
576
    "series",        // class Article, PrintSeries
577
    "school",        // class Thesis
578
    "institution",   // class Report
579
    "organization",  // class Proceedings
580
    "nextVersion",
581
    "previousVersion",
582
    "isbn",         // class Book
583
    "issn",         // class Journal
584
    "uri",
585
	);
586
	/*
587
	 $table_rows = array();
588
	 foreach($field_order as $fieldname){
589

    
590
		if(isset($referenceTO->$fieldname)){
591

    
592
		if($fieldname == "datePublished") {
593
		$partial = $referenceTO->$fieldname;
594
		$datePublished = '';
595
		if($partial->start){
596
		//var_dump ($partial->start);
597
		$datePublishedYear = substr($partial->start, 0, 4);
598
		$datePublishedMonth = substr($partial->start, 5, 2);
599

    
600
		if (!(preg_match('#[0-9]#',$datePublishedMonth))){
601
		$datePublishedMonth = '00';
602
		}
603

    
604
		$datePublishedDay = substr($partial->start, 7, 2);
605
		if (!(preg_match('#[0-9]#',$datePublishedDay))){
606
		$datePublishedDay = '00';
607
		}
608
		$datePublished = $datePublishedYear.'-'.$datePublishedMonth.'-'.$datePublishedDay;
609
		}
610
		if($partial->end){
611
		$datePublished = (strlen($datePublished) > 0 ? ' '.t('to').' ' : '').substr($partial->end, 0, 4).'-'.substr($partial->end, 4, 2).'-'.substr($partial->end, 6, 2);
612
		}
613
		$table_rows[] = array(t(ucfirst(strtolower($fieldname))), $datePublished);
614
		//$datePublished = array(t(ucfirst(strtolower($fieldname))), $datePublished);
615
		} else if(is_object($referenceTO->$fieldname)){
616
		if ($fieldname == "authorTeam"){
617
		$dump = $referenceTO->$fieldname;
618
		$teammembers = "teamMembers";
619
		$team = $dump->$teammembers;
620
		$nameArray = array();
621

    
622
		foreach($team as $member){
623
		if (strlen($member->lastname)> 0){
624
		$nname = $member->lastname;
625
		$name = $nname;
626
		if (strlen($member->firstname)> 0){
627
		$vname = $member->firstname;
628
		$name =$vname." ". $nname;
629
		}
630
		$nameArray[] =$name;
631
		}else{
632
		if (strlen($member->titleCache)> 0){
633
		$nameArray[] = $member->titleCache;
634
		}
635
		}
636
		}
637
		$names = join($nameArray, ", ");
638
		}else if ($fieldname == "inReference"){
639
		$type = $referenceTO ->$fieldname-> type;
640
		$names = $referenceTO-> $fieldname-> titleCache;
641
		switch ($type) {
642
		case "Book":
643
		$fieldname = "in book";
644
		break;
645
		case "Journal":
646
		$fieldname = "in journal";
647
		break;
648
		case "Proceedings":
649
		$fieldname = "in proceedings";
650
		break;
651
		}
652

    
653
		}else{
654
		$names = $referenceTO->$fieldname-> titleCache;
655
		}
656
		$table_rows[] = array(t(ucfirst(strtolower($fieldname))), $names);
657
		//$name = array(t(ucfirst(strtolower($fieldname))), $names);
658

    
659
		} else {
660
		$table_rows[] = array(t(ucfirst(strtolower($fieldname))), $referenceTO->$fieldname);
661
		//$name = array(t(ucfirst(strtolower($fieldname))), $referenceTO->$fieldname);
662
		}
663
		}
664
		}
665
		*/
666

    
667
	//select the type of the reference and find the in Reference attribute
668

    
669
	$referenceData = array(
670
    "title" => NULL,
671
	//"titleCache",
672
	//"citation",
673
    "authorTeam" => NULL,
674
    "editor" => NULL,
675
    "publisher" => NULL,
676
    "placePublished" => NULL,
677
    "datePublished" => NULL,
678
    "year" => NULL,
679
    "edition" => NULL,      // class Book
680
    "volume" => NULL,       // class Article
681
    "seriesPart" => NULL,
682
    "inReference" => NULL,
683
	//"inJournal",     // class Article
684
	//"inBook",        // class BookSection
685
    "nomRefBase" => NULL,    // class BookSection, Book, Article
686
	//"inProceedings", // class InProceedings
687
    "pages" => NULL,         // class Article
688
    "series" => NULL,        // class Article, PrintSeries
689
    "school" => NULL,        // class Thesis
690
    "institution" => NULL,   // class Report
691
    "organization" => NULL,  // class Proceedings
692
    "nextVersion" => NULL,
693
    "previousVersion" => NULL,
694
    "isbn" => NULL,         // class Book
695
    "issn" => NULL,         // class Journal
696
    "uri" => NULL,
697
	);
698

    
699
	foreach($field_order as $fieldname){
700

    
701
		if(isset($referenceTO->$fieldname)){
702
			switch($fieldname){
703
				case "datePublished":
704
					$partial = $referenceTO->$fieldname;
705
					$datePublished = '';
706
					if($partial->start){
707
						$datePublishedYear = substr($partial->start, 0, 4);
708
						$datePublishedMonth = substr($partial->start, 5, 2);
709
						if (!(preg_match('#[0-9]#',$datePublishedMonth))){
710
							$datePublishedMonth = '00';
711
						}
712
						$datePublishedDay = substr($partial->start, 7, 2);
713
						if (!(preg_match('#[0-9]#',$datePublishedDay))){
714
							$datePublishedDay = '00';
715
						}
716
						$datePublished = $datePublishedYear.'-'.$datePublishedMonth.'-'.$datePublishedDay;
717
					}
718
					if($partial->end){
719
						$datePublished = (strlen($datePublished) > 0 ? ' '.t('to').' ' : '').substr($partial->end, 0, 4).'-'.substr($partial->end, 4, 2).'-'.substr($partial->end, 6, 2);
720
					}
721

    
722
					$referenceData[$fieldname] = $datePublishedYear;
723
					break;
724

    
725
				default:
726
					if(is_object($referenceTO->$fieldname)){
727
						if ($fieldname == "authorTeam"){
728
							$dump = $referenceTO->$fieldname;
729
							$teammembers = "teamMembers";
730
							$team = $dump->$teammembers;
731
							$nameArray = array();
732

    
733
							foreach($team as $member){
734
								if (strlen($member->lastname)> 0){
735
									$nname = $member->lastname;
736
									$name = $nname;
737
									if (strlen($member->firstname)> 0){
738
										$vname = $member->firstname;
739
										$name =$vname." ". $nname;
740
									}
741
									$nameArray[] =$name;
742
								}else{
743
									if (strlen($member->titleCache)> 0){
744
										$nameArray[] = $member->titleCache;
745
									}
746
								}
747
							}
748
							$names = join($nameArray, ", ");
749
							$referenceData[$fieldname] = $names;
750
						}else if ($fieldname == "inReference"){
751
							$names = $referenceTO->$fieldname->titleCache;
752
							$referenceData[$fieldname] = $names;
753
						}else{
754
							$names = $referenceTO->$fieldname->titleCache;
755
							$referenceData[$fieldname] = $names;
756
						}
757
					}else{
758
						$referenceData[$fieldname] = $referenceTO->$fieldname;
759
					}
760

    
761
			}
762
		}
763
	}
764
	$author_team =  cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $referenceTO->uuid);
765
	//return "" . ((strlen($referenceData["authorTeam"])>0) ? ($referenceData["authorTeam"] . '. ') : '')
766
	return "" . ((strlen($author_team->titleCache)>0) ? ($author_team->titleCache . '. ') : '')
767
	. ((strlen($referenceData["datePublished"])>0) ? ($referenceData["datePublished"] . '. ') : '')
768
	. ((strlen($referenceData["title"])>0) ? ($referenceData["title"] . '. ') : "")
769
	. ((strlen($referenceData["placePublished"])>0) ? ($referenceData["placePublished"] . '. ') : '')
770
	. ((strlen($referenceData["editor"])>0) ? ($referenceData["editor"] . '. ') : '')
771
	. ((strlen($referenceData["publisher"])>0) ? ($referenceData["publisher"] . '. ') : '')
772
	. ((strlen($referenceData["inReference"])>0) ? ($referenceData["inReference"] . '. ') : '')
773
	. ((strlen($referenceData["series"])>0) ? ($referenceData["series"] . '. ') : '')
774
	. ((strlen($referenceData["volume"])>0) ? ($referenceData["volume"] . '. ') : '')
775
	. ((strlen($referenceData["pages"])>0) ? ($referenceData["pages"] . '. ') : '')
776
	. ((strlen($referenceData["isbn"])>0) ? ($referenceData["isbn"] . '. ') : '')
777
	. ((strlen($referenceData["issn"])>0) ? ($referenceData["issn"] . '. ') : '')
778
	. ((strlen($referenceData["uri"])>0) ? ($referenceData["uri"] . '. ') : '');
779

    
780
}
781

    
782

    
783
function theme_cdm_media_page($media, $mediarepresentation_uuid = false, $partId = false){
784
	$out = '';
785
	// determine which reprresentation and which part to show
786
	$representationIdx = 0;
787
	if($mediarepresentation_uuid){
788
		$i = 0;
789
		foreach($media->representations as $representation) {
790
			if($representation->uuid == $mediarepresentation_uuid){
791
				$representationIdx = $i;
792
			}
793
			$i++;
794
		}
795
	} else {
796
		$mediarepresentation_uuid = $media->representations[0]->uuid;
797
	}
798

    
799
	$partIdx  = 0;
800
	if(!is_numeric($partId)){
801
		// assuming it is an uuid
802
		$i = 0;
803
		foreach($media->representations[$representationIdx]->parts as $part) {
804
			if($part->uuid == $partId){
805
				$partIdx = $i;
806
			}
807
			$i++;
808
		}
809
	} else {
810
		// assuming it is an index
811
		$partIdx = $partId;
812
	}
813

    
814
	$media_metadata = cdm_read_media_metadata($media);
815
	//$title = $media->titleCache;
816
	$title = $media_metadata['title'];
817

    
818
	$imageMaxExtend = variable_get('image-page-maxextend', 400);
819

    
820
	if(!$title){
821
		$title = 'Media '.$media->uuid.'';
822
	}
823

    
824
	drupal_set_title($title);
825

    
826

    
827
	$out .= '<div class="media">';
828

    
829
	//$out .= '<div class="viewer">';
830
	$out .= theme(cdm_back_to_image_gallery_button);
831
	$out .= '<div class="viewer">';
832
	//$out .= theme('cdm_media_gallerie_image', $representation->parts[$partIdx], $imageMaxExtend);
833
	$out .= theme('cdm_openlayers_image', $media->representations[$representationIdx]->parts[$partIdx], $imageMaxExtend);
834
	$out .= '</div>';
835

    
836
	// general media metadata
837
	//$media_metadata = cdm_ws_get(CDM_WS_MEDIA_METADATA, array($media->uuid));
838
	//vardump("PRINTING MEDIA METADATA");
839
	//vardump($media_metadata);
840
	//vardump("PRINTING MEDIA");
841
	//vardump($media);
842
	$metadataToPrint = theme('cdm_media_caption', $media);
843
	$out .= $metadataToPrint;
844

    
845

    
846
	//tabs for the different representations
847
	//ul.secondary
848
	$out .= '<ul class="primary">';
849
	foreach($media->representations as $representation){
850
		$out .= '<li>'.l($media->representations[$representationIdx]->mimeType, path_to_media($media->uuid, $mediarepresentation_uuid, $partIdx)).'</li>';
851
	}
852
	$out .= '</ul>';
853

    
854
	// representation(-part) specific metadata
855
	$thumbnailMaxExtend = 100;
856
	$out .= '<table>';
857
	//$out .= '<tr><th colspan="3">'.t('MimeType').': '.$media->representations[$representationIdx]->mimeType.'</th></tr>';
858
	$i = 0;
859
	foreach($media->representations[$representationIdx]->parts as $part){
860
		$out .= '<tr><th>'.t('Part').' '.($i + 1).'</th><td>';
861
		switch($part->class){
862
			case 'ImageFile': $out .= $part->width.' x '.$part->height.' - '.$part->size.'k'; break;
863
			case 'AudioFile':
864
			case 'MovieFile': $out .= t('Duration').': '.$part->duration.'s - '.$part->size.'k'; break;
865
			default: $out .= $part->size.'k';
866
		}
867
		$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>';
868
		$i++;
869
	}
870
	$out .= '</table>';
871
	$out .= '</div>';
872

    
873
	return $out;
874
}
875

    
876
/**
877
 * Allows theming of the taxon page tabs
878
 *
879
 * @param $tabname
880
 * @return unknown_type
881
 */
882
function theme_cdm_taxonpage_tab($tabname){
883
	//TODO replace by using translations or theme the menue tabs itself instead?
884
	switch($tabname){
885
		default: return t($tabname);
886
	}
887
}
888

    
(6-6/8)