Project

General

Profile

« Previous | Next » 

Revision 0387c539

Added by Andreas Kohlbecker almost 14 years ago

footnotes for taxon names in the synonymy page #392 and replacing "senu bubbles" #391

View differences:

modules/cdm_dataportal/cdm_dataportal.css
323 323
  font-style: italic;
324 324
}
325 325

  
326
.heterotypicSynonymyGroup li.footnotes, .homotypicSynonymyGroup li.footnotes{
327
	margin-top: 10px;
328
    margin-left: 6px;
329
    padding-left: 6px;
330
    list-style: none;
331
    list-style-image: none;
332
    background-image: none;
333
}
334

  
modules/cdm_dataportal/cdm_dataportal.module
44 44
define('CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME', "description_gallery");
45 45
define('CDM_DATAPORTAL_MEDIA_GALLERY_NAME', "media_gallery");
46 46
define('CDM_DATAPORTAL_SEARCH_GALLERY_NAME', "search_gallery");
47
define('CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS', 'cdm_dataportal_display_taxon_relationships');
48
define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS', 'cdm_dataportal_display_name_relations');
49
define('CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT', 1);
50
define('CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_DEFAULT', 1);
47 51

  
48 52

  
49 53

  
......
751 755
                        the full nomenclatural reference.')
752 756
	);
753 757

  
754
	$form['cdm_dataportal_display_name_relations'] = array(
758
	$form[CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS] = array(
755 759
    '#type' => 'checkbox',
756 760
    '#title' => t('Show name relations of accepted taxa on taxon page'),
757
    '#default_value' => variable_get('cdm_dataportal_display_name_relations', 1),
761
    '#default_value' => variable_get(CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_DEFAULT),
758 762
    '#description' => t('')
759 763
	);
764
	
765
	$form[CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS] = array(
766
    '#type' => 'checkbox',
767
    '#title' => t('Show taxon relations of accepted taxa on taxon page'),
768
    '#default_value' => variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT),
769
    '#description' => t('')
770
    );
760 771

  
761 772
	$form['cdm_dataportal_display_is_accepted_for'] = array(
762 773
    '#type' => 'checkbox',
modules/cdm_dataportal/classes/footnotemanager.php
37 37
     * 
38 38
     * @param $footnoteListKey
39 39
     * @param $separator
40
     * @return unknown_type
40
     * @return the rendered footnotelist
41 41
     */
42 42
    public static function renderFootnoteList($footnoteListKey, $separator = ', '){
43 43
      $out = '';
modules/cdm_dataportal/classes/renderhints.php
23 23
      
24 24
    }
25 25

  
26
    public static function getfootnoteListKey(){
26
    public static function getFootnoteListKey(){
27 27
      return self::$footnoteListKey;
28 28
    }
29 29
    
30
    public static function setfootnoteListKey($key){
31
      return self::$footnoteListKey = $footnoteListKey;
30
    public static function setFootnoteListKey($key){
31
      self::$footnoteListKey = $key;
32 32
    }
33 33
    
34 34
    public static function pushToRenderStack($pathelement){
35
      return array_push(self::$renderStack, $pathelement);
35
      array_push(self::$renderStack, $pathelement);
36 36
    }
37 37
    
38 38
   
modules/cdm_dataportal/js/footnotes.js
5 5
		  return '.'+$(object).attr('href').substr(1);
6 6
	  }
7 7
	  
8
	  function getFootnoteKeyClassName(object){
9
		  return '.'+$(object).attr('href').substr(1).replace(/-/gi, '-key-');
10
	  }
11
	  
8 12
	  $('a.footnote-key').mouseover(function(e){
9 13
		  var fnClassName = getFootnoteClassName(this);
14
		  var fnKeyClassName = getFootnoteKeyClassName(this); 
10 15
		  $('.footnote').css('background-color', 'transparent').css('background-color', 'transparent').removeClass('active');
16
		  $('a.footnote-key').css('background-color', 'transparent').css('background-color', 'transparent').removeClass('active');
11 17
		  $(fnClassName).css('background-color', 'yellow');
18
		  $(fnKeyClassName).css('background-color', 'yellow');
12 19
	  	}
13 20
	  ).mouseout(function(e){
14 21
		  var fnClassName = getFootnoteClassName(this);
22
		  var fnKeyClassName = getFootnoteKeyClassName(this); 
15 23
		  $(fnClassName).not('.active').css('background-color', 'transparent');
24
		  $(fnKeyClassName).not('.active').css('background-color', 'transparent');
16 25
	  	}
17 26
	  ).click(function(e){
18 27
		  var fnClassName = getFootnoteClassName(this);
19
		  $('.footnote').css('background-color', 'transparent').removeClass('active');
28
		  var fnKeyClassName = getFootnoteKeyClassName(this); 
29
		  $('.footnote').css('background-color', 'transparent').removeClass('active'); 
30
		  $('a.footnote-key').css('background-color', 'transparent').removeClass('active');
20 31
		  $(fnClassName).css('background-color', 'yellow').addClass('active');
32
		  $(fnKeyClassName).css('background-color', 'yellow').addClass('active');
21 33
	  });
22 34
	  
23 35
  }));
