Revision e3d8e63e
Added by Niels Hoffmann over 11 years ago
7.x/modules/dwca_export/dwca_export.module | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
|
3 |
define ("CSV_FILE_EXTENSION", ".txt"); |
|
4 | 3 |
// at the moment we are using a static meta.xml file |
5 |
define ("METADATA_FILE", "meta.xml"); |
|
6 |
|
|
4 |
define ("METADATA_FILE_NAME", "meta.xml");
|
|
5 |
define ("STATIC_DIR", "/static/"); |
|
7 | 6 |
define ("ARCHIVE_ROOT_DIR", "dwca_export/"); |
8 | 7 |
|
9 |
function _get_static_file_map(){ |
|
8 |
function _dwca_export_get_static_file_map(){
|
|
10 | 9 |
$static_file_map = array( |
11 |
'classification' => array( |
|
10 |
'classification.txt' => array(
|
|
12 | 11 |
'view_name'=> 'dwca_export_classification', |
13 | 12 |
'display_id' => 'views_data_export_1', |
14 | 13 |
'out_file_url' => NULL |
15 | 14 |
), |
16 |
'typesandspecimen' => array( |
|
15 |
'typesandspecimen.txt' => array(
|
|
17 | 16 |
'view_name'=> 'view_test_specimen_export', |
18 | 17 |
'display_id' => 'views_data_export_1', |
19 | 18 |
'out_file_url' => NULL |
... | ... | |
112 | 111 |
'#default_value' => $view_data['view_name'], |
113 | 112 |
'#size' => 60, |
114 | 113 |
'#maxlength' => 64, |
115 |
'#description' => t('specify view for ' . $dwca_filename . CSV_FILE_EXTENSION),
|
|
114 |
'#description' => t('specify view for ' . $dwca_filename), |
|
116 | 115 |
); |
117 | 116 |
} |
118 | 117 |
|
... | ... | |
161 | 160 |
if(!isset($file_map)){ |
162 | 161 |
//TODO load from variables, consider using strongarm |
163 | 162 |
// current implementation uses a static filemap |
164 |
$file_map = _get_static_file_map(); |
|
163 |
$file_map = _dwca_export_get_static_file_map();
|
|
165 | 164 |
} |
166 | 165 |
|
167 | 166 |
if($file_name && $out_file_url){ |
... | ... | |
214 | 213 |
$result = $zip->open(drupal_realpath($tmp_archive_file_name), ZipArchive::CREATE); |
215 | 214 |
|
216 | 215 |
// there might be a better way to get at this information |
217 |
$module_static_dir_absolute = realpath(drupal_get_path('module', 'dwca_export')) . "/static/";
|
|
216 |
$module_static_dir_absolute_path = realpath(drupal_get_path('module', 'dwca_export')) . STATIC_DIR;
|
|
218 | 217 |
|
219 | 218 |
if ($result !== TRUE) { |
220 | 219 |
throw new Exception(t('Could not create zip_archive %tmp_archive_file_name', array('%tmp_archive_file_name' => $tmp_archive_file_name))); |
... | ... | |
222 | 221 |
|
223 | 222 |
|
224 | 223 |
// add metadata |
225 |
$zip->addFile($module_static_dir_absolute.$metadata, ARCHIVE_ROOT_DIR.METADATA_FILE);
|
|
224 |
$zip->addFile($module_static_dir_absolute_path.METADATA_FILE_NAME, ARCHIVE_ROOT_DIR.METADATA_FILE_NAME);
|
|
226 | 225 |
// add the csv data files |
227 | 226 |
foreach(_dwca_export_archive_descriptor_file_map() as $dwca_filename=>$view_data){ |
228 | 227 |
|
229 | 228 |
$view_temp_file = $view_data['out_file_url']; |
230 | 229 |
if($view_temp_file){ |
231 |
$zip->addFile(drupal_realpath($view_temp_file), ARCHIVE_ROOT_DIR.$dwca_filename.CSV_FILE_EXTENSION);
|
|
230 |
$zip->addFile(drupal_realpath($view_temp_file), ARCHIVE_ROOT_DIR.$dwca_filename); |
|
232 | 231 |
}else{ |
233 |
throw new Exception(t('Cannot create %file', array('%file' => $dwca_filename.CSV_FILE_EXTENSION)));
|
|
232 |
throw new Exception(t('Cannot create %file', array('%file' => $dwca_filename))); |
|
234 | 233 |
} |
235 | 234 |
} |
236 | 235 |
|
Also available in: Unified diff
renamed a function