Project

General

Profile

« Previous | Next » 

Revision b9438135

Added by Andreas Kohlbecker over 12 years ago

portal side fix for #2679 (Improve Concept Relationships for Dataportal)

View differences:

5.x/modules/cdm_dataportal/cdm_dataportal.module
1513 1513
  return !$source->idNamespace && strlen($source->idNamespace) == 0;
1514 1514
}
1515 1515

  
1516
function _is_invers_taxonRelationship($taxonRelationship, $focusedTaxon){
1517
  return $taxonRelationship->fromTaxon->uuid == $focusedTaxon->uuid;
1518
}
1519

  
1516 1520

  
1517 1521

  
1518 1522
/**
5.x/modules/cdm_dataportal/theme/cdm_dataportal.name.theme
267 267

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

  
272 272
	return $out;
273 273
}
......
288 288
			$is_first_entry = false;
289 289
			$typeDesignations = cdm_ws_get(CDM_WS_PORTAL_NAME_TYPEDESIGNATIONS, $synonym->name->uuid);
290 290
			// is first list entry
291
			$out .= '<li class="firstentry synonym">'.theme('cdm_related_taxon',$synonym, UUID_HETEROTYPIC_SYNONYM_OF).'</li>';
291
			$out .= '<li class="firstentry synonym">'.cdm_related_taxon($synonym, UUID_HETEROTYPIC_SYNONYM_OF).'</li>';
292 292
		} else {
293
			$out .= '<li class="synonym">'.theme('cdm_related_taxon',$synonym, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
293
			$out .= '<li class="synonym">'.cdm_related_taxon($synonym, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
294 294
		}
295 295
	}
296 296
	//$test =  theme('cdm_annotation_footnotes', $footnoteListKey, 'li');
......
332 332

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

  
339 339
	foreach($synonymList as $synonym){
340
		$out .= '<li class="synonym">'.theme('cdm_related_taxon', $synonym, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
340
		$out .= '<li class="synonym">'.cdm_related_taxon($synonym, UUID_HOMOTYPIC_SYNONYM_OF).'</li>';
341 341
	}
342 342

  
343 343
	$homonym_typeDesignations = cdm_ws_get(CDM_WS_PORTAL_NAME_TYPEDESIGNATIONS, $synonymList[0]->name->uuid);
5.x/modules/cdm_dataportal/theme/cdm_dataportal.page.theme
445 445
  //render taxon relationships
446 446
  if(variable_get(CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS, CDM_DATAPORTAL_DISPLAY_TAXON_RELATIONSHIPS_DEFAULT)){
447 447
    $taxonRelationships = cdm_ws_get(CDM_WS_PORTAL_TAXON_RELATIONS, $taxon->uuid);
448
    $out .= theme('cdm_taxonRelationships', $taxonRelationships);
448
    $out .= theme('cdm_taxonRelationships', $taxonRelationships, $taxon);
449 449
  }
450 450
  //render name relationships
451 451
  $name_rels_to_show = variable_get('name_relationships_to_show', null);
5.x/modules/cdm_dataportal/theme/cdm_dataportal.taxon.theme
13 13
function theme_cdm_search_results($pager, $path, $parameters){
14 14

  
15 15

  
16
	$showThumbnails = $_SESSION['pageoptions']['searchtaxa']['showThumbnails'];
17
	if( !is_numeric($showThumbnails)){
18
		$showThumbnails = 1;
19
	}
20
	$setSessionUri = url('cdm_api/setvalue/session', "var=[pageoption][searchtaxa][showThumbnails]&val=");
21
	drupal_add_js('$(document).ready(function() {
16
  $showThumbnails = $_SESSION['pageoptions']['searchtaxa']['showThumbnails'];
17
  if( !is_numeric($showThumbnails)){
18
    $showThumbnails = 1;
19
  }
20
  $setSessionUri = url('cdm_api/setvalue/session', "var=[pageoption][searchtaxa][showThumbnails]&val=");
21
  drupal_add_js('$(document).ready(function() {
22 22

  
23 23
        // init
24 24
        if('.$showThumbnails.' == 1){
......
42 42
          });
43 43
        });', "inline");
44 44

  
45
	drupal_set_title(t('Search results'));
45
  drupal_set_title(t('Search results'));
46 46

  
47
	$out = ''; //l('Advanced Search', '/cdm_dataportal/search');
47
  $out = ''; //l('Advanced Search', '/cdm_dataportal/search');
48 48

  
49
	$out = '<div class="page_options"><form name="pageoptions"><input id="showThumbnails" type="checkbox" name="showThumbnails" '.($showThumbnails == 1? 'checked="checked"': '').'> '.t('Show Thumbnails').'</form></div>';
50
	if(count($pager->records) > 0){
51
	    $out .= '<div id="search_results">';
52
		$out .= theme('cdm_list_of_taxa', $pager->records);
53
		$out .= '</div>';
54
		$out .= theme('cdm_pager', $pager, $path, $parameters);
55
	} else {
56
		$out = '<h4 class="error">Sorry, no matching entries found.</h4>';
57
	}
58
	return $out;
49
  $out = '<div class="page_options"><form name="pageoptions"><input id="showThumbnails" type="checkbox" name="showThumbnails" '.($showThumbnails == 1? 'checked="checked"': '').'> '.t('Show Thumbnails').'</form></div>';
50
  if(count($pager->records) > 0){
51
      $out .= '<div id="search_results">';
52
    $out .= theme('cdm_list_of_taxa', $pager->records);
53
    $out .= '</div>';
54
    $out .= theme('cdm_pager', $pager, $path, $parameters);
55
  } else {
56
    $out = '<h4 class="error">Sorry, no matching entries found.</h4>';
57
  }
58
  return $out;
59 59
}
60 60

  
61 61

  
......
66 66
 * @param unknown_type $taxonRelationships
67 67
 * @return unknown
68 68
 */
