function drush_getlocations_geocoder in Get Locations 7
Same name and namespace in other branches
- 7.2 drush/getlocations.drush.inc \drush_getlocations_geocoder()
Command to download the Geocoder-js javascript library.
1 string reference to 'drush_getlocations_geocoder'
- getlocations_drush_command in drush/
getlocations.drush.inc - Implements hook_drush_command().
File
- drush/
getlocations.drush.inc, line 224 - getlocations.drush.inc @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL
Code
function drush_getlocations_geocoder() {
$args = func_get_args();
if (!empty($args[0])) {
$path = $args[0];
}
else {
$path = 'sites/all/libraries';
}
// Create the path if it does not exist.
if (!is_dir($path)) {
drush_op('mkdir', $path);
drush_log(dt('Directory @path was created', array(
'@path' => $path,
)), 'notice');
}
// Set the directory to the download location.
$olddir = getcwd();
chdir($path);
$zip = GETLOCATIONS_GEOCODER_DOWNLOAD_URI;
$dirname = 'geocoder-js';
// Download the zip archive
if ($filepath = drush_download_file($zip)) {
$filename = basename($filepath);
// Remove any existing directory
if (is_dir($dirname)) {
drush_delete_dir($dirname, TRUE);
drush_log(dt('An existing Geocoder-js library was deleted from @path', array(
'@path' => $path,
)), 'notice');
}
// Decompress the zip archive
drush_tarball_extract($filename);
// Copy the file into place.
$src = 'geocoder-js-master';
if (is_dir($src)) {
if (drush_mkdir($dirname)) {
drush_copy_dir($src . '/dist/geocoder.min.js', $dirname . '/geocoder.min.js');
drush_delete_dir($src);
}
}
}
if ($filepath && is_dir($dirname)) {
drush_log(dt('Geocoder-js javascript library has been installed in @path', array(
'@path' => $path,
)), 'success');
}
else {
drush_log(dt('Drush was unable to install the Geocoder-js javascript library to @path', array(
'@path' => $path,
)), 'error');
}
// Set working directory back to the previous working directory.
chdir($olddir);
}