You are here

function media_bulk_upload_import in D7 Media 7.3

Same name and namespace in other branches
  1. 7.4 modules/media_bulk_upload/includes/media_bulk_upload.admin.inc \media_bulk_upload_import()
  2. 7.2 modules/media_bulk_upload/includes/media_bulk_upload.admin.inc \media_bulk_upload_import()

Form callback for mass import.

1 string reference to 'media_bulk_upload_import'
media_bulk_upload_menu in modules/media_bulk_upload/media_bulk_upload.module
Implements hook_menu().

File

modules/media_bulk_upload/includes/media_bulk_upload.admin.inc, line 11
This file contains the admin functions for the Media Bulk Upload module.

Code

function media_bulk_upload_import($form, &$form_state) {
  if (!isset($form_state['storage']['files'])) {
    $form_state['storage']['step'] = 'choose';
    $form_state['storage']['next_step'] = 'preview';
    $form['directory'] = array(
      '#type' => 'textfield',
      '#title' => t('Directory'),
      '#description' => t('Enter the absolute directory on the web server to look for files. Subdirectories inside this directory will not be scanned unless the Recurse through subdirectories box is checked.'),
      '#required' => TRUE,
    );
    $form['recurse'] = array(
      '#type' => 'checkbox',
      '#title' => t('Recurse through subdirectories'),
      '#description' => 'Iterate over the directory looking for files within subfolders that match the pattern.',
    );
    $form['to_directory'] = array(
      '#type' => 'textfield',
      '#title' => t('To Directory'),
      '#description' => t('Enter the subdirectory of /sites/default/files where files will be copied. If empty the default directory will be use.'),
      '#required' => FALSE,
    );
    $form['pattern'] = array(
      '#type' => 'textarea',
      '#title' => t('Pattern'),
      '#description' => t("Only files matching these patterns will be imported. Enter one pattern per line. The '*' character is a wildcard. Example patterns are %png_example to import all PNG files.", array(
        '%png_example' => '*.png',
      )),
      '#default_value' => '*',
      '#required' => TRUE,
    );
    $form['actions'] = array(
      '#type' => 'actions',
    );
    $form['actions']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Preview'),
    );
    $form['actions']['cancel'] = array(
      '#type' => 'link',
      '#title' => t('Cancel'),
      '#href' => isset($_GET['destination']) ? $_GET['destination'] : 'admin/content/file',
    );
  }
  else {
    $form['preview'] = array(
      '#markup' => theme('item_list', array(
        'items' => $form_state['storage']['files'],
      )),
    );
    $form = confirm_form($form, t('Import these files?'), 'admin/content/file/import');
  }
  return $form;
}