69
function theme_cdm_taxonRelationships($taxonRelationships){
70

  
71
	if(!$taxonRelationships){
72
		return;
73
	}
74

  
75
	RenderHints::pushToRenderStack('taxonRelationships');
76
	$footnoteListKey = 'taxonRelationships';
77
	RenderHints::setFootnoteListKey($footnoteListKey);
78

  
79
	$misapplied = array();
80
	$joinedAuthorTeams = array();
81

  
82
	$taxon_relationship_types = variable_get(CDM_TAXON_RELATIONSHIP_TYPES, unserialize(CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT));
83

  
84
	// aggregate misapplied names having the same fullname:
85
	foreach($taxonRelationships as $taxonRelation){
86

  
87
	    if( in_array($taxonRelation->type->uuid, $taxon_relationship_types)) {
88

  
89
    		if( $taxonRelation->type->uuid == UUID_MISAPPLIED_NAME_FOR || $taxonRelation->type->uuid == UUID_INVALID_DESIGNATION_FOR ){
90

  
91
    			$name = $taxonRelation->fromTaxon->name->titleCache;
92

  
93
    			$author_team = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $taxonRelation->fromTaxon->sec->uuid);
94
    			$authorteam = $author_team->titleCache;
95

  
96
    			if(!isset($misapplied[$name])){
97
    				$misapplied[$name]['out'] =
98
    				  '<span class="misapplied">'
99
    				  .theme('cdm_related_taxon',$taxonRelation->fromTaxon, UUID_MISAPPLIED_NAME_FOR).
100
    				  '</span>';
101
    			}
102

  
103
    			// collect all authors for this fullname
104
    			if(isset($authorteam)){
105
    				$misapplied[$name]['authorteam'][$authorteam] = '';
106
    				$joinedAuthorTeams[$authorteam] = 'sensu '.theme('cdm_reference', $taxonRelation->fromTaxon->sec);
107
    			}
108

  
109
    	    } else {
110
    	      // all relationsship types but misapplied_name_for invalid_designation_for
111
    	       $taxonRelationshipsLines[] = theme('cdm_related_taxon',$taxonRelation->fromTaxon, $taxonRelation->type->uuid, $taxonRelation->type, true);
112
    	    }
113
   		}
114
	}
115

  
116
	// sort the joinedAuthorTeams and create footnotes and footnotekeys
117
	ksort($joinedAuthorTeams);
118
	foreach($joinedAuthorTeams as $authorteam=>$sensuCitation){
119
		$footnoteKey = FootnoteManager::addNewFootnote($footnoteListKey, $sensuCitation);
120
		$joinedAuthorTeams[$authorteam] = '<span class="sensu">sensu '.$authorteam. theme('cdm_footnote_key', $footnoteKey).'</span>';
121
	}
122

  
123
	// generate output
124
	if(is_array($misapplied) && count($misapplied) >0 ){
125
    	$out .= '<ul class="misapplied">';
126
    	foreach($misapplied as $misapplied_name){
127

  
128
    		$out .= '<li class="synonym">'.$misapplied_name['out'] . " ";
129
    		if(isset($misapplied_name['authorteam'])){
130
    			// fill authors with the renderedFootnoteKey and sorting 'em
131
    			foreach($misapplied_name['authorteam'] as $authorteam=>&$renderedFootnoteKey) {
132
    				$renderedFootnoteKey = $joinedAuthorTeams[$authorteam];
133
    			}
134
    				ksort($misapplied_name['authorteam']);
135
    				$out .= join('; ', $misapplied_name['authorteam']);
136
    		}
137
    		$out .= '</li>';
138

  
139
    	}
140
    	$out .= '</ul>';
141
	}
142

  
143
	if(is_array($taxonRelationshipsLines) && count($taxonRelationshipsLines) >0 ){
144
    	$out .= '<ul class="taxonRelationships">';
145
    	foreach($taxonRelationshipsLines as $taxonRelationshipLine){
146
    		$out .= '<li class="synonym">'. $taxonRelationshipLine . '</li>';
147
    	}
148
    	$out .= '</ul>';
149
	}
150

  
151

  
152
	$tr_footnotes = theme('cdm_footnotes', $footnoteListKey, 'li');
153
	$tr_footnotes_exploded = explode('sensu', $tr_footnotes);
154
	$tr_footnotes_aux = '';
155
	foreach ($tr_footnotes_exploded as $element){
156
		$tr_footnotes_aux .= $element;
157
	}
158
	$out .= '<ul>' . $tr_footnotes_aux . '</ul>';
159
	//$out .= '</ul>';
160
	RenderHints::popFromRenderStack();
161
	return $out;
