Project

General

Profile

Download (32.1 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
	$selectShowMedia = variable_get('cdm_dataportal_show_media', 0);
69
	if ($selectShowMedia == 0){
70
		$media = cdm_ws_get(CDM_WS_PORTAL_TAXON_MEDIA, array($taxon->uuid, $prefMimeTypeRegex, $prefMediaQuality));
71
	}else{
72
		$media = cdm_ws_get(CDM_WS_PORTAL_TAXON_SUBTREE_MEDIA, array($taxon->uuid, $prefMimeTypeRegex, $prefMediaQuality));
73
	}
74
	if(!isset($media[0])) {
75
		$hideTabs[] = theme('cdm_taxonpage_tab', 'Images');
76
	}
77
	// hideImage flag depending on administative preset
78
	$hideImages = false;
79
	if(variable_get('image_hide_rank', '0') != '0'){
80
		$rankCompare = rank_compare($taxon->name->rank->uuid, variable_get('image_hide_rank', '-99'));
81
		$hideImages =  ($rankCompare > -1);
82
	}
83

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

    
91
	// --- GET polytomousKeys --- //
92
	$polytomousKeysPager = cdm_ws_get(CDM_WS_POLYTOMOUSKEY, null, "findByTaxonomicScope=$taxon->uuid");
93
  $identificationKeyCount = 0;
94
	if($polytomousKeysPager){
95
	 $identificationKeyCount += $polytomousKeysPager->count;
96
	}
97
	if($identificationKeyCount == 0){
98
		$hideTabs[] = theme('cdm_taxonpage_tab', 'Keys');
99
	}
100
  // -------------------------------------------- //
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
  //var_dump(variable_get('cdm_dataportal_display_is_accepted_for', CDM_DATAPORTAL_DISPLAY_IS_ACCEPTED_FOR));
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
  // --- PAGE PART: 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/taxon'), '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
  // --- PAGE PART: 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( 'taxon_image_gallery_' . variable_get('image_gallery_viewer', 'default'),
161
  	     array($taxon, $media));
162
  	$out .= $taxon_image_gallery;
163

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

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

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

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

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

    
193
  // --- PAGE PART: KEYS --- //
194
  if($identificationKeyCount > 0 && ($page_part == 'keys' || $page_part == 'all') ){
195
    $out .= '<div id="keys">';
196
        if($page_part == 'all'){
197
      $out .= '<h2>'.t('Keys').'</h2>';
198
    }
199
    $out .= theme('cdm_block_IdentificationKeys', $taxon->uuid);
200
    $out .= '</div>';
201
  }
202
  return $out;
203
}
204

    
205

    
206
/**
207
 * Outputs all descriptive data and shows the preferred picture of the
208
 * accepted taxon.
209
 *
210
 */
211
function theme_cdm_taxon_page_description($taxon, $mergedTrees, $media = null, $hideImages = false){
212

    
213
	if( variable_get('cdm_dataportal_show_default_image', false) && !$hideImages){
214
		// preferred image
215
		// hardcoded for testing;
216
		$defaultRepresentationPart = false;
217
		$defaultRepresentationPart->width = 184;
218
		$defaultRepresentationPart->height = 144;
219
		$defaultRepresentationPart->uri = drupal_get_path('theme', 'palmweb_2').'/images/no_picture.png';
220

    
221
		// preferred image size 184px × 144
222
		$imageMaxExtend = 184;
223
		$out .= '<div class="preferredImage">'.$defaultRepresentationPart->uri.theme('cdm_preferredImage', $media, $defaultRepresentationPart, $imageMaxExtend).'</div>';
224
	}
225
	// description TOC
226
	$out .= theme('cdm_featureTreeTOCs', $mergedTrees);
227
	// description
228
	$out .= theme('cdm_featureTrees', $mergedTrees, $taxon);
229
	return $out;
230
}
231

    
232

    
233
function theme_cdm_taxon_page_specimens($taxon){
234

    
235
	RenderHints::pushToRenderStack('taxon_page_specimens');
236

    
237
	$specimensOrObersvations = cdm_ws_get(CDM_WS_TAXON, array($taxon->uuid, 'specimensOrObersvations') );
238

    
239
	//collect media (fieldObjectMedia, derivedUnitMedia) and add as fields
240
	 foreach($specimensOrObersvations as $specimensOrObersvation) {
241
			$specimensOrObersvation->_fieldObjectMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array($specimensOrObersvation->uuid, 'fieldObjectMedia') );
242
			$specimensOrObersvation->_derivedUnitMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array($specimensOrObersvation->uuid, 'derivedUnitMedia') );
