You are here

function patterns_import_submit in Patterns 7

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

File

includes/forms/import.inc, line 358
Importing Patterns from a file or using an URL.

Code

function patterns_import_submit($form, &$form_state) {
  $success = FALSE;
  $name = $form_state['values']['name'];
  $format = isset($form_state['values']['format']) ? $form_state['values']['format'] : PATTERNS_FORMAT_UNKNOWN;
  $content = isset($form_state['values']['pattern']) ? $form_state['values']['pattern'] : $form_state['values']['content'];
  if (!empty($content)) {
    $success = patterns_io_save_pattern($content, $name, $format, $form_state['values']['destination'], $form_state['values']['content']);
  }

  // success message displayed by patterns_io_save_pattern
  if (!$success) {
    drupal_set_message(t('File %name could not be saved on the server. Import failed.', array(
      '%name' => $name,
    )), 'error');
  }
  $form_state['redirect'] = 'admin/patterns';
}