You are here

function media_import in D7 Media 7

Form callback for mass import.

1 string reference to 'media_import'
media_menu in ./media.module
Implement of hook_menu().

File

includes/media.admin.inc, line 432
This file contains the admin functions for the Media module.

Code

function media_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'),
      '#required' => TRUE,
    );
    $form['pattern'] = array(
      '#type' => 'textfield',
      '#title' => t('Pattern'),
      '#description' => t('Only files matching this pattern will be imported. For example, to import all jpg and gif files, the pattern would be <em>*.jpg|*.gif</em>.'),
    );
    $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/media',
    );
  }
  else {
    $form['preview'] = array(
      '#markup' => theme('item_list', array(
        'items' => $form_state['storage']['files'],
      )),
    );
    $form = confirm_form($form, t('Import these files?'), 'admin/content/media/import');
  }
  return $form;
}