Project

General

Profile

« Previous | Next » 

Revision f19f47fa

Added by Andreas Kohlbecker about 9 years ago

basic implementation of #4314 (taxon page: display of bibliography in a block on the taxon page)

View differences:

7.x/modules/cdm_dataportal/cdm_dataportal.module
25 25
module_load_include('inc', 'cdm_dataportal', 'includes/common');
26 26
module_load_include('inc', 'cdm_dataportal', 'includes/pages');
27 27
module_load_include('inc', 'cdm_dataportal', 'includes/media');
28
module_load_include('inc', 'cdm_dataportal', 'includes/maps');

29
module_load_include('inc', 'cdm_dataportal', 'includes/occurrences');

28
module_load_include('inc', 'cdm_dataportal', 'includes/maps');
29
module_load_include('inc', 'cdm_dataportal', 'includes/occurrences');
30 30
module_load_include('inc', 'cdm_dataportal', 'includes/descriptions');
31 31
module_load_include('inc', 'cdm_dataportal', 'includes/pre-drupal8');
32 32

  
......
274 274

  
275 275
/* ====================== hook implementations ====================== */
276 276
/**
277
 * Implements hook_permission().
 *
277
 * Implements hook_permission().
278
 *
278 279
 * Valid permissions for this module.
279 280
 *
280 281
 * @return array
......
296 297
}
297 298

  
298 299
/**
299
 * Implements hook_menu().
 */
300
 * Implements hook_menu().
301
 */
300 302
function cdm_dataportal_menu() {
301 303
  $items = array();
302 304

  
......
887 889
  }
888 890
  if (!isset($media[$taxon->uuid])) {
889 891

  
890
    // --- GET Images --- //

891
    $mediaQueryParameters = array(

892
        "type" => "ImageFile",

893
    );

894

  
895
    $relationship_choice = variable_get(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS, unserialize(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT));

896
    $mediaQueryParameters['relationships'] = implode(',', get_selection($relationship_choice['direct']));

892
    // --- GET Images --- //
893
    $mediaQueryParameters = array(
894
        "type" => "ImageFile",
895
    );
896

  
897
    $relationship_choice = variable_get(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS, unserialize(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT));
898
    $mediaQueryParameters['relationships'] = implode(',', get_selection($relationship_choice['direct']));
897 899
    $mediaQueryParameters['relationshipsInvers'] = implode(',', get_selection($relationship_choice['invers']));
898 900

  
899 901
    $taxon_media_filter_choice = variable_get(CDM_TAXON_MEDIA_FILTER, unserialize(CDM_TAXON_MEDIA_FILTER_DEFAULT));
......
901 903
    $mediaQueryParameters['includeOccurrences'] = (boolean) $taxon_media_filter_choice['includeOccurrences'] != 0;
902 904
    $mediaQueryParameters['includeTaxonNameDescriptions'] = (boolean) $taxon_media_filter_choice['includeTaxonNameDescriptions'] != 0;
903 905

  
904
    $ws_endpoint = NULL;

906
    $ws_endpoint = NULL;
905 907
    if ( variable_get('cdm_images_include_children', 0) == 0) {
906 908
      $ws_endpoint = CDM_WS_PORTAL_TAXON_MEDIA;
907 909
    } else {
908 910
      $ws_endpoint = CDM_WS_PORTAL_TAXON_SUBTREE_MEDIA;
909 911
    }
910

  
911
    $media[$taxon->uuid] = cdm_ws_get($ws_endpoint,

912
        array(

913
            $taxon->uuid,

914
        ),

912

  
913
    $media[$taxon->uuid] = cdm_ws_get($ws_endpoint,
914
        array(
915
            $taxon->uuid,
916
        ),
915 917
        queryString($mediaQueryParameters)
916 918
       );
917 919
  }
......
930 932
function _load_occurences_for_taxon($taxon){
931 933

  
932 934
  static $occurences = NULL;
933

  
934
  if(!isset($occurences)) {

935
    $occurences = array();

936
  }

935

  
936
  if(!isset($occurences)) {
937
    $occurences = array();
938
  }
937 939

  
938 940
  if (!isset($occurences[$taxon->uuid])){
939 941

  
940 942
    $relationship_choice = variable_get(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS, unserialize(CDM_AGGREGATE_BY_TAXON_RELATIONSHIPS_DEFAULT));
941 943
    $relationship_choice['direct'] = get_selection($relationship_choice['direct']);
942
    $relationship_choice['invers'] = get_selection($relationship_choice['invers']);

943

  
944
    $by_associatedtaxon_query = http_build_query(array(

945
        'relationshipsInvers' => implode(',', $relationship_choice['invers']),

946
        'relationships' => implode(',', $relationship_choice['direct']),

947
        'pageSize' => null // all hits in one page

948
    )

949
    );

950

  
951
    $pager = cdm_ws_get(CDM_WS_OCCURRENCE_BY_ASSOCIATEDTAXON,

952
        null,

953
        $by_associatedtaxon_query . '&taxonUuid=' . $taxon->uuid

954
    );

955

  
956

  
957
    if(isset($pager->records[0])){

958
      $occurences[$taxon->uuid] =  $pager->records;

959
    }

960
  }

944
    $relationship_choice['invers'] = get_selection($relationship_choice['invers']);
945

  
946
    $by_associatedtaxon_query = http_build_query(array(
947
        'relationshipsInvers' => implode(',', $relationship_choice['invers']),
948
        'relationships' => implode(',', $relationship_choice['direct']),
949
        'pageSize' => null // all hits in one page
950
    )
951
    );
952

  
953
    $pager = cdm_ws_get(CDM_WS_OCCURRENCE_BY_ASSOCIATEDTAXON,
954
        null,
955
        $by_associatedtaxon_query . '&taxonUuid=' . $taxon->uuid
956
    );
957

  
958

  
959
    if(isset($pager->records[0])){
960
      $occurences[$taxon->uuid] =  $pager->records;
961
    }
962
  }
961 963
  return $occurences[$taxon->uuid];
962 964
}
963 965
 */