243
			//	  	$derivedUnitFacde = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array($descriptionElement->associatedSpecimenOrObservation->uuid) );
244
			//	  	$descriptionElement->_titleCache = $derivedUnitFacde->titleCache;
245
	}
246

    
247
	if(variable_get('cdm_dataportal_map_openlayers', 1)){
248
		$occurrenceQuery = cdm_ws_get(CDM_WS_GEOSERVICE_OCCURRENCEMAP, $taxon->uuid);
249
		$occurrenceQuery = $occurrenceQuery->String;
250
		$out .= get_openlayers_map(variable_get('cdm_dataportal_geoservice_display_width', false), $occurrenceQuery);
251
	}
252

    
253

    
254

    
255
	if($specimensOrObersvations){
256
		$out_specimenList = '<table class="specimens">';
257
		$i = 1;
258
		foreach($specimensOrObersvations as $specimensOrObersvation) {
259
			$i++;
260

    
261
				$mediaList = array();
262
				if(is_array($specimensOrObersvation->_fieldObjectMedia)){
263
					$mediaList = array_merge($mediaList, $specimensOrObersvation->_fieldObjectMedia);
264
				}
265
				if(is_array($specimensOrObersvation->_derivedUnitMedia)){
266
					$mediaList = array_merge($mediaList, $specimensOrObersvation->_derivedUnitMedia);
267
				}
268

    
269
				// --- render the title cache
270
				$out_row = '<tr class="descriptionElement descriptionElement_IndividualsAssociation '.($i%2?'odd':'even').'">';
271
				if($specimensOrObersvation->class != 'FieldObservation'){
272
          $label_html = cdm_dynabox($specimensOrObersvation->titleCache,
273
            cdm_compose_url('portal/'.CDM_WS_DERIVEDUNIT_FACADE, array($specimensOrObersvation->uuid)),
274
            'cdm_derivedUnitFacade',
275
            'Click for details',
276
            array('div', 'div'));
277
				} else {
278
				  $label_html = $specimensOrObersvation->titleCache;
279
				}
280
				$out_row .= '<td>' . $label_html . '</td>';
281

    
282
				// --- render associated media
283
				if(count($mediaList) > 0){
284
					$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
285
					$gallery_name =  $specimensOrObersvation->uuid;
286
					$captionElements = array('#uri'=>t('open media'));
287
					$gallery_html = theme(
288
	  			    'cdm_media_gallerie',
289
					$mediaList,
290
					$gallery_name ,
291
					$gallery_settings['cdm_dataportal_media_maxextend'],
292
					$gallery_settings['cdm_dataportal_media_cols'],
293
					$gallery_settings['cdm_dataportal_media_maxRows'],
294
					$captionElements, 'LIGHTBOX', null, null);
295
				} else {
296
					$gallery_html = '';
297
				}
298
				$out_row .= '<td>'.$gallery_html.'</td></tr>';
299
				$out_specimenList .= $out_row;
300
		}
301
		$out_specimenList .= '</table>';
302
	}
303

    
304
	$out .= $out_specimenList;
305

    
306

    
307
	RenderHints::popFromRenderStack();
308
	return $out;