69
function theme_cdm_taxonRelationships($taxonRelationships, $focusedTaxon){
70

  
71
  if(!$taxonRelationships){
72
    return;
73
  }
74

  
75
  RenderHints::pushToRenderStack('taxonRelationships');
76
  $footnoteListKey = 'taxonRelationships';
77
  RenderHints::setFootnoteListKey($footnoteListKey);
78

  
79
  $misapplied = array();
80
  $joinedAuthorTeams = array();
81

  
82
  $taxon_relationship_types = variable_get(CDM_TAXON_RELATIONSHIP_TYPES, unserialize(CDM_TAXON_RELATIONSHIP_TYPES_DEFAULT));
83

  
84
  // aggregate misapplied names having the same fullname:
85
  foreach($taxonRelationships as $taxonRelation){
86

  
87
      if( in_array($taxonRelation->type->uuid, $taxon_relationship_types)) {
88

  
89
        if( $taxonRelation->type->uuid == UUID_MISAPPLIED_NAME_FOR || $taxonRelation->type->uuid == UUID_INVALID_DESIGNATION_FOR ){
90

  
91
          $name = $taxonRelation->fromTaxon->name->titleCache;
92

  
93
          $author_team = cdm_ws_get(CDM_WS_REFERENCE_AUTHORTEAM, $taxonRelation->fromTaxon->sec->uuid);
94
          $authorteam = $author_team->titleCache;
95

  
96
          if(!isset($misapplied[$name])){
97
            $misapplied[$name]['out'] =
98
              '<span class="misapplied">'
99
              .cdm_related_taxon($taxonRelation->fromTaxon, UUID_MISAPPLIED_NAME_FOR).
100
              '</span>';
101
          }
102

  
103
          // collect all authors for this fullname
104
          if(isset($authorteam)){
105
            $misapplied[$name]['authorteam'][$authorteam] = '';
106
            $joinedAuthorTeams[$authorteam] = 'sensu '.theme('cdm_reference', $taxonRelation->fromTaxon->sec);
107
          }
108

  
109
          } else {
110
            // all relationsship types but misapplied_name_for invalid_designation_for
111
             $taxonRelationshipsLines[] = cdm_taxonRelationship($taxonRelation, true, _is_invers_taxonRelationship($taxonRelation, $focusedTaxon));
112
          }
113
       }
114
  }
115

  
116
  // sort the joinedAuthorTeams and create footnotes and footnotekeys
117
  ksort($joinedAuthorTeams);
118
  foreach($joinedAuthorTeams as $authorteam=>$sensuCitation){
119
    $footnoteKey = FootnoteManager::addNewFootnote($footnoteListKey, $sensuCitation);
120
    $joinedAuthorTeams[$authorteam] = '<span class="sensu">sensu '.$authorteam. theme('cdm_footnote_key', $footnoteKey).'</span>';
121
  }
122

  
123
  // generate output
124
  if(is_array($misapplied) && count($misapplied) >0 ){
125
      $out .= '<ul class="misapplied">';
126
      foreach($misapplied as $misapplied_name){
127

  
128
        $out .= '<li class="synonym">'.$misapplied_name['out'] . " ";
129
        if(isset($misapplied_name['authorteam'])){
130
          // fill authors with the renderedFootnoteKey and sorting 'em
131
          foreach($misapplied_name['authorteam'] as $authorteam=>&$renderedFootnoteKey) {
132
            $renderedFootnoteKey = $joinedAuthorTeams[$authorteam];
133
          }
134
            ksort($misapplied_name['authorteam']);
135
            $out .= join('; ', $misapplied_name['authorteam']);
136
        }
137
        $out .= '</li>';
138

  
139
      }
140
      $out .= '</ul>';
141
  }
142

  
143
  if(is_array($taxonRelationshipsLines) && count($taxonRelationshipsLines) >0 ){
144
      $out .= '<ul class="taxonRelationships">';
145
      foreach($taxonRelationshipsLines as $taxonRelationshipLine){
146
        $out .= '<li class="synonym">'. $taxonRelationshipLine . '</li>';
147
      }
148
      $out .= '</ul>';
149
  }
150

  
151

  
152
  $tr_footnotes = theme('cdm_footnotes', $footnoteListKey, 'li');
153
  $tr_footnotes_exploded = explode('sensu', $tr_footnotes);
154
  $tr_footnotes_aux = '';
155
  foreach ($tr_footnotes_exploded as $element){
156
    $tr_footnotes_aux .= $element;
157
  }
158
  $out .= '<ul>' . $tr_footnotes_aux . '</ul>';
159
  //$out .= '</ul>';
160
  RenderHints::popFromRenderStack();
161
  return $out;
162 162
}
163 163

  
164 164

  
165 165

  
166 166
function theme_cdm_acceptedFor(){
167
	RenderHints::pushToRenderStack('acceptedFor');
168

  
169
	$out = '';
170
	if(isset($_REQUEST['acceptedFor'])){
171

  
172
		$synonym = cdm_ws_get(CDM_WS_PORTAL_TAXON, $_REQUEST['acceptedFor']);
173

  
174
		if($synonym){
175
			$out .= '<span class="acceptedFor">';
176
			$out .= t('is accepted for ');
177
			if(isset($synonym->name->nomenclaturalReference)){
178
				$referenceUri = url(path_to_reference($synonym->name->nomenclaturalReference->uuid));
179
			}
180
			$out .= theme('cdm_taxonName', $synonym->name, null, $referenceUri);
181
			$out .= theme('cdm_annotations_as_footnotekeys', $synonym);
182
			$out .= '</span>';
183
		}
184
	}
185
	RenderHints::popFromRenderStack();
186
	return $out;
167
  RenderHints::pushToRenderStack('acceptedFor');
168

  
169
  $out = '';
170
  if(isset($_REQUEST['acceptedFor'])){
171

  
172
    $synonym = cdm_ws_get(CDM_WS_PORTAL_TAXON, $_REQUEST['acceptedFor']);
173

  
174
    if($synonym){
175
      $out .= '<span class="acceptedFor">';
176
      $out .= t('is accepted for ');
177
      if(isset($synonym->name->nomenclaturalReference)){
178
        $referenceUri = url(path_to_reference($synonym->name->nomenclaturalReference->uuid));
179
      }
180
      $out .= theme('cdm_taxonName', $synonym->name, null, $referenceUri);
181
      $out .= theme('cdm_annotations_as_footnotekeys', $synonym);
182
      $out .= '</span>';
183
    }
184
  }
185
  RenderHints::popFromRenderStack();
186
  return $out;
187 187
}
188 188

  
189 189

  
190 190

  
191 191
function theme_cdm_list_of_taxa($records, $showMedia = false){
192 192

  
193
	RenderHints::pushToRenderStack('list_of_taxa');
193
  RenderHints::pushToRenderStack('list_of_taxa');
194 194

  
195
	$form_name = 'search_gallery';
196
	//$default_values = unserialize(CDM_DATAPORTAL_GALLERY_SETTINGS);
195
  $form_name = 'search_gallery';
196
  //$default_values = unserialize(CDM_DATAPORTAL_GALLERY_SETTINGS);
197 197
    //$gallery_settings = variable_get($form_name, $default_values);
198 198

  
199 199
    $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SEARCH_GALLERY_NAME);
