1 |
1 |
<?php
|
2 |
2 |
// $Id$
|
3 |
3 |
|
4 |
|
//TODO if required outsource all theme functions and uncomment next line
|
5 |
|
//require_once('cdm_dataportal.theme.php');
|
|
4 |
require_once('cdm_dataportal.theme.php');
|
6 |
5 |
|
7 |
6 |
/* ====================== hook implementations ====================== */
|
8 |
7 |
|
... | ... | |
78 |
77 |
}
|
79 |
78 |
|
80 |
79 |
|
|
80 |
/**
|
|
81 |
* Implementation of hook_validate()
|
|
82 |
*
|
|
83 |
* @param $element
|
|
84 |
*/
|
|
85 |
function cdm_webservice_url_validate($element){
|
|
86 |
if (!str_endsWith($element['#value'], $str_end)) {
|
|
87 |
form_set_error('cdm_webservice_url', t("The URL to the CDM Web Service must end with a slash: '/'."));
|
|
88 |
}
|
|
89 |
}
|
|
90 |
|
|
91 |
|
81 |
92 |
/* ====================== menu callback functions ====================== */
|
82 |
93 |
|
83 |
94 |
/**
|
... | ... | |
95 |
106 |
'#title' => t('CDM Store Webservice'),
|
96 |
107 |
'#default_value' => variable_get('cdm_webservice_url', 'none'),
|
97 |
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')),
|
98 |
111 |
);
|
99 |
112 |
|
100 |
113 |
return $form;
|
101 |
114 |
}
|
102 |
115 |
|
|
116 |
|
103 |
117 |
/**
|
104 |
118 |
* Displays a list of the known taxonomic names. Long lists are split up into multiple pages
|
105 |
119 |
*
|
... | ... | |
120 |
134 |
return $out;
|
121 |
135 |
}
|
122 |
136 |
|
|
137 |
|
123 |
138 |
/**
|
124 |
139 |
* The taxon page gives detailed information on a taxon, it shows:
|
125 |
140 |
* - Taxon name
|
... | ... | |
134 |
149 |
return theme('cdm_name', $name);
|
135 |
150 |
// END of dummy implementation
|
136 |
151 |
}
|
137 |
|
|
138 |
152 |
|
139 |
|
/* ====================== theme functions ====================== */
|
|
153 |
|
|
154 |
/* ====================== other functions ====================== */
|
|
155 |
|
|
156 |
|
|
157 |
/**
|
|
158 |
* @param $str the string to truncate
|
|
159 |
* @param $len the maximun length
|
|
160 |
* @param $appendix an optional appendix.
|
|
161 |
*
|
|
162 |
* @return the string truncated to the specified length or the original string as given as parameter.
|
|
163 |
* if an appendix has been defined the resulting string
|
|
164 |
* will have the specified length inculding the the appendix.
|
|
165 |
*/
|
|
166 |
function str_trunk(&$str, $len, $appendix=''){
|
|
167 |
if(strlen($str) >= $len )
|
|
168 |
return substr($str, 0, $len - strlen($appendix)).$appendix;
|
|
169 |
else
|
|
170 |
return $str;
|
|
171 |
}
|
|
172 |
|
|
173 |
/**
|
|
174 |
* @param string $str
|
|
175 |
* @param string $sub
|
|
176 |
* @return boolean
|
|
177 |
*/
|
|
178 |
function str_beginsWith( $str, $sub ) {
|
|
179 |
return ( substr( $str, 0, strlen( $sub ) ) === $sub );
|
|
180 |
}
|
|
181 |
|
|
182 |
/**
|
|
183 |
*
|
|
184 |
* @param string $str
|
|
185 |
* @param string $sub
|
|
186 |
* @return boolean
|
|
187 |
*/
|
|
188 |
function str_endsWith( $str, $sub ) {
|
|
189 |
return ( substr( $str, strlen( $str ) - strlen( $sub ) ) === $sub );
|
|
190 |
}
|