Project

General

Profile

« Previous | Next » 

Revision 6eaec849

Added by Katja Luther almost 5 years ago

implement blast search table for the result

View differences:

modules/cdm_dataportal/includes/media.inc
353 353
      $complete_media = cdm_ws_get(CDM_WS_MEDIA, $media->uuid);
354 354
      if (isset($complete_media->representations[0]->parts[0])) {
355 355

  
356
        //
357
        // Find preferred representation.
358
        //
359

  
360
        $thumbnail_representations = cdm_preferred_media_representations($complete_media, array(
361
            'image/jpg',
362
            'image/jpeg',
363
            'image/png',
364
            'image/gif',
356
          //
357
          // Find preferred representation.
358
          //
359

  
360
          $thumbnail_representations = cdm_preferred_media_representations($complete_media, array(
361
              'image/jpg',
362
              'image/jpeg',
363
              'image/png',
364
              'image/gif',
365 365
          ),
366
          $maxExtend,
367
          $maxExtend
368
        );
369
        // due to a bug the portal/taxon/{uuid}/media service only delivers a filtered media object
370
        // which only contains the thumbnail representation even if the height and width filters are not set.
371
        // --> #6970
372
        // to get hold of the full resolution images we send a separate request :
373
       // $complete_media = cdm_ws_get(CDM_WS_MEDIA, $media->uuid);
374
        $full_size_representations = cdm_preferred_media_representations($complete_media, array(
375
            'image/jpg',
376
            'image/jpeg',
377
            'image/png',
378
            'image/gif',
379
          )
380
        );
381
        if (count($thumbnail_representations) == 0) {
382
          // Fallback to using the first one in the list.
383
          $thumbnail_representations = $media->representations;
384
          $full_size_representations = $media->representations;
385
        }
386
        $thumbnail_representation = array_shift($thumbnail_representations);
387
        $full_size_representation = array_shift($full_size_representations);
388

  
389
        // $preferred_media_representation->parts[0]->uri =
390
        // "http://127.0.0.1/images/palmae/palm_tc_14415_1.jpg";
391
        $contentTypeDirectory = media_content_type_dir($thumbnail_representation, 'application');
392

  
393
        $mediaPartHtml = call_user_func_array(
394
          'cdm_media_gallerie_' . $contentTypeDirectory,
395
          array( $thumbnail_representation->parts[0], $maxExtend, TRUE)
396
        );
397
        // --- Compose Media Link.
398
        $mediaLinkUri = FALSE;
399
        if ($alternativeMediaUri) {
400
          if (isset($alternativeMediaUri[$mediaIndex])) {
401
            $mediaLinkUri = $alternativeMediaUri[$mediaIndex];
366
              $maxExtend,
367
              $maxExtend
368
          );
369
          // due to a bug the portal/taxon/{uuid}/media service only delivers a filtered media object
370
          // which only contains the thumbnail representation even if the height and width filters are not set.
371
          // --> #6970
372
          // to get hold of the full resolution images we send a separate request :
373
          // $complete_media = cdm_ws_get(CDM_WS_MEDIA, $media->uuid);
374
          $full_size_representations = cdm_preferred_media_representations($complete_media, array(
375
                  'image/jpg',
376
                  'image/jpeg',
377
                  'image/png',
378
                  'image/gif',
379
              )
380
          );
381
          if (count($thumbnail_representations) == 0) {
382
              // Fallback to using the first one in the list.
383
              $thumbnail_representations = $media->representations;
384
              $full_size_representations = $media->representations;
402 385
          }
403
          if (is_string($alternativeMediaUri)) {
404
            $mediaLinkUri = $alternativeMediaUri;
386
          $thumbnail_representation = array_shift($thumbnail_representations);
387
          $full_size_representation = array_shift($full_size_representations);
388

  
389
          // $preferred_media_representation->parts[0]->uri =
390
          // "http://127.0.0.1/images/palmae/palm_tc_14415_1.jpg";
391
          $contentTypeDirectory = media_content_type_dir($thumbnail_representation, 'application');
392

  
393
          $mediaPartHtml = call_user_func_array(
394
              'cdm_media_gallerie_' . $contentTypeDirectory,
395
              array($thumbnail_representation->parts[0], $maxExtend, TRUE)
396
          );
397
          // --- Compose Media Link.
398
          $mediaLinkUri = FALSE;
399
          if ($alternativeMediaUri) {
400
              if (isset($alternativeMediaUri[$mediaIndex])) {
401
                  $mediaLinkUri = $alternativeMediaUri[$mediaIndex];
402
              }
403
              if (is_string($alternativeMediaUri)) {
404
                  $mediaLinkUri = $alternativeMediaUri;
405
              }
406
          } else {
407
              $mediaLinkUri = $full_size_representation->parts[0]->uri;
405 408
          }
406
        }
407
        else {
408
          $mediaLinkUri = $full_size_representation->parts[0]->uri;
409
        }
410
        $mediaIndex++;
411

  
412
        // media captions will be loaded via AHAH
413
        _add_js_ahah();
414
        $content_url = cdm_compose_url(CDM_WS_PORTAL_MEDIA, $media->uuid);
415
        $cdm_proxy_url_caption = url('cdm_api/proxy/' . urlencode($content_url) . "/cdm_media_caption/" . serialize($captionElements));
416
        $ahah_media_caption =  '<div class="ahah-content" data-cdm-ahah-url="' . $cdm_proxy_url_caption . '">'
417
          . '<span class="loading" style="display: none;">' . loading_image_html() . '</span></div>';
418

  
419
        // preparing the part link (= click on image itself) which can be handled in two ways
420
        //
421
        //  1. open image in lightbox, the captions in the lightbox will be loaded via AHAH
422
        //  2. open the media in a new window with target 'specimen'
423
        if ($mediaLinkType == 'LIGHTBOX' && $contentTypeDirectory == 'image') {
424
          $mediaPartLinkAttributes['class'] = array('lightbox');
425
        } else {
426
          $mediaPartLinkAttributes['target'] = "specimen";
427
          $openMediaLinkAttributes['target'] = "specimen";
428
        }
429
        $mediaPartLinkAttributes['alt'] = htmlentities($ahah_media_caption);
430

  
431
        // --- preparing the media caption
432

  
433
        /* old comment: "no caption elements to show up here except the $caption_link_uri, if at all"
434
         *
435
         * a.kohlbecker 2013-03-14 :
436
         *   It is unclear why no caption elements should be shown, Was it a technical reason?
437
         *   see commit r16723 740177eb-a1d8-4ec3-a630-accd905eb3da
438
         *   If not problems arise with this remove it after some weeks
439
         */
440
        $captionPartHtml = $ahah_media_caption;
441

  
442
        if ($caption_link_uri) {
443
          if ($contentTypeDirectory == 'image') {
444
            // it is an image, so open it in the media page
445
            $captionPartHtml .= '<div class="media-caption-link">' . l($caption_link_uri, path_to_media($media->uuid), array(
446
                'attributes' => array(), 'html' => TRUE,
447
              )) . '</div>';
409
          $mediaIndex++;
410

  
411
          // media captions will be loaded via AHAH
412
          _add_js_ahah();
413
          $content_url = cdm_compose_url(CDM_WS_PORTAL_MEDIA, $media->uuid);
414
          //if $captionElements == null, set $captionPartHtml = '' otherwise the loading image is shown but nothing is loaded.
415
          if ($captionElements) {
416

  
417
              $cdm_proxy_url_caption = url('cdm_api/proxy/' . urlencode($content_url) . "/cdm_media_caption/" . serialize($captionElements));
418
              $ahah_media_caption = '<div class="ahah-content" data-cdm-ahah-url="' . $cdm_proxy_url_caption . '">'
419
                  . '<span class="loading" style="display: none;">' . loading_image_html() . '</span></div>';
420

  
421
            // preparing the part link (= click on image itself) which can be handled in two ways
422
            //
423
            //  1. open image in lightbox, the captions in the lightbox will be loaded via AHAH
424
            //  2. open the media in a new window with target 'specimen'
425
            if ($mediaLinkType == 'LIGHTBOX' && $contentTypeDirectory == 'image') {
426
              $mediaPartLinkAttributes['class'] = array('lightbox');
427
            } else {
428
              $mediaPartLinkAttributes['target'] = "specimen";
429
              $openMediaLinkAttributes['target'] = "specimen";
430
            }
431
            $mediaPartLinkAttributes['alt'] = htmlentities($ahah_media_caption);
432

  
433
            // --- preparing the media caption
434

  
435
            /* old comment: "no caption elements to show up here except the $caption_link_uri, if at all"
436
             *
437
             * a.kohlbecker 2013-03-14 :
438
             *   It is unclear why no caption elements should be shown, Was it a technical reason?
439
             *   see commit r16723 740177eb-a1d8-4ec3-a630-accd905eb3da
440
             *   If not problems arise with this remove it after some weeks
441
             */
442
            $captionPartHtml = $ahah_media_caption;
443
          }else{
444
              $captionPartHtml = '';
448 445
          }
449
          else {
450
            // otherwise open it directly and let the the browser handle the media type
451
            $openMediaLinkAttributes['absolute'] = TRUE;
452
            $captionPartHtml .= '<div class="media-caption-link">' . l($caption_link_uri, $mediaLinkUri, array(
453
                'attributes' => $openMediaLinkAttributes, 'html' => TRUE,
454
              )) . '</div>';
446
          if ($caption_link_uri) {
447
              if ($contentTypeDirectory == 'image') {
448
                // it is an image, so open it in the media page
449

  
450
                $captionPartHtml .= '<div class="media-caption-link">' . l($caption_link_uri, path_to_media($media->uuid), array(
451
                    'attributes' => array(), 'html' => TRUE,
452
                        )) . '</div>';
453

  
454

  
455
              }
456
              else {
457
                // otherwise open it directly and let the the browser handle the media type
458
                $openMediaLinkAttributes['absolute'] = TRUE;
459
                $captionPartHtml .= '<div class="media-caption-link">' . l($caption_link_uri, $mediaLinkUri, array(
460
                    'attributes' => $openMediaLinkAttributes, 'html' => TRUE,
461
                  )) . '</div>';
462
              }
455 463
          }
456
        }
457 464

  
458
        $captionParts[] = $captionPartHtml;
465
          $captionParts[] = $captionPartHtml;
459 466

  
460
        // --- Surround imagePart with link, this .
461
        if ($doLink) {
462
          $mediaPartHtml = l($mediaPartHtml, $mediaLinkUri, array(
463
            'attributes' => $mediaPartLinkAttributes, 'html' => TRUE,
464
          ));
465
        }
467
            // --- Surround imagePart with link, this .
468
          if ($doLink) {
469
            $mediaPartHtml = l($mediaPartHtml, $mediaLinkUri, array(
470
                'attributes' => $mediaPartLinkAttributes, 'html' => TRUE,
471
            ));
472
          }
466 473
      }
467 474
      else {
468 475
        $mediaPartHtml = '';

Also available in: Unified diff