You are here

function opening_hours_js_settings in Opening hours 7

Generate the JavaScript settings array shared between presentation and admin.

1 call to opening_hours_js_settings()
opening_hours_js_attach_common in ./opening_hours.module
Common JavaScript attachments.

File

./opening_hours.module, line 489
Opening hours module.

Code

function opening_hours_js_settings($nid = NULL) {
  $settings = array(
    'blockedDays' => variable_get('opening_hours_blocked_days', array()),
    'firstDayOfWeek' => (int) variable_get('date_first_day', 1),
    // Options for the jQuery UI datepicker date formatter.
    'formatDate' => array(
      'monthNames' => array(
        t('January'),
        t('February'),
        t('March'),
        t('April'),
        t('May'),
        t('June'),
        t('July'),
        t('August'),
        t('September'),
        t('October'),
        t('November'),
        t('December'),
      ),
      'dayNames' => array(
        t('Sunday'),
        t('Monday'),
        t('Tuesday'),
        t('Wednesday'),
        t('Thursday'),
        t('Friday'),
        t('Saturday'),
      ),
    ),
  );
  $settings['categories'] = array();

  // If we have a category vocabulary selected for this node
  // type, get the category terms and export them as a setting.
  if (function_exists('taxonomy_vocabulary_machine_name_load')) {
    if ($nid) {
      $node = node_load($nid);
    }
    else {
      $node = menu_get_object();
    }
    if (!empty($node->type)) {
      $machine_name = variable_get('opening_hours_category_vocabulary_' . $node->type, 0);
      if (!empty($machine_name)) {
        $vocabulary = taxonomy_vocabulary_machine_name_load($machine_name);
        if ($vocabulary) {
          foreach (taxonomy_get_tree($vocabulary->vid, 0, 1) as $term) {
            $settings['categories'][$term->tid] = $term->name;
          }
        }
      }
    }
  }
  return $settings;
}