Project

General

Profile

Download (20.3 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 theme_cdm_typedesignations($typeDesignations = array()){
48
	/*
49
	 if(isset($renderTemplate['referencePart']['reference']) && $taxonName->nomenclaturalReference){
50
	 $microreference = null;
51
	 if(isset($renderTemplate['referencePart']['microreference'])){
52
	 $microreference = $taxonName->nomenclaturalMicroReference;
53
	 }
54
	 $citation = cdm_ws_get(CDM_WS_NOMENCLATURAL_REFERENCE_CITATION, array($typeDesignation->uuid), "microReference=".urlencode($microreference));
55
	 $citation = $citation->String;
56
	 */
57

    
58
	RenderHints::pushToRenderStack('typedesignations');
59
	//_add_js_cluetip();
60
	$out = '<ul class="typeDesignations">';
61
	$typeDesignation_footnotes = false;
62
	$is_lectotype = false;
63
	$specimenTypeDesignations = array();
64
	$separator = ',';
65
	foreach($typeDesignations as $typeDesignation){
66
		if($typeDesignation->class == 'SpecimenTypeDesignation'){
67
			// SpecimenTypeDesignations should be ordered. collect theme here only
68
			$specimenTypeDesignations[] = $typeDesignation;
69
		}else{ //it is a lectotype?
70
			if(strcmp($typeDesignation->typeStatus->titleCache, 'lectotype') == 0){
71
				$is_lectotype = true;
72
			}
73
			// it's a NameTypeDesignation
74
			if($typeDesignation->notDesignated){
75
				$out .= '<li class="nameTypeDesignation"><span class="status">' . ($is_lectotype ? 'Lectotype' : 'Type') . '</span>: ' . t('not designated'). '</li>';
76
				//$out .= '<li class="nameTypeDesignation"><span class="status">Lectotype</span>: '.t('not designated'). '</li>';
77
			}else if($typeDesignation->typeName){
78
				$link_to_name_page = '?q=' . path_to_name($typeDesignation->typeName->uuid);
79
				$out .= '<li class="nameTypeDesignation"><span class="status">' . ($is_lectotype ? 'Lectotype' : 'Type') . '</span>';
80
				if($typeDesignation->citation){
81
					$out .= type_designation_citation_layout($typeDesignation, $separator);
82
					//footnotes
83
					//$fkey_typeDesignation = FootnoteManager::addNewFootnote(RenderHints::getRenderPath() . '-typeDesignations-' . $typeDesignation->uuid, $typeDesignation->citation->titleCache);
84
					/*
85
				  $fkey_typeDesignation = FootnoteManager::addNewFootnote(RenderHints::getRenderPath() . '-typeDesignations', $typeDesignation->citation->titleCache);
86
				  $out .= theme('cdm_footnote_key', $fkey_typeDesignation, $separator, true, true) . ')';
87
				  */
88
				}
89
				if($typeDesignation->typeName->nomenclaturalReference){
90
					$referenceUri = url(path_to_reference($typeDesignation->typeName->nomenclaturalReference->uuid));
91
				}
92
				$out .= ': ' . theme('cdm_taxonName', $typeDesignation->typeName, $link_to_name_page, $referenceUri, true, true);
93
			}
94
		}
95
	}
96

    
97
	if(!empty($specimenTypeDesignations)){
98
		// sorting might be different for dataportals so this has to be parameterized
99
		usort($specimenTypeDesignations, "compare_specimenTypeDesignationStatus");
100
		foreach($specimenTypeDesignations as $std){
101
			$typeReference = '';
102
			//show citation only for Lectotype or Neotype
103
			$showCitation = isset($std->typeStatus) && ($std->typeStatus->uuid == UUID_NEOTYPE || $std->typeStatus->uuid == UUID_LECTOTYPE);
104
			if($showCitation && !empty($std->citation)){
105
				//$shortCitation = $std->citation->authorTeam->titleCache;
106

    
107
				$author_team = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $std->citation->uuid);
108
				$shortCitation = $author_team->titleCache;
109

    
110
				$shortCitation .= (strlen($shortCitation) > 0 ? ' ' : '' ). partialToYear($std->citation->datePublished->start);
111
				if(strlen($shortCitation) == 0){
112
					$shortCitation = theme('cdm_reference', $std->citation);
113
					$missingShortCitation = true;
114
				}
115

    
116
				$typeReference .= '&nbsp;(' . t('designated by');
117
				$typeReference .= '&nbsp;<span class="typeReference '.($missingShortCitation ? '' : 'cluetip').' no-print" title="'. htmlspecialchars('|'.theme('cdm_reference',$std->citation ).'|') .'">';
118
				$typeReference .= $shortCitation.'</span>';
119
				$typeReference .= ':'. $std->citationMicroReference .')';
120

    
121
				$_fkey2 = FootnoteManager::addNewFootnote(RenderHints::getRenderPath() . '-lectotypes', $std->citation->titleCache);
122
				$typeReference .= theme('cdm_footnote_key', $_fkey2, $separator, true, true);
123
			}
124

    
125
			$derivedUnitFacadeInstance = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, $std->typeSpecimen->uuid);
126

    
127
			$out .= '<li class="specimenTypeDesignation">';
128
			$out .= '<span class="status">'
129
			.(($std->typeStatus->representation_L10n) ? $std->typeStatus->representation_L10n : t('Type'))
130
			.$typeReference.'</span>: '.$derivedUnitFacadeInstance->titleCache;
131
			$out .= theme('cdm_specimen', $derivedUnitFacadeInstance);
132

    
133
			//footnotes for synonymy acronyms
134
			$_fkey = FootnoteManager::addNewFootnote(RenderHints::getRenderPath() . '-acronyms', $derivedUnitFacadeInstance->collection->titleCache);
135
			$out .= theme('cdm_footnote_key', $_fkey, $separator);
136
			$out .= '</li>';
137

    
138
			if (!empty($std->citation)){
139
				$render_footnote_lectotypes = true;
140
			 //$out .= theme('cdm_footnotes', RenderHints::getRenderPath() . '-lectotypes');
141
			}
142
		}
143
	}
