[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

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

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


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7