Projet

Général

Profil

Révision 7547bb19

Ajouté par Assos Assos il y a environ 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views_bulk_operations/actions/archive.action.inc
3 3
/**
4 4
 * @file
5 5
 * Provides an action for creating a zip archive of selected files.
6
 *
6 7
 * An entry in the {file_managed} table is created for the newly created archive,
7 8
 * and it is marked as permanent or temporary based on the operation settings.
8 9
 */
9 10

  
11
/**
12
 * Implements hook_action_info().
13
 */
10 14
function views_bulk_operations_archive_action_info() {
11 15
  $actions = array();
12 16
  if (function_exists('zip_open')) {
......
71 75
    $archive_file->filemime = file_get_mimetype($destination);
72 76
    $archive_file->uid      = $user->uid;
73 77
    $archive_file->status   = $context['settings']['temporary'] ? FALSE : FILE_STATUS_PERMANENT;
78
    // Clear filesize() cache to avoid private file system differences in
79
    // filesize.
80
    // @see https://www.drupal.org/node/2743999
81
    clearstatcache();
74 82
    file_save($archive_file);
75 83

  
76 84
    $url = file_create_url($archive_file->uri);
......
100 108
}
101 109

  
102 110
/**
103
 * Assembles a sanitized and unique URI for the archive, and returns it for
104
 * usage by the action callback (views_bulk_operations_archive_action).
111
 * Assembles a sanitized and unique URI for the archive.
112
 *
113
 * @returns array
114
 *   A URI array used by the action callback
115
 *   (views_bulk_operations_archive_action).
105 116
 */
106 117
function views_bulk_operations_archive_action_submit($form, $form_state) {
107 118
  // Validate the scheme, fallback to public if it's somehow invalid.
......
156 167
/**
157 168
 * Create a sanitized and unique version of the provided filename.
158 169
 *
159
 * @param $filename
160
 *   String filename
170
 * @param string $filename
171
 *   The filename to create.
172
 * @param array $archive_list
173
 *   The list of files already in the archive.
161 174
 *
162
 * @return
175
 * @return string
163 176
 *   The new filename.
164 177
 */
165 178
function _views_bulk_operations_archive_action_create_filename($filename, $archive_list) {
......
167 180
  // some filesystems, not many applications handle them well.
168 181
  $filename = preg_replace('/[\x00-\x1F]/u', '_', $filename);
169 182
  if (substr(PHP_OS, 0, 3) == 'WIN') {
170
    // These characters are not allowed in Windows filenames
183
    // These characters are not allowed in Windows filenames.
171 184
    $filename = str_replace(array(':', '*', '?', '"', '<', '>', '|'), '_', $filename);
172 185
  }
173 186

  

Formats disponibles : Unified diff