144

    
145
	$out .= '</ul>';
146
	//render the footnotes at the end of the page
147

    
148
	if ($render_footnote_lectotypes){
149
		$out .= theme('cdm_footnotes', RenderHints::getRenderPath() . '-lectotypes');
150
	}
151
	$out .= theme('cdm_footnotes', RenderHints::getRenderPath() . '-acronyms', 'li');
152
	$out .= theme('cdm_footnotes', RenderHints::getRenderPath() . '-typeDesignations', 'li');
153
	//$out .= theme('cdm_footnotes', RenderHints::getRenderPath() . '-typeDesignations-' . $typeDesignation->uuid, 'li');
154

    
155
	RenderHints::popFromRenderStack();
156
	return $out;
157
}
158

    
159

    
160
/**
161
 * FIXME this definitively has to be in another spot. just didn't know where to put it right now.
162
 * Compares the status of two SpecimenTypeDesignations
163
 * @param String $a 	a SpecimenTypeDesignations
164
 * @param String $b		another SpecimenTypeDesignations
165
 */
166
function compare_specimenTypeDesignationStatus($a, $b){
167
	/* this is the desired sort oder as of now:
168
	 * 	Holotype
169
	 * 	Isotype
170
	 * 	Lectotype
171
	 * 	Isolectotype
172
	 * 	Syntype
173
	 *
174
	 * TODO
175
	 * Basically, what we are trying to do is, we define an ordered array of TypeDesignation-states
176
	 * and use the index of this array for comparison. This array has to be filled with the cdm-
177
	 * TypeDesignation states and the order should be parameterisable inside the dataportal.
178
	 */
179
	// make that static for now
180
	$typeOrder = array('Holotype', 'Isotype', 'Lectotype', 'Isolectotype', 'Syntype');
181

    
182
	$aQuantifier = array_search($a->typeStatus->label, $typeOrder);
183
	$bQuantifier = array_search($b->typeStatus->label, $typeOrder);
184

    
185
	if ($aQuantifier == $bQuantifier) {
186
		// sort alphabetically
187
		return ($a->typeStatus->label < $b->typeStatus->label) ? -1 : 1;
188
	}
189
	return ($aQuantifier < $bQuantifier) ? -1 : 1;
190

    
191
}
192

    
193
function theme_cdm_nameRelationships($nameRelationships, $skipTypes = false){
194

    
195
	if(!$nameRelationships){
196
		return;
197
	}
198

    
199
	RenderHints::pushToRenderStack('nameRelationships');
200
	$footnoteListKey = 'nameRelationships';
201
	RenderHints::setFootnoteListKey($footnoteListKey);
202

    
203
	// group by relationship type
204
	$relationshipGroups = array();
205
	foreach($nameRelationships as $nameRelationship){
206
		if(!array_key_exists($nameRelationship->type->uuid, $relationshipGroups)){
207
			$relationshipGroups[$nameRelationship->type->uuid] = array();
208
		}
209
		$relationshipGroups[$nameRelationship->type->uuid][] = $nameRelationship;
210
	}
211

    
212
	// generate output
213
	$out = '';
214
	foreach($relationshipGroups as $group){
215
		$type = $group[0]->type;
216

    
217
		if(is_array($skipTypes) && in_array($type->uuid, $skipTypes)){
218
			continue;
219
		}
220

    
221
		$block->module = 'cdm_dataportal';
222
		$block->subject = t(ucfirst($type->inverseRepresentation_L10n));
223
		$block->delta = generalizeString(strtolower($type->inverseRepresentation_L10n));
224

    
225
		foreach($group as $relationship){
226
			$relatedNames[] = cdm_taggedtext2html($relationship->fromName->taggedName);
227
		}
228

    
229
		$block->content .= implode('; ', $relatedNames);
230
		$out .= theme('block', $block);
231
	}
232
	$out .= theme('cdm_footnotes', $footnoteListKey, 'li');
233

    
234
	RenderHints::popFromRenderStack();
235
	return $out;
236
}
237

    
238

    
239

    
240
function theme_cdm_homotypicSynonymLine($taxon){
241
	$out = '';
242
	$out .= '<li class="synonym">'.theme('cdm_related_taxon', $taxon, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
243

    
244
	return $out;
245
}
246

    
247
function theme_cdm_heterotypicSynonymyGroup($homotypicalGroup){
248

    
249
	RenderHints::pushToRenderStack('heterotypicSynonymyGroup');
250

    
251
	$out = '';
252
	$out = '<ul class="heterotypicSynonymyGroup">';
253
	$footnoteListKey = ( isset($homotypicalGroup[0]) ? $homotypicalGroup[0]->uuid : 'NULL');
254
	RenderHints::setFootnoteListKey($footnoteListKey);
255

    
256
	$is_first_entry = true;
257
	$typeDesignations = null;
258
	foreach($homotypicalGroup as $synonym){
259
		if($is_first_entry){
260
			$is_first_entry = false;
261
			$typeDesignations = cdm_ws_get(CDM_WS_PORTAL_NAME_TYPEDESIGNATIONS, $synonym->name->uuid);
262
			// is first list entry
263
			$out .= '<li class="firstentry synonym">'.theme('cdm_related_taxon',$synonym, UUID_HETEROTYPIC_SYNONYM_OF).'</li>';
264
		} else {
265
			$out .= '<li class="synonym">'.theme('cdm_related_taxon',$synonym, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
266
		}
267
	}
268
	//$test =  theme('cdm_annotation_footnotes', $footnoteListKey, 'li');
269
	//tuypedesignations footnotes
270

    
271
	if($typeDesignations){
272
		$out .= theme('cdm_typedesignations', $typeDesignations);
273

    
274
	}
275

    
276
	//annotation footnotes
277
	//$annotation_key = ( isset($homotypicalGroup[0]) ? $homotypicalGroup[0]->uuid : 'NULL');
278
	//$fkey_annotations = FootnoteManager::addNewFootnote(RenderHints::getRenderPath() . '-annotations-' . $annotation_key, $annotation_key);
279
	//$out .= theme('cdm_footnotes', RenderHints::getRenderPath() . '-annotations-' . $annotation_key);
280
	$out .= theme('cdm_annotation_footnotes', $footnoteListKey, 'li');
281
	//$out .= theme('cdm_annotation_footnotes', $footnoteListKey);
282
	$out .= '</ul>';
283

    
284

    
285
	RenderHints::popFromRenderStack();
286
	return $out;
287
}
288

    
289

    
290

    
291
function theme_cdm_homotypicSynonymyGroup($synonymList, $prependedSynonyms = array()){
292

    
293
	RenderHints::pushToRenderStack('homotypicSynonymyGroup');
294

    
295
	$footnoteListKey = isset($prependedSynonyms[0]) ? $prependedSynonyms[0]->uuid : (isset($synonymList[0]) ? $synonymList[0]->uuid : 'NULL');
296
	$accepted_taxon_footnoteListKey = RenderHints::getFootnoteListKey();
297
	RenderHints::setFootnoteListKey($footnoteListKey);
298

    
299
	if(! is_array($synonymList) || count($synonymList) == 0){
300
		return;
301
	}
302

    
303
	$out = '<ul class="homotypicSynonyms">';
304

    
305
	if(!empty($prependedSynonyms)){
306
		foreach($prependedSynonyms as $taxon){
307
			$out .= '<li class="synonym">'.theme('cdm_related_taxon', $taxon, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
308
		}
309
	}
310

    
311
	foreach($synonymList as $synonym){
312
		$out .= '<li class="synonym">'.theme('cdm_related_taxon', $synonym, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
313
	}
314

    
315
	$typeDesignations = cdm_ws_get(CDM_WS_PORTAL_NAME_TYPEDESIGNATIONS, $synonymList[0]->name->uuid);
316
	if($typeDesignations){
317
		$out .= theme('cdm_typedesignations', $typeDesignations);
318
	}
319
	if($accepted_taxon_footnoteListKey){// to avoiding drupal warnings (#1830) why false???
320
		$out .= theme('cdm_footnotes', $accepted_taxon_footnoteListKey, 'li');
321
	}
322
	$out .= theme('cdm_annotation_footnotes', $footnoteListKey, 'li');
323
	$out .= '</ul>';
324

    
325
	RenderHints::popFromRenderStack();
326
	return $out;
327
}
328

    
329

    
330
function theme_cdm_taxonName($taxonName, $nameLink = NULL, $refenceLink = NULL,
331
	$show_annotations = true, $is_type_designation = false, $skiptags = array()){
332

    
333
	$renderTemplate = get_nameRenderTemplate(RenderHints::getRenderPath(), $nameLink, $refenceLink);
334
	$partDefinition = get_partDefinition($taxonName->class);
335

    
336
	// apply defintions to template
337
	foreach($renderTemplate as $part=>$uri){
338
		if(isset($partDefinition[$part])){
339
			$renderTemplate[$part] = $partDefinition[$part];
340
		}
341
		if(is_array($uri)){
342
			$renderTemplate[$part]['#uri'] = $uri['#uri'];
343
		}
344
	}
345

    
346
	$firstEntryIsValidNamePart = is_array($taxonName->taggedName)
347
	&& is_string($taxonName->taggedName[0]->text)
348
	&& $taxonName->taggedName[0]->text != ''
349
	&& $taxonName->taggedName[0]->type == 'name';
350

    
351
	// got to use second entry as first one, see ToDo comment below ...
352
	if($firstEntryIsValidNamePart){
353

    
354
		$taggedName = $taxonName->taggedName;
355

    
356
		$lastAuthorElementString = false;
357
		$hasNamePart_with_Authors = isset($renderTemplate['namePart']) && isset($renderTemplate['namePart']['authors']);
358
		$hasNameAuthorPart_with_Authors = isset($renderTemplate['nameAuthorPart']) && isset($renderTemplate['nameAuthorPart']['authors']);
359

    
360
		if(!($hasNamePart_with_Authors || $hasNameAuthorPart_with_Authors)){
361
			//      // find author and split off from name
362
			//      // TODO expecting to find the author as the last element
363
			//      if($taggedName[count($taggedName)- 1]->type == 'authors'){
364
			//        $authorTeam = $taggedName[count($taggedName)- 1]->text;
365
			//        unset($taggedName[count($taggedName)- 1]);
366
			//      }
367

    
368
			// remove all authors
369
			$taggedNameNew = array();
370
			foreach($taggedName as $element){
371
				if($element->type != 'authors'){
372
					$taggedNameNew[] = $element;
373
				} else {
374
					$lastAuthorElementString = $element->text;
375
				}
376
			}
377
			$taggedName = $taggedNameNew;
378

    
379
		}
380
		$name = '<span class="'.$taxonName->class.'">'.theme('cdm_taggedtext2html', $taggedName, 'span', ' ', $skiptags).'</span>';
381
	} else {
382
		$name = '<span class="'.$taxonName->class.'_titleCache">'.$taxonName->titleCache.'</span>';
383
	}
384

    
385
	// fill name into $renderTemplate
386
	array_setr('name', $name, $renderTemplate);
387

    
388
	//  // fill with authorTeam
389
	//  if($authorTeam){
390
	//    $authorTeamHtml = ' <span class="authorTeam">'.$authorTeam.'</span>';
391
	//    array_setr('authorTeam', $authorTeamHtml, $renderTemplate);
392
	//  }
393

    
394
	// fill with reference
395
	if(isset($renderTemplate['referencePart']) && !$is_type_designation){
396

    
397
		// [Eckhard]:"Komma nach dem Taxonnamen ist grunsätzlich falsch,
398
		// Komma nach dem Autornamen ist überall dort falsch, wo ein "in" folgt."
399
		if(isset($renderTemplate['referencePart']['reference']) && $taxonName->nomenclaturalReference){
400
			$microreference = null;
401
			if(isset($renderTemplate['referencePart']['microreference'])){
402
				$microreference = $taxonName->nomenclaturalMicroReference;
403
			}
404
			$citation = cdm_ws_get(CDM_WS_NOMENCLATURAL_REFERENCE_CITATION, array($taxonName->nomenclaturalReference->uuid), "microReference=".urlencode($microreference));
405
			$citation = $citation->String;
406
			// find preceding element of the refrence
407
			$precedingKey = get_preceding_contentElementKey('reference', $renderTemplate);
408
			if(str_beginsWith($citation, ", in")){
409
				$citation = substr($citation, 2);
410
				$separator = ' ';
411
			} else if(!str_beginsWith($citation, "in") && $precedingKey == 'authors'){
412
				$separator = ', ';
413
			} else {
414
				$separator = ' ';
415
			}
416

    
417
			$referenceArray['#separator'] = $separator;
418
			$referenceArray['#html'] = '<span class="reference">'.$citation.'</span>';
419
			array_setr('reference', $referenceArray, $renderTemplate);
420
		}
421

    
422
		// if authors have been removed from the name part the last named authorteam
423
		// should be added to the reference citation, otherwise, keep the separator
424
		// out of the reference
425
		if(isset($renderTemplate['referencePart']['authors']) && $lastAuthorElementString){
426
			// if the nomenclaturalReference cintation is not included in the reference part but diplay of the microreference
427
			// is whanted append the microreference to the authorTeam
428
			if(!isset($renderTemplate['referencePart']['reference']) && isset($renderTemplate['referencePart']['microreference'])){
429
				$separator = ": ";
430
				$citation = $taxonName->nomenclaturalMicroReference;
431
			}
432
			$referenceArray['#html'] = ' <span class="reference">'.$lastAuthorElementString.$separator.$citation.'</span>';
433
			array_setr('authors', $referenceArray, $renderTemplate);
434
		}
435

    
436
	}
437

    
438
	// fill with status
439
	if(is_array($taxonName->status)){
440
		if(array_setr('status', true, $renderTemplate)){
441
			if(isset($taxonName->status[0])){
442
				foreach($taxonName->status as $status){
443
					$statusHtml .= ', '.$status->type->representation_L10n_abbreviated;
444
				}
445
			}
446
			array_setr('status', ' <span class="nomenclatural_status">'.$statusHtml.'</span>', $renderTemplate);
447
		}
448
	}
449

    
450
	// fill with protologues etc...
451
	if(array_setr('description', true, $renderTemplate)){
452
		$descriptions = cdm_ws_get(CDM_WS_PORTAL_NAME_DESCRIPTIONS, $taxonName->uuid);
453
		foreach($descriptions as $description){
454
			if(!empty($description)){
455
				foreach($description->elements as $description_element){
456
					$second_citation = '';
457
					if ($description_element->multilanguageText_L10n->text){
458
						$second_citation = '[& ' . $description_element->multilanguageText_L10n->text . '].';
459
					}
460
					$descriptionHtml .= $second_citation;
461
					$descriptionHtml .= theme("cdm_media", $description_element, array('application/pdf', 'image/png', 'image/jpeg', 'image/gif', 'text/html'));
462
				}
463
			}
464
		}
465
		array_setr('description', $descriptionHtml, $renderTemplate);
466
	}
467

    
468
	// render
469
	$out = '<span ref="/name/'.$taxonName->uuid.'">';
470

    
471
	foreach($renderTemplate as $partName=>$part){
472
		$separator = '';
473
		$partHtml = '';
474
		$uri = false;
475
		if(!is_array($part)){
476
			continue;
477
		}
478
		if(isset($part['#uri']) && is_string($part['#uri'])){
479
			$uri = $part['#uri'];
480
			unset($part['#uri']);
481
		}
482
		foreach($part as $key=>$content){
483
			$html = '';
484
			if(is_array($content)){
485
				$html = $content['#html'];
486
				$separator = $content['#separator'];
487
			} else if(is_string($content)){
488
				$html = $content;
489
			}
490
			$partHtml .= '<span class="'.$key.'">'.$html.'</span>';
491
		}
492
		if($uri){
493
			$out .= $separator.'<a href="'.$uri.'" class="'.$partName.'">'.$partHtml.'</a>';
494
		} else {
495
			$out .= $separator.$partHtml;
496

    
497
		}
498
	}
499
	$out .= '</span>';
500
	if ($show_annotations){
501
		//$out .= theme('cdm_annotations_as_footnotekeys', $taxonName);
502
	}
503
	return $out;
504
}
505

    
506
/**
507
 * Recursively searches the array for the $key and sets the given value
508
 * @param $key
509
 * @param $value
510
 * @param $array
511
 * @return true if the key has been found
512
 */
513
function &array_setr($key, $value, array &$array){
514
	foreach($array as $k=>&$v){
515
		if($key == $k){
516
			$v = $value;
517
			return $array;
518
		} else if(is_array($v)){
519
			$innerArray = array_setr($key, $value, $v);
520
			if($innerArray){
521
				return $array;
522
			}
523
		}
524
	}
525
	return null;
526
}
527

    
528
function &get_preceding_contentElement($contentElementKey, array &$renderTemplate){
529
	$precedingElement = null;
530
	foreach($renderTemplate as &$part){
531
		foreach($part as $key=>&$element){
532
			if($key == $contentElementKey){
533
				return $precedingElement;
534
			}
535
			$precedingElement = $element;
536
		}
537
	}
538
	return null;
539
}
540

    
541
function &get_preceding_contentElementKey($contentElementKey, array &$renderTemplate){
542
	$precedingKey = null;
543
	foreach($renderTemplate as &$part){
544
		if(is_array($part)){
545
			foreach($part as $key=>&$element){
546
				if($key == $contentElementKey){
547
					return $precedingKey;
548
				}
549
				if(!str_beginsWith($key, '#')){
550
					$precedingKey = $key;
551
				}
552
			}
553
		}
554
	}
555
	return null;
556
}
557

    
558

    
559

    
560

    
561

    
562

    
563

    
(4-4/8)