47
49
function date_popup_init() {
48
50
drupal_add_css(drupal_get_path('module', 'date_popup') .'/themes/datepicker.css');
49
drupal_add_css(drupal_get_path('module', 'date_popup') .'/themes/timeentry.css');
51
if (variable_get('date_popup_timepicker', 'default') == 'default') {
52
drupal_add_css(drupal_get_path('module', 'date_popup') .'/themes/timeentry.css');
201
205
$date_granularity = array_intersect($granularity, array('month', 'day', 'year'));
202
206
$time_granularity = array_intersect($granularity, array('hour', 'minute', 'second'));
203
207
$date_format = (date_limit_format($element['#date_format'], $date_granularity));
205
208
if (empty($date_granularity)) return array();
207
210
// The datepicker can't handle zero or negative values like 0:+1
246
249
'#size' => !empty($element['#size']) ? $element['#size'] : 20,
247
250
'#maxlength' => !empty($element['#maxlength']) ? $element['#maxlength'] : 30,
251
'#attributes' => $element['#attributes'],
249
253
// Views exposed filters are treated as submitted even if not,
250
254
// so force the #default value in that case.
268
272
$spinner_text = array(t('Now'), t('Previous field'), t('Next field'), t('Increment'), t('Decrement'));
269
273
$settings = array(
270
'show24Hours' => strpos($element['#date_format'], 'H') ? TRUE : FALSE,
274
'show24Hours' => strpos($element['#date_format'], 'H') !== FALSE ? TRUE : FALSE,
271
275
'showSeconds' => (in_array('second', $granularity) ? TRUE : FALSE),
272
276
'timeSteps' => array(1, intval($element['#date_increment']), (in_array('second', $granularity) ? $element['#date_increment'] : 0)),
273
277
'spinnerImage' => '',
309
313
$date_granularity = array_intersect($granularity, array('month', 'day', 'year'));
310
314
$time_granularity = array_intersect($granularity, array('hour', 'minute', 'second'));
311
315
$label = !empty($element['#date_title']) ? $element['#date_title'] : (!empty($element['#title']) ? $element['#title'] : '');
313
318
// If the field is empty and not required, set it to empty and return.
314
319
// If the field is empty and required, set error message and return.
375
380
$time = date_convert_from_custom(trim(!empty($element['#value']['time']) ? $element['#value']['time'] : ''), $time_format);
376
381
$value = trim(substr($date, 0, 10) .' '. substr($time, 11, 8));
378
384
if (date_is_valid($value, DATE_DATETIME, $granularity)) {
379
385
$date = date_make_date($value, $element['#date_timezone'], DATE_DATETIME, $granularity);
380
386
$value = date_convert($date, DATE_OBJECT, DATE_DATETIME);
413
* Store personalized format options for each user.
415
* TODO see what is needed to remove this completely.
416
* It is now only used by Date Popup and not really needed there.
420
function date_format_options() {
423
$formats = date_get_formats();
425
module_load_include('inc', 'date', 'date_admin');
426
$now = date_example_date();
428
foreach ($formats as $type => $format_types) {
429
foreach ($format_types as $format => $format_attributes) {
430
// Create an option that shows date only without time, along with the
431
// default string which has both date and time.
432
$no_time = date_limit_format($format, array('month', 'day', 'year'));
433
$zones = array('', 'O', 'P', 'e');
434
foreach ($zones as $zone) {
435
$time_format = !empty($zone) ? $format .' '. $zone : $format;
436
$options[$no_time] = date_format_date($now, 'custom', $no_time);
437
$options[$time_format] = date_format_date($now, 'custom', $time_format);
407
447
* Recreate a date format string so it has the values popup expects.
409
449
* @param string $format
493
533
$output = $element['#children'];
495
535
return '<div class="'. $class .'">'. theme('form_element', $element, $output) .'</div>';
539
* Implementation of hook_menu().
541
function date_popup_menu() {
544
$items['admin/settings/date_popup'] = array(
545
'title' => 'Date Popup Configuration',
546
'description' => 'Allows the user to configure the Date Popup settings.',
547
'page callback' => 'drupal_get_form',
548
'page arguments' => array('date_popup_settings'),
549
'access callback' => 'user_access',
550
'access arguments' => array('administer site configuration'),
551
'type' => MENU_NORMAL_ITEM,
556
* General configuration form for controlling the Date Popup behaviour.
558
function date_popup_settings() {
560
$form['#prefix'] = t('<p>The Date Popup calendar datepicker uses the jQuery UI datepicker. A version of that is included with the Date Popup module, but you are strongly encouraged to use the <a href="http://drupal.org/project/jquery_ui">jQuery UI module</a> instead. If the jQuery UI module is installed, the Date Popup will use the datepicker from that module, which is likely to be more current. If you are having any problems with Popups and you are not already using jQuery UI, please do that as a first step before reporting problems.</p>');
561
$form['#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>');
563
$form['date_popup_timepicker'] = array(
565
'#options' => array('default' => t('Use default jQuery timepicker'), 'none' => t('Manual time entry, no jQuery timepicker')),
566
'#title' => t('Timepicker'),
567
'#default_value' => variable_get('date_popup_timepicker', 'default'),
568
'#description' => t("Choose the jQuery timepicker to user."),
572
/* ___________ IE6 IFRAME FIX ________ */
573
.ui-datepicker-cover {
574
display: none; /*sorry for IE5*/
575
display/**/: block; /*sorry for IE5*/
576
position: absolute; /*must have*/
577
z-index: -1; /*must have*/
578
filter: mask(); /*must have*/
579
top: -4px; /*must have*/
580
left: -4px; /*must have*/ /* LTR */
581
width: 200px; /*must have*/
582
height: 200px; /*must have*/
586
$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>';
588
return system_settings_form($form);
b'\\ No newline at end of file'