200 200

  
201
	$showMedia_taxa = $gallery_settings['cdm_dataportal_show_taxon_thumbnails'];
202
	$showMedia_synonyms = $gallery_settings['cdm_dataportal_show_synonym_thumbnails'];
203
	//$showMedia_taxa = variable_get('cdm_dataportal_findtaxa_show_taxon_thumbnails', 1);
204
	//$showMedia_synonyms = variable_get('cdm_dataportal_findtaxa_show_synonym_thumbnails', 0);
205

  
206
	$classification_uuid = get_taxonomictree_uuid_selected();
207

  
208
	// .. well, for sure not as performant as before, but better than nothing.
209
	$synonym_uuids = array();
210
	foreach($records as $taxon){
211
		if($taxon->class != "Taxon"){
212
			if(!array_key_exists($taxon->uuid, $synonym_uuids)){
213
				$synonym_uuids[$taxon->uuid] = $taxon->uuid;
214
			}
215
		}
216
	}
217
	// batch service not jet implemented:
218
	// $table_of_accepted = cdm_ws_property(CDM_WS_PORTAL_TAXON_ACCEPTED, join(',', $synonym_uuids));
219
	// thus ...
220
	$table_of_accepted = array();
221

  
222
	foreach($synonym_uuids as $synUuid){
223
		$table_of_accepted[$synUuid] = cdm_ws_get(CDM_WS_PORTAL_TAXON_ACCEPTED, array($synUuid, $classification_uuid));
224
	}
225

  
226
	$out = '<ul class="cdm_names" style="background-image: none;">';
227

  
228
	foreach($records as $taxon){
229
		// its a Taxon
230
		if($taxon->class == "Taxon"){
231
			$taxonUri = url(path_to_taxon($taxon->uuid));
232
			if(isset($taxon->name->nomenclaturalReference)){
233
				$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
234
			}
235
			$out .= '<li class="Taxon">'.theme('cdm_taxonName', $taxon->name, $taxonUri, $referenceUri);
236
			$out .= theme('cdm_annotations_as_footnotekeys', $taxon);
237

  
238
			if($showMedia_taxa){
239
				$out .= theme('cdm_taxon_list_thumbnails', $taxon);
240
			}
241
			$out .= '</li>';
242
		} else {
243
			// its a synonym
244
			$uuid = $taxon->uuid;
245
			$acceptedTaxa = $table_of_accepted[$uuid];
246
			if(count($acceptedTaxa) == 1){
247
				$acceptedTaxon = $acceptedTaxa[0];
248
				$taxonUri = theme('cdm_uri_to_synonym', $taxon->uuid, $acceptedTaxon->uuid, 'synonymy');
249
				if(isset($acceptedTaxon->name->nomenclaturalReference)){
250
					$referenceUri = url(path_to_reference($acceptedTaxon->name->nomenclaturalReference->uuid));
251
				}
252
				$out .= '<li class="Synonym">'.theme('cdm_taxonName', $taxon->name, $taxonUri, $referenceUri);
253
				$out .= theme('cdm_annotations_as_footnotekeys', $taxon);
254
				if($showMedia_synonyms){
255
					$out .= theme('cdm_taxon_list_thumbnails', $acceptedTaxon);
256
				}
257
				$out .= '</li>';
258
			} else {
259
				//TODO avoid using Ajax in the cdm_dynabox .... why?
260
				//TODO add media
261
				$out .= cdm_dynabox(
262
				  theme('cdm_taxonName', $taxon->name, null, null, false),
263
				  cdm_compose_url(CDM_WS_PORTAL_TAXON_ACCEPTED, array($taxon->uuid, $classification_uuid)),
264
				  'cdm_list_of_taxa',
265
				  'Click for accepted taxon');
266
			}
267
		}
268
	}
