Project

General

Profile

« Previous | Next » 

Revision 344ba84d

Added by Francisco Revilla over 13 years ago

fising ticket #1804

View differences:

modules/cdm_dataportal/theme/cdm_dataportal.page.theme
85 85
		$hideTabs[] = theme('cdm_taxonpage_tab', 'Images');
86 86
	}
87 87

  
88
//	$descriptionElementCount = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS_ELEMENTSBYTYPE, array($taxon->uuid, 'IndividualsAssociation'), "count=true");
89
//	if($descriptionElementCount->Integer < 0) { //DEBUG HACK
90
   // ### sending the same query twice is faster than two different ones, $descriptionElements will be retrieved again in the specimens page
88
	//	$descriptionElementCount = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS_ELEMENTSBYTYPE, array($taxon->uuid, 'IndividualsAssociation'), "count=true");
89
	//	if($descriptionElementCount->Integer < 0) { //DEBUG HACK
90
	// ### sending the same query twice is faster than two different ones, $descriptionElements will be retrieved again in the specimens page
91 91
	$descriptionElements = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS_ELEMENTSBYTYPE, array($taxon->uuid, 'IndividualsAssociation'));
92
  $descriptionElementCount = is_array($descriptionElements) ? count($descriptionElements) : 0;
92
	$descriptionElementCount = is_array($descriptionElements) ? count($descriptionElements) : 0;
93 93
	if($descriptionElementCount == 0) {
94
    $hideTabs[] = theme('cdm_taxonpage_tab', 'Specimens');
95
  }
94
		$hideTabs[] = theme('cdm_taxonpage_tab', 'Specimens');
95
	}
96 96

  
97 97
	// hideImage flag depending on administative preset
98 98
	$hideImages = false;
......
135 135
  				$structured_description_featuretree_uuid = variable_get(CDM_DATAPORTAL_STRUCTURED_DESCRIPTION_FEATURETREE_UUID, false);
136 136
  				$naturallanguage_textData = cdm_ws_get(CDM_WS_DESCRIPTION_NATURALLANGUAGE_DESCRIPTION, array($taxonDescription->uuid, $structured_description_featuretree_uuid));
137 137
  				if(!$naturallanguage_textData){
138
            drupal_set_message('The \'FeatureTree\' for the generation of natural language representations is not configured correctly, please select a \'FeatureTree\' in the '.l('CDM Dataportal Settings', 'admin/settings/cdm_dataportal/layout'), 'warning');
138
  					drupal_set_message('The \'FeatureTree\' for the generation of natural language representations is not configured correctly, please select a \'FeatureTree\' in the '.l('CDM Dataportal Settings', 'admin/settings/cdm_dataportal/layout'), 'warning');
139 139
  				}
140 140
  				$taxonDescription->elements = null;
141 141
  				$taxonDescription->elements = array($naturallanguage_textData);
......
162 162
  	// get the image gallery as configured by the admin
163 163
  	$taxon_image_gallery = call_user_func_array(
164 164
	    'taxon_image_gallery_' . variable_get('image_gallery_viewer', 'default'),
165
	    array($taxon, $media));
165
  	array($taxon, $media));
166 166
  	$out .= $taxon_image_gallery;
167 167

  
168 168
  	$out .= '</div>';
......
228 228

  
229 229
	RenderHints::pushToRenderStack('taxon_page_specimens');
230 230

  
231
  $descriptionElements = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS_ELEMENTSBYTYPE, array($taxon->uuid, 'IndividualsAssociation') );
232

  
233
  //collect media (fieldObjectMedia, derivedUnitMedia) and add as fields
234
  foreach($descriptionElements as $descriptionElement) {
235
  	if($descriptionElement->associatedSpecimenOrObservation){
236
	  	$descriptionElement->_fieldObjectMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array($descriptionElement->associatedSpecimenOrObservation->uuid, 'fieldObjectMedia') );
237
	  	$descriptionElement->_derivedUnitMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array($descriptionElement->associatedSpecimenOrObservation->uuid, 'derivedUnitMedia') );
238
//	  	$derivedUnitFacde = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array($descriptionElement->associatedSpecimenOrObservation->uuid) );
239
//	  	$descriptionElement->_titleCache = $derivedUnitFacde->titleCache;
240
  	}
