You are here

function s3fs_copy_system_images_confirm_form in S3 File System 7.2

Same name and namespace in other branches
  1. 7.3 s3fs.module \s3fs_copy_system_images_confirm_form()
1 string reference to 's3fs_copy_system_images_confirm_form'
s3fs_menu in ./s3fs.module
Implements hook_menu().

File

./s3fs.module, line 973
Hook implementations and other primary functionality for S3 File System.

Code

function s3fs_copy_system_images_confirm_form($form, &$form_state) {
  if (!variable_get('s3fs_no_rewrite_cssjs', FALSE)) {
    drupal_goto('admin/config/media/s3fs/actions');
  }

  // Active stream wrapper.
  $wrapper = variable_get('file_default_scheme', 'public') . '://';
  $directories = s3fs_copy_system_images_directories();
  if (!empty($directories['root_dirs'])) {
    $description = t('<h2><strong><span class="warning">Warning: Unrelated files may be deleted. Proceed with caution.</span></strong></h2>');
    $description .= t('
      <p>All files located in the S3 directories shown below will be deleted as part of this copy process. If you have stored files in
      one of these locations that is not related to S3 system images, <strong>cancel this process immediately and resolve the conflicts
      before proceeding.</strong> If a large number of modules are installed, this process can take several minutes to complete.</p>');
    $description .= t('<h3>!count images to be copied to S3:</h3>', array(
      '!count' => $directories['total'],
    ));
    $description .= t('<h4>Summary</h4>');
    $description .= '<ul>';
    foreach ($directories['root_dirs'] as $root_dir => $root_count) {
      $description .= '<li>' . $wrapper . $root_dir . ' (' . $root_count . ')</li>';
    }
    $description .= '</ul><br>';
    $description .= t('<h3>Details</h3>');
    $description .= '<ul>';
    foreach ($directories['dirs'] as $dir => $count) {
      $description .= '<li>' . $wrapper . $dir . ' (' . $count . ')</li>';
    }
    $description .= '</ul><br>';
  }
  else {
    $description = t('<p>Copy system images from modules, themes, and libraries to the S3 File System.</p>
      <p>If a large number of modules are installed, this process can take several minutes to complete.</p>');
  }
  $form = confirm_form($form, t('Copy System Images to S3'), array(
    'path' => 'admin/config/media/s3fs/actions',
  ), $description);

  // Pass data to form submit through build_info.
  $form_state['build_info']['system_stream_wrapper'] = $wrapper;
  $form_state['build_info']['system_image_directories'] = $directories;

  // Set submit function.
  $form['actions']['submit']['#submit'] = array(
    's3fs_copy_system_images_confirm_form_submit',
  );
  return $form;
}