function download_count_sparkline_download in Download Count 8
Same name and namespace in other branches
- 7.3 includes/download_count.drush.inc \download_count_sparkline_download()
Callback to do the actual sparkling plugin download.
1 string reference to 'download_count_sparkline_download'
- download_count_drush_command in includes/
download_count.drush.inc - Implements hook_drush_command().
File
- includes/
download_count.drush.inc, line 42 - Drush commands for download_count.
Code
function download_count_sparkline_download() {
$args = func_get_args();
if (count($args) == 0) {
$uri = SPARKLINE_BASE_URI . SPARKLINE_VERSION . '/' . SPARKLINE_FILENAME;
$path = 'sites/all/libraries/jquery.sparkline';
}
elseif (count($args) == 1) {
$uri = SPARKLINE_BASE_URI . $args[0] . '/' . SPARKLINE_FILENAME;
$path = 'sites/all/libraries/jquery.sparkline';
}
elseif (count($args) == 2) {
$uri = SPARKLINE_BASE_URI . $args[0] . '/' . SPARKLINE_FILENAME;
$path = $args[1];
print 'path= ' . $path;
print is_dir($path);
}
else {
drush_log(dt('Too many arguments. Use "drush help sparklines" to see information for this command'), 'error');
return;
}
if (!is_dir($path)) {
drush_op('mkdir', $path);
drush_log(dt('Directory @path was created', [
'@path' => $path,
]), 'notice');
}
$original_dir = getcwd();
chdir($path);
if (is_file(SPARKLINE_FILENAME)) {
drush_op('unlink', SPARKLINE_FILENAME);
}
if (!drush_shell_exec('wget ' . $uri)) {
drush_shell_exec('curl -O ' . $uri);
}
if (is_file(SPARKLINE_FILENAME)) {
drush_log(dt('The sparkline plugin has been downloaded to @path', [
'@path' => $path,
]), 'success');
}
else {
drush_log(dt('Drush was unable to download the sparkline plugin to @path', [
'@path' => $path,
]), 'error');
}
chdir($original_dir);
}