fullcalendar.drush.inc in FullCalendar 7
Drush integration for FullCalendar.
File
fullcalendar.drush.inc
View source
<?php
include_once 'fullcalendar.module';
define('FULLCALENDAR_DOWNLOAD_URI', 'http://arshaw.com/fullcalendar/downloads/fullcalendar-' . FULLCALENDAR_MIN_PLUGIN_VERSION . '.zip');
function fullcalendar_drush_command() {
$items = array();
$items['fullcalendar-plugin'] = array(
'description' => dt("Downloads the FullCalendar plugin."),
'arguments' => array(
'path' => dt('Optional. A path where to install the FullCalendar plugin. If omitted Drush will use the default location.'),
),
);
return $items;
}
function fullcalendar_drush_help($section) {
switch ($section) {
case 'drush:fullcalendar-plugin':
return dt("Downloads the FullCalendar plugin from arshaw.com, default location is sites/all/libraries.");
}
}
function drush_fullcalendar_plugin($path = 'sites/all/libraries') {
if (!drush_shell_exec('type unzip')) {
return drush_set_error(dt('Missing dependency: unzip. Install it before using this command.'));
}
if (!is_dir($path)) {
drush_op('mkdir', $path);
drush_log(dt('Directory @path was created', array(
'@path' => $path,
)), 'notice');
}
$olddir = getcwd();
chdir($path);
$filename = basename(FULLCALENDAR_DOWNLOAD_URI);
$dirname = basename(FULLCALENDAR_DOWNLOAD_URI, '.zip');
if (is_dir($dirname)) {
drush_log(dt('A existing FullCalendar plugin was overwritten at @path', array(
'@path' => $path,
)), 'notice');
}
if (is_file($filename)) {
drush_op('unlink', $filename);
}
if (!drush_shell_exec('wget ' . FULLCALENDAR_DOWNLOAD_URI)) {
drush_shell_exec('curl -O ' . FULLCALENDAR_DOWNLOAD_URI);
}
if (is_file($filename)) {
drush_shell_exec('unzip -qq -o ' . $filename);
drush_op('unlink', $filename);
if (is_dir('fullcalendar')) {
drush_shell_exec('rm -rf fullcalendar');
}
drush_shell_exec('mv ' . $dirname . '/fullcalendar fullcalendar');
drush_shell_exec('rm -rf ' . $dirname);
}
chdir($olddir);
if (is_dir($path . '/fullcalendar')) {
drush_log(dt('FullCalendar plugin has been downloaded to @path', array(
'@path' => $path,
)), 'success');
}
else {
drush_log(dt('Drush was unable to download the FullCalendar plugin to @path', array(
'@path' => $path,
)), 'error');
}
}