You are here

function date_popup_init in Date 6.2

Same name and namespace in other branches
  1. 6 date_popup/date_popup.module \date_popup_init()
  2. 7 date_popup/date_popup.module \date_popup_init()

Implementation of hook_init().

File

date_popup/date_popup.module, line 92
A module to enable jquery calendar and time entry popups. Requires the Date API.

Code

function date_popup_init() {
  global $user;
  if (!module_exists('jquery_ui') || !function_exists('jquery_ui_get_path')) {
    if ($user->uid == 1) {
      drupal_set_message(t('The Date Popup module now requires the <a href="@link">jQuery UI module</a> version 6.x-1.5 or higher as a source for the datepicker. Please install it immediately.', array(
        '@link' => 'http://drupal.org/project/jquery_ui',
      )), 'error');
    }
    return;
  }
  $date_popup_css_file = variable_get('date_popup_css_file', date_popup_css_default());

  // Force loading base jquery-ui.css when using date_popup default theme,
  // otherwise the popup calendar will be displayed with no theme at all.
  if ($date_popup_css_file == date_popup_css_default()) {
    drupal_add_css(jquery_ui_get_path() . '/themes/base/jquery-ui.css');
  }
  else {
    drupal_add_css(dirname($date_popup_css_file) . '/jquery-ui.css');
  }
  drupal_add_css($date_popup_css_file);
  if (variable_get('date_popup_timepicker', 'default') == 'default') {
    drupal_add_css(drupal_get_path('module', 'date_popup') . '/themes/jquery.timeentry.css');
  }
}