......
1023 1025
 *
1024 1026
 */
1025 1027
function markup_to_render_array($html, $weight = 0) {
1026
  return array(

1028
  return array(
1027 1029
          '#markup' => $html,
1028 1030
          '#weight' => $weight,
1029 1031
      );
......
1046 1048
    return;
1047 1049
  }
1048 1050
  if ($polytomousKeyNode->class != "PolytomousKeyNode") {
1049
    drupal_set_message(_load_polytomousKeySubGraph() . t('invalid type given.'), 'error');
1051
    drupal_set_message('_load_polytomousKeySubGraph(): ' . t('invalid type given.'), 'error');
1050 1052
    return;
1051 1053
  }
1052 1054
  if (!is_uuid($polytomousKeyNode->uuid)) {
1053
    drupal_set_message(_load_polytomousKeySubGraph() . t('invalid type given.'), 'error');
1055
    drupal_set_message('_load_polytomousKeySubGraph(): ' . t('invalid type given.'), 'error');
1054 1056
    return;
1055 1057
  }
1056 1058

  
......
1363 1365

  
1364 1366
  $taxonPager = cdm_dataportal_search_execute();
1365 1367

  
1366
  $showThumbnails = do_showThumbnails();

1367

  
1368
  $setSessionUri = url('cdm_api/setvalue/session', array(

1369
      'query' => array('var' => '[pageoption][searchtaxa][showThumbnails]', 'val' => ''),

1370
  ));

1371

  
1372
  drupal_add_js('jQuery(document).ready(function() {

1373

  
1374
      // init

1375
      if(' . $showThumbnails . ' == 1){

1376
      jQuery(\'.media_gallery\').show(20);

1377
  } else {

1378
      jQuery(\'.media_gallery\').hide(20);

1379
  }

1380
      // add change hander

1381
      jQuery(\'#showThumbnails\').change(

1382
      function(event){

1383
      var state = 0;

1384
      if(jQuery(this).is(\':checked\')){

1385
      jQuery(\'.media_gallery\').show(20);

1386
      state = 1;

1387
  } else {

1388
      jQuery(\'.media_gallery\').hide(20);

1389
  }

1390
      // store state in session variable

1391
      var uri = \'' . $setSessionUri . '\' + state;

1392
      jQuery.get(uri);

1393
  });

1368
  $showThumbnails = do_showThumbnails();
1369

  
1370
  $setSessionUri = url('cdm_api/setvalue/session', array(
1371
      'query' => array('var' => '[pageoption][searchtaxa][showThumbnails]', 'val' => ''),
1372
  ));
1373

  
1374
  drupal_add_js('jQuery(document).ready(function() {
1375

  
1376
      // init
1377
      if(' . $showThumbnails . ' == 1){
1378
      jQuery(\'.media_gallery\').show(20);
1379
  } else {
1380
      jQuery(\'.media_gallery\').hide(20);
1381
  }
1382
      // add change hander
1383
      jQuery(\'#showThumbnails\').change(
1384
      function(event){
1385
      var state = 0;
1386
      if(jQuery(this).is(\':checked\')){
1387
      jQuery(\'.media_gallery\').show(20);
1388
      state = 1;
1389
  } else {
1390
      jQuery(\'.media_gallery\').hide(20);
1391
  }
1392
      // store state in session variable
1393
      var uri = \'' . $setSessionUri . '\' + state;
1394
      jQuery.get(uri);
1395
  });
1394 1396
  });',
1395
  array('type' => "inline", 'scope' => JS_DEFAULT));

1396

  
1397
  array('type' => "inline", 'scope' => JS_DEFAULT));
1398

  
1397 1399
  drupal_set_title(t('Search results'), PASS_THROUGH);
1398 1400

  
1399 1401
  return theme('cdm_search_results', array(
......
1436 1438
            $search_gallery_settings['cdm_dataportal_show_thumbnail_captions'] > 0
1437 1439
            )
1438 1440
         ? 1 : 0;
1439

  
1441

  
1440 1442
       drupal_array_set_nested_value($_SESSION, array('pageoption', 'searchtaxa', 'showThumbnails'), $showThumbnails);
1441 1443
    }
1442
    $showThumbnails = $_SESSION['pageoption']['searchtaxa']['showThumbnails'];

1443
    if (!is_numeric($showThumbnails)) {

1444
      $showThumbnails = 1;

1445
    }

1444
    $showThumbnails = $_SESSION['pageoption']['searchtaxa']['showThumbnails'];
1445
    if (!is_numeric($showThumbnails)) {
1446
      $showThumbnails = 1;
1447
    }
1446 1448
  }
1447 1449

  
1448 1450
  return $showThumbnails;
......
1652 1654
 *
1653 1655
 * @param $cdmEntity
1654 1656
 */
1655
function html_class_atttibute_ref($cdmEntity) {
1657
function html_class_attribute_ref($cdmEntity) {
1656 1658

  
1657 1659
  if (is_cdm_entity($cdmEntity)) {
1658 1660
    return "cdm:" . $cdmEntity->class . " uuid:" . $cdmEntity->uuid;
......
1830 1832

  
1831 1833
  $metadata_caption = array(
1832 1834
    'title' => '',// Media_metadata and media.
1833
    'artist' => '',// Media_metadata and media.
    'rights',// Media_metadata and media.
    'location',// Media_metadata.
1835
    'artist' => '',// Media_metadata and media.
1836
    'rights',// Media_metadata and media.
1837
    'location',// Media_metadata.
1834 1838
    'filename' => '',// Media.
1835 1839
    'mediacreated' => '',// Media.
1836 1840
    'description' => '',
......
2098 2102
 *   of an other type. A TextData element holding a multilanguageText or a
2099 2103
 *   source reference is considered to be not empty.
2100 2104
 */
2101
function hasFeatureNodeDescriptionElements($featureNode) {
2105
function has_feature_node_description_elements($featureNode) {
2102 2106

  
2103 2107
  if (isset($featureNode->descriptionElements) && is_array($featureNode->descriptionElements) && count($featureNode->descriptionElements) > 0) {
2104 2108
    if(!isset($featureNode->descriptionElements['#type'])){ // #type is used to identify e.g. DTO elements: '#type' => 'DTO'
......
2111 2115
  }
2112 2116
  else if (isset($featureNode->childNodes) && is_array($featureNode->childNodes)) {
2113 2117
    foreach ($featureNode->childNodes as $child) {
2114
      if (hasFeatureNodeDescriptionElements($child)) {
2118
      if (has_feature_node_description_elements($child)) {
2115 2119
        return TRUE;
2116 2120
      }
2117 2121
    }

Also available in: Unified diff