modules/cdm_dataportal/theme/cdm_dataportal.common.theme
10 10
* See http://www.mozilla.org/MPL/MPL-1.1.html for the full license terms.
11 11
*/
12 12

  
13
define(FOOTNOTE_ANNOTATIONS, 'annotations');
14

  
13 15
/**
14 16
 * TODO if getting fragment from request is possible remove $_REQUEST['highlite'] HACK
15 17
 * NOT WORKING since fragments are not available to the server
......
81 83
/**
82 84
 * Almost any cdmObject may be annotated. Therefore we provide a generic way to display
83 85
 * as well as create or update annotations.
86
 * The following cdm classes are annotatable:
87
 * 
88
 *  DescriptionElementBase
89
 *	EventBase
90
 *	HomotypicalGroup
91
 *	IdentifiableEntity
92
 *	  DescriptionBase
93
 *	  IdentifiableMediaEntity
94
 *	  Media
95
 *	  Sequence
96
 *	  TaxonBase
97
 *	  TaxonNameBase
98
 *	  TaxonomicTree
99
 *	  TermBase
100
 *	LanguageStringBase
101
 *	ReferencedEntityBase
102
 *	  NomenclaturalStatus
103
 *	  OriginalSourceBase
104
 *	  RelationshipBase
105
 *	  TypeDesignationBase
106
 *	TaxonNode
107
 *  WorkingSet
84 108
 *
85 109
 * TODO it should be configurable which objects can be annotated as this might differ in dataportals
86 110
 *
87 111
 */
88 112
function theme_cdm_annotation($cdmBase){
89 113
	
90
	$annotationUrl = cdm_compose_annotations_url($cdmBase);
91

  
92
	if($annotationUrl){
93
		drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cdm_annotations.js');
94
		drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/jquery.form.js');
95
		$annotationProxyUrl = url('cdm_api/proxy/'. urlencode($annotationUrl).'/cdm_annotation_content');
96
	
97
		$out = ' <span class="annotation">';
98
		$out .= '<span class="annotation_toggle" rel="'.$annotationProxyUrl.'">+</span>';
99
			
100
	
101
		$out .= '<div class="annotation_box"></div>';
102
		$out .= '</span>';
103
	}
114
//    $annotationUrl = cdm_compose_annotations_url($cdmBase);
115
//
116
//	if($annotationUrl){
117
//		drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/cdm_annotations.js');
118
//		drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/jquery.form.js');
119
//		$annotationProxyUrl = url('cdm_api/proxy/'. urlencode($annotationUrl).'/cdm_annotation_content');
120
//	
121
//		$out = ' <span class="annotation">';
122
//		$out .= '<span class="annotation_toggle" rel="'.$annotationProxyUrl.'">+</span>';
123
//			
124
//	
125
//		$out .= '<div class="annotation_box"></div>';
126
//		$out .= '</span>';
127
//	}
128
    $annotationUrl = cdm_compose_annotations_url($cdmBase);
129
    if($annotationUrl){
130
        $annotationPager = cdm_ws_get($annotationUrl, null, null, null, true);
131
        foreach($annotationPager->records as $annotation){
132
	        $footnoteKey = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), $annotation->text);
133
	        $out .= (isset($out)? ',' : '') . theme('cdm_footnote_key', $footnoteKey);
134
        }
135
    }
104 136

  
105 137
	return $out;