309
}
310

    
311
function specimens_search_form() {
312

    
313
	//form select options
314
	$form['specimens_search_options'] = array(
315
    '#type' => 'value',
316
    '#value' => array(t('No sort'), t('Name'), t('CatalogNumber'), t('Gallery'))
317
	);
318

    
319
	//the form
320
	$form['specimens_search'] = array(
321
    '#title' => t('Speciments sort'),
322
	  '#type' => 'fieldset',
323
	  '#description' => t('Select your sort criteria.'),
324
	  '#collapsible' => TRUE,
325
    '#collapsed' => FALSE
326
	);
327

    
328
	//criteria
329
	$form['specimens_search']['first_criteria'] = array(
330
    '#title' => t('First criteria'),
331
    '#type' => 'select',
332
    '#options' => $form['specimens_search_options']['#value']
333
	);
334
	$form['specimens_search']['second_criteria'] = array(
335
    '#title' => t('Second criteria'),
336
    '#type' => 'select',
337
    '#options' => $form['specimens_search_options']['#value']
338
	);
339
	$form['specimens_search']['third_criteria'] = array(
340
    '#title' => t('Third criteria'),
341
    '#type' => 'select',
342
    '#options' => $form['specimens_search_options']['#value']
343
	);
344

    
345
	//submit button
346
	$form['specimens_search']['submit'] = array(
347
    '#type' => 'submit',
348
    '#value' => t('Sort')
349
	);
350

    
351
	/*
352
	//from properties
353
	$form['#method'] = 'post';
354
	$form['#action'] = 'http://example.com/?q=foo/bar';
355
	$form['#attributes'] = array(
356
    'enctype' => 'multipart/form-data',
357
    'target' => 'name_of_target_frame'
358
	);
359
	$form['#prefix'] = '<div class="my-form-class">';
360
	$form['#suffix'] = '</div>';
361
	*/
362

    
363
	//returning value
364
	return $form;
365
}
366

    
367
/**
368
 * Show whole synonymy for the accepted taxon. Synonymy list is headed by the complete scientific name
369
 * of the accepted taxon with nomenclatural reference.
370
 *
371
 */
372
function theme_cdm_taxon_page_synonymy($taxon, $addAcceptedTaxon){
373

    
374
	RenderHints::pushToRenderStack('taxon_page_synonymy');
375
	$synomymie = cdm_ws_get(CDM_WS_PORTAL_TAXON_SYNONYMY, $taxon->uuid);
376
	$skip = array(UUID_BASIONYM);
377

    
378
	//render full accepted taxon
379
	if($addAcceptedTaxon){
380
		if(isset($taxon->name->nomenclaturalReference)){
381
			$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
382
		}
383

    
384
		$accepted_name = theme('cdm_taxonName', $taxon->name, null, $referenceUri);
385
		$out .= '<span class="accepted-name">';
386
		$out .= $accepted_name;
387
        $out .= '</span>';
388

    
389
		$special_annotations_array = array();
390
		$special_annotations_array[] = $taxon->name;
391
		$special_annotations_array[] = $taxon;
392
		$out .= theme('cdm_annotations_as_footnotekeys',
393
					$special_annotations_array,
394
					RenderHints::getRenderPath() . '-annotations');
395
					RenderHints::setFootnoteListKey(RenderHints::getRenderPath() . '-annotations');
396
	}
397
	//render accepted taxon homotypic synonymy groups or type desygnations
398
	//if(!isset($synomymie->homotypicSynonymsByHomotypicGroup[0])){
399
		//if($addAcceptedTaxon && !isset($synomymie->homotypicSynonymsByHomotypicGroup[0])){
400
		// display the type information for the added taxon
401
    //}
402

    
403
    //render accepted taxon homotypic synonymy groups or type desygnations but
404
	//show only the typedesignations at the homotypic synonymy group
405
	if (!$synomymie->homotypicSynonymsByHomotypicGroup[0]->name->uuid){
406
		$typeDesignations = cdm_ws_get(CDM_WS_PORTAL_TAXON_NAMETYPEDESIGNATIONS, $taxon->uuid);
407
		if($typeDesignations){
408
			$out .= theme('cdm_typedesignations', $typeDesignations);
409
			$out .= '<ul class="homotypicSynonyms">' . '</ul>';
410
		}
411
	}
412
    // render the homotypicSynonymyGroup including the type information
413
	if($synomymie->homotypicSynonymsByHomotypicGroup){
414
        $out .= theme('cdm_homotypicSynonymyGroup', $synomymie->homotypicSynonymsByHomotypicGroup, $taxon->uuid);
415
	}
416
	/*
417
	else{
418
		$out .= '<ul class="homotypicSynonyms"></ul>';
419
	}
420
	*/
421
	//render accepted taxon heterotypic synonymy groups
422
	if($synomymie->heterotypicSynonymyGroups) {
423
		foreach($synomymie->heterotypicSynonymyGroups as $homotypicalGroup){
424
			$out .= theme('cdm_heterotypicSynonymyGroup', $homotypicalGroup);
425
		}
426
	}
427
	//render taxon relationships
428
	if(variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT)){
429
		$taxonRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS, $taxon->uuid);
