Project

General

Profile

Download (29.7 KB) Statistics
| Branch: | Tag: | Revision:
1 32a96ee6 Andreas Kohlbecker
<?php
2 1e687365 Andreas Kohlbecker
// $Id$
3 32a96ee6 Andreas Kohlbecker
4
/**
5
 * @file
6
 * Functions which are required or useful when accessing and processing CDM Data Store Webservices
7 94112bee n.hoffmann
 *
8 32a96ee6 Andreas Kohlbecker
 * Naming conventions:
9
 * ----------------------
10 94112bee n.hoffmann
 *
11 32a96ee6 Andreas Kohlbecker
 *  - all webservice access methods are prefixed with cdm_ws
12 94112bee n.hoffmann
 *
13 32a96ee6 Andreas Kohlbecker
 *
14
 * Copyright (C) 2007 EDIT
15 94112bee n.hoffmann
 * European Distributed Institute of Taxonomy
16 32a96ee6 Andreas Kohlbecker
 * http://www.e-taxonomy.eu
17
 */
18
require_once ('xml2json.php');
19 9d47d187 Andreas Kohlbecker
require_once ('commons.php');
20 6ee322a7 Andreas Kohlbecker
require_once ('uuids.php');
21 ee780c57 Andreas Kohlbecker
22 2447830d Andreas Kohlbecker
define(DEFAULT_TAXONTREE_RANKLIMIT, '');//TODO Genus UUID
23 ee780c57 Andreas Kohlbecker
24 d96a6e06 Andreas Kohlbecker
25 32a96ee6 Andreas Kohlbecker
/**
26 d96a6e06 Andreas Kohlbecker
 * Implementation of hook_requirements()
27 32a96ee6 Andreas Kohlbecker
 */
28 d96a6e06 Andreas Kohlbecker
function cdm_api_requirements() {
29
30
  $requirements['cdm_api'] = array(
31
    'title' => t('CDM API')
32
  );
33
34
  if( function_exists('curl_init') ){
35 94112bee n.hoffmann
    $requirements['cdm_api']['description'] = ''; // description below title is not jet in use
36 d96a6e06 Andreas Kohlbecker
    $requirements['cdm_api']['value'] =  'CURL php extension is available.';
37
  } else {
38
    $requirements['cdm_api']['value'] =  'CURL php extension is missing.';
39
  }
40
 
41
  //FIXME: once _get_content_fsockopen is implemented change  severity to  REQUIREMENT_WARNING,
42
  $requirements['cdm_api']['severity'] =  (function_exists('curl_init') ? REQUIREMENT_OK : REQUIREMENT_ERROR);
43
  
44
  return $requirements;
45 32a96ee6 Andreas Kohlbecker
}
46
47 d96a6e06 Andreas Kohlbecker
48 bd6b2769 Andreas Kohlbecker
/**
49 d96a6e06 Andreas Kohlbecker
 * Implementation of hook_menu()
50 bd6b2769 Andreas Kohlbecker
 */
51 d96a6e06 Andreas Kohlbecker
function cdm_api_menu($may_cache) {
52
  $items = array();
53
  if ($may_cache) {
54 5602a381 n.hoffmann
    $items[] = array(
55 5a688ffe Andreas Kohlbecker
      // usage: url('cdm_api/proxy/'.urlencode($content_url)."/$theme");
56 d96a6e06 Andreas Kohlbecker
      'path' => 'cdm_api/proxy',
57
      'callback' => 'proxy_content',
58
      'access' => true,
59
      'type' => MENU_CALLBACK,
60 5602a381 n.hoffmann
    );
61 b09e63fd Andreas Kohlbecker
    
62
    $items[] = array(
63
      // usage: url('cdm_api/proxy/'.urlencode($content_url)."/$theme");
64
      'path' => 'cdm_api/setvalue/session',
65
      'callback' => 'setvalue_session',
66
      'access' => true,
67
      'type' => MENU_CALLBACK,
68
    );
69
    
70 bd6b2769 Andreas Kohlbecker
  }
71 d96a6e06 Andreas Kohlbecker
  
72
  return $items;
73 bd6b2769 Andreas Kohlbecker
}
74 d93dad11 n.hoffmann
75
/**
76
 * Configures the settings forfm for the CDM-API module.
77
 *
78
 * @return Array Drupal settings form
79
 */
