Project

General

Profile

Download (20.5 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
	$data_type = variable_get('cdm_dataportal_data_type', 'BIOLOGY');
24
	
25
	if($data_type == 'ZOOLOGY'){
26
		if ($typeDesignation->typeStatus->uuid == UUID_ORIGINAL_DESIGNATION ||
27
		    $typeDesignation->typeStatus->uuid == UUID_MONOTYPE){
28
			$res = ' ('. $typeDesignation->typeStatus->representation_L10n . ')';
29
			return $res;
30
		 }	 
31
	}
32

    
33
	if ($citation){
34
    //$type = $typeDesignation_citation->type;
35
    $year = substr($citation->datePublished->start, 0, 4);
36
    $author = $citation->authorTeam->titleCache;
37
    $res .= ' (designated by ';
38
    $res .= $author;
39
    $res .= ($year ? ' '.$year : '');
40
    $res .= ($pages ? ': '. $pages : '');
41
    //$res .= ')';
42
      
43
    $fkey_typeDesignation = FootnoteManager::addNewFootnote(RenderHints::getRenderPath() . '-typeDesignations', $typeDesignation->citation->titleCache);
44
    $res .= theme('cdm_footnote_key', $fkey_typeDesignation, $footnote_separator, true, true) . ')';
45
       
46
    }		
47
	return $res;
48
}
49

    
50
function theme_cdm_typedesignations($typeDesignations = array()){
51
	/*
52
	 if(isset($renderTemplate['referencePart']['reference']) && $taxonName->nomenclaturalReference){
53
	 $microreference = null;
54
	 if(isset($renderTemplate['referencePart']['microreference'])){
55
	 $microreference = $taxonName->nomenclaturalMicroReference;
56
	 }
57
	 $citation = cdm_ws_get(CDM_WS_NOMENCLATURAL_REFERENCE_CITATION, array($typeDesignation->uuid), "microReference=".urlencode($microreference));
58
	 $citation = $citation->String;
59
	 */
60

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

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

    
110
				$author_team = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $std->citation->uuid);
111
				$shortCitation = $author_team->titleCache;
112

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

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

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

    
128
			$derivedUnitFacadeInstance = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, $std->typeSpecimen->uuid);
129

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

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

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

    
148
	$out .= '</ul>';
149
	//render the footnotes at the end of the page
150
	
151
	if ($render_footnote_lectotypes){
152
		$out .= theme('cdm_footnotes', RenderHints::getRenderPath() . '-lectotypes');
153
	}
154
	$out .= theme('cdm_footnotes', RenderHints::getRenderPath() . '-acronyms', 'li');
155
	$out .= theme('cdm_footnotes', RenderHints::getRenderPath() . '-typeDesignations', 'li');
156
	//$out .= theme('cdm_footnotes', RenderHints::getRenderPath() . '-typeDesignations-' . $typeDesignation->uuid, 'li');
157
 
158
	RenderHints::popFromRenderStack();
159
	return $out;
160
}
161

    
162

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

    
185
	$aQuantifier = array_search($a->typeStatus->label, $typeOrder);
186
	$bQuantifier = array_search($b->typeStatus->label, $typeOrder);
187

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

    
194
}
195

    
196
function theme_cdm_nameRelationships($nameRelationships, $skipTypes = false){
197

    
198
	if(!$nameRelationships){
199
		return;
200
	}
201

    
202
	RenderHints::pushToRenderStack('nameRelationships');
203
	$footnoteListKey = 'nameRelationships';
204
	RenderHints::setFootnoteListKey($footnoteListKey);
205

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

    
215
	// generate output
216
	$out = '';
217
	foreach($relationshipGroups as $group){
218
		$type = $group[0]->type;
219

    
220
		if(is_array($skipTypes) && in_array($type->uuid, $skipTypes)){
221
			continue;
222
		}
223

    
224
		$block->module = 'cdm_dataportal';
225
		$block->subject = t(ucfirst($type->inverseRepresentation_L10n));
226
		$block->delta = generalizeString(strtolower($type->inverseRepresentation_L10n));
227

    
228
		foreach($group as $relationship){
229
			$relatedNames[] = cdm_taggedtext2html($relationship->fromName->taggedName);
230
		}
231

    
232
		$block->content .= implode('; ', $relatedNames);
233
		$out .= theme('block', $block);
234
	}
235
	$out .= theme('cdm_footnotes', $footnoteListKey, 'li');
236

    
237
	RenderHints::popFromRenderStack();
238
	return $out;
239
}
240

    
241

    
242

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

    
247
	return $out;
