Revision 9aff46e4
Added by Andreas Kohlbecker over 9 years ago
7.x/modules/palmweb/palmweb.module | ||
---|---|---|
19 | 19 |
|
20 | 20 |
|
21 | 21 |
/** |
22 |
* Implements hook_cdm_feature_node_toc_items_alter()
|
|
22 |
* Implements hook_cdm_feature_node_blocks_alter()
|
|
23 | 23 |
* |
24 |
* FIXME hook_cdm_feature_node_toc_items_alter() no longer exists, use cdm_toc_list_add_item() instead |
|
25 | 24 |
*/ |
26 |
function palmweb_cdm_feature_node_toc_items_alter($items){
|
|
25 |
function palmweb_cdm_feature_node_blocks_alter(&$block_list, $taxon){
|
|
27 | 26 |
|
28 |
$http_request_params = drupal_get_query_parameters(); |
|
29 |
$countFeatures = count($items); |
|
30 |
|
|
31 |
// number of taxa |
|
32 |
$numberOfChildren = count(cdm_ws_get(CDM_WS_PORTAL_TAXONOMY_CHILDNODES_OF_TAXON, array ( |
|
33 |
get_taxonomictree_uuid_selected(), |
|
34 |
substr(strrchr($_GET["q"],'/'), 1), |
|
35 |
))); |
|
36 |
if ($numberOfChildren != 0) { |
|
37 |
array_unshift($items, |
|
38 |
l( |
|
39 |
t(theme('cdm_feature_name', array('feature_name' => 'Number of Taxa'))), |
|
40 |
$_GET['q'], |
|
41 |
array( |
|
42 |
'query' => $http_request_params, |
|
43 |
'attributes' => array('class' => array('toc')), |
|
44 |
'fragment' => generalizeString('Number Of Taxa'), |
|
45 |
) |
|
46 |
) |
|
47 |
); |
|
27 |
if($taxon) { |
|
28 |
// taxon is only given if called from within the taxon general page part |
|
29 |
$numberOfChildren = count(cdm_ws_get(CDM_WS_PORTAL_TAXONOMY_CHILDNODES_OF_TAXON, array (get_taxonomictree_uuid_selected(), $taxon->uuid))); |
|
30 |
$subRank = 'sub taxa'; |
|
31 |
if ($taxon->name->rank->titleCache == "Genus") { |
|
32 |
$subRank = "species"; |
|
33 |
} else if ($taxon->name->rank->titleCache == "Species") { |
|
34 |
if($numberOfChildren==1){ |
|
35 |
$subRank = "infraspecific taxon"; |
|
36 |
} |
|
37 |
else { |
|
38 |
$subRank = "infraspecific taxa"; |
|
39 |
} |
|
40 |
} |
|
41 |
if ($numberOfChildren > 0) { |
|
42 |
$block = feature_block('Number of Taxa'); |
|
43 |
// FIXME use compose_cdm_feature_block_elements() in next line |
|
44 |
$block->content = array(markup_to_render_array('<ul class="feature-block-elements"><li>' . $numberOfChildren . " " . $subRank . '</li></ul>')); |
|
45 |
array_unshift($block_list, $block); |
|
46 |
cdm_toc_list_add_item('Number of Taxa', 'number-of-taxa', NULL, TRUE); |
|
47 |
} |
|
48 | 48 |
} |
49 | 49 |
|
50 |
// Setting the Anchor to the Bibliography section if the option is enabled. |
|
51 |
$show_bibliography = variable_get('cdm_show_bibliography', 1); |
|
52 |
|
|
53 |
$markerTypes['markerTypes'] = UUID_MARKERTYPE_USE; |
|
54 |
$useDescriptions = cdm_ws_get(CDM_WS_PORTAL_TAXON_DESCRIPTIONS, substr(strrchr($_GET["q"], '/'), 1), queryString($markerTypes)); |
|
55 |
if (!empty($useDescriptions)) { |
|
56 |
$items[] = l( |
|
57 |
t(theme('cdm_feature_name', array('feature_name' => 'Uses'))), |
|
58 |
$_GET['q'], |
|
59 |
array( |
|
60 |
'query' => $http_request_params, |
|
61 |
'attributes' => array('class' => array('toc')), |
|
62 |
'fragment' => 'userecords' |
|
63 |
) |
|
64 |
); |
|
65 |
} |
|
66 |
|
|
67 |
if ($show_bibliography && $countFeatures != 0) { |
|
68 |
$items[] = l( |
|
69 |
t(theme('cdm_feature_name', array('feature_name' => 'Bibliography'))), |
|
70 |
$_GET['q'], |
|
71 |
array( |
|
72 |
'query' => $http_request_params, |
|
73 |
'attributes' => array('class' => array('toc')), |
|
74 |
'fragment' => 'bibliography' |
|
75 |
) |
|
76 |
); |
|
77 |
} |
|
78 |
return $items; |
|
79 |
} |
|
50 |
return $block_list; |
|
51 |
} |
Also available in: Unified diff
introducing the api hook cdm_feature_node_blocks_alter and removing hook_cdm_feature_node_blocks_alter, this makes theme_cdm_feature_nodes obsolte, reducing speccial code in palmweb theme