Revision f19f47fa
Added by Andreas Kohlbecker about 9 years ago
7.x/modules/cdm_dataportal/includes/pages.inc | ||
---|---|---|
1 | 1 |
<?php |
2 |
/**
|
|
3 |
* @file
|
|
4 |
* Page functions.
|
|
5 |
*
|
|
6 |
* @copyright
|
|
7 |
* (C) 2007-2012 EDIT
|
|
8 |
* European Distributed Institute of Taxonomy
|
|
9 |
* http://www.e-taxonomy.eu
|
|
10 |
*
|
|
11 |
* The contents of this module are subject to the Mozilla
|
|
12 |
* Public License Version 1.1.
|
|
2 |
/** |
|
3 |
* @file |
|
4 |
* Page functions. |
|
5 |
* |
|
6 |
* @copyright |
|
7 |
* (C) 2007-2012 EDIT |
|
8 |
* European Distributed Institute of Taxonomy |
|
9 |
* http://www.e-taxonomy.eu |
|
10 |
* |
|
11 |
* The contents of this module are subject to the Mozilla |
|
12 |
* Public License Version 1.1. |
|
13 | 13 |
* @see http://www.mozilla.org/MPL/MPL-1.1.html |
14 | 14 |
* |
15 | 15 |
* @author |
16 |
* - Andreas Kohlbecker <a.kohlbecker@BGBM.org> |
|
16 |
* - Andreas Kohlbecker <a.kohlbecker@BGBM.org> |
|
17 |
*/ |
|
18 |
|
|
19 |
|
|
20 |
/** |
|
21 |
* Creates a render array representing the ocurrences associetad with the $taxon. |
|
22 |
* |
|
23 |
* The resulting render array contains two elements: |
|
24 |
* - 'map': A map showing all point locations of the occurences is availabale |
|
25 |
* - 'specimen_list': the list of occurences prepated as table for theme_table() |
|
26 |
* |
|
27 |
* @param object $taxon |
|
28 |
* A cdm Taxon object |
|
29 |
* @return |
|
30 |
* A render array suitable for drupal_render() |
|
31 |
* |
|
17 | 32 |
*/ |
33 |
function cdm_dataportal_taxon_page_specimens($taxon) { |
|
34 |
|
|
35 |
$render_array = array(); |
|
36 |
RenderHints::pushToRenderStack('taxon_page_specimens'); |
|
18 | 37 |
|
19 |
|
|
20 |
/** |
|
21 |
* Creates a render array representing the ocurrences associetad with the $taxon. |
|
22 |
* |
|
23 |
* The resulting render array contains two elements: |
|
24 |
* - 'map': A map showing all point locations of the occurences is availabale |
|
25 |
* - 'specimen_list': the list of occurences prepated as table for theme_table() |
|
26 |
* |
|
27 |
* @param object $taxon |
|
28 |
* A cdm Taxon object |
|
29 |
* @return |
|
30 |
* A render array suitable for drupal_render() |
|
31 |
* |
|
32 |
*/ |
|
33 |
function cdm_dataportal_taxon_page_specimens($taxon) { |
|
34 |
|
|
35 |
$render_array = array(); |
|
36 |
RenderHints::pushToRenderStack('taxon_page_specimens'); |
|
37 |
|
|
38 |
$relationship_choice = variable_get(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS, unserialize(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT)); |
|
38 |
$relationship_choice = variable_get(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS, unserialize(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT)); |
|
39 | 39 |
$relationship_choice['direct'] = get_selection($relationship_choice['direct']); |
40 | 40 |
$relationship_choice['invers'] = get_selection($relationship_choice['invers']); |
41 | 41 |
|
... | ... | |
50 | 50 |
|
51 | 51 |
$by_associatedtaxon_query = http_build_query($by_associatedtaxon_query_parameters); |
52 | 52 |
|
53 |
$pager = cdm_ws_get(CDM_WS_OCCURRENCE_BY_ASSOCIATEDTAXON,
|
|
54 |
null,
|
|
55 |
$by_associatedtaxon_query . '&taxonUuid=' . $taxon->uuid
|
|
56 |
);
|
|
53 |
$pager = cdm_ws_get(CDM_WS_OCCURRENCE_BY_ASSOCIATEDTAXON, |
|
54 |
null, |
|
55 |
$by_associatedtaxon_query . '&taxonUuid=' . $taxon->uuid |
|
56 |
); |
|
57 | 57 |
|
58 |
$specimensOrObservations = array();
|
|
59 |
if(isset($pager->records[0])){
|
|
60 |
$specimensOrObservations = $pager->records;
|
|
58 |
$specimensOrObservations = array(); |
|
59 |
if(isset($pager->records[0])){ |
|
60 |
$specimensOrObservations = $pager->records; |
|
61 | 61 |
} |
62 | 62 |
|
63 | 63 |
// order occurrences by date but types should be on top of the list |
... | ... | |
71 | 71 |
$other_occurrences[] = $occurrence; |
72 | 72 |
} |
73 | 73 |
} |
74 |
$specimensOrObservations = array_merge($type_specimens, $other_occurrences);
|
|
75 |
|
|
76 |
// Collect media (fieldObjectMedia, derivedUnitMedia) and add as a custom field
|
|
77 |
// $occurrence->_fieldObjectMedia
|
|
78 |
foreach ($specimensOrObservations as &$occurrence) {
|
|
79 |
$occurrence->_fieldObjectMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array(
|
|
80 |
$occurrence->uuid,
|
|
81 |
'fieldObjectMedia',
|
|
82 |
));
|
|
83 |
$occurrence->_derivedUnitMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array(
|
|
84 |
$occurrence->uuid,
|
|
85 |
'derivedUnitMedia',
|
|
86 |
));
|
|
87 |
}
|
|
88 |
|
|
89 |
// --- get map service HTTP query paramaters
|
|
90 |
if (count($specimensOrObservations) > 0) {
|
|
91 |
$occurrence_query = cdm_ws_get(CDM_WS_GEOSERVICE_OCCURRENCEMAP, $taxon->uuid, $by_associatedtaxon_query);
|
|
92 |
|
|
93 |
if( isset($occurrence_query->String) ) {
|
|
94 |
$occurrence_query = $occurrence_query->String;
|
|
74 |
$specimensOrObservations = array_merge($type_specimens, $other_occurrences); |
|
75 |
|
|
76 |
// Collect media (fieldObjectMedia, derivedUnitMedia) and add as a custom field |
|
77 |
// $occurrence->_fieldObjectMedia |
|
78 |
foreach ($specimensOrObservations as &$occurrence) { |
|
79 |
$occurrence->_fieldObjectMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array( |
|
80 |
$occurrence->uuid, |
|
81 |
'fieldObjectMedia', |
|
82 |
)); |
|
83 |
$occurrence->_derivedUnitMedia = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, array( |
|
84 |
$occurrence->uuid, |
|
85 |
'derivedUnitMedia', |
|
86 |
)); |
|
87 |
} |
|
88 |
|
|
89 |
// --- get map service HTTP query paramaters |
|
90 |
if (count($specimensOrObservations) > 0) { |
|
91 |
$occurrence_query = cdm_ws_get(CDM_WS_GEOSERVICE_OCCURRENCEMAP, $taxon->uuid, $by_associatedtaxon_query); |
|
92 |
|
|
93 |
if( isset($occurrence_query->String) ) { |
|
94 |
$occurrence_query = $occurrence_query->String; |
|
95 | 95 |
$legend_format_query = null; |
96 |
$distribution_query = NULL;
|
|
97 |
|
|
98 |
$render_array['map'] = compose_map($occurrence_query, $distribution_query, $legend_format_query);
|
|
99 |
}
|
|
100 |
}
|
|
101 |
|
|
102 |
// --- generate the specimen list as table
|
|
103 |
$specimen_table = array(
|
|
104 |
'#theme' => 'table',
|
|
105 |
'#weight' => 2,
|
|
106 |
// prefix attributes and rows with '#' to let it pass to the theme function,
|
|
107 |
// otherwise it is handled as child render array
|
|
108 |
'#attributes' => array('class' => 'specimens'),
|
|
109 |
'#rows' => array(),
|
|
110 |
);
|
|
111 |
|
|
112 |
if ($specimensOrObservations) {
|
|
113 |
|
|
114 |
foreach ($specimensOrObservations as $specimenOrObservation) {
|
|
115 |
|
|
116 |
$mediaList = array();
|
|
117 |
if (is_array($specimenOrObservation->_fieldObjectMedia)) {
|
|
118 |
$mediaList = array_merge($mediaList, $specimenOrObservation->_fieldObjectMedia);
|
|
119 |
}
|
|
120 |
if (is_array($specimenOrObservation->_derivedUnitMedia)) {
|
|
121 |
$mediaList = array_merge($mediaList, $specimenOrObservation->_derivedUnitMedia);
|
|
96 |
$distribution_query = NULL; |
|
97 |
|
|
98 |
$render_array['map'] = compose_map($occurrence_query, $distribution_query, $legend_format_query); |
|
99 |
} |
|
100 |
} |
|
101 |
|
|
102 |
// --- generate the specimen list as table |
|
103 |
$specimen_table = array( |
|
104 |
'#theme' => 'table', |
|
105 |
'#weight' => 2, |
|
106 |
// prefix attributes and rows with '#' to let it pass to the theme function, |
|
107 |
// otherwise it is handled as child render array |
|
108 |
'#attributes' => array('class' => 'specimens'), |
|
109 |
'#rows' => array(), |
|
110 |
); |
|
111 |
|
|
112 |
if ($specimensOrObservations) { |
|
113 |
|
|
114 |
foreach ($specimensOrObservations as $specimenOrObservation) { |
|
115 |
|
|
116 |
$mediaList = array(); |
|
117 |
if (is_array($specimenOrObservation->_fieldObjectMedia)) { |
|
118 |
$mediaList = array_merge($mediaList, $specimenOrObservation->_fieldObjectMedia); |
|
119 |
} |
|
120 |
if (is_array($specimenOrObservation->_derivedUnitMedia)) { |
|
121 |
$mediaList = array_merge($mediaList, $specimenOrObservation->_derivedUnitMedia); |
|
122 | 122 |
} |
123 | 123 |
|
124 | 124 |
// typelabel will contain the typeStatus |
... | ... | |
128 | 128 |
$type_status = array(); |
129 | 129 |
foreach ($typeDesignationPager->records as $typeDesignation) { |
130 | 130 |
if (isset($typeDesignation->typeStatus->representation_L10n)){ |
131 |
$type_status[] = $typeDesignation->typeStatus->representation_L10n;
|
|
132 |
}
|
|
133 |
}
|
|
131 |
$type_status[] = $typeDesignation->typeStatus->representation_L10n; |
|
132 |
} |
|
133 |
} |
|
134 | 134 |
$type_label = implode(', ', $type_status); |
135 | 135 |
if($type_label){ |
136 | 136 |
$type_label .= ': ' ; |
137 |
}
|
|
138 |
}
|
|
137 |
} |
|
138 |
} |
|
139 | 139 |
|
140 | 140 |
// --- Specimen entry as dynamic label: |
141 | 141 |
// -> Dynabox for the specimenOrObservation |
142 |
$gallery_name = $specimenOrObservation->uuid;
|
|
142 |
$gallery_name = $specimenOrObservation->uuid; |
|
143 | 143 |
|
144 | 144 |
$derived_unit_ws_request = cdm_compose_url(CDM_WS_OCCURRENCE, array( $specimenOrObservation->uuid)); |
145 |
$label_html = cdm_dynabox(
|
|
146 |
$specimenOrObservation->uuid,
|
|
147 |
$type_label . $specimenOrObservation->titleCache,
|
|
148 |
$derived_unit_ws_request,
|
|
149 |
'cdm_specimenOrObservation', // the theme or compose function to use
|
|
145 |
$label_html = cdm_dynabox( |
|
146 |
$specimenOrObservation->uuid, |
|
147 |
$type_label . $specimenOrObservation->titleCache, |
|
148 |
$derived_unit_ws_request, |
|
149 |
'cdm_specimenOrObservation', // the theme or compose function to use |
|
150 | 150 |
'Click for details', |
151 |
array('div','div'),
|
|
151 |
array('div','div'), |
|
152 | 152 |
array(), |
153 |
'function(){ jQuery(\'#media_gallery_' . $gallery_name . '\').hide(); }', // open_callback
|
|
154 |
'function(){ jQuery(\'#media_gallery_' . $gallery_name . '\').show(); }' // close_callback
|
|
155 |
);
|
|
156 |
|
|
157 |
// --- Render associated media.
|
|
158 |
$gallery_html = '';
|
|
159 |
if (count($mediaList) > 0) {
|
|
160 |
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
|
|
161 |
$captionElements = array(
|
|
162 |
'#uri' => t('open media'),
|
|
163 |
);
|
|
164 |
|
|
165 |
$gallery_html = theme('cdm_media_gallerie', array(
|
|
166 |
'mediaList' => $mediaList,
|
|
167 |
'galleryName' => $gallery_name,
|
|
168 |
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
|
169 |
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
|
170 |
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
|
|
171 |
'captionElements' => $captionElements,
|
|
172 |
'mediaLinkType' => 'LIGHTBOX',
|
|
173 |
'alternativeMediaUri' => NULL,
|
|
174 |
'galleryLinkUri' => NULL,
|
|
175 |
));
|
|
176 |
}
|
|
177 |
|
|
178 |
$specimen_table['#rows'][] = array(
|
|
179 |
// An array of table rows. Every row is an array of cells, or an associative array
|
|
180 |
'data' => array(
|
|
181 |
// Each cell can be either a string or an associative array
|
|
182 |
$label_html . $gallery_html
|
|
183 |
),
|
|
184 |
'class' => array(
|
|
185 |
'descriptionElement',
|
|
186 |
'descriptionElement_IndividualsAssociation'
|
|
187 |
),
|
|
188 |
);
|
|
189 |
}
|
|
190 |
}
|
|
191 |
|
|
153 |
'function(){ jQuery(\'#media_gallery_' . $gallery_name . '\').hide(); }', // open_callback |
|
154 |
'function(){ jQuery(\'#media_gallery_' . $gallery_name . '\').show(); }' // close_callback |
|
155 |
); |
|
156 |
|
|
157 |
// --- Render associated media. |
|
158 |
$gallery_html = ''; |
|
159 |
if (count($mediaList) > 0) { |
|
160 |
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME); |
|
161 |
$captionElements = array( |
|
162 |
'#uri' => t('open media'), |
|
163 |
); |
|
164 |
|
|
165 |
$gallery_html = theme('cdm_media_gallerie', array( |
|
166 |
'mediaList' => $mediaList, |
|
167 |
'galleryName' => $gallery_name, |
|
168 |
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'], |
|
169 |
'cols' => $gallery_settings['cdm_dataportal_media_cols'], |
|
170 |
'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null, |
|
171 |
'captionElements' => $captionElements, |
|
172 |
'mediaLinkType' => 'LIGHTBOX', |
|
173 |
'alternativeMediaUri' => NULL, |
|
174 |
'galleryLinkUri' => NULL, |
|
175 |
)); |
|
176 |
} |
|
177 |
|
|
178 |
$specimen_table['#rows'][] = array( |
|
179 |
// An array of table rows. Every row is an array of cells, or an associative array |
|
180 |
'data' => array( |
|
181 |
// Each cell can be either a string or an associative array |
|
182 |
$label_html . $gallery_html |
|
183 |
), |
|
184 |
'class' => array( |
|
185 |
'descriptionElement', |
|
186 |
'descriptionElement_IndividualsAssociation' |
|
187 |
), |
|
188 |
); |
|
189 |
} |
|
190 |
} |
|
191 |
|
|
192 | 192 |
$render_array['specimen_list'] = $specimen_table; |
193 | 193 |
$render_array['pager'] = markup_to_render_array( |
194 | 194 |
theme('cdm_pager', array( |
... | ... | |
197 | 197 |
'parameters' => $_REQUEST, |
198 | 198 |
)), |
199 | 199 |
10 // weight |
200 |
);
|
|
201 |
|
|
202 |
RenderHints::popFromRenderStack();
|
|
203 |
return $render_array;
|
|
200 |
); |
|
201 |
|
|
202 |
RenderHints::popFromRenderStack(); |
|
203 |
return $render_array; |
|
204 | 204 |
} |
205 | 205 |
|
206 | 206 |
|
... | ... | |
316 | 316 |
) |
317 | 317 |
); |
318 | 318 |
|
319 |
// 5. put all disitribution data into the distribution feature node
|
|
319 |
// 5. put all distribution data into the distribution feature node |
|
320 | 320 |
if($distribution_text_data //if text data exists |
321 | 321 |
|| ($distribution_info_dto && isset($distribution_info_dto->tree) && $distribution_info_dto->tree->rootElement->numberOfChildren>0) // OR if tree element has distribution elements |
322 | 322 |
|| ($distribution_info_dto && !empty($distribution_info_dto->elements))) { // OR if DTO has distribution elements |
... | ... | |
530 | 530 |
$render_array['taxon_profile_image'] = markup_to_render_array('<div id="taxonProfileImage" style="width:' . $taxon_profile_image_settings['maxextend'] . 'px">' . $profile_image. '</div>', -101); |
531 | 531 |
} |
532 | 532 |
|
533 |
$toc = array( |
|
534 |
'#theme' => 'item_list', |
|
535 |
'#items' => cdm_feature_node_toc_items($merged_tree->root->childNodes), |
|
536 |
'#title' => t('Content'), |
|
537 |
'#weight' => -100, |
|
538 |
'#suffix' => '</div>', |
|
539 |
'#prefix'=> '<div id="page-toc">' |
|
540 |
); |
|
541 |
$render_array['taxon_description_feature_toc'] = $toc; //markup_to_render_array($toc_html); |
|
542 | 533 |
|
543 | 534 |
// Render the sections for each feature |
544 | 535 |
$render_array['taxon_description_features'] = markup_to_render_array( |
... | ... | |
548 | 539 |
) |
549 | 540 |
); |
550 | 541 |
|
542 |
$toc = array( |
|
543 |
'#theme' => 'item_list', |
|
544 |
'#items' => cdm_feature_node_toc_items($merged_tree->root->childNodes), |
|
545 |
'#title' => t('Content'), |
|
546 |
'#weight' => -100, // move to the top |
|
547 |
'#suffix' => '</div>', |
|
548 |
'#prefix'=> '<div id="page-toc">' |
|
549 |
); |
|
550 |
$render_array['taxon_description_feature_toc'] = $toc; //markup_to_render_array($toc_html); |
|
551 |
|
|
552 |
|
|
553 |
if(variable_get(BIBLIOGRAPHY_FOR_ORIGINAL_SOURCE, 1) == 1){ |
|
554 |
$bibliography_block = feature_block(t('Bibliography')); |
|
555 |
$bibliography_block->content = FootnoteManager::renderFootnoteList('BIBLIOGRAPHY'); |
|
556 |
$render_array['taxon_description_bibliography'] = markup_to_render_array( |
|
557 |
theme('block', |
|
558 |
array( |
|
559 |
'elements' => array( |
|
560 |
'#block' => $bibliography_block, |
|
561 |
'#children' => $bibliography_block->content, |
|
562 |
) |
|
563 |
) |
|
564 |
), |
|
565 |
100 // weight |
|
566 |
); |
|
567 |
$render_array['taxon_description_feature_toc']['#items'][] = toc_list_item('Bibliography', array('class' => 'bibliography')); |
|
568 |
} |
|
569 |
|
|
570 |
|
|
551 | 571 |
return $render_array; |
552 | 572 |
} |
553 | 573 |
|
... | ... | |
609 | 629 |
} |
610 | 630 |
} |
611 | 631 |
} |
612 |
}
|
|
632 |
} |
|
613 | 633 |
} |
614 | 634 |
|
615 | 635 |
|
... | ... | |
634 | 654 |
|
635 | 655 |
$variables['element']['#link'] = $link; |
636 | 656 |
} |
637 |
} |
|
657 |
} |
Also available in: Unified diff
basic implementation of #4314 (taxon page: display of bibliography in a block on the taxon page)