Project

General

Profile

Revision ed912c77

Added by Assos Assos about 6 years ago

Weekly update of contrib modules

View differences:

drupal7/sites/all/modules/libraries/libraries.drush.inc
23 23
    'arguments' => array(
24 24
      'libraries' => 'A comma delimited list of library machine names.',
25 25
    ),
26
    'required-arguments' => TRUE,
26
    'options' => array(
27
      'all' => 'Download all registered libraries.',
28
    ),
27 29
  );
28 30

  
29 31
  return $items;
......
42 44
 * Clears the library cache.
43 45
 */
44 46
function libraries_drush_invalidate_cache() {
45
  // @see drupal_flush_all_caches()
46
  foreach (libraries_flush_caches() as $table) {
47
    cache_clear_all('*', $table, TRUE);
48
  }
47
  libraries_cache_clear();
49 48
}
50 49

  
51 50
/**
......
109 108
function drush_libraries_download() {
110 109
  drush_command_include('pm-download');
111 110

  
112
  $libraries = libraries_info();
111
  $all_libraries = libraries_detect();
113 112

  
114
  // @todo Consider supporting downloading all downloadable libraries.
115
  // @todo Consider offering a selection if no library is specified.
116
  foreach (pm_parse_arguments(func_get_args(), FALSE) as $machine_name) {
117
    if (!isset($libraries[$machine_name])) {
118
      $message = dt("The !library library is not registered with Libraries API.\n", array('!library' => $machine_name));
119
      $message .= dt("Provide an info file for it or implement hook_libraries_info().\n");
120
      $message .= dt("See hook_libraries_info() for more information.\n");
121
      drush_set_error('DRUSH_LIBRARY_UKNOWN', $message);
122
      continue;
113
  // Prepare a list of names of downloadable libraries.
114
  $downloadable_names = array();
115
  foreach ($all_libraries as $machine_name => $library) {
116
    // Skip libraries that are already installed.
117
    // @todo Allow (optionally) re-downloading installing libraries.
118
    if (!empty($library['download file url']) && !$library['installed']) {
119
      $downloadable_names[] = $machine_name;
123 120
    }
124
    $library = $libraries[$machine_name];
121
  }
125 122

  
126
    if (empty($library['download file url'])) {
127
      $message = dt("The !library library cannot be downloaded.\n", array('!library' => $machine_name));
128
      $message .= dt("Libraries need to specify a download file URL to support being downloaded via Drush.\n");
129
      $message .= dt("See hook_libraries_info() for more information.\n");
130
      drush_set_error('DRUSH_LIBRARY_NOT_DOWNLOADABLE', $message);
131
      continue;
123
  // Gather a list of libraries to download. If '--all' was specified, that
124
  // takes precedence over any other arguments. Otherwise and if no arguments
125
  // are specified, we present a choice of all downloadable libraries.
126
  if (drush_get_option('all', FALSE) && $downloadable_names) {
127
    $machine_names = $downloadable_names;
128
  }
129
  elseif (pm_parse_arguments(func_get_args(), FALSE)) {
130
    $machine_names = array();
131
    foreach (pm_parse_arguments(func_get_args(), FALSE) as $machine_name) {
132
      // If there was an error with with one of the libraries, continue to try
133
      // to install any remaining libraries.
134
      if (!isset($all_libraries[$machine_name])) {
135
        $message = dt("The !library library is not registered with Libraries API.\n", array('!library' => $machine_name));
136
        $message .= dt("Provide an info file for it or implement hook_libraries_info().\n");
137
        $message .= dt("See hook_libraries_info() for more information.\n");
138
        drush_set_error('DRUSH_LIBRARY_UKNOWN', $message);
139
        continue;
140
      }
141
      if (empty($all_libraries[$machine_name]['download file url'])) {
142
        $message = dt("The !library library cannot be downloaded.\n", array('!library' => $machine_name));
143
        $message .= dt("Libraries need to specify a download file URL to support being downloaded via Drush.\n");
144
        $message .= dt("See hook_libraries_info() for more information.\n");
145
        drush_set_error('DRUSH_LIBRARY_NOT_DOWNLOADABLE', $message);
146
        continue;
147
      }
148
      $machine_names[] = $machine_name;
149
    }
150
  }
151
  elseif ($downloadable_names) {
152
    $machine_names = drush_choice_multiple(drupal_map_assoc($downloadable_names), FALSE, 'Select which libraries to download.');
153
    // If the operation was cancelled by the user, or if no libraries were
154
    // selected, bail out without any further error message.
155
    if (!$machine_names) {
156
      return;
132 157
    }
133
    $download_url = $library['download file url'];
158
  }
159
  else {
160
    drush_log(dt('There are no registered, uninstalled libraries that can be downloaded.'), 'warning');
161
    return;
162
  }
163

  
164
  foreach ($machine_names as $machine_name) {
165
    $download_url = $all_libraries[$machine_name]['download file url'];
134 166

  
135 167
    drush_log(dt('Downloading library !name ...', array('!name' => $machine_name)));
136 168

  
......
205 237
        drush_delete_dir($install_location, TRUE);
206 238
      }
207 239
      else {
208
        drush_log(dt("Skip installation of !project to !dest.", array('!project' => $library['machine name'], '!dest' => $install_location)), 'warning');
240
        drush_log(dt("Skip installation of !project to !dest.", array('!project' => $machine_name, '!dest' => $install_location)), 'warning');
209 241
        continue;
210 242
      }
211 243
    }

Also available in: Unified diff