430
		$out .= theme('cdm_taxonRelationships', $taxonRelationships);
431
	}
432
	//render name relationships
433
	$name_rels_to_show = variable_get('name_relationships_to_show', null);
434
	$skip = array();
435
	if($name_rels_to_show){
436
		foreach ($name_rels_to_show as $key => $value){
437
			if ($value === 0){
438
				$skip[] = $key;
439
			}
440
		}
441
		if (sizeof($name_rels_to_show) != sizeof($skip)){
442
			$nameRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_TO_NAMERELATIONS, $taxon->uuid);
443
			$out .= theme('cdm_nameRelationships', $nameRelationships, $skip);
444
		}
445
	}
446
	/*
447
	 if(variable_get(CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_DEFAULT)){
448
	 $nameRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_TO_NAMERELATIONS, $taxon->uuid);
449
	 // TODO is it correct to skip relationsFromThisName since all relationships are to be understood as 'is .... of'
450
	 if(variable_get('cdm_dataportal_name_relations_skiptype_basionym', 1)){
451
	 $skip = array(UUID_BASIONYM);
452
	 }
453
	 $out .= theme('cdm_nameRelationships', $nameRelationships, $skip);
454
	 }
455
	 */
456

    
457
	//render the annontations text for the accepted taxa
458
	if ($addAcceptedTaxon){
459
		$out .= theme('cdm_footnotes', RenderHints::getRenderPath() . '-annotations', 'li');
460
	}
461
	RenderHints::popFromRenderStack();
462

    
463
	return $out;
464
}
465

    
466
/**
467
 * TODO Implementation of Hook taxon_image_gallery()
468
 *
469
 * @param unknown_type $taxon
470
 * @param unknown_type $media
471
 * @return unknown_type
472
 */
473
function taxon_image_gallery_default($taxon, $media){
474

    
475
	$hasImages = isset($media[0]);
476

    
477
	if($hasImages){
478
		//
479
		$maxExtend = 150;
480
		$cols = 3;
481
		$maxRows = false;
482
		$alternativeMediaUri = null;
483
		$captionElements = array('title', 'rights', '#uri'=>t('open Image'));
484
		$gallery_name = $taxon->uuid;
485
		$mediaLinkType = 'LIGHTBOX';
486

    
487
		//$gallery_settings = getGallerySettings(CDM_DATAPORTAL_MEDIA_GALLERY_NAME);
488
		$gallery_settings = getGallerySettings(CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB);
489
		$out = '<div class="image-gallerie">';
490
		$out .= theme('cdm_media_gallerie',
491
		  $media,
492
		  $gallery_name,
493
		  $gallery_settings['cdm_dataportal_media_maxextend'],
494
		  $gallery_settings['cdm_dataportal_media_cols'],
495
		  0, // ignore maxrows settings
496
		  $captionElements,
497
		  $mediaLinkType,
498
		  null,
499
		  null,
500
		  $gallery_settings['cdm_dataportal_show_thumbnail_captions']);
501
		  $out .= '</div>';
502
	}else{
503
		$out = 'No images available.';
504

    
505
	}
506
	return $out;
507

    
508
}
509

    
510
/**
511
 * TODO Implementation of Hook taxon_image_gallery()
512
 *
513
 * @param unknown_type $taxon
514
 * @param unknown_type $media
515
 * @return unknown_type
516
 */
