Project

General

Profile

« Previous | Next » 

Revision 7a2a14b3

Added by Andreas Kohlbecker over 9 years ago

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, ...

View differences:

7.x/modules/cdm_dataportal/cdm_api/cdm_api.module
1773 1773
       $(\'.messages.debug\').before( \'<h6 class="messages_toggler debug">Debug Messages (click to toggle)</h6>\' );
1774 1774
       $(\'.messages_toggler\').click(function(){
1775 1775
         $(this).next().slideToggle(\'fast\');
1776
         return FALSE;
1776
         return false;
1777 1777
       }).next().hide();
1778 1778
     });', array('type' => 'inline'));
1779 1779

  
7.x/modules/cdm_dataportal/cdm_dataportal.module
908 908
    'cdm_media_caption' => array('variables' => array(
909 909
      'media' => NULL,
910 910
      'elements' => array('title', 'description', 'artist', 'location', 'rights'),
911
      'fileUri' => NULL,
912 911
      )),
913 912
    'cdm_media_gallerie' => array('variables' => array(
914 913
      'mediaList' => NULL,
7.x/modules/cdm_dataportal/js/ahah-content.js
5 5

  
6 6
(Drupal.ahahContentAutoAttach = (function ($) {
7 7

  
8
    $(".ahah-content").each(function(i){
9
      
10
      var ahahContent = $(this);
11
      url = ahahContent.attr("rel");
12
      ahahContent.removeAttr('rel').find('.loading').css('display', 'block');
8
	// firebug console stub (avoids errors if firebug is not active)
9
	if(typeof console === "undefined") {
10
	    console = { log: function() { } };
11
	}
13 12

  
14
      $.get(url, function(html){
15
        ahahContent.find('.loading').remove();
16
        ahahContent.append(html);
17
        });
13
  // register with all elements .ahah-content
14
    $(".ahah-content").each(function(index, element) {
15
      var ahahContent = $(element);
16
      url = ahahContent.attr("rel");
17
      console.log("ahah-content url:" + url);
18
      if(url !== undefined && url.length > 1){
19
//        ahahContent.removeAttr('rel').find('.loading').css('display', 'block');
20
        ahahContent.find('.loading').css('display', 'block');
21
        $.get(url, function(html){
22
          ahahContent.find('.loading').remove();
23
          ahahContent.append(html);
24
          });
25
        }
18 26
      });
19
    
27

  
20 28
      // register with lightbox etc ...
21 29
      $('body').bind('overflow', function(event){
22
        
30

  
23 31
        var ahah_content_set = $(event.target).find('.ahah-content');
24
        if(ahah_content_set != undefined){
32
        if(ahah_content_set !== undefined){
25 33
          $(ahah_content_set).each(function(i){
26 34
            var ahah_content = $(this);
27 35
            var url = ahah_content.attr('rel');
28
            if(url != undefined){
36
            console.log("ahah-content on 'overflow' url:" + url);
37
            if(url !== undefined && url.length > 1){
29 38
              ahah_content.removeAttr('rel').find('.loading').css('display', 'block');
30 39
              $.get(url, function(html){
31 40
                ahah_content.find('.loading').remove().end().append(html);
32 41
                });
33 42
            }
34
          })
35
          
43
          });
44

  
36 45
        }
37 46
      });
38
      
39
    }))(jQuery)
40
  
47

  
48
    }))(jQuery);
49

  
41 50

  
42 51

  
43
  jQuery(document).ready(Drupal.ahahContentAutoAttach);
52
jQuery(document).ready(Drupal.ahahContentAutoAttach);
7.x/modules/cdm_dataportal/js/cdm_dynabox.js
16 16
    var url = dynabox_content.attr('title');
17 17

  
18 18
    if(url !== undefined && url.length > 1){
19
      dynabox_content.removeAttr('title').find('.loading').css( 'display', 'block');
19
      dynabox_content.removeAttr('title').find('.loading').show();
20 20
      $.get(url, function(html){
21 21
        dynabox_content.find('.loading').remove().end().append(html);
22 22
      });
23 23
    }
24
  }
24
  };
25 25

  
26
  $('.dynabox').find('.dynabox_content').hide().click(function(event){event.stopPropagation();});
26
  $('.dynabox').find('.dynabox_content').click(function(event){event.stopPropagation();});
27 27

  
28 28
  $('.dynabox a.label').dblclick(loadDynaContent);
29 29
  $('.dynabox a.label').click(loadDynaContent);
30 30

  
31 31
    //$('li.dynabox> span').click(function(event){event.stopPropagation();});