248
}
249

    
250
function theme_cdm_heterotypicSynonymyGroup($homotypicalGroup){
251

    
252
	RenderHints::pushToRenderStack('heterotypicSynonymyGroup');
253

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

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

    
274
	if($typeDesignations){
275
		$out .= theme('cdm_typedesignations', $typeDesignations);
276

    
277
	}
278

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

    
287

    
288
	RenderHints::popFromRenderStack();
289
	return $out;
290
}
291

    
292

    
293

    
294
function theme_cdm_homotypicSynonymyGroup($synonymList, $prependedSynonyms = array()){
295

    
296
	RenderHints::pushToRenderStack('homotypicSynonymyGroup');
297

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

    
302
	if(! is_array($synonymList) || count($synonymList) == 0){
303
		return;
304
	}
305

    
306
	$out = '<ul class="homotypicSynonyms">';
307

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

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

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

    
328
	RenderHints::popFromRenderStack();
329
	return $out;
330
}
331

    
332

    
333
function theme_cdm_taxonName($taxonName, $nameLink = NULL, $refenceLink = NULL,
334
                   $show_annotations = true, $is_type_designation = false, $skiptags = array()){
335

    
336
	$renderTemplate = get_nameRenderTemplate(RenderHints::getRenderPath(), $nameLink, $refenceLink);
337
	$partDefinition = get_partDefinition($taxonName->class);
338

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

    
349
	$firstEntryIsValidNamePart = is_array($taxonName->taggedName)
350
	&& is_string($taxonName->taggedName[0]->text)
351
	&& $taxonName->taggedName[0]->text != ''
352
	&& $taxonName->taggedName[0]->type == 'name';
353

    
354
	// got to use second entry as first one, see ToDo comment below ...
355
	if($firstEntryIsValidNamePart){
356

    
357
		$taggedName = $taxonName->taggedName;
358

    
359
		$lastAuthorElementString = false;
360
		$hasNamePart_with_Authors = isset($renderTemplate['namePart']) && isset($renderTemplate['namePart']['authors']);
361
		$hasNameAuthorPart_with_Authors = isset($renderTemplate['nameAuthorPart']) && isset($renderTemplate['nameAuthorPart']['authors']);
362

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

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

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

    
388
	// fill name into $renderTemplate
389
	array_setr('name', $name, $renderTemplate);
390

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

    
397
	// fill with reference
398
	if(isset($renderTemplate['referencePart']) && !$is_type_designation){
399

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

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

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

    
439
	}
440

    
441
	// fill with status
442
	if((bool) $taxon->name->status){
443
	if(array_setr('status', true, $renderTemplate)){
444
		if(isset($taxon->name->status[0])){
445
			foreach($taxon->name->status as $status){
446
				$statusHtml .= ', '.$status->type->representation_L10n;
447
			}
448
		}
449
		array_setr('status', ' <span class="nomenclatural_status">'.$statusHtml.'</span>', $renderTemplate);
450
	}
451
	}
452
	// fill with protologues etc...
453
	if(array_setr('description', true, $renderTemplate)){
454
		$descriptions = cdm_ws_get(CDM_WS_PORTAL_NAME_DESCRIPTIONS, $taxonName->uuid);
455
		foreach($descriptions as $description){
456
			if(!empty($description)){
457
				foreach($description->elements as $description_element){
458
					$second_citation = '';
459
					if ($description_element->multilanguageText_L10n->text){
460
						$second_citation = '[& ' . $description_element->multilanguageText_L10n->text . '].';
461
					}
462
					$descriptionHtml .= $second_citation;
463
					$descriptionHtml .= theme("cdm_media", $description_element, array('application/pdf', 'image/png', 'image/jpeg', 'image/gif', 'text/html'));
464
				}
465
			}
466
		}
467
		array_setr('description', $descriptionHtml, $renderTemplate);
468
	}
469

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

    
473
	foreach($renderTemplate as $partName=>$part){
474
		$separator = '';
475
		$partHtml = '';
476
		$uri = false;
477
		if(!is_array($part)){
478
			continue;
479
		}
480
		if(isset($part['#uri']) && is_string($part['#uri'])){
481
			$uri = $part['#uri'];
482
			unset($part['#uri']);
483
		}
484
		foreach($part as $key=>$content){
485
			$html = '';
486
			if(is_array($content)){
487
				$html = $content['#html'];
488
				$separator = $content['#separator'];
489
			} else if(is_string($content)){
490
				$html = $content;
491
			}
492
			$partHtml .= '<span class="'.$key.'">'.$html.'</span>';
493
		}
494
		if($uri){
495
			$out .= $separator.'<a href="'.$uri.'" class="'.$partName.'">'.$partHtml.'</a>';
496
		} else {
497
			$out .= $separator.$partHtml;
498
			
499
		}
500
	}
501
	$out .= '</span>';
502
	if ($show_annotations){
503
    //$out .= theme('cdm_annotations_as_footnotekeys', $taxonName);
504
	}
505
	return $out;
506
}
507

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

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

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

    
560

    
561

    
562

    
563

    
564

    
565

    
(4-4/8)