Revision d74aa4df
Added by Andreas Kohlbecker over 13 years ago
modules/cdm_dataportal/theme/cdm_dataportal.media.theme | ||
---|---|---|
3 | 3 |
|
4 | 4 |
/** |
5 | 5 |
* Copyright (C) 2007 EDIT |
6 |
* European Distributed Institute of Taxonomy
|
|
6 |
* European Distributed Institute of Taxonomy |
|
7 | 7 |
* http://www.e-taxonomy.eu |
8 |
*
|
|
8 |
* |
|
9 | 9 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
10 | 10 |
* See http://www.mozilla.org/MPL/MPL-1.1.html for the full license terms. |
11 | 11 |
*/ |
... | ... | |
77 | 77 |
|
78 | 78 |
} |
79 | 79 |
|
80 |
function theme_cdm_mediaTypeTerm($feature){ |
|
81 |
$icon_url = drupal_get_path('module', 'cdm_dataportal').'/images/'.$feature->representation_L10n.'-media.png'; |
|
80 |
function theme_cdm_mediaTypeTerm($feature, $mediaUrl = false){ |
|
81 |
$provider = ''; |
|
82 |
if(strpos($mediaUrl, 'www.biodiversitylibrary.org') > 0){ |
|
83 |
$provider = '-BHL'; |
|
84 |
} |
|
85 |
$icon_image = $feature->representation_L10n.'-media'.$provider.'.png'; |
|
86 |
$icon_url = drupal_get_path('module', 'cdm_dataportal').'/images/'.$icon_image; |
|
82 | 87 |
return '<img src="'.$icon_url.'" height="14px" alt="'.$feature->representation_L10n.'" />'; |
83 | 88 |
} |
84 | 89 |
|
... | ... | |
88 | 93 |
$attributes = array('title'=> theme('cdm_feature_name', $feature->representation_L10n), 'target'=>'_blank'); |
89 | 94 |
//$attributes = array('title'=>$feature->representation_L10n, 'target'=>'_blank'); |
90 | 95 |
//$attributes = array('title'=>'original publication', 'target'=>'_blank'); |
91 |
$out .= l(theme('cdm_mediaTypeTerm', $feature), $part->uri, $attributes, NULL, NULL, TRUE, TRUE); |
|
96 |
$out .= l(theme('cdm_mediaTypeTerm', $feature, $part->uri), $part->uri, $attributes, NULL, NULL, TRUE, TRUE);
|
|
92 | 97 |
} |
93 | 98 |
return $out; |
94 | 99 |
} |
... | ... | |
99 | 104 |
$attributes = array('class'=>'thickbox', 'rel'=>'representation-'.$representation->uuid, 'title'=>$feature->representation_L10n); |
100 | 105 |
for($i = 0; $part = $representation->representationParts[$i]; $i++){ |
101 | 106 |
if($i == 0){ |
102 |
|
|
103 |
$out .= l(theme('cdm_mediaTypeTerm', $feature), $part->uri, $attributes, NULL, NULL, TRUE, TRUE); |
|
107 |
$out .= l(theme('cdm_mediaTypeTerm', $feature, $part->uri), $part->uri, $attributes, NULL, NULL, TRUE, TRUE); |
|
104 | 108 |
} else { |
105 | 109 |
$out .= l('', $part->uri, $attributes, NULL, NULL, TRUE); |
106 | 110 |
} |
... | ... | |
113 | 117 |
foreach($representation->parts as $part){ |
114 | 118 |
$attributes = array('title'=> theme('cdm_feature_name', $feature->representation_L10n), 'target'=>'_blank'); |
115 | 119 |
//$attributes = array('title'=>t('original publication'), 'target'=>'_blank'); |
116 |
$out .= l(theme('cdm_mediaTypeTerm', $feature), $part->uri, $attributes, NULL, NULL, TRUE, TRUE); |
|
120 |
$out .= l(theme('cdm_mediaTypeTerm', $feature, $part->uri), $part->uri, $attributes, NULL, NULL, TRUE, TRUE);
|
|
117 | 121 |
} |
118 | 122 |
return $out; |
119 | 123 |
} |
... | ... | |
214 | 218 |
* @param $galleryLinkUri an URI to link the the hint on more images to; if null no link is created |
215 | 219 |
* @return unknown_type |
216 | 220 |
*/ |
217 |
function theme_cdm_media_gallerie($mediaList, $galleryName, $maxExtend = 150, $cols = 4, $maxRows = false, $captionElements = array('title'), |
|
218 |
$mediaLinkType = 'LIGHTBOX', $alternativeMediaUri = null, $galleryLinkUri = null ){ |
|
219 |
|
|
221 |
function theme_cdm_media_gallerie($mediaList, $galleryName, |
|
222 |
$maxExtend = 150, $cols = 4, $maxRows = false, $captionElements = array('title'), |
|
223 |
$mediaLinkType = 'LIGHTBOX', $alternativeMediaUri = null, $galleryLinkUri = null ){ |
|
224 |
|
|
220 | 225 |
if(!is_array($captionElements)){ |
221 | 226 |
$captionElements = array(); |
222 | 227 |
} |
... | ... | |
228 | 233 |
} |
229 | 234 |
|
230 | 235 |
$galleryID = "media_gallery_".$galleryName; |
236 |
$mediaPartLinkAttributes = array(); |
|
237 |
$openMediaLinkAttributes = array(); |
|
231 | 238 |
|
232 | 239 |
// prepare media links |
233 | 240 |
$doLink = false; |
234 |
$linkAttributes = null; |
|
235 | 241 |
if($mediaLinkType != 'NONE'){ |
236 | 242 |
$doLink = true; |
237 | 243 |
} |
238 | 244 |
if($mediaLinkType == 'LIGHTBOX'){ |
239 | 245 |
$doLink = true; |
240 |
//_add_js_thickbox(); |
|
241 |
//$linkAttributes = array("class"=>"thickbox", "rel"=>"media_gallerie".$galleryName); |
|
242 | 246 |
_add_js_lightbox($galleryID); |
243 |
$linkAttributes = array("class"=>"lightbox"); |
|
244 | 247 |
} |
245 | 248 |
|
246 | 249 |
// render the media gallery grid |
... | ... | |
258 | 261 |
for($c = 0; $c < $cols; $c++){ |
259 | 262 |
$media = array_shift($mediaList); |
260 | 263 |
if(isset($media->representations[0]->parts[0])){ |
261 |
$contentTypeDirectory = media_content_type_dir($media->representations[0], 'image'); |
|
262 |
$mediaIndex++; |
|
263 |
$mediaPartHtml = theme('cdm_media_gallerie_'.$contentTypeDirectory, $media->representations[0]->parts[0], $maxExtend, TRUE); |
|
264 | 264 |
|
265 |
// |
|
266 |
// find preferred representation |
|
267 |
// |
|
268 |
$preferred_media_representations_list = cdm_preferred_media_representations( |
|
269 |
$media, |
|
270 |
array('image/jpg', 'image/jpeg', 'image/png', 'image/gif'), |
|
271 |
$maxExtend, $maxExtend); |
|
272 |
if(count($preferred_media_representations_list) == 0){ |
|
273 |
// fallback to using the first one in the list |
|
274 |
$preferred_media_representations_list = $media->representations; |
|
275 |
} |
|
276 |
$preferred_media_representation = array_shift($preferred_media_representations_list); |
|
277 |
|
|
278 |
// $preferred_media_representation->parts[0]->uri = "http://127.0.0.1/images/palmae/palm_tc_14415_1.jpg"; |
|
279 |
$contentTypeDirectory = media_content_type_dir($preferred_media_representation, 'application'); |
|
280 |
$mediaIndex++; |
|
281 |
$mediaPartHtml = theme('cdm_media_gallerie_'.$contentTypeDirectory, $preferred_media_representation->parts[0], $maxExtend, TRUE); |
|
265 | 282 |
// --- compose Media Link |
266 | 283 |
$mediaLinkUri = false; |
267 | 284 |
if($alternativeMediaUri){ |
... | ... | |
272 | 289 |
$mediaLinkUri = $alternativeMediaUri; |
273 | 290 |
} |
274 | 291 |
} else { |
275 |
$mediaLinkUri = $media->representations[0]->parts[0]->uri;
|
|
292 |
$mediaLinkUri = $preferred_media_representation->parts[0]->uri;
|
|
276 | 293 |
} |
277 | 294 |
|
278 |
// generate gallery caption |
|
279 | 295 |
_add_js_ahah(); |
280 | 296 |
$content_url = cdm_compose_url(CDM_WS_PORTAL_MEDIA, $media->uuid); |
281 |
$cdm_proxy_url = url('cdm_api/proxy/'.urlencode($content_url)."/cdm_media_caption/".join(',',$captionElements));
|
|
297 |
$cdm_proxy_url = url('cdm_api/proxy/'.urlencode($content_url)."/cdm_media_caption/".serialize($captionElements));
|
|
282 | 298 |
$captionPartHtml = '<div class="ahah-content" rel="'.$cdm_proxy_url.'"><span class="loading" style="display: none;">Loading ....</span></div>'; |
283 | 299 |
|
300 |
// generate gallery caption |
|
301 |
if($mediaLinkType == 'LIGHTBOX' && $contentTypeDirectory == 'image'){ |
|
302 |
$mediaPartLinkAttributes['class'] = "lightbox"; |
|
303 |
} else { |
|
304 |
$mediaPartLinkAttributes['target'] = "specimen"; |
|
305 |
$openMediaLinkAttributes['target'] = "specimen"; |
|
306 |
} |
|
284 | 307 |
// generate & add caption to lightbox |
285 | 308 |
$lightBoxCaptionElements = null; |
286 | 309 |
$cdm_proxy_url = url('cdm_api/proxy/'.urlencode($content_url)."/cdm_media_caption"); //.($lightBoxCaptionElements?'/'.join (',',$lightBoxCaptionElements):'')); |
287 |
$linkAttributes['alt'] = '<div class="ahah-content" rel="'.$cdm_proxy_url.'"><span class="loading" style="display: none;">Loading ....</span></div>';
|
|
310 |
$mediaPartLinkAttributes['alt'] = '<div class="ahah-content" rel="'.$cdm_proxy_url.'"><span class="loading" style="display: none;">Loading ....</span></div>';
|
|
288 | 311 |
|
289 | 312 |
if(isset($captionElements['#uri'])){ |
290 |
$captionPartHtml .= '<div>'.l($captionElements['#uri'], path_to_media($media->uuid), null, null, null, FALSE, TRUE).'</div>'; |
|
313 |
if($contentTypeDirectory == 'image'){ |
|
314 |
$captionPartHtml .= '<div>'.l($captionElements['#uri'], path_to_media($media->uuid), null, null, null, FALSE, TRUE).'</div>'; |
|
315 |
} else { |
|
316 |
$captionPartHtml .= '<div>'.l($captionElements['#uri'], $mediaLinkUri, $openMediaLinkAttributes, null, null, TRUE, TRUE).'</div>'; |
|
317 |
} |
|
291 | 318 |
} |
292 | 319 |
$captionParts[] = $captionPartHtml; |
293 | 320 |
|
294 | 321 |
// --- surround imagePart with link |
295 | 322 |
if($doLink){ |
296 |
$mediaPartHtml = l($mediaPartHtml, $mediaLinkUri, $linkAttributes, null, null, FALSE, TRUE);
|
|
323 |
$mediaPartHtml = l($mediaPartHtml, $mediaLinkUri, $mediaPartLinkAttributes, null, null, FALSE, TRUE);
|
|
297 | 324 |
} |
298 | 325 |
|
299 | 326 |
} else { |
... | ... | |
303 | 330 |
$out .= '<td>'.$mediaPartHtml.'</td>'; |
304 | 331 |
} |
305 | 332 |
$out .= '</tr>'; // end of media parts |
306 |
if(isset($captionElements[0])){
|
|
333 |
if(count($captionElements) > 0){
|
|
307 | 334 |
$out .= '<tr>'; |
308 | 335 |
// add caption row |
309 | 336 |
foreach($captionParts as $captionPartHtml){ |
... | ... | |
329 | 356 |
//TODO merge with theme_cdm_media_mime_image? |
330 | 357 |
|
331 | 358 |
if(isset($mediaRepresentationPart)){ |
332 |
|
|
359 |
|
|
333 | 360 |
$h = $mediaRepresentationPart->height; |
334 | 361 |
$w = $mediaRepresentationPart->width; |
335 | 362 |
if($w == 0 || $h == 0){ |
... | ... | |
381 | 408 |
|
382 | 409 |
} |
383 | 410 |
|
411 |
function theme_cdm_media_gallerie_application($mediaRepresentationPart, $maxExtend, $addPassePartout = FALSE, $attributes = null){ |
|
412 |
|
|
413 |
if(isset($mediaRepresentationPart)){ |
|
414 |
|
|
415 |
if($addPassePartout){ |
|
416 |
$out .= '<div class="image-passe-partout" style="width:'.$maxExtend.'px; height:'.$maxExtend.'px;">'; |
|
417 |
} else { |
|
418 |
// do not add margins if no pass partout is shown |
|
419 |
$margins = ''; |
|
420 |
} |
|
421 |
$out .= '<div class="appication">Web Application</div>'; |
|
422 |
|
|
423 |
if($addPassePartout){ |
|
424 |
$out .= '</div>'; |
|
425 |
} |
|
426 |
return $out; |
|
427 |
} |
|
428 |
|
|
429 |
} |
|
430 |
|
|
431 |
function theme_cdm_media_gallerie_text($mediaRepresentationPart, $maxExtend, $addPassePartout = FALSE, $attributes = null){ |
|
432 |
|
|
433 |
if(isset($mediaRepresentationPart)){ |
|
434 |
|
|
435 |
if($addPassePartout){ |
|
436 |
$out .= '<div class="image-passe-partout" style="width:'.$maxExtend.'px; height:'.$maxExtend.'px;">'; |
|
437 |
} else { |
|
438 |
// do not add margins if no pass partout is shown |
|
439 |
$margins = ''; |
|
440 |
} |
|
441 |
$out .= '<div class="appication">Web Application</div>'; |
|
442 |
|
|
443 |
if($addPassePartout){ |
|
444 |
$out .= '</div>'; |
|
445 |
} |
|
446 |
return $out; |
|
447 |
} |
|
448 |
|
|
449 |
} |
|
450 |
|
|
384 | 451 |
function theme_cdm_openlayers_image($mediaRepresentationPart, $maxExtend){ |
385 | 452 |
|
386 | 453 |
// see http://trac.openlayers.org/wiki/UsingCustomTiles#UsingTilesWithoutaProjection |
387 | 454 |
// and http://trac.openlayers.org/wiki/SettingZoomLevels |
388 |
|
|
455 |
|
|
389 | 456 |
drupal_add_js(drupal_get_path('module', 'cdm_dataportal').'/js/OpenLayers/OpenLayers.js', 'core', 'header'); |
390 |
|
|
457 |
|
|
391 | 458 |
//TODO megre code below with code from theme_cdm_media_gallerie_image |
392 | 459 |
//var_dump("MEDIA URI: " . $mediaRepresentationPart->uri); |
393 | 460 |
//TODO merge code below with code from theme_cdm_media_gallerie_image |
... | ... | |
424 | 491 |
maxExtent: new OpenLayers.Bounds(0, 0, '.$w.', '.$h.') |
425 | 492 |
}; |
426 | 493 |
var mapOptions={ |
427 |
controls:
|
|
428 |
[
|
|
494 |
controls: |
|
495 |
[ |
|
429 | 496 |
new OpenLayers.Control.PanZoom(), |
430 | 497 |
new OpenLayers.Control.Navigation({zoomWheelEnabled: false, handleRightClicks:true, zoomBoxKeyMask: OpenLayers.Handler.MOD_CTRL}) |
431 | 498 |
], |
432 | 499 |
restrictedExtent: new OpenLayers.Bounds(0, 0, '.$w.', '.$h.') |
433 | 500 |
}; |
434 |
|
|
501 |
|
|
435 | 502 |
var graphic = new OpenLayers.Layer.Image( |
436 | 503 |
\'Image Title\', |
437 | 504 |
\''.$mediaRepresentationPart->uri.'\', |
... | ... | |
439 | 506 |
new OpenLayers.Size('.$w.', '.$h.'), |
440 | 507 |
imageLayerOptions |
441 | 508 |
); |
442 |
|
|
509 |
|
|
443 | 510 |
function init() { |
444 | 511 |
map = new OpenLayers.Map(\'openlayers_image\', mapOptions); |
445 | 512 |
map.addLayers([graphic]); |
446 | 513 |
map.setCenter(new OpenLayers.LonLat(0, 0), 1); |
447 | 514 |
map.zoomToMaxExtent(); |
448 | 515 |
} |
449 |
|
|
516 |
|
|
450 | 517 |
$(document).ready(function(){ |
451 | 518 |
init(); |
452 | 519 |
|
Also available in: Unified diff
fixes and modifications for TDWG 2010