Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

cdm-dataportal / modules / cdm_dataportal / theme / cdm_dataportal.occurrence.theme @ 806baeb2

History | View | Annotate | Download (2.71 KB)

1
<?php
2
// $Id$
3

    
4
/**
5
* Copyright (C) 2007 EDIT
6
* European Distributed Institute of Taxonomy 
7
* http://www.e-taxonomy.eu
8
* 
9
* The contents of this file are subject to the Mozilla Public License Version 1.1
10
* See http://www.mozilla.org/MPL/MPL-1.1.html for the full license terms.
11
*/
12

    
13
function theme_cdm_specimen($specimen){
14

    
15
	_add_js_thickbox();
16

    
17
	$out = '';
18
	if(isset($specimen->media[0])){
19

    
20
		$image_url = drupal_get_path('module', 'cdm_dataportal').'/images/external_link.gif';
21
		// thickbox has problems reading the first url parameter, so a litte hack is needed here:
22
		// adding a meaningless patameter &tb_hack=1& ....
23
		$out .= '&nbsp;<a href="#TB_inline?tb_hack=1&width=300&amp;height=330&amp;inlineId=specimen_media_'.$specimen->uuid.'" class="thickbox">'
24
		.'<img src="'.$image_url.'" title="'.t('Show media').'" /></a>';
25

    
26
		$out .= '<div id="specimen_media_'.$specimen->uuid.'" class="tickbox_content"><table>';
27

    
28
		$media_row = '<tr class="media_data">';
29
		$meta_row = '<tr class="meta_data">';
30

    
31
		foreach($specimen->media as $media){
32
			foreach($media->representations as $representation){
33

    
34
				//TODO this this is PART 2/2 of a HACK - select preferred representation by mimetype and size
35
				//
36
				if(true || $representation->mimeType == 'image/jpeg'){
37
					foreach($representation->parts as $part){
38
						// get media uri conversion rules if the module is installed and activated
39
						if(module_exists('cdm_mediauri')){
40
							$muris = cdm_mediauri_conversion($part->uri);
41
						}
42
						// --- handle media preview rules
43
						if(isset($muris['preview'])){
44

    
45
							$a_child = '<img src="'.$muris['preview']['uri'].'" class="preview" '
46
							.($muris['preview']['size_x'] ? 'width="'.$muris['preview']['size_x'].'"' : '')
47
							.($muris['preview']['size_y'] ? 'width="'.$muris['preview']['size_y'].'"' : '')
48
							.'/>';
49
						} else {
50
							$a_child = '<img src="'.$part->uri.'" />';
51
						}
52

    
53
						// --- handle web application rules
54
						$webapp = '';
55
						if(isset($muris['webapp'])){
56
							if($muris['webapp']['embed_html']){
57
								// embed in same page
58
								$webapp = $muris['webapp']['embed_html'];
59
							} else {
60
								$webapp = l(t('web application'), $muris['webapp']['uri']);
61
							}
62
						}
63
						$media_row .= '<td><a href="'.$part->uri.'" target="'.$part->uuid.'">'.$a_child.'</a></td>';
64
						$meta_row .= '<td><span class="label">'.check_plain($specimen->titleCache).'</span><div class="webapp">'.$webapp.'</div></td>';
65
					} // END parts
66
					//TODO this is PART 2/2 of a hack
67
					break;
68
				} // END representations
69
			} // END media
70
		}
71
		$out .= $media_row.'</tr>';
72
		$out .= $meta_row.'</tr>';
73

    
74
		$out .= '</div></table>';
75
	}
76
	return $out;
77
}
Add picture from clipboard (Maximum size: 40 MB)