198 |
198 |
* Prepares an empty Drupal block for displaying description elements of a specific CDM Feature.
|
199 |
199 |
*
|
200 |
200 |
* The block can also be used for pseudo Features like a bibliography. Pseudo features are
|
201 |
|
* derived from other data on the fly and so not exist as such in the cdm data. In case
|
202 |
|
* of pseudo features the $feature is left empty
|
|
201 |
* derived from other data on the fly and so not exist as such in the cdm data. For pseudo
|
|
202 |
* features the $feature can be created using make_pseudo_feature().
|
203 |
203 |
*
|
204 |
204 |
* @param $feature_name
|
205 |
205 |
* A label describing the feature, usually the localized feature representation.
|
206 |
206 |
* @param object $feature
|
207 |
|
* The CDM Feature for which the block is created. (optional)
|
|
207 |
* The CDM Feature for which the block is created.
|
208 |
208 |
* @return object
|
209 |
209 |
* A Drupal block object
|
210 |
210 |
*/
|
211 |
|
function feature_block($feature_name, $feature = NULL) {
|
212 |
|
$block = new stdclass(); // Empty object.
|
|
211 |
function feature_block($feature_name, $feature) {
|
|
212 |
$block = new stdclass();
|
213 |
213 |
$block->module = 'cdm_dataportal';
|
214 |
|
$block->delta = generalizeString($feature_name);
|
215 |
214 |
$block->region = NULL;
|
216 |
|
$class_attribute = $feature ? html_class_attribute_ref($feature) : '';
|
|
215 |
$class_attribute = html_class_attribute_ref($feature);
|
|
216 |
$block_delta = $feature->uuid;
|
|
217 |
$block->delta = generalizeString($block_delta);
|
217 |
218 |
$block->subject = '<a name="' . $block->delta . '"></a><span class="' . $class_attribute . '">'
|
218 |
219 |
. theme('cdm_feature_name', array('feature_name' => $feature_name))
|
219 |
220 |
. '</span>';
|
... | ... | |
1234 |
1235 |
if (isset($state_data->state)) {
|
1235 |
1236 |
$state = cdm_term_representation($state_data->state);
|
1236 |
1237 |
|
|
1238 |
$sample_count = 0;
|
1237 |
1239 |
if (isset($state_data->count)) {
|
|
1240 |
$sample_count = $state_data->count;
|
1238 |
1241 |
$state .= ' (' . $state_data->count . ')';
|
1239 |
1242 |
}
|
1240 |
1243 |
|
... | ... | |
1245 |
1248 |
$modifiers_strings = cdm_modifers_representations($state_data);
|
1246 |
1249 |
$state_data_markup = $state . ($modifiers_strings ? ' ' . $modifiers_strings : '');
|
1247 |
1250 |
// we could use strip_tags() to reduce the markup to text for the key but this is expensive
|
1248 |
|
$sort_key = str_pad($state_data->count, 6, '0', STR_PAD_LEFT) . '_' . $state_data_markup;
|
|
1251 |
$sort_key = str_pad($sample_count, 6, '0', STR_PAD_LEFT) . '_' . $state_data_markup;
|
1249 |
1252 |
$state_data_strings[$sort_key] = $state_data_markup;
|
1250 |
1253 |
}
|
1251 |
1254 |
|
... | ... | |
1299 |
1302 |
* - sources
|
1300 |
1303 |
*/
|
1301 |
1304 |
|
1302 |
|
$out = compose_quant_stats($element);
|
|
1305 |
$out = render_quantitative_statistics($element);
|
1303 |
1306 |
|
1304 |
1307 |
$render_array = compose_description_element($element, $feature_block_settings, $out, $element->feature->uuid, $prepend_feature_label);
|
1305 |
1308 |
|
... | ... | |
1312 |
1315 |
*
|
1313 |
1316 |
* @return string
|
1314 |
1317 |
*/
|
1315 |
|
function compose_quant_stats($element) {
|
|
1318 |
function render_quantitative_statistics($element) {
|
1316 |
1319 |
$out = '';
|
1317 |
1320 |
$type_representation = NULL;
|
1318 |
1321 |
$min_max = min_max_array();
|
... | ... | |
1320 |
1323 |
$other_values = [];
|
1321 |
1324 |
|
1322 |
1325 |
if (isset($element->statisticalValues)) {
|
|
1326 |
$out = '<span class=\"' . html_class_attribute_ref($element) . '\">';
|
1323 |
1327 |
$other_values_markup = [];
|
1324 |
1328 |
foreach ($element->statisticalValues as $statistical_val) {
|
1325 |
1329 |
|
... | ... | |
1363 |
1367 |
|
1364 |
1368 |
|
1365 |
1369 |
$out .= $min_max_markup . ' ' . implode($other_values_markup, ', ');
|
|
1370 |
$out .= '</span>';
|
1366 |
1371 |
}
|
1367 |
1372 |
|
1368 |
1373 |
if (isset($element->unit)) {
|
... | ... | |
2113 |
2118 |
if($show_description_elements){
|
2114 |
2119 |
$out = render_description_string($description, get_root_nodes_for_dataset($description));
|
2115 |
2120 |
}
|
2116 |
|
$out .= icon_link($path_to_description);;
|
|
2121 |
$out .= icon_link($path_to_description);
|
2117 |
2122 |
|
2118 |
2123 |
return $out;
|
2119 |
2124 |
}
|
... | ... | |
2139 |
2144 |
}
|
2140 |
2145 |
break;
|
2141 |
2146 |
case 'QuantitativeData':
|
2142 |
|
$descriptionString .= '<i>' . $element->feature->representation_L10n . '</i>: ' . compose_quant_stats($element) . "; ";
|
|
2147 |
$descriptionString .= '<i>' . $element->feature->representation_L10n . '</i>: ' . render_quantitative_statistics($element) . "; ";
|
2143 |
2148 |
break;
|
2144 |
2149 |
}
|
2145 |
2150 |
}
|
... | ... | |
2161 |
2166 |
*
|
2162 |
2167 |
* @ingroup compose
|
2163 |
2168 |
*/
|
2164 |
|
function compose_cdm_description_table($description_uuid, $descriptive_dataset_uuid = NULL) {
|
|
2169 |
function compose_description_table($description_uuid, $descriptive_dataset_uuid = NULL) {
|
2165 |
2170 |
RenderHints::pushToRenderStack('description_table');
|
2166 |
2171 |
|
2167 |
2172 |
$render_array = [];
|
... | ... | |
2231 |
2236 |
$render_array[] = markup_to_render_array(render_cdm_taxon($description->taxon));
|
2232 |
2237 |
}
|
2233 |
2238 |
|
2234 |
|
$root_nodes = [];
|
2235 |
2239 |
$root_nodes = get_root_nodes_for_dataset($description);
|
2236 |
2240 |
|
2237 |
2241 |
$header = ['Feature/Character', 'State'];
|
... | ... | |
2250 |
2254 |
$items = [];
|
2251 |
2255 |
foreach ($description->sources as $source) {
|
2252 |
2256 |
if ($source->type == 'Aggregation' and isset($source->cdmSource)){
|
2253 |
|
$specimendescription = $source->cdmSource;
|
|
2257 |
$cdm_source_entity = $source->cdmSource;
|
|
2258 |
switch($cdm_source_entity->class){
|
|
2259 |
case 'Taxon':
|
|
2260 |
$source_link_markup = render_taxon_or_name($cdm_source_entity) . icon_link(path_to_taxon($cdm_source_entity->uuid, false), generalizeString(PSEUDO_FEATURE_AGGREGATION_DESCRIPTIONS));
|
|
2261 |
break;
|
|
2262 |
case 'TaxonDescription':
|
|
2263 |
case 'SpecimenDescription':
|
|
2264 |
case 'NameDescription':
|
|
2265 |
$source_link_markup = render_cdm_description($cdm_source_entity);
|
|
2266 |
break;
|
|
2267 |
default:
|
|
2268 |
$source_link_markup = '<span class="error">unhandled CdmSource</span>';
|
|
2269 |
}
|
2254 |
2270 |
$items[] = [
|
2255 |
|
'data' => render_cdm_description($specimendescription),
|
|
2271 |
'data' => $source_link_markup
|
2256 |
2272 |
];
|
2257 |
2273 |
}
|
2258 |
2274 |
}
|
... | ... | |
2315 |
2331 |
case 'QuantitativeData':
|
2316 |
2332 |
$rows[] = [
|
2317 |
2333 |
$element->feature->representation_L10n,
|
2318 |
|
compose_quant_stats($element),
|
|
2334 |
render_quantitative_statistics($element),
|
2319 |
2335 |
];
|
2320 |
2336 |
break;
|
2321 |
2337 |
}
|
ref #8686 adding support for Taxon CdmLinks in "Bibliography"