32
}))(jQuery)
32
}))(jQuery);
33 33

  
34 34

  
35 35

  
7.x/modules/cdm_dataportal/js/openlayers_map.js
10 10
  var defaultBaseLayer;
11 11

  
12 12
  var defaultControls = [
13
             new OpenLayers.Control.PanZoom(),
13
           new OpenLayers.Control.PanZoom(),
14 14
           new OpenLayers.Control.Navigation({zoomWheelEnabled: false, handleRightClicks:true, zoomBoxKeyMask: OpenLayers.Handler.MOD_CTRL})
15 15
         ];
16 16
  /*
7.x/modules/cdm_dataportal/theme/cdm_dataportal.common.theme
71 71
 * TODO if getting fragment from request is possible remove
72 72
 * $_REQUEST['highlite'] HACK
73 73
 * NOT WORKING since fragments are not available to the server
74
 *
74 75
 * function fragment(){
75
 * global $fragment;
76
 * if(!$fragment){
77
 * $fragment = substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'],
78
 * '#'));
79
 * }
80
 * return $fragment;
76
 *    global $fragment;
77
 *    if(!$fragment){
78
 *       $fragment = substr($_SERVER['REQUEST_URI'], strrpos($_SERVER['REQUEST_URI'], '#'));
79
 *    }
80
 *   return $fragment;
81 81
 * }
82 82
 */
83 83
function uuid_anchor($uuid, $innerHTML) {
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) {
7.x/modules/cdm_dataportal/theme/cdm_dataportal.occurrence.theme
106 106
    'derivedUnitMedia',
107 107
  );
108 108
  static $fieldLabels = array(
109
    'type' => 'Basis of Record',
109 110
    'fieldNumber' => 'Collectors number',
110 111
    'absoluteElevation' => 'Altitude',
111 112
    'absoluteElevationMinimum' => 'Altitude maximum',
7.x/modules/cdm_dataportal/theme/cdm_dataportal.page.theme
131 131
  }
132 132

  
133 133
  // --- GET specimensOrObservations --- //
134
  // Comment @WA Note the spelling error!
135
  $specimensOrObservations = cdm_ws_get(CDM_WS_TAXON, array(
136
    $taxon->uuid,
137
    'specimensOrObersvations',
138
  ));
134
  $specimensOrObservations = cdm_ws_get(CDM_WS_TAXON, array( $taxon->uuid, 'specimensOrObservations'));
139 135

  
140 136
  $specimensOrObservationsCount = is_array($specimensOrObservations) ? count($specimensOrObservations) : 0;
141 137
  if ($specimensOrObservationsCount == 0 || ($tabsToDisplay["Specimens"] == '0')) {
......
343 339
  $taxon = $variables['taxon'];
344 340
  RenderHints::pushToRenderStack('taxon_page_specimens');
345 341

  
346
  // Comment @WA: Note the spelling error.
347 342
  $specimensOrObservations = cdm_ws_get(CDM_WS_TAXON, array(
348 343
    $taxon->uuid,
349
    'specimensOrObersvations',
344
    'specimensOrObservations',
350 345
  ));
351 346

  
352 347
  // Collect media (fieldObjectMedia, derivedUnitMedia) and add as fields.
......
373 368
      // os=&od=&legend=0&recalculate=false&image=false
374 369
      $occurrenceQuery = $occurrenceQuery->String;
375 370

  
371
      $legendFormatQueryStr = null;
376 372
      if (variable_get('cdm_dataportal_map_openlayers', 1)) {
377

  
378 373
        $out .= get_openlayers_map(variable_get('cdm_dataportal_geoservice_display_width', FALSE), variable_get('cdm_dataportal_geoservice_bounding_box', FALSE), $occurrenceQuery, NULL,
379
            // Comment @WA: not defined.
380
            // $legendFormatQueryStr,
381
            NULL, variable_get('cdm_dataportal_geoservice_map_caption', ''));
374
            $legendFormatQueryStr, variable_get('cdm_dataportal_geoservice_map_caption', ''));
382 375
      }
383 376
      else {
384 377
        // get_image_map($width, $occurrenceQuery = FALSE, $distributionQuery = FALSE, $legendFormatQuery = FALSE, $map_caption = FALSE )
385 378
        $out .= get_image_map(variable_get('cdm_dataportal_geoservice_display_width', FALSE), variable_get('cdm_dataportal_geoservice_bounding_box', FALSE), $occurrenceQuery, NULL,
386
            // @WA: not defined
387
            // $legendFormatQueryStr,
388
            NULL, variable_get('cdm_dataportal_geoservice_map_caption', ''));
379
            $legendFormatQueryStr, variable_get('cdm_dataportal_geoservice_map_caption', ''));
