1 |
6657531f
|
Andreas Kohlbecker
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Page theming 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 |
|
|
* @see http://www.mozilla.org/MPL/MPL-1.1.html
|
14 |
|
|
*/
|
15 |
|
|
|
16 |
|
|
/**
|
17 |
|
|
* Returns HTML for the default title of a taxon page.
|
18 |
|
|
* * The returned title is a formatted taxon name.
|
19 |
|
|
*
|
20 |
|
|
* @param array $variables
|
21 |
|
|
* An associative array containing:
|
22 |
|
|
* - taxon: The taxon name being formatted for the title.
|
23 |
|
|
* - uuid: UUID for the taxon.
|
24 |
|
|
*
|
25 |
828a0c8c
|
Andreas Kohlbecker
|
* @return string
|
26 |
|
|
* Markup for a taxon page title
|
27 |
|
|
*
|
28 |
6657531f
|
Andreas Kohlbecker
|
* @ingroup themeable
|
29 |
|
|
*/
|
30 |
|
|
function theme_cdm_taxon_page_title($variables) {
|
31 |
|
|
$taxon = $variables['taxon'];
|
32 |
|
|
RenderHints::pushToRenderStack('taxon_page_title');
|
33 |
|
|
$referenceUri = '';
|
34 |
|
|
$out = '';
|
35 |
|
|
if (isset($taxon->name->nomenclaturalReference)) {
|
36 |
|
|
$referenceUri = url(path_to_reference($taxon->name->nomenclaturalReference->uuid));
|
37 |
|
|
}
|
38 |
|
|
|
39 |
63c3ac73
|
Andreas Kohlbecker
|
$out .= render_taxon_or_name($taxon, NULL, $referenceUri, FALSE);
|
40 |
6657531f
|
Andreas Kohlbecker
|
RenderHints::popFromRenderStack();
|
41 |
|
|
|
42 |
|
|
return '<span class="' . $taxon->class . '">' . $out . '</span>';
|
43 |
|
|
}
|
44 |
|
|
|
45 |
216abf0b
|
Patric Plitzner
|
/**
|
46 |
|
|
* Returns HTML for the default title of a specimen page.
|
47 |
|
|
* * The returned title is a the identifier of the specimen.
|
48 |
|
|
*
|
49 |
|
|
* @param array $variables
|
50 |
|
|
* An associative array containing:
|
51 |
|
|
* - specimen: The specimen being formatted for the title.
|
52 |
|
|
*
|
53 |
828a0c8c
|
Andreas Kohlbecker
|
* @return string
|
54 |
|
|
* Markup for the title of a specimen page
|
55 |
|
|
*
|
56 |
216abf0b
|
Patric Plitzner
|
* @ingroup themeable
|
57 |
|
|
*/
|
58 |
0b4ac33b
|
Patrick Plitzner
|
function theme_cdm_specimen_page_title($variables)
|
59 |
|
|
{
|
60 |
828a0c8c
|
Andreas Kohlbecker
|
|
61 |
216abf0b
|
Patric Plitzner
|
$specimen = $variables['specimen'];
|
62 |
|
|
RenderHints::pushToRenderStack('specimen_page_title');
|
63 |
|
|
$referenceUri = '';
|
64 |
|
|
$out = '';
|
65 |
|
|
|
66 |
828a0c8c
|
Andreas Kohlbecker
|
$collection = null;
|
67 |
a2acff0a
|
Katja Luther
|
if (!($specimen->class == 'FieldUnit')) {
|
68 |
|
|
if ($specimen->collection) {
|
69 |
|
|
if ($specimen->collection->code) {
|
70 |
|
|
$collection = $specimen->collection->code;
|
71 |
|
|
} elseif ($specimen->collection->name) {
|
72 |
|
|
$collection = $specimen->collection->name;
|
73 |
|
|
}
|
74 |
|
|
}
|
75 |
|
|
if ($specimen->accessionNumber) {
|
76 |
|
|
$specimenID = $specimen->accessionNumber;
|
77 |
|
|
} elseif ($specimen->barcode) {
|
78 |
|
|
$specimenID = $specimen->barcode;
|
79 |
|
|
} elseif ($specimen->catalogNumber) {
|
80 |
|
|
$specimenID = $specimen->catalogNumber;
|
81 |
|
|
} elseif ($specimen->titleCache) {
|
82 |
|
|
$specimenID = $specimen->titleCache;
|
83 |
|
|
}
|
84 |
|
|
if (!isset($specimenID) and !isset($collection)) {
|
85 |
|
|
$specimenID = $specimen->uuid;
|
86 |
|
|
}
|
87 |
|
|
}else{
|
88 |
|
|
if ($specimen->titleCache) {
|
89 |
|
|
$specimenID = $specimen->titleCache;
|
90 |
|
|
}
|
91 |
|
|
if (!isset($specimenID) and !isset($collection)) {
|
92 |
|
|
$specimenID = $specimen->uuid;
|
93 |
0b4ac33b
|
Patrick Plitzner
|
}
|
94 |
907cc9b4
|
Patrick Plitzner
|
}
|
95 |
|
|
|
96 |
a2acff0a
|
Katja Luther
|
if ($specimen ->class == 'FieldUnit'){
|
97 |
|
|
$out .= "FieldUnit ";
|
98 |
|
|
}else{
|
99 |
|
|
$out .= "Specimen ";
|
100 |
|
|
}
|
101 |
216abf0b
|
Patric Plitzner
|
|
102 |
72d57201
|
Katja Luther
|
if($collection){
|
103 |
|
|
$out .= $collection." ";
|
104 |
|
|
}
|
105 |
|
|
$out .= $specimenID;
|
106 |
216abf0b
|
Patric Plitzner
|
|
107 |
72d57201
|
Katja Luther
|
RenderHints::popFromRenderStack();
|
108 |
|
|
|
109 |
|
|
return '<span class="' . $specimen->class . '">' . $out . '</span>';
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
/**
|
113 |
|
|
* Returns HTML for the default title of a specimen page.
|
114 |
|
|
* * The returned title is a the identifier of the specimen.
|
115 |
|
|
*
|
116 |
|
|
* @param array $variables
|
117 |
|
|
* An associative array containing:
|
118 |
|
|
* - specimen: The specimen being formatted for the title.
|
119 |
|
|
*
|
120 |
|
|
* @return string
|
121 |
|
|
* Markup for the title of a specimen page
|
122 |
|
|
*
|
123 |
|
|
* @ingroup themeable
|
124 |
|
|
*/
|
125 |
|
|
function theme_cdm_specimen_dto_page_title($variables)
|
126 |
|
|
{
|
127 |
|
|
|
128 |
|
|
$specimen = $variables['specimen'];
|
129 |
|
|
RenderHints::pushToRenderStack('specimen_page_title');
|
130 |
|
|
$referenceUri = '';
|
131 |
|
|
$out = '';
|
132 |
|
|
|
133 |
|
|
$collection = null;
|
134 |
|
|
if (!($specimen->class == 'FieldUnit')) {
|
135 |
|
|
if ($specimen->collection) {
|
136 |
|
|
if ($specimen->collection->code) {
|
137 |
|
|
$collection = $specimen->collection->code;
|
138 |
|
|
} elseif ($specimen->collection->name) {
|
139 |
|
|
$collection = $specimen->collection->name;
|
140 |
|
|
}
|
141 |
|
|
}
|
142 |
|
|
if ($specimen->accessionNumber) {
|
143 |
|
|
$specimenID = $specimen->accessionNumber;
|
144 |
|
|
} elseif ($specimen->barcode) {
|
145 |
|
|
$specimenID = $specimen->barcode;
|
146 |
|
|
} elseif ($specimen->catalogNumber) {
|
147 |
|
|
$specimenID = $specimen->catalogNumber;
|
148 |
|
|
} elseif ($specimen->titleCache) {
|
149 |
|
|
$specimenID = $specimen->titleCache;
|
150 |
|
|
}
|
151 |
|
|
if (!isset($specimenID) and !isset($collection)) {
|
152 |
|
|
$specimenID = $specimen->uuid;
|
153 |
|
|
}
|
154 |
|
|
}else{
|
155 |
|
|
if ($specimen->titleCache) {
|
156 |
|
|
$specimenID = $specimen->titleCache;
|
157 |
|
|
}
|
158 |
|
|
if (!isset($specimenID) and !isset($collection)) {
|
159 |
|
|
$specimenID = $specimen->uuid;
|
160 |
|
|
}
|
161 |
|
|
}
|
162 |
|
|
|
163 |
|
|
if ($specimen ->class == 'FieldUnit'){
|
164 |
|
|
$out .= "FieldUnit ";
|
165 |
|
|
}else{
|
166 |
|
|
$out .= "Specimen ";
|
167 |
|
|
}
|
168 |
|
|
|
169 |
|
|
if($collection){
|
170 |
|
|
$out .= $collection." ";
|
171 |
|
|
}
|
172 |
|
|
$out .= $specimenID;
|
173 |
|
|
|
174 |
|
|
RenderHints::popFromRenderStack();
|
175 |
216abf0b
|
Patric Plitzner
|
|
176 |
72d57201
|
Katja Luther
|
return '<span class="' . $specimen->class . '">' . $out . '</span>';
|
177 |
216abf0b
|
Patric Plitzner
|
}
|
178 |
|
|
|
179 |
6657531f
|
Andreas Kohlbecker
|
/**
|
180 |
|
|
* Returns HTML for the default title for a name page.
|
181 |
|
|
*
|
182 |
|
|
* The returned title is a formatted name.
|
183 |
|
|
*
|
184 |
|
|
* @param array $variables
|
185 |
|
|
* An associative array containing:
|
186 |
|
|
* - taxon_name: The taxon name object.
|
187 |
|
|
*
|
188 |
828a0c8c
|
Andreas Kohlbecker
|
* @return string
|
189 |
|
|
* Markup for the title of a name page
|
190 |
|
|
*
|
191 |
6657531f
|
Andreas Kohlbecker
|
* @ingroup themeable
|
192 |
|
|
*/
|
193 |
|
|
function theme_cdm_name_page_title($variables) {
|
194 |
|
|
$taxon_name = $variables['taxon_name'];
|
195 |
a7560a18
|
Andreas Kohlbecker
|
RenderHints::pushToRenderStack('name_page_title');
|
196 |
d0d068e9
|
Andreas Kohlbecker
|
|
197 |
|
|
$referenceUri = NULL;
|
198 |
6657531f
|
Andreas Kohlbecker
|
if (isset($taxon_name->nomenclaturalReference)) {
|
199 |
|
|
$referenceUri = url(path_to_reference($taxon_name->nomenclaturalReference->uuid));
|
200 |
|
|
}
|
201 |
|
|
|
202 |
d64f1d61
|
Andreas Kohlbecker
|
$out = '<span class="' . html_class_attribute_ref($taxon_name) . '">'
|
203 |
c8c879d8
|
Andreas Kohlbecker
|
. render_taxon_or_name($taxon_name, NULL, $referenceUri, FALSE)
|
204 |
|
|
. '</span>';
|
205 |
6657531f
|
Andreas Kohlbecker
|
RenderHints::popFromRenderStack();
|
206 |
|
|
return $out;
|
207 |
|
|
}
|
208 |
|
|
|
209 |
|
|
|
210 |
0e0c8c01
|
Andreas Kohlbecker
|
|
211 |
|
|
/**
|
212 |
|
|
* Returns HTML for the given result page including a pager.
|
213 |
|
|
*
|
214 |
|
|
* @param array $variables
|
215 |
|
|
* An associative array containing:
|
216 |
|
|
* - pager: The cdmlib pager object containing the result set of cdm base
|
217 |
|
|
* objects (currently this function can only handle taxon instances =>
|
218 |
|
|
* TODO)
|
219 |
|
|
* - path: The target path for the pager links, this will usually point to
|
220 |
|
|
* 'cdm_dataportal/search/results/taxon'
|
221 |
|
|
*
|
222 |
828a0c8c
|
Andreas Kohlbecker
|
* @return string
|
223 |
|
|
* Markup for the result page
|
224 |
|
|
*
|
225 |
|
|
* @throws Exception
|
226 |
|
|
*
|
227 |
0e0c8c01
|
Andreas Kohlbecker
|
* @ingroup themeable
|
228 |
|
|
*/
|
229 |
0a1dc066
|
Andreas Kohlbecker
|
function theme_cdm_search_taxa_results($variables)
|
230 |
1d69a96c
|
Andreas Kohlbecker
|
{
|
231 |
0e0c8c01
|
Andreas Kohlbecker
|
$pager = $variables['pager'];
|
232 |
34dd7be9
|
Andreas Kohlbecker
|
$path = $variables['path'];
|
233 |
0e0c8c01
|
Andreas Kohlbecker
|
|
234 |
34dd7be9
|
Andreas Kohlbecker
|
$freetextSearchResults = array();
|
235 |
0e0c8c01
|
Andreas Kohlbecker
|
|
236 |
|
|
// If the pager contains records of SearchResults, extract the taxa and use
|
237 |
|
|
// them as records instead.
|
238 |
|
|
if (isset($pager->records[0]) && $pager->records[0]->class == "SearchResult") {
|
239 |
|
|
$freetextSearchResults = $pager->records;
|
240 |
|
|
$taxa = array();
|
241 |
|
|
// $highlightedFragments = array();
|
242 |
|
|
foreach ($pager->records as $searchResult) {
|
243 |
|
|
$taxa[] = &$searchResult->entity;
|
244 |
|
|
/*
|
245 |
|
|
if(!isset($searchResult->fieldHighlightMap)){
|
246 |
|
|
$searchResult->fieldHighlightMap = NULL;
|
247 |
|
|
}
|
248 |
|
|
$fragmentHighlighting[] = $searchResult->fieldHighlightMap;
|
249 |
|
|
*/
|
250 |
|
|
}
|
251 |
|
|
$pager->records = $taxa;
|
252 |
|
|
}
|
253 |
|
|
|
254 |
1d69a96c
|
Andreas Kohlbecker
|
|
255 |
0e0c8c01
|
Andreas Kohlbecker
|
// Add thumbnails checkbox and refine search link.
|
256 |
|
|
$out = '<div class="page_options">';
|
257 |
|
|
if (isset($_REQUEST['ws'])) {
|
258 |
|
|
if (cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) {
|
259 |
|
|
$out .= '<div id="backButton">' . l(t('Modify search'), cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) . '</div>';
|
260 |
|
|
}
|
261 |
|
|
}
|
262 |
1d69a96c
|
Andreas Kohlbecker
|
if (variable_get(SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX, SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX_DEFAULT)) {
|
263 |
c278f2a0
|
Andreas Kohlbecker
|
$out .= '<form name="pageoptions"><div id="showThumbnails"><input class="showThumbnails" type="checkbox" name="showThumbnails" ' . (do_showThumbnails() == 1 ? 'checked="checked"' : '') . '> ' . t('Display image thumbnails') . '</div></form>';
|
264 |
1d69a96c
|
Andreas Kohlbecker
|
}
|
265 |
61b6ee11
|
Andreas Kohlbecker
|
$out .= '</div>';
|
266 |
f56b1626
|
Andreas Kohlbecker
|
|
267 |
61b6ee11
|
Andreas Kohlbecker
|
$classification = cdm_dataportal_searched_in_classification();
|
268 |
f56b1626
|
Andreas Kohlbecker
|
|
269 |
a488aeb6
|
Andreas Kohlbecker
|
|
270 |
|
|
if ( count(cdm_ws_fetch_all(CDM_WS_PORTAL_TAXONOMY)) > 1 ) { // FIXME use a count REST method for this!!!
|
271 |
f56b1626
|
Andreas Kohlbecker
|
$out .= '<div id="search-summary">' . t('results for') . ' ';
|
272 |
|
|
if ($classification != NULL) {
|
273 |
|
|
$out .= $classification->titleCache ;
|
274 |
|
|
} else {
|
275 |
|
|
$out .= t('any classification');
|
276 |
|
|
}
|
277 |
0e0c8c01
|
Andreas Kohlbecker
|
$out .= ':</div>';
|
278 |
61b6ee11
|
Andreas Kohlbecker
|
}
|
279 |
0e0c8c01
|
Andreas Kohlbecker
|
|
280 |
|
|
// List results.
|
281 |
|
|
if (isset($pager->records) && count($pager->records) > 0) {
|
282 |
|
|
$out .= '<div id="search_results">';
|
283 |
01fff74a
|
Andreas Kohlbecker
|
$list_of_taxa = compose_list_of_taxa($pager->records, $freetextSearchResults, $classification === NULL);
|
284 |
|
|
$out .= drupal_render($list_of_taxa);
|
285 |
0e0c8c01
|
Andreas Kohlbecker
|
$out .= '</div>';
|
286 |
|
|
$out .= theme('cdm_pager', array(
|
287 |
|
|
'pager' => $pager,
|
288 |
|
|
'path' => $path,
|
289 |
|
|
'parameters' => $_REQUEST,
|
290 |
|
|
));
|
291 |
|
|
} else {
|
292 |
04f74f8d
|
Andreas Kohlbecker
|
$out .= '<h4 class="error">' . t('Sorry, no matching entries found.') . '</h4>';
|
293 |
0e0c8c01
|
Andreas Kohlbecker
|
}
|
294 |
|
|
return $out;
|
295 |
|
|
}
|
296 |
308b5f90
|
Andreas Kohlbecker
|
|
297 |
|
|
|
298 |
6eaec849
|
Katja Luther
|
/**
|
299 |
|
|
* Returns HTML for the given result page including a pager.
|
300 |
|
|
*
|
301 |
|
|
* @param array $variables
|
302 |
|
|
* An associative array containing:
|
303 |
|
|
* - pager: TODO
|
304 |
|
|
* - path: The target path for the pager links, this will usually point to
|
305 |
|
|
* 'cdm_dataportal/search/results/taxon'
|
306 |
|
|
*
|
307 |
|
|
* @return string
|
308 |
|
|
* Markup for the result page
|
309 |
|
|
*
|
310 |
|
|
* @throws Exception
|
311 |
|
|
*
|
312 |
|
|
* @ingroup themeable
|
313 |
|
|
*/
|
314 |
|
|
function theme_cdm_search_specimen_results($variables)
|
315 |
|
|
{
|
316 |
|
|
$pager = $variables['pager'];
|
317 |
|
|
$path = $variables['path'];
|
318 |
|
|
|
319 |
|
|
|
320 |
|
|
|
321 |
|
|
// Add thumbnails checkbox and refine search link.
|
322 |
|
|
$out = '<div class="page_options">';
|
323 |
|
|
//if (isset($_REQUEST['ws'])) {
|
324 |
|
|
// if (cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) {
|
325 |
|
|
// $out .= '<div id="backButton">' . l(t('Modify search'), cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) . '</div>';
|
326 |
|
|
// }
|
327 |
|
|
//}
|
328 |
|
|
if (variable_get(SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX, SEARCH_RESULTS_SHOW_THUMBNAIL_CHECKBOX_DEFAULT)) {
|
329 |
|
|
$out .= '<form name="pageoptions"><div id="showThumbnails"><input class="showThumbnails" type="checkbox" name="showThumbnails" ' . (do_showThumbnails() == 1 ? 'checked="checked"' : '') . '> ' . t('Display image thumbnails') . '</div></form>';
|
330 |
|
|
}
|
331 |
|
|
$out .= '</div>';
|
332 |
|
|
|
333 |
|
|
|
334 |
|
|
|
335 |
|
|
|
336 |
|
|
|
337 |
|
|
|
338 |
|
|
// List results.
|
339 |
|
|
if (isset($pager->data) ) {
|
340 |
|
|
$data = json_decode($pager->data, true);
|
341 |
|
|
$out .= '<div id="search_results">';
|
342 |
|
|
$list_of_result = compose_table_of_blast_result($data);
|
343 |
|
|
$out .= $list_of_result;
|
344 |
|
|
$out .= '</div>';
|
345 |
|
|
// $out .= theme('cdm_pager', array(
|
346 |
|
|
// 'pager' => $pager,
|
347 |
|
|
// 'path' => $path,
|
348 |
|
|
// 'parameters' => $_REQUEST,
|
349 |
|
|
//));
|
350 |
|
|
} else {
|
351 |
|
|
$out .= '<h4 class="error">' . t('Sorry, no matching entries found.') . '</h4>';
|
352 |
|
|
}
|
353 |
|
|
return $out;
|
354 |
|
|
}
|
355 |
|
|
|
356 |
|
|
|
357 |
6657531f
|
Andreas Kohlbecker
|
/**
|
358 |
|
|
* TODO Implementation of Hook taxon_image_gallery()
|
359 |
|
|
*
|
360 |
828a0c8c
|
Andreas Kohlbecker
|
* @param object $taxon
|
361 |
|
|
* @param object $media
|
362 |
6657531f
|
Andreas Kohlbecker
|
*
|
363 |
828a0c8c
|
Andreas Kohlbecker
|
* @return string
|
364 |
|
|
* Markup for the default media gallery
|
365 |
6657531f
|
Andreas Kohlbecker
|
*/
|
366 |
|
|
function taxon_image_gallery_default($taxon, $media) {
|
367 |
|
|
$hasImages = isset($media[0]);
|
368 |
|
|
|
369 |
|
|
if ($hasImages) {
|
370 |
|
|
|
371 |
|
|
$maxExtend = 150;
|
372 |
|
|
$cols = 3;
|
373 |
|
|
$maxRows = FALSE;
|
374 |
|
|
$alternativeMediaUri = NULL;
|
375 |
|
|
/* Comment @WA: was in D5:
|
376 |
|
|
$captionElements = array(
|
377 |
|
|
'title',
|
378 |
|
|
'rights',
|
379 |
7afb5232
|
Andreas Kohlbecker
|
'#uri' => t('Open Image'),
|
380 |
6657531f
|
Andreas Kohlbecker
|
);
|
381 |
|
|
*/
|
382 |
|
|
$captionElements = array(
|
383 |
|
|
'title',
|
384 |
|
|
'description',
|
385 |
|
|
'artist',
|
386 |
|
|
'location',
|
387 |
|
|
'rights',
|
388 |
7afb5232
|
Andreas Kohlbecker
|
'#uri' => t('Open image'),
|
389 |
6657531f
|
Andreas Kohlbecker
|
);
|
390 |
|
|
$gallery_name = $taxon->uuid;
|
391 |
|
|
$mediaLinkType = 'LIGHTBOX';
|
392 |
|
|
|
393 |
|
|
// $gallery_settings = getGallerySettings(CDM_DATAPORTAL_MEDIA_GALLERY_NAME);
|
394 |
|
|
|
395 |
|
|
$gallery_settings = getGallerySettings(CDM_DATAPORTAL_TAXON_MEDIA_GALLERY_NAME_TAB);
|
396 |
|
|
|
397 |
|
|
$out = '<div class="image-gallerie">';
|
398 |
a9815578
|
Andreas Kohlbecker
|
$out .= compose_cdm_media_gallerie(array(
|
399 |
6657531f
|
Andreas Kohlbecker
|
'mediaList' => $media,
|
400 |
|
|
'galleryName' => $gallery_name,
|
401 |
|
|
'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
|
402 |
|
|
'cols' => $gallery_settings['cdm_dataportal_media_cols'],
|
403 |
|
|
'maxRows' => 0, // Ignore maxrows settings.
|
404 |
|
|
'captionElements' => $captionElements,
|
405 |
|
|
'mediaLinkType' => $mediaLinkType,
|
406 |
|
|
'alternativeMediaUri' => NULL,
|
407 |
|
|
'galleryLinkUri' => NULL,
|
408 |
|
|
'showCaption' => $gallery_settings['cdm_dataportal_show_thumbnail_captions'],
|
409 |
|
|
));
|
410 |
|
|
$out .= '</div>';
|
411 |
|
|
}
|
412 |
|
|
else {
|
413 |
|
|
$out = 'No images available.';
|
414 |
|
|
}
|
415 |
|
|
return $out;
|
416 |
|
|
}
|
417 |
|
|
|
418 |
|
|
/**
|
419 |
|
|
* TODO Implementation of Hook taxon_image_gallery()
|
420 |
|
|
*
|
421 |
828a0c8c
|
Andreas Kohlbecker
|
* @param object $taxon
|
422 |
|
|
* @param object $media
|
423 |
|
|
*
|
424 |
|
|
* @return string
|
425 |
|
|
* Markup for the fsi media gallery
|
426 |
6657531f
|
Andreas Kohlbecker
|
*
|
427 |
828a0c8c
|
Andreas Kohlbecker
|
* @throws Exception
|
428 |
6657531f
|
Andreas Kohlbecker
|
*/
|
429 |
|
|
function taxon_image_gallery_fsi($taxon, $media) {
|
430 |
|
|
$flashLink = isset($media[0]);
|
431 |
|
|
|
432 |
|
|
if ($flashLink) {
|
433 |
|
|
|
434 |
|
|
if (module_exists("fsi_gallery")) {
|
435 |
|
|
$out = theme("fsi_gallery", array('taxon' => $taxon, 'media' => $media));
|
436 |
|
|
}
|
437 |
|
|
else {
|
438 |
|
|
$message = t('In order to use the FSI gallery you must enable the according ') . l(t("module"), "admin/modules");
|
439 |
|
|
drupal_set_message($message, "error");
|
440 |
|
|
$out = '<h3>' . $message . '</h3>';
|
441 |
|
|
}
|
442 |
|
|
}
|
443 |
|
|
else {
|
444 |
|
|
$out = 'No images available.';
|
445 |
|
|
}
|
446 |
|
|
return $out;
|
447 |
|
|
}
|
448 |
|
|
|
449 |
|
|
|
450 |
|
|
/**
|
451 |
|
|
* @todo Please document this function.
|
452 |
|
|
* @see http://drupal.org/node/1354
|
453 |
|
|
*/
|
454 |
|
|
function theme_cdm_media_page($variables) {
|
455 |
a867b774
|
Andreas Kohlbecker
|
|
456 |
6657531f
|
Andreas Kohlbecker
|
$media = $variables['media'];
|
457 |
|
|
$mediarepresentation_uuid = $variables['mediarepresentation_uuid'];
|
458 |
|
|
$partId = $variables['partId'];
|
459 |
|
|
$out = '';
|
460 |
4fa6f9ba
|
Andreas Kohlbecker
|
|
461 |
|
|
// Determine which representation and which part to show
|
462 |
4946eebf
|
Andreas Kohlbecker
|
$active_representation_index = 0;
|
463 |
4fa6f9ba
|
Andreas Kohlbecker
|
|
464 |
|
|
if (!$mediarepresentation_uuid) {
|
465 |
4946eebf
|
Andreas Kohlbecker
|
// no representation requested by the method parameters, find the best one
|
466 |
4fa6f9ba
|
Andreas Kohlbecker
|
$representations = cdm_preferred_media_representations($media, array('image/png', 'image/jpeg', 'image/gif'), null, null);
|
467 |
4946eebf
|
Andreas Kohlbecker
|
if($representations && count($representations) > 0){
|
468 |
|
|
$preferred_representation = array_shift($representations);
|
469 |
|
|
$mediarepresentation_uuid = $preferred_representation->uuid;
|
470 |
|
|
}
|
471 |
4fa6f9ba
|
Andreas Kohlbecker
|
}
|
472 |
|
|
|
473 |
4946eebf
|
Andreas Kohlbecker
|
if($mediarepresentation_uuid){
|
474 |
|
|
foreach ($media->representations as $representation) {
|
475 |
|
|
if ($representation->uuid == $mediarepresentation_uuid) {
|
476 |
|
|
break;
|
477 |
|
|
}
|
478 |
|
|
$active_representation_index++;
|
479 |
6657531f
|
Andreas Kohlbecker
|
}
|
480 |
|
|
}
|
481 |
|
|
|
482 |
4fa6f9ba
|
Andreas Kohlbecker
|
|
483 |
4946eebf
|
Andreas Kohlbecker
|
$active_part_index = 0;
|
484 |
|
|
if (is_uuid($partId)) {
|
485 |
|
|
foreach ($media->representations[$active_representation_index]->parts as $part) {
|
486 |
6657531f
|
Andreas Kohlbecker
|
if ($part->uuid == $partId) {
|
487 |
4946eebf
|
Andreas Kohlbecker
|
break;
|
488 |
6657531f
|
Andreas Kohlbecker
|
}
|
489 |
4946eebf
|
Andreas Kohlbecker
|
$active_part_index++;
|
490 |
6657531f
|
Andreas Kohlbecker
|
}
|
491 |
|
|
}
|
492 |
4946eebf
|
Andreas Kohlbecker
|
else if(is_numeric($partId)){
|
493 |
|
|
$active_part_index = $partId;
|
494 |
6657531f
|
Andreas Kohlbecker
|
}
|
495 |
|
|
|
496 |
97ff635c
|
Andreas Kohlbecker
|
$media_metadata = read_media_metadata($media);
|
497 |
50d9206b
|
Andreas Kohlbecker
|
$title = 'Media';
|
498 |
|
|
if($media_metadata['title']){
|
499 |
|
|
$title .= ' ' .$media_metadata['title'];
|
500 |
|
|
} else if(isset($media_metadata['filename'])){
|
501 |
|
|
$title .= ' (' .$media_metadata['filename'] .')';
|
502 |
|
|
}
|
503 |
6657531f
|
Andreas Kohlbecker
|
|
504 |
|
|
$imageMaxExtend = variable_get('image-page-maxextend', 400);
|
505 |
|
|
|
506 |
|
|
drupal_set_title($title, PASS_THROUGH);
|
507 |
|
|
|
508 |
|
|
$out .= '<div class="media cdm_media_viewer_image">';
|
509 |
|
|
|
510 |
3e2af8c2
|
Andreas Kohlbecker
|
if(preg_match('/cdm_dataportal\/taxon\//', $_SERVER['HTTP_REFERER']) ){
|
511 |
78bac306
|
Andreas Kohlbecker
|
if(variable_get('cdm_dataportal_taxonpage_tabs', 1)){
|
512 |
|
|
// taxon page with tabs
|
513 |
|
|
$out .= '<div id="backToGalleryButton">' . l(t('Back to images'), $_SESSION['cdm']['last_gallery']) . '</div>';
|
514 |
|
|
} else {
|
515 |
|
|
// tabless mode
|
516 |
|
|
$out .= '<div id="backToGalleryButton">' . l(t('Back to taxon page'), $_SESSION['cdm']['last_gallery']) . '</div>';
|
517 |
|
|
}
|
518 |
3e2af8c2
|
Andreas Kohlbecker
|
}
|
519 |
6657531f
|
Andreas Kohlbecker
|
$out .= '<div class="viewer">';
|
520 |
4946eebf
|
Andreas Kohlbecker
|
$out .= cdm_openlayers_image($media->representations[$active_representation_index]->parts[$active_part_index], $imageMaxExtend);
|
521 |
6657531f
|
Andreas Kohlbecker
|
$out .= '</div>';
|
522 |
|
|
|
523 |
|
|
// General media metadata.
|
524 |
f79d32d6
|
Andreas Kohlbecker
|
$metadataToPrint = theme('cdm_media_caption', array('media' => $media, 'sources_as_content' => true));
|
525 |
6657531f
|
Andreas Kohlbecker
|
$out .= $metadataToPrint;
|
526 |
|
|
|
527 |
63d5030d
|
Andreas Kohlbecker
|
$cdm_standard_image_viewer_settings = get_array_variable_merged(CDM_STANDARD_IMAGE_VIEWER, CDM_STANDARD_IMAGE_VIEWER_DEFAULT);
|
528 |
|
|
if ($cdm_standard_image_viewer_settings['media_representation_details_enabled'] == 1){
|
529 |
|
|
// Tabs for the different representations.
|
530 |
|
|
// Representation(-part) specific metadata.
|
531 |
|
|
$thumbnailMaxExtend = 100;
|
532 |
|
|
$out .= '<h3>' .t('Media representations') .'</h3><ul id="media-representations">';
|
533 |
|
|
$r_i = 0;
|
534 |
|
|
foreach ($media->representations as $representation) {
|
535 |
|
|
$out .= '<li><strong>'. t('Representation') . ' ' . $r_i . "</strong> ($representation->mimeType)" ;
|
536 |
|
|
// parts
|
537 |
|
|
$active_part_index = 0;
|
538 |
|
|
$table_class_attribute = '';
|
539 |
|
|
if($partIdx == $active_part_index && $active_representation_index == $r_i ){
|
540 |
|
|
$table_class_attribute = 'class="active"';
|
541 |
a867b774
|
Andreas Kohlbecker
|
}
|
542 |
63d5030d
|
Andreas Kohlbecker
|
$out .= "<table $table_class_attribute>";
|
543 |
|
|
foreach ($representation->parts as $part) {
|
544 |
|
|
$out .= '<tr><th>' . t('Part') . ' ' . ($active_part_index + 1) . '</th></tr><tr><td>';
|
545 |
|
|
switch ($part->class) {
|
546 |
|
|
case 'ImageFile':
|
547 |
|
|
$out .= $part->width . 'x' . $part->height . ' px - ' . $part->size . ' kB';
|
548 |
|
|
break;
|
549 |
|
|
case 'AudioFile':
|
550 |
|
|
case 'MovieFile':
|
551 |
|
|
$out .= t('Duration') . ': ' . $part->duration . 's - ' . $part->size . ' kB';
|
552 |
|
|
break;
|
553 |
|
|
default:
|
554 |
|
|
$out .= $part->size . 'k';
|
555 |
|
|
}
|
556 |
6657531f
|
Andreas Kohlbecker
|
|
557 |
63d5030d
|
Andreas Kohlbecker
|
$out .= '</td><td><a href="' . url(path_to_media($media->uuid, $representation->uuid, $active_part_index)) . '">'
|
558 |
|
|
. cdm_media_gallerie_image($part, $thumbnailMaxExtend, TRUE);
|
559 |
|
|
$active_part_index++;
|
560 |
|
|
}
|
561 |
|
|
$out .= '</table>';
|
562 |
|
|
$out .= '</li>';
|
563 |
|
|
$r_i++;
|
564 |
a867b774
|
Andreas Kohlbecker
|
}
|
565 |
63d5030d
|
Andreas Kohlbecker
|
$out .= '</ul>';
|
566 |
6657531f
|
Andreas Kohlbecker
|
}
|
567 |
|
|
|
568 |
a867b774
|
Andreas Kohlbecker
|
$out .= '</div>';
|
569 |
6657531f
|
Andreas Kohlbecker
|
return $out;
|
570 |
|
|
}
|
571 |
|
|
|
572 |
|
|
/**
|
573 |
|
|
* @todo Please document this function.
|
574 |
|
|
* @see http://drupal.org/node/1354
|
575 |
|
|
*/
|
576 |
|
|
function theme_cdm_polytomousKey_page($variables) {
|
577 |
|
|
$polytomousKey = $variables['polytomousKey'];
|
578 |
|
|
drupal_set_title($polytomousKey->titleCache, PASS_THROUGH);
|
579 |
|
|
|
580 |
|
|
$out = theme("cdm_IdentificationKey", array(
|
581 |
|
|
'identificationKey' => $polytomousKey,
|
582 |
|
|
'doLinkToKeyPage' => FALSE,
|
583 |
|
|
'showIdentificationKeyTitle' => FALSE,
|
584 |
|
|
));
|
585 |
|
|
|
586 |
|
|
// Key nodes in linked style.
|
587 |
|
|
$out .= theme('cdm_polytomousKey', array('polytomousKey' => $polytomousKey));
|
588 |
|
|
/*
|
589 |
29809fe3
|
Andreas Kohlbecker
|
* FIXME implement node type for keys !!!
|
590 |
|
|
* (wrapping the content in the cdm_dataportal.node becomes obsolete then).
|
591 |
|
|
*/
|
592 |
|
|
return '<div id="identificationKey">' . $out . '</div>';
|
593 |
4feeabc7
|
Andreas Kohlbecker
|
}
|