517
function taxon_image_gallery_fsi($taxon, $media){
518

    
519
	$flashLink = isset($media[0]);
520

    
521
	if($flashLink){
522

    
523
		$taggedName = $taxon->name->taggedName;
524

    
525
		$nameArray = array();
526
		foreach($taggedName as $taggedText){
527
			if($taggedText->type == 'name'){
528
				$nameArray[] = $taggedText->text;
529
			}
530
		}
531

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

    
534
		$out = '
535

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

    
538
<script type="text/javascript">
539
<!--
540
  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",
541
    "http://media.bgbm.org/erez/erez?src=erez-private/flashrequired.svg&tmp=Large&quality=97&width=620&height=400",
542
    "width=620;height=400;bgcolor=454343;wmode=opaque");
543
// -->
544
</script>
545
<noscript>
546
  <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">
547
    <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"/>
548
    <param name="bgcolor" value="454343" />
549
    <param name="wmode" value="opaque" />
550
    <param name="allowscriptaccess" value="always" />
551
    <param name="allowfullscreen" value="true" />
552
    <param name="quality" value="high" />
553
    <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"
554
      width="620"
555
      height="400"
556
      bgcolor="454343"
557
      wmode="opaque"
558
      allowscriptaccess="always"
559
      allowfullscreen="true"
560
      quality="high"
561
      type="application/x-shockwave-flash"
562
      pluginspage="http://www.adobe.com/go/getflashplayer">
563
    </embed>
564
  </object>
565

    
566
</noscript>';
567

    
568
	}else{
569
		$out = 'No images available.';
570

    
571
	}
572
	return $out;
573

    
574
}
575
/**
576
 * Show a reference in it's atomized form
577
 */
