You are here

function date_api_status in Date 7.2

Same name and namespace in other branches
  1. 7.3 date_api/date_api.module \date_api_status()

Helper function to retun the status of required date variables.

2 calls to date_api_status()
date_api_requirements in date_api/date_api.install
Implements hook_requirements().
date_help in date_api/date_api.module
Implements hook_help().

File

date_api/date_api.module, line 78
This module will make the date API available to other modules.

Code

function date_api_status() {
  $t = get_t();
  $error_messages = array();
  $success_messages = array();
  $value = variable_get('date_default_timezone');
  if (isset($value)) {
    $success_messages[] = $t('The timezone has been set to <a href="@regional_settings">@timezone</a>.', array(
      '@regional_settings' => url('admin/config/regional/settings'),
      '@timezone' => $value,
    ));
  }
  else {
    $error_messages[] = $t('The Date API requires that you set up the <a href="@regional_settings">site timezone</a> to function correctly.', array(
      '@regional_settings' => url('admin/config/regional/settings'),
    ));
  }
  $value = variable_get('date_first_day');
  if (isset($value)) {
    $days = date_week_days();
    $success_messages[] = $t('The first day of the week has been set to <a href="@regional_settings">@day</a>.', array(
      '@regional_settings' => url('admin/config/regional/settings'),
      '@day' => $days[$value],
    ));
  }
  else {
    $error_messages[] = $t('The Date API requires that you set up the <a href="@regional_settings">site first day of week settings</a> to function correctly.', array(
      '@regional_settings' => url('admin/config/regional/settings'),
    ));
  }
  $value = variable_get('date_format_medium');
  if (isset($value)) {
    $now = date_now();
    $success_messages[] = $t('The medium date format type has been set to @value. You may find it helpful to add new format types like Date, Time, Month, or Year, with appropriate formats, at <a href="@regional_date_time">Date and time</a> settings.', array(
      '@value' => $now
        ->format($value),
      '@regional_date_time' => url('admin/config/regional/date-time'),
    ));
  }
  else {
    $error_messages[] = $t('The Date API requires that you set up the <a href="@regional_date_time">system date formats</a> to function correctly.', array(
      '@regional_date_time' => url('admin/config/regional/date-time'),
    ));
  }
  return array(
    'errors',
    $error_messages,
    'success' => $success_messages,
  );
}