diff --git README.txt README.txt index 89129ad..7b3b691 100644 --- README.txt +++ README.txt @@ -1,7 +1,7 @@ -This version of FullCalendar requires specific versions of the following: - The 6.x-2.x branch of jQuery Update (http://drupal.org/project/jquery_update) - Version 1.7 of jQuery UI (http://drupal.org/project/jquery_ui) -Instructions for installing each can be found in their respective README.txt files +This module requires the 3rd party library for FullCalendar located at +http://arshaw.com/fullcalendar. Download and unzip this library into the +sites/all/libraries/fullcalendar directory, or use the Libraries API module for +site specific libraries. To use the fullcalendar module: 1) Install Views, Date, Date API, and Date Timezone modules @@ -13,4 +13,4 @@ To use the fullcalendar module: KNOWN ISSUES: When displaying a repeating date field, each event might show up multiple times on each repeat instance. To solve this problem, change the 'Distinct' setting -to yes in the Views display settings. This is a not a bug in FullCalendar. +to yes in the Views display settings. This is not a bug in FullCalendar. diff --git fullcalendar.custom.css fullcalendar.custom.css new file mode 100644 index 0000000..c869821 --- /dev/null +++ fullcalendar.custom.css @@ -0,0 +1,38 @@ +/* $Id$ */ + +/* Undo Drupal default theme link colors */ +.fc-content a:link, +.fc-content a:visited { + color: #fff; + text-decoration: none; +} + +/* Reset FullCalendar generic style */ +.fc-event, +.fc-agenda .fc-event-time, +.fc-event a { + border-style: none; + background-color: transparent; + color: inherit; +} + +/* Set FullCalendar default style */ +.fc-event-default, +.fc-agenda .fc-event-default .fc-event-time, +.fc-event-default a { + border-color: #36c; + border-style: solid; + background-color: #36c; + color: #fff; +} + +/* Styling for updated message */ +#fullcalendar-status { + background: #ecf8f4; + border: 1px solid #fff; + color: #687; + display: none; + margin: 0 0 10px 0; + padding: 15px; + text-align: center; +} diff --git fullcalendar.drush.inc fullcalendar.drush.inc new file mode 100644 index 0000000..8656813 --- /dev/null +++ fullcalendar.drush.inc @@ -0,0 +1,98 @@ + 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; +} + +/** + * Implements hook_drush_help(). + */ +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."); + } +} + +/** + * Commands to download the FullCalendar plugin. + */ +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.')); + } + + // 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); + + $filename = basename(FULLCALENDAR_DOWNLOAD_URI); + $dirname = basename(FULLCALENDAR_DOWNLOAD_URI, '.zip'); + + // Remove any existing FullCalendar plugin directory + if (is_dir($dirname)) { + drush_log(dt('A existing FullCalendar plugin was overwritten at @path', array('@path' => $path)), 'notice'); + } + // Remove any existing FullCalendar plugin zip archive + if (is_file($filename)) { + drush_op('unlink', $filename); + } + + // Download the zip archive + if (!drush_shell_exec('wget '. FULLCALENDAR_DOWNLOAD_URI)) { + drush_shell_exec('curl -O '. FULLCALENDAR_DOWNLOAD_URI); + } + + if (is_file($filename)) { + // Decompress the zip archive + drush_shell_exec('unzip -qq -o '. $filename); + // Remove the zip archive + 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); + } + + // Set working directory back to the previous working directory. + 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'); + } +} diff --git fullcalendar.install fullcalendar.install new file mode 100644 index 0000000..c73b56a --- /dev/null +++ fullcalendar.install @@ -0,0 +1,37 @@ + $t('FullCalendar plugin'), + 'value' => $t('At least @a', array('@a' => FULLCALENDAR_MIN_PLUGIN_VERSION)), + 'severity' => REQUIREMENT_ERROR, + 'description' => $t('You need to download the !fullcalendar and extract the entire contents of the archive into the %path folder of your server.', array('!fullcalendar' => l(t('FullCalendar plugin'), 'http://arshaw.com/fullcalendar/download'), '%path' => 'sites/all/libraries')), + ); + } + else { + $requirements['fullcalendar_plugin'] = array( + 'title' => $t('FullCalendar plugin'), + 'severity' => REQUIREMENT_OK, + 'value' => fullcalendar_get_version(), + ); + } + } + + return $requirements; +} diff --git fullcalendar.module fullcalendar.module index 8339399..868f421 100644 --- fullcalendar.module +++ fullcalendar.module @@ -7,6 +7,16 @@ */ /** + * The default path to the FullCalender plugin. + */ +define('FULLCALENDAR_PATH', 'sites/all/libraries/fullcalendar'); + +/** + * The minimum supported version of the FullCalender plugin. + */ +define('FULLCALENDAR_MIN_PLUGIN_VERSION', '1.4.10'); + +/** * Implements hook_views_api(). */ function fullcalendar_views_api() { @@ -17,18 +27,30 @@ function fullcalendar_views_api() { } /** - * Implements hook_init(). + * Implements hook_library(). */ -function fullcalendar_init() { - $path = drupal_get_path('module', 'fullcalendar'); - - drupal_add_css($path . '/fullcalendar.css'); - drupal_add_js($path . '/fullcalendar.js'); - - drupal_add_library('system', 'ui.draggable'); - drupal_add_library('system', 'ui.droppable'); - drupal_add_library('system', 'ui.resizable'); - drupal_add_library('system', 'effects.highlight'); +function fullcalendar_library() { + $libraries['fullcalendar'] = array( + 'title' => 'FullCalendar', + 'website' => 'http://arshaw.com/fullcalendar', + 'version' => FULLCALENDAR_MIN_PLUGIN_VERSION, + 'js' => array( + FULLCALENDAR_PATH . '/fullcalendar.js' => array(), + ), + 'css' => array( + FULLCALENDAR_PATH . '/fullcalendar.css' => array( + 'type' => 'file', + 'media' => 'screen', + ), + ), + 'dependencies' => array( + array('system', 'ui.draggable'), + array('system', 'ui.droppable'), + array('system', 'ui.resizable'), + array('system', 'effects.highlight'), + ), + ); + return $libraries; } /** @@ -163,6 +185,7 @@ function template_preprocess_views_view_fullcalendar(&$vars) { 'agenda' => $vars['options']['times']['fc_timeformat'], 'clock' => $vars['options']['times']['fc_clock'], ); + drupal_add_library('fullcalendar', 'fullcalendar'); drupal_add_js(array('fullcalendar' => $settings), 'setting'); drupal_add_js(drupal_get_path('module', 'fullcalendar') . '/fullcalendar.views.js'); } @@ -322,3 +345,55 @@ function fullcalendar_date_fields($entity, $entity_type = 'node') { } return $fields; } + +/** + * Checks FullCalendar dependencies + * + * @return + * Array with TRUE/FALSE for each dependency. + * + * @see fullcalendar_requirements() + */ +function _fullcalendar_status() { + $status = array(); + $status['fullcalendar_plugin'] = FALSE; + + if (version_compare(fullcalendar_get_version(), FULLCALENDAR_MIN_PLUGIN_VERSION, '>=')) { + $status['fullcalendar_plugin'] = TRUE; + } + + return $status; +} + +/** + * Returns the version of FullCalender plugin that is installed. + * + * This can be used by other modules' hook_requirements() to ensure that the + * proper version of Colorbox plugin is installed. + * + * @see version_compare + */ +function fullcalendar_get_version($fullcalendar_path = NULL) { + $version = 0; + $pattern = '#FullCalendar v([0-9\.a-z]+)#'; + + // No file is passed in so use the default location. + if (is_null($fullcalendar_path)) { + $fullcalendar_path = fullcalendar_get_js_path(); + } + + // Return the version of FullCalendar plugin. + $fullcalendar_plugin = file_get_contents($fullcalendar_path, NULL, NULL, 0, 40); + if (preg_match($pattern, $fullcalendar_plugin, $matches)) { + $version = $matches[1]; + } + + return $version; +} + +/** + * Returns the path to the FullCalender plugin. + */ +function fullcalendar_get_js_path() { + return FULLCALENDAR_PATH . '/fullcalendar.js'; +}