106 138

  
......
152 184

  
153 185
/* ============================ footnotes ============================= */
154 186

  
155
function theme_cdm_footnote_key($footnoteKey){
156
  $out = '<a href="#footnote-'.$footnoteKey.'" class="footnote-key">'.$footnoteKey.'</a>';
187
function theme_cdm_footnote_key($footnoteKey, $highlightable=true){
188
  $out = '<a href="#footnote-'.$footnoteKey.'" class="footnote-key footnote-key-'.$footnoteKey.'">'.$footnoteKey.'</a>';
157 189
  return $out;
158 190
}
159 191

  
......
163 195
  return $out;
164 196
}
165 197

  
198
function theme_cdm_footnotes($footnoteListKey, $enclosingTag = 'span'){
199
	
200
	$out = '<'.$enclosingTag.' class="footnotes footnotes-'.$footnoteListKey.'">' . FootnoteManager::renderFootnoteList($footnoteListKey) . '</'.$enclosingTag.'>';
201
	return $out;
202
}
203

  
166 204

  
167 205
/* ============================ pager ============================= */
168 206

  
modules/cdm_dataportal/theme/cdm_dataportal.descriptions.theme
329 329

  
330 330
		if(variable_get('cdm_dataportal_map_openlayers', 1)){
331 331
			// embed into openlayers viewer
332
			$query_string .= '&img=false&legend=1&mlp=3';
332
			if (variable_get('cdm_dataportal_geoservice_legend_on', TRUE)){
333
			  $query_string .= '&img=false&legend=1&mlp=3';
334
			}
335
			$map_data_parameters->String = str_replace(': ', "%20", $map_data_parameters->String);
336
			$map_data_parameters->String = str_replace('(', "", $map_data_parameters->String);
337
			$map_data_parameters->String = str_replace(')', "", $map_data_parameters->String);
333 338
			$map_tdwg_Uri = url($server. '/areas.php?' .$map_data_parameters->String, $query_string);
334 339
			$legend_url_font_size = variable_get('cdm_dataportal_geoservice_legend_font_size', 10);
335 340
			$legend_url_font_style = variable_get('cdm_dataportal_geoservice_legend_font_style', 1);
......
337 342
			$legend_url_icon_width  = variable_get('cdm_dataportal_geoservice_legend_icon_width', 35);
338 343
			$legend_url_icon_height = variable_get('cdm_dataportal_geoservice_legend_icon_height', 15);
339 344

  
340
			//#print($map_tdwg_Uri.'<br>');
345
			print($map_tdwg_Uri.'<br>');
341 346

  
342 347
			// get the respone from the map service
343 348
			$responseObj = cdm_ws_get($map_tdwg_Uri, null, null, "GET", TRUE);
modules/cdm_dataportal/theme/cdm_dataportal.name.theme
123 123

  
124 124
}
125 125

  
126
function theme_cdm_nameRelations($nameRelationships, $skipTypes = false){
126
function theme_cdm_nameRelationships($nameRelationships, $skipTypes = false){
127 127

  
128
    if(!$nameRelationships){
129
        return;
130
    }
131
    
132
	RenderHints::pushToRenderStack('nameRelationships');
133
    $footnoteListKey = 'nameRelationships';
134
    RenderHints::setFootnoteListKey($footnoteListKey);
135
    
128 136
	// group by relationship type
129 137
	$relationshipGroups = array();
130 138
	foreach($nameRelationships as $nameRelationship){
......
154 162
		$block->content .= implode('; ', $relatedNames);
155 163
		$out .= theme('block', $block);
156 164
	}
165
	$out .= theme('cdm_footnotes', $footnoteListKey, 'div');
166
	
167
	RenderHints::popFromRenderStack();
157 168
	return $out;
158 169
}
159 170

  
......
169 180
function theme_cdm_heterotypicSynonymyGroup($homotypicalGroup){
170 181
	
171 182
	RenderHints::pushToRenderStack('heterotypicSynonymyGroup');
183
	
172 184
	$out = '';
173 185
	$out = '<ul class="heterotypicSynonymyGroup">';
174

  
186
    $footnoteListKey = ( isset($homotypicalGroup[0]) ? $homotypicalGroup[0]->uuid : 'NULL');
187
	RenderHints::setFootnoteListKey($footnoteListKey);
188
    
175 189
	$is_first_entry = true;
176 190
	$typeDesignations = null;
177 191
	foreach($homotypicalGroup as $synonym){
178 192
		if($is_first_entry){
179
			RenderHints::setfootnoteListKey($synonym->uuid);
180 193
			$is_first_entry = false;
181 194
			//$typeDesignations = cdm_ws_get(CDM_WS_NAME_TYPEDESIGNATIONS, $synonym->name->uuid);
182 195
			$typeDesignations = cdm_ws_get(CDM_WS_PORTAL_TAXON_NAMETYPEDESIGNATIONS, $synonym->uuid);
......
190 203
		$out .= theme('cdm_typedesignations', $typeDesignations);
191 204
	}
192 205

  
206
	$out .= theme('cdm_footnotes', $footnoteListKey, 'li');
193 207
	$out .= '</ul>';
194 208
    
195
	$out .= FootnoteManager::renderFootnoteList($firstSynonymUuid);
196 209
    
197 210
    RenderHints::popFromRenderStack();
198 211
	return $out;
......
204 217
	
205 218
	RenderHints::pushToRenderStack('homotypicSynonymyGroup');
206 219
	
207
	$firstSynonymUuid = isset($prependedSynonyms[0]) ? $prependedSynonyms[0]->uuid : (isset($synonymList[0]) ? $synonymList[0]->uuid : 'NULL');
208
	RenderHints::setfootnoteListKey($firstSynonymUuid);
220
	$footnoteListKey = isset($prependedSynonyms[0]) ? $prependedSynonyms[0]->uuid : (isset($synonymList[0]) ? $synonymList[0]->uuid : 'NULL');
221
	RenderHints::setFootnoteListKey($footnoteListKey);
209 222
	
210 223
	if(! is_array($synonymList) || count($synonymList) == 0){
211 224
		return;
......
228 241
		$out .= theme('cdm_typedesignations', $typeDesignations);
229 242
	}
230 243

  
244
	$out .= theme('cdm_footnotes', $footnoteListKey, 'li');
231 245
	$out .= '</ul>';
232
	$out .= FootnoteManager::renderFootnoteList($firstSynonymUuid);
233 246
	
234 247
	RenderHints::popFromRenderStack();
235 248
	return $out;
......
397 410
			$out .= $separator.$partHtml;
398 411
		}
399 412
	}
400

  
401
	return $out.'</span>';
413
    $out .= '</span>';
414
    
415
	// add annotations
416
	$out .= theme('cdm_annotation', $taxonName);
417
	
418
	return $out;
402 419
}
403 420

  
404 421
/**
modules/cdm_dataportal/theme/cdm_dataportal.page.theme
140 140
  	$addAcceptedTaxon = !variable_get('cdm_dataportal_nomref_in_title', CDM_DATAPORTAL_NOMREF_IN_TITLE);
141 141
  	$out .= theme('cdm_taxon_page_synonymy', $taxon, $addAcceptedTaxon);
142 142

  
143
  	if(variable_get('cdm_dataportal_display_name_relations', 1)){
144

  
145
  		$nameRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_NAMERELATIONS, $taxon->uuid);
146
  		// TODO is it correct to skip relationsFromThisName since all relationships are to be understood as 'is .... of'
147
  		if(variable_get('cdm_dataportal_name_relations_skiptype_basionym', 1)){
148
  			$skip = array(UUID_BASIONYM);
149
  		}
150
  		$out .= theme('cdm_nameRelations', $nameRelationships, $skip);
151
  	}
152 143
  	$out .= '</div>';
153 144
  }
154 145

  
......
192 183

  
193 184
	RenderHints::pushToRenderStack('taxon_page_synonymy');
194 185
	$synomymie = cdm_ws_get(CDM_WS_PORTAL_TAXON_SYNONYMY, $taxon->uuid);
195
	$taxonRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS, $taxon->uuid);
196 186
	$skip = array(UUID_BASIONYM);
197 187

  
198 188
	if($addAcceptedTaxon){
......
218 208
			$out .= theme('cdm_heterotypicSynonymyGroup', $homotypicalGroup);
219 209
		}
220 210
	}
221

  
222
	$out .= theme('cdm_taxonRelations', $taxonRelationships, $skip);
211
	
212
    if(variable_get(CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_NAME_RELATIONSHIPS_DEFAULT)){
213

  
214
        $nameRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_NAMERELATIONS, $taxon->uuid);
215
        // TODO is it correct to skip relationsFromThisName since all relationships are to be understood as 'is .... of'
216
        if(variable_get('cdm_dataportal_name_relations_skiptype_basionym', 1)){
217
            $skip = array(UUID_BASIONYM);
218
        }
219
        $out .= theme('nameRelationships', $nameRelationships, $skip);
220
    }
221
    
222
   if(variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT)){
223
   	    $taxonRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS, $taxon->uuid);
224
        $out .= theme('cdm_taxonRelationships', $taxonRelationships);
225
    }
226
	
223 227
    RenderHints::popFromRenderStack();
224 228
	return $out;
225 229
}
modules/cdm_dataportal/theme/cdm_dataportal.taxon.theme
64 64
 * @param unknown_type $taxonRelationships
65 65
 * @return unknown
66 66
 */