80 2e748209 Andreas Kohlbecker
function cdm_api_settings_form(){
81
  
82 70fb5e15 Andreas Kohlbecker
  $form['cdm_webservice'] = array(
83 2e748209 Andreas Kohlbecker
      '#type' => 'fieldset',
84
      '#title' => t('CDM Web Service'),
85
      '#collapsible' => FALSE,
86
      '#collapsed' => FALSE,
87
  );
88
89
  $form['cdm_webservice']['cdm_webservice_url'] =  array(
90
    '#type' => 'textfield',
91
    '#title'         => t('CDM Web Service URL'),
92
    '#description'   => t('The URL of CDM Webservice which delivers the data to be published.'),
93 24b09d7c Andreas Kohlbecker
    '#default_value' => variable_get('cdm_webservice_url', NULL),
94 2e748209 Andreas Kohlbecker
  );
95 30c5a6bd Andreas Kohlbecker
  
96
  $form['cdm_webservice']['taxontree_ranklimit'] =  array(
97
    '#type'          => 'select',
98
    '#title'         => t('Rank of highest displayed taxon'),
99 2447830d Andreas Kohlbecker
    '#default_value' => variable_get('taxontree_ranklimit', DEFAULT_TAXONTREE_RANKLIMIT_UUID),
100 70fb5e15 Andreas Kohlbecker
    '#options'       => cdm_rankVocabulary_as_option(),
101 30c5a6bd Andreas Kohlbecker
    '#description'   => t('The rank of the highest displayed taxon in the taxontree.'),
102
  );
103
  
104
  /*
105 2e748209 Andreas Kohlbecker
  $form['cdm_webservice']['cdm_webservice_isStub'] =  array(
106
    '#type' => 'checkbox',
107
    '#title'         => t('Use Web Service Stub'),
108
    '#default_value' => variable_get('cdm_webservice_isStub', 1),
109
    '#description'   => t('Use a static web service stub. Only for development. For further information please refer to the ')
110
  .l('ws_stub/README.txt', 'http://dev.e-taxonomy.eu/svn/trunk/drupal/modules/cdm_dataportal/cdm/ws_stub/README.txt', array('target'=>'_blank')),
111
  );
112 d96a6e06 Andreas Kohlbecker
  
113 2e748209 Andreas Kohlbecker
114
  $form['cdm_webservice']['cdm_webservice_type'] =  array(
115 812a9c04 Andreas Kohlbecker
    '#type'          => 'select',
116 2e748209 Andreas Kohlbecker
    '#title'         => t('Web Service Type'),
117
    '#default_value' => variable_get('cdm_webservice_type', 'json'),
118 812a9c04 Andreas Kohlbecker
    '#options'       => array(
119
            'xml'  => t('XML'),
120
            'json' => t('JSON'),
121 2e748209 Andreas Kohlbecker
        ),
122
    '#description'   => t('The response data type of the web service.'),
123
  );
124 30c5a6bd Andreas Kohlbecker
  */
125 d96a6e06 Andreas Kohlbecker
126
  $form['cdm_webservice']['cdm_webservice_cache'] =  array(
127
    '#type' => 'checkbox',
128
    '#title'         => t('Enable Caching'),
129
    '#default_value' => variable_get('cdm_webservice_cache', 1),
130 21604cea Andreas Kohlbecker
    '#description'   => t('Enable caching of webservice responses on simple requests, '
131
      .'that is requests which only have one parameter generally a UUID or a concatenation of UUIDs')
132 d96a6e06 Andreas Kohlbecker
  );
133 2e748209 Andreas Kohlbecker
  
134
  $form['cdm_webservice']['proxy'] = array(
135
      '#type' => 'fieldset',
136
      '#title' => t('Proxy'),
137
      '#collapsible' => TRUE,
138
      '#collapsed' => TRUE
139
  );
140
  
141
  $form['cdm_webservice']['proxy']['cdm_webservice_proxy_url'] =  array(
142
    '#type' => 'textfield',
143
    '#title'         => t('Proxy URL'),
144 94112bee n.hoffmann
    '#description'   => t('If this proxy url is set the cdm api tries
145
    to connect the web service over the given proxy server.
146 2e748209 Andreas Kohlbecker
    Otherwise proxy usage is deactivated.'),
147
    '#default_value' => variable_get('cdm_webservice_proxy_url', false),
148
  );
149
  
150
  $form['cdm_webservice']['proxy']['cdm_webservice_proxy_port'] =  array(
151
    '#type' => 'textfield',
152
    '#title'         => t('Proxy Port'),
153
    '#default_value' => variable_get('cdm_webservice_proxy_port', '80'),
154
  );
155
  
156
  $form['cdm_webservice']['proxy']['cdm_webservice_proxy_usr'] =  array(
157
    '#type' => 'textfield',
158
    '#title'         => t('Login'),
159
    '#default_value' => variable_get('cdm_webservice_proxy_usr', false),
160
  );
161
  
162
  $form['cdm_webservice']['proxy']['cdm_webservice_proxy_pwd'] =  array(
163
    '#type' => 'textfield',
164
    '#title'         => t('Password'),
165
    '#default_value' => variable_get('cdm_webservice_proxy_pwd', false),
166
  );
167
  
168
  $form['cdm_webservice']['cdm_webservice_debug'] =  array(
169
    '#type' => 'checkbox',
170
    '#title'         => t('Debug CDM Web Service'),
171
    '#default_value' => variable_get('cdm_webservice_debug', 1),
172 0d127818 Andreas Kohlbecker
    '#description'   => t('Enable CDM Web Service debugging messages. Only visible for administrators!')
173 94112bee n.hoffmann
  );
174
    
175 2e748209 Andreas Kohlbecker
  return $form;
176
}
177
178 d96a6e06 Andreas Kohlbecker
/**
179
 * Implementation of hook_cron().
180
 *
181
 * Expire outdated cache entries
182
 */
183
function cdm_api_cron() {
184
  cache_clear_all(NULL, 'cache_cdm_ws');
185
}
186
187
188
// ----------------------------------------------------------- //
189
190
191
/**
192 94112bee n.hoffmann
 * Converts an array of TagedText items into a sequence of corresponding html tags whereas
193 d96a6e06 Andreas Kohlbecker
 * each item will provided with a class attribute which set to the key of the TaggedText item.
194 94112bee n.hoffmann
 *
195 d96a6e06 Andreas Kohlbecker
 * @param array $taggedtxt
196
 * @param String $tag
197 94112bee n.hoffmann
 * @param String $glue the string by which the chained text tokens are concatenated together.
198 d93dad11 n.hoffmann
 *       Default is a blank character
199 94112bee n.hoffmann
 * @return String of HTML
200 d96a6e06 Andreas Kohlbecker
 */
201 5a688ffe Andreas Kohlbecker
function cdm_taggedtext2html(array &$taggedtxt, $tag = 'span', $glue = ' ', $skiptags = array()){
202 81df545f Andreas Kohlbecker
   $out = '';
203
   $i = 0;
204 d96a6e06 Andreas Kohlbecker
   foreach($taggedtxt as $tt){
205 81df545f Andreas Kohlbecker
     if(!in_array($tt->type, $skiptags) && strlen($tt->text) > 0){
206 bd4696a1 n.hoffmann
      $out .= (strlen($out) > 0 && ++$i < count($taggedtxt)? $glue : '').'<'.$tag.' class="'.$tt->type.'">'.t($tt->text).'</'.$tag.'>';
207 5a688ffe Andreas Kohlbecker
     }
208 d96a6e06 Andreas Kohlbecker
   }
209
   return $out;
210
}
211
212
/**
213
 * Finds the text tagged with $$tag_type in an array of taggedText instances
214
 *
215
 * @param array $taggedtxt
216
 * @param string $tag_type
217
 * @return the text mapped by $tag_type or an empty string
218
 */
219
function cdm_taggedtext_value(array &$taggedtxt = array(), $tag_type){
220
  foreach($taggedtxt as $tagtxt){
221
    if($tagtxt->type == $tag_type)
222
    return $tagtxt->text;
223
  }
224
  return '';
225
}
226 d93dad11 n.hoffmann
227
/**
228
 * media Array [4]
229
 *   representations Array [3]
230
 *       mimeType  image/jpeg
231
 *       representationParts Array [1]
232
 *           duration  0
233
 *           heigth  0
234
 *           size  0
235
 *           uri http://wp5.e-taxonomy.eu/dataportal/cichorieae/media/protolog/jpeg/Acanthocephalus_p1.jpg
236
 *           uuid  15c687f1-f79d-4b79-992f-7ba0f55e610b
237
 *           width 0
238
 *       suffix  jpg
239
 *       uuid  930b7d51-e7b6-4350-b21e-8124b14fe29b
240
 *   title
241
 *   uuid  17e514f1-7a8e-4daa-87ea-8f13f8742cf9
242
 *
243 abd0ab13 Andreas Kohlbecker
 * @param unknown_type $media
244 d93dad11 n.hoffmann
 * @param array $mimeTypes
245
 * @param unknown_type $width
246
 * @param unknown_type $height
247
 * @return unknown
248
 */
249 abd0ab13 Andreas Kohlbecker
function cdm_preferred_media_representations($media, array $mimeTypes, $width = 400, $height = 300){
250 d93dad11 n.hoffmann
    /**
251
252 94112bee n.hoffmann
     *
253 1712ae8f Andreas Kohlbecker
     */
254
  $prefRepr = array();
255 abd0ab13 Andreas Kohlbecker
  if(!isset($media->representations[0])){
256 1712ae8f Andreas Kohlbecker
    return $prefRepr;
257
  }
258 ac1c4d60 Andreas Kohlbecker
  
259
  while(count($mimeTypes) > 0){
260
    // getRepresentationByMimeType
261
    $mimeType = array_shift($mimeTypes);
262 abd0ab13 Andreas Kohlbecker
    foreach($media->representations as $representation){
263
      if($representation->mimeType == $mimeType){
264 ac1c4d60 Andreas Kohlbecker
        // preffered mimetype found -> erase all remaining mimetypes to end loop
265
        $mimeTypes = array();
266
        $dwa = 0;
267
        // look for part with the best matching size
268 abd0ab13 Andreas Kohlbecker
        foreach($representation->parts as $part){
269 ac1c4d60 Andreas Kohlbecker
          $dw = $part->width * $part->height - $height * $width;
270
          if($dw < 0){
271
            $dw *= -1;
272
          }
273
          $dwa+= $dw;
274 1712ae8f Andreas Kohlbecker
        }
275 abd0ab13 Andreas Kohlbecker
        $dwa = (count($representation->parts)>0) ? $dwa / count($representation->parts) : 0;
276
        $prefRepr[$dwa.'_'.$mimeTypeKey] = $representation;
277 1712ae8f Andreas Kohlbecker
      }
278
    }
279
  }
280
  // sort
281
  krsort($prefRepr);
282
  // return
283
  return $prefRepr;
284
}
285
286 30c5a6bd Andreas Kohlbecker
/**
287 2cd9a3d6 Andreas Kohlbecker
 * expects an ISO 8601 time representations of a org.joda.time.Partial 
288
 * of the form yyyy-MM-dd and returns the year as String. 
289 30c5a6bd Andreas Kohlbecker
 * In case the year is unknown (= ????) null is returned.
290
 *
291 2cd9a3d6 Andreas Kohlbecker
 * @param ISO 8601 time representations of a org.joda.time.Partial 
292
 * @return String 
293 30c5a6bd Andreas Kohlbecker
 */
294
function partialToYear($partial){
295 24b09d7c Andreas Kohlbecker
  if(is_string($partial)){
296 2cd9a3d6 Andreas Kohlbecker
    $year = substr($partial, 0, 4);  
297 24b09d7c Andreas Kohlbecker
    if($year != '??'){
298
      return $year;
299 2cd9a3d6 Andreas Kohlbecker
    } 
300 30c5a6bd Andreas Kohlbecker
  }
301 2cd9a3d6 Andreas Kohlbecker
  return; 
302 30c5a6bd Andreas Kohlbecker
}
303
/**
304 2cd9a3d6 Andreas Kohlbecker
 * expects an ISO 8601 time representations of a org.joda.time.Partial 
305 30c5a6bd Andreas Kohlbecker
 * of the form yyyy-MM-dd and returns the month as String.
306
 * In case the month is unknown (= ???) null is returned.
307
 *
308 2cd9a3d6 Andreas Kohlbecker
 * @param ISO 8601 time representations of a org.joda.time.Partial 
309
 * @return String 
310 30c5a6bd Andreas Kohlbecker
 */
311
function partialToMonth($partial){
312 24b09d7c Andreas Kohlbecker
  if(is_string($partial)){
313
    $month = substr($partial, 5, 2);
314
    if($month != '??'){
315
      return $month;
316
    }
317 30c5a6bd Andreas Kohlbecker
  }
318 2cd9a3d6 Andreas Kohlbecker
  return; 
319 30c5a6bd Andreas Kohlbecker
}
320
/**
321 2cd9a3d6 Andreas Kohlbecker
 * expects an ISO 8601 time representations of a org.joda.time.Partial 
322 30c5a6bd Andreas Kohlbecker
 * of the form yyyy-MM-dd and returns the day as String.
323
 * In case the day is unknown (= ???) null is returned.
324
 *
325 2cd9a3d6 Andreas Kohlbecker
 * @param ISO 8601 time representations of a org.joda.time.Partial 
326
 * @return String 
327 30c5a6bd Andreas Kohlbecker
 */
328
function partialToDay($partial){
329 24b09d7c Andreas Kohlbecker
  if(is_string($partial)){
330
    $day = substr($partial, 7, 2);
331
    if($day != '??'){
332
      return $day;
333
    }
334 30c5a6bd Andreas Kohlbecker
  }
335 24b09d7c Andreas Kohlbecker
  return;
336 30c5a6bd Andreas Kohlbecker
}
337 d96a6e06 Andreas Kohlbecker
338 fa97cd20 Andreas Kohlbecker
/**
339 2cd9a3d6 Andreas Kohlbecker
 * 
340 24b09d7c Andreas Kohlbecker
 * @param $uri_pattern
341
 * @param $pathParameters an array of path elements, or a single element
342
 * @param $query  A query string to append to the URL.
343
 * @return unknown_type
344 fa97cd20 Andreas Kohlbecker
 */
345 24b09d7c Andreas Kohlbecker
function cdm_compose_url($uri_pattern, $pathParameters = array(), $query = NULL ){
346 6ee322a7 Andreas Kohlbecker
  
347 cacc1bbf Andreas Kohlbecker
  $request_params = '';
348
  $path_params = '';
349 24b09d7c Andreas Kohlbecker
  
350 2cd9a3d6 Andreas Kohlbecker
  /* (1) 
351
   * substitute all place holders ($0, $1, ..) in the 
352 24b09d7c Andreas Kohlbecker
   * $uri_pattern by the according element of the $pathParameters array
353
   */
354
  static $helperArray = array();
355 784a4314 Andreas Kohlbecker
  if($pathParameters && !is_array($pathParameters)){
356 24b09d7c Andreas Kohlbecker
    $helperArray[0] = $pathParameters;
357
    $pathParameters = $helperArray;
358
  }
359 784a4314 Andreas Kohlbecker
  
360 24b09d7c Andreas Kohlbecker
  $i = 0;
361
  while(strpos($uri_pattern, "$".$i) !== FALSE){
362
    if(count($pathParameters) <= $i){
363
      drupal_set_message('cdm_compose_url(): missing pathParameters', 'debug');
364
    }
365 784a4314 Andreas Kohlbecker
    $uri_pattern = str_replace("$".$i, rawurlencode($pathParameters[$i]), $uri_pattern);
366 2cd9a3d6 Andreas Kohlbecker
    ++$i;      
367 24b09d7c Andreas Kohlbecker
  }
368
    
369
  /* (2)
370
   * Append all remaining element of the $pathParameters array as path elements
371
   */
372
  if(count($pathParameters) > $i){
373
    // strip trailing slashes
374 2cd9a3d6 Andreas Kohlbecker
    if(strrchr($uri_pattern, '/') == strlen($uri_pattern)){ 
375
      $uri_pattern = substr($uri_pattern, 0, strlen($uri_pattern) - 1); 
376 24b09d7c Andreas Kohlbecker
    }
377
    while(count($pathParameters) > $i){
378
      $uri_pattern .= '/' . $pathParameters[$i];
379
      ++$i;
380 cacc1bbf Andreas Kohlbecker
    }
381 32a96ee6 Andreas Kohlbecker
  }
382
  
383 24b09d7c Andreas Kohlbecker
  /* (3)
384
   * Append the query string supplied by $query
385
   */
386
  if (isset($query)) {
387
    $uri_pattern .= (strpos($uri_pattern, '?') !== FALSE ? '&' : '?') . $query;
388 32a96ee6 Andreas Kohlbecker
  }
389
  
390 24b09d7c Andreas Kohlbecker
  $path = $ws_name.$uri_pattern;
391
  
392
  $uri = variable_get('cdm_webservice_url', '').$path;
393
  return $uri;
394 32a96ee6 Andreas Kohlbecker
}
395
396 6ee322a7 Andreas Kohlbecker
397 24b09d7c Andreas Kohlbecker
function proxy_content($uri, $theme = null){
398 5602a381 n.hoffmann
  
399 d96a6e06 Andreas Kohlbecker
  $args = func_get_args();
400 2e748209 Andreas Kohlbecker
  
401 24b09d7c Andreas Kohlbecker
  $uriEncoded = array_shift($args);
402
  $uri = urldecode($uriEncoded);
403 d96a6e06 Andreas Kohlbecker
  $theme = array_shift($args);
404 5602a381 n.hoffmann
  
405
  $request_method = strtoupper($_SERVER["REQUEST_METHOD"]);
406
  
407
  if($request_method == "POST"){
408
    
409
    $parameters = $_POST;
410
    
411
    $post_data = array();
412
    foreach ($parameters as $k=>$v)
413
    {
414
        $post_data[] = "$k=".utf8_encode($v);
415
    }
416
    $post_data = implode(',', $post_data);
417
    
418
    // testing
419 784a4314 Andreas Kohlbecker
    $data = cdm_http_request($uri, "POST", $post_data);
420 5602a381 n.hoffmann
    print $data;
421
    
422 8a60c8fc Andreas Kohlbecker
  }else if(strpos($theme, '/') > 0){ // must be a mimetype
423
    header('Content-Type: '.$theme);
424 784a4314 Andreas Kohlbecker
    $data = _http_request_binary($uri);
425 8a60c8fc Andreas Kohlbecker
    print $data;
426
    exit;
427
  } else {
428 5602a381 n.hoffmann
    // in all other cases perform a simple get request
429
    //TODO reconsider caching logic in this function
430
    if(!$theme){
431
      // print out JSON, the cache cannot be used since it contains objects
432 784a4314 Andreas Kohlbecker
      $data = cdm_http_request($uri);
433 8a60c8fc Andreas Kohlbecker
      print $data;
434
      exit;
435 5602a381 n.hoffmann
    } else {
436 784a4314 Andreas Kohlbecker
      $obj = cdm_ws_get($uri, null, null, null, TRUE);
437 5602a381 n.hoffmann
      array_unshift($args, $theme, $obj);
438
      print call_user_func_array('theme', $args);
439
    }
440 8a60c8fc Andreas Kohlbecker
  }
441 32a96ee6 Andreas Kohlbecker
}
442
443 b09e63fd Andreas Kohlbecker
function setvalue_session(){
444
 
445
  if(strlen(arg(3)) > 0){
446
    $keys = explode('|', arg(3));
447
  }
448
  $val = arg(4);
449
  
450
  // prevent from malicous tags  
451
  $val = strip_tags($val);
452
  
453
  $var = &$_SESSION;
454
  $i = 0;
455
  foreach($keys as $key){
456
    $hasMoreKeys = ++$i < count($var);
457
    if($hasMoreKeys && (!isset($var[$key]) || !is_array($var[$key]))){
458
      $var[$key] = array();
459
    }
460
    $var = &$var[$key];
461
  }
462
  $var = $val;
463
}
464
465 8a60c8fc Andreas Kohlbecker
function uri_uriByProxy($uri, $theme = false){
466
  // usage: url('cdm_api/proxy/'.urlencode($content_url)."/$theme");)
467
  return url('cdm_api/proxy/'.urlencode($uri).($theme?"/$theme":''));
468
}
469 32a96ee6 Andreas Kohlbecker
470 30c5a6bd Andreas Kohlbecker
/**
471
 * Enter description here...
472
 *
473
 * @param String $resourceURI
474
 * @param pageSize
475
 *            the maximum number of entities returned per page (can be null
476
 *            to return all entities in a single page)
477
 * @param pageNumber
478
 *            the number of the page to be returned, the first page has the
479
 *            pageNumber = 1
480
 * @return unknown
481
 */
482
function cdm_ws_page($resourceURI, $pageSize, $pageNumber){
483 24b09d7c Andreas Kohlbecker
  return cdm_ws_get($resourceURI, null, queryString(array("page" => $pageNumber, 'pageSize'=>$pageSize)));
484 30c5a6bd Andreas Kohlbecker
}
485
486
function cdm_ws_taxonomy_find($uuid, $rank = null, $viewUuid = null){
487 24b09d7c Andreas Kohlbecker
 return cdm_ws_get(CDM_WS_TAXONOMY, null, queryString(array("uuid" => $uuid, 'rank'=>$rank)));
488 30c5a6bd Andreas Kohlbecker
}
489
490
/**
491
 * Enter description here...
492
 *
493
 * @param unknown_type $secUuid
494
 * @param unknown_type $path
495
 * @return unknown
496
 */
497 2447830d Andreas Kohlbecker
function cdm_ws_taxonomy($path = null){
498
 return cdm_ws_get(cdm_ws_taxonomy_compose_resourcePath($path));
499 30c5a6bd Andreas Kohlbecker
}
500
501 2447830d Andreas Kohlbecker
function cdm_ws_taxonomy_compose_resourcePath($path = null){
502
  $viewrank =  _cdm_taxonomy_compose_viewrank();
503 30c5a6bd Andreas Kohlbecker
  return CDM_WS_TAXONOMY . '/' . ($viewrank ? $viewrank : '' ) . ($path ? '/' . $path : '') ;
504
}
505
506
/**
507
 * Enter description here...
508
 *
509
 * @param UUID $secUuid
510
 * @param String $path
511
 * @return unknown
512
 */
513 2447830d Andreas Kohlbecker
function cdm_ws_taxonomy_pathFromRoot($path){
514
 $viewrank =  _cdm_taxonomy_compose_viewrank();
515
 return cdm_ws_get(CDM_WS_TAXONOMY .  ($viewrank ? '/' .$viewrank : '' )  . '/' . $path . '/path' );
516 30c5a6bd Andreas Kohlbecker
}
517
518
/**
519
 * Enter description here...
520
 *
521
 * @param UUID $viewUuid
522
 * @param String $rank
523
 * @return unknown
524
 */
525 2447830d Andreas Kohlbecker
function _cdm_taxonomy_compose_viewrank(){
526
  $viewUuid = variable_get('cdm_taxonomictree_uuid', false);
527
  if(!$viewUuid){
528
    return;
529 30c5a6bd Andreas Kohlbecker
  }
530
  $rank = variable_get('taxontree_ranklimit', DEFAULT_TAXONTREE_RANKLIMIT);
531
  return $viewUuid . (empty($rank) ? '' : ','.$rank);
532 32a96ee6 Andreas Kohlbecker
}
533
534 30c5a6bd Andreas Kohlbecker
535 70fb5e15 Andreas Kohlbecker
function cdm_rankVocabulary_as_option(){
536
  global $rankVocabularyOptions;
537
  if(!$rankVocabularyOptions){
538
    $vocab = cdm_ws_get(CDM_WS_TERMVOCABULARY, UUID_RANK);
539
    $rankVocabularyOptions = array();
540
    foreach($vocab->terms as $term){
541
      $rankVocabularyOptions[$term->uuid] = t($term->representation_L10n);
542
    }
543
    array_reverse($rankVocabularyOptions);
544
  }
545
  return $rankVocabularyOptions;
546
}
547
548
549 24b09d7c Andreas Kohlbecker
function cdm_ws_descriptions_by_featuretree($featureTree, $descriptions, $isDescriptionsSeparated = false){
550
  
551
  if(!$featureTree){
552
    drupal_set_message('cdm_ws_descriptions_by_featuretree() - No feature supplied', 'error');
553
    return false;
554
  }
555
  
556 2cd9a3d6 Andreas Kohlbecker
  $mergedTrees = array(); 
557 24b09d7c Andreas Kohlbecker
  
558
  if($isDescriptionsSeparated){
559
    // merge any description into a sparate feature tree
560
    foreach($descriptions as $desc){
561
      $mergedNodes = _mergeFeatureTreeDesciptions($featureTree->root->children, $desc->elements);
562
      
563
      $mergedTree = clone $featureTree;
564
      $mergedTree->root->children = $mergedNodes;
565
      $mergedTrees[] = $mergedTree;
566
    }
567
  } else {
568
    // combine all descripions into one feature tree
569
    foreach($descriptions as $desc){
570
      $mergedNodes = _mergeFeatureTreeDesciptions($featureTree->root->children, $desc->elements);
571
      $featureTree->root->children = $mergedNodes;
572
    }
573
    $mergedTrees[] = $featureTree;
574
  }
575
  
576
 return $mergedTrees;
577
}
578
579
function _mergeFeatureTreeDesciptions($featureNodes, $descriptionElements){
580
  
581
  foreach($featureNodes as &$node){
582
    
583 2cd9a3d6 Andreas Kohlbecker
    // append corresponding elements to an additional node field: $node->descriptionElements 
584 24b09d7c Andreas Kohlbecker
    foreach($descriptionElements as $element){
585
      if($element->feature->uuid == $node->feature->uuid){
586
        if(!isset($node->descriptionElements)){
587
          $node->descriptionElements = array();
588
        }
589
        $node->descriptionElements[] = $element;
590
      }
591
    }
592
    
593
    // recurse into node children
594
    if(is_array($node->children)){
595
      foreach($node->children as $nodes){
596
        $mergedChildNodes = _mergeFeatureTreeDesciptions($nodes, $descriptionElements);
597
        $node->children = $mergedChildNodes;
598
      }
599
    }
600
    
601
  }
602
  return $featureNodes;
603
}
604
605 30c5a6bd Andreas Kohlbecker
606 4f462b79 Andreas Kohlbecker
/**
607 d96a6e06 Andreas Kohlbecker
 * Loads the XML or JSON response for the given url from the CDM Data Store Webservice.
608
 * The XML is turned into a object which is returned.
609 94112bee n.hoffmann
 *
610 24b09d7c Andreas Kohlbecker
 * @param String $uri the relative url of the web service call.
611 d96a6e06 Andreas Kohlbecker
 *        Relative means relative to the web service base url which is stored in cdm_webservice_url
612 30c5a6bd Andreas Kohlbecker
 * @param $is_multi_parameter_query parameter to indicate that the URI has queryparameters and should not be cached
613 d96a6e06 Andreas Kohlbecker
 * @return An object or false
614 4f462b79 Andreas Kohlbecker
 */
615 784a4314 Andreas Kohlbecker
616 2447830d Andreas Kohlbecker
617 784a4314 Andreas Kohlbecker
/**
618 2cd9a3d6 Andreas Kohlbecker
 * Send a HTTP GET request to the RESTService and deserializes 
619 784a4314 Andreas Kohlbecker
 * and returns the response as object
620 2cd9a3d6 Andreas Kohlbecker
 * 
621 2447830d Andreas Kohlbecker
 * @param $uri
622
 * @param $pathParameters
623
 * @param $query
624
 * @param $method the HTTP method to use, valuid values are "GET" or "POST";
625
 * @param $absoluteURI
626
 * @return unknown_type
627 784a4314 Andreas Kohlbecker
 */
628
function cdm_ws_get($uri, $pathParameters = array(), $query = null, $method="GET", $absoluteURI = false){
629 9d47d187 Andreas Kohlbecker
   
630 784a4314 Andreas Kohlbecker
  // transform the given uri path or patthern into a proper webservice uri
631
  if(!$absoluteURI){
632
    $uri = cdm_compose_url($uri, $pathParameters, $query);
633
  }
634
  
635 24b09d7c Andreas Kohlbecker
  $do_cache = variable_get('cdm_webservice_cache', 1); //strpos($uri, "?") !== FALSE; // if the url has a query parameter sting
636 9d47d187 Andreas Kohlbecker
  // only cache cdm webservice URIs
637
  $do_cache = $do_cache && str_beginsWith($uri, variable_get('cdm_webservice_url', '#EMPTY#'));
638 d96a6e06 Andreas Kohlbecker
  $cache_entry = false;
639 24b09d7c Andreas Kohlbecker
   
640 d96a6e06 Andreas Kohlbecker
  if($do_cache){
641 94112bee n.hoffmann
    // try to get object from cache
642 24b09d7c Andreas Kohlbecker
    $cache_entry = cache_get($uri, 'cache_cdm_ws');
643 d96a6e06 Andreas Kohlbecker
  }
644 32a96ee6 Andreas Kohlbecker
  
645 d96a6e06 Andreas Kohlbecker
  if(!$cache_entry){
646
    // load fresh data from webservice
647 6e1ec3a4 Andreas Kohlbecker
    $time_get_start = microtime(true);
648 030b3c6c Andreas Kohlbecker
    // request data from webservice JSON or XML
649 784a4314 Andreas Kohlbecker
    $datastr = cdm_http_request($uri, $method);
650 6e1ec3a4 Andreas Kohlbecker
    $time_get = microtime(true) - $time_get_start;
651 24b09d7c Andreas Kohlbecker
652 6e1ec3a4 Andreas Kohlbecker
    
653
    $time_parse_start = microtime(true);
654 030b3c6c Andreas Kohlbecker
    // parse data and create object
655 d96a6e06 Andreas Kohlbecker
    $obj = cdm_load_obj($datastr);
656 24b09d7c Andreas Kohlbecker
657 6e1ec3a4 Andreas Kohlbecker
    $time_parse = microtime(true) - $time_parse_start;
658 0d127818 Andreas Kohlbecker
    if(variable_get('cdm_webservice_debug', 1) && user_access('administer')){
659 2cd9a3d6 Andreas Kohlbecker
      $success_msg = $obj || $datastr == "[]" ? 'valid':'invalid'; 
660 24b09d7c Andreas Kohlbecker
      _add_debugMessage($uri, $time_get, $time_parse, strlen($datastr), $success_msg);
661 e46927b4 Andreas Kohlbecker
    }
662 2447830d Andreas Kohlbecker
    if($obj && $do_cache) {
663 d96a6e06 Andreas Kohlbecker
      // store fresh data in cache
664 24b09d7c Andreas Kohlbecker
      cache_set($uri, 'cache_cdm_ws', serialize($obj), CACHE_TEMPORARY);
665 d96a6e06 Andreas Kohlbecker
    }
666 32a96ee6 Andreas Kohlbecker
  } else {
667 d96a6e06 Andreas Kohlbecker
    $obj = unserialize($cache_entry->data);
668 0d127818 Andreas Kohlbecker
    if(variable_get('cdm_webservice_debug', 1) && user_access('administer')){
669 537134d6 Andreas Kohlbecker
      _add_status_message_toggler();
670 a5d76b99 Andreas Kohlbecker
      drupal_set_message('Using cache for: '.$uri, 'debug');
671 e46927b4 Andreas Kohlbecker
    }
672 32a96ee6 Andreas Kohlbecker
  }
673 d96a6e06 Andreas Kohlbecker
  return $obj;
674 32a96ee6 Andreas Kohlbecker
}
675
676 24b09d7c Andreas Kohlbecker
function _add_debugMessage($uri, $time_get, $time_parse, $datasize, $success_msg){
677
  
678 2447830d Andreas Kohlbecker
  static $cummulated_time_parse;
679
  static $cummulated_time_get;
680 24b09d7c Andreas Kohlbecker
  _add_status_message_toggler();
681 2447830d Andreas Kohlbecker
  
682
  $cummulated_time_get += $time_get;
683
  $cummulated_time_parse += $time_parse;
684 24b09d7c Andreas Kohlbecker
 
685 2447830d Andreas Kohlbecker
  $message = '<span class="uri">'.$uri.'</span><br />';
686
  $message .= '[fetched in: '.sprintf('%3.3f', $time_get).'s('.sprintf('%3.3f', $cummulated_time_get).'s); ';
687
  $message .= 'parsed in '.sprintf('%3.3f', $time_parse).' s('.sprintf('%3.3f', $cummulated_time_parse).'s); ';
688 24b09d7c Andreas Kohlbecker
  $message .= 'size:'.sprintf('%3.1f', ($datasize / 1024)).' kb of '.$success_msg.' data: ';
689
  $message .= '<a href="'.$uri.'.xml" target="data" class="'.$success_msg.'">xml</a>,';
690
  $message .= '<a href="'.$uri.'.json" target="data" class="'.$success_msg.'">json</a>';
691
  $message .= '] ';
692
  
693
  drupal_set_message($message, 'debug');
694
695
}
696
697 d96a6e06 Andreas Kohlbecker
698 32a96ee6 Andreas Kohlbecker
function cdm_load_obj($datastr){
699 8c19e1a5 Andreas Kohlbecker
     
700 c0ac3382 Andreas Kohlbecker
  // if the web service delivers XML convert it into json
701 32a96ee6 Andreas Kohlbecker
  if(variable_get('cdm_webservice_type', 'xml') == 'xml'){
702 94112bee n.hoffmann
    $datastr = xml2json::transformXmlStringToJson($datastr);
703 32a96ee6 Andreas Kohlbecker
  }
704 6ee322a7 Andreas Kohlbecker
  
705 24b09d7c Andreas Kohlbecker
  $obj = json_decode($datastr);
706
  
707
  
708
  if(!(is_object($obj) || is_array($obj)) ){
709 6ee322a7 Andreas Kohlbecker
    ob_start();
710
    var_dump($obj);
711
    $obj_dump = ob_get_contents();
712
    ob_clean();
713
    return false;
714
  }
715
716 812a9c04 Andreas Kohlbecker
  return $obj;
717 32a96ee6 Andreas Kohlbecker
}
718 5602a381 n.hoffmann
719 2447830d Andreas Kohlbecker
/**
720 2cd9a3d6 Andreas Kohlbecker
 * 
721 2447830d Andreas Kohlbecker
 * @param $uri
722 2cd9a3d6 Andreas Kohlbecker
 * @param $method the HTTP method to use, valuid values are "GET" or "POST"; efaults to "GET" even if null, 
723 2447830d Andreas Kohlbecker
 *        false or any invalid value is supplied.
724
 * @param $parameters
725
 * @param $header
726
 * @return unknown_type
727
 */
728 784a4314 Andreas Kohlbecker
function cdm_http_request($uri, $method="GET", $parameters = array(), $header = false){
729 d96a6e06 Andreas Kohlbecker
  global $locale;  // drupal variable containing the current locale i.e. language
730
  static $header;
731 32a96ee6 Andreas Kohlbecker
  
732 2447830d Andreas Kohlbecker
  if($method != "GET" && $method != "POST"){
733
    $method  = "GET";
734
  }
735
  
736 d96a6e06 Andreas Kohlbecker
  if(!$header){
737
    $header = array();
738 94112bee n.hoffmann
    $header[] = 'Accept: '.(variable_get('cdm_webservice_type', 'json') == 'json' ? 'application/json' : 'text/xml');
739 d96a6e06 Andreas Kohlbecker
    $header[] = 'Accept-Language: '.$locale;
740 30c5a6bd Andreas Kohlbecker
    $header[] = 'Accept-Charset: UTF-8';
741 d96a6e06 Andreas Kohlbecker
  }
742
  
743
  if(function_exists('curl_init')){
744
745
    // use the CURL lib if installed it is supposed to be 20x faster
746 784a4314 Andreas Kohlbecker
    return _http_request_using_curl($uri, $header, $method, $parameters);
747 8a60c8fc Andreas Kohlbecker
  } else {
748 784a4314 Andreas Kohlbecker
    return _http_request_using_fsockopen($uri, $header, $method, $parameters);
749 8a60c8fc Andreas Kohlbecker
  }
750
}
751
752 784a4314 Andreas Kohlbecker
function _http_request_using_fsockopen($uri, $header = array(), $method = "GET"){
753 24b09d7c Andreas Kohlbecker
  //FIXME implement get_content_fsockopen($uri);
754 784a4314 Andreas Kohlbecker
   watchdog('CDM_API', '_http_request_fsockopen - UNIMPLEMENTED', WATCHDOG_ERROR);
755 d96a6e06 Andreas Kohlbecker
   return false;
756 32a96ee6 Andreas Kohlbecker
}
757
758
759 cacc1bbf Andreas Kohlbecker
/**
760 d96a6e06 Andreas Kohlbecker
 * Return string content from a remote file
761 94112bee n.hoffmann
 *
762 24b09d7c Andreas Kohlbecker
 * @param string $uri
763 d96a6e06 Andreas Kohlbecker
 * @return string
764 94112bee n.hoffmann
 *
765 d96a6e06 Andreas Kohlbecker
 * @author Luiz Miguel Axcar (lmaxcar@yahoo.com.br)
766
*/
767 784a4314 Andreas Kohlbecker
function _http_request_using_curl($uri, $header = array(), $method = "GET", $parameters = array())
768 d96a6e06 Andreas Kohlbecker
{
769
    $ch = curl_init();
770
771 24b09d7c Andreas Kohlbecker
    curl_setopt ($ch, CURLOPT_URL, $uri);
772 d96a6e06 Andreas Kohlbecker
    // set proxy settings
773
    if(variable_get('cdm_webservice_proxy_url', false)){
774
      curl_setopt($ch, CURLOPT_PROXY, variable_get('cdm_webservice_proxy_url', ''));
775
      curl_setopt($ch, CURLOPT_PROXYPORT, variable_get('cdm_webservice_proxy_port', '80'));
776
      if(variable_get('cdm_webservice_proxy_usr', false)){
777 94112bee n.hoffmann
        curl_setopt ($ch, CURLOPT_PROXYUSERPWD, variable_get('cdm_webservice_proxy_usr', '').':'.variable_get('cdm_webservice_proxy_pwd', ''));
778 d96a6e06 Andreas Kohlbecker
      }
779
    }
780
    // set headers
781
    curl_setopt ($ch, CURLOPT_HTTPHEADER, $header);
782 5602a381 n.hoffmann
    // set method if not default
783
    if($method != "GET"){
784
      if($method == "POST"){
785
        
786
        curl_setopt ($ch, CURLOPT_POST, 1);
787
        curl_setopt ($ch, CURLOPT_POSTFIELDS, $parameters);
788
        
789
      }else{
790
        // other obscure http methods get passed to curl directly
791
        // TODO generic parameter/body handling
792
        curl_setopt ($ch, CURLOPT_CUSTOMREQUEST, $method);
793
      }
794
    }
795
    
796 d96a6e06 Andreas Kohlbecker
    ob_start();
797
    curl_exec ($ch);
798
    if(curl_errno($ch)){
799 2447830d Andreas Kohlbecker
      watchdog('CDM_API', '_http_request_curl() - '.curl_error($ch).'; REQUEST-METHOD:'.$method.' URL: '.substr($uri.' ', 0, 150), WATCHDOG_ERROR);
800 0d127818 Andreas Kohlbecker
        if(variable_get('cdm_webservice_debug', 1)  && user_access('administer') ){
801 2447830d Andreas Kohlbecker
          drupal_set_message('_http_request_curl() - '.curl_error($ch).'; REQUEST-METHOD:'.$method.' URL: '.substr($uri.' ', 0, 150), 'error');
802 d96a6e06 Andreas Kohlbecker
        }
803
    }
804 8e564bc0 n.hoffmann
    curl_close ($ch);
805
    $string = ob_get_contents();
806
    ob_end_clean();
807
 
808 94112bee n.hoffmann
    return $string;
809 32a96ee6 Andreas Kohlbecker
}
810
811 6e1ec3a4 Andreas Kohlbecker
function cdm_api_secref_cache_prefetch(&$secUuids){
812
  global $secref_cache;
813
  if(!is_array($secref_cache)){
814
    $secref_cache = array();
815
  }
816
  $uniqueUuids = array_unique($secUuids);
817
  $i = 0;
818
  $param = '';
819
  while($i++ < count($uniqueUuids)){
820
    $param .= $secUuids[$i].',';
821
    if(strlen($param) + 37 > 2000){
822
     _cdm_api_secref_cache_add($param);
823
      $param = '';
824
    }
825
  }
826
  if($param){
827
     _cdm_api_secref_cache_add($param);
828
  }
829
}
830
831
function cdm_api_secref_cache_get($secUuid){
832
  global $secref_cache;
833
  if(!is_array($secref_cache)){
834
    $secref_cache = array();
835
  }
836
  if(!array_key_exists($secUuid, $secref_cache)){
837
    _cdm_api_secref_cache_add($secUuid);
838
  }
839 94112bee n.hoffmann
  return $secref_cache[$secUuid];
840 6e1ec3a4 Andreas Kohlbecker
}
841
842
function cdm_api_secref_cache_clear(){
843
  global $secref_cache;
844
  $secref_cache = array();
845
}
846
847
function _cdm_api_secref_cache_add($secUuidsStr){
848
  global $secref_cache;
849 24b09d7c Andreas Kohlbecker
  $ref = cdm_ws_get(CDM_WS_REFERENCE, $secUuidsStr);
850
  // batch fetching not jet reimplemented thus:
851
  /*$assocRefSTOs = array();
852 ba530d73 Andreas Kohlbecker
  if($refSTOs) {
853
    foreach($refSTOs as $ref){
854
      $assocRefSTOs[$ref->uuid] = $ref;
855
    }
856
    $secref_cache = array_merge($secref_cache, $assocRefSTOs);
857 24b09d7c Andreas Kohlbecker
  }*/
858
  $secref_cache[$ref->uuid] = $ref;
859
}
860
861
function queryString($elements) {
862
  $query = '';
863
  foreach($elements as $key=>$value){
864 8934f97c Andreas Kohlbecker
    if(is_array($value)){
865
      foreach($value as $v){
866
        $query .= (strlen($query) > 0 ? '&' : '').$key.'='.urlencode($v);
867
      }
868
    } else{
869 2cd9a3d6 Andreas Kohlbecker
      $query .= (strlen($query) > 0 ? '&' : '').$key.'='.urlencode($value);      
870 8934f97c Andreas Kohlbecker
    }
871 6e1ec3a4 Andreas Kohlbecker
  }
872 24b09d7c Andreas Kohlbecker
  return $query;
873 6e1ec3a4 Andreas Kohlbecker
}
874 d96a6e06 Andreas Kohlbecker
875 6ee322a7 Andreas Kohlbecker
/**
876 fa650011 Andreas Kohlbecker
 * implementation of the magic method __clone to allow deep cloning of objects and arrays
877 32a96ee6 Andreas Kohlbecker
 */
878 24b09d7c Andreas Kohlbecker
function __clone(){
879
    foreach($this as $name => $value){
880 fa650011 Andreas Kohlbecker
        if(gettype($value)=='object' || gettype($value)=='array'){
881 24b09d7c Andreas Kohlbecker
            $this->$name= clone($this->$name);
882
        }
883
    }
884 2cd9a3d6 Andreas Kohlbecker
} 
885 32a96ee6 Andreas Kohlbecker
886 fa650011 Andreas Kohlbecker
/**
887
 * Make a complete deep copy of an array replacing
888
 * references with deep copies until a certain depth is reached
889
 * ($maxdepth) whereupon references are copied as-is...
890
 * [From http://us3.php.net/manual/en/ref.array.php]
891
 * @param $array
892
 * @param $copy
893
 * @param $maxdepth
894
 * @param $depth
895
 * @return unknown_type
896
 */
897
function array_deep_copy (&$array, &$copy, $maxdepth=50, $depth=0) {
898
    if($depth > $maxdepth) { $copy = $array; return; }
899
    if(!is_array($copy)) $copy = array();
900
    foreach($array as $k => &$v) {
901
        if(is_array($v)) {        array_deep_copy($v,$copy[$k],$maxdepth,++$depth);
902
        } else {
903
            $copy[$k] = $v;
904
        }
905
    }
906
}
907
908 32a96ee6 Andreas Kohlbecker
/**
909 2cd9a3d6 Andreas Kohlbecker
 * Implementation of theme_status_messages($display = NULL) 
910 24b09d7c Andreas Kohlbecker
 * @see includes/theme.inc
911 2cd9a3d6 Andreas Kohlbecker
 * 
912 24b09d7c Andreas Kohlbecker
 * @param $display
913
 * @return unknown_type
914 32a96ee6 Andreas Kohlbecker
 */
915 24b09d7c Andreas Kohlbecker
function _add_status_message_toggler() {
916
  static $isAdded;
917
  if(!$isAdded){
918
    
919
    drupal_add_js(
920
          '$(document).ready(function(){
921
          
922 784a4314 Andreas Kohlbecker
            $(\'.messages.debug\').before( \'<h6 class="messages_toggler debug">Debug Messages (klick to toggle)</h6>\' );
923 24b09d7c Andreas Kohlbecker
            $(\'.messages_toggler\').click(function(){
924
              $(this).next().slideToggle(\'fast\');
925
                return false;
926
            }).next().hide();
927
            
928
          });'
929
          , 'inline');
930 2cd9a3d6 Andreas Kohlbecker
    $isAdded = TRUE;      
931 24b09d7c Andreas Kohlbecker
  }
932
}
933
934 2cd9a3d6 Andreas Kohlbecker
define('CDM_WS_MEDIA', 'portal/media');
935 24b09d7c Andreas Kohlbecker
936 6ee322a7 Andreas Kohlbecker
define('CDM_WS_NAME', 'name');
937 32a96ee6 Andreas Kohlbecker
938 24b09d7c Andreas Kohlbecker
define('CDM_WS_NAME_TYPEDESIGNATIONS', 'name/$0/typeDesignations');
939
940
define('CDM_WS_TAXON_NAMETYPEDESIGNATIONS', 'portal/taxon/$0/nameTypeDesignations');
941
942
define('CDM_WS_TAXON_DESCRIPTIONS', 'portal/taxon/$0/descriptions');
943
944
define('CDM_WS_NAME_DESCRIPTIONS', 'portal/name/$0/descriptions');
945 32a96ee6 Andreas Kohlbecker
946 46a52efe Andreas Kohlbecker
define('CDM_WS_REFERENCE', 'reference');
947
948 70fb5e15 Andreas Kohlbecker
define('CDM_WS_NOMENCLATURAL_REFERENCE_CITATION', 'reference/$0/nomenclaturalCitation/$1');
949
950 24b09d7c Andreas Kohlbecker
define('CDM_WS_FIND_TAXA', 'portal/taxon/find');
951
952
define('CDM_WS_TAXON', 'portal/taxon');
953 8c19e1a5 Andreas Kohlbecker
954 6ee322a7 Andreas Kohlbecker
/**
955 24b09d7c Andreas Kohlbecker
 * @parameters $0 : the taxon uuid
956 2cd9a3d6 Andreas Kohlbecker
 * 
957
 * @returns 
958 6ee322a7 Andreas Kohlbecker
 */
