Revision 7a2a14b3
Added by Andreas Kohlbecker over 9 years ago
7.x/modules/cdm_dataportal/theme/cdm_dataportal.media.theme | ||
---|---|---|
205 | 205 |
return $out; |
206 | 206 |
} |
207 | 207 |
|
208 |
|
|
208 | 209 |
/** |
209 |
* @todo Please document this function. |
|
210 |
* @see http://drupal.org/node/1354 |
|
210 |
* Theme function for captions of media elements. This method is usually called from |
|
211 |
* within the theme_cdm_media_gallerie() function or indirectly via AHAH. |
|
212 |
* |
|
213 |
* @param array $variables |
|
214 |
* an associative array with the following elements: |
|
215 |
* - 'media': the cdm media object to show the captions for |
|
216 |
* - 'elements': |
|
217 |
* an array which defining the caption elements to show up |
|
218 |
* example: |
|
219 |
* Show 'title', 'description', 'file', 'filename' in the caption: |
|
220 |
* array('title', 'description', 'file', 'filename') |
|
221 |
* |
|
222 |
* @return string |
|
223 |
* the themed html output |
|
211 | 224 |
*/ |
212 | 225 |
function theme_cdm_media_caption($variables) { |
213 | 226 |
$media = $variables['media']; |
214 | 227 |
$elements = $variables['elements']; |
215 |
$fileUri = $variables['fileUri']; |
|
216 | 228 |
$media_metadata = cdm_read_media_metadata($media); |
217 | 229 |
|
218 | 230 |
$doTitle = !$elements || array_search('title', $elements) !== FALSE; |
... | ... | |
313 | 325 |
* - maxExtend |
314 | 326 |
* - cols |
315 | 327 |
* - maxRows |
316 |
* - captionElements: An array, possible values are like in the following |
|
317 |
* example: |
|
318 |
* array('title', 'description', 'file', 'filename'), |
|
319 |
* //to add a link to the caption: |
|
320 |
* array('titlecache', '#uri'=>t('open Image')); |
|
328 |
* - showCaption: boolean value, whether to show captions or not. |
|
329 |
* - captionElements: An array of caption elements to be shown. In case the array |
|
330 |
* is empty of NULL all available caption elements will be show. In order to |
|
331 |
* supress all captions set 'showCaption' to FALSE |
|
332 |
* example: |
|
333 |
* 1) Show 'title', 'description', 'file', 'filename' in the caption: |
|
334 |
* array('title', 'description', 'file', 'filename'), |
|
335 |
* 2) To add an addtional link at the bottom of the caption: |
|
336 |
* array('titlecache', '#uri'=>t('open Image')) this will cause a link |
|
337 |
* to be rendered with label 'open Image' which will open the accoring |
|
338 |
* media object. |
|
321 | 339 |
* - mediaLinkType: Valid values: |
322 | 340 |
* - "NONE": do not link the images, |
323 | 341 |
* - "LIGHTBOX": open the link in a light box, |
... | ... | |
350 | 368 |
$alternativeMediaUri = $variables['alternativeMediaUri']; |
351 | 369 |
$galleryLinkUri = $variables['galleryLinkUri']; |
352 | 370 |
$showCaption = $variables['showCaption']; |
353 |
if (!is_array($captionElements)) { |
|
354 |
$captionElements = array(); |
|
371 |
|
|
372 |
$caption_link_uri = ''; |
|
373 |
if(isset($captionElements['#uri'])){ |
|
374 |
$caption_link_uri = $captionElements['#uri']; |
|
375 |
unset($captionElements['#uri']); |
|
376 |
} |
|
377 |
if (!is_array($captionElements) || count($captionElements) == 0) { |
|
378 |
$captionElements = NULL; |
|
355 | 379 |
} |
356 | 380 |
|
357 | 381 |
// TODO correctly handle multiple media representation parts |
358 |
// Comment @WA: this does not work when clean_urls is enabled.. |
|
359 |
// $_SESSION['cdm']['last_gallery'] = substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], "?q=") + 3); |
|
360 |
// ..this works. |
|
361 | 382 |
$_SESSION['cdm']['last_gallery'] = current_path(); |
362 | 383 |
// Prevent from errors. |
363 | 384 |
if (!isset($mediaList[0])) { |
... | ... | |
448 | 469 |
$mediaLinkUri = $preferred_media_representation->parts[0]->uri; |
449 | 470 |
} |
450 | 471 |
|
472 |
// media captions will be loaded via AHAH |
|
451 | 473 |
_add_js_ahah(); |
452 | 474 |
$content_url = cdm_compose_url(CDM_WS_PORTAL_MEDIA, $media->uuid); |
475 |
$cdm_proxy_url_caption = url('cdm_api/proxy/' . urlencode($content_url) . "/cdm_media_caption/" . serialize($captionElements)); |
|
453 | 476 |
|
454 |
$cdm_proxy_url = url('cdm_api/proxy/' . urlencode($content_url) . "/cdm_media_caption/" . serialize($captionElements)); |
|
455 |
$captionPartHtml = '<div class="ahah-content" rel="' . $cdm_proxy_url . '"><span class="loading" style="display: none;">Loading ....</span></div>'; |
|
456 | 477 |
|
457 |
// Generate gallery caption. |
|
478 |
// preparing the part link (= click on image iteself) which can be handled in two ways |
|
479 |
// |
|
480 |
// 1. open image in lightbox, the captions in the lighhtbox will be loaded via AHAH |
|
481 |
// 2. open the media in a new window with target 'specimen' |
|
458 | 482 |
if ($mediaLinkType == 'LIGHTBOX' && $contentTypeDirectory == 'image') { |
459 | 483 |
$mediaPartLinkAttributes['class'] = array('lightbox'); |
460 | 484 |
} |
... | ... | |
462 | 486 |
$mediaPartLinkAttributes['target'] = "specimen"; |
463 | 487 |
$openMediaLinkAttributes['target'] = "specimen"; |
464 | 488 |
} |
465 |
// Generate & add caption to lightbox. |
|
466 |
$lightBoxCaptionElements = NULL; |
|
467 |
// .($lightBoxCaptionElements?'/'.join(',',$lightBoxCaptionElements):'')); |
|
468 |
$cdm_proxy_url = url('cdm_api/proxy/' . urlencode($content_url) . "/cdm_media_caption"); |
|
489 |
$mediaPartLinkAttributes['alt'] = '<div class="ahah-content" rel="' . $cdm_proxy_url_caption . '">' |
|
490 |
. '<span class="loading" style="display: none;">Loading ....</span></div>'; |
|
469 | 491 |
|
470 |
$mediaPartLinkAttributes['alt'] = '<div class="ahah-content" rel="' . $cdm_proxy_url . '"><span class="loading" style="display: none;">Loading ....</span></div>'; |
|
471 | 492 |
|
472 |
if (isset($captionElements['#uri'])) { |
|
493 |
// preparing the media caption - no caption elements to show up here except the $caption_link_uri, if at all |
|
494 |
// |
|
495 |
$captionPartHtml = ''; |
|
496 |
if ($caption_link_uri) { |
|
473 | 497 |
if ($contentTypeDirectory == 'image') { |
474 |
$captionPartHtml .= '<div class="media-caption-link">' . l($captionElements['#uri'], path_to_media($media->uuid), array( |
|
498 |
// it is an image, so open it in the media page |
|
499 |
$captionPartHtml .= '<div class="media-caption-link">' . l($caption_link_uri, path_to_media($media->uuid), array( |
|
475 | 500 |
'attributes' => array(), 'html' => TRUE, |
476 | 501 |
)) . '</div>'; |
477 | 502 |
} |
478 | 503 |
else { |
504 |
// otherwise open it directly and let the the browser handle the media type |
|
479 | 505 |
$openMediaLinkAttributes['absolute'] = TRUE; |
480 |
$captionPartHtml .= '<div class="media-caption-link">' . l($captionElements['#uri'], $mediaLinkUri, array(
|
|
506 |
$captionPartHtml .= '<div class="media-caption-link">' . l($caption_link_uri, $mediaLinkUri, array(
|
|
481 | 507 |
'attributes' => $openMediaLinkAttributes, 'html' => TRUE, |
482 | 508 |
)) . '</div>'; |
483 | 509 |
} |
484 | 510 |
} |
511 |
|
|
485 | 512 |
$captionParts[] = $captionPartHtml; |
486 | 513 |
|
487 |
// --- Surround imagePart with link. |
|
514 |
// --- Surround imagePart with link, this .
|
|
488 | 515 |
if ($doLink) { |
489 | 516 |
$mediaPartHtml = l($mediaPartHtml, $mediaLinkUri, array( |
490 | 517 |
'attributes' => $mediaPartLinkAttributes, 'html' => TRUE, |
... | ... | |
499 | 526 |
} |
500 | 527 |
$out .= '</tr>'; // End of media parts. |
501 | 528 |
if ($showCaption) { |
502 |
if (count($captionElements) > 0) {
|
|
529 |
if ( (is_array($captionElements) && count($captionElements) > 0) || $caption_link_uri) {
|
|
503 | 530 |
$out .= '<tr>'; |
504 | 531 |
// Add caption row. |
505 | 532 |
foreach ($captionParts as $captionPartHtml) { |
Also available in: Unified diff
fixing #3217 (specimens: rename label type into 'Basis of record') and solving a lot of problems like recursive page loading du to a bug in ahah-content.js and type in cdm service call, ...