241
  }
231
	$descriptionElements = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS_ELEMENTSBYTYPE, array($taxon->uuid, 'IndividualsAssociation') );
242 232

  
243
  if(variable_get('cdm_dataportal_map_openlayers', 1)){
244
    $occurrenceQuery = cdm_ws_get(CDM_WS_GEOSERVICE_OCCURRENCEMAP, $taxon->uuid);
245
    $occurrenceQuery = $occurrenceQuery->String;
246
    $out .= get_openlayers_map(variable_get('cdm_dataportal_geoservice_display_width', false), $occurrenceQuery);
247
  }
233
	//collect media (fieldObjectMedia, derivedUnitMedia) and add as fields
234
	foreach($descriptionElements as $descriptionElement) {
235
		if($descriptionElement->associatedSpecimenOrObservation){
236
			$descriptionElement->_fieldObjectMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array($descriptionElement->associatedSpecimenOrObservation->uuid, 'fieldObjectMedia') );
237
			$descriptionElement->_derivedUnitMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array($descriptionElement->associatedSpecimenOrObservation->uuid, 'derivedUnitMedia') );
238
			//	  	$derivedUnitFacde = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array($descriptionElement->associatedSpecimenOrObservation->uuid) );
239
			//	  	$descriptionElement->_titleCache = $derivedUnitFacde->titleCache;
240
		}
241
	}
248 242

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

  
250 249

  
251
  if($descriptionElements){
252
  	$out_specimenList = '<table class="specimens">';
253
  	$i = 1;
254
  	foreach($descriptionElements as $descriptionElement) {
255
  		$i++;
256
  		if($descriptionElement->associatedSpecimenOrObservation){
257 250

  
258
  			$mediaList = array();
259
  			if(is_array($descriptionElement->_fieldObjectMedia)){
260
  				$mediaList = array_merge($mediaList, $descriptionElement->_fieldObjectMedia);
261
  			}
262
  		  if(is_array($descriptionElement->_derivedUnitMedia)){
263
          $mediaList = array_merge($mediaList, $descriptionElement->_derivedUnitMedia);
264
        }
265
  			$li = '<tr class="descriptionElement descriptionElement_IndividualsAssociation '.($i%2?'odd':'even').'"><td>' . $descriptionElement->associatedSpecimenOrObservation->titleCache;
266
  			if(count($mediaList) > 0){
267
	  			$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
268
	  			$gallery_name =  $descriptionElement->associatedSpecimenOrObservation->uuid;
269
  				$captionElements = array('#uri'=>t('open media'));
270
	  			$gallery_html = theme(
251
	if($descriptionElements){
252
		$out_specimenList = '<table class="specimens">';
253
		$i = 1;
254
		foreach($descriptionElements as $descriptionElement) {
255
			$i++;
256
			if($descriptionElement->associatedSpecimenOrObservation){
257

  
258
				$mediaList = array();
259
				if(is_array($descriptionElement->_fieldObjectMedia)){
260
					$mediaList = array_merge($mediaList, $descriptionElement->_fieldObjectMedia);
261
				}
262
				if(is_array($descriptionElement->_derivedUnitMedia)){
263
					$mediaList = array_merge($mediaList, $descriptionElement->_derivedUnitMedia);
264
				}
265
				$li = '<tr class="descriptionElement descriptionElement_IndividualsAssociation '.($i%2?'odd':'even').'"><td>' . $descriptionElement->associatedSpecimenOrObservation->titleCache;
266
				if(count($mediaList) > 0){
267
					$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
268
					$gallery_name =  $descriptionElement->associatedSpecimenOrObservation->uuid;
269
					$captionElements = array('#uri'=>t('open media'));
270
					$gallery_html = theme(
271 271
	  			    'cdm_media_gallerie',
272
	            $mediaList,
273
	  		      $gallery_name ,
274
						  $gallery_settings['cdm_dataportal_media_maxextend'],
275
						  $gallery_settings['cdm_dataportal_media_cols'],
276
						  $gallery_settings['cdm_dataportal_media_maxRows'],
277
						  $captionElements, 'LIGHTBOX', null, null);
278
  			} else {
279
  				$gallery_html = '';
280
  			}
281
  			$li .= '</td><td>'.$gallery_html.'</td></tr>';
282
  			$out_specimenList .= $li;
283
  		}
284
  	}
285
  	$out_specimenList .= '</table>';
286
  }
272
					$mediaList,
273
					$gallery_name ,
274
					$gallery_settings['cdm_dataportal_media_maxextend'],
275
					$gallery_settings['cdm_dataportal_media_cols'],
276
					$gallery_settings['cdm_dataportal_media_maxRows'],
277
					$captionElements, 'LIGHTBOX', null, null);
278
				} else {
279
					$gallery_html = '';
280
				}
281
				$li .= '</td><td>'.$gallery_html.'</td></tr>';
282
				$out_specimenList .= $li;
283
			}
284
		}
285
		$out_specimenList .= '</table>';
286
	}
