function menu_minipanels_drush_download in Menu Minipanels 6
Same name and namespace in other branches
- 7 menu_minipanels.drush.inc \menu_minipanels_drush_download()
Download the qtip script.
1 call to menu_minipanels_drush_download()
- drush_menu_minipanels_post_enable in ./
menu_minipanels.drush.inc - Implements drush_MODULE_post_COMMAND().
1 string reference to 'menu_minipanels_drush_download'
- menu_minipanels_drush_command in ./
menu_minipanels.drush.inc - Implements hook_drush_command().
File
- ./
menu_minipanels.drush.inc, line 25 - Drush integration for Menu_MiniPanels.
Code
function menu_minipanels_drush_download() {
$url = "http://craigsworks.com/projects/qtip/download/package/production/development/";
$args = func_get_args();
if (isset($args[0])) {
$path = $args[0];
}
else {
$path = drush_get_context('DRUSH_DRUPAL_ROOT');
if (module_exists('libraries') && ($lib_path = libraries_get_path('qtip'))) {
$path .= '/' . $lib_path;
}
else {
$path .= '/sites/all/libraries/qtip';
}
}
// Ensure the directory exists, if it doesn't exist, recursively create it.
if (!is_dir($path) && !mkdir($path, 0777, TRUE)) {
drush_log(dt('Drush was unable to create the directory @path.', array(
'@path' => $path,
)), 'error');
return;
}
$olddir = getcwd();
drush_op('chdir', $path);
$tmp_file = 'qtip.zip';
// Download the file.
if (!drush_shell_exec("wget -q -P . \"%s\" --output-document %s", $url, $tmp_file)) {
drush_shell_exec("curl -L \"%s\" > %s", $url, $tmp_file);
}
if (file_exists($tmp_file) || drush_get_context('DRUSH_SIMULATE')) {
if (!drush_shell_exec("unzip %s", $tmp_file)) {
drush_op('chdir', $olddir);
return drush_set_error('DRUSH_PM_DOWNLOAD_FAILED', 'Drush was unable to extract qTip from ' . $tmp_file . ', ensure the \'unzip\' command is in your command path. You may also manually extract the file.');
}
else {
drush_log(dt('qTip has been downloaded & extracted to @path.', array(
'@path' => $path,
)), 'success');
}
}
else {
drush_op('chdir', $olddir);
return drush_set_error('DRUSH_PM_DOWNLOAD_FAILED', 'Drush was unable to download qTip from ' . $url . '.');
}
}