959 24b09d7c Andreas Kohlbecker
define('CDM_WS_TAXON_SYNONYMY', 'portal/taxon/$0/synonymy');
960
961
define('CDM_WS_TAXON_RELATIONS', 'portal/taxon/$0/taxonRelationships');
962
963
define('CDM_WS_TAXON_NAMERELATIONS', 'portal/taxon/$0/nameRelationships');
964
965 32a96ee6 Andreas Kohlbecker
966 6ee322a7 Andreas Kohlbecker
/**
967 24b09d7c Andreas Kohlbecker
 * @parameters $0 : the taxon uuid
968 2cd9a3d6 Andreas Kohlbecker
 * 
969 24b09d7c Andreas Kohlbecker
 * @returns the taxon which is the accepted synonym for the taxon given as
970 bbf2df83 Andreas Kohlbecker
 * parameter taxonUuid. If the taxon specified by taxonUuid is itself the
971
 * accepted taxon, this one will be returned.
972 6ee322a7 Andreas Kohlbecker
 */
973 9ee2882b Andreas Kohlbecker
define('CDM_WS_TAXON_ACCEPTED', 'portal/taxon/$0/accepted');
974 bd6b2769 Andreas Kohlbecker
975 784a4314 Andreas Kohlbecker
define('CDM_WS_TAXON_MEDIA', 'portal/taxon/$0/media/$1/$2');
976
977 6ee322a7 Andreas Kohlbecker
/**
978 94112bee n.hoffmann
 *
979 bbf2df83 Andreas Kohlbecker
 * Gets the root nodes of the taxonomic concept tree for the concept
980
 * reference specified by the secUuid parameter.
981 94112bee n.hoffmann
 *
982 a22e3f38 Andreas Kohlbecker
 * stub: treenode_root
983 6ee322a7 Andreas Kohlbecker
 */
984 2cd9a3d6 Andreas Kohlbecker
define('CDM_WS_TAXONOMY', 'portal/taxontree');
985 2447830d Andreas Kohlbecker
986
define('CDM_WS_TERMVOCABULARY', 'term/$0');
987 8934f97c Andreas Kohlbecker
988 70fb5e15 Andreas Kohlbecker
define('CDM_WS_TERM_COMPARE', 'term/$0/compareTo/$1');
989
990 8934f97c Andreas Kohlbecker
define('CDM_WS_TDWG_LEVEL', 'term/tdwg/$0');
991 d93dad11 n.hoffmann
992
/**
993
 * returns FeatureTrees that are stored in this community store
994
 *
995
 */
996 24b09d7c Andreas Kohlbecker
define('CDM_WS_FEATURETREE', 'featuretree/$0');
997
998
define('CDM_WS_FEATURETREES', 'featuretree');
999 8a60c8fc Andreas Kohlbecker
1000
define('CDM_WS_GEOSERVICE_DISTRIBUTIONMAP', 'geo/map/distribution/$0');