Project

General

Profile

« Previous | Next » 

Revision 4946eebf

Added by Andreas Kohlbecker almost 7 years ago

ref #6683 bugfixes in image viewer

View differences:

modules/cdm_dataportal/theme/cdm_dataportal.page.theme
563 563
  $out = '';
564 564

  
565 565
  // Determine which representation and which part to show
566
  $representationIdx = 0;
566
  $active_representation_index = 0;
567 567

  
568 568
  if (!$mediarepresentation_uuid) {
569
    // no representation requested by the method parameters, find the best one
569 570
    $representations = cdm_preferred_media_representations($media, array('image/png', 'image/jpeg', 'image/gif'), null, null);
570
    $mediarepresentation_uuid = isset($representations[0]) ? $representations[0]->uuid : null;
571
    if($representations  && count($representations) > 0){
572
      $preferred_representation = array_shift($representations);
573
      $mediarepresentation_uuid = $preferred_representation->uuid;
574
    }
571 575
  }
572 576

  
573
  $p_i = 0;
574
  foreach ($media->representations as $representation) {
575
    if ($representation->uuid == $mediarepresentation_uuid) {
576
      $representationIdx = $p_i;
577
  if($mediarepresentation_uuid){
578
    foreach ($media->representations as $representation) {
579
      if ($representation->uuid == $mediarepresentation_uuid) {
580
        break;
581
      }
582
      $active_representation_index++;
577 583
    }
578
    $p_i++;
579 584
  }
580 585

  
581 586

  
582
  $partIdx = 0;
583
  if (!is_numeric($partId)) {
584
    // Assuming it is an uuid.
585
    $p_i = 0;
586
    foreach ($media->representations[$representationIdx]->parts as $part) {
587
  $active_part_index = 0;
588
  if (is_uuid($partId)) {
589
    foreach ($media->representations[$active_representation_index]->parts as $part) {
587 590
      if ($part->uuid == $partId) {
588
        $partIdx = $p_i;
591
        break;
589 592
      }
590
      $p_i++;
593
      $active_part_index++;
591 594
    }
592 595
  }
593
  else {
594
    // Assuming it is an index.
595
    $partIdx = $partId;
596
  else if(is_numeric($partId)){
597
    $active_part_index = $partId;
596 598
  }
597 599

  
598 600
  $media_metadata = read_media_metadata($media);
......
611 613

  
612 614
  $out .= theme('cdm_back_to_image_gallery_button', array());
613 615
  $out .= '<div class="viewer">';
614
  $out .= cdm_openlayers_image($media->representations[$representationIdx]->parts[$partIdx], $imageMaxExtend);
616
  $out .= cdm_openlayers_image($media->representations[$active_representation_index]->parts[$active_part_index], $imageMaxExtend);
615 617
  $out .= '</div>';
616 618

  
617 619
  // General media metadata.
......
626 628
  foreach ($media->representations as $representation) {
627 629
    $out .= '<li><strong>'. t('Representation') . ' ' . $r_i . "</strong> ($representation->mimeType)" ;
628 630
    // parts
629
    $p_i = 0;
631
    $active_part_index = 0;
630 632
    $table_class_attribute = '';
631
    if($partIdx == $p_i && $representationIdx == $r_i ){
633
    if($partIdx == $active_part_index && $active_representation_index == $r_i ){
632 634
      $table_class_attribute = 'class="active"';
633 635
    }
634 636
    $out .= "<table $table_class_attribute>";
635 637
    foreach ($representation->parts as $part) {
636
      $out .= '<tr><th>' . t('Part') . ' ' . ($p_i + 1) . '</th></tr><tr><td>';
638
      $out .= '<tr><th>' . t('Part') . ' ' . ($active_part_index + 1) . '</th></tr><tr><td>';
637 639
      switch ($part->class) {
638 640
        case 'ImageFile':
639 641
          $out .= $part->width . 'x' . $part->height . ' px - ' . $part->size . ' kB';
......
646 648
          $out .= $part->size . 'k';
647 649
      }
648 650

  
649
      $out .= '</td><td><a href="' . url(path_to_media($media->uuid, $representation->uuid, $p_i)) . '">'
651
      $out .= '</td><td><a href="' . url(path_to_media($media->uuid, $representation->uuid, $active_part_index)) . '">'
650 652
        . cdm_media_gallerie_image($part, $thumbnailMaxExtend, TRUE);
651
      $p_i++;
653
      $active_part_index++;
652 654
    }
653 655
    $out .= '</table>';
654 656
    $out .=  '</li>';

Also available in: Unified diff