269

  
270
	$out .= '</ul>';
271
	RenderHints::popFromRenderStack();
272
	return $out;
201
  $showMedia_taxa = $gallery_settings['cdm_dataportal_show_taxon_thumbnails'];
202
  $showMedia_synonyms = $gallery_settings['cdm_dataportal_show_synonym_thumbnails'];
203
  //$showMedia_taxa = variable_get('cdm_dataportal_findtaxa_show_taxon_thumbnails', 1);
204
  //$showMedia_synonyms = variable_get('cdm_dataportal_findtaxa_show_synonym_thumbnails', 0);
205

  
206
  $classification_uuid = get_taxonomictree_uuid_selected();
207

  
208
  // .. well, for sure not as performant as before, but better than nothing.
209
  $synonym_uuids = array();
210
  foreach($records as $taxon){
211
    if($taxon->class != "Taxon"){
212
      if(!array_key_exists($taxon->uuid, $synonym_uuids)){
213
        $synonym_uuids[$taxon->uuid] = $taxon->uuid;
214
      }
215
    }
216
  }
217
  // batch service not jet implemented:
218
  // $table_of_accepted = cdm_ws_property(CDM_WS_PORTAL_TAXON_ACCEPTED, join(',', $synonym_uuids));
219
  // thus ...
220
  $table_of_accepted = array();
221

  
222
  foreach($synonym_uuids as $synUuid){
223
    $table_of_accepted[$synUuid] = cdm_ws_get(CDM_WS_PORTAL_TAXON_ACCEPTED, array($synUuid, $classification_uuid));
224
  }
225

  
226
  $out = '<ul class="cdm_names" style="background-image: none;">';
227

  
228
  foreach($records as $taxon){
229
    // its a Taxon
230
    if($taxon->class == "Taxon"){
231
      $taxonUri = url(path_to_taxon($taxon->uuid));
232
      if(isset($taxon->name->nomenclaturalReference)){
233
        $referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
234
      }
235
      $out .= '<li class="Taxon">'.theme('cdm_taxonName', $taxon->name, $taxonUri, $referenceUri);
236
      $out .= theme('cdm_annotations_as_footnotekeys', $taxon);
237

  
238
      if($showMedia_taxa){
239
        $out .= theme('cdm_taxon_list_thumbnails', $taxon);
240
      }
241
      $out .= '</li>';
242
    } else {
243
      // its a synonym
244
      $uuid = $taxon->uuid;
245
      $acceptedTaxa = $table_of_accepted[$uuid];
246
      if(count($acceptedTaxa) == 1){
247
        $acceptedTaxon = $acceptedTaxa[0];
248
        $taxonUri = theme('cdm_uri_to_synonym', $taxon->uuid, $acceptedTaxon->uuid, 'synonymy');
249
        if(isset($acceptedTaxon->name->nomenclaturalReference)){
250
          $referenceUri = url(path_to_reference($acceptedTaxon->name->nomenclaturalReference->uuid));
251
        }
252
        $out .= '<li class="Synonym">'.theme('cdm_taxonName', $taxon->name, $taxonUri, $referenceUri);
253
        $out .= theme('cdm_annotations_as_footnotekeys', $taxon);
254
        if($showMedia_synonyms){
255
          $out .= theme('cdm_taxon_list_thumbnails', $acceptedTaxon);
256
        }
257
        $out .= '</li>';
258
      } else {
259
        //TODO avoid using Ajax in the cdm_dynabox .... why?
260
        //TODO add media
261
        $out .= cdm_dynabox(
262
          theme('cdm_taxonName', $taxon->name, null, null, false),
263
          cdm_compose_url(CDM_WS_PORTAL_TAXON_ACCEPTED, array($taxon->uuid, $classification_uuid)),
264
          'cdm_list_of_taxa',
265
          'Click for accepted taxon');
266
      }
267
    }
268
  }
269

  
270
  $out .= '</ul>';
271
  RenderHints::popFromRenderStack();
272
  return $out;
273 273
}
274 274

  
275
/**
276
 * renders a representation of the given taxon relationship.
277
 * According name relatinships are also being rendered.
278
 *
279
 *
280
 * @param unknown_type $taxon
281
 * @param unknown_type $reltype_uuid
282
 * @param unknown_type $taxonRelationType
283
 * @param unknown_type $doLinkTaxon
284
 */
