Revision fe095dd7
Added by Lorna Morris over 11 years ago
7.x/modules/dwca_export_views/dwca_export_views.module | ||
---|---|---|
180 | 180 |
|
181 | 181 |
foreach ($field_term_map as $key => $value) { |
182 | 182 |
|
183 |
$term_array[$key] = array(); |
|
184 |
|
|
185 |
//drupal_set_message(t(' THE key... ') . $key); |
|
183 | 186 |
//if the value is an array with key names dwca_export_ |
184 | 187 |
if ( (array) $value === $value ) { |
185 | 188 |
|
186 | 189 |
foreach ($value as $key2 => $value2) { |
187 | 190 |
|
188 |
drupal_set_message(t(' THE key2... ') . $key);
|
|
191 |
/////////drupal_set_message(t(' THE key2... ') . $key2);
|
|
189 | 192 |
//$term_array[] = $key; |
190 |
$term_array[$key] = array(); |
|
193 |
//////////////////////////////////////////////$term_array[$key] = array();
|
|
191 | 194 |
if (substr($key, 0, 11) == 'dwca_export') { |
192 | 195 |
|
193 | 196 |
$term_array[$key][] = $value2; |
194 |
//$index = current($field_term_map); |
|
195 |
drupal_set_message(t(' THE value IS... ') . $value2); |
|
196 | 197 |
} |
197 | 198 |
} |
198 |
} |
|
199 |
} |
|
200 |
|
|
199 | 201 |
} |
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
|
204 | 202 |
|
205 | 203 |
//check if the array size is the same as the number of fields in the meta.xml for either the |
206 | 204 |
//core or the particular extension |
... | ... | |
218 | 216 |
|
219 | 217 |
$core_string = $meta_string->core->files->location[0]; |
220 | 218 |
$classification_view_name = "dwca_export_" . substr($core_string, 0, -4); |
221 |
//echo $classification_view_name; |
|
222 |
echo "Theclassviewnameis:" . $classification_view_name . "\n"; |
|
223 |
drupal_set_message(t(' THE class view name is ') . $classification_view_name); |
|
224 | 219 |
|
225 | 220 |
//the first position in the dwca is always the id and this doesn't point to a term so use the empty string |
226 | 221 |
$views[$classification_view_name][0] = ''; |
227 | 222 |
|
228 | 223 |
//set the core node of the meta.xml with dwca_export_classifcation values from the form |
229 |
//currently we're relying on the order of fields in the view corresponding to the order of fields in the meta.xml
|
|
224 |
//currently we're relying on the order of fields in the view to correspond to the order of fields in the meta.xml
|
|
230 | 225 |
|
231 | 226 |
//in the meta.xml id index="0" fields start at index 1 |
232 | 227 |
$index = 1; |
... | ... | |
234 | 229 |
foreach($meta_string->core->field as $field) |
235 | 230 |
{ |
236 | 231 |
$term = (string)$field[@term]; |
237 |
//drupal_set_message(t(' THE META TERM IS ') . $term); |
|
238 |
//$field[@term] = $field_term_map['name_1']; |
|
239 |
$field[@term] = $term_array['dwca_export_classification'][$index]; |
|
232 |
|
|
233 |
if (isset($term_array['dwca_export_classification'][$index])) { |
|
234 |
$field[@term] = $term_array['dwca_export_classification'][$index]; |
|
235 |
} |
|
236 |
|
|
240 | 237 |
$index++; |
241 | 238 |
//$views[$classification_view_name][] = $term; |
242 | 239 |
} |
243 | 240 |
|
244 |
$index = 1; |
|
245 | 241 |
|
242 |
|
|
243 |
//only modify the extensions which have been modified in the form |
|
246 | 244 |
foreach($meta_string->extension as $extension) |
247 | 245 |
{ |
248 | 246 |
//echo $extension->files->location[0] . "\n"; |
249 |
$extension_string = $extension->files->location[0] . "\n"; |
|
250 |
|
|
247 |
$extension_string = $extension->files->location[0] . "\n"; |
|
251 | 248 |
$extension_view_name = "dwca_export_" . substr($extension_string, 0, -5); |
252 | 249 |
//echo "The ext view name is:" . $classification_view_name . "\n"; |
253 |
drupal_set_message(t(' THE ext view name is ') . $extension_view_name); |
|
254 |
echo "Theclassviewnameis:" . $classification_view_name . "\n"; |
|
250 |
//drupal_set_message(t(' THE ext view name is ') . $extension_view_name); |
|
251 |
|
|
252 |
if ( array_key_exists($extension_view_name, $term_array)) { |
|
255 | 253 |
$views[$extension_view_name][0] = ''; |
256 |
|
|
257 |
foreach($extension->field as $field) |
|
258 |
{ |
|
259 |
$term = (string)$field[@term]; |
|
260 |
//$views[$extension_view_name][] = $term; |
|
261 |
$field[@term] = $term_array[$extension_view_name][$index]; |
|
262 |
$index++; |
|
254 |
|
|
255 |
$index2 = 1; |
|
256 |
|
|
257 |
foreach($extension->field as $field2) |
|
258 |
{ |
|
259 |
$term = (string)$field2[@term]; |
|
260 |
//$views[$extension_view_name][] = $term; |
|
261 |
if (isset($term_array[(string)$extension_view_name][$index2])) { |
|
262 |
$field2[@term] = $term_array[(string)$extension_view_name][$index2]; |
|
263 |
} |
|
264 |
$index2++; |
|
265 |
} |
|
263 | 266 |
} |
264 | 267 |
} |
265 | 268 |
|
266 | 269 |
// Saving the whole modified XML to a new filename |
267 |
$meta_string->asXml('updated.xml'); |
|
270 |
$meta_string->asXml('updated_meta.xml');
|
|
268 | 271 |
//$meta_string->asXml($xml_file); |
269 | 272 |
|
270 |
drupal_set_message(t('UPDATE THE META XML file WITH THE VALUES COLLECTED: <pre>@result</pre>', array('@num' => 1, '@result' => print_r($field_term_map, TRUE))));
|
|
273 |
//drupal_set_message(t('VALUES: <pre>@result</pre>', array('@num' => 1, '@result' => print_r($term_array, TRUE))));
|
|
271 | 274 |
} |
272 | 275 |
|
273 | 276 |
//TODO Lorna - could we modify this method with a boolean to indicate whether we want to create the map or whether we want to modify the xml with values in the map |
... | ... | |
319 | 322 |
foreach($meta_string->children() as $child) |
320 | 323 |
{ |
321 | 324 |
// core or extension |
322 |
//echo $child->getName() . ": " . $child . "<br />"; |
|
323 |
|
|
324 | 325 |
//foreach($child->children() as $child2) |
325 | 326 |
//{ |
326 | 327 |
// core or extension |
... | ... | |
487 | 488 |
|
488 | 489 |
// In this case we've completed the final page of the wizard, so process the |
489 | 490 |
// submitted information. |
490 |
drupal_set_message(t('This information was collected by this wizard:')); |
|
491 | 491 |
foreach ($form_state['step_information'] as $index => $value) { |
492 | 492 |
// Remove FAPI fields included in the values (form_token, form_id and form_build_id |
493 | 493 |
// This is not required, you may access the values using $value['stored_values'] |
Also available in: Unified diff
Finished creating the form to modify the terms in the met.xml according to user input.