You are here

function patterns_import_submit in Patterns 6.2

Same name and namespace in other branches
  1. 5 patterns.module \patterns_import_submit()
  2. 6 patterns.module \patterns_import_submit()
  3. 7.2 includes/forms/import.inc \patterns_import_submit()
  4. 7 includes/forms/import.inc \patterns_import_submit()
3 string references to 'patterns_import_submit'
patterns_import_file in ./patterns.module
Display the import pattern file form
patterns_import_source in ./patterns.module
Display the import pattern form
patterns_import_url in ./patterns.module
Display the import pattern url form

File

./patterns.module, line 636
Enables extremely simple adding/removing features to your site with minimal to no configuration

Code

function patterns_import_submit($form, &$form_state) {
  if (isset($form_state['pattern_file'])) {
    $saved = file_copy($form_state['pattern_file']->filepath, $form_state['pattern_file']->destination);
  }
  else {
    if ($form_state['values']['xmlsource']) {
      $saved = file_save_data($form_state['values']['xmlsource'], variable_get('patterns_save_xml', 'patterns') . '/' . $form_state['values']['xmlname'] . '.xml', FILE_EXISTS_REPLACE);
    }
  }
  if ($saved) {

    // Reload patterns
    patterns_get_patterns(true);
    drupal_set_message('Pattern successfully imported.');
  }
  else {
    drupal_set_message("File couldn't be saved on the server. Import failed.", 'error');
  }
  $form_state['redirect'] = 'admin/build/patterns';
}