1
|
<?php
|
2
|
/**
|
3
|
* @file
|
4
|
* Occurrence 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 a specimen.
|
18
|
*
|
19
|
* @param array $variables
|
20
|
* An associative array containing:
|
21
|
* - specimenTypeDesignation: Object.
|
22
|
*
|
23
|
* @ingroup themeable
|
24
|
*
|
25
|
* TODO: this function is not being used at all - can we remove it? (a.kohlbecker 6.2.2013)
|
26
|
*/
|
27
|
function theme_cdm_specimen($variables) {
|
28
|
$specimenTypeDesignation = $variables['specimenTypeDesignation'];
|
29
|
|
30
|
// _add_js_thickbox();
|
31
|
if (isset($specimenTypeDesignation->typeSpecimen)) {
|
32
|
$derivedUnitFacade = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, $specimenTypeDesignation->typeSpecimen->uuid);
|
33
|
}
|
34
|
|
35
|
$out = '';
|
36
|
if (isset($specimenTypeDesignation->media[0])) {
|
37
|
|
38
|
$image_url = base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/external_link.gif';
|
39
|
// Thickbox has problems reading the first url parameter, so a litte hack is
|
40
|
// needed here:
|
41
|
// Adding a meaningless parameter &tb_hack=1& ....
|
42
|
$out .= ' <a href="#TB_inline?tb_hack=1&width=300&height=330&inlineId=specimen_media_' . $specimenTypeDesignation->uuid . '" class="thickbox">' . '<img src="' . $image_url . '" title="' . t('Show media') . '" /></a>';
|
43
|
|
44
|
$out .= '<div id="specimen_media_' . $specimenTypeDesignation->uuid . '" class="tickbox_content"><table>';
|
45
|
|
46
|
$media_row = '<tr class="media_data">';
|
47
|
$meta_row = '<tr class="meta_data">';
|
48
|
|
49
|
foreach ($specimenTypeDesignation->media as $media) {
|
50
|
foreach ($media->representations as $representation) {
|
51
|
|
52
|
// TODO this this is PART 2/2 of a HACK - select preferred
|
53
|
// representation by mimetype and size.
|
54
|
if (TRUE || $representation->mimeType == 'image/jpeg') {
|
55
|
foreach ($representation->parts as $part) {
|
56
|
// Get media uri conversion rules if the module is installed and
|
57
|
// activated.
|
58
|
if (module_exists('cdm_mediauri')) {
|
59
|
$muris = cdm_mediauri_conversion($part->uri);
|
60
|
}
|
61
|
// --- Handle media preview rules.
|
62
|
if (isset($muris['preview'])) {
|
63
|
|
64
|
$a_child = '<img src="' . $muris['preview']['uri'] . '" class="preview" ' . ($muris['preview']['size_x'] ? 'width="' . $muris['preview']['size_x'] . '"' : '') . ($muris['preview']['size_y'] ? 'width="' . $muris['preview']['size_y'] . '"' : '') . '/>';
|
65
|
}
|
66
|
else {
|
67
|
$a_child = '<img src="' . $part->uri . '" />';
|
68
|
}
|
69
|
|
70
|
// --- Handle web application rules.
|
71
|
$webapp = '';
|
72
|
if (isset($muris['webapp'])) {
|
73
|
if ($muris['webapp']['embed_html']) {
|
74
|
// Embed in same page.
|
75
|
$webapp = $muris['webapp']['embed_html'];
|
76
|
}
|
77
|
else {
|
78
|
$webapp = l(t('web application'), $muris['webapp']['uri']);
|
79
|
}
|
80
|
}
|
81
|
$media_row .= '<td><a href="' . $part->uri . '" target="' . $part->uuid . '">' . $a_child . '</a></td>';
|
82
|
$meta_row .= '<td><span class="label">' . check_plain($specimenTypeDesignation->titleCache) . '</span><div class="webapp">' . $webapp . '</div></td>';
|
83
|
} // END parts.
|
84
|
// TODO this is PART 2/2 of a hack.
|
85
|
break;
|
86
|
} // END representations.
|
87
|
} // END media.
|
88
|
}
|
89
|
$out .= $media_row . '</tr>';
|
90
|
$out .= $meta_row . '</tr>';
|
91
|
|
92
|
$out .= '</div></table>';
|
93
|
}
|
94
|
return $out;
|
95
|
}
|
96
|
|
97
|
|
98
|
/**
|
99
|
*
|
100
|
* @param unknown_type $field
|
101
|
*
|
102
|
* @todo turn into theme function
|
103
|
*/
|
104
|
function cdm_occurrence_field_name_label($field){
|
105
|
|
106
|
static $field_labels = array(
|
107
|
'class' => 'Basis of Record',
|
108
|
'fieldNumber' => 'Collectors number',
|
109
|
'absoluteElevation' => 'Altitude',
|
110
|
'absoluteElevationMinimum' => 'Altitude maximum',
|
111
|
'absoluteElevationMaximum' => 'Altitude minimum',
|
112
|
'getGatheringPeriod' => 'Gathering period',
|
113
|
);
|
114
|
|
115
|
if (isset($field_labels[$field])) {
|
116
|
$field = $field_labels[$field];
|
117
|
}
|
118
|
|
119
|
$field = preg_replace_callback(
|
120
|
'/([a-z])([A-Z])/',
|
121
|
function ($m) {
|
122
|
return $m[1] . ' ' . strtolower ($m[2]);
|
123
|
},
|
124
|
$field);
|
125
|
|
126
|
return t('@field-name :', array('@field-name' => ucfirst($field)));
|
127
|
}
|
128
|
|
129
|
|