1 |
806baeb2
|
Andreas Kohlbecker
|
<?php
|
2 |
|
|
// $Id$
|
3 |
|
|
|
4 |
|
|
/**
|
5 |
35eafafb
|
f.revilla
|
* 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 |
806baeb2
|
Andreas Kohlbecker
|
|
13 |
c2c8970d
|
Andreas Kohlbecker
|
|
14 |
806baeb2
|
Andreas Kohlbecker
|
function theme_cdm_feature_nodesTOC($featureNodes){
|
15 |
|
|
|
16 |
0364559b
|
Andreas Kohlbecker
|
$out .= '<ul>';
|
17 |
|
|
|
18 |
|
|
foreach($featureNodes as $node){
|
19 |
294bea51
|
Andreas Kohlbecker
|
|
20 |
|
|
if(hasFeatureNodeDescriptionElements($node)){
|
21 |
0364559b
|
Andreas Kohlbecker
|
|
22 |
|
|
$featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
|
23 |
|
|
// HACK to implement images for taxa, should be removed
|
24 |
|
|
if($node->feature->uuid != UUID_IMAGE){
|
25 |
|
|
$out .= '<li>'.l(t(theme('cdm_feature_name', $featureRepresentation)), $_GET['q'], array("class"=>"toc"), NULL, generalizeString($featureRepresentation)).'</li>';
|
26 |
|
|
}
|
27 |
|
|
}
|
28 |
|
|
}
|
29 |
806baeb2
|
Andreas Kohlbecker
|
|
30 |
0364559b
|
Andreas Kohlbecker
|
$out .= '</ul>';
|
31 |
|
|
return $out;
|
32 |
806baeb2
|
Andreas Kohlbecker
|
}
|
33 |
|
|
|
34 |
|
|
function theme_cdm_feature_name($feature_name){
|
35 |
0364559b
|
Andreas Kohlbecker
|
//TODO replace by using translations ?
|
36 |
|
|
switch($feature_name){
|
37 |
|
|
default: return t(ucfirst($feature_name));
|
38 |
|
|
}
|
39 |
806baeb2
|
Andreas Kohlbecker
|
}
|
40 |
|
|
|
41 |
16f9664d
|
Andreas Kohlbecker
|
/**
|
42 |
|
|
* Renders the taxon profile. The taxon profile consists of description elements
|
43 |
|
|
* which are ordered by the structure defined by specific FeatureTree. The chosen
|
44 |
|
|
* FeatureTree is merged with the list of desctiprion elements prior to using this
|
45 |
|
|
* method (see function cdm_ws_descriptions_by_featuretree() ).
|
46 |
|
|
*
|
47 |
|
|
* @param unknown_type $mergedTrees
|
48 |
|
|
* @param unknown_type $taxon The taxon whose sprofile to show
|
49 |
|
|
*/
|
50 |
806baeb2
|
Andreas Kohlbecker
|
function theme_cdm_featureTrees($mergedTrees, $taxon){
|
51 |
0364559b
|
Andreas Kohlbecker
|
if(!$mergedTrees){
|
52 |
|
|
return;
|
53 |
|
|
}
|
54 |
|
|
foreach($mergedTrees as &$mTree){
|
55 |
7e510a5a
|
Andreas Kohlbecker
|
//TODO display title and reference in case of multiple $mergedTrees -> theme
|
56 |
0364559b
|
Andreas Kohlbecker
|
$out .= theme('cdm_feature_nodes', $mTree->root->children, $taxon);
|
57 |
|
|
}
|
58 |
|
|
return $out;
|
59 |
806baeb2
|
Andreas Kohlbecker
|
}
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
function theme_cdm_featureTreeTOCs($mergedTrees){
|
64 |
|
|
|
65 |
0364559b
|
Andreas Kohlbecker
|
if(!$mergedTrees){
|
66 |
|
|
return;
|
67 |
|
|
}
|
68 |
|
|
//FIXME
|
69 |
447f45e7
|
Andreas Kohlbecker
|
$out = '<div id="featureTOC">';
|
70 |
0364559b
|
Andreas Kohlbecker
|
$out .= '<h2>' . t('Content') .'</h2>';
|
71 |
806baeb2
|
Andreas Kohlbecker
|
|
72 |
0364559b
|
Andreas Kohlbecker
|
//TODO diplay title and reference in case of multiple $mergedTrees -> theme
|
73 |
806baeb2
|
Andreas Kohlbecker
|
|
74 |
0364559b
|
Andreas Kohlbecker
|
foreach($mergedTrees as &$mTree){
|
75 |
|
|
$out .= theme('cdm_feature_nodesTOC', $mTree->root->children);
|
76 |
|
|
}
|
77 |
806baeb2
|
Andreas Kohlbecker
|
|
78 |
0364559b
|
Andreas Kohlbecker
|
$out .= '</div>';
|
79 |
|
|
return $out;
|
80 |
806baeb2
|
Andreas Kohlbecker
|
}
|
81 |
|
|
|
82 |
|
|
|
83 |
3467d3b2
|
Andreas Kohlbecker
|
/**
|
84 |
7e510a5a
|
Andreas Kohlbecker
|
* Renders the $mergedFeatureNodes for the given $taxon.
|
85 |
3467d3b2
|
Andreas Kohlbecker
|
* The merged nodes can be obtained by making use of the
|
86 |
|
|
* function cdm_ws_descriptions_by_featuretree()
|
87 |
|
|
*
|
88 |
|
|
* @param unknown_type $featureNodes
|
89 |
|
|
* @param unknown_type $taxon
|
90 |
|
|
*/
|
91 |
|
|
function theme_cdm_feature_nodes($mergedFeatureNodes, $taxon){
|
92 |
806baeb2
|
Andreas Kohlbecker
|
|
93 |
0364559b
|
Andreas Kohlbecker
|
RenderHints::pushToRenderStack('feature_nodes');
|
94 |
|
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME);
|
95 |
|
|
|
96 |
afc363df
|
Andreas Kohlbecker
|
foreach($mergedFeatureNodes as $node){
|
97 |
7e510a5a
|
Andreas Kohlbecker
|
|
98 |
294bea51
|
Andreas Kohlbecker
|
if(hasFeatureNodeDescriptionElements($node)) {
|
99 |
95944919
|
Andreas Kohlbecker
|
|
100 |
0364559b
|
Andreas Kohlbecker
|
$featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
|
101 |
|
|
$block->module = 'cdm_dataportal';
|
102 |
|
|
|
103 |
95944919
|
Andreas Kohlbecker
|
$media_list = array();
|
104 |
|
|
|
105 |
7e3ad261
|
Andreas Kohlbecker
|
if($node->feature->uuid != UUID_IMAGE) {
|
106 |
afc363df
|
Andreas Kohlbecker
|
|
107 |
0364559b
|
Andreas Kohlbecker
|
$block->delta = generalizeString($featureRepresentation);
|
108 |
54e498e3
|
Andreas Kohlbecker
|
$block->subject = '<span class="'. html_class_atttibute_ref($node->feature) . '">' . theme('cdm_feature_name', $featureRepresentation) . '</span>';
|
109 |
0364559b
|
Andreas Kohlbecker
|
$block->module = "cdm_dataportal-feature";
|
110 |
|
|
$block->content = '';
|
111 |
|
|
|
112 |
afc363df
|
Andreas Kohlbecker
|
/*
|
113 |
|
|
* Content/DISTRIBUTION
|
114 |
|
|
*/
|
115 |
0364559b
|
Andreas Kohlbecker
|
if($node->feature->uuid == UUID_DISTRIBUTION){
|
116 |
|
|
|
117 |
|
|
if(variable_get(DISTRIBUTION_TEXTDATA_DISPLAY_ON_TOP, 0)){
|
118 |
|
|
$distributionTextDataList = array();
|
119 |
|
|
$distributionElementsList = array();
|
120 |
|
|
foreach($node->descriptionElements as $descriptionElement){
|
121 |
|
|
if($descriptionElement->class == "TextData"){
|
122 |
|
|
$distributionTextDataList[] = $descriptionElement;
|
123 |
|
|
} else {
|
124 |
|
|
$distributionElementsList[] = $descriptionElement;
|
125 |
|
|
}
|
126 |
|
|
}
|
127 |
|
|
if(count($distributionTextDataList) > 0){
|
128 |
|
|
$node->descriptionElements = $distributionElementsList;
|
129 |
|
|
$block->content .= theme('cdm_descriptionElements', $distributionTextDataList, $node->feature->uuid, $taxon->uuid);
|
130 |
|
|
}
|
131 |
|
|
}
|
132 |
ecc6714f
|
f.revilla
|
|
133 |
0364559b
|
Andreas Kohlbecker
|
// Display cdm distribution map TODO this is a HACK to a proper generic implementation?
|
134 |
|
|
$block->content .= theme('cdm_distribution_map', $taxon);
|
135 |
7e3ad261
|
Andreas Kohlbecker
|
$block->content .= theme('cdm_descriptionElements', $node->descriptionElements, $node->feature->uuid, $taxon->uuid);
|
136 |
0364559b
|
Andreas Kohlbecker
|
}
|
137 |
|
|
|
138 |
afc363df
|
Andreas Kohlbecker
|
/*
|
139 |
|
|
* Content/COMMON_NAME
|
140 |
|
|
*/
|
141 |
|
|
else if ($node->feature->uuid == UUID_COMMON_NAME){
|
142 |
0364559b
|
Andreas Kohlbecker
|
$block->content .= theme('cdm_common_names', $node->descriptionElements);
|
143 |
|
|
/*
|
144 |
|
|
}else if($node->feature->uuid == UUID_IMAGE_SOURCES) {
|
145 |
|
|
$block->content .= theme('cdm_image_sources', $node->descriptionElements);
|
146 |
|
|
*/
|
147 |
afc363df
|
Andreas Kohlbecker
|
}
|
148 |
|
|
|
149 |
|
|
/*
|
150 |
|
|
* Content/ALL OTHER FEATURES
|
151 |
|
|
*/
|
152 |
|
|
else {
|
153 |
0364559b
|
Andreas Kohlbecker
|
$block->content .= theme('cdm_descriptionElements', $node->descriptionElements, $node->feature->uuid, $taxon->uuid);
|
154 |
afc363df
|
Andreas Kohlbecker
|
|
155 |
|
|
/*
|
156 |
|
|
* Content/ALL OTHER FEATURES/Subordinate Features
|
157 |
|
|
*
|
158 |
|
|
* subordinate features are printed inline in one floating text,
|
159 |
|
|
* it is expected that supordinate features only "contain" TextData elements
|
160 |
|
|
*/
|
161 |
|
|
// TODO move into own theme
|
162 |
|
|
if(count($node->children) > 0){
|
163 |
|
|
|
164 |
|
|
//TODO support more than one level of childen http://dev.e-taxonomy.eu/trac/ticket/2393
|
165 |
|
|
$text = '';
|
166 |
|
|
foreach ($node->children as $child){
|
167 |
|
|
|
168 |
|
|
if (is_array($child->descriptionElements)){
|
169 |
|
|
foreach ($child->descriptionElements as $element) {
|
170 |
|
|
|
171 |
|
|
if(is_array($element->media)){
|
172 |
|
|
// append media of supordinate emelents to list of main feature
|
173 |
|
|
$media_list = array_merge($media_list, $element->media);
|
174 |
|
|
}
|
175 |
|
|
|
176 |
|
|
$description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
|
177 |
|
|
//TODO use localized version of feature name, the locale must match the locale of the multilanguage text (http://dev.e-taxonomy.eu/trac/ticket/2394)
|
178 |
|
|
$description = str_replace($element->feature->titleCache, '<em>' . $element->feature->titleCache . '</em>', $description);
|
179 |
|
|
}
|
180 |
|
|
$text .= " " . $description;
|
181 |
|
|
$description = '';
|
182 |
|
|
}
|
183 |
|
|
|
184 |
|
|
}
|
185 |
|
|
$block->content .= $text;
|
186 |
|
|
}
|
187 |
|
|
|
188 |
0364559b
|
Andreas Kohlbecker
|
}
|
189 |
|
|
|
190 |
afc363df
|
Andreas Kohlbecker
|
/*
|
191 |
|
|
* Media/ALL FEATURES
|
192 |
|
|
*/
|
193 |
|
|
$media_list = array_merge($media_list, cdm_dataportal_media_from_descriptionElements($node->descriptionElements));
|
194 |
0364559b
|
Andreas Kohlbecker
|
$captionElements = array('title', 'rights');
|
195 |
7e510a5a
|
Andreas Kohlbecker
|
|
196 |
|
|
$gallery = theme('cdm_media_gallerie', $media_list, CDM_DATAPORTAL_DESCRIPTION_GALLERY_NAME.'_'.$node->feature->uuid,
|
197 |
|
|
$gallery_settings['cdm_dataportal_media_maxextend'],
|
198 |
|
|
$gallery_settings['cdm_dataportal_media_cols'],
|
199 |
|
|
$gallery_settings['cdm_dataportal_media_maxRows'],
|
200 |
|
|
$captionElements
|
201 |
0364559b
|
Andreas Kohlbecker
|
);
|
202 |
|
|
|
203 |
7e510a5a
|
Andreas Kohlbecker
|
$block->content .= $gallery;
|
204 |
0364559b
|
Andreas Kohlbecker
|
$block->content .= theme('cdm_footnotes', $node->feature->uuid);
|
205 |
|
|
$block->content .= theme('cdm_annotation_footnotes', $node->feature->uuid);
|
206 |
|
|
|
207 |
294bea51
|
Andreas Kohlbecker
|
// add anchor to subject
|
208 |
|
|
$block->subject = '<a name="'.$block->delta.'"></a>'. $block->subject;
|
209 |
0364559b
|
Andreas Kohlbecker
|
|
210 |
294bea51
|
Andreas Kohlbecker
|
$out .= theme('block', $block);
|
211 |
0364559b
|
Andreas Kohlbecker
|
}
|
212 |
|
|
}
|
213 |
|
|
|
214 |
|
|
}
|
215 |
|
|
RenderHints::popFromRenderStack();
|
216 |
|
|
return $out;
|
217 |
806baeb2
|
Andreas Kohlbecker
|
}
|
218 |
|
|
|
219 |
ff59ee31
|
Andreas Kohlbecker
|
function theme_FeatureTree_hierarchy($FeatureTreeUuid){
|
220 |
|
|
|
221 |
0364559b
|
Andreas Kohlbecker
|
if(!is_uuid($FeatureTreeUuid)){
|
222 |
|
|
return;
|
223 |
|
|
}
|
224 |
ff59ee31
|
Andreas Kohlbecker
|
$out = '';
|
225 |
0364559b
|
Andreas Kohlbecker
|
$featureTree = cdm_ws_get(CDM_WS_FEATURETREE, array($FeatureTreeUuid));
|
226 |
|
|
if($featureTree && $featureTree->root){
|
227 |
|
|
$out = '<ul class="'.$featureTree->class.'">';
|
228 |
|
|
$out .= theme('FeatureTree_hierarchy_children', $featureTree->root);
|
229 |
|
|
$out .= '</ul>';
|
230 |
|
|
}
|
231 |
|
|
return $out;
|
232 |
ff59ee31
|
Andreas Kohlbecker
|
}
|
233 |
|
|
|
234 |
|
|
function theme_FeatureTree_hierarchy_children($node){
|
235 |
|
|
|
236 |
0364559b
|
Andreas Kohlbecker
|
$out = '';
|
237 |
|
|
if($node->children){
|
238 |
ff59ee31
|
Andreas Kohlbecker
|
|
239 |
0364559b
|
Andreas Kohlbecker
|
foreach($node->children as $childNode){
|
240 |
ff59ee31
|
Andreas Kohlbecker
|
$out .= '<li>'.check_plain($childNode->feature->representation_L10n);
|
241 |
7e510a5a
|
Andreas Kohlbecker
|
if($childNode->children && count($childNode->children) > 0){
|
242 |
0364559b
|
Andreas Kohlbecker
|
$out .= '<ul>'.theme('FeatureTree_hierarchy_children', $childNode).'</ul>';
|
243 |
ff59ee31
|
Andreas Kohlbecker
|
}
|
244 |
|
|
$out .= '</li>';
|
245 |
0364559b
|
Andreas Kohlbecker
|
}
|
246 |
|
|
}
|
247 |
|
|
return $out;
|
248 |
ff59ee31
|
Andreas Kohlbecker
|
}
|
249 |
|
|
|
250 |
806baeb2
|
Andreas Kohlbecker
|
|
251 |
|
|
|
252 |
7e510a5a
|
Andreas Kohlbecker
|
/**
|
253 |
|
|
*
|
254 |
|
|
* Join the texts in $elementArray and enclose with a HTML tag
|
255 |
|
|
* @param unknown_type $elementArray
|
256 |
|
|
* @param unknown_type $feature the feature to which the elements given in $elementArray are belonging to
|
257 |
|
|
* @param unknown_type $glue defaults to empty string
|
258 |
|
|
* @param unknown_type $sortArray whether to sort the $elementArray alphabetically
|
259 |
|
|
* @param unknown_type $enclosingHtml
|
260 |
|
|
*/
|
261 |
806baeb2
|
Andreas Kohlbecker
|
function theme_cdm_descriptionElementArray($elementArray, $feature, $glue = '', $sortArray = false, $enclosingHtml = 'ul'){
|
262 |
0364559b
|
Andreas Kohlbecker
|
$out = '<'.$enclosingHtml.' class="description" id="'.$feature->representation_L10n.'">';
|
263 |
806baeb2
|
Andreas Kohlbecker
|
|
264 |
0364559b
|
Andreas Kohlbecker
|
if($sortArray) sort($elementArray);
|
265 |
806baeb2
|
Andreas Kohlbecker
|
|
266 |
0364559b
|
Andreas Kohlbecker
|
$out .= join($elementArray, $glue);
|
267 |
806baeb2
|
Andreas Kohlbecker
|
|
268 |
0364559b
|
Andreas Kohlbecker
|
$out .= '</'.$enclosingHtml.'>';
|
269 |
|
|
return $out;
|
270 |
806baeb2
|
Andreas Kohlbecker
|
}
|
271 |
|
|
|
272 |
35eafafb
|
f.revilla
|
|
273 |
|
|
function theme_cdm_descriptionElement_CommonTaxonName($element){
|
274 |
0364559b
|
Andreas Kohlbecker
|
$out = $element->language->representation_L10n . ' (' . $element->area->titleCache . '): ' . $element->name;
|
275 |
|
|
return $out;
|
276 |
35eafafb
|
f.revilla
|
}
|
277 |
e742cf3b
|
f.revilla
|
|
278 |
2264b60d
|
Andreas Kohlbecker
|
|
279 |
806baeb2
|
Andreas Kohlbecker
|
/**
|
280 |
35eafafb
|
f.revilla
|
* TODO: assign a new name to the function? because it is used for the citations
|
281 |
806baeb2
|
Andreas Kohlbecker
|
* textdata elements and not for all text data description elements
|
282 |
|
|
* @param $element The description element which contains the text information
|
283 |
35eafafb
|
f.revilla
|
* @param $asListElement A boolean which determines whether the citations should
|
284 |
|
|
* be renderer as a list or not
|
285 |
806baeb2
|
Andreas Kohlbecker
|
* @return unknown_type Html to be renderized in drupal
|
286 |
|
|
*/
|
287 |
0a579fac
|
f.revilla
|
function theme_cdm_descriptionElementTextData($element, $asListElement, $feature_uuid = null){
|
288 |
7e3ad261
|
Andreas Kohlbecker
|
|
289 |
0364559b
|
Andreas Kohlbecker
|
$description = str_replace("\n", "<br/>", $element->multilanguageText_L10n->text);
|
290 |
|
|
$sourceRefs = '';
|
291 |
|
|
$result = array();
|
292 |
|
|
$out;
|
293 |
|
|
$res_author;
|
294 |
|
|
$res_date;
|
295 |
|
|
|
296 |
|
|
if(is_array($element->sources)){
|
297 |
|
|
foreach($element->sources as $source){
|
298 |
|
|
$referenceCitation = theme('cdm_DescriptionElementSource', $source);
|
299 |
2264b60d
|
Andreas Kohlbecker
|
if($description && strlen($description) > 0 && $referenceCitation ){
|
300 |
|
|
$sourceRefs .= ' ('.$referenceCitation.')' ;
|
301 |
|
|
}else if ($referenceCitation){
|
302 |
|
|
$sourceRefs = $referenceCitation;
|
303 |
|
|
}
|
304 |
90713556
|
Andreas Kohlbecker
|
|
305 |
2264b60d
|
Andreas Kohlbecker
|
if(strlen($sourceRefs) > 0){
|
306 |
|
|
$sourceRefs = '<span class="sources">' . $sourceRefs . '</span>';
|
307 |
|
|
}
|
308 |
90713556
|
Andreas Kohlbecker
|
|
309 |
2264b60d
|
Andreas Kohlbecker
|
if ($source->nameUsedInSource->uuid){ //do a link to name page
|
310 |
|
|
$name_used_in_source_link_to_show = l($source->nameUsedInSource->titleCache,
|
311 |
|
|
path_to_name($source->nameUsedInSource->uuid),
|
312 |
|
|
array(), NULL, NULL, FALSE ,TRUE);
|
313 |
|
|
}else if (strlen($source->nameUsedInSource->originalNameString) > 0){ //show a text without link
|
314 |
|
|
$name_used_in_source_link_to_show = $source->nameUsedInSource->originalNameString;
|
315 |
|
|
}
|
316 |
90713556
|
Andreas Kohlbecker
|
|
317 |
2264b60d
|
Andreas Kohlbecker
|
if ($asListElement){
|
318 |
|
|
$out = '<li class="descriptionText">' . $name_used_in_source_link_to_show;
|
319 |
|
|
//adding ":" if necesary
|
320 |
|
|
if ($name_used_in_source_link_to_show && ($description || $sourceRefs)){
|
321 |
|
|
$out .= ': ';
|
322 |
|
|
}
|
323 |
c8b3ae89
|
Andreas Kohlbecker
|
$out .= $description . $sourceRefs . theme('cdm_annotations_as_footnotekeys', $element, $feature_uuid) . '</li>';
|
324 |
2264b60d
|
Andreas Kohlbecker
|
}else{
|
325 |
|
|
if ($name_used_in_source_link_to_show){
|
326 |
|
|
$name_used_in_source_link_to_show = ' (name in source: '. $name_used_in_source_link_to_show . ')';
|
327 |
|
|
}
|
328 |
|
|
$out = $description . $sourceRefs . $name_used_in_source_link_to_show;
|
329 |
|
|
}
|
330 |
0364559b
|
Andreas Kohlbecker
|
}
|
331 |
|
|
}
|
332 |
|
|
//if no sources, print the description
|
333 |
|
|
if(!isset($out)) {
|
334 |
|
|
$out = $description;
|
335 |
|
|
}
|
336 |
c8b3ae89
|
Andreas Kohlbecker
|
|
337 |
0364559b
|
Andreas Kohlbecker
|
return $out;
|
338 |
806baeb2
|
Andreas Kohlbecker
|
}
|
339 |
|
|
|
340 |
2264b60d
|
Andreas Kohlbecker
|
|
341 |
35eafafb
|
f.revilla
|
function theme_cdm_common_names($elements){
|
342 |
0364559b
|
Andreas Kohlbecker
|
$text_data_out = '';
|
343 |
|
|
$common_name_out = '';
|
344 |
|
|
$separator = ',';
|
345 |
|
|
$textData_commonNames = array();
|
346 |
|
|
|
347 |
|
|
|
348 |
|
|
if (is_array($elements)){
|
349 |
|
|
foreach ($elements as $element){
|
350 |
|
|
if ($element->class == 'CommonTaxonName'){
|
351 |
|
|
//$key = '<b>' . $element->language->representation_L10n . '</b> (' . $element->area->titleCache . ')';
|
352 |
|
|
if ($element->language->representation_L10n){
|
353 |
|
|
$key = '<b>' . $element->language->representation_L10n . '</b>';
|
354 |
|
|
$key .= (strlen($element->area->titleCache)>0) ? ' (' . $element->area->titleCache . ')' : '';
|
355 |
|
|
}
|
356 |
|
|
$common_names[$key][] = $element;
|
357 |
|
|
}else if ($element->class == 'TextData'){
|
358 |
|
|
//else if ($element->class == 'TextData' && $element->feature->uuid == UUID_COMMON_NAME){
|
359 |
|
|
$textData_commonNames[] = $element;
|
360 |
|
|
}
|
361 |
|
|
}
|
362 |
|
|
}
|
363 |
|
|
//handling common names
|
364 |
|
|
|
365 |
|
|
if (count($common_names) > 0){
|
366 |
|
|
//sorting the a-array based on the area (key)
|
367 |
|
|
ksort($common_names);
|
368 |
|
|
//creating the output to be render by drupal
|
369 |
|
|
foreach ($common_names as $key => $elements){
|
370 |
|
|
$rendered_element_list = '';
|
371 |
|
|
foreach($elements as $element){
|
372 |
|
|
$sourcesFootnoteKeyList = '';
|
373 |
|
|
// adding footnotes sources
|
374 |
|
|
foreach($element->sources as $source){
|
375 |
|
|
if(_is_original_source_type($source)){
|
376 |
|
|
$_fkey = FootnoteManager::addNewFootnote(UUID_COMMON_NAME, theme('cdm_DescriptionElementSource', $source, false));
|
377 |
|
|
$sourcesFootnoteKeyList .= theme('cdm_footnote_key', $_fkey, ($sourcesFootnoteKeyList ? $separator : ''));
|
378 |
|
|
}
|
379 |
|
|
}
|
380 |
|
|
if($element->name){
|
381 |
|
|
$rendered_element_list .= (strlen($rendered_element_list) > 0 ? ', ': '') . $element->name . $sourcesFootnoteKeyList;
|
382 |
|
|
}
|
383 |
|
|
}
|
384 |
|
|
if ($key){
|
385 |
|
|
$common_name_out .= (strlen($common_name_out) > 0 ? '; ': '') . $key . ': ' . $rendered_element_list;
|
386 |
|
|
}else{
|
387 |
|
|
$common_name_out .= (strlen($common_name_out) > 0 ? '; ': '') . $rendered_element_list;
|
388 |
|
|
}
|
389 |
|
|
}
|
390 |
|
|
}
|
391 |
|
|
//handling commons names as text data
|
392 |
|
|
foreach($textData_commonNames as $text_data_element){
|
393 |
|
|
$text_data_out .= theme('cdm_descriptionElementTextData', $text_data_element, true, $text_data_element->feature->uuid);
|
394 |
|
|
}
|
395 |
2ad9878b
|
Andreas Kohlbecker
|
|
396 |
0364559b
|
Andreas Kohlbecker
|
$common_name_out = "<div class=common_names_as_common_names> $common_name_out </div>";
|
397 |
e742cf3b
|
f.revilla
|
$out_array[] = $text_data_out;
|
398 |
0364559b
|
Andreas Kohlbecker
|
$common_name_out_text_data = '<div class=common_names_as_text_data>' . theme('cdm_descriptionElementArray', $out_array, $element->feature) . '</div>';
|
399 |
2ad9878b
|
Andreas Kohlbecker
|
|
400 |
0364559b
|
Andreas Kohlbecker
|
return $common_name_out . $common_name_out_text_data;
|
401 |
|
|
//return $common_name_out . theme('cdm_descriptionElementArray', $out_array, $element->feature);
|
402 |
|
|
//return "<div class=common_names> $common_name_out $common_name_out_text_data";
|
403 |
35eafafb
|
f.revilla
|
}
|
404 |
|
|
|
405 |
806baeb2
|
Andreas Kohlbecker
|
/**
|
406 |
|
|
* Theme a list of description elements, usually of a specific feature type
|
407 |
|
|
* @param $descriptionElements
|
408 |
|
|
* @return unknown_type
|
409 |
|
|
*/
|
410 |
4ed510e8
|
f.revilla
|
function theme_cdm_descriptionElements($descriptionElements, $featureUuid, $taxon_uuid){
|
411 |
0364559b
|
Andreas Kohlbecker
|
|
412 |
|
|
$outArray = array();
|
413 |
|
|
|
414 |
|
|
/*
|
415 |
|
|
$userDefined = mixed_variable_get(LAYOUT_SETTING_PREFIX . $featureUuid, FEATURE_TREE_LAYOUT_DEFAULTS);
|
416 |
|
|
if(variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT'){
|
417 |
|
|
$glue = '';
|
418 |
|
|
$enclosingTag = 'dl';
|
419 |
|
|
$entryEnclosingTag = null;
|
420 |
|
|
} else if($userDefined && $userDefined['enabled']){
|
421 |
|
|
$glue = $userDefined['glue'];
|
422 |
|
|
$enclosingTag = $userDefined['enclosingTag'];
|
423 |
|
|
$entryEnclosingTag = $userDefined['entryEnclosingTag'];
|
424 |
|
|
} else {
|
425 |
|
|
// TODO remove once LAYOUT_SETTING_PREFIX-{uuid} seeting are confired to work for all portals (selenium test still missing!!!)
|
426 |
|
|
$glue = '';
|
427 |
|
|
$enclosingTag = 'ul';
|
428 |
|
|
$entryEnclosingTag = null ;
|
429 |
|
|
}
|
430 |
|
|
*/
|
431 |
|
|
|
432 |
f609dfdb
|
Andreas Kohlbecker
|
if(variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT'){
|
433 |
16718c52
|
Andreas Kohlbecker
|
$glue = '';
|
434 |
bd9dd43a
|
Andreas Kohlbecker
|
$enclosingTag = 'dl';
|
435 |
16718c52
|
Andreas Kohlbecker
|
} else {
|
436 |
|
|
$glue = '';
|
437 |
bd9dd43a
|
Andreas Kohlbecker
|
$enclosingTag = 'ul';
|
438 |
16718c52
|
Andreas Kohlbecker
|
}
|
439 |
adb8c38b
|
Andreas Kohlbecker
|
|
440 |
0364559b
|
Andreas Kohlbecker
|
$sortOutArray = false;
|
441 |
|
|
$distributionElements = array();
|
442 |
|
|
|
443 |
|
|
RenderHints::pushToRenderStack('cdm_descriptionElements');
|
444 |
|
|
|
445 |
|
|
if(is_array($descriptionElements)){//avoiding warning box in drupal for flora malesiana
|
446 |
|
|
foreach($descriptionElements as $descriptionElement) {
|
447 |
|
|
|
448 |
|
|
// --- DISTRIBUTION ---- //
|
449 |
|
|
if($descriptionElement->feature->uuid == UUID_DISTRIBUTION){
|
450 |
|
|
if($descriptionElement->class == 'Distribution'){
|
451 |
|
|
$sortKey = $descriptionElement->area->representation_L10n;
|
452 |
|
|
$distributionElements[$sortKey]= $descriptionElement;
|
453 |
|
|
} else if($descriptionElement->class == 'TextData'){
|
454 |
|
|
$asListElement = false;
|
455 |
|
|
$repr = theme ('cdm_descriptionElementTextData', $descriptionElement, $asListElement, $descriptionElement->feature->uuid);
|
456 |
|
|
|
457 |
|
|
if( !array_search($repr, $outArray)){
|
458 |
3467d3b2
|
Andreas Kohlbecker
|
$outArray[] = $repr;
|
459 |
0364559b
|
Andreas Kohlbecker
|
//TODO HINT: sorting in theme_cdm_descriptionElementArray will not work since this array contains html attributes with uuids !!!!
|
460 |
|
|
$sortOutArray = true;
|
461 |
|
|
$glue = '<br/> ';
|
462 |
|
|
$enclosingTag = 'p';
|
463 |
|
|
}
|
464 |
|
|
}
|
465 |
|
|
}
|
466 |
|
|
|
467 |
|
|
// --- IMAGE_SOURCES --- //
|
468 |
|
|
else if($descriptionElement->feature->uuid == UUID_IMAGE_SOURCES){
|
469 |
|
|
$image_sources[] = $descriptionElement;
|
470 |
|
|
}
|
471 |
|
|
|
472 |
|
|
// ---- class == TextData ---- //
|
473 |
|
|
else if($descriptionElement->class == 'TextData'){
|
474 |
|
|
$asListElement = true;
|
475 |
|
|
$outArray[] = theme('cdm_descriptionElementTextData', $descriptionElement, $asListElement, $descriptionElement->feature->uuid);
|
476 |
|
|
}else if ($descriptionElement->class == 'CommonTaxonName') {
|
477 |
|
|
$outArray[] = theme('cdm_descriptionElement_CommonTaxonName', $descriptionElement);
|
478 |
|
|
}else {
|
479 |
|
|
$outArray[] = '<li>No method for rendering unknown description class: '.$descriptionElement->classType.'</li>';
|
480 |
|
|
}
|
481 |
94bb9048
|
f.revilla
|
}
|
482 |
0364559b
|
Andreas Kohlbecker
|
}
|
483 |
|
|
|
484 |
|
|
//if feature = NAME USAGE sort the list of sources
|
485 |
|
|
//this is ONLY for FLORA MALESIANA and FLORE d'AFRIQUE CENTRALE
|
486 |
|
|
if($descriptionElement->feature->uuid == UUID_NAME_USAGE){
|
487 |
|
|
sort($outArray);
|
488 |
|
|
}
|
489 |
7e3ad261
|
Andreas Kohlbecker
|
|
490 |
|
|
|
491 |
0364559b
|
Andreas Kohlbecker
|
if($image_sources){
|
492 |
|
|
$outArray[] = theme('cdm_description_element_image_source', $image_sources, true);
|
493 |
35eafafb
|
f.revilla
|
|
494 |
0364559b
|
Andreas Kohlbecker
|
}
|
495 |
7fc77599
|
f.revilla
|
|
496 |
0364559b
|
Andreas Kohlbecker
|
if(variable_get('distribution_sort', 'NO_SORT') != 'NO_SORT'){
|
497 |
|
|
$outArray[] = theme('cdm_description_ordered_distributions', $taxon_uuid, $distributionElements);
|
498 |
|
|
}else{
|
499 |
|
|
ksort($distributionElements);
|
500 |
|
|
$outArray[] = theme('cdm_descriptionElementDistribution', $distributionElements); // TODO , $entryEnclosingTag);
|
501 |
|
|
}
|
502 |
|
|
|
503 |
|
|
// take the feature of the last $descriptionElement
|
504 |
|
|
$feature = $descriptionElement->feature;
|
505 |
|
|
$out = theme('cdm_descriptionElementArray', $outArray, $feature, $glue, $sortOutArray, $enclosingTag);
|
506 |
|
|
|
507 |
|
|
RenderHints::popFromRenderStack();
|
508 |
|
|
return $out;
|
509 |
806baeb2
|
Andreas Kohlbecker
|
}
|
510 |
|
|
|
511 |
0364559b
|
Andreas Kohlbecker
|
/**
|
512 |
|
|
*
|
513 |
|
|
* Enter description here ...
|
514 |
|
|
* @param unknown_type $a
|
515 |
|
|
* @param unknown_type $b
|
516 |
|
|
*/
|
517 |
94bb9048
|
f.revilla
|
function compare_image_sources($a, $b){
|
518 |
|
|
if($a->multilanguageText_L10n->text == $b->multilanguageText_L10n->text){
|
519 |
0364559b
|
Andreas Kohlbecker
|
return 0;
|
520 |
94bb9048
|
f.revilla
|
}
|
521 |
|
|
return ($a->multilanguageText_L10n->text < $b->multilanguageText_L10n->text) ? -1 : 1;
|
522 |
|
|
}
|
523 |
|
|
|
524 |
|
|
/**
|
525 |
adb8c38b
|
Andreas Kohlbecker
|
*
|
526 |
94bb9048
|
f.revilla
|
*/
|
527 |
|
|
function theme_cdm_description_element_image_source($image_sources, $asListElement) {
|
528 |
|
|
$out = '';
|
529 |
|
|
$separator = ',';
|
530 |
|
|
RenderHints::pushToRenderStack('descriptionElementImageSource');
|
531 |
|
|
RenderHints::setFootnoteListKey(UUID_IMAGE_SOURCES);
|
532 |
adb8c38b
|
Andreas Kohlbecker
|
|
533 |
94bb9048
|
f.revilla
|
//sorting the image sources
|
534 |
|
|
usort($image_sources, "compare_image_sources");
|
535 |
|
|
//generate the footnotes
|
536 |
|
|
foreach($image_sources as $image_source){
|
537 |
|
|
$footNoteKeys = cdm_annotations_as_footnotekeys($image_source);
|
538 |
|
|
foreach($image_source->sources as $source){
|
539 |
|
|
if(_is_original_source_type($source)){
|
540 |
|
|
$fn_key = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
|
541 |
|
|
cdm_add_footnote_to_array($footNoteKeys, $fn_key);// ensure uniqueness of the footnote keys
|
542 |
|
|
}
|
543 |
adb8c38b
|
Andreas Kohlbecker
|
}
|
544 |
94bb9048
|
f.revilla
|
//sort and render footnote keys
|
545 |
|
|
$footnoteKeyListStr = '';
|
546 |
|
|
asort($footNoteKeys);
|
547 |
|
|
foreach($footNoteKeys as $footNoteKey){
|
548 |
|
|
$footnoteKeyListStr .= theme('cdm_footnote_key', $footNoteKey, ($footnoteKeyListStr ? $separator : ''));
|
549 |
|
|
}
|
550 |
|
|
//return value!
|
551 |
a92c0aa5
|
f.revilla
|
$out .= '<span class="descriptionElement descriptionElement-'.$image_source->uuid.'">'.$image_source->multilanguageText_L10n->text . $footnoteKeyListStr . '; </span>';
|
552 |
|
|
|
553 |
94bb9048
|
f.revilla
|
}
|
554 |
adb8c38b
|
Andreas Kohlbecker
|
|
555 |
94bb9048
|
f.revilla
|
RenderHints::popFromRenderStack();
|
556 |
|
|
return $out;
|
557 |
|
|
}
|
558 |
|
|
|
559 |
806baeb2
|
Andreas Kohlbecker
|
/**
|
560 |
35eafafb
|
f.revilla
|
*
|
561 |
806baeb2
|
Andreas Kohlbecker
|
* @param unknown_type $descriptionElements
|
562 |
0364559b
|
Andreas Kohlbecker
|
* @param String $enclosingTag
|
563 |
806baeb2
|
Andreas Kohlbecker
|
*/
|
564 |
0364559b
|
Andreas Kohlbecker
|
function theme_cdm_descriptionElementDistribution($descriptionElements, $enclosingTag = "span"){
|
565 |
35eafafb
|
f.revilla
|
|
566 |
cc84321f
|
Andreas Kohlbecker
|
|
567 |
|
|
if(!$enclosingTag){
|
568 |
|
|
$enclosingTag = "span";
|
569 |
|
|
}
|
570 |
|
|
|
571 |
0364559b
|
Andreas Kohlbecker
|
$out = '';
|
572 |
|
|
$separator = ',';
|
573 |
|
|
RenderHints::pushToRenderStack('descriptionElementDistribution');
|
574 |
|
|
RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
|
575 |
|
|
|
576 |
|
|
foreach($descriptionElements as $descriptionElement){
|
577 |
|
|
|
578 |
|
|
// annotations as footnotes
|
579 |
|
|
$footNoteKeys = cdm_annotations_as_footnotekeys($descriptionElement);
|
580 |
|
|
// source references as footnotes
|
581 |
|
|
foreach($descriptionElement->sources as $source){
|
582 |
|
|
if(_is_original_source_type($source)){
|
583 |
|
|
$fn_key = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
|
584 |
|
|
cdm_add_footnote_to_array($footNoteKeys, $fn_key);// ensure uniqueness of the footnote keys
|
585 |
|
|
}
|
586 |
|
|
}
|
587 |
|
|
// sort and render footnote keys
|
588 |
|
|
$footnoteKeyListStr = '';
|
589 |
|
|
asort($footNoteKeys);
|
590 |
|
|
foreach($footNoteKeys as $footNoteKey){
|
591 |
|
|
$footnoteKeyListStr .= theme('cdm_footnote_key', $footNoteKey, ($footnoteKeyListStr ? $separator : ''));
|
592 |
|
|
}
|
593 |
35eafafb
|
f.revilla
|
|
594 |
0364559b
|
Andreas Kohlbecker
|
$out .= '<'. $enclosingTag .' class="descriptionElement descriptionElement-'.$descriptionElement->uuid.'">'
|
595 |
|
|
. $descriptionElement->area->representation_L10n . $footnoteKeyListStr . ' </'. $enclosingTag .'>';
|
596 |
|
|
}
|
597 |
|
|
|
598 |
|
|
RenderHints::popFromRenderStack();
|
599 |
|
|
return $out;
|
600 |
806baeb2
|
Andreas Kohlbecker
|
}
|
601 |
0364559b
|
Andreas Kohlbecker
|
|
602 |
dd268826
|
f.revilla
|
/**
|
603 |
|
|
* Function target is to compare two different foootnotes objects.
|
604 |
adb8c38b
|
Andreas Kohlbecker
|
* The comparation is based on the footnote key. The one which is
|
605 |
dd268826
|
f.revilla
|
* displayed as footnote number.
|
606 |
adb8c38b
|
Andreas Kohlbecker
|
*
|
607 |
dd268826
|
f.revilla
|
* @param footnote object $a
|
608 |
|
|
* @param footnote object $b
|
609 |
|
|
*/
|
610 |
|
|
function footnotes_key_compare($a, $b){
|
611 |
0364559b
|
Andreas Kohlbecker
|
$res = 0;
|
612 |
|
|
if ($a->keyStr < $b->keyStr){
|
613 |
|
|
$res = -1;
|
614 |
|
|
}elseif ($a->keyStr > $b->keyStr){
|
615 |
|
|
$res = 1;
|
616 |
|
|
}
|
617 |
|
|
return $res;
|
618 |
dd268826
|
f.revilla
|
}
|
619 |
39efe1be
|
f.revilla
|
|
620 |
636be34b
|
f.revilla
|
function theme_cdm_description_ordered_distributions($taxon_uuid, $descriptionElements){
|
621 |
0364559b
|
Andreas Kohlbecker
|
//returning null if no description elements
|
622 |
|
|
if ($descriptionElements == null){
|
623 |
|
|
return '';
|
624 |
|
|
}
|
625 |
|
|
//initialization some variables
|
626 |
|
|
$out = '';
|
627 |
|
|
$separator = ',';
|
628 |
|
|
RenderHints::pushToRenderStack('descriptionElementDistribution');
|
629 |
|
|
RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
|
630 |
|
|
//getting all the taxon description for a given taxon
|
631 |
|
|
$taxonDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, $taxon_uuid);
|
632 |
|
|
foreach ($taxonDescriptions as $description){
|
633 |
|
|
$descriptions_uuids[] = $description->uuid;
|
634 |
|
|
}
|
635 |
|
|
//getting the sortered distributions (omiting level ??)
|
636 |
|
|
$request_params = array();
|
637 |
|
|
$request_params['omitLevels'] = UUID_NAMEDAREALEVEL_TDWGLEVEL_2;
|
638 |
|
|
$ordered_areas = cdm_ws_get(CDM_WS_PORTAL_DESCRIPTION_DISTRIBUTION_TREE, join(',',$descriptions_uuids), queryString($request_params));
|
639 |
|
|
$ordered_areas = $ordered_areas->rootElement->children;
|
640 |
|
|
|
641 |
|
|
//printing the distributions
|
642 |
|
|
foreach ($ordered_areas as $element_level1){
|
643 |
|
|
//level1
|
644 |
|
|
if ($element_level1->data){
|
645 |
|
|
$out .= '<dt>' . $element_level1->data->area->representation_L10n . ':</dt> ';
|
646 |
|
|
}
|
647 |
|
|
$out .= '<dd>';
|
648 |
|
|
|
649 |
|
|
//level3
|
650 |
|
|
foreach ($element_level1->children as $element_level3){
|
651 |
|
|
if ($element_level3->data){
|
652 |
|
|
$text_l3 = $element_level3->data->area->representation_L10n;
|
653 |
|
|
}
|
654 |
|
|
$fnKeysLevel3Str = '';
|
655 |
|
|
$fnKeysLevel3 = cdm_annotations_as_footnotekeys($element_level3->data);
|
656 |
|
|
foreach($element_level3->data->sources as $source){
|
657 |
|
|
if(_is_original_source_type($source)){
|
658 |
|
|
$fn_key3 = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
|
659 |
|
|
cdm_add_footnote_to_array($fnKeysLevel3, $fn_key3);
|
660 |
|
|
}
|
661 |
|
|
}
|
662 |
|
|
//level4
|
663 |
|
|
$l4_regions = array();
|
664 |
|
|
foreach ($element_level3->children as $element_level4){
|
665 |
|
|
if ($element_level4->data){
|
666 |
|
|
$text_l4 = $element_level4->data->area->representation_L10n;
|
667 |
|
|
$l4_regions[$element_level3->data->area->representation_L10n] = '';
|
668 |
|
|
$fnKeysLevel4Str = '';
|
669 |
|
|
$fnKeysLevel4 = cdm_annotations_as_footnotekeys($element_level4->data);
|
670 |
|
|
foreach($element_level4->data->sources as $source){
|
671 |
|
|
if(_is_original_source_type($source)){
|
672 |
|
|
$fn_key4 = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_DescriptionElementSource', $source, false));
|
673 |
|
|
cdm_add_footnote_to_array($fnKeysLevel4, $fn_key4);
|
674 |
|
|
}
|
675 |
|
|
}
|
676 |
|
|
usort($fnKeysLevel4, "footnotes_key_compare");
|
677 |
|
|
$l4_regions[$text_l4] = $fnKeysLevel4;
|
678 |
|
|
}
|
679 |
|
|
}//level4
|
680 |
|
|
//managing level3 and level4 for generating the right output
|
681 |
|
|
usort($fnKeysLevel3, "footnotes_key_compare");
|
682 |
|
|
foreach ($fnKeysLevel3 as $key3){
|
683 |
|
|
foreach ($l4_regions as $key4 => $value4){
|
684 |
|
|
cdm_add_footnote_to_array($l4_regions[$key4], $key3);
|
685 |
|
|
}
|
686 |
|
|
}
|
687 |
|
|
if ($element_level3->numberOfChildren == 1 &&
|
688 |
|
|
$text_l3 == $element_level3->children[0]->data->area->representation_L10n){
|
689 |
|
|
//var_dump($element_level3->children[0]->data->area->representation_L10n);
|
690 |
|
|
$fnStr = '';
|
691 |
|
|
$region = array_pop($l4_regions);
|
692 |
|
|
foreach($region as $key){
|
693 |
|
|
$fnStr .= theme('cdm_footnote_key', $key, ($fnStr ? $separator : ''));
|
694 |
|
|
}
|
695 |
|
|
$out .= "$text_l3 $fnStr; ";
|
696 |
|
|
//removing whitespaces when &fnStr is empty
|
697 |
|
|
if(substr($out, -3) == ' ; '){
|
698 |
|
|
$out = substr($out, 0, -3) . '; ';
|
699 |
|
|
}
|
700 |
|
|
}else{
|
701 |
|
|
$fnKeysLevel3Str = '';
|
702 |
|
|
foreach($fnKeysLevel3 as $key){
|
703 |
|
|
$fnKeysLevel3Str .= theme('cdm_footnote_key', $key, ($fnKeysLevel3Str ? $separator : ''));
|
704 |
|
|
}
|
705 |
|
|
$text_l4_aux = '';
|
706 |
|
|
foreach ($l4_regions as $key => $value){
|
707 |
|
|
$fnKeysLevel4Str = '';
|
708 |
|
|
if (is_array($l4_regions[$key])) {
|
709 |
|
|
foreach ($l4_regions[$key] as $fnkey){//warning why?
|
710 |
|
|
$fnKeysLevel4Str .= theme('cdm_footnote_key', $fnkey, ($fnKeysLevel4Str ? $separator : ''));
|
711 |
|
|
}
|
712 |
|
|
}
|
713 |
|
|
//if ($key != $text_l3 || sizeof($l4_regions > 1)){
|
714 |
|
|
if ($key != $text_l3){
|
715 |
|
|
$text_l4_aux .= "$key $fnKeysLevel4Str, ";
|
716 |
|
|
}
|
717 |
|
|
}
|
718 |
|
|
$text_l4_aux = substr($text_l4_aux, 0, -2);
|
719 |
|
|
|
720 |
|
|
if (strlen($text_l4_aux) > 0){
|
721 |
|
|
$out .= "$text_l3 $fnKeysLevel3Str ($text_l4_aux); ";
|
722 |
|
|
}else{
|
723 |
|
|
$out .= "$text_l3 $fnKeysLevel3Str; ";
|
724 |
|
|
}
|
725 |
|
|
|
726 |
|
|
}
|
727 |
|
|
}//level3
|
728 |
|
|
$out = substr($out, 0, -2);
|
729 |
|
|
$out .= '.</dd>';
|
730 |
|
|
}//level1
|
731 |
|
|
|
732 |
|
|
RenderHints::popFromRenderStack();
|
733 |
|
|
return $out;
|
734 |
39efe1be
|
f.revilla
|
}
|
735 |
|
|
|
736 |
806baeb2
|
Andreas Kohlbecker
|
function theme_cdm_DescriptionElementSource($descriptionElementSource, $doLink = TRUE){
|
737 |
e70c228f
|
f.revilla
|
|
738 |
0364559b
|
Andreas Kohlbecker
|
if(isset($descriptionElementSource->citation)){
|
739 |
|
|
$out = theme('cdm_reference', $descriptionElementSource->citation, $descriptionElementSource->citationMicroReference, $doLink);
|
740 |
|
|
}
|
741 |
|
|
return $out;
|
742 |
806baeb2
|
Andreas Kohlbecker
|
}
|
743 |
16718c52
|
Andreas Kohlbecker
|
|
744 |
2264b60d
|
Andreas Kohlbecker
|
function theme_cdm_IdentifieableSource($source, $doLink = TRUE){
|
745 |
|
|
|
746 |
|
|
if(isset($source->citation)){
|
747 |
|
|
$out = theme('cdm_reference', $source->citation, $source->citationMicroReference, $doLink);
|
748 |
|
|
}
|
749 |
|
|
return $out;
|
750 |
|
|
}
|
751 |
|
|
|
752 |
|
|
|
753 |
|
|
|
754 |
|
|
|
755 |
16718c52
|
Andreas Kohlbecker
|
|
756 |
e63edd95
|
f.revilla
|
/*
|
757 |
|
|
function theme_cdm_descriptionElementDistribution($descriptionElements){
|
758 |
|
|
|
759 |
|
|
$out = '';
|
760 |
|
|
$separator = ',';
|
761 |
|
|
RenderHints::pushToRenderStack('descriptionElementDistribution');
|
762 |
|
|
RenderHints::setFootnoteListKey(UUID_DISTRIBUTION);
|
763 |
|
|
foreach($descriptionElements as $descriptionElement){
|
764 |
|
|
// annotations as footnotes
|
765 |
|
|
$annotationFootnoteKeys = theme('cdm_annotations_as_footnotekeys', $descriptionElement);
|
766 |
|
|
// source references as footnotes
|
767 |
|
|
$sourcesFootnoteKeyList = '';
|
768 |
|
|
foreach($descriptionElement->sources as $source){
|
769 |
|
|
if(_is_original_source_type($source)){
|
770 |
|
|
$_fkey = FootnoteManager::addNewFootnote(UUID_DISTRIBUTION, theme('cdm_DescriptionElementSource', $source, false));
|
771 |
|
|
$sourcesFootnoteKeyList .= theme('cdm_footnote_key', $_fkey, UUID_DISTRIBUTION, ($sourcesFootnoteKeyList ? $separator : ''));
|
772 |
|
|
}
|
773 |
|
|
}
|
774 |
|
|
if($annotationFootnoteKeys && $sourcesFootnoteKeyList){
|
775 |
|
|
$annotationFootnoteKeys .= $separator;
|
776 |
|
|
}
|
777 |
|
|
$out .= $descriptionElement->area->representation_L10n . $annotationFootnoteKeys . $sourcesFootnoteKeyList . ' ';
|
778 |
|
|
}
|
779 |
|
|
|
780 |
|
|
$out = substr($out, 0, strlen($out)-strlen($separator) );
|
781 |
|
|
|
782 |
|
|
RenderHints::popFromRenderStack();
|
783 |
|
|
return $out;
|
784 |
|
|
|
785 |
|
|
}
|
786 |
|
|
*/
|
787 |
|
|
|
788 |
806baeb2
|
Andreas Kohlbecker
|
|
789 |
|
|
/**
|
790 |
|
|
* TODO
|
791 |
|
|
* Quick-and-dirty solution to show distribution service to exemplar groups
|
792 |
|
|
*
|
793 |
|
|
* @param unknown_type $featureTo
|
794 |
|
|
* @return unknown
|
795 |
|
|
*/
|
796 |
a973da5b
|
Andreas Kohlbecker
|
function theme_cdm_distribution_map($taxon){
|
797 |
806baeb2
|
Andreas Kohlbecker
|
|
798 |
0364559b
|
Andreas Kohlbecker
|
$server = getEDITMapServiceURI();
|
799 |
|
|
|
800 |
|
|
if(!$server){
|
801 |
|
|
//warning message
|
802 |
|
|
drupal_set_message('No \'Geoservice Access Point\' has been set so far. '
|
803 |
|
|
. 'Please configure the variable \'Geoservice Access Point\' here '
|
804 |
|
|
. l('CDM Dataportal Settings', 'admin/settings/cdm_dataportal/geo'), 'warning');
|
805 |
|
|
//message to render
|
806 |
|
|
return "<p>No geoservice specified</p>";
|
807 |
|
|
}else{
|
808 |
|
|
$fontStyles = array(0 => "plane", 1 => "italic");
|
809 |
|
|
|
810 |
|
|
// query cdm server for map service uri parameters
|
811 |
|
|
$map_data_parameters = cdm_ws_get(CDM_WS_GEOSERVICE_DISTRIBUTIONMAP, $taxon->uuid);
|
812 |
|
|
$out .= "<!-- map_data_parameters:". print_r($map_data_parameters, true) . " -->";
|
813 |
|
|
$query_string = $map_data_parameters->String;
|
814 |
|
|
if(!$query_string){
|
815 |
|
|
// the $query_string is empty if there are no distribution areas defined
|
816 |
|
|
return ;
|
817 |
|
|
}
|
818 |
|
|
|
819 |
|
|
// some cleaning of the URI paramters, TODO is this still needed?
|
820 |
|
|
$query_string = str_replace('%3A', ":", $query_string);
|
821 |
|
|
|
822 |
|
|
// additional query parameters as set in the data portal admin section
|
823 |
|
|
$display_width = variable_get('cdm_dataportal_geoservice_display_width', false);
|
824 |
|
|
$bounding_box = variable_get('cdm_dataportal_geoservice_bounding_box', false);
|
825 |
|
|
$labels_on = variable_get('cdm_dataportal_geoservice_labels_on', 0);
|
826 |
|
|
|
827 |
|
|
$query_string .= ($display_width ? '&ms=' . $display_width: '').
|
828 |
|
|
($bounding_box ? '&bbox=' . $bounding_box : '')
|
829 |
90f3f039
|
Andreas Kohlbecker
|
. ($labels_on ? '&label=' . $labels_on : '');
|
830 |
0364559b
|
Andreas Kohlbecker
|
|
831 |
|
|
/* ------ choose the display mode, either openlayers or static image ------ */
|
832 |
|
|
|
833 |
|
|
if(variable_get('cdm_dataportal_map_openlayers', 1)){
|
834 |
|
|
|
835 |
|
|
$query_string .= '&img=false';
|
836 |
|
|
|
837 |
|
|
/* =========== display distributions using the openlayers map viewer =========== */
|
838 |
|
|
|
839 |
|
|
$legend_url_font_size = variable_get('cdm_dataportal_geoservice_legend_font_size', 10);
|
840 |
|
|
$legend_url_font_style = variable_get('cdm_dataportal_geoservice_legend_font_style', 1);
|
841 |
|
|
$legend_url_font_style = $fontStyles[$legend_url_font_style];
|
842 |
|
|
$legend_url_icon_width = variable_get('cdm_dataportal_geoservice_legend_icon_width', 35);
|
843 |
|
|
$legend_url_icon_height = variable_get('cdm_dataportal_geoservice_legend_icon_height', 15);
|
844 |
|
|
|
845 |
|
|
$legendFormatQueryStr = "format=image".urlencode('/')."png&TRANSPARENT=TRUE";
|
846 |
|
|
$legendFormatQueryStr .= "&WIDTH=".$legend_url_icon_width."&HEIGHT=".$legend_url_icon_height."&";
|
847 |
|
|
//TODO why is the layer=topp:tdwg_level_4 parameter neede at all here??
|
848 |
|
|
$legendFormatQueryStr .="layer=topp".urlencode(':')."tdwg_level_4&LEGEND_OPTIONS=forceLabels".urlencode(':')."on;fontStyle".urlencode(':').$legend_url_font_style.";fontSize".urlencode(':').$legend_url_font_size."&SLD=".urlencode($sldLegend);
|
849 |
|
|
|
850 |
|
|
$out .= get_openlayers_map(
|
851 |
|
|
$display_width,
|
852 |
|
|
null,
|
853 |
|
|
$query_string,
|
854 |
|
|
$legendFormatQueryStr,
|
855 |
|
|
variable_get('cdm_dataportal_geoservice_map_caption', '')
|
856 |
|
|
);
|
857 |
|
|
|
858 |
|
|
} else {
|
859 |
|
|
|
860 |
|
|
// simple image
|
861 |
|
|
$mapStaticCaption = '&mc_s=Georgia,15,blue&mc=' . variable_get('cdm_dataportal_geoservice_map_caption', '');
|
862 |
|
|
|
863 |
|
|
$query_string .= '&img=true';
|
864 |
|
|
$query_string .= '&legend=1&mlp=3' . $mapStaticCaption . '&recalculate=false';
|
865 |
|
|
|
866 |
|
|
$map_service_script_name = "areas.php";
|
867 |
|
|
|
868 |
|
|
// apply Plain Image map settings
|
869 |
|
|
if (variable_get('edit_map_server', EDIT_MAPSERVER_V1_URI) == EDIT_MAPSERVER_V11_URI){
|
870 |
|
|
/*
|
871 |
|
|
* example : title=a:Naturalized++non-invasive
|
872 |
|
|
* &ad=cyprusdivs:bdcode:a:5&as=a:ff9900,,0.1,&l=tdwg4
|
873 |
|
|
* &ms=500&bbox=32,34,35,36&img=true&legend=1&mlp=3
|
874 |
|
|
* &mc_s=Georgia,15,blue&mc=&recalculate=false
|
875 |
|
|
*
|
876 |
|
|
* http://edit.br.fgov.be/edit_wp5/v1/rest_gen.php?
|
877 |
|
|
* l=background_gis:b,cyprusdivs&ad=cyprusdivs%3Abdcode%3Aa%3A8%2C4
|
878 |
|
|
* &as=a%3A339966%2C%2C0.1%2C|b:0000ff,,
|
879 |
|
|
* &bbox=32%2C34%2C35%2C36&img=true&legend=1&mc=&mc_s=Georgia%2C15%2Cblue
|
880 |
|
|
* &mlp=3&ms=500&recalculate=false&title=a%3Aindigenous
|
881 |
|
|
*/
|
882 |
|
|
|
883 |
|
|
$map_service_script_name = "rest_gen.php";
|
884 |
|
|
|
885 |
|
|
$bgcolor_areaStyleId= "y";
|
886 |
|
|
$baselayer_areaStyleId= "z";
|
887 |
|
|
$bgcolor_layer='';
|
888 |
|
|
$additional_area_styles = array();
|
889 |
|
|
|
890 |
|
|
// background color:
|
891 |
|
|
if(variable_get('map_bg_color', '')){
|
892 |
|
|
$bgcolor_layer = "background_gis:".$bgcolor_areaStyleId;
|
893 |
|
|
$additional_area_styles[] = $bgcolor_areaStyleId . ":" . variable_get('map_bg_color', '') . ",,";
|
894 |
|
|
}
|
895 |
|
|
|
896 |
|
|
//TODO HACK to replace the default base layer which currently is tdwg4 !!!
|
897 |
b22c2561
|
Andreas Kohlbecker
|
if(strpos($query_string, "?l=") !== FALSE){
|
898 |
|
|
$layer_param_token = "?l=";
|
899 |
|
|
} else {
|
900 |
|
|
$layer_param_token = "&l=";
|
901 |
|
|
}
|
902 |
|
|
if(strpos($query_string, "?as=") !== FALSE){
|
903 |
|
|
$areystyle_param_token = "?as=";
|
904 |
|
|
} else {
|
905 |
|
|
$areystyle_param_token = "&as=";
|
906 |
|
|
}
|
907 |
|
|
|
908 |
0364559b
|
Andreas Kohlbecker
|
if(variable_get('map_base_layer', '')){
|
909 |
b22c2561
|
Andreas Kohlbecker
|
$query_string = str_replace($layer_param_token."tdwg4", "$layer_param_token".variable_get('map_base_layer', ''). ":" . $baselayer_areaStyleId, $query_string);
|
910 |
0364559b
|
Andreas Kohlbecker
|
} else {
|
911 |
b22c2561
|
Andreas Kohlbecker
|
$query_string = str_replace($layer_param_token."tdwg4", $layer_param_token."tdwg4:".$baselayer_areaStyleId . ",", $query_string);
|
912 |
0364559b
|
Andreas Kohlbecker
|
}
|
913 |
|
|
|
914 |
|
|
if($bgcolor_layer){
|
915 |
b22c2561
|
Andreas Kohlbecker
|
$query_string = str_replace($layer_param_token, $layer_param_token . $bgcolor_layer . ",", $query_string);
|
916 |
0364559b
|
Andreas Kohlbecker
|
}
|
917 |
|
|
|
918 |
|
|
if(variable_get('map_base_layer_style', '')){
|
919 |
|
|
$additional_area_styles[] = $baselayer_areaStyleId . ":" . variable_get('map_base_layer_style', '');
|
920 |
|
|
}
|
921 |
|
|
|
922 |
|
|
foreach ($additional_area_styles as $as) {
|
923 |
b22c2561
|
Andreas Kohlbecker
|
$query_string = str_replace($areystyle_param_token, $areystyle_param_token . $as . "|", $query_string);
|
924 |
0364559b
|
Andreas Kohlbecker
|
}
|
925 |
|
|
|
926 |
|
|
}
|
927 |
|
|
|
928 |
|
|
$mapUri = url("$server/$map_service_script_name?$query_string");
|
929 |
|
|
$out .= '<img class="distribution_map" src="' . $mapUri . '" alt="Distribution Map" />';
|
930 |
|
|
}
|
931 |
|
|
return $out;
|
932 |
|
|
}
|
933 |
806baeb2
|
Andreas Kohlbecker
|
}
|
934 |
2d284a25
|
Andreas Kohlbecker
|
|
935 |
|
|
/**
|
936 |
|
|
* Returns a list of a specific type of IdentificationKeys, the list can be restricteded by a taxon.
|
937 |
|
|
* @param $type The simple name of the cdm class implementing the interface IIdentificationKey,
|
938 |
|
|
* valid values are : PolytomousKey, MediaKey, MultiAccessKey
|
939 |
|
|
* @param $taxonUuid if given this parameter restrict the listed keys to
|
940 |
|
|
* those which have the taxon identified be this uuid in scope.
|
941 |
|
|
*/
|
942 |
|
|
function _list_IdentificationKeys($type, $taxonUuid = null, $pageSize = null, $pageNumber = null){
|
943 |
|
|
|
944 |
|
|
if(!$type){
|
945 |
|
|
drupal_set_message("Type parameter is missing", "error");
|
946 |
|
|
return;
|
947 |
|
|
}
|
948 |
|
|
$cdm_ws_pasepath = null;
|
949 |
|
|
switch($type){
|
950 |
|
|
case "PolytomousKey" : $cdm_ws_pasepath = CDM_WS_POLYTOMOUSKEY; break;
|
951 |
|
|
case "MediaKey" : $cdm_ws_pasepath = CDM_WS_MEDIAKEY; break;
|
952 |
|
|
case "MultiAccessKey" : $cdm_ws_pasepath = CDM_WS_MULTIACCESSKEY; break;
|
953 |
|
|
}
|
954 |
|
|
|
955 |
|
|
if(!$cdm_ws_pasepath){
|
956 |
|
|
drupal_set_message("Type parameter is not valid: ".$type, "error");
|
957 |
|
|
}
|
958 |
|
|
|
959 |
|
|
$queryParameters = '';
|
960 |
|
|
if(is_numeric($pageSize)){
|
961 |
0364559b
|
Andreas Kohlbecker
|
$queryParameters = "pageSize=".$pageSize;
|
962 |
2d284a25
|
Andreas Kohlbecker
|
} else {
|
963 |
0364559b
|
Andreas Kohlbecker
|
$queryParameters = "pageSize=0";
|
964 |
2d284a25
|
Andreas Kohlbecker
|
}
|
965 |
|
|
|
966 |
|
|
if(is_numeric($pageNumber)){
|
967 |
|
|
$queryParameters = "pageNumber=".$pageNumber;
|
968 |
|
|
} else {
|
969 |
|
|
$queryParameters = "pageNumber=0";
|
970 |
|
|
}
|
971 |
|
|
$queryParameters = null;
|
972 |
|
|
if($taxonUuid){
|
973 |
|
|
$queryParameters = "findByTaxonomicScope=$taxonUuid";
|
974 |
|
|
}
|
975 |
|
|
$pager = cdm_ws_get($cdm_ws_pasepath, null, $queryParameters);
|
976 |
|
|
|
977 |
|
|
if(!$pager || $pager->count == 0){
|
978 |
|
|
return array();
|
979 |
|
|
}
|
980 |
|
|
return $pager->records;
|
981 |
|
|
}
|
982 |
|
|
|
983 |
cafc7c3b
|
Andreas Kohlbecker
|
function theme_cdm_IdentificationKey($identificationKey, $doLinkToKeyPage = true, $showIdentificationKeyTitle = true){
|
984 |
2264b60d
|
Andreas Kohlbecker
|
|
985 |
0364559b
|
Andreas Kohlbecker
|
$parentRenderPath = RenderHints::getRenderPath();
|
986 |
|
|
RenderHints::pushToRenderStack("IdentificationKey");
|
987 |
|
|
|
988 |
|
|
if($showIdentificationKeyTitle){
|
989 |
|
|
if($doLinkToKeyPage) {
|
990 |
|
|
$out = l($identificationKey->titleCache, path_to_key($identificationKey->class, $identificationKey->uuid));
|
991 |
|
|
} else {
|
992 |
|
|
$out = $identificationKey->titleCache;
|
993 |
|
|
}
|
994 |
|
|
}
|
995 |
|
|
if(is_array($identificationKey->sources)){
|
996 |
|
|
// display sources
|
997 |
|
|
$i = 0;
|
998 |
|
|
$out .= '<div>';
|
999 |
|
|
foreach($identificationKey->sources as $source){
|
1000 |
cafc7c3b
|
Andreas Kohlbecker
|
$out .= ($i++ > 0 ? ', ' : '' ) . theme("cdm_IdentifieableSource", $source);
|
1001 |
0364559b
|
Andreas Kohlbecker
|
}
|
1002 |
|
|
$out .= '</div>';
|
1003 |
|
|
}
|
1004 |
|
|
// display annotations
|
1005 |
cafc7c3b
|
Andreas Kohlbecker
|
$out .= theme('cdm_annotations', cdm_ws_getAnnotationsFor($identificationKey), 'div');
|
1006 |
0364559b
|
Andreas Kohlbecker
|
RenderHints::popFromRenderStack();
|
1007 |
|
|
return $out;
|
1008 |
2264b60d
|
Andreas Kohlbecker
|
}
|
1009 |
|
|
|
1010 |
|
|
function theme_cdm_polytomousKey(&$polytomousKey){
|
1011 |
|
|
|
1012 |
0364559b
|
Andreas Kohlbecker
|
$keyStyle = "linkedStyle"; // TODO settings needed
|
1013 |
2264b60d
|
Andreas Kohlbecker
|
|
1014 |
0364559b
|
Andreas Kohlbecker
|
RenderHints::pushToRenderStack("polytomousKey");
|
1015 |
2264b60d
|
Andreas Kohlbecker
|
// key nodes in linked style
|
1016 |
|
|
$out = '<table class="polytomousKey polytomousKey_'.$keyStyle.'">';
|
1017 |
|
|
$out .= theme('cdm_polytomousKey_'.$keyStyle.'_subgraph', $polytomousKey->root);
|
1018 |
|
|
$out .= '</table>';
|
1019 |
|
|
RenderHints::popFromRenderStack();
|
1020 |
|
|
return $out;
|
1021 |
|
|
}
|
1022 |
|
|
|
1023 |
|
|
function theme_cdm_polytomousKey_linkedStyle_subgraph(&$polytomousKeyNode){
|
1024 |
|
|
|
1025 |
|
|
static $statementCountCharacter = '\'';
|
1026 |
|
|
|
1027 |
|
|
$out = "";
|
1028 |
|
|
|
1029 |
|
|
if(is_array($polytomousKeyNode->children)){
|
1030 |
|
|
|
1031 |
|
|
$childCount = 0;
|
1032 |
|
|
|
1033 |
|
|
// render edges of the current node
|
1034 |
|
|
foreach($polytomousKeyNode->children as &$child){
|
1035 |
96634aa3
|
Andreas Kohlbecker
|
|
1036 |
0364559b
|
Andreas Kohlbecker
|
if(!isset($child->statement)){
|
1037 |
|
|
// skip node with empty statements (see below for explanation: "Special case")
|
1038 |
|
|
continue;
|
1039 |
|
|
}
|
1040 |
96634aa3
|
Andreas Kohlbecker
|
|
1041 |
2264b60d
|
Andreas Kohlbecker
|
$out .= '<tr class="childCount_' . $childCount . '">';
|
1042 |
|
|
|
1043 |
|
|
$out .= '<td class="nodeNumber">'. uuid_anchor($polytomousKeyNode->uuid, $polytomousKeyNode->nodeNumber . str_pad("", $childCount++ , $statementCountCharacter)) . "</td>";
|
1044 |
|
|
|
1045 |
96634aa3
|
Andreas Kohlbecker
|
/*
|
1046 |
|
|
* Special case:
|
1047 |
|
|
* Child nodes with empty statements but taxa as leaf are to
|
1048 |
|
|
* treated as if all those taxa where direct children of the source node.
|
1049 |
|
|
*/
|
1050 |
|
|
$islinkToManyTaxa = !isset($child->children[0]->statement) && isset($child->children[0]->taxon->uuid);
|
1051 |
|
|
$islinkToTaxon = isset($child->taxon->uuid);
|
1052 |
|
|
$islinkToSubKey = isset($child->subkey->uuid);
|
1053 |
|
|
$islinkToOtherNode = isset($child->otherNode);
|
1054 |
|
|
$islinkToNode = $child->nodeNumber && !$islinkToManyTaxa && !$islinkToOtherNode; // either null or 0
|
1055 |
|
|
|
1056 |
|
|
$out .= '<td ' . RenderHints::getHtmlElementID($child) . ' class="edge">';
|
1057 |
2264b60d
|
Andreas Kohlbecker
|
if(isset($polytomousKeyNode->question->label_l10n)){
|
1058 |
|
|
$out .= $polytomousKeyNode->question->label_l10n . ": ";
|
1059 |
|
|
}
|
1060 |
|
|
$out .= $child->statement->label_l10n;
|
1061 |
|
|
|
1062 |
96634aa3
|
Andreas Kohlbecker
|
// --- links to nodes taxa and subkeys
|
1063 |
|
|
$out .= '<div class="nodeLink">';
|
1064 |
|
|
|
1065 |
|
|
// link to a PolytomousKeyNode
|
1066 |
|
|
if($islinkToNode){
|
1067 |
|
|
$out .= '<div class="nodeLinkToNode">' . l($child->nodeNumber, $_REQUEST["q"], null, null, $child->uuid) . '</div>';
|
1068 |
|
|
}
|
1069 |
|
|
|
1070 |
|
|
// link to a PolytomousKeyNode
|
1071 |
|
|
if($islinkToOtherNode){
|
1072 |
|
|
$out .= '<div class="nodeLinkToOtherNode">' . l($child->otherNode->nodeNumber, $_REQUEST["q"], null, null, $child->otherNode->uuid) . '</div>';
|
1073 |
|
|
}
|
1074 |
|
|
|
1075 |
|
|
// link to one or many taxa
|
1076 |
|
|
if($islinkToTaxon || $islinkToManyTaxa){
|
1077 |
|
|
|
1078 |
0364559b
|
Andreas Kohlbecker
|
if($islinkToManyTaxa){
|
1079 |
96634aa3
|
Andreas Kohlbecker
|
$taxonChildren = $child->children;
|
1080 |
0364559b
|
Andreas Kohlbecker
|
} else {
|
1081 |
96634aa3
|
Andreas Kohlbecker
|
$taxonChildren = array($child);
|
1082 |
0364559b
|
Andreas Kohlbecker
|
}
|
1083 |
96634aa3
|
Andreas Kohlbecker
|
|
1084 |
0364559b
|
Andreas Kohlbecker
|
foreach($taxonChildren as $taxonChild){
|
1085 |
|
|
// TODO many taxa $child->children->taxon
|
1086 |
|
|
$out .= '<div class="nodeLinkToTaxon">';
|
1087 |
|
|
if(is_object($taxonChild->modifyingText)){
|
1088 |
|
|
$i = 0;
|
1089 |
96634aa3
|
Andreas Kohlbecker
|
foreach(get_object_vars($taxonChild->modifyingText) as $language=>$languageString){
|
1090 |
0364559b
|
Andreas Kohlbecker
|
$out .= ($i++ > 0 ? ', ' : '') . '<span class="modifyingText">'. $languageString->text . '</span> ';
|
1091 |
cafc7c3b
|
Andreas Kohlbecker
|
}
|
1092 |
0364559b
|
Andreas Kohlbecker
|
}
|
1093 |
89b7d4bd
|
Andreas Kohlbecker
|
$out .= theme("cdm_taxonName", $taxonChild->taxon->name, url(path_to_taxon($taxonChild->taxon->uuid)));
|
1094 |
0364559b
|
Andreas Kohlbecker
|
$out .= '</div>';
|
1095 |
|
|
}
|
1096 |
96634aa3
|
Andreas Kohlbecker
|
|
1097 |
|
|
// link to a subkey
|
1098 |
0364559b
|
Andreas Kohlbecker
|
if($islinkToSubKey){
|
1099 |
|
|
$out .= '<div class="nodeLinkToSubkey">' . theme('cdm_IdentificationKey', $child->subkey) . '</div>';
|
1100 |
|
|
}
|
1101 |
96634aa3
|
Andreas Kohlbecker
|
|
1102 |
2264b60d
|
Andreas Kohlbecker
|
}
|
1103 |
|
|
|
1104 |
0364559b
|
Andreas Kohlbecker
|
$out .= '</div>'; // end node link
|
1105 |
96634aa3
|
Andreas Kohlbecker
|
$out .= '</td>'; // end edge
|
1106 |
2264b60d
|
Andreas Kohlbecker
|
$out .= '</tr>';
|
1107 |
|
|
|
1108 |
|
|
}
|
1109 |
|
|
|
1110 |
|
|
// recurse into child nodes
|
1111 |
|
|
foreach($polytomousKeyNode->children as &$child){
|
1112 |
|
|
$out .= theme('cdm_polytomousKey_linkedStyle_subgraph', $child);
|
1113 |
|
|
}
|
1114 |
|
|
|
1115 |
|
|
}
|
1116 |
|
|
return $out;
|
1117 |
|
|
}
|
1118 |
|
|
|
1119 |
2d284a25
|
Andreas Kohlbecker
|
/**
|
1120 |
|
|
* Renders a list of a specific type of IdentificationKeys, the list can be restricteded by a taxon.
|
1121 |
|
|
* @param $type The simple name of the cdm class implementing the interface IIdentificationKey,
|
1122 |
|
|
* valid values are : PolytomousKey, MediaKey, MultiAccessKey
|
1123 |
|
|
* @param $taxonUuid if given this parameter restrict the listed keys to
|
1124 |
|
|
* those which have the taxon identified be this uuid in scope.
|
1125 |
|
|
*/
|
1126 |
|
|
function theme_cdm_list_IdentificationKeys($type, $taxonUuid = null, $pageSize, $pageNumber){
|
1127 |
|
|
|
1128 |
|
|
$keyList = _list_IdentificationKeys($type, $taxonUuid);
|
1129 |
|
|
if(!$keyList || count ($keyList) == 0){
|
1130 |
0364559b
|
Andreas Kohlbecker
|
return;
|
1131 |
2d284a25
|
Andreas Kohlbecker
|
}
|
1132 |
|
|
|
1133 |
|
|
RenderHints::pushToRenderStack('list_IdentificationKeys');
|
1134 |
|
|
$out = '<ul>';
|
1135 |
|
|
foreach ($keyList as $key){
|
1136 |
2264b60d
|
Andreas Kohlbecker
|
$out .= '<li>';
|
1137 |
|
|
$out .= theme('cdm_IdentificationKey', $key);
|
1138 |
|
|
$out .= '</li>';
|
1139 |
2d284a25
|
Andreas Kohlbecker
|
}
|
1140 |
|
|
$out .= '</ul>';
|
1141 |
2264b60d
|
Andreas Kohlbecker
|
$out .= theme("cdm_annotation_footnotes", RenderHints::getRenderPath());
|
1142 |
2d284a25
|
Andreas Kohlbecker
|
RenderHints::popFromRenderStack();
|
1143 |
|
|
|
1144 |
|
|
return $out;
|
1145 |
|
|
}
|
1146 |
|
|
|
1147 |
|
|
function theme_cdm_block_IdentificationKeys($taxonUuid = null, $pageSize = null){
|
1148 |
|
|
|
1149 |
0364559b
|
Andreas Kohlbecker
|
static $types = array("PolytomousKey"=>"Polytomous", "MediaKey"=>"Media", "MultiAccessKey"=>"Multiaccess");
|
1150 |
2d284a25
|
Andreas Kohlbecker
|
RenderHints::pushToRenderStack('block_IdentificationKeys');
|
1151 |
0364559b
|
Andreas Kohlbecker
|
$out = '';
|
1152 |
|
|
foreach($types as $type=>$label){
|
1153 |
|
|
$keylist = theme('cdm_list_IdentificationKeys', $type, $taxonUuid, $pageSize, $pageNumber);
|
1154 |
|
|
if(!$keylist){
|
1155 |
|
|
continue;
|
1156 |
|
|
}
|
1157 |
|
|
$out .= '<div class="'.$type.'">';
|
1158 |
|
|
$out .= '<h3>'.t($label)."</h3>";
|
1159 |
|
|
$out .= $keylist;
|
1160 |
|
|
$out .= '</div>';
|
1161 |
|
|
}
|
1162 |
2d284a25
|
Andreas Kohlbecker
|
RenderHints::popFromRenderStack();
|
1163 |
0364559b
|
Andreas Kohlbecker
|
return $out;
|
1164 |
|
|
}
|