Project

General

Profile

« Previous | Next » 

Revision a973da5b

Added by Andreas Kohlbecker over 13 years ago

fixing footnote order for distributions and commonnames

View differences:

modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme
111 111
				$out .= '<a name="'.$block->delta.'"></a>';
112 112
				$out .= theme('block', $block);
113 113

  
114
				// TODO HACK
114
				// Display cdm distribution map TODO this is a HACK to a proper generic implementation?
115 115
				if($node->feature->uuid == UUID_DISTRIBUTION){
116
					$out .= theme('cdm_descriptionElements_distribution', $taxon);
116
					$out .= theme('cdm_distribution_map', $taxon);
117 117
				}
118 118

  
119 119
				$out .= theme('cdm_footnotes', $node->feature->uuid);
......
211 211

  
212 212

  
213 213
function theme_cdm_common_names($elements){
214
	$result;
214

  
215
	$out = '';
215 216
	$separator = ',';
216
	//create the a-array with the areas and text to show
217
	
217 218
	foreach ($elements as $element){
218 219
		if ($element->class == 'CommonTaxonName'){
219
			$sourcesFootnoteKeyList = '';
220
			foreach($element->sources as $source){
221
				if(_is_original_source_type($source)){ 
222
				  $_fkey = FootnoteManager::addNewFootnote(UUID_COMMON_NAME, theme('cdm_DescriptionElementSource', $source, false));
223
                  $sourcesFootnoteKeyList .= theme('cdm_footnote_key', $_fkey, UUID_COMMON_NAME, ($sourcesFootnoteKeyList ? $separator : ''));
224
				}
225
			}
226
			//$common_names[$element->language->representation_L10n] = ' (' . $element->area->titleCache . '): ' . $element->name . $sourcesFootnoteKeyList;
227
			//$common_names['<b>' . $element->language->representation_L10n . '</b> (' . $element->area->titleCache . ')'] = ': ' . $element->name . $sourcesFootnoteKeyList;
228 220
			$key = '<b>' . $element->language->representation_L10n . '</b> (' . $element->area->titleCache . ')';
229
			if($common_names[$key]){
230
				$common_names[$key] = $common_names[$key] . ', ' . $element->name . $sourcesFootnoteKeyList;
231
			}else{
232
				$common_names[$key] = $element->name . $sourcesFootnoteKeyList;
233
			}
221
			$common_names[$key][] = $element;
234 222
		}
235 223
	}
224
	
236 225
	if (count($common_names) > 0){
237 226
		//sorting the a-array based on the area (key)
238 227
		ksort($common_names);
239 228
		//creating the output to be render by drupal
240
		foreach ($common_names as $key => $val){
241
			if (count($result) > 0){
242
				$result = $result . '; ';
229
		foreach ($common_names as $key => $elements){
230

  
231
			$rendered_element_list = '';
232
			foreach($elements as $element){
233
				$sourcesFootnoteKeyList = '';
234
				// add footnotes for sources
235
	            foreach($element->sources as $source){
236
	                if(_is_original_source_type($source)){ 
237
	                  $_fkey = FootnoteManager::addNewFootnote(UUID_COMMON_NAME, theme('cdm_DescriptionElementSource', $source, false));
238
	                  $sourcesFootnoteKeyList .= theme('cdm_footnote_key', $_fkey, UUID_COMMON_NAME, ($sourcesFootnoteKeyList ? $separator : ''));
239
	                }
240
	            }
241
				$rendered_element_list .= (strlen($rendered_element_list) > 0 ? ', ': '') . $element->name . $sourcesFootnoteKeyList;
243 242
			}
244
			$result = $result . $key . ': ' . $val;
243
			$out .= (strlen($out) > 0 ? '; ': '') . $key . ': ' . $rendered_element_list;
244
			
245 245
		}
246
	} else {
247
		$result = '';
248 246
	}
249
	return $result;
247
	return $out;
250 248
}
251 249

  
252 250
/**
......
314 312
	RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
315 313
	foreach($descriptionElements as $descriptionElement){
316 314
		// annotations as footnotes
317
		$annotationFootnoteKeys = theme('cdm_annotations_as_footnotekeys', $descriptionElement);
315
		//$annotationFootnoteKeys = theme('cdm_annotations_as_footnotekeys', $descriptionElement);
316
		$footNoteKeys = cdm_annotations_as_footnotekeys($descriptionElement);
317
		
318 318
		// source references as footnotes
319
		$sourcesFootnoteKeyList = '';
320 319
		foreach($descriptionElement->sources as $source){
321 320
			if(_is_original_source_type($source)){
322
			 $_fkey = FootnoteManager::addNewFootnote(UUID_DISTRIBUTION, theme('cdm_DescriptionElementSource', $source, false));
323
			 $sourcesFootnoteKeyList .= theme('cdm_footnote_key', $_fkey, UUID_DISTRIBUTION, ($sourcesFootnoteKeyList ? $separator : ''));
321
			 $_fkey = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
322
			 $footNoteKeys[] = new FootnoteKey($_fkey, RenderHints::getFootnoteListKey());
324 323
			}
325 324
		}
326
		if($annotationFootnoteKeys && $sourcesFootnoteKeyList){
327
			$annotationFootnoteKeys .= $separator;
328
		}
329
		$out .= $descriptionElement->area->representation_L10n . $annotationFootnoteKeys . $sourcesFootnoteKeyList . ' ';
325
		// sort and render footnote keys
326
		$footnoteKeyListStr = '';
327
		asort($footNoteKeys);
328
        foreach($footNoteKeys as $footNoteKey){
329
			$footnoteKeyListStr .= theme('cdm_footnote_key', $footNoteKey->keyStr, $footnoteKey->footnoteListKey, ($footnoteKeyListStr ? $separator : ''));
330
        }
331
		
332
        
333
		$out .= '<span class="descriptionElement descriptionElement-'.$descriptionElement->uuid.'">'.$descriptionElement->area->representation_L10n . $footnoteKeyListStr . ' </span>';
330 334
	}
331 335

  
332 336
	$out = substr($out, 0, strlen($out)-strlen($separator) );
......
353 357
 * @param unknown_type $featureTo
354 358
 * @return unknown
355 359
 */
356
function theme_cdm_descriptionElements_distribution($taxon){
360
function theme_cdm_distribution_map($taxon){
357 361

  
358 362
	$fontStyles = array(0 => "plane", 1 => "italic");
359 363
	$server = variable_get('cdm_dataportal_geoservice_access_point', false);

Also available in: Unified diff