Project

General

Profile

« Previous | Next » 

Revision 9d47d187

Added by Andreas Kohlbecker over 12 years ago

fixed caching problem; improved openlayers map

View differences:

.gitattributes
8 8
modules/cdm_dataportal/cdm_api/cdm_api.info -text
9 9
modules/cdm_dataportal/cdm_api/cdm_api.install -text
10 10
modules/cdm_dataportal/cdm_api/cdm_api.module -text
11
modules/cdm_dataportal/cdm_api/commons.php -text
11 12
modules/cdm_dataportal/cdm_api/json/JSON.php -text
12 13
modules/cdm_dataportal/cdm_api/json/LICENSE -text
13 14
modules/cdm_dataportal/cdm_api/uuids.php -text
modules/cdm_dataportal/cdm_api/cdm_api.module
16 16
 * http://www.e-taxonomy.eu
17 17
 */
18 18
require_once ('xml2json.php');
19
require_once ('commons.php');
19 20
require_once ('uuids.php');
20 21

  
21 22
define(DEFAULT_TAXONTREE_RANKLIMIT, '');//TODO Genus UUID
......
625 626
 * @return unknown_type
626 627
 */
627 628
function cdm_ws_get($uri, $pathParameters = array(), $query = null, $method="GET", $absoluteURI = false){
628
  
629
   
629 630
  // transform the given uri path or patthern into a proper webservice uri
630 631
  if(!$absoluteURI){
631 632
    $uri = cdm_compose_url($uri, $pathParameters, $query);
632 633
  }
633 634
  
634 635
  $do_cache = variable_get('cdm_webservice_cache', 1); //strpos($uri, "?") !== FALSE; // if the url has a query parameter sting
635
  // never cache absolute URIs
636
  $do_cache = $do_cache && !$absoluteURI;
636
  // only cache cdm webservice URIs
637
  $do_cache = $do_cache && str_beginsWith($uri, variable_get('cdm_webservice_url', '#EMPTY#'));
637 638
  $cache_entry = false;
638 639
   
639 640
  if($do_cache){
modules/cdm_dataportal/cdm_api/commons.php
1
<?php
2

  
3
/**
4
 * Truncates a $string to the specified $length. 
5
 * If the supplied string is equal to or shorter than the $legth the original is returend.
6
 * if an $appendix is defined the resulting string will have the specified $length including the $appendix.
7
 *
8
 * @param String $string  the string to truncate
9
 * @param Number $length  the maximun length
10
 * @param String $appendix  an optional appendix.
11
 *
12
 * @return the string
13
 */
14
function str_trunk(&$string, $length, $appendix=''){
15
  if(strlen($string) >= $length ){
16
    return  substr($string, 0, $length - strlen($appendix)).$appendix;
17
  } else {
18
    return $string;
19
  }
20
}
21

  
22
/**
23
 * @param string $str
24
 * @param string $sub
25
 * @return boolean
26
 */
27
function str_beginsWith( $str, $sub ) {
28
  return ( substr( $str, 0, strlen( $sub ) ) === $sub );
29
}
30

  
31
/**
32
 *
33
 * @param string $str
34
 * @param string $sub
35
 * @return boolean
36
 */
37
function str_endsWith( $str, $sub ) {
38
  return ( substr( $str, strlen( $str ) - strlen( $sub ) ) === $sub );
39
}
40

  
41
/**
42
 * Replaces all occurences in $array of the key defined in $replace_map with the according values in the 
43
 * $replace_map.
44
 * 
45
 * @param $array
46
 * @param $replace_map 
47
 * @return unknown_type
48
 */
49
function array_replace_key($array, $replace_map){
50
  foreach($replace_map as $key=>$newkey){
51
    if(isset($array[$key])){
52
      $array[$newkey] = $array[$key];
53
      unset($array[$key]);
54
    }
55
  }
56
  return $array;
57
}
58

  
59
/**
60
 * Replaces all occurrences of space characters with 
61
 * an underscore and transforms the given
62
 * string to lowercase.
63
 *
64
 * @param String $string
65
 * @return the transformed string
66
 */
67
function generalizeString($string){
68
  return str_replace(' ', '_', strtolower($string));
69
}
modules/cdm_dataportal/cdm_dataportal.module
736 736
  
737 737
  $form['cdm_dataportal']['geoservice']['cdm_dataportal_geoservice_bounding_box'] = array(
738 738
    '#type' => 'textfield',
739
    '#title' => t('Geoservice Bounding Box'),
739
    '#title' => t('Fixed Geoservice Bounding Box'),
740 740
    '#default_value' => variable_get('cdm_dataportal_geoservice_bounding_box', '-180,-90,180,90'),
741
    '#description' => t('Define the surrounding area using latitude and longitude. Leave as is for the whole world.')
741
    '#description' => t('Define urrounding of area to be displayed in maps. Use "-180,-90,180,90" for the whole world. Leave <strong>empty</strong> to let the map <strong>automatically zoom</strong> to the distribution area.')
742 742
  );
743 743
  
744 744
   //cdm_dataportal_geoservice_labels_on
......
1078 1078
  return false;
1079 1079
}
1080 1080

  
1081
/**
1082
 * Truncates a $string to the specified $length. 
1083
 * If the supplied string is equal to or shorter than the $legth the original is returend.
1084
 * if an $appendix is defined the resulting string will have the specified $length including the $appendix.
1085
 *
1086
 * @param String $string	the string to truncate
1087
 * @param Number $length	the maximun length
1088
 * @param String $appendix	an optional appendix.
1089
 *
1090
 * @return the string
1091
 */
1092
function str_trunk(&$string, $length, $appendix=''){
1093
  if(strlen($string) >= $length ){
1094
    return  substr($string, 0, $length - strlen($appendix)).$appendix;
1095
  } else {
1096
    return $string;
1097
  }
1098
}
1099

  
1100
/**
1101
 * @param string $str
1102
 * @param string $sub
1103
 * @return boolean
1104
 */
1105
function str_beginsWith( $str, $sub ) {
1106
  return ( substr( $str, 0, strlen( $sub ) ) === $sub );
1107
}
1108

  
1109
/**
1110
 *
1111
 * @param string $str
1112
 * @param string $sub
1113
 * @return boolean
1114
 */
1115
function str_endsWith( $str, $sub ) {
1116
  return ( substr( $str, strlen( $str ) - strlen( $sub ) ) === $sub );
1117
}
1118

  
1119
/**
1120
 * Replaces all occurences in $array of the key defined in $replace_map with the according values in the 
1121
 * $replace_map.
1122
 * 
1123
 * @param $array
1124
 * @param $replace_map 
1125
 * @return unknown_type
1126
 */
1127
function array_replace_key($array, $replace_map){
1128
  foreach($replace_map as $key=>$newkey){
1129
    if(isset($array[$key])){
1130
      $array[$newkey] = $array[$key];
1131
      unset($array[$key]);
1132
    }
1133
  }
1134
  return $array;
1135
}
1136

  
1137
/**
1138
 * Replaces all occurrences of space characters with 
1139
 * an underscore and transforms the given
1140
 * string to lowercase.
1141
 *
1142
 * @param String $string
1143
 * @return the transformed string
1144
 */
1145
function generalizeString($string){
1146
  return str_replace(' ', '_', strtolower($string));
1147
}
1148

  
1149 1081
/**@Deprecated
1150 1082
 * 
1151 1083
 */
modules/cdm_dataportal/cdm_dataportal.theme.php
660 660
    $map_data_parameters = cdm_ws_get(CDM_WS_GEOSERVICE_DISTRIBUTIONMAP, $taxon->uuid);
661 661

  
662 662
    $display_width = variable_get('cdm_dataportal_geoservice_display_width', false);
663
    //$bounding_box = variable_get('cdm_dataportal_geoservice_bounding_box', false);
663
    $bounding_box = variable_get('cdm_dataportal_geoservice_bounding_box', false);
664 664
    $labels_on = variable_get('cdm_dataportal_geoservice_labels_on', 0);
665 665

  
666 666
    $query_string = ($display_width ? '&ms=' . $display_width: '')
......
693 693
        }
694 694
      }
695 695
      // get the bbox from the response object
696
      $zoomto_bbox = ($responseObj->bbox ? $responseObj->bbox : '-180, -90, 180, 90');
696
      $zoomto_bbox = ($bounding_box ? $bounding_box : ($responseObj->bbox ? $responseObj->bbox :'-180, -90, 180, 90') );
697 697
      
698 698
      $add_tdwg1 = (isset($tdwg_sldUris['tdwg1']) ? "
699 699
          tdwg_1.params.SLD = '".$tdwg_sldUris['tdwg1']."';

Also available in: Unified diff