67
function theme_cdm_taxonRelations($taxonRelationships){
67
function theme_cdm_taxonRelationships($taxonRelationships){
68 68

  
69 69
	if(!$taxonRelationships){
70 70
		return;
71 71
	}
72
	
73
	RenderHints::pushToRenderStack('taxonRelationships');
74
    $footnoteListKey = 'taxonRelationships';
75
    RenderHints::setFootnoteListKey($footnoteListKey);
72 76

  
73
	_add_js_cluetip();
74

  
75
	// aggregate misapplied names having the same fullname:
76 77
	$misapplied = array();
78
	$joinedAuthorTeams = array();
79
	
80
	// aggregate misapplied names having the same fullname:
77 81
	foreach($taxonRelationships as $taxonRelation){
78 82
		if(true || $taxonRelation->type->uuid == UUID_MISAPPLIED_NAME_FOR || $taxonRelation->type->uuid == UUID_INVALID_DESIGNATION_FOR ){
79 83

  
......
87 91

  
88 92
			// collect all authors for this fullname
89 93
			if(isset($authorteam)){
90
				$misapplied[$name]['authorteam'][$authorteam] = '&nbsp;<span class="sensu cluetip no-print" title="|sensu '.htmlspecialchars(theme('cdm_reference',$taxonRelation->fromTaxon->sec )).'|">sensu '
91
				.$authorteam.'</span>'
92
				.'<span class="reference only-print">sensu '.theme('cdm_reference', $taxonRelation->fromTaxon->sec ).'</span>';
94
                  $misapplied[$name]['authorteam'][$authorteam] = '';
95
                  $joinedAuthorTeams[$authorteam] = 'sensu '.theme('cdm_reference', $taxonRelation->fromTaxon->sec);
93 96
			}
94 97

  
95 98
		}
96 99
	}
100
	
101
	// sort the joinedAuthorTeams and create footnotes and footnotekeys
102
	ksort($joinedAuthorTeams);
103
	foreach($joinedAuthorTeams as $authorteam=>$sensuCitation){
104
		$footnoteKey = FootnoteManager::addNewFootnote($footnoteListKey, $sensuCitation);
105
		$joinedAuthorTeams[$authorteam] = '<span class="sensu">sensu '.$authorteam. theme('cdm_footnote_key', $footnoteKey).'</span>';
106
	}
97 107

  
98 108
	// generate output
99 109
	$out = '<ul class="misapplied">';
110
	
100 111
	foreach($misapplied as $misapplied_name){
112
		
101 113
		$out .= '<li class="synonym">'.$misapplied_name['out'] . " ";
102
		// sorting authors
114
		// fill authors the renderedFootnoteKey and sorting 'em
115
		foreach($misapplied_name['authorteam'] as $authorteam=>&$renderedFootnoteKey) {
116
		  $renderedFootnoteKey = $joinedAuthorTeams[$authorteam];
117
	    }
103 118
		if(isset($misapplied_name['authorteam'])){
104 119
			ksort($misapplied_name['authorteam']);
105 120
			$out .= join('; ', $misapplied_name['authorteam']);
106 121
		}
107 122
		$out .= '</li>';
123
		
108 124
	}
109 125
	$out .= '</ul>';
126
	
127
	$out .= theme('cdm_footnotes', $footnoteListKey, 'div');
128
    RenderHints::popFromRenderStack();
110 129
	return $out;
111 130
}
112 131

  

Also available in: Unified diff