Revision f19f47fa
Added by Andreas Kohlbecker about 9 years ago
7.x/modules/cdm_dataportal/includes/descriptions.inc | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
function cdm_modifers_representations($iModifieable, $glue = ', ') { |
10 | 10 |
$modifiers_strings = array(); |
11 |
if (isset($iModifieable->modifiers)) {
|
|
12 |
foreach ($iModifieable->modifiers as $modifier) {
|
|
13 |
$modifiers_strings[] = cdm_term_representation($modifier);
|
|
14 |
}
|
|
11 |
if (isset($iModifieable->modifiers)) { |
|
12 |
foreach ($iModifieable->modifiers as $modifier) { |
|
13 |
$modifiers_strings[] = cdm_term_representation($modifier); |
|
14 |
} |
|
15 | 15 |
} |
16 | 16 |
return implode(', ', $modifiers_strings); |
17 | 17 |
} |
... | ... | |
107 | 107 |
function cdm_feature_node_toc_items($feature_nodes) { |
108 | 108 |
$items = array(); |
109 | 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 | 110 |
foreach ($feature_nodes as $node) { |
114 | 111 |
|
115 |
if (isset($node->descriptionElements['#type']) || hasFeatureNodeDescriptionElements($node)) {
|
|
112 |
if (isset($node->descriptionElements['#type']) || has_feature_node_description_elements($node)) {
|
|
116 | 113 |
|
117 |
$featureRepresentation = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature'; |
|
114 |
$feature_name = isset($node->feature->representation_L10n) ? $node->feature->representation_L10n : 'Feature'; |
|
115 |
$class_attributes = 'feature-toc-item-' . $node->feature->uuid; |
|
118 | 116 |
//TODO HACK to implement images for taxa, should be removed. |
119 | 117 |
if ($node->feature->uuid != UUID_IMAGE) { |
120 |
$items[] = array( |
|
121 |
'data' => 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 |
'class' => array('feature-toc-item-' . $node->feature->uuid), |
|
118 |
$items[] = toc_list_item( |
|
119 |
theme( |
|
120 |
'cdm_feature_name', |
|
121 |
array('feature_name' => $feature_name)) |
|
122 |
, |
|
123 |
array('class' => $class_attributes) |
|
131 | 124 |
); |
132 | 125 |
} |
133 | 126 |
} |
... | ... | |
138 | 131 |
return $items; |
139 | 132 |
} |
140 | 133 |
|
134 |
/** |
|
135 |
* Prepares an empty Drupal block for displaying description elements of a specific CDM Feature. |
|
136 |
* |
|
137 |
* The block can also be used for pseudo Features like a bibliography. Pseudo features are |
|
138 |
* derived from other data on the fly and so not exist as such in the cdm data. In case |
|
139 |
* of pseudo features the $feature is left empty |
|
140 |
* |
|
141 |
* @param $feature_name |
|
142 |
* A label describing the feature, usually the localized feature representation. |
|
143 |
* @param $feature |
|
144 |
* The CDM Feature for which the block is created. (optional) |
|
145 |
* @return object |
|
146 |
* A Drupal block object |
|
147 |
*/ |
|
148 |
function feature_block($feature_name, $feature = null) { |
|
149 |
$block = new stdclass(); // Empty object. |
|
150 |
$block->module = 'cdm_dataportal'; |
|
151 |
$block->delta = generalizeString($feature_name); |
|
152 |
$block->region = null; |
|
153 |
$block->subject = '<a name="' . $block->delta . '"></a><span class="' . html_class_attribute_ref($feature) . '">' |
|
154 |
. theme('cdm_feature_name', array('feature_name' => $feature_name)) |
|
155 |
. '</span>'; |
|
156 |
$block->module = "cdm_dataportal-feature"; |
|
157 |
$block->content = ''; |
|
158 |
return $block; |
|
159 |
} |
|
160 |
|
|
161 |
/** |
|
162 |
* Creates a list item for a table of content, suitable as data element for a themed list |
|
163 |
* |
|
164 |
* @see theme_list() |
|
165 |
* |
|
166 |
* @param $label |
|
167 |
* @param $http_request_params |
|
168 |
* @param $attributes |
|
169 |
* @return array |
|
170 |
*/ |
|
171 |
function toc_list_item($label, $attributes = array()) { |
|
172 |
|
|
173 |
// we better cache here since drupal_get_query_parameters has no internal static cache variable |
|
174 |
$http_request_params = drupal_static('http_request_params', drupal_get_query_parameters()); |
|
175 |
|
|
176 |
$item = array( |
|
177 |
'data' => l( |
|
178 |
$label, |
|
179 |
$_GET['q'], |
|
180 |
array( |
|
181 |
'attributes' => array('class' => array('toc')), |
|
182 |
'fragment' => generalizeString($label), |
|
183 |
'query' => $http_request_params |
|
184 |
) |
|
185 |
) |
|
186 |
); |
|
187 |
$item['attributes'] = $attributes; |
|
188 |
return $item; |
|
189 |
} |
|
190 |
|
|
141 | 191 |
/** |
142 | 192 |
* Creates the footnotes for the given CDM DescriptionElement instance. |
143 | 193 |
* |
... | ... | |
151 | 201 |
*/ |
152 | 202 |
function cdm_create_description_element_footnotes($description_element, $separator = ','){ |
153 | 203 |
|
204 |
|
|
154 | 205 |
// Annotations as footnotes. |
155 | 206 |
$footNoteKeys = cdm_annotations_as_footnotekeys($description_element); |
207 |
|
|
156 | 208 |
// Source references as footnotes. |
157 | 209 |
foreach ($description_element->sources as $source) { |
158 | 210 |
if (_is_original_source_type($source)) { |
159 |
$fn_key = FootnoteManager::addNewFootnote(RenderHints::getFootnoteListKey(), theme('cdm_OriginalSource', array(
|
|
211 |
$fn_key = FootnoteManager::addNewFootnote(original_source_footnote_list_key(), theme('cdm_OriginalSource', array(
|
|
160 | 212 |
'source' => $source, |
161 | 213 |
'doLink' => FALSE, |
162 | 214 |
))); |
... | ... | |
173 | 225 |
return $footnoteKeyListStr; |
174 | 226 |
} |
175 | 227 |
|
228 |
/** |
|
229 |
* |
|
230 |
* @return string the footnote_list_key |
|
231 |
*/ |
|
232 |
function original_source_footnote_list_key($key_suggestion = null) { |
|
233 |
if(!$key_suggestion){ |
|
234 |
$key_suggestion = RenderHints::getFootnoteListKey(); |
|
235 |
} |
|
236 |
$footnote_list_key = variable_get(BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE, 1) == 1 ? 'BIBLIOGRAPHY' : $key_suggestion; |
|
237 |
return $footnote_list_key; |
|
238 |
} |
|
239 |
|
Also available in: Unified diff
basic implementation of #4314 (taxon page: display of bibliography in a block on the taxon page)