287

  
288
	$out .= drupal_get_form('specimens_search_form');
289
	//$test = specimens_table($descriptionElements);
290
	//$out .= $test;
287 291

  
288
  $out .= $out_specimenList;
292
	$out .= $out_specimenList;
289 293

  
290 294

  
291 295
	RenderHints::popFromRenderStack();
292 296
	return $out;
293 297
}
298

  
299
function specimens_search_form() {
300

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

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

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

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

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

  
294 355
/**
295 356
 * Show whole synonymy for the accepted taxon. Synonymy list is headed by the complete scientific name
296 357
 * of the accepted taxon with nomenclatural reference.
......
318 379
		RenderHints::setFootnoteListKey(RenderHints::getRenderPath() . '-annotations');
319 380
	}
320 381
	//render accepted taxon homotypic synonymy groups or type desygnations
321
	if(!isset($synomymie->homotypicSynonymsByHomotypicGroup[0])){
382
	//if(!isset($synomymie->homotypicSynonymsByHomotypicGroup[0])){
322 383
		//if($addAcceptedTaxon && !isset($synomymie->homotypicSynonymsByHomotypicGroup[0])){
323 384
		// display the type information for the added taxon
324 385
		$typeDesignations = cdm_ws_get(CDM_WS_PORTAL_TAXON_NAMETYPEDESIGNATIONS, $taxon->uuid);
325 386
		if($typeDesignations){
326 387
			$out .= theme('cdm_typedesignations', $typeDesignations);
327 388
		}
328
	} else {
389
	//}
390
	if($synomymie->homotypicSynonymsByHomotypicGroup){
329 391
		// render the homotypicSynonymyGroup including the type information
330
		$out .= theme('cdm_homotypicSynonymyGroup', $synomymie->homotypicSynonymsByHomotypicGroup);
392
    $out .= theme('cdm_homotypicSynonymyGroup', $synomymie->homotypicSynonymsByHomotypicGroup);
331 393
	}
332 394
	//render accepted taxon heterotypic synonymy groups
333 395
	if($synomymie->heterotypicSynonymyGroups) {
......
340 402
		$taxonRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS, $taxon->uuid);
341 403
		$out .= theme('cdm_taxonRelationships', $taxonRelationships);
342 404
	}
343
  //render name relationships
344
  $name_rels_to_show = variable_get('name_relationships_to_show', null);
345
  $skip = array();
346
  if($name_rels_to_show){
347
	  foreach ($name_rels_to_show as $key => $value){
348
	    if ($value === 0){
349
	      $skip[] = $key;
350
	    }
351
	  }
352
	  if (sizeof($name_rels_to_show) != sizeof($skip)){
353
	   $nameRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_TO_NAMERELATIONS, $taxon->uuid);
354
	   $out .= theme('cdm_nameRelationships', $nameRelationships, $skip);
355
	  }
356
  }
357
  /*
358
  if(variable_get(CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_DEFAULT)){
359
    $nameRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_TO_NAMERELATIONS, $taxon->uuid);
360
    // TODO is it correct to skip relationsFromThisName since all relationships are to be understood as 'is .... of'
361
    if(variable_get('cdm_dataportal_name_relations_skiptype_basionym', 1)){
362
      $skip = array(UUID_BASIONYM);
363
    }
364
    $out .= theme('cdm_nameRelationships', $nameRelationships, $skip);
365
  }
366
  */
405
	//render name relationships
406
	$name_rels_to_show = variable_get('name_relationships_to_show', null);
407
	$skip = array();
408
	if($name_rels_to_show){
409
		foreach ($name_rels_to_show as $key => $value){
410
			if ($value === 0){
411
				$skip[] = $key;
412
			}
413
		}
414
		if (sizeof($name_rels_to_show) != sizeof($skip)){
415
			$nameRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_TO_NAMERELATIONS, $taxon->uuid);
416
			$out .= theme('cdm_nameRelationships', $nameRelationships, $skip);
417
		}
418
	}
419
	/*
420
	 if(variable_get(CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_DEFAULT)){
421
	 $nameRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_TO_NAMERELATIONS, $taxon->uuid);
422
	 // TODO is it correct to skip relationsFromThisName since all relationships are to be understood as 'is .... of'
423
	 if(variable_get('cdm_dataportal_name_relations_skiptype_basionym', 1)){
424
	 $skip = array(UUID_BASIONYM);
425
	 }
426
	 $out .= theme('cdm_nameRelationships', $nameRelationships, $skip);
427
	 }
428
	 */
367 429
	RenderHints::popFromRenderStack();
368 430

  
369 431
	return $out;
......
379 441
 */
380 442
function taxon_image_gallery_default($taxon, $media){
381 443

  
382
	 $hasImages = isset($media[0]);
383

  
384
  if($hasImages){
385
    //
386
    $maxExtend = 150;
387
    $cols = 3;
388
    $maxRows = false;
389
    $alternativeMediaUri = null;
390
    $captionElements = array('title', 'rights', '#uri'=>t('open Image'));
391
    $gallery_name = $taxon->uuid;
392
    $mediaLinkType = 'LIGHTBOX';
393

  
394
    $gallery_settings = getGallerySettings(CDM_DATAPORTAL_MEDIA_GALLERY_NAME);
395

  
396
    $out = '<div class="image-gallerie">';
397
    $out .= theme('cdm_media_gallerie', $media,
398
        $gallery_name,
399
        $gallery_settings['cdm_dataportal_media_maxextend'],
400
        $gallery_settings['cdm_dataportal_media_cols'],
401
        0, // ignore maxrows settings
402
        $captionElements,
403
        $mediaLinkType,
404
        null);
405
    $out .= '</div>';
406
  }else{
407
    $out = 'No images available.';
444
	$hasImages = isset($media[0]);
445

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

  
456
		$gallery_settings = getGallerySettings(CDM_DATAPORTAL_MEDIA_GALLERY_NAME);
457

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

  
409
  }
410
  return $out;
471
	}
472
	return $out;
411 473

  
412 474
}
413 475

  
......
420 482
 */
421 483
function taxon_image_gallery_fsi($taxon, $media){
422 484

  
423
  $flashLink = isset($media[0]);
485
	$flashLink = isset($media[0]);
424 486

  
425
  if($flashLink){
487
	if($flashLink){
426 488

  
427
    $taggedName = $taxon->name->taggedName;
489
		$taggedName = $taxon->name->taggedName;
428 490

  
429
    $nameArray = array();
430
    foreach($taggedName as $taggedText){
431
      if($taggedText->type == 'name'){
432
        $nameArray[] = $taggedText->text;
433
      }
434
    }
491
		$nameArray = array();
492
		foreach($taggedName as $taggedText){
493
			if($taggedText->type == 'name'){
494
				$nameArray[] = $taggedText->text;
495
			}
496
		}
435 497

  
436
    $query = join("%5F", $nameArray) . '%20AND%20EditWP6%20AND%20jpg';
498
		$query = join("%5F", $nameArray) . '%20AND%20EditWP6%20AND%20jpg';
437 499

  
438
    $out = '
500
		$out = '
439 501

  
440 502
<script type="text/javascript" src="http://media.bgbm.org/erez/js/fsiwriter.js"></script>
441 503

  
......
469 531

  
470 532
</noscript>';
471 533

  
472
  }else{
473
    $out = 'No images available.';
534
	}else{
535
		$out = 'No images available.';
474 536

  
475
  }
476
  return $out;
537
	}
538
	return $out;
477 539

  
478 540
}
479 541
/**

Also available in: Unified diff