Project

General

Profile

« Previous | Next » 

Revision d946105e

Added by Andreas Kohlbecker over 16 years ago

View differences:

.gitattributes
3 3
module_patches/nodefamily/nodefamily_create-others-nodes.patch -text
4 4
modules/cdm_dataportal/cdm/cdm_api.php -text
5 5
modules/cdm_dataportal/cdm/ws_stub/README.txt -text
6
modules/cdm_dataportal/cdm/ws_stub/xml/name%2F%3Fuuid%3Duuid.xml -text
6 7
modules/cdm_dataportal/cdm_dataportal.info -text
7 8
modules/cdm_dataportal/cdm_dataportal.module -text
8 9
modules/cdm_dataportal/cdm_dataportal.theme.php -text
modules/cdm_dataportal/cdm/cdm_api.php
25 25
   return $out;
26 26
}
27 27

  
28
/**
29
 * @return string
30
 * @param string $url
31
 * @desc Return string content from a remote file
32
 * @author Luiz Miguel Axcar (lmaxcar@yahoo.com.br)
33
*/
34
function get_content($url)
35
{
36
    $ch = curl_init();
37

  
38
    curl_setopt ($ch, CURLOPT_URL, $url);
39
    curl_setopt ($ch, CURLOPT_HEADER, 0);
40

  
41
    ob_start();
42

  
43
    curl_exec ($ch);
44
    curl_close ($ch);
45
    $string = ob_get_contents();
46

  
47
    ob_end_clean();
48
   
49
    return $string;    
50
}
51

  
28 52
/**
29 53
 * Loads the XML response for the given url from the CDM Data Store Webservice.
30 54
 * The XML is turned into a object wich is retuned. Incase of an error a 
......
38 62
 */
39 63
function cdm_ws_load($url){
40 64

  
41
  $obj = simplexml_load_file(variable_get('cdm_webservice_url', '').$url);
65
  if(variable_get('cdm_webservice_isStub', 0)){
66
    $url = urlencode($url);
67
  }
68
  
69
  //TODO get_content() requires the php curl extension to be installed, maybe we should chose an other function
70
  $data = get_content($url);
71
  
72

  
73
  
42 74
  if(!$obj){
43 75
    $backtrace = debug_backtrace();
44 76
    watchdog('CDM', $backtrace[1]['function'].' - failed to load '.$url, WATCHDOG_ERROR);
45 77
  }
78
  $obj->ws_url = $url;
79
  
46 80
  return $obj;
47 81
}
48 82

  
83

  
49 84
/**
50 85
 * The whatis service returns the type 
51 86
 * i.e. DTO class name and simplename & cdm class name and simplename of the instance referenced by the $uuid parameter. 
modules/cdm_dataportal/cdm/ws_stub/xml/name%2F%3Fuuid%3Duuid.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<NameTO>
3
	<uuid>987129837</uuid>
4
	<fullname>Acanthocephalus Kar. & Kir.</fullname>
5
	<taggedName>
6
		<TaggedText>
7
			<tag>name</tag>
8
			<text>Acanthocephalus</text>
9
		</TaggedText>
10
		<TaggedText>
11
			<tag>Kar. & Kir.</tag>
12
			<text>Acanthocephalus</text>
13
		</TaggedText>
14
	</taggedName>
15
	<nomenclaturalReference>
16
		in Bull. Soc. Imp. Naturalistes Moscou 15: 127. 1842
17
	</nomenclaturalReference>
18
</NameTO>
modules/cdm_dataportal/cdm_dataportal.module
76 76
  return $items;
77 77
}
78 78

  
79
/**
80
 * Implementation of hook_block()
81
 * 
82
 * Provides the following blocks:
83
 *  0: list of links useful during development
84
 *
85
 * @param String $op
86
 * @param int $delta
87
 */
88
function cdm_dataportal_block($op='list', $delta=0) {
89
  // listing of blocks, such as on the admin/block page
90
  if ($op == "list") {
91
    $block[0]["info"] = t("CDM DataPortal DevLinks");
92
    return $block;
93
  }
94
  else if ($op == 'view') {
95
    switch($delta){
96
      case 0:
97
        $block['subject'] = t('CDM DataPortal DevLinks');
98
        $block['content'] = '<ul><li>'.l('Taxon Page', 'cdm_dataportal/taxon/uuid').'</li><li>'.l('Name List', 'cdm_dataportal/names').'</li></ul>';
99
        return $block;
100
    }
101
  }
102
}
103

  
79 104

  
80 105
/**
81 106
 * Implementation of hook_validate()
......
83 108
 * @param $element
84 109
 */
