You are here

function patterns_import_submit in Patterns 5

Same name and namespace in other branches
  1. 6.2 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()

File

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

Code

function patterns_import_submit($form_id, $form_values) {
  if ($file = file_check_upload('xmlfile')) {

    // Currently nothing is happening with files saved here....
    if (file_check_directory(file_create_path(variable_get('patterns_save_xml', 'patterns')))) {
      file_save_upload('xmlfile', variable_get('patterns_save_xml', 'patterns'));
    }
    else {
      drupal_set_message(t('Pattern was registered but the file was not saved on the server because of improperly setup files directory.'));
    }
  }
  else {
    if ($form_values['xmlsource']) {
      file_save_data($form_values['xmlsource'], variable_get('patterns_save_xml', 'patterns') . '/' . $form_values['xmlname'] . '.xml', FILE_EXISTS_REPLACE);
    }
  }

  // Reload patterns
  patterns_get_patterns(true);
  return 'admin/build/patterns';
}