<?php
// $Id:

function datepicker_requirements($phase) {
  $requirements = array();
  $t = get_t();

  $path = drupal_get_path('module', 'datepicker');
  $css = file_exists($path .'/datePicker.css');
  $date_js = file_exists($path .'/date.js');
  $picker_js = file_exists($path .'/jquery.datePicker.js');

  $requirements['datepicker_css']['title'] = $t('Date picker CSS');
  if (!$css) {
    $requirements['datepicker_css']['value'] = $t('Not found');
    $requirements['datepicker_css']['description'] = $t('Missing CSS file. Please !download it to your datepicker module directory. See README.txt for more info.', array('!download' => l(t('download the datepicker CSS file'), 'http://www.kelvinluck.com/assets/jquery/datePicker/v2/demo/styles/datePicker.css')));
    $requirements['datepicker_css']['severity'] = REQUIREMENT_ERROR;
  }
  else {
    $requirements['datepicker_css']['value'] = $t('Found');
  }

  $requirements['datepicker_datejs']['title'] = $t('Date library');
  if (!$date_js) {
    $requirements['datepicker_datejs']['value'] = $t('Not found');
    $requirements['datepicker_datejs']['description'] = $t('Missing Date jQuery plugin. Please !download and extract it to your datepicker module directory. See README.txt for more info.', array('!download' => l(t('download the Date jQuery plugin'), 'http://jqueryjs.googlecode.com/svn/trunk/plugins/methods/date.js')));
    $requirements['datepicker_datejs']['severity'] = REQUIREMENT_ERROR;
  }
  else {
    $requirements['datepicker_datejs']['value'] = $t('Found');
  }

  $requirements['datepicker_jquery']['title'] = $t('datePicker plugin');
  if (!$picker_js) {
    $requirements['datepicker_jquery']['value'] = $t('Not found');
    $requirements['datepicker_jquery']['description'] = $t('Missing jQuery datePicker plug-in. Please !download it to your datepicker module directory and rename it to jquery.datePicker.js. See README.txt for more info.', array('!download' => l(t('download the jQuery datePicker plugin'), 'http://code.google.com/p/jquery-datepicker/')));
    $requirements['datepicker_jquery']['severity'] = REQUIREMENT_ERROR;
  }
  else {
    $requirements['datepicker_jquery']['value'] = $t('Found');
  }

  return $requirements;
}

function datepicker_install() {
  $ret = array();
  // we need to run after event.module
  $ret[] = update_sql("UPDATE {system} SET weight = 1 WHERE name = 'datepicker'");
  return $ret;
}
