'application/zip' )); }else{ drupal_set_message('The Darwincore Arhive for this site has not yet been created'); drupal_goto('/'); } } /** * Form function, called by drupal_get_form() * in dwca_export_menu(). */ function dwca_export_config_form($form, &$form_state){ global $base_url; $form['dwca_export_info'] = array( '#markup' => '
For general information on the DarwinCore Archive format please refer to ' . l('GBIF - Standards and Tools - Darwin Core Archives', 'http://www.gbif.org/informatics/standards-and-tools/publishing-data/data-standards/darwin-core-archives/') . '
' ); $form['dwca_export_execute'] = array( '#markup' => 'The DarwinCore Archive export can be downloaded from ' . l(url('dwca.zip', array( 'absolute' => TRUE )), 'dwca.zip') . '
' ); $form['dwca_export_view_mapping'] = dwca_export_select_view_form(); $form['#submit'][] = 'dwca_export_config_form_submit'; return system_settings_form($form); } function dwca_export_select_view_form(){ $views = array( '#type' => 'fieldset', '#title' => t('View to file mapping') ); //'#tree' => TRUE, foreach(variable_get(FILE_MAP, 'dwca_export_archive_descriptor_file_map') as $dwca_filename => $view_data){ if($dwca_filename == 'description'){ $views[$dwca_filename] = array( '#type' => 'fieldset', '#title' => t('DESCRIPTIVE DATA TYPES'), '#weight' => 3, '#collapsible' => TRUE, '#collapsed' => TRUE, //'#prefix' => '' . $key . ' ' . $value . '
'; }else{ $description_key = 'description'; if(array_key_exists($description_key, $dwca_export_archive_descriptor_file_map)){ //get the inner array containing the different description data types $description_map = $dwca_export_archive_descriptor_file_map[$description_key]; if(array_key_exists($key, $description_map)){ $dwca_export_archive_descriptor_file_map[$description_key][$key]['view_name'] = $value; } } } } variable_del(FILE_MAP); variable_set(FILE_MAP, $dwca_export_archive_descriptor_file_map); } /** * Validate function for the above form. * * Reports an error if view name entered by the user does not exist in the * database. */ function dwca_export_config_form_validate($form, &$form_state){ $variables = $form_state['input']; $dwca_export_archive_descriptor_file_map = variable_get(FILE_MAP); $view_names = array(); $missing_view_names = ''; $missing_view = false; foreach($variables as $key => $value){ //TODO: Check whether the views for the inner array cotaining all the description views exist if(array_key_exists($key, $dwca_export_archive_descriptor_file_map)){ $view = views_get_view($value); // check whether there is a view named with this value if(!$view){ $view_names[] = $value; $missing_view_names .= $value . ', '; $missing_view = true; } } } if($missing_view){ form_set_error('', t('VIEW(S) ' . $missing_view_names . ' NOT FOUND. Please input another view name.')); } }