1 |
5189a8ec
|
Andreas Kohlbecker
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Hooks provided by the CDM DataPortal module.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* @addtogroup hooks
|
10 |
|
|
* @{
|
11 |
|
|
*/
|
12 |
|
|
|
13 |
9aff46e4
|
Andreas Kohlbecker
|
/**
|
14 |
|
|
* Alter the feature block list.
|
15 |
|
|
*
|
16 |
|
|
* Modules implementing this hook can add, remove or modify
|
17 |
|
|
* feature blocks of the taxon general page part and of the
|
18 |
|
|
* specimen page part.
|
19 |
|
|
*
|
20 |
|
|
* @param $block_list
|
21 |
|
|
* the array of blocks as returned by list_blocks()
|
22 |
|
|
* @param $taxon
|
23 |
|
|
* Optional CDM Taxon instance, currently only given if
|
24 |
|
|
* called from within the taxon general page part
|
25 |
|
|
*
|
26 |
|
|
* @return array
|
27 |
|
|
* the altered $block_list
|
28 |
|
|
*
|
29 |
|
|
*/
|
30 |
|
|
function hook_cdm_feature_node_blocks_alter(&$block_list, $taxon = NULL) {
|
31 |
|
|
|
32 |
|
|
if($taxon) {
|
33 |
|
|
// taxon is only given if called from within the taxon general page part
|
34 |
|
|
$numberOfChildren = count(cdm_ws_get(CDM_WS_PORTAL_TAXONOMY_CHILDNODES_OF_TAXON, array (get_taxonomictree_uuid_selected(), $taxon->uuid)));
|
35 |
|
|
$subRank = 'sub taxa';
|
36 |
|
|
if ($taxon->name->rank->titleCache == "Genus") {
|
37 |
|
|
$subRank = "species";
|
38 |
|
|
} else if ($taxon->name->rank->titleCache == "Species") {
|
39 |
|
|
if($numberOfChildren==1){
|
40 |
|
|
$subRank = "infraspecific taxon";
|
41 |
|
|
}
|
42 |
|
|
else {
|
43 |
|
|
$subRank = "infraspecific taxa";
|
44 |
|
|
}
|
45 |
|
|
}
|
46 |
|
|
if ($numberOfChildren > 0) {
|
47 |
|
|
$block = feature_block('Number of Taxa');
|
48 |
|
|
// FIXME use compose_cdm_feature_block_elements() in next line
|
49 |
|
|
$block->content = array(markup_to_render_array('<ul class="feature-block-elements"><li>' . $numberOfChildren . " " . $subRank . '</li></ul>'));
|
50 |
|
|
array_unshift($block_list, $block);
|
51 |
|
|
cdm_toc_list_add_item('Number of Taxa', 'number-of-taxa', NULL, TRUE);
|
52 |
|
|
}
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
return $block_list;
|
56 |
|
|
}
|
57 |
5189a8ec
|
Andreas Kohlbecker
|
|
58 |
|
|
/**
|
59 |
|
|
* @} End of "addtogroup hooks".
|
60 |
|
|
*/
|