Project

General

Profile

Download (3.91 KB) Statistics
| Branch: | Tag: | Revision:
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
/**
14
 *
15
 * @param $specimenTypeDesignation
16
 * @return unknown_type
17
 */
18
function theme_cdm_specimen($specimenTypeDesignation){
19

    
20
	// _add_js_thickbox();
21

    
22
	if($specimenTypeDesignation->typeSpecimen){
23
		$derivedUnitFacade = cdm_ws_get(CDM_WS_DERIVEDUNIT_FACADE, $specimenTypeDesignation->typeSpecimen->uuid);
24
	}
25

    
26
	$out = '';
27
	if(isset($specimenTypeDesignation->media[0])){
28

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

    
35
		$out .= '<div id="specimen_media_'.$specimenTypeDesignation->uuid.'" class="tickbox_content"><table>';
36

    
37
		$media_row = '<tr class="media_data">';
38
		$meta_row = '<tr class="meta_data">';
39

    
40
		foreach($specimenTypeDesignation->media as $media){
41
			foreach($media->representations as $representation){
42

    
43
				//TODO this this is PART 2/2 of a HACK - select preferred representation by mimetype and size
44
				//
45
				if(true || $representation->mimeType == 'image/jpeg'){
46
					foreach($representation->parts as $part){
47
						// get media uri conversion rules if the module is installed and activated
48
						if(module_exists('cdm_mediauri')){
49
							$muris = cdm_mediauri_conversion($part->uri);
50
						}
51
						// --- handle media preview rules
52
						if(isset($muris['preview'])){
53

    
54
							$a_child = '<img src="'.$muris['preview']['uri'].'" class="preview" '
55
							.($muris['preview']['size_x'] ? 'width="'.$muris['preview']['size_x'].'"' : '')
56
							.($muris['preview']['size_y'] ? 'width="'.$muris['preview']['size_y'].'"' : '')
57
							.'/>';
58
						} else {
59
							$a_child = '<img src="'.$part->uri.'" />';
60
						}
61

    
62
						// --- handle web application rules
63
						$webapp = '';
64
						if(isset($muris['webapp'])){
65
							if($muris['webapp']['embed_html']){
66
								// embed in same page
67
								$webapp = $muris['webapp']['embed_html'];
68
							} else {
69
								$webapp = l(t('web application'), $muris['webapp']['uri']);
70
							}
71
						}
72
						$media_row .= '<td><a href="'.$part->uri.'" target="'.$part->uuid.'">'.$a_child.'</a></td>';
73
						$meta_row .= '<td><span class="label">'.check_plain($specimenTypeDesignation->titleCache).'</span><div class="webapp">'.$webapp.'</div></td>';
74
					} // END parts
75
					//TODO this is PART 2/2 of a hack
76
					break;
77
				} // END representations
78
			} // END media
79
		}
80
		$out .= $media_row.'</tr>';
81
		$out .= $meta_row.'</tr>';
82

    
83
		$out .= '</div></table>';
84
	}
85
	return $out;
86
}
87

    
88
function theme_cdm_derivedUnitFacade($derivedUnitFacade){
89

    
90
	static $excludeFields = array('class', 'titleCache', 'derivedUnitMedia');
91

    
92
	if(is_object($derivedUnitFacade)){
93
		$out = '<dl>';
94
	  foreach (get_object_vars($derivedUnitFacade) as $field=>$value){
95
	  	if(!in_array($field, $excludeFields) && ($value && (!is_object($value) || isset($value->class) ))){
96
	  		switch($field){
97
	  			case 'locality': $stringValue = $value->language->representation_L10n; break;
98
	  			case 'country' : $stringValue = $value->representation_L10n; break;
99
	  			case 'collector':
100
	  			case 'collection' : $stringValue = $value->titleCache; break;
101
	  			case 'exactLocation': $stringValue = $value->sexagesimalString; break;
102
	  			default: $stringValue = $value;
103
	  		}
104
	  	  $out .= '<dt>' . t(ucfirst($field)) . ':</dt><dd>' . $stringValue . '</dd>';
105
	  	}
106
	  }
107
		$out .= '</dl>';
108
	}
109
	return $out;
110
}
(5-5/8)