function highcharttable_drush_download_libraries in HighchartTable 7
Command to download the Highcharts and HighchartTable libraries.
1 string reference to 'highcharttable_drush_download_libraries'
- highcharttable_drush_command in drush/
highcharttable.drush.inc - Implements hook_drush_command().
File
- drush/
highcharttable.drush.inc, line 48 - Drush integration for HighchartTable.
Code
function highcharttable_drush_download_libraries() {
$args = func_get_args();
$lib_path = empty($args[0]) ? 'sites/all/libraries' : trim($args[0]);
// Create the libraries directory if it does not exist.
if (!is_dir($lib_path)) {
drush_op('mkdir', $lib_path);
drush_log(dt('Directory @lib_path created.', array(
'@lib_path' => $lib_path,
)), 'notice');
}
drush_log(dt('Starting downloads to @lib_path. Please wait...', array(
'@lib_path' => $lib_path,
)), 'success');
// jQuery.highchartTable first (for no partiuclar reason.
if ($zip = highcharttable_download_and_extract_zip(HIGHCHARTTABLE_ZIP, $lib_path)) {
if (highcharttable_rename_dir("{$lib_path}/jquery-highchartTable-plugin-master", "{$lib_path}/highcharttable")) {
drush_log(dt('Directory renamed to @lib_path.', array(
'@lib_path' => "{$lib_path}/highcharttable",
)), 'success');
}
}
$lib_highcharts = "{$lib_path}/highcharts";
if (!is_dir($lib_highcharts)) {
drush_op('mkdir', $lib_highcharts);
drush_log(dt('Directory @lib_path created.', array(
'@lib_path' => $lib_highcharts,
)), 'notice');
}
$lib_highcharts_js = "{$lib_highcharts}/js";
$highcharts_js = "{$lib_highcharts}/js/highcharts.js";
if (file_exists($highcharts_js)) {
drush_log(dt('@highcharts_js already exists. You could try the existing file. Or you could rename it and run this Drush command again to download a fresh copy.', array(
'@highcharts_js' => $highcharts_js,
)), 'warning');
return;
}
elseif (!is_dir($lib_highcharts_js)) {
drush_op('mkdir', $lib_highcharts_js);
drush_log(dt('Directory @lib_path created.', array(
'@lib_path' => $lib_highcharts_js,
)), 'notice');
}
// drush_download_file() [without leading underscore] does not work here.
if (_drush_download_file(HIGHCHARTS_JS, $highcharts_js, TRUE)) {
drush_log(dt('@url downloaded.', array(
'@url' => HIGHCHARTS_JS,
)), 'success');
}
}