[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/date/date_popup/ -> date_popup.module (source)

   1  <?php
   2  // $Id: date_popup.module,v 1.42.2.1.2.65 2010/11/20 11:33:30 karens Exp $
   3  /**
   4   * @file
   5   * A module to enable jquery calendar and time entry popups.
   6   * Requires the Date API.
   7   *
   8   * Add a type of #date_popup to any date, time, or datetime field that will
   9   * use this popup. Set #date_format to the way the date should be presented
  10   * to the user in the form. Set #default_value to be a date in the local
  11   * timezone, and note the timezone name in #date_timezone.
  12   *
  13   * The element will create two textfields, one for the date and one for the
  14   * time. The date textfield will include a jQuery popup calendar date picker,
  15   * and the time textfield uses a jQuery timepicker.
  16   *
  17   * If no time elements are included in the format string, only the date
  18   * textfield will be created. If no date elements are included in the format
  19   * string, only the time textfield, will be created.
  20   *
  21   */
  22  
  23  /**
  24   * Load needed files.
  25   */
  26  function date_popup_load() {
  27    static $loaded = FALSE;
  28    if ($loaded) {
  29      return;
  30    }
  31    $path = drupal_get_path('module', 'date_popup');
  32    if (module_exists('jquery_ui')) {
  33      jquery_ui_add('ui.datepicker');
  34    }
  35    if (variable_get('date_popup_timepicker', 'default') == 'default') {
  36      drupal_add_js($path .'/lib/jquery.timeentry.pack.js');
  37    }
  38    $loaded = TRUE;
  39  }
  40  
  41  function date_popup_css_default() {
  42    if (!module_exists('jquery_ui')) {
  43      return '';
  44    }
  45    $version = jquery_ui_get_version();
  46    $jquery_ui_path = drupal_get_path('module', 'jquery_ui');
  47    switch ($version) {
  48      case '1.6':
  49        return drupal_get_path('module', 'date_popup') .'/themes/datepicker.css';
  50      default:
  51        return drupal_get_path('module', 'date_popup') .'/themes/datepicker.1.7.css';
  52    }
  53  }
  54  
  55  function date_popup_css_options() {
  56    $paths = array();
  57    if (!module_exists('jquery_ui')) {
  58      return $paths;
  59    }
  60    $version = jquery_ui_get_version();
  61    $jquery_ui_path = drupal_get_path('module', 'jquery_ui');
  62    switch ($version) {
  63      case '1.6':
  64        $paths[drupal_get_path('module', 'date_popup') .'/themes/datepicker.css'] = t('Date Popup default');
  65        $paths[$jquery_ui_path .'/jquery.ui/themes/default/ui.datepicker.css'] = t('jQuery UI default');
  66        break;
  67      default:
  68        $paths[drupal_get_path('module', 'date_popup') .'/themes/datepicker.1.7.css'] = t('Date Popup default');
  69        $paths[$jquery_ui_path .'/jquery.ui/themes/base/ui.datepicker.css'] = t('jQuery UI default');
  70        break;
  71    }
  72    return $paths;
  73  }
  74  
  75  /**
  76   * Implementation of hook_init().
  77   */
  78  function date_popup_init() {
  79    global $user;
  80    if (!module_exists('jquery_ui') && $user->uid == 1) {
  81      drupal_set_message(t('The Date Popup module now requires the <a href="@link">jQuery UI module</a> as a source for the datepicker. Please install it immediately.', array('@link' => 'http://drupal.org/project/jquery_ui')), 'error');
  82      return;
  83    }
  84    
  85    drupal_add_css(variable_get('date_popup_css_file', date_popup_css_default()));
  86    
  87    if (variable_get('date_popup_timepicker', 'default') == 'default') {
  88      drupal_add_css(drupal_get_path('module', 'date_popup')  .'/themes/jquery.timeentry.css');
  89    }
  90  }
  91  
  92   /**
  93   * Create a unique CSS id name and output a single inline JS block for
  94   * each startup function to call and settings array to pass it.  This
  95   * used to create a unique CSS class for each unique combination of
  96   * function and settings, but using classes requires a DOM traversal
  97   * and is much slower than an id lookup.  The new approach returns to
  98   * requiring a duplicate copy of the settings/code for every element
  99   * that uses them, but is much faster.  We could combine the logic by
 100   * putting the ids for each unique function/settings combo into
 101   * Drupal.settings and searching for each listed id.
 102   *
 103   * @param $pfx
 104   *   The CSS class prefix to search the DOM for.
 105   *   TODO : unused ?
 106   * @param $func
 107   *   The jQuery function to invoke on each DOM element containing the
 108   * returned CSS class.
 109   * @param $settings
 110   *   The settings array to pass to the jQuery function.
 111   * @returns
 112   *   The CSS id to assign to the element that should have
 113   * $func($settings) invoked on it.
 114   */
 115  function date_popup_js_settings_id($id, $func, $settings) {
 116    static $js_added = FALSE;
 117    static $id_count = array();
 118  
 119    // Make sure popup date selector grid is in correct year.
 120    if (!empty($settings['yearRange'])) {
 121      $parts = explode(':', $settings['yearRange']);
 122      // Set the default date to 0 or the lowest bound if the date ranges do not include the current year
 123      // Necessary for the datepicker to render and select dates correctly
 124      $defaultDate = ($parts[0] > 0 || 0 > $parts[1]) ? $parts[0] : 0;
 125  
 126      // The 1.7 version of datepicker renders the range of year options 
 127      // relative to the drawn year in the popup, and will re-render the options 
 128      // whenever the year changes.
 129      if (strpos(jquery_ui_get_version(), '1.7') === 0 && ($parts[0] >= 0 || 0 >= $parts[1])) {
 130        $range = max($parts) - min($parts);
 131        $defaultDate = $parts[0];
 132        $settings['yearRange'] = '-' . $range . ':' . '+' . $range;
 133      }
 134      $settings += array('defaultDate' => (string) $defaultDate . 'y');
 135      }
 136  
 137    if (!$js_added) {
 138      drupal_add_js(drupal_get_path('module', 'date_popup') .'/date_popup.js');
 139      $js_added = TRUE;
 140    }
 141  
 142    // We use a static array to account for possible multiple form_builder()
 143    // calls in the same request (form instance on 'Preview').
 144    if (!isset($id_count[$id])) {
 145      $id_count[$id] = 0;
 146    }
 147  
 148  // It looks like we need the additional id_count for this to
 149  // work correctly when there are multiple values.  
 150  //  $return_id = "$id-$func-popup";
 151    $return_id = "$id-$func-popup-". $id_count[$id]++;
 152    $js_settings['datePopup'][$return_id] = array(
 153      'func' => $func,
 154      'settings' => $settings
 155    );
 156    drupal_add_js($js_settings, 'setting');
 157    return $return_id;
 158  }
 159  
 160  function date_popup_theme() {
 161    return array(
 162      'date_popup' => array('arguments' => array('element' => NULL)),
 163      );
 164  }
 165  
 166  /**
 167   * Implementation of hook_elements().
 168   *
 169   * Set the #type to date_popup and fill the element #default_value with
 170   * a date adjusted to the proper local timezone in datetime format (YYYY-MM-DD HH:MM:SS).
 171   *
 172   * The element will create two textfields, one for the date and one for the
 173   * time. The date textfield will include a jQuery popup calendar date picker,
 174   * and the time textfield uses a jQuery timepicker.
 175   *
 176   * NOTE - Converting a date stored in the database from UTC to the local zone
 177   * and converting it back to UTC before storing it is not handled by this
 178   * element and must be done in pre-form and post-form processing!!
 179   *
 180   * #date_timezone
 181   *   The local timezone to be used to create this date.
 182   *
 183   * #date_format
 184   *   Unlike earlier versions of this popup, most formats will work.
 185   *
 186   * #date_increment
 187   *   Increment minutes and seconds by this amount, default is 1.
 188   *
 189   * #date_year_range
 190   *   The number of years to go back and forward in a year selector,
 191   *   default is -3:+3 (3 back and 3 forward).
 192   *
 193   */
 194  function date_popup_elements() {
 195    return array(
 196      'date_popup' => array(
 197        '#input' => TRUE,
 198        '#tree' => TRUE,
 199        '#date_timezone' => date_default_timezone_name(),
 200        '#date_format' => variable_get('date_format_short', 'm/d/Y - H:i'),
 201        '#date_increment' => 1,
 202        '#date_year_range' => '-3:+3',
 203        '#process' => array('date_popup_process'),
 204        ),
 205      );
 206  }
 207  
 208  /**
 209   * Javascript popup element processing.
 210   * Add popup attributes to $element.
 211   * 
 212   * In regular FAPI processing $element['#value'] will contain a string
 213   * value before the form is submitted, and an array during submission.
 214   * 
 215   * In regular FAPI processing $edit is empty until the form is submitted
 216   * when it will contain an array.
 217   * 
 218   * Views widget processing now receives the same values as normal FAPI
 219   * processing (that was not true in Views 1).
 220   * 
 221   */
 222  function date_popup_process($element, $edit, $form_state, $form) {
 223    date_popup_load();
 224    require_once('./'. drupal_get_path('module', 'date_api') .'/date_api_elements.inc');
 225  
 226    $date = NULL;
 227    $granularity = date_format_order($element['#date_format']);
 228    
 229    if (!empty($edit) && is_array($edit) && !empty($edit['date'])) {
 230      $input = $edit['date'] . (!empty($edit['time']) ? ' '. $edit['time'] : '');
 231      $datetime = date_convert_from_custom($input, $element['#date_format']);
 232      $date = date_make_date($datetime, $element['#date_timezone'], DATE_DATETIME, $granularity);
 233    }
 234    elseif (!empty($element['#value'])) {
 235      $date = date_make_date($element['#value'], $element['#date_timezone'], DATE_DATETIME, $granularity);
 236    }
 237    
 238    date_increment_round($date, $element['#date_increment']);
 239    $granularity = date_format_order($element['#date_format']);
 240    $element['#tree'] = TRUE;
 241    $element['#granularity'] = $granularity;
 242    $element['date'] = date_popup_process_date($element, $edit, $date);
 243    $element['time'] = date_popup_process_time($element, $edit, $date);
 244    
 245    if (isset($element['#element_validate'])) {
 246      array_push($element['#element_validate'], 'date_popup_validate');
 247    }
 248    else {
 249      $element['#element_validate'] = array('date_popup_validate');
 250    }
 251    return $element;
 252  }
 253  
 254  /**
 255   * Process the date portion of the element.
 256   */
 257  function date_popup_process_date(&$element, $edit = NULL, $date = NULL) {
 258    $granularity = $element['#granularity'];
 259    $date_granularity = array_intersect($granularity, array('month', 'day', 'year'));
 260    $time_granularity = array_intersect($granularity, array('hour', 'minute', 'second'));
 261    $date_format = (date_limit_format($element['#date_format'], $date_granularity));
 262    if (empty($date_granularity)) return array();
 263    
 264    // The datepicker can't handle zero or negative values like 0:+1
 265    // even though the Date API can handle them, so rework the value
 266    // we pass to the datepicker to use defaults it can accept (such as +0:+1)
 267    // date_range_string() adds the necessary +/- signs to the range string.
 268    $range = date_range_years($element['#date_year_range'], $date);
 269    $year_range = date_range_string($range);
 270  
 271    $settings = array(
 272      'prevText' => '&laquo;',
 273      'nextText' => '&raquo;',
 274      'currentText' => date_t('Today', 'date_nav'),
 275      'changeMonth' => TRUE,
 276      'changeYear' => TRUE,    
 277      'clearText' => t('Clear'),
 278      'closeText' => t('Close'),
 279      'firstDay' => intval(variable_get('date_first_day', 1)),
 280      'dayNames' => date_week_days(TRUE),
 281      'dayNamesShort' => date_week_days_abbr(TRUE, TRUE, 3),
 282      'dayNamesMin' => date_week_days_abbr(TRUE, TRUE, 2),
 283      'monthNames' => array_values(date_month_names(TRUE)),
 284      'monthNamesShort' => array_values(date_month_names_abbr(TRUE)),
 285      //'buttonImage' => base_path() . drupal_get_path('module', 'date_api') ."/images/calendar.png",
 286      //'buttonImageOnly' => TRUE,
 287      'autoPopUp' => 'focus',
 288      'closeAtTop' => FALSE,
 289      'speed' => 'immediate',
 290      'dateFormat' => date_popup_format_to_popup($date_format, 'datepicker'),
 291      'yearRange' => $year_range,
 292      // Custom setting, will be expanded in Drupal.behaviors.date_popup()
 293      'fromTo' => isset($fromto),
 294      );    
 295    
 296    // Create a unique id for each set of custom settings.
 297    $id = date_popup_js_settings_id($element['#id'], 'datepicker', $settings);
 298    $sub_element = array(
 299      '#type' => 'textfield',
 300      '#default_value' => (!empty($element['#value']['date']) || !empty($edit['date'])) && is_object($date) ? date_format_date($date, 'custom', $date_format) : '',
 301      '#id' => $id,    
 302      '#size' => !empty($element['#size']) ? $element['#size'] : 20,
 303      '#maxlength' => !empty($element['#maxlength']) ? $element['#maxlength'] : 30,
 304      '#attributes' => $element['#attributes'],
 305      );
 306    // Views exposed filters are treated as submitted even if not,
 307    // so force the #default value in that case.  
 308    if (!empty($element['#force_value'])) {
 309      $sub_element['#value'] = $sub_element['#default_value'];
 310    }
 311    // TODO, figure out exactly when we want this description. In many places it is not desired.
 312    $sub_element['#description'] = ' '. t('Format: @date', array('@date' => date_format_date(date_now(), 'custom', $date_format)));
 313    return $sub_element;
 314  }
 315  
 316  /**
 317   * Process the time portion of the element.
 318   */
 319  function date_popup_process_time(&$element, $edit = NULL, $date = NULL) {
 320    $granularity = $element['#granularity'];
 321    $time_granularity = array_intersect($granularity, array('hour', 'minute', 'second'));
 322    $time_format = date_popup_format_to_popup_time(date_limit_format($element['#date_format'], $time_granularity));
 323    if (empty($time_granularity)) return array();
 324  
 325    $spinner_text = array(t('Now'), t('Previous field'), t('Next field'), t('Increment'), t('Decrement'));
 326    $settings = array(
 327      'show24Hours' => strpos($element['#date_format'], 'H') !== FALSE ? TRUE : FALSE,
 328      'showSeconds' => (in_array('second', $granularity) ? TRUE : FALSE),
 329      'timeSteps' => array(1, intval($element['#date_increment']), (in_array('second', $granularity) ? $element['#date_increment'] : 0)),
 330      'spinnerImage' => '',
 331      'fromTo' => isset($fromto),
 332      );
 333  
 334    // Create a unique id for each set of custom settings.
 335    $id = date_popup_js_settings_id($element['#id'], 'timeEntry', $settings);
 336    $sub_element = array(
 337      '#type' => 'textfield',
 338      '#default_value' => (!empty($element['#value']['time']) || !empty($edit['time'])) && is_object($date) ? date_format_date($date, 'custom', $time_format) : '',
 339      '#id' => $id,
 340      '#size' => 10,
 341      '#maxlength' => 10,
 342      );
 343    // Views exposed filters are treated as submitted even if not,
 344    // so force the #default value in that case.  
 345    if (!empty($element['#force_value'])) {
 346      $sub_element['#value'] = $sub_element['#default_value'];
 347    }
 348    // TODO, figure out exactly when we want this description. In many places it is not desired.
 349    $sub_element['#description'] = t('Format: @date', array('@date' => date_format_date(date_now(), 'custom', $time_format)));
 350    return ($sub_element);
 351  }
 352  
 353  /**
 354   * Massage the input values back into a single date.
 355   * 
 356   * When used as a Views widget, the validation step always gets triggered,
 357   * even with no form submission. Before form submission $element['#value']
 358   * contains a string, after submission it contains an array.
 359   * 
 360   */
 361  function date_popup_validate($element, &$form_state) {
 362    if (is_string($element['#value'])) {
 363      return;
 364    }
 365    $granularity = $element['#granularity'];
 366    $date_granularity = array_intersect($granularity, array('month', 'day', 'year'));
 367    $time_granularity = array_intersect($granularity, array('hour', 'minute', 'second'));
 368    $label = !empty($element['#date_title']) ? $element['#date_title'] : (!empty($element['#title']) ? $element['#title'] : '');
 369    $label = t($label);
 370    
 371    // If the field is empty and not required, set it to empty and return.
 372    // If the field is empty and required, set error message and return.
 373    $error_field = implode('][', $element['#parents']);
 374    if (empty($element['#value']['date'])) {
 375      if ($element['#required']) {
 376        // Set message on both date and time to get them highlighted properly.
 377        $message = t('Field %field is required.', array('%field' => $label));
 378        if (!empty($date_granularity)) {
 379          form_set_error($error_field .'][date', $message);  
 380          $message = ' ';
 381        }
 382        if (!empty($time_granularity)) {
 383          form_set_error($error_field .'][time', $message);  
 384        }
 385      }
 386      form_set_value($element, NULL, $form_state);
 387      return;
 388    }
 389  
 390    require_once('./'. drupal_get_path('module', 'date_api') .'/date_api_elements.inc');
 391    date_popup_load();
 392    $value = date_popup_input_value($element);
 393    
 394    // If the created date is valid, set it.
 395    if (!empty($value)) {
 396      form_set_value($element, $value, $form_state);
 397      return;
 398    }
 399    else {
 400      // Set message on both date and time to get them highlighted properly.
 401      $message = t('Field %field is invalid.', array('%field' => $label));
 402      if (!empty($date_granularity)) {
 403        form_set_error($error_field .'][date', $message);  
 404        $message = ' ';
 405      }
 406      if (!empty($time_granularity)) {
 407        form_set_error($error_field .'][time', $message);  
 408      }
 409    }
 410    form_set_value($element, NULL, $form_state);
 411  }
 412  
 413  /**
 414   * Helper function for extracting a date value out of user input.
 415   * 
 416   * @param autocomplete
 417   *   Should we add a time value to complete the date if there is no time?
 418   *   Useful anytime the time value is optional. 
 419   */
 420  function date_popup_input_value($element, $auto_complete = FALSE) {
 421    date_popup_load();
 422    $granularity = date_format_order($element['#date_format']);
 423    $format = $element['#date_format'];
 424    $format = strtr($format, timepicker_format_replacements());
 425    $format = date_limit_format($format, $granularity);
 426    // Evaluate date and time parts separately since we can't know or care
 427    // how they're combined in the complete date format.
 428    $time_format = date_limit_format($format, array('hour', 'minute', 'second'));
 429    $date_format = date_limit_format($format, array('year', 'month', 'day'));
 430    $value = '';
 431    if (is_array($element['#value']) && !empty($element['#value']['date'])) {
 432      $date = date_convert_from_custom(trim(!empty($element['#value']['date']) ? $element['#value']['date'] : ''), $date_format);
 433      $time = date_convert_from_custom(trim(!empty($element['#value']['time']) ? $element['#value']['time'] : ''), $time_format);
 434      $value = trim(substr($date, 0, 10) .' '. substr($time, 11, 8));
 435    }
 436    
 437    if (date_is_valid($value, DATE_DATETIME, $granularity)) {
 438      $date = date_make_date($value, $element['#date_timezone'], DATE_DATETIME, $granularity);
 439      $value = date_convert($date, DATE_OBJECT, DATE_DATETIME);
 440      return $value;
 441    }
 442    return NULL;
 443  }
 444  
 445  /**
 446   * Allowable time formats.
 447   */
 448  function date_popup_time_formats($with_seconds = FALSE) {
 449    return array(
 450      'H:i:s',
 451      'h:i:sA',
 452      );
 453  }
 454  
 455  /**
 456   * Format options array.
 457   * 
 458   * There are just a few options available for the earlier 'calendar'
 459   * version.
 460   */
 461  function date_popup_formats() {
 462    return array_keys(date_format_options());
 463  }
 464  
 465  /**
 466   * Store personalized format options for each user.
 467   *
 468   * TODO see what is needed to remove this completely.
 469   * It is now only used by Date Popup and not really needed there.
 470   *
 471   * @return array
 472   */
 473  function date_format_options() {
 474    global $user;
 475    $options = array();
 476    $formats = date_get_formats();
 477    $options = array();
 478    module_load_include('inc', 'date', 'date_admin');
 479    $now = date_example_date();
 480    if (!empty($now)) {
 481      foreach ($formats as $type => $format_types) {
 482        foreach ($format_types as $format => $format_attributes) {
 483          // Create an option that shows date only without time, along with the
 484          // default string which has both date and time.
 485          $no_time = date_limit_format($format, array('month', 'day', 'year'));
 486          $zones = array('', 'O', 'P', 'e');
 487          foreach ($zones as $zone) {
 488            $time_format = !empty($zone) ? $format .' '. $zone : $format;
 489            $options[$no_time] = date_format_date($now, 'custom', $no_time);
 490            $options[$time_format] = date_format_date($now, 'custom', $time_format);
 491          }
 492        }
 493      }
 494      asort($options);
 495    }
 496    return $options;
 497  }
 498  
 499  /**
 500   * Recreate a date format string so it has the values popup expects.
 501   *
 502   * @param string $format
 503   *   a normal date format string, like Y-m-d
 504   * @return string
 505   *   A format string in popup format, like YMD-, for the 
 506   *   earlier 'calendar' version, or m/d/Y for the later 'datepicker' 
 507   *   version.
 508   */
 509  function date_popup_format_to_popup($format) {
 510    if (empty($format)) {
 511      $format = 'Y-m-d';
 512    }
 513    $replace = datepicker_format_replacements();
 514    return strtr($format, $replace);
 515  }
 516  
 517  /**
 518   * Recreate a date format string so it has the values popup expects.
 519   *
 520   * @param string $format
 521   *   a normal date format string, like Y-m-d
 522   * @return string
 523   *   a format string in popup format, like YMD-
 524   */
 525  function date_popup_format_to_popup_time($format) {
 526    if (empty($format)) {
 527      $format = 'H:i';
 528    }
 529    $format = strtr($format, timepicker_format_replacements());
 530    $format = str_replace(array(' ', '/', '-', '.', ',', 'F', 'M', 'l', 'z', 'w', 'W', 'd', 'j', 'm', 'n', 'y', 'Y'), '', $format);
 531    return $format;
 532  }
 533  
 534  /**
 535   * Reconstruct popup format string into normal format string.
 536   *
 537   * @param string $format
 538   *   a string in popup format, like YMD-
 539   * @return string
 540   *   a normal date format string, like Y-m-d
 541   */
 542  function date_popup_popup_to_format($format) {
 543    $replace = array_flip(datepicker_format_replacements());
 544    return strtr($format, $replace);
 545  }
 546  
 547  function timepicker_format_replacements() {
 548    return array(
 549      'G' => 'H',
 550      'g' => 'h',
 551      'a' => 'A',
 552      ' a' => 'A',
 553      ' A' => 'A',
 554      );
 555  }
 556  
 557  /**
 558   * The format replacement patterns for the new datepicker.
 559   */
 560  function datepicker_format_replacements() {
 561    return array(
 562     'd' => 'dd',
 563     'j' => 'd',
 564     'l' => 'DD',
 565     'D' => 'D',
 566     'm' => 'mm',
 567     'n' => 'm',
 568     'F' => 'MM',
 569     'M' => 'M',
 570     'Y' => 'yy',
 571     'y' => 'y',
 572     );
 573  }
 574  
 575  /**
 576   * Format a date popup element.
 577   *
 578   * Use a class that will float date and time next to each other.
 579   */
 580  function theme_date_popup($element) {
 581    $output = '';
 582    $class = 'container-inline-date form-item';
 583    // Add #date_float to allow date parts to float together on the same line. 
 584    if (empty($element['#date_float'])) {
 585      $class .= ' date-clear-block';
 586    }
 587    if (isset($element['#children'])) {
 588      $output = $element['#children'];
 589    }
 590    return '<div class="'. $class .'">'. theme('form_element', $element, $output) .'</div>';
 591  }
 592  
 593  /**
 594   * Implementation of hook_menu().
 595   */
 596  function date_popup_menu() {
 597    $items = array();
 598  
 599    $items['admin/settings/date_popup'] = array(
 600      'title' => 'Date Popup Configuration',
 601      'description' => 'Allows the user to configure the Date Popup settings.',
 602      'page callback' => 'drupal_get_form',
 603      'page arguments' => array('date_popup_settings'),
 604      'access callback' => 'user_access',
 605      'access arguments' => array('administer site configuration'),
 606      'type' => MENU_NORMAL_ITEM,
 607    );
 608    return $items;
 609  }
 610  /**
 611   * General configuration form for controlling the Date Popup behaviour.
 612   */
 613  function date_popup_settings() {
 614    $form['date_popup_css_file'] = array(
 615      '#type' => 'select',
 616      '#title' => t('Datepicker css'),
 617      '#description' => t('Choose the css to use for the jQuery UI datepicker.'),
 618      '#options' => date_popup_css_options(),
 619      '#default_value' => variable_get('date_popup_css_file', date_popup_css_default()),
 620    );
 621    $form['date_popup_css_file']['#prefix'] = t('<p>The Date Popup calendar datepicker uses the jQuery UI datepicker. You must install the jQuery UI module for this to work. It has its own css file, or there is a Drupal adaptation included in Date Popup that you can use.</p>');
 622      
 623    $form['date_popup_timepicker'] = array(
 624      '#type' => 'select',
 625      '#options' => array('default' => t('Use default jQuery timepicker'), 'none' => t('Manual time entry, no jQuery timepicker')),
 626      '#title' => t('Timepicker'),
 627      '#default_value' => variable_get('date_popup_timepicker', 'default'),
 628      '#description' => t("Choose the jQuery timepicker to user."),
 629    );
 630  
 631    $form['date_popup_timepicker']['#prefix'] .= t('<p>The Date Popup module uses a jQuery timepicker module. There is no "official" jQuery UI timepicker, and not everyone likes the one that is included here. If you do not want to use the timepicker, you can turn it off below and users will get a regular textfield instead.</p>');
 632    
 633    $css = <<<EOM
 634  /* ___________ IE6 IFRAME FIX ________ */
 635  .ui-datepicker-cover {
 636    display: none; /*sorry for IE5*/
 637    display/**/: block; /*sorry for IE5*/
 638    position: absolute; /*must have*/
 639    z-index: -1; /*must have*/
 640    filter: mask(); /*must have*/
 641    top: -4px; /*must have*/
 642    left: -4px; /*must have*/ /* LTR */
 643    width: 200px; /*must have*/
 644    height: 200px; /*must have*/
 645  }
 646  EOM;
 647  
 648    $form['#suffix'] = t('<p>The Date Popup calendar includes some css for IE6 that breaks css validation. Since IE 6 is now superceded by IE 7 and IE 8, the special css for IE 6 has been removed from the regular css used by the Date Popup. If you find you need that css after all, you can add it back in your theme. Look at the way the Garland theme adds special IE-only css in in its page.tpl.php file. The css you need is:</p>') .'<blockquote><PRE>'. $css .'</PRE></blockquote>';
 649  
 650    return system_settings_form($form);
 651  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7