You are here

function addtocalendar_settings_form in Add To Calendar Button (AddEvent.com) 7.2

Settings form for widets and field type.

Parameters

array $settings: Wudget settings.

array $field_list: Contains field list.

Return value

array|mixed Contains form fields.

2 calls to addtocalendar_settings_form()
addtocalendar_field_formatter_settings_form_alter in ./addtocalendar.module
Implements hook_field_formatter_settings_form_alter().
addtocalendar_field_widget_settings_form in ./addtocalendar.module
Implements hook_field_widget_settings_form().

File

includes/addtocalendar.inc, line 19
Includes settings form and addtocalendar build processor.

Code

function addtocalendar_settings_form(array $settings, array $field_list) {
  $settings_form['addtocalendar_show'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show Add to Calendar'),
    '#default_value' => isset($settings['addtocalendar_show']) ? $settings['addtocalendar_show'] : '',
  );
  $settings_form['addtocalendar_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Add to Calendar Settings'),
    '#states' => array(
      "visible" => array(
        "input[name*='addtocalendar_show']" => array(
          "checked" => TRUE,
        ),
      ),
    ),
  );
  $settings_form['addtocalendar_settings']['display_text'] = array(
    '#type' => 'textfield',
    '#title' => t('Display Text'),
    '#default_value' => isset($settings['addtocalendar_settings']['display_text']) ? $settings['addtocalendar_settings']['display_text'] : t('Add to Calendar'),
  );
  if (isset($settings['widget_setting_form'])) {
    $settings_form['addtocalendar_settings']['disable_text'] = array(
      '#type' => 'textfield',
      '#title' => t('Disable Text'),
      '#default_value' => isset($settings['addtocalendar_settings']['disable_text']) ? $settings['addtocalendar_settings']['disable_text'] : t('Add to Calendar is disabled'),
    );
  }
  $settings_form['addtocalendar_settings']['style'] = array(
    '#type' => 'select',
    '#title' => t('Select Style'),
    '#options' => array(
      0 => t('No Styling'),
      'blue' => t('Blue'),
      'glow_orange' => t('Glow Orange'),
    ),
    '#default_value' => !empty($settings['addtocalendar_settings']['style']) ? $settings['addtocalendar_settings']['style'] : 'blue',
  );
  $field_options = array();
  foreach ($field_list as $id => $field_i) {
    $field_options[$id] = $field_i['label'];
  }
  $field_options = array_merge(array(
    'token' => t('Use Token/Static Content'),
  ), array(
    'title' => t('Title'),
  ), $field_options);
  $info = array(
    'atc_title' => t('Title'),
    'atc_description' => t('Description'),
    'atc_location' => t('Location'),
    'atc_organizer' => t('Organizer'),
    'atc_date_start' => t('Start date'),
    'atc_date_end' => t('End date'),
  );
  foreach ($info as $id => $label) {
    $settings_form['addtocalendar_settings'][$id]['field'] = array(
      '#type' => 'select',
      '#title' => t('@label : field', [
        '@label' => $label,
      ]),
      '#options' => $field_options,
      '#description' => t('Select field to be used as @label for calendar events', array(
        '@label' => $label,
      )),
      '#default_value' => !empty($settings['addtocalendar_settings'][$id]['field']) ? $settings['addtocalendar_settings'][$id]['field'] : '',
    );
    $default_value = $label;
    if ($id == 'atc_date_start' || $id == 'atc_date_end') {
      $default_value = date('Y-m-d H:i:s', time());
    }
    $settings_form['addtocalendar_settings'][$id]['tokenized'] = array(
      '#type' => 'textfield',
      '#title' => check_plain($label . ': Static/Tokenized Content'),
      '#default_value' => !empty($settings['addtocalendar_settings'][$id]['tokenized']) ? $settings['addtocalendar_settings'][$id]['tokenized'] : $default_value,
      '#description' => t('Select field to be used as @label for calendar events', [
        '@label' => $label,
      ]),
    );
  }
  if (!isset($settings['widget_setting_form'])) {
    unset($settings_form['addtocalendar_settings']['atc_date_start']['field']);
    unset($settings_form['addtocalendar_settings']['atc_date_start']['tokenized']);
  }
  $settings_form['addtocalendar_settings']['atc_organizer_email'] = array(
    '#type' => 'textfield',
    '#title' => t('Organizer email: Static/Tokenized Content'),
    '#default_value' => !empty($settings['addtocalendar_settings']['atc_organizer_email']) ? $settings['addtocalendar_settings']['atc_organizer_email'] : variable_get('site_mail', ''),
  );
  $settings_form['addtocalendar_settings']['atc_privacy'] = array(
    '#type' => 'select',
    '#title' => t('Privacy'),
    '#options' => array(
      'public' => t('Public'),
      'private' => t('Private'),
    ),
    '#description' => t('Use public for free access to event information from any places. User private if the event is closed to public access.'),
    '#default_value' => !empty($settings['addtocalendar_settings']['atc_privacy']) ? $settings['addtocalendar_settings']['atc_privacy'] : '',
  );
  $settings_form['addtocalendar_settings']['data_secure'] = array(
    '#type' => 'select',
    '#title' => t('Security level'),
    '#options' => array(
      'auto' => t('Auto'),
      'true' => t('Use https only'),
      'false' => t('Use http only'),
    ),
    '#default_value' => !empty($settings['addtocalendar_settings']['data_secure']) ? $settings['addtocalendar_settings']['data_secure'] : '',
  );
  $settings_form['addtocalendar_settings']['data_calendars'] = array(
    '#type' => 'checkboxes',
    '#options' => array(
      'iCalendar' => t('iCalendar'),
      'Google Calendar' => t('Google Calendar'),
      'Outlook' => t('Outlook'),
      'Outlook Online' => t('Outlook Online'),
      'Yahoo! Calendar' => t('Yahoo! Calendar'),
    ),
    '#default_value' => !empty($settings['addtocalendar_settings']['data_calendars']) ? $settings['addtocalendar_settings']['data_calendars'] : array(),
    '#title' => t('List of calendars to show in button list.'),
  );
  return $settings_form;
}