578
function theme_cdm_reference_page($referenceTO){
579

    
580
	/*
581
	 if($referenceTO->titleCache) {
582
		drupal_set_title($referenceTO->titleCache);
583
		} else {
584
		drupal_set_title($referenceTO->fullCitation);
585
		}
586
		*/
587

    
588
	$field_order = array(
589
    "title",
590
	//"titleCache",
591
	//"citation",
592
    "authorTeam",
593
    "editor",
594
    "publisher",
595
    "placePublished",
596
    "datePublished",
597
    "year",
598
    "edition",      // class Book
599
    "volume",       // class Article
600
    "seriesPart",
601
    "inReference",
602
	//"inJournal",     // class Article
603
	//"inBook",        // class BookSection
604
    "nomRefBase",    // class BookSection, Book, Article
605
	//"inProceedings", // class InProceedings
606
    "pages",         // class Article
607
    "series",        // class Article, PrintSeries
608
    "school",        // class Thesis
609
    "institution",   // class Report
610
    "organization",  // class Proceedings
611
    "nextVersion",
612
    "previousVersion",
613
    "isbn",         // class Book
614
    "issn",         // class Journal
615
    "uri",
616
	);
617
	/*
618
	 $table_rows = array();
619
	 foreach($field_order as $fieldname){
620

    
621
		if(isset($referenceTO->$fieldname)){
622

    
623
		if($fieldname == "datePublished") {
624
		$partial = $referenceTO->$fieldname;
625
		$datePublished = '';
626
		if($partial->start){
627
		//var_dump ($partial->start);
628
		$datePublishedYear = substr($partial->start, 0, 4);
629
		$datePublishedMonth = substr($partial->start, 5, 2);
630

    
631
		if (!(preg_match('#[0-9]#',$datePublishedMonth))){
632
		$datePublishedMonth = '00';
633
		}
634

    
635
		$datePublishedDay = substr($partial->start, 7, 2);
636
		if (!(preg_match('#[0-9]#',$datePublishedDay))){
637
		$datePublishedDay = '00';
638
		}
639
		$datePublished = $datePublishedYear.'-'.$datePublishedMonth.'-'.$datePublishedDay;
640
		}
641
		if($partial->end){
642
		$datePublished = (strlen($datePublished) > 0 ? ' '.t('to').' ' : '').substr($partial->end, 0, 4).'-'.substr($partial->end, 4, 2).'-'.substr($partial->end, 6, 2);
643
		}
644
		$table_rows[] = array(t(ucfirst(strtolower($fieldname))), $datePublished);
645
		//$datePublished = array(t(ucfirst(strtolower($fieldname))), $datePublished);
646
		} else if(is_object($referenceTO->$fieldname)){
647
		if ($fieldname == "authorTeam"){
648
		$dump = $referenceTO->$fieldname;
649
		$teammembers = "teamMembers";
650
		$team = $dump->$teammembers;
651
		$nameArray = array();
652

    
653
		foreach($team as $member){
654
		if (strlen($member->lastname)> 0){
655
		$nname = $member->lastname;
656
		$name = $nname;
657
		if (strlen($member->firstname)> 0){
658
		$vname = $member->firstname;
659
		$name =$vname." ". $nname;
660
		}
661
		$nameArray[] =$name;
662
		}else{
663
		if (strlen($member->titleCache)> 0){
664
		$nameArray[] = $member->titleCache;
665
		}
666
		}
667
		}
668
		$names = join($nameArray, ", ");
669
		}else if ($fieldname == "inReference"){
670
		$type = $referenceTO ->$fieldname-> type;
671
		$names = $referenceTO-> $fieldname-> titleCache;
672
		switch ($type) {
673
		case "Book":
674
		$fieldname = "in book";
675
		break;
676
		case "Journal":
677
		$fieldname = "in journal";
678
		break;
679
		case "Proceedings":
680
		$fieldname = "in proceedings";
681
		break;
682
		}
683

    
684
		}else{
685
		$names = $referenceTO->$fieldname-> titleCache;
686
		}
687
		$table_rows[] = array(t(ucfirst(strtolower($fieldname))), $names);
688
		//$name = array(t(ucfirst(strtolower($fieldname))), $names);
689

    
690
		} else {
691
		$table_rows[] = array(t(ucfirst(strtolower($fieldname))), $referenceTO->$fieldname);
692
		//$name = array(t(ucfirst(strtolower($fieldname))), $referenceTO->$fieldname);
693
		}
694
		}
695
		}
696
		*/
697

    
698
	//select the type of the reference and find the in Reference attribute
699

    
700
	$referenceData = array(
701
    "title" => NULL,
702
	//"titleCache",
703
	//"citation",
704
    "authorTeam" => NULL,
705
    "editor" => NULL,
706
    "publisher" => NULL,
707
    "placePublished" => NULL,
708
    "datePublished" => NULL,
709
    "year" => NULL,
710
    "edition" => NULL,      // class Book
711
    "volume" => NULL,       // class Article
712
    "seriesPart" => NULL,
713
    "inReference" => NULL,
714
	//"inJournal",     // class Article
715
	//"inBook",        // class BookSection
716
    "nomRefBase" => NULL,    // class BookSection, Book, Article
717
	//"inProceedings", // class InProceedings
718
    "pages" => NULL,         // class Article
719
    "series" => NULL,        // class Article, PrintSeries
720
    "school" => NULL,        // class Thesis
721
    "institution" => NULL,   // class Report
722
    "organization" => NULL,  // class Proceedings
723
    "nextVersion" => NULL,
724
    "previousVersion" => NULL,
725
    "isbn" => NULL,         // class Book
726
    "issn" => NULL,         // class Journal
727
    "uri" => NULL,
728
	);
729

    
730
	foreach($field_order as $fieldname){
731

    
732
		if(isset($referenceTO->$fieldname)){
733
			switch($fieldname){
734
				case "datePublished":
735
					$partial = $referenceTO->$fieldname;
736
					$datePublished = '';
737
					if($partial->start){
738
						$datePublishedYear = substr($partial->start, 0, 4);
739
						$datePublishedMonth = substr($partial->start, 5, 2);
740
						if (!(preg_match('#[0-9]#',$datePublishedMonth))){
741
							$datePublishedMonth = '00';
742
						}
743
						$datePublishedDay = substr($partial->start, 7, 2);
744
						if (!(preg_match('#[0-9]#',$datePublishedDay))){
745
							$datePublishedDay = '00';
746
						}
747
						$datePublished = $datePublishedYear.'-'.$datePublishedMonth.'-'.$datePublishedDay;
748
					}
749
					if($partial->end){
750
						$datePublished = (strlen($datePublished) > 0 ? ' '.t('to').' ' : '').substr($partial->end, 0, 4).'-'.substr($partial->end, 4, 2).'-'.substr($partial->end, 6, 2);
751
					}
752

    
753
					$referenceData[$fieldname] = $datePublishedYear;
754
					break;
755

    
756
				default:
757
					if(is_object($referenceTO->$fieldname)){
758
						if ($fieldname == "authorTeam"){
759
							$dump = $referenceTO->$fieldname;
760
							$teammembers = "teamMembers";
761
							$team = $dump->$teammembers;
762
							$nameArray = array();
763

    
764
							foreach($team as $member){
765
								if (strlen($member->lastname)> 0){
766
									$nname = $member->lastname;
767
									$name = $nname;
768
									if (strlen($member->firstname)> 0){
769
										$vname = $member->firstname;
770
										$name =$vname." ". $nname;
771
									}
772
									$nameArray[] =$name;
773
								}else{
774
									if (strlen($member->titleCache)> 0){
775
										$nameArray[] = $member->titleCache;
776
									}
777
								}
778
							}
779
							$names = join($nameArray, ", ");
780
							$referenceData[$fieldname] = $names;
781
						}else if ($fieldname == "inReference"){
782
							$names = $referenceTO->$fieldname->titleCache;
783
							$referenceData[$fieldname] = $names;
784
						}else{
785
							$names = $referenceTO->$fieldname->titleCache;
786
							$referenceData[$fieldname] = $names;
787
						}
788
					}else{
789
						$referenceData[$fieldname] = $referenceTO->$fieldname;
790
					}
791

    
792
			}
793
		}
794
	}
795
	$author_team =  cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $referenceTO->uuid);
