Index: event.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/event/event.module,v
retrieving revision 1.193
diff -u -r1.193 event.module
--- event.module	28 Mar 2006 02:58:57 -0000	1.193
+++ event.module	14 Apr 2006 15:49:49 -0000
@@ -1440,6 +1440,20 @@
 function event_validate_form_date(&$node, $date) {
   $prefix = $date .'_';
 
+  /**
+   *  If using javascript pop-up calendar, convert input date back to individual date parts expected by the validator
+   */
+  if (variable_get('event_selector_'. $node->type, 'select') == 'jscalendar') {
+    $get = $prefix . 'date';
+    $this_date = $node->$get;
+    $timestamp = mktime(substr($this_date, 11, 2), substr($this_date, 14, 2), substr($this_date, 17, 2), substr($this_date, 5, 2), substr($this_date, 8, 2), substr($this_date, 0, 4));
+    $node->{$prefix . 'year'}   = date("Y", $timestamp);
+    $node->{$prefix . 'month'}  = date("n", $timestamp);
+    $node->{$prefix . 'day'}    = date("d", $timestamp);
+    $node->{$prefix . 'hour'}   = variable_get('event_ampm', '0') ? date("H", $timestamp) : date("g", $timestamp);
+    $node->{$prefix . 'minute'} = date("i", $timestamp);
+  }
+  
   // If we have all the parameters, re-calculate $node->event_$date .
   if (isset($node->{$prefix . 'year'}) && isset($node->{$prefix . 'month'}) && isset($node->{$prefix . 'day'}) && isset($node->{$prefix . 'hour'}) && isset($node->{$prefix . 'minute'})) {
     $hour = $node->{$prefix . 'hour'};
@@ -1736,25 +1750,85 @@
         '#options' => array('all' => t('All views'), 'solo' => t('Only in views for this type'), 'never' => t('Never')),
         '#description' => t('All views: This content type will be available for display on all calendar views, including with other events.<br />Only in views for this type: This content type will only appear in calendar views specific to this type and never with other events.<br />Never: This content type will not be associated with the events calendar.')
       );
+      /**
+       *  add type-specific option to use javascript pop-up calendar instead of regular date selector
+       *  if jscalendar is not installed, no option is available but a message indicates that it could be an option if installed
+       */
+      if (module_exist('jscalendar')) {
+        $form['workflow']['event_selector_'. $type] = array(
+          '#type' => 'radios', 
+          '#title' =>  t('Event date selector'), 
+          '#default_value' => variable_get('event_selector_'. $type, 'select'), 
+          '#options' => array('select' => t('Drop-down select list'), 'jscalendar' => t('Javascript pop-up calendar')), 
+          '#description' => t('The type of selector to be used when creating dates. The javascript pop-up calendar requires the installation of the <a href="http://drupal.org/node/57285">jscalendar</a> module.'), 
+          '#required' => TRUE,
+          );
+      } else {
+        $form['workflow']['event_selector_'. $type] = array(
+          '#type' => 'radios', 
+          '#title' =>  t('Date selector'), 
+          '#default_value' => variable_get('event_selector_'. $type, 'select'), 
+          '#options' => array('select' => t('Drop-down select list')), 
+          '#description' => t('The type of selector to be used when creating dates. A javascript pop-up calendar selector would be available as an option if the <a href="http://drupal.org/node/57285">jscalendar</a> module was installed.'), 
+          '#required' => TRUE,
+          );
+      }
       break;
     // node edit form
     case $type .'_node_form':
       if (variable_get('event_nodeapi_'. $type, 'never') != 'never') {
-        $form['event_start'] = array(
-          '#type' => 'fieldset',
-          '#title' => t('Start'),
-          '#description' => t('Start date.'),
-          '#weight' => -15
-          );
-        $form['event_start']['date'] = event_form_date($node->event_start ? $node->event_start : _event_user_time(), 'start', $node->start_offset);
+        /**
+         *  Check to see if jscalendar is installed and selected as the input choice
+         *  If so, display it, otherwise default to normal drop-down list selectors
+         */
+        if (module_exist('jscalendar') && variable_get('event_selector_'. $type, 'select') == 'jscalendar') {
+
+          $form['date'] = array(
+            '#type' => 'fieldset',
+            '#title' => t('Date'),
+            '#description' => t('Input the date in the format YYYY-MM-DD HH:MM:SS or click the button to use a javascript calendar pop-up button to select a date.'),
+            '#weight' => -15
+            );
+          $form['date']['start_date'] = array(
+            '#title' => t('Start Date'),
+            '#type' => 'textfield',
+            '#default_value' => date("Y-m-d H:m:s", $node->event_start ? $node->event_start : _event_user_time()),
+            '#attributes' => array('class' => 'jscalendar'),
+            '#attributes' => array('class' => 'jscalendar'),
+            '#jscalendar_ifFormat' => '%Y-%m-%d %H:%M:%S',
+            '#jscalendar_showsTime' => 'true',
+            '#jscalendar_timeFormat' => variable_get('event_ampm', '0') == 0 ? '24' : '12',
+            );
+          $form['date']['end_date'] = array(
+            '#title' => t('End Date'),
+            '#type' => 'textfield',
+            '#default_value' => date("Y-m-d H:m:s", $node->event_end ? $node->event_end : _event_user_time()),
+            '#attributes' => array('class' => 'jscalendar'),
+            '#attributes' => array('class' => 'jscalendar'),
+            '#jscalendar_ifFormat' => '%Y-%m-%d %H:%M:%S',
+            '#jscalendar_showsTime' => 'true',
+            '#jscalendar_timeFormat' => variable_get('event_ampm', '0') == 0 ? '24' : '12',
+            );
 
-        $form['event_end'] = array(
-          '#type' => 'fieldset',
-          '#title' => t('End'),
-          '#description' => t('End date.'),
-          '#weight' => -14
-          );
-        $form['event_end']['date'] = event_form_date(($node->event_end ? $node->event_end : _event_user_time()), 'end', $node->end_offset);
+        } else {
+        
+          $form['event_start'] = array(
+            '#type' => 'fieldset',
+            '#title' => t('Start'),
+            '#description' => t('Start date.'),
+            '#weight' => -15
+            );
+          $form['event_start']['date'] = event_form_date($node->event_start ? $node->event_start : _event_user_time(), 'start', $node->start_offset);
+
+          $form['event_end'] = array(
+            '#type' => 'fieldset',
+            '#title' => t('End'),
+            '#description' => t('End date.'),
+            '#weight' => -14
+            );
+          $form['event_end']['date'] = event_form_date(($node->event_end ? $node->event_end : _event_user_time()), 'end', $node->end_offset);
+
+        }
 
         if (variable_get('event_timezone_input', 'site') == 'input') {
           $form['timezone'] = array(
