1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* Returns the localized representations of the modifiers hold by the supplied cdm instance concatenated into one string.
|
5
|
*
|
6
|
* @param object $iModifieable
|
7
|
* cdm instance of an class implementing the interface IModifieable: DescriptionElementBase, StateDate, State
|
8
|
*/
|
9
|
function cdm_modifers_representations($iModifieable, $glue = ', ') {
|
10
|
$modifiers_strings = array();
|
11
|
if (isset($iModifieable->modifiers)) {
|
12
|
foreach ($iModifieable->modifiers as $modifier) {
|
13
|
$modifiers_strings[] = cdm_term_representation($modifier);
|
14
|
}
|
15
|
}
|
16
|
return implode(', ', $modifiers_strings);
|
17
|
}
|
18
|
|
19
|
/**
|
20
|
* Filters the given set of description elements and prefers computed elements over
|
21
|
* others. Computed description elements are identified by the MarkerType.COMPUTED()
|
22
|
*
|
23
|
* If the given set contains at least one computed element only the computed elements
|
24
|
* returned.
|
25
|
*
|
26
|
* @param $description_elements
|
27
|
* An array of CDM DescriptionElementBase instances
|
28
|
* @return only the computed description elements otherwise all others.
|
29
|
* @deprecated this is replaced by the cdmlib DistributionUtil class!!!
|
30
|
*/
|
31
|
function cdm_description_elements_prefer_computed($description_elements){
|
32
|
|
33
|
$computed_elements = array();
|
34
|
$other_elements = array();
|
35
|
|
36
|
if(!empty($description_elements)){
|
37
|
foreach ($description_elements as $element) {
|
38
|
if(cdm_entity_has_marker($element, UUID_MARKERTYPE_COMPUTED)){
|
39
|
$computed_elements[] = $element;
|
40
|
} else {
|
41
|
$other_elements[] = $element;
|
42
|
}
|
43
|
}
|
44
|
}
|
45
|
|
46
|
if(count($computed_elements) > 0) {
|
47
|
return $computed_elements;
|
48
|
} else {
|
49
|
return $other_elements;
|
50
|
}
|
51
|
}
|
52
|
|
53
|
function cdm_distribution_filter_query(){
|
54
|
$cdm_distribution_filter = get_array_variable_merged(CDM_DISTRIBUTION_FILTER, CDM_DISTRIBUTION_FILTER_DEFAULT);
|
55
|
$query = array();
|
56
|
|
57
|
if($cdm_distribution_filter['filter_rules']['statusOrderPreference']){
|
58
|
$query['statusOrderPreference'] = 1;
|
59
|
}
|
60
|
if($cdm_distribution_filter['filter_rules']['subAreaPreference']){
|
61
|
$query['subAreaPreference'] = 1;
|
62
|
}
|
63
|
if(is_array($cdm_distribution_filter['hideMarkedAreas']) && count($cdm_distribution_filter['hideMarkedAreas']) > 0){
|
64
|
$query['hideMarkedAreas'] = '';
|
65
|
foreach ($cdm_distribution_filter['hideMarkedAreas'] as $marker_type => $enabled)
|
66
|
if($enabled){
|
67
|
$query['hideMarkedAreas'] .= ($query['hideMarkedAreas'] ? ',' : '') . $marker_type;
|
68
|
}
|
69
|
}
|
70
|
|
71
|
return $query;
|
72
|
}
|
73
|
|
74
|
/**
|
75
|
* Merge the fields 'annotations', 'markers', 'sources', 'media' from the source CDM DescriptionElement into the target.
|
76
|
*
|
77
|
* @param $target
|
78
|
* The source CDM DescriptionElement
|
79
|
* @param $source
|
80
|
* The target CDM DescriptionElement
|
81
|
*/
|
82
|
function cdm_merge_description_elements(&$target, &$source){
|
83
|
static $fields_to_merge = array('annotations', 'markers', 'sources', 'media');
|
84
|
|
85
|
foreach ($fields_to_merge as $field){
|
86
|
if(is_array($source->$field)) {
|
87
|
if(!is_array($target->$field)){
|
88
|
$target->$field = $source->$field;
|
89
|
} else {
|
90
|
$target->$field = array_merge($target->$field, $source->$field);
|
91
|
}
|
92
|
}
|
93
|
}
|
94
|
}
|
95
|
|
96
|
/**
|
97
|
* Prepares the items for a table of content list.
|
98
|
*
|
99
|
* see also hook_cdm_feature_node_toc_items_alter()
|
100
|
*
|
101
|
* @param $feature_nodes
|
102
|
* An array of CDM FeatureNode instances
|
103
|
*
|
104
|
* @return array
|
105
|
* The items array is an array suitable for theme_item_list().
|
106
|
*/
|
107
|
function cdm_feature_node_toc_items($feature_nodes) {
|
108
|
$items = array();
|
109
|
|
110
|
// we better cache here since drupal_get_query_parameters has no internal static cache variable
|
111
|
$http_request_params = drupal_get_query_parameters();
|
112
|
|
113
|
foreach ($feature_nodes as $node) {
|
114
|
|
115
|
if (isset($node->descriptionElements['#type']) || hasFeatureNodeDescriptionElements($node)) {
|
116
|
|
117
|
$featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature';
|
118
|
//TODO HACK to implement images for taxa, should be removed.
|
119
|
if ($node->feature->uuid != UUID_IMAGE) {
|
120
|
$items[] = array(
|
121
|
l(
|
122
|
theme('cdm_feature_name', array('feature_name' => $featureRepresentation)),
|
123
|
$_GET['q'],
|
124
|
array(
|
125
|
'attributes' => array('class' => array('toc')),
|
126
|
'fragment' => generalizeString($featureRepresentation),
|
127
|
'query' => $http_request_params
|
128
|
)
|
129
|
)
|
130
|
);
|
131
|
}
|
132
|
}
|
133
|
}
|
134
|
|
135
|
drupal_alter('cdm_feature_node_toc_items', $items);
|
136
|
|
137
|
return $items;
|
138
|
}
|
139
|
|
140
|
/**
|
141
|
* Creates the footnotes for the given CDM DescriptionElement instance.
|
142
|
*
|
143
|
* Footnotes are created for annotatins and original sources.
|
144
|
*
|
145
|
* @param $descriptionElement
|
146
|
* A CDM DescriptionElement instance
|
147
|
* @param $separator
|
148
|
* Optional parameter. The separator string to concatenate the footnode ids, default is ','
|
149
|
* @return the string of foot note keys
|
150
|
*/
|
151
|
function cdm_create_description_element_footnotes($description_element, $separator = ','){
|
152
|
|
153
|
// Annotations as footnotes.
|
154
|
$footNoteKeys = cdm_annotations_as_footnotekeys($description_element);
|
155
|
// Source references as footnotes.
|
156
|
foreach ($description_element->sources as $source) {
|
157
|
if (_is_original_source_type($source)) {
|
158
|
$fn_key = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_OriginalSource', array(
|
159
|
'source' => $source,
|
160
|
'doLink' => FALSE,
|
161
|
)));
|
162
|
// Ensure uniqueness of the footnote keys.
|
163
|
cdm_add_footnote_to_array($footNoteKeys, $fn_key);
|
164
|
}
|
165
|
}
|
166
|
// Sort and render footnote keys.
|
167
|
$footnoteKeyListStr = '';
|
168
|
asort($footNoteKeys);
|
169
|
foreach ($footNoteKeys as $footNoteKey) {
|
170
|
$footnoteKeyListStr .= theme('cdm_footnote_key', array('footnoteKey' => $footNoteKey, 'separator' => ($footnoteKeyListStr ? $separator : '')));
|
171
|
}
|
172
|
return $footnoteKeyListStr;
|
173
|
}
|
174
|
|