796
	//return "" . ((strlen($referenceData["authorTeam"])>0) ? ($referenceData["authorTeam"] . '. ') : '')
797
	return "" . ((strlen($author_team->titleCache)>0) ? ($author_team->titleCache . '. ') : '')
798
	. ((strlen($referenceData["datePublished"])>0) ? ($referenceData["datePublished"] . '. ') : '')
799
	. ((strlen($referenceData["title"])>0) ? ($referenceData["title"] . '. ') : "")
800
	. ((strlen($referenceData["placePublished"])>0) ? ($referenceData["placePublished"] . '. ') : '')
801
	. ((strlen($referenceData["editor"])>0) ? ($referenceData["editor"] . '. ') : '')
802
	. ((strlen($referenceData["publisher"])>0) ? ($referenceData["publisher"] . '. ') : '')
803
	. ((strlen($referenceData["inReference"])>0) ? ($referenceData["inReference"] . '. ') : '')
804
	. ((strlen($referenceData["series"])>0) ? ($referenceData["series"] . '. ') : '')
805
	. ((strlen($referenceData["volume"])>0) ? ($referenceData["volume"] . '. ') : '')
806
	. ((strlen($referenceData["pages"])>0) ? ($referenceData["pages"] . '. ') : '')
807
	. ((strlen($referenceData["isbn"])>0) ? ($referenceData["isbn"] . '. ') : '')
808
	. ((strlen($referenceData["issn"])>0) ? ($referenceData["issn"] . '. ') : '')
809
	. ((strlen($referenceData["uri"])>0) ? ($referenceData["uri"] . '. ') : '');