285
function cdm_taxonRelationship($taxonRelationship, $doLinkTaxon = false, $inverse = false){
286

  
287
  // validate object
288
  if( ! (isset($taxonRelationship->toTaxon) && isset($taxonRelationship->fromTaxon) && isset($taxonRelationship->type)) ) {
289
    return;
290
  }
291

  
292
  $reltype_uuid = $taxonRelationship->type->uuid;
293
  $taxonRelationType = $taxonRelationship->type;
275 294

  
276
function theme_cdm_related_taxon($taxon, $reltype_uuid = false, $taxonRelationType = null, $doLinkTaxon = false){
277

  
278
	static $relsign_homo = '≡';
279
	static $relsign_hetero = '=';
280
	static $relsign_invalid = '&ndash;';
281

  
282
	$name_prefix = '';
283
	$name_postfix = '';
284

  
285
	$skiptags = array();
286

  
287
	if(isset($taxonRelationType->representation_L10n_abbreviatedLabel)){
288
		$relsign = $taxonRelationType->representation_L10n_abbreviatedLabel;
289
	}
290

  
291
	$reltype_representation = '';
292
	if(isset($taxonRelationType->representation_L10n)){
293
		$reltype_representation = $taxonRelationType->representation_L10n;
294
	}
295

  
296
	if(!$relsign) {
297

  
298
		$relsign = '';
299
       	switch ($reltype_uuid){
300
    		case UUID_HETEROTYPIC_SYNONYM_OF:
301
    		case UUID_SYNONYM_OF:
302
    			$relsign = $relsign_hetero;
303
    			break;
304
    		case UUID_HOMOTYPIC_SYNONYM_OF:
305
    			$relsign = $relsign_homo;
306
    			break;
307
    		case UUID_MISAPPLIED_NAME_FOR:
308
    		case UUID_INVALID_DESIGNATION_FOR:
309
    			$skiptags[] = 'authors';
310
    			$relsign = $relsign_invalid;
311
    			$name_prefix = '"';
312
    			$name_postfix = '"';
313
    			break;
314
    		default :
315
    			$relsign = $relsign_invalid;
316
	    }
317
	}
318
	/*
319
	 * names with status invalid or nudum are to be displayed with the $relsign_invalid,
320
	 * these names appear at the end of all names in their homotypic group
321
	 * (ordered correctly by the java cdm_lib)
322
	 */
323
	if ( is_array($taxon->name->status)) {
324
		foreach($taxon->name->status as $status){
325
			if ($status->type->uuid == UUID_NOMENCLATURALSTATUS_TYPE_INVALID || $status->type->uuid == UUID_NOMENCLATURALSTATUS_TYPE_NUDUM){
326
				$relsign = $relsign_invalid;
327
			}
328
		}
329
	}
330

  
331
	// now rendering starts ..
332

  
333
	RenderHints::pushToRenderStack('related_taxon');
334

  
335
	if($taxon->name->nomenclaturalReference){
336
		$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
337
	}
338
	if($doLinkTaxon){
339
	  $taxonUri = url(path_to_taxon($taxon->uuid));
340
	}
341
	//printing the taxonName and the handling the special case of annotations
342
	$nameHtml = theme('cdm_taxonName', $taxon->name, $taxonUri, $referenceUri, true, false, $skiptags);
343
	$special_annotations_array = array();
344
	$special_annotations_array[] = $taxon->name;
345
	$special_annotations_array[] = $taxon;
346
	$nameHtml .= theme('cdm_annotations_as_footnotekeys', $special_annotations_array);
347

  
348
	//later homonym or trated as later homonym AND bloking names
349
	$from_name_relations = cdm_ws_get(CDM_WS_PORTAL_TAXON_FROM_NAMERELATIONS, $taxon->uuid);
350
	$to_name_relations = cdm_ws_get(CDM_WS_PORTAL_TAXON_TO_NAMERELATIONS, $taxon->uuid);
351
	//first the FROM RELS
352
	if ($from_name_relations){
353
		foreach($from_name_relations as $element){
354
			switch ($element->type->representation_L10n){
355
				case 'later homonym for':
356
					if(isset($name_relations_html)){
357
						$name_relations_html .= ' nec ' . l($element->toName->titleCache . ' ' .  substr($element->toName->nomenclaturalReference->datePublished->start, 0, 4),
358
						    'cdm_dataportal/name/' . $element->toName->uuid . '/' . $taxon->uuid . '/' . $element->toName->taxonBases[0]->uuid);
359
					}else{
360
						$name_relations_html = ' non ' . l($element->toName->titleCache . ' ' .  substr($element->toName->nomenclaturalReference->datePublished->start, 0, 4),
295

  
296
  $reltype_representation = '';
297

  
298
  if($inverse) {
299
    $taxon = $taxonRelationship->toTaxon;
300
    $relsign = $taxonRelationType->inverseRepresentation_L10n_abbreviatedLabel;
301
    $reltype_representation = $taxonRelationType->inverseRepresentation_L10n;
302
  } else {
303
    $taxon = $taxonRelationship->fromTaxon;
304
    $relsign = $taxonRelationType->representation_L10n_abbreviatedLabel;
305
    $reltype_representation = $taxonRelationType->representation_L10n;
306
  }
307

  
308
  return cdm_related_taxon($taxon, null, $relsign, $reltype_representation, $doLinkTaxon);
309
}
310

  
311
/**
312
* renders a representation of the given taxon relationship.
313
* According name relatinships are also being rendered.
314
*
315
*
316
* @param unknown_type $taxon
317
* @param unknown_type $reltype_uuid
318
* @param unknown_type $taxonRelationType
319
* @param unknown_type $doLinkTaxon
320
*/
321
function cdm_related_taxon($taxon, $reltype_uuid = null, $relsign = null, $reltype_representation = null, $doLinkTaxon = false){
322

  
323
  static $relsign_homo = '≡';
324
  static $relsign_hetero = '=';
325
  static $relsign_invalid = '&ndash;';
326

  
327
  $name_prefix = '';
328
  $name_postfix = '';
329

  
330
  $skiptags = array();
331

  
332
  if(!$relsign) {
333

  
334
    $relsign = '';
335
    switch ($reltype_uuid){
336
      case UUID_HETEROTYPIC_SYNONYM_OF:
337
      case UUID_SYNONYM_OF:
338
        $relsign = $relsign_hetero;
339
        break;
340
      case UUID_HOMOTYPIC_SYNONYM_OF:
341
        $relsign = $relsign_homo;
342
        break;
343
      case UUID_MISAPPLIED_NAME_FOR:
344
      case UUID_INVALID_DESIGNATION_FOR:
345
        $skiptags[] = 'authors';
346
        $relsign = $relsign_invalid;
347
        $name_prefix = '"';
348
        $name_postfix = '"';
349
        break;
350
      default :
351
        $relsign = $relsign_invalid;
352
    }
353
  }
354
  /*
355
   * names with status invalid or nudum are to be displayed with the $relsign_invalid,
356
  * these names appear at the end of all names in their homotypic group
357
  * (ordered correctly by the java cdm_lib)
358
  */
359
  if ( is_array($taxon->name->status)) {
360
    foreach($taxon->name->status as $status){
361
      if ($status->type->uuid == UUID_NOMENCLATURALSTATUS_TYPE_INVALID || $status->type->uuid == UUID_NOMENCLATURALSTATUS_TYPE_NUDUM){
362
        $relsign = $relsign_invalid;
363
      }
364
    }
365
  }
366

  
367
  // now rendering starts ..
368

  
369
  RenderHints::pushToRenderStack('related_taxon');
370

  
371
  if($taxon->name->nomenclaturalReference){
372
    $referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
373
  }
374
  if($doLinkTaxon){
375
    $taxonUri = url(path_to_taxon($taxon->uuid));
376
  }
377
  //printing the taxonName and the handling the special case of annotations
378
  $nameHtml = theme('cdm_taxonName', $taxon->name, $taxonUri, $referenceUri, true, false, $skiptags);
379
  $special_annotations_array = array();
380
  $special_annotations_array[] = $taxon->name;
381
  $special_annotations_array[] = $taxon;
382
  $nameHtml .= theme('cdm_annotations_as_footnotekeys', $special_annotations_array);
383

  
384
  //later homonym or trated as later homonym AND bloking names
385
  $from_name_relations = cdm_ws_get(CDM_WS_PORTAL_TAXON_FROM_NAMERELATIONS, $taxon->uuid);
386
  $to_name_relations = cdm_ws_get(CDM_WS_PORTAL_TAXON_TO_NAMERELATIONS, $taxon->uuid);
387
  //first the FROM RELS
388
  if ($from_name_relations){
389
    foreach($from_name_relations as $element){
390
      switch ($element->type->representation_L10n){
391
        case 'later homonym for':
392
          if(isset($name_relations_html)){
393
            $name_relations_html .= ' nec ' . l($element->toName->titleCache . ' ' .  substr($element->toName->nomenclaturalReference->datePublished->start, 0, 4),
394
                'cdm_dataportal/name/' . $element->toName->uuid . '/' . $taxon->uuid . '/' . $element->toName->taxonBases[0]->uuid);
395
          }else{
396
            $name_relations_html = ' non ' . l($element->toName->titleCache . ' ' .  substr($element->toName->nomenclaturalReference->datePublished->start, 0, 4),
361 397
                        'cdm_dataportal/name/' . $element->toName->uuid . '/' . $taxon->uuid . '/' . $element->toName->taxonBases[0]->uuid)
362
						. ' ' . $element->toName->datePublished->start;
363
					}
364
					break;
365
				case 'treated as later homonym for':
366
					if(isset($name_relations_html)){
367
						$name_relations_html = ' nec ' . l($element->toName->titleCache . ' ' .  substr($element->toName->nomenclaturalReference->datePublished->start, 0, 4),
398
            . ' ' . $element->toName->datePublished->start;
399
          }
400
          break;
401
        case 'treated as later homonym for':
402
          if(isset($name_relations_html)){
403
            $name_relations_html = ' nec ' . l($element->toName->titleCache . ' ' .  substr($element->toName->nomenclaturalReference->datePublished->start, 0, 4),
368 404
                              'cdm_dataportal/name/' . $element->toName->uuid);
369
					}else{
370
						$name_relations_html = ' non ' . l($element->toName->titleCache . ' ' .  substr($element->toName->nomenclaturalReference->datePublished->start, 0, 4),
371
					                   'cdm_dataportal/name/' . $element->toName->uuid);
372
					}
373
					break;
374
			}
375
		}
376
		//second the TO RELS
377
		if ($to_name_relations){
378
			foreach($to_name_relations as $element){
379
				switch ($element->type->representation_L10n){
380
					case 'blocking name for':
381
						if(isset($name_relations_html) ){
382
							$name_relations_html .= ' nec ' . l($element->fromName->titleCache . ' ' .  substr($element->fromName->nomenclaturalReference->datePublished->start, 0, 4),
405
          }else{
406
            $name_relations_html = ' non ' . l($element->toName->titleCache . ' ' .  substr($element->toName->nomenclaturalReference->datePublished->start, 0, 4),
407
                             'cdm_dataportal/name/' . $element->toName->uuid);
408
          }
409
          break;
410
      }
411
    }
412
    //second the TO RELS
413
    if ($to_name_relations){
414
      foreach($to_name_relations as $element){
415
        switch ($element->type->representation_L10n){
416
          case 'blocking name for':
417
            if(isset($name_relations_html) ){
418
              $name_relations_html .= ' nec ' . l($element->fromName->titleCache . ' ' .  substr($element->fromName->nomenclaturalReference->datePublished->start, 0, 4),
383 419
                'cdm_dataportal/name/' . $element->fromName->uuid . '/' . $taxon->uuid . '/' . $element->fromName->taxonBases[0]->uuid);
384
						}else{
385
							$name_relations_html = ' non ' . l($element->fromName->titleCache . ' ' .  substr($element->fromName->nomenclaturalReference->datePublished->start, 0, 4),
420
            }else{
421
              $name_relations_html = ' non ' . l($element->fromName->titleCache . ' ' .  substr($element->fromName->nomenclaturalReference->datePublished->start, 0, 4),
386 422
                        'cdm_dataportal/name/' . $element->fromName->uuid . '/' . $taxon->uuid . '/' . $element->fromName->taxonBases[0]->uuid)
387
							. ' ' . $element->fromName->datePublished->start;
388
						}
389
						break;
390
				}
391
			}
392
		}
423
              . ' ' . $element->fromName->datePublished->start;
424
            }
425
            break;
426
        }
427
      }
428
    }
393 429
    //rels output
394
		if(isset($name_relations_html)){
395
			$name_relations_html = '['. $name_relations_html .']';
396
		}
397
	}
430
    if(isset($name_relations_html)){
431
      $name_relations_html = '['. $name_relations_html .']';
432
    }
433
  }
398 434
  //geneal output
399
	$out = '<span class="relation_sign" title="' . $reltype_representation . '">'.$relsign.'</span>'.$name_prefix . $nameHtml . $name_postfix . $name_relations_html;
400
	$out = uuid_anchor($taxon->uuid, $out);
435
  $out = '<span class="relation_sign" title="' . $reltype_representation . '">'.$relsign.'</span>'.$name_prefix . $nameHtml . $name_postfix . $name_relations_html;
436
  $out = uuid_anchor($taxon->uuid, $out);
401 437

  
402
	RenderHints::popFromRenderStack();
438
  RenderHints::popFromRenderStack();
403 439

  
404
	return $out;
440
  return $out;
405 441
}
406 442

  
407 443
/**
......
409 445
function theme_cdm_taxon_list_thumbnails($taxon){
410 446

  
411 447

  
412
	$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SEARCH_GALLERY_NAME);
413
	$showCaption = $gallery_settings['cdm_dataportal_show_thumbnail_captions'];
448
  $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SEARCH_GALLERY_NAME);
449
  $showCaption = $gallery_settings['cdm_dataportal_show_thumbnail_captions'];
414 450

  
415
	if($showCaption){
416
		$captionElements = array('title', 'rights');
417
	}
451
  if($showCaption){
452
    $captionElements = array('title', 'rights');
453
  }
418 454

  
419
	$gallery_name = $taxon->uuid;
455
  $gallery_name = $taxon->uuid;
420 456

  
421
 	$mediaQueryParameters = array("type"=>"ImageFile");
422
	$galleryLinkUri = path_to_taxon($taxon->uuid).'/images';
457
   $mediaQueryParameters = array("type"=>"ImageFile");
458
  $galleryLinkUri = path_to_taxon($taxon->uuid).'/images';
423 459

  
424
	// cdm_dataportal_show_media = ???? TODO
425
	$selectShowMedia = variable_get('cdm_dataportal_show_media', 0);
426
	if ($selectShowMedia == 0){
427
		$mediaList = cdm_ws_get(CDM_WS_PORTAL_TAXON_MEDIA, array($taxon->uuid), queryString( $mediaQueryParameters ));
428
	}else{
429
		$mediaList = cdm_ws_get(CDM_WS_PORTAL_TAXON_SUBTREE_MEDIA, array($taxon->uuid), queryString( $mediaQueryParameters ));
430
	}
460
  // cdm_dataportal_show_media = ???? TODO
461
  $selectShowMedia = variable_get('cdm_dataportal_show_media', 0);
462
  if ($selectShowMedia == 0){
463
    $mediaList = cdm_ws_get(CDM_WS_PORTAL_TAXON_MEDIA, array($taxon->uuid), queryString( $mediaQueryParameters ));
464
  }else{
465
    $mediaList = cdm_ws_get(CDM_WS_PORTAL_TAXON_SUBTREE_MEDIA, array($taxon->uuid), queryString( $mediaQueryParameters ));
466
  }
431 467

  
432
	$out .= theme('cdm_media_gallerie', $mediaList, $gallery_name ,
433
    	$gallery_settings['cdm_dataportal_media_maxextend'],
434
    	$gallery_settings['cdm_dataportal_media_cols'],
435
    	$gallery_settings['cdm_dataportal_media_maxRows'],
436
    	$captionElements, 'LIGHTBOX', null, $galleryLinkUri);
468
  $out .= theme('cdm_media_gallerie', $mediaList, $gallery_name ,
469
      $gallery_settings['cdm_dataportal_media_maxextend'],
470
      $gallery_settings['cdm_dataportal_media_cols'],
471
      $gallery_settings['cdm_dataportal_media_maxRows'],
472
      $captionElements, 'LIGHTBOX', null, $galleryLinkUri);
437 473

  
438
	return $out;
474
  return $out;
439 475
}
440 476

  
441 477

  

Also available in: Unified diff