389 380
      }
390 381
    }
391 382
  }
......
406 397

  
407 398
      // --- Render the title cache.
408 399
      $out_row = '<tr class="descriptionElement descriptionElement_IndividualsAssociation ' . ($i % 2 ? 'odd' : 'even') . '">';
400

  
409 401
      if ($specimensOrObservation->class != 'FieldObservation') {
410
        $label_html = cdm_dynabox($specimensOrObservation->titleCache, cdm_compose_url('portal/' . CDM_WS_DERIVEDUNIT_FACADE, array(
411
          $specimensOrObservation->uuid,
412
        )), 'cdm_derivedUnitFacade', 'Click for details', array(
413
          'div',
414
          'div',
415
        ));
402
        // details are loaded on request via the cdm_dynabox by AJAX
403
        $derived_unit_ws_request = cdm_compose_url('portal/' . CDM_WS_DERIVEDUNIT_FACADE, array( $specimensOrObservation->uuid));
404
        $label_html = cdm_dynabox(
405
            $specimensOrObservation->titleCache,
406
            $derived_unit_ws_request,
407
            'cdm_derivedUnitFacade',
408
            'Click for details',
409
            array('div','div')
410
        );
416 411
      }
417 412
      else {
418 413
        $label_html = $specimensOrObservation->titleCache;
......
420 415
      $out_row .= '<td>' . $label_html . '</td>';
421 416

  
422 417
      // --- Render associated media.
418
      $gallery_html = '';
423 419
      if (count($mediaList) > 0) {
424 420
        $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SPECIMEN_GALLERY_NAME);
425 421
        $gallery_name = $specimensOrObservation->uuid;
......
432 428
          'galleryName' => $gallery_name,
433 429
          'maxExtend' => $gallery_settings['cdm_dataportal_media_maxextend'],
434 430
          'cols' => $gallery_settings['cdm_dataportal_media_cols'],
435
          'maxRows' => $gallery_settings['cdm_dataportal_media_maxRows'],
431
          'maxRows' => isset($gallery_settings['cdm_dataportal_media_maxRows']) ? isset($gallery_settings['cdm_dataportal_media_maxRows']) : null,
436 432
          'captionElements' => $captionElements,
437 433
          'mediaLinkType' => 'LIGHTBOX',
438 434
          'alternativeMediaUri' => NULL,
439 435
          'galleryLinkUri' => NULL,
440 436
          ));
441 437
      }
442
      else {
443
        $gallery_html = '';
444
      }
445 438
      $out_row .= '<td>' . $gallery_html . '</td></tr>';
446 439
      $out_specimenList .= $out_row;
447 440
    }
......
859 852

  
860 853
  $out .= '<div class="media cdm_media_viewer_image">';
861 854

  
862
  // $out .= '<div class="viewer">';
863 855
  $out .= theme('cdm_back_to_image_gallery_button', array());
864 856
  $out .= '<div class="viewer">';
865
  // $out .= theme('cdm_media_gallerie_image', $representation->parts[$partIdx],
866
  // $imageMaxExtend);
867 857
  $out .= theme('cdm_openlayers_image', array('mediaRepresentationPart' => $media->representations[$representationIdx]->parts[$partIdx], 'maxExtend' => $imageMaxExtend));
868 858
  $out .= '</div>';
869 859

  
......
889 879
  // Representation(-part) specific metadata.
890 880
  $thumbnailMaxExtend = 100;
891 881
  $out .= '<table>';
892
  // $out .= '<tr><th colspan="3">'.t('MimeType').':
893
  // '.$media->representations[$representationIdx]->mimeType.'</th></tr>';
894 882
  $i = 0;
895 883
  foreach ($media->representations[$representationIdx]->parts as $part) {
896 884
    $out .= '<tr><th>' . t('Part') . ' ' . ($i + 1) . '</th><td>';
7.x/modules/cdm_dataportal/theme/cdm_dataportal.taxon.theme
581 581
  $out = '';
582 582
  $gallery_settings = getGallerySettings(CDM_DATAPORTAL_SEARCH_GALLERY_NAME);
583 583
  $showCaption = $gallery_settings['cdm_dataportal_show_thumbnail_captions'];
584
  $captionElements = '';
585 584
  if ($showCaption) {
586 585
    $captionElements = array(
587 586
      'title',
588 587
      'rights',
589 588
    );
589
  } else {
590
    $captionElements = array();
590 591
  }
591 592

  
592 593
  $gallery_name = $taxon->uuid;

Also available in: Unified diff