You are here

function apps_download_apps_list in Apps 7

Construct an array of downloadables to download.

2 calls to apps_download_apps_list()
apps_download_apps_batch in ./apps.installer.inc
Make the batch for downloading modules for app.
drush_apps_install in ./apps.drush.inc
Install an app, or list.

File

./apps.installer.inc, line 58
installer.inc hold all of the function used to download apps and thier deps

Code

function apps_download_apps_list($app) {
  $downloads = array();
  $update = $app['installed'] && !empty($app['upgradeable']);

  // Find all downloads needed for dependencies.
  foreach (array(
    'dependencies' => 'module',
    'libraries' => 'library',
  ) as $download_key => $download_type) {
    if (!empty($app[$download_key])) {
      foreach ($app[$download_key] as $dep) {
        if (!$dep['installed'] || $update) {
          if ($dep['installed'] && $update && !empty($dep['version']['version'])) {
            $info_file_location = $download_type == 'module' ? drupal_get_path('module', $dep['version']['name'], FALSE) : 'sites/all/libraries/' . $dep['version']['name'];
            if ($info = drupal_parse_info_file($info_file_location . '/' . APPS_APP_INFO)) {

              // if don't have current version of version the same, skip this download.
              if (empty($info['version']) || $dep['version']['version'] == $info['version']) {
                continue;
              }
            }
          }
          $downloads[$dep['downloadable']]['for'][] = $dep['version']['name'];
          $downloads[$dep['downloadable']]['type'] = $download_type;
          $downloads[$dep['downloadable']]['version'] = isset($dep['version']['version']) ? $dep['version']['version'] : $app['version'];
        }
      }
    }
  }

  // Add our core modules download.
  if (!$app['installed'] || !empty($app['upgradeable'])) {
    $downloads[$app['downloadable']]['for'][] = $app['machine_name'];
    $downloads[$app['downloadable']]['type'] = 'app';
    $downloads[$app['downloadable']]['version'] = $app['version'];
  }

  // Foreach download find the URL.
  foreach ($downloads as $key => $download) {
    $downloads[$key]['url'] = $app['downloadables'][$key];

    // Do a quick dirty pull of the name from the key.
    $downloads[$key]['name'] = ($e = strpos($key, " ")) ? substr($key, 0, $e) : $key;
  }
  return $downloads;
}