Project

General

Profile

Download (2.49 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
// $Id$
3

    
4
/**
5
 * @file
6
 * Functions which are required or useful when accessing and processing CDM Data Store Webservices
7
 * 
8
 * Naming conventions:
9
 * ----------------------
10
 * 
11
 *  - all webservice access methods are prefixed with cdm_ws
12
 */
13

    
14
/**
15
 * Enter description here...
16
 *
17
 * @param unknown_type $tag
18
 * @return unknown
19
 */
20
function cdm_taggedtext2html(array $taggedText, $tag = 'span'){
21
   foreach($taggedText as $class=>$value){
22
     $out .= '<'.$tag.' class="'.$class.'">'.$value.'</ '.$tag.'>';
23
   }
24
   return $out;
25
}
26

    
27
/**
28
 * Loads the XML response for the given url from the CDM Data Store Webservice.
29
 * The XML is turned into a object wich is retuned. Incase of an error a 
30
 * approriate watchdog message is generated and the function returns false.
31
 * 
32
 * 
33
 *
34
 * @param String $url the relative url of the web service call. 
35
 *        Relative means relative to the web service base url which is stored in cdm_webservice_url
36
 * @return An object or false
37
 */
38
function cdm_ws_load($url){
39

    
40
  $obj = simplexml_load_file(variable_get('cdm_webservice_url', '').$url);
41
  if(!$obj){
42
    $backtrace = debug_backtrace();
43
    watchdog('CDM', $backtrace[1]['function'].' - failed to load '.$url, WATCHDOG_ERROR);
44
  }
45
  return $obj;
46
}
47

    
48
/**
49
 * The whatis service returns the type 
50
 * i.e. DTO class name and simplename & cdm class name and simplename of the instance referenced by the $uuid parameter. 
51
 * 
52
 *
53
 * @param unknown_type $uuid
54
 * @return false if the cdm store contains no matching instance. An associative array with the following key-value pairs:
55
 *   - 'cdmName':       name of the cdm class as returned by Class.getName(), e.g. eu.etaxonomy.cdm.model.taxon.Taxon
56
 *   - 'cdmSimpleName': simple name of the cdm class as returned by Class.getSimpleName(), e.g. Taxon
57
 *   - 'dtoName':       name of the DTO class as returned by Class.getName(), e.g. eu.etaxonomy.cdm.dto.TaxonTO
58
 *   - 'dtoSimpleName': simple name of the TDO class as returned by Class.getSimpleName(), e.g. TaxonTO
59
 */
60
function cdm_ws_whatis($uuid){
61
  return cdm_ws_load("whatis/?uuid=$uuid");
62
}
63

    
64
/**
65
 * load a name from the CDM Webservice
66
 *
67
 * @param String $uuid
68
 * @return a NameTO instance or false 
69
 */
70
function cdm_ws_get_nameTO($uuid){
71
  return cdm_ws_load("name/?uuid=$uuid");
72
}
73

    
74
/**
75
 * load a list of names from the CDM Webservice
76
 *
77
 * @param unknown_type $page
78
 * @param unknown_type $hide_unaccepted
79
 */
80
function cdm_ws_nameTO_list($page = 1, $hide_unaccepted){
81
   
82
}
    (1-1/1)