Revision 053a92ec
Added by Andreas Kohlbecker about 9 years ago
7.x/modules/cdm_dataportal/settings.php | ||
---|---|---|
85 | 85 |
array( |
86 | 86 |
'show' => 1, |
87 | 87 |
'maxextend' => 184, |
88 |
'media_uri_query' => '', |
|
88 | 89 |
'custom_placeholder_image_on' => 0, |
89 | 90 |
'custom_placeholder_image_fid' => '' |
90 | 91 |
) |
... | ... | |
1063 | 1064 |
/* |
1064 | 1065 |
* 'show' => 1, |
1065 | 1066 |
* 'maxextend' => 184, |
1067 |
* 'media_uri_query' => '' |
|
1066 | 1068 |
* 'custom_placeholder_image_on' => 1, |
1067 | 1069 |
* 'custom_placeholder_image_fid' => '' |
1068 | 1070 |
*/ |
... | ... | |
1084 | 1086 |
'#description' => t('The maximum extend in either dimension, width or height, of the profil picture in pixels.') |
1085 | 1087 |
); |
1086 | 1088 |
|
1089 |
$form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['media_uri_query'] = array( |
|
1090 |
'#type' => 'textfield', |
|
1091 |
'#tree' => TRUE, |
|
1092 |
'#title' => t('Additional URI query parameter'), |
|
1093 |
'#default_value' => $taxon_profile_image_settings['media_uri_query'], |
|
1094 |
'#maxlength' => 1024, |
|
1095 |
'#size' => 60, |
|
1096 |
'#description' => t('Additional query parameters to be used when requesting for the ' |
|
1097 |
. 'profile image. E.g.: <code>width=400&height=300&quality=95&format=jpeg</code>.' |
|
1098 |
. 'The query parameters will be appendend to the uri of the media representation part' |
|
1099 |
. ' as stored in the cdm. The query parameter string must not start with a \'&\' or \'?\'') |
|
1100 |
); |
|
1101 |
|
|
1087 | 1102 |
$form['taxon_profile'][CDM_TAXON_PROFILE_IMAGE]['custom_placeholder_image_on'] = array( |
1088 | 1103 |
'#type' => 'checkbox', |
1089 | 1104 |
'#title' => t('Use a custom placeholder image'), |
7.x/modules/cdm_dataportal/theme/cdm_dataportal.media.theme | ||
---|---|---|
771 | 771 |
return $out; |
772 | 772 |
} |
773 | 773 |
|
774 |
/** |
|
775 |
* @todo Please document this function. |
|
776 |
* @see http://drupal.org/node/1354 |
|
777 |
*/ |
|
778 |
function theme_cdm_preferredImage($variables) { |
|
779 |
|
|
780 |
$media = $variables['media']; |
|
781 |
$defaultRepresentationPart = $variables['defaultRepresentationPart']; |
|
782 |
$imageMaxExtend = $variables['imageMaxExtend']; |
|
783 |
$parameters = $variables['parameters']; |
|
784 |
|
|
785 |
$out = ''; |
|
786 |
|
|
787 |
if (isset($media[0])) { |
|
788 |
$representationPart = $media[0]->representations[0]->parts[0]; |
|
789 |
if ($parameters) { |
|
790 |
$representationPart->uri . $parameters; |
|
791 |
} |
|
792 |
} |
|
793 |
else { |
|
794 |
$representationPart = $defaultRepresentationPart; |
|
795 |
} |
|
796 |
|
|
797 |
$attributes = array( |
|
798 |
'alt' => (isset($media->representations[0]->parts[0]->uri) ? $media->representations[0]->parts[0]->uri : "no image available"), |
|
799 |
); |
|
800 |
$out .= theme('cdm_media_gallerie_image', array( |
|
801 |
'mediaRepresentationPart' => $representationPart, |
|
802 |
'maxExtend' => $imageMaxExtend, |
|
803 |
'addPassePartout' => FALSE, |
|
804 |
'attributes' => $attributes, |
|
805 |
)); |
|
806 |
|
|
807 |
return $out; |
|
808 |
} |
7.x/modules/cdm_dataportal/theme/cdm_dataportal.page.theme | ||
---|---|---|
294 | 294 |
$taxon_profile_image_settings = variable_get(CDM_TAXON_PROFILE_IMAGE, unserialize(CDM_TAXON_PROFILE_IMAGE_DEFAULT)); |
295 | 295 |
if ($taxon_profile_image_settings['show'] && !$hideImages) { |
296 | 296 |
|
297 |
$defaultRepresentationPart = new stdClass(); |
|
298 |
if(!empty($taxon_profile_image_settings['custom_placeholder_image_on']) && !empty($taxon_profile_image_settings['custom_placeholder_image_fid'])){ |
|
299 |
// use the user provided image |
|
300 |
$profile_image_file = file_load($taxon_profile_image_settings['custom_placeholder_image_fid']); |
|
301 |
$url = file_create_url($profile_image_file->uri); |
|
302 |
$image_info = image_get_info($profile_image_file->uri); |
|
303 |
$defaultRepresentationPart->width = $image_info['width']; |
|
304 |
$defaultRepresentationPart->height = $image_info['height']; |
|
305 |
$defaultRepresentationPart->uri = $url; |
|
306 |
} else { |
|
307 |
// use the hardcoded default |
|
308 |
$defaultRepresentationPart->width = 184; |
|
309 |
$defaultRepresentationPart->height = 144; |
|
310 |
$defaultRepresentationPart->uri = base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/no_picture.png'; |
|
311 |
} |
|
312 |
|
|
313 |
$out .= '<div id="taxonProfileImage">' . theme('cdm_preferredImage', array( |
|
314 |
'media' => $media, |
|
315 |
'defaultRepresentationPart' => $defaultRepresentationPart, |
|
316 |
'imageMaxExtend' => $taxon_profile_image_settings['maxextend'], |
|
317 |
)) . '</div>'; |
|
297 |
$representationPart = new stdClass(); |
|
298 |
$attributes = array(); |
|
299 |
if (isset($media[0]->representations[0]->parts[0])) { |
|
300 |
$representationPart = $media[0]->representations[0]->parts[0]; |
|
301 |
$attributes['alt'] = $representationPart->uri; |
|
302 |
|
|
303 |
if(!empty($taxon_profile_image_settings['media_uri_query'])){ |
|
304 |
$representationPart->uri = $representationPart->uri |
|
305 |
. (strpos($representationPart->uri, '?') !== FALSE ? '&' : '?') |
|
306 |
. $taxon_profile_image_settings['media_uri_query']; |
|
307 |
} |
|
308 |
} |
|
309 |
else { |
|
310 |
// show placeholder image instead |
|
311 |
if(!empty($taxon_profile_image_settings['custom_placeholder_image_on']) && !empty($taxon_profile_image_settings['custom_placeholder_image_fid'])){ |
|
312 |
// use the user provided image |
|
313 |
$profile_image_file = file_load($taxon_profile_image_settings['custom_placeholder_image_fid']); |
|
314 |
$url = file_create_url($profile_image_file->uri); |
|
315 |
$image_info = image_get_info($profile_image_file->uri); |
|
316 |
$representationPart->width = $image_info['width']; |
|
317 |
$representationPart->height = $image_info['height']; |
|
318 |
$representationPart->uri = $url; |
|
319 |
} else { |
|
320 |
// use the hard coded default |
|
321 |
$representationPart->width = 184; |
|
322 |
$representationPart->height = 144; |
|
323 |
$representationPart->uri = base_path() . drupal_get_path('module', 'cdm_dataportal') . '/images/no_picture.png'; |
|
324 |
} |
|
325 |
$attributes['alt'] = "no image available"; |
|
326 |
} |
|
327 |
|
|
328 |
$profile_image = theme('cdm_media_gallerie_image', array( |
|
329 |
'mediaRepresentationPart' => $representationPart, |
|
330 |
'maxExtend' => $taxon_profile_image_settings['maxextend'], |
|
331 |
'addPassePartout' => FALSE, |
|
332 |
'attributes' => $attributes, |
|
333 |
)); |
|
334 |
$out .= '<div id="taxonProfileImage">' . $profile_image. '</div>'; |
|
318 | 335 |
} |
319 | 336 |
|
320 | 337 |
// Description TOC. |
7.x/modules/cdm_dataportal/theme/theme_registry.inc | ||
---|---|---|
169 | 169 |
'attributes' => NULL, |
170 | 170 |
)), |
171 | 171 |
'cdm_openlayers_image' => array('variables' => array('mediaRepresentationPart' => NULL, 'maxExtend' => NULL)), |
172 |
'cdm_preferredImage' => array('variables' => array( |
|
173 |
'media' => NULL, |
|
174 |
'defaultRepresentationPart' => NULL, |
|
175 |
'imageMaxExtend' => NULL, |
|
176 |
'parameters' => '', |
|
177 |
)), |
|
178 |
|
|
179 | 172 |
// Themes in cdm_dataportal.name.theme. |
180 | 173 |
'cdm_taxonName' => array('variables' => array( |
181 | 174 |
'taxonName' => NULL, |
7.x/themes/garland_cichorieae/template.php | ||
---|---|---|
4 | 4 |
* Overrides of generic themeing functions in cdm_dataportal.theme.php. |
5 | 5 |
*/ |
6 | 6 |
|
7 |
/** |
|
8 |
* Returns HTML for a cdm_taxon_page_profile. |
|
9 |
* |
|
10 |
* The description page is supposed to be the front page for a taxon. |
|
11 |
* |
|
12 |
* @param array $variables |
|
13 |
* An associative array containing: |
|
14 |
* - taxon: The taxon object displayed on the taxon page. |
|
15 |
* - mergedTrees |
|
16 |
* - media: |
|
17 |
* - hideImages: boolean, FALSE if images should be hided. |
|
18 |
* |
|
19 |
* @ingroup themeable |
|
20 |
*/ |
|
21 |
function garland_cichorieae_cdm_taxon_page_profile($variables) { |
|
22 |
$taxon = $variables['taxon']; |
|
23 |
$mergedTrees = $variables['mergedTrees']; |
|
24 |
$media = $variables['media']; |
|
25 |
$hideImages = $variables['hideImages']; |
|
26 |
|
|
27 |
$out = ''; |
|
28 |
global $base_url; |
|
29 |
|
|
30 |
RenderHints::pushToRenderStack('taxon_page_description'); |
|
31 |
// Description TOC. |
|
32 |
$out = theme('cdm_featureTreeTOCs', array('mergedTrees' => $mergedTrees)); |
|
33 |
|
|
34 |
// Preferred image. |
|
35 |
// 2 lines hard coded for testing. |
|
36 |
if (variable_get('cdm_dataportal_show_default_image', FALSE) && !$hideImages) { |
|
37 |
|
|
38 |
// $defaultPreferredImage = drupal_get_path('theme', |
|
39 |
// 'garland_cichorieae').'/images/nopic_400x300.jpg'; |
|
40 |
$defaultRepresentationPart = new stdClass(); |
|
41 |
$defaultRepresentationPart->width = 400; |
|
42 |
$defaultRepresentationPart->height = 300; |
|
43 |
$defaultRepresentationPart->uri = base_path() . drupal_get_path('theme', 'garland_cichorieae') . '/images/nopic_400x300_4x3cm.jpg'; |
|
44 |
|
|
45 |
$imageUriParams = '&width=400&height=300&quality=95&format=jpeg'; |
|
46 |
|
|
47 |
$imageMaxExtend = 400; |
|
48 |
$out .= '<div id="taxonProfileImage">' . theme('cdm_preferredImage', array( |
|
49 |
'media' => $media, |
|
50 |
'defaultRepresentationPart' => $defaultRepresentationPart, |
|
51 |
'imageMaxExtend' => $imageMaxExtend, |
|
52 |
'parameters' => $imageUriParams, |
|
53 |
)) . '</div>'; |
|
54 |
} |
|
55 |
|
|
56 |
// Description. |
|
57 |
$out .= theme('cdm_featureTrees', array( |
|
58 |
'mergedTrees' => $mergedTrees, |
|
59 |
'taxon' => $taxon, |
|
60 |
)); |
|
61 |
RenderHints::popFromRenderStack(); |
|
62 |
|
|
63 |
return $out; |
|
64 |
} |
|
65 |
|
|
66 | 7 |
/** |
67 | 8 |
* @todo Please document this function. |
68 | 9 |
* @see http://drupal.org/node/1354 |
7.x/themes/palmweb_2/template.php | ||
---|---|---|
4 | 4 |
* Overrides of generic themeing functions in cdm_dataportal.theme.php. |
5 | 5 |
*/ |
6 | 6 |
|
7 |
/** |
|
8 |
* Returns HTML for a cdm_taxon_page_profile. |
|
9 |
* |
|
10 |
* The description page is supposed to be the front page for a taxon. |
|
11 |
* |
|
12 |
* @param array $variables |
|
13 |
* An associative array containing: |
|
14 |
* - taxon: The taxon object displayed on the taxon page. |
|
15 |
* - mergedTrees |
|
16 |
* - media: |
|
17 |
* - hideImages: boolean, FALSE if images should be hided. |
|
18 |
* |
|
19 |
* @ingroup themeable |
|
20 |
*/ |
|
21 |
function palmweb_2_cdm_taxon_page_profile($variables){ |
|
22 |
|
|
23 |
$taxon = $variables['taxon']; |
|
24 |
$mergedTrees = $variables['mergedTrees']; |
|
25 |
$media = $variables['media']; |
|
26 |
$hideImages = $variables['hideImages']; |
|
27 |
|
|
28 |
$out = ''; |
|
29 |
|
|
30 |
if (!$hideImages) { |
|
31 |
// Preferred image. |
|
32 |
// Hardcoded for testing. |
|
33 |
$defaultRepresentationPart = new stdClass(); |
|
34 |
$defaultRepresentationPart->width = 184; |
|
35 |
$defaultRepresentationPart->height = 144; |
|
36 |
$defaultRepresentationPart->uri = base_path() .drupal_get_path('theme', 'palmweb_2') . '/images/no_picture.png'; |
|
37 |
|
|
38 |
// Preferred image size 184px × 144. |
|
39 |
$imageMaxExtend = 184; |
|
40 |
$out .= '<div id="taxonProfileImage">'; |
|
41 |
$out .= theme('cdm_preferredImage', array( |
|
42 |
'media' => $media, |
|
43 |
'defaultRepresentationPart' => $defaultRepresentationPart, |
|
44 |
'imageMaxExtend' => $imageMaxExtend, |
|
45 |
)); |
|
46 |
$out .= '</div>'; |
|
47 |
} |
|
48 |
|
|
49 |
// Description TOC. |
|
50 |
$out .= theme('cdm_featureTreeTOCs', array('mergedTrees' => $mergedTrees)); |
|
51 |
|
|
52 |
// Description. |
|
53 |
$out .= theme('cdm_featureTrees', array('mergedTrees' => $mergedTrees, 'taxon' => $taxon)); |
|
54 |
|
|
55 |
return $out; |
|
56 |
} |
|
57 |
|
|
58 | 7 |
/** |
59 | 8 |
* @todo Please document this function. |
60 | 9 |
* @see http://drupal.org/node/1354 |
Also available in: Unified diff
replacing theme_cdm_preferred_image() function by generic base functionality for all portals