85 110
function cdm_webservice_url_validate($element){
86
  if (!str_endsWith($element['#value'], $str_end)) {
111
  if (!str_endsWith($element['#value'], '/')) {
87 112
      form_set_error('cdm_webservice_url', t("The URL to the CDM Web Service must end with a slash: '/'."));
88 113
    }
89 114
}
......
100 125
function cdm_dataportal_settings(){
101 126

  
102 127
   //TODO: settings are still incomplete, compare with trunk/dataportal/inc/config_default.php.inc
103
   
104
   $form['cdm_webservice_url'] =  array(
128
    $form['cdm_webservice'] = array(
129
      '#type' => 'fieldset',
130
      '#title' => t('CDM Web Servic'),
131
      '#collapsible' => FALSE,
132
      '#collapsed' => TRUE,
133
    );
134
  
135
   $form['cdm_webservice']['cdm_webservice_url'] =  array(
105 136
    '#type' => 'textfield',
106
    '#title'         => t('CDM Store Webservice'),
107
    '#default_value' => variable_get('cdm_webservice_url', 'none'),
108
    '#description'   => t('The URL to Webservice of the CDM Store which is to be published.'),
109
     // #validate is set by default in form.inc#L334 to cdm_webservice_url_validate, if 
110
    '#validate'      => array('_cdm_form_validate_endswith' => array('/', 'cdm_webservice_url')),
137
    '#title'         => t('CDM Web Service URL'),
138
    '#description'   => t('The URL of CDM Webservice which delivers the data to be published.'),
139
    '#default_value' => variable_get('cdm_webservice_url', 'http://dev.e-taxonomy.eu/svn/trunk/drupal/modules/cdm_dataportal/cdm/ws_stub/xml/'),
111 140
    );
112 141
    
113
   return $form;
142
    $form['cdm_webservice']['cdm_webservice_isStub'] =  array(
143
    '#type' => 'checkbox',
144
    '#title'         => t('Use Web Service Stub'),
145
    '#default_value' => variable_get('cdm_webservice_isStub', 1),
146
    '#description'   => t('Use a static web service stub. Only for development. For further information please refer to the ')
147
                      .l('ws_stub/README.txt', 'http://dev.e-taxonomy.eu/svn/trunk/drupal/modules/cdm_dataportal/cdm/ws_stub/README.txt', array('target'=>'_blank')),
148
    );
149
   
150
   return system_settings_form($form);
114 151
}
115 152

  
116 153

  
......
143 180
 *
144 181
 * @param $name_uuid the $name_uuid of the taxon name 
145 182
 */
146
function cdm_dataportal_view_taxon($name_uuid){
183
function cdm_dataportal_view_taxon($uuid){
147 184
  //FIXME this is a dummy implementation
148
  $name = cdm_ws_get_name();
185
  $name = cdm_ws_get_name($uuid);
149 186
  return theme('cdm_name', $name);
150 187
  // END of dummy implementation
151 188
}
modules/cdm_dataportal/cdm_dataportal.theme.php
28 28
 *  
29 29
 * @param NameTO $nameTO the taxon name
30 30
 */
31
function theme_cdm_name(NameTO $nameTO){
31
function theme_cdm_name($nameTO){
32 32
    //TODO: how to respect the different subtypes of eu.etaxonomy.cdm.model.name.TaxonNameBase ?
33
    return cdm_taggedtext2html($nameTO->taggedName, 'span');
33
    $out = '<h2>Dummy content</h2>';
34
    if($nameTO){
35
       $out .= '<pre>'.print_r($nameTO, true).'</pre>';
36
      $out .= '<div>'.$nameTO->ws_url.'</div>';
37
      //$out .= '<div>'.cdm_taggedtext2html($nameTO->taggedName).'</div>';
38
    } else {
39
      $out .= '<div>Item not found</div>';
40
    }
41
    return $out;
34 42
}
35 43

  
36 44
/**

Also available in: Unified diff