810

    
811
}
812

    
813

    
814
function theme_cdm_media_page($media, $mediarepresentation_uuid = false, $partId = false){
815
	$out = '';
816
	// determine which reprresentation and which part to show
817
	$representationIdx = 0;
818
	if($mediarepresentation_uuid){
819
		$i = 0;
820
		foreach($media->representations as $representation) {
821
			if($representation->uuid == $mediarepresentation_uuid){
822
				$representationIdx = $i;
823
			}
824
			$i++;
825
		}
826
	} else {
827
		$mediarepresentation_uuid = $media->representations[0]->uuid;
828
	}
829

    
830
	$partIdx  = 0;
831
	if(!is_numeric($partId)){
832
		// assuming it is an uuid
833
		$i = 0;
834
		foreach($media->representations[$representationIdx]->parts as $part) {
835
			if($part->uuid == $partId){
836
				$partIdx = $i;
837
			}
838
			$i++;
839
		}
840
	} else {
841
		// assuming it is an index
842
		$partIdx = $partId;
843
	}
844

    
845
	$media_metadata = cdm_read_media_metadata($media);
846
	//$title = $media->titleCache;
847
	$title = $media_metadata['title'];
848

    
849
	$imageMaxExtend = variable_get('image-page-maxextend', 400);
850

    
851
	if(!$title){
852
		$title = 'Media '.$media->uuid.'';
853
	}
854

    
855
	drupal_set_title($title);
856

    
857

    
858
	$out .= '<div class="media">';
859

    
860
	//$out .= '<div class="viewer">';
861
	$out .= theme(cdm_back_to_image_gallery_button);
862
	$out .= '<div class="viewer">';
863
	//$out .= theme('cdm_media_gallerie_image', $representation->parts[$partIdx], $imageMaxExtend);
864
	$out .= theme('cdm_openlayers_image', $media->representations[$representationIdx]->parts[$partIdx], $imageMaxExtend);
865
	$out .= '</div>';
866

    
867
	// general media metadata
868
	//$media_metadata = cdm_ws_get(CDM_WS_MEDIA_METADATA, array($media->uuid));
869
	//vardump("PRINTING MEDIA METADATA");
870
	//vardump($media_metadata);
871
	//vardump("PRINTING MEDIA");
872
	//vardump($media);
873
	$metadataToPrint = theme('cdm_media_caption', $media);
874
	$out .= $metadataToPrint;
875

    
876

    
877
	//tabs for the different representations
878
	//ul.secondary
879
	$out .= '<ul class="primary">';
880
	foreach($media->representations as $representation){
881
		$out .= '<li>'.l($media->representations[$representationIdx]->mimeType, path_to_media($media->uuid, $mediarepresentation_uuid, $partIdx)).'</li>';
882
	}
883
	$out .= '</ul>';
884

    
885
	// representation(-part) specific metadata
886
	$thumbnailMaxExtend = 100;
887
	$out .= '<table>';
888
	//$out .= '<tr><th colspan="3">'.t('MimeType').': '.$media->representations[$representationIdx]->mimeType.'</th></tr>';
889
	$i = 0;
890
	foreach($media->representations[$representationIdx]->parts as $part){
891
		$out .= '<tr><th>'.t('Part').' '.($i + 1).'</th><td>';
892
		switch($part->class){
893
			case 'ImageFile': $out .= $part->width.' x '.$part->height.' - '.$part->size.'k'; break;
894
			case 'AudioFile':
895
			case 'MovieFile': $out .= t('Duration').': '.$part->duration.'s - '.$part->size.'k'; break;
896
			default: $out .= $part->size.'k';
897
		}
898
		$out .= '</td><td><a href="'.url(path_to_media($media->uuid, $mediarepresentation_uuid, $i)).'">'
899
		  .theme('cdm_media_gallerie_image', $part, $thumbnailMaxExtend, true);'</a></td><tr>';
900
		$i++;
901
	}
902
	$out .= '</table>';
903
	$out .= '</div>';
904

    
905
	return $out;
906
}
907

    
908
/**
909
 * Allows theming of the taxon page tabs
910
 *
911
 * @param $tabname
912
 * @return unknown_type
913
 */
914
function theme_cdm_taxonpage_tab($tabname){
915
	//TODO replace by using translations or theme the menue tabs itself instead?
916
	switch($tabname){
917
		default: return t($tabname);
918
	}
919
}
920

    
(6-6/8)