Project

General

Profile

Download (21.2 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
 * This function prints the lectotype citation with the correct layout
15
 * Lectotypes are renderized in the synonymy tab of a taxon if they exist
16
 * @param $typeDesignation_citation The lectotype citation to print
17
 * @return html valid string
18
 */
19
function type_designation_citation_layout($typeDesignation, $footnote_separator = ','){
20
	$res = '';
21
	$citation = $typeDesignation->citation;
22
	$pages = $typeDesignation->citationMicroReference;
23

    
24
	if ($typeDesignation->typeStatus->uuid == UUID_ORIGINAL_DESIGNATION ||
25
	$typeDesignation->typeStatus->uuid == UUID_MONOTYPE){
26
		$res = ' ('. $typeDesignation->typeStatus->representation_L10n . ')';
27
		return $res;
28
	}
29

    
30
	if ($citation){
31
		//$type = $typeDesignation_citation->type;
32
	$year = substr($citation->datePublished->start, 0, 4);
33
	$author = $citation->authorTeam->titleCache;
34
	$res .= ' (designated by ';
35
	$res .= $author;
36
	$res .= ($year ? ' '.$year : '');
37
	$res .= ($pages ? ': '. $pages : '');
38
	//$res .= ')';
39

    
40
	$fkey_typeDesignation = FootnoteManager::addNewFootnote(RenderHints::getRenderPath() . '-typeDesignations', $typeDesignation->citation->titleCache);
41
	$res .= theme('cdm_footnote_key', $fkey_typeDesignation, $footnote_separator, true, true) . ')';
42

    
43
}
44
return $res;
45
}
46

    
47
function contains_type_designation ($element, $collection){
48
    $result = false;
49
    foreach ($collection as $a){
50
    	if($a->uuid == $element->uuid){
51
    		$result = true;
52
    	}
53
    }
54
    return $result;
55
}
56

    
57
function cdm_add_type_designations ($source, $extra) {
58
	if (is_array($source)){
59
	   $result = $source;
60
        if ($extra){
61
            foreach ($extra as $element) { 
62
                if (!contains_type_designation($element, $source)){
63
                $result[] = $element;
64
            }
65
        }
66
    }
67
	}else {
68
		$result = $extra;
69
	}
70
  
71
    return $result;
72
}
73

    
74
function theme_cdm_typedesignations($typeDesignations = array()){
75
	/*
76
	 if(isset($renderTemplate['referencePart']['reference']) && $taxonName->nomenclaturalReference){
77
	 $microreference = null;
78
	 if(isset($renderTemplate['referencePart']['microreference'])){
79
	 $microreference = $taxonName->nomenclaturalMicroReference;
80
	 }
81
	 $citation = cdm_ws_get(CDM_WS_NOMENCLATURAL_REFERENCE_CITATION, array($typeDesignation->uuid), "microReference=".urlencode($microreference));
82
	 $citation = $citation->String;
83
	 */
84

    
85
	//RenderHints::pushToRenderStack('typedesignations');
86
	//_add_js_cluetip();
87
	$out = '<ul class="typeDesignations">';
88
	$typeDesignation_footnotes = false;
89
	$is_lectotype = false;
90
	$specimenTypeDesignations = array();
91
	$separator = ',';
92
	foreach($typeDesignations as $typeDesignation){
93
		if($typeDesignation->class == 'SpecimenTypeDesignation'){
94
			// SpecimenTypeDesignations should be ordered. collect theme here only
95
			$specimenTypeDesignations[] = $typeDesignation;
96
		}else{ //it is a lectotype?
97
			if(strcmp($typeDesignation->typeStatus->titleCache, 'lectotype') == 0){
98
				$is_lectotype = true;
99
			}
100
			// it's a NameTypeDesignation
101
			if($typeDesignation->notDesignated){
102
				$out .= '<li class="nameTypeDesignation"><span class="status">' . ($is_lectotype ? 'Lectotype' : 'Type') . '</span>: ' . t('not designated'). '</li>';
103
				//$out .= '<li class="nameTypeDesignation"><span class="status">Lectotype</span>: '.t('not designated'). '</li>';
104
			}else if($typeDesignation->typeName){
105
				$link_to_name_page = '?q=' . path_to_name($typeDesignation->typeName->uuid);
106
				$out .= '<li class="nameTypeDesignation"><span class="status">' . ($is_lectotype ? 'Lectotype' : 'Type') . '</span>';
107

    
108
				if($typeDesignation->citation){
109
					$out .= type_designation_citation_layout($typeDesignation, $separator);
110
					//footnotes
111
					//$fkey_typeDesignation = FootnoteManager::addNewFootnote(RenderHints::getRenderPath() . '-typeDesignations-' . $typeDesignation->uuid, $typeDesignation->citation->titleCache);
112
					/*
113
				  $fkey_typeDesignation = FootnoteManager::addNewFootnote(RenderHints::getRenderPath() . '-typeDesignations', $typeDesignation->citation->titleCache);
114
				  $out .= theme('cdm_footnote_key', $fkey_typeDesignation, $separator, true, true) . ')';
115
				  */
116
				}
117
				if($typeDesignation->typeName->nomenclaturalReference){
118
					$referenceUri = url(path_to_reference($typeDesignation->typeName->nomenclaturalReference->uuid));
119
				}
120
				$out .= ': ' . theme('cdm_taxonName', $typeDesignation->typeName, $link_to_name_page, $referenceUri, true, true);
121
			}
122
		}
123
	}
124

    
125
	if(!empty($specimenTypeDesignations)){
126
		// sorting might be different for dataportals so this has to be parameterized
127
		usort($specimenTypeDesignations, "compare_specimenTypeDesignationStatus");
128
		foreach($specimenTypeDesignations as $std){
129
			$typeReference = '';
130
			//show citation only for Lectotype or Neotype
131
			$showCitation = isset($std->typeStatus) && ($std->typeStatus->uuid == UUID_NEOTYPE || $std->typeStatus->uuid == UUID_LECTOTYPE);
132
			if($showCitation && !empty($std->citation)){
133
				//$shortCitation = $std->citation->authorTeam->titleCache;
134

    
135
				$author_team = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $std->citation->uuid);
136
				$shortCitation = $author_team->titleCache;
137

    
138
				$shortCitation .= (strlen($shortCitation) > 0 ? ' ' : '' ). partialToYear($std->citation->datePublished->start);
139
				if(strlen($shortCitation) == 0){
140
					$shortCitation = theme('cdm_reference', $std->citation);
141
					$missingShortCitation = true;
142
				}
143

    
144
				$typeReference .= '&nbsp;(' . t('designated by');
145
				$typeReference .= '&nbsp;<span class="typeReference '.($missingShortCitation ? '' : 'cluetip').' no-print" title="'. htmlspecialchars('|'.theme('cdm_reference',$std->citation ).'|') .'">';
146
				$typeReference .= $shortCitation.'</span>';
147
				$typeReference .= ':'. $std->citationMicroReference .')';
148

    
149
				$_fkey2 = FootnoteManager::addNewFootnote(RenderHints::getRenderPath() . '-lectotypes', $std->citation->titleCache);
150
				$typeReference .= theme('cdm_footnote_key', $_fkey2, $separator, true, true);
151
			}
152

    
153
			$derivedUnitFacadeInstance = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, $std->typeSpecimen->uuid);
154

    
155
			$out .= '<li class="specimenTypeDesignation">';
156
			$out .= '<span class="status">'
157
			.(($std->typeStatus->representation_L10n) ? $std->typeStatus->representation_L10n : t('Type'))
158
			.$typeReference.'</span>: '.$derivedUnitFacadeInstance->titleCache;
159
			$out .= theme('cdm_specimen', $derivedUnitFacadeInstance);
160

    
161
			//footnotes for synonymy acronyms
162
			$_fkey = FootnoteManager::addNewFootnote(RenderHints::getRenderPath() . '-acronyms', $derivedUnitFacadeInstance->collection->titleCache);
163
			$out .= theme('cdm_footnote_key', $_fkey, $separator);
164
			$out .= '</li>';
165

    
166
			if (!empty($std->citation)){
167
				$render_footnote_lectotypes = true;
168
			 //$out .= theme('cdm_footnotes', RenderHints::getRenderPath() . '-lectotypes');
169
			}
170
		}
171
	}
172

    
173
	$out .= '</ul>';
174
	
175
	//render the footnotes at the end of the page
176
	if ($render_footnote_lectotypes){
177
		$out .= theme('cdm_footnotes', RenderHints::getRenderPath() . '-lectotypes');
178
	}
179
	$out .= theme('cdm_footnotes', RenderHints::getRenderPath() . '-acronyms', 'li');
180
	$out .= theme('cdm_footnotes', RenderHints::getRenderPath() . '-typeDesignations', 'li');
181
	//$out .= theme('cdm_footnotes', RenderHints::getRenderPath() . '-typeDesignations-' . $typeDesignation->uuid, 'li');
182

    
183
	RenderHints::popFromRenderStack();
184

    
185
	return $out;
186
}
187

    
188

    
189
/**
190
 * FIXME this definitively has to be in another spot. just didn't know where to put it right now.
191
 * Compares the status of two SpecimenTypeDesignations
192
 * @param String $a 	a SpecimenTypeDesignations
193
 * @param String $b		another SpecimenTypeDesignations
194
 */
195
function compare_specimenTypeDesignationStatus($a, $b){
196
	/* this is the desired sort oder as of now:
197
	 * 	Holotype
198
	 * 	Isotype
199
	 * 	Lectotype
200
	 * 	Isolectotype
201
	 * 	Syntype
202
	 *
203
	 * TODO
204
	 * Basically, what we are trying to do is, we define an ordered array of TypeDesignation-states
205
	 * and use the index of this array for comparison. This array has to be filled with the cdm-
206
	 * TypeDesignation states and the order should be parameterisable inside the dataportal.
207
	 */
208
	// make that static for now
209
	$typeOrder = array('Holotype', 'Isotype', 'Lectotype', 'Isolectotype', 'Syntype');
210

    
211
	$aQuantifier = array_search($a->typeStatus->label, $typeOrder);
212
	$bQuantifier = array_search($b->typeStatus->label, $typeOrder);
213

    
214
	if ($aQuantifier == $bQuantifier) {
215
		// sort alphabetically
216
		return ($a->typeStatus->label < $b->typeStatus->label) ? -1 : 1;
217
	}
218
	return ($aQuantifier < $bQuantifier) ? -1 : 1;
219

    
220
}
221

    
222
function theme_cdm_nameRelationships($nameRelationships, $skipTypes = false){
223

    
224
	if(!$nameRelationships){
225
		return;
226
	}
227

    
228
	RenderHints::pushToRenderStack('nameRelationships');
229
	$footnoteListKey = 'nameRelationships';
230
	RenderHints::setFootnoteListKey($footnoteListKey);
231

    
232
	// group by relationship type
233
	$relationshipGroups = array();
234
	foreach($nameRelationships as $nameRelationship){
235
		if(!array_key_exists($nameRelationship->type->uuid, $relationshipGroups)){
236
			$relationshipGroups[$nameRelationship->type->uuid] = array();
237
		}
238
		$relationshipGroups[$nameRelationship->type->uuid][] = $nameRelationship;
239
	}
240

    
241
	// generate output
242
	$out = '';
243
	foreach($relationshipGroups as $group){
244
		$type = $group[0]->type;
245

    
246
		if(is_array($skipTypes) && in_array($type->uuid, $skipTypes)){
247
			continue;
248
		}
249

    
250
		$block->module = 'cdm_dataportal';
251
		$block->subject = t(ucfirst($type->inverseRepresentation_L10n));
252
		$block->delta = generalizeString(strtolower($type->inverseRepresentation_L10n));
253

    
254
		foreach($group as $relationship){
255
			$relatedNames[] = cdm_taggedtext2html($relationship->fromName->taggedName);
256
		}
257

    
258
		$block->content .= implode('; ', $relatedNames);
259
		$out .= theme('block', $block);
260
	}
261
	$out .= theme('cdm_footnotes', $footnoteListKey, 'li');
262

    
263
	RenderHints::popFromRenderStack();
264
	return $out;
265
}
266

    
267

    
268

    
269
function theme_cdm_homotypicSynonymLine($taxon){
270
	$out = '';
271
	$out .= '<li class="synonym">'.theme('cdm_related_taxon', $taxon, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
272

    
273
	return $out;
274
}
275

    
276
function theme_cdm_heterotypicSynonymyGroup($homotypicalGroup){
277

    
278
	RenderHints::pushToRenderStack('heterotypicSynonymyGroup');
279

    
280
	$out = '';
281
	$out = '<ul class="heterotypicSynonymyGroup">';
282
	$footnoteListKey = ( isset($homotypicalGroup[0]) ? $homotypicalGroup[0]->uuid : 'NULL');
283
	RenderHints::setFootnoteListKey($footnoteListKey);
284

    
285
	$is_first_entry = true;
286
	$typeDesignations = null;
287
	foreach($homotypicalGroup as $synonym){
288
		if($is_first_entry){
289
			$is_first_entry = false;
290
			$typeDesignations = cdm_ws_get(CDM_WS_PORTAL_NAME_TYPEDESIGNATIONS, $synonym->name->uuid);
291
			// is first list entry
292
			$out .= '<li class="firstentry synonym">'.theme('cdm_related_taxon',$synonym, UUID_HETEROTYPIC_SYNONYM_OF).'</li>';
293
		} else {
294
			$out .= '<li class="synonym">'.theme('cdm_related_taxon',$synonym, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
295
		}
296
	}
297
	//$test =  theme('cdm_annotation_footnotes', $footnoteListKey, 'li');
298
	//tuypedesignations footnotes
299

    
300
	if($typeDesignations){
301
		$out .= theme('cdm_typedesignations', $typeDesignations);
302

    
303
	}
304

    
305
	//annotation footnotes
306
	//$annotation_key = ( isset($homotypicalGroup[0]) ? $homotypicalGroup[0]->uuid : 'NULL');
307
	//$fkey_annotations = FootnoteManager::addNewFootnote(RenderHints::getRenderPath() . '-annotations-' . $annotation_key, $annotation_key);
308
	//$out .= theme('cdm_footnotes', RenderHints::getRenderPath() . '-annotations-' . $annotation_key);
309
	$out .= theme('cdm_annotation_footnotes', $footnoteListKey, 'li');
310
	//$out .= theme('cdm_annotation_footnotes', $footnoteListKey);
311
	$out .= '</ul>';
312

    
313

    
314
	RenderHints::popFromRenderStack();
315
	return $out;
316
}
317

    
318

    
319

    
320
function theme_cdm_homotypicSynonymyGroup($synonymList, $accepted_taxon_uuid, $prependedSynonyms = array()){
321

    
322
	RenderHints::pushToRenderStack('homotypicSynonymyGroup');
323

    
324
	$footnoteListKey = isset($prependedSynonyms[0]) ? $prependedSynonyms[0]->uuid : (isset($synonymList[0]) ? $synonymList[0]->uuid : 'NULL');
325
	$accepted_taxon_footnoteListKey = RenderHints::getFootnoteListKey();
326
	RenderHints::setFootnoteListKey($footnoteListKey);
327

    
328
	if(! is_array($synonymList) || count($synonymList) == 0){
329
		return;
330
	}
331

    
332
	$out = '<ul class="homotypicSynonyms">';
333

    
334
	if(!empty($prependedSynonyms)){
335
		foreach($prependedSynonyms as $taxon){
336
			$out .= '<li class="synonym">'.theme('cdm_related_taxon', $taxon, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
337
		}
338
	}
339

    
340
	foreach($synonymList as $synonym){
341
		$out .= '<li class="synonym">'.theme('cdm_related_taxon', $synonym, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
342
	}
343
	
344
	$homonym_typeDesignations = cdm_ws_get(CDM_WS_PORTAL_NAME_TYPEDESIGNATIONS, $synonymList[0]->name->uuid);
345
    $accepted_typeDesignations = cdm_ws_get(CDM_WS_PORTAL_TAXON_NAMETYPEDESIGNATIONS, $accepted_taxon_uuid);
346
    if($accepted_typeDesignations){
347
        $typeDesignations = cdm_add_type_designations($homonym_typeDesignations, $accepted_typeDesignations);
348
    }else {
349
    	$typeDesignations = $homonym_typeDesignations;
350
    }
351
	if($typeDesignations){
352
		$out .= theme('cdm_typedesignations', $typeDesignations);
353
	}
354
	if($accepted_taxon_footnoteListKey){// to avoiding drupal warnings (#1830) why false???
355
		$out .= theme('cdm_footnotes', $accepted_taxon_footnoteListKey, 'li');
356
	}
357
	
358
	$out .= theme('cdm_annotation_footnotes', $footnoteListKey, 'li');
359
	$out .= '</ul>';
360

    
361
	RenderHints::popFromRenderStack();
362
	return $out;
363
}
364

    
365

    
366
function theme_cdm_taxonName($taxonName, $nameLink = NULL, $refenceLink = NULL,
367
	$show_annotations = true, $is_type_designation = false, $skiptags = array()){
368

    
369
	$renderTemplate = get_nameRenderTemplate(RenderHints::getRenderPath(), $nameLink, $refenceLink);
370
	$partDefinition = get_partDefinition($taxonName->class);
371

    
372
	// apply defintions to template
373
	foreach($renderTemplate as $part=>$uri){
374
		if(isset($partDefinition[$part])){
375
			$renderTemplate[$part] = $partDefinition[$part];
376
		}
377
		if(is_array($uri)){
378
			$renderTemplate[$part]['#uri'] = $uri['#uri'];
379
		}
380
	}
381

    
382
	$firstEntryIsValidNamePart = is_array($taxonName->taggedName)
383
	&& is_string($taxonName->taggedName[0]->text)
384
	&& $taxonName->taggedName[0]->text != ''
385
	&& $taxonName->taggedName[0]->type == 'name';
386

    
387
	// got to use second entry as first one, see ToDo comment below ...
388
	if($firstEntryIsValidNamePart){
389

    
390
		$taggedName = $taxonName->taggedName;
391

    
392
		$lastAuthorElementString = false;
393
		$hasNamePart_with_Authors = isset($renderTemplate['namePart']) && isset($renderTemplate['namePart']['authors']);
394
		$hasNameAuthorPart_with_Authors = isset($renderTemplate['nameAuthorPart']) && isset($renderTemplate['nameAuthorPart']['authors']);
395

    
396
		if(!($hasNamePart_with_Authors || $hasNameAuthorPart_with_Authors)){
397
			//      // find author and split off from name
398
			//      // TODO expecting to find the author as the last element
399
			//      if($taggedName[count($taggedName)- 1]->type == 'authors'){
400
			//        $authorTeam = $taggedName[count($taggedName)- 1]->text;
401
			//        unset($taggedName[count($taggedName)- 1]);
402
			//      }
403

    
404
			// remove all authors
405
			$taggedNameNew = array();
406
			foreach($taggedName as $element){
407
				if($element->type != 'authors'){
408
					$taggedNameNew[] = $element;
409
				} else {
410
					$lastAuthorElementString = $element->text;
411
				}
412
			}
413
			$taggedName = $taggedNameNew;
414

    
415
		}
416
		$name = '<span class="'.$taxonName->class.'">'.theme('cdm_taggedtext2html', $taggedName, 'span', ' ', $skiptags).'</span>';
417
	} else {
418
		$name = '<span class="'.$taxonName->class.'_titleCache">'.$taxonName->titleCache.'</span>';
419
	}
420

    
421
	// fill name into $renderTemplate
422
	array_setr('name', $name, $renderTemplate);
423

    
424
	//  // fill with authorTeam
425
	//  if($authorTeam){
426
	//    $authorTeamHtml = ' <span class="authorTeam">'.$authorTeam.'</span>';
427
	//    array_setr('authorTeam', $authorTeamHtml, $renderTemplate);
428
	//  }
429

    
430
	// fill with reference
431
	if(isset($renderTemplate['referencePart']) && !$is_type_designation){
432

    
433
		// [Eckhard]:"Komma nach dem Taxonnamen ist grunsätzlich falsch,
434
		// Komma nach dem Autornamen ist überall dort falsch, wo ein "in" folgt."
435
		if(isset($renderTemplate['referencePart']['reference']) && $taxonName->nomenclaturalReference){
436
			$microreference = null;
437
			if(isset($renderTemplate['referencePart']['microreference'])){
438
				$microreference = $taxonName->nomenclaturalMicroReference;
439
			}
440
			$citation = cdm_ws_get(CDM_WS_NOMENCLATURAL_REFERENCE_CITATION, array($taxonName->nomenclaturalReference->uuid), "microReference=".urlencode($microreference));
441
			$citation = $citation->String;
442
			// find preceding element of the refrence
443
			$precedingKey = get_preceding_contentElementKey('reference', $renderTemplate);
444
			if(str_beginsWith($citation, ", in")){
445
				$citation = substr($citation, 2);
446
				$separator = ' ';
447
			} else if(!str_beginsWith($citation, "in") && $precedingKey == 'authors'){
448
				$separator = ', ';
449
			} else {
450
				$separator = ' ';
451
			}
452

    
453
			$referenceArray['#separator'] = $separator;
454
			$referenceArray['#html'] = '<span class="reference">'.$citation.'</span>';
455
			array_setr('reference', $referenceArray, $renderTemplate);
456
		}
457

    
458
		// if authors have been removed from the name part the last named authorteam
459
		// should be added to the reference citation, otherwise, keep the separator
460
		// out of the reference
461
		if(isset($renderTemplate['referencePart']['authors']) && $lastAuthorElementString){
462
			// if the nomenclaturalReference cintation is not included in the reference part but diplay of the microreference
463
			// is whanted append the microreference to the authorTeam
464
			if(!isset($renderTemplate['referencePart']['reference']) && isset($renderTemplate['referencePart']['microreference'])){
465
				$separator = ": ";
466
				$citation = $taxonName->nomenclaturalMicroReference;
467
			}
468
			$referenceArray['#html'] = ' <span class="reference">'.$lastAuthorElementString.$separator.$citation.'</span>';
469
			array_setr('authors', $referenceArray, $renderTemplate);
470
		}
471

    
472
	}
473

    
474
	// fill with status
475
	if(is_array($taxonName->status)){
476
		if(array_setr('status', true, $renderTemplate)){
477
			if(isset($taxonName->status[0])){
478
				foreach($taxonName->status as $status){
479
					$statusHtml .= ', '.$status->type->representation_L10n_abbreviated;
480
				}
481
			}
482
			array_setr('status', ' <span class="nomenclatural_status">'.$statusHtml.'</span>', $renderTemplate);
483
		}
484
	}
485

    
486
	// fill with protologues etc...
487
	if(array_setr('description', true, $renderTemplate)){
488
		$descriptions = cdm_ws_get(CDM_WS_PORTAL_NAME_DESCRIPTIONS, $taxonName->uuid);
489
		foreach($descriptions as $description){
490
			if(!empty($description)){
491
				foreach($description->elements as $description_element){
492
					$second_citation = '';
493
					if ($description_element->multilanguageText_L10n->text){
494
						$second_citation = '[& ' . $description_element->multilanguageText_L10n->text . '].';
495
					}
496
					$descriptionHtml .= $second_citation;
497
					$descriptionHtml .= theme("cdm_media", $description_element, array('application/pdf', 'image/png', 'image/jpeg', 'image/gif', 'text/html'));
498
				}
499
			}
500
		}
501
		array_setr('description', $descriptionHtml, $renderTemplate);
502
	}
503

    
504
	// render
505
	$out = '<span ref="/name/'.$taxonName->uuid.'">';
506

    
507
	foreach($renderTemplate as $partName=>$part){
508
		$separator = '';
509
		$partHtml = '';
510
		$uri = false;
511
		if(!is_array($part)){
512
			continue;
513
		}
514
		if(isset($part['#uri']) && is_string($part['#uri'])){
515
			$uri = $part['#uri'];
516
			unset($part['#uri']);
517
		}
518
		foreach($part as $key=>$content){
519
			$html = '';
520
			if(is_array($content)){
521
				$html = $content['#html'];
522
				$separator = $content['#separator'];
523
			} else if(is_string($content)){
524
				$html = $content;
525
			}
526
			$partHtml .= '<span class="'.$key.'">'.$html.'</span>';
527
		}
528
		if($uri){
529
			$out .= $separator.'<a href="'.$uri.'" class="'.$partName.'">'.$partHtml.'</a>';
530
		} else {
531
			$out .= $separator.$partHtml;
532

    
533
		}
534
	}
535
	$out .= '</span>';
536
	if ($show_annotations){
537
		//$out .= theme('cdm_annotations_as_footnotekeys', $taxonName);
538
	}
539
	return $out;
540
}
541

    
542
/**
543
 * Recursively searches the array for the $key and sets the given value
544
 * @param $key
545
 * @param $value
546
 * @param $array
547
 * @return true if the key has been found
548
 */
549
function &array_setr($key, $value, array &$array){
550
	foreach($array as $k=>&$v){
551
		if($key == $k){
552
			$v = $value;
553
			return $array;
554
		} else if(is_array($v)){
555
			$innerArray = array_setr($key, $value, $v);
556
			if($innerArray){
557
				return $array;
558
			}
559
		}
560
	}
561
	return null;
562
}
563

    
564
function &get_preceding_contentElement($contentElementKey, array &$renderTemplate){
565
	$precedingElement = null;
566
	foreach($renderTemplate as &$part){
567
		foreach($part as $key=>&$element){
568
			if($key == $contentElementKey){
569
				return $precedingElement;
570
			}
571
			$precedingElement = $element;
572
		}
573
	}
574
	return null;
575
}
576

    
577
function &get_preceding_contentElementKey($contentElementKey, array &$renderTemplate){
578
	$precedingKey = null;
579
	foreach($renderTemplate as &$part){
580
		if(is_array($part)){
581
			foreach($part as $key=>&$element){
582
				if($key == $contentElementKey){
583
					return $precedingKey;
584
				}
585
				if(!str_beginsWith($key, '#')){
586
					$precedingKey = $key;
587
				}
588
			}
589
		}
590
	}
591
	return null;
592
}
593

    
594

    
595

    
596

    
597

    
598

    
599

    
(4-4/8)