You are here

function birthdays_field_formatter_settings_form in Birthdays 7

Implements hook_field_formatter_settings_form().

File

./birthdays.module, line 371
The Birthdays module allows users to add their birthday to their profile. It lists birthdays on a seperate page and in different blocks. Users can receive an email on their birthday automatically, and the administrator can receive daily reminders of…

Code

function birthdays_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
  $element = array();
  $settings = $instance['display'][$view_mode]['settings'];
  switch ($instance['display'][$view_mode]['type']) {
    case 'birthdays_plaintext':
      $element['#attached'] = array(
        'js' => array(
          drupal_get_path('module', 'system') . '/system.js',
          array(
            'type' => 'setting',
            'data' => array(
              'dateTime' => array(
                'birthdays-dateformat' => array(
                  'text' => t('Displayed as'),
                  'lookup' => url('admin/config/birthdays/lookup'),
                ),
                'birthdays-dateformat-noyear' => array(
                  'text' => t('Displayed as'),
                  'lookup' => url('admin/config/birthdays/lookup-noyear'),
                ),
              ),
            ),
          ),
        ),
      );

      // Only display the with-year format when years are not disabled or when
      // using a dummy view mode from the Views module.
      if ($instance['settings']['hide_year'] != BIRTHDAYS_HIDE_YEAR_YES || $view_mode == '_dummy') {
        $element['dateformat'] = array(
          '#type' => 'textfield',
          '#title' => t('Dateformat with year'),
          '#description' => t('You can use options available from the <a href="http://php.net/manual/en/function.date.php">PHP manual</a>, [starsign] and [age].'),
          '#required' => TRUE,
          '#size' => 10,
          '#default_value' => $settings['dateformat'],
          '#field_suffix' => ' <small id="edit-birthdays-dateformat-suffix"></small>',
          '#id' => 'edit-birthdays-dateformat',
        );
      }

      // Display the no-year format only when having no year is possible. If
      // using Views we can not know for sure.
      if ($instance['settings']['hide_year'] != BIRTHDAYS_HIDE_YEAR_NO || $view_mode == '_dummy') {
        $element['dateformat_noyear'] = array(
          '#type' => 'textfield',
          '#title' => t('Dateformat without year'),
          '#description' => t('You can use options available form the <a href="http://php.net/manual/en/function.date.php">PHP manual</a> and [starsign].'),
          '#required' => TRUE,
          '#size' => 10,
          '#default_value' => $settings['dateformat_noyear'],
          '#id' => 'edit-birthdays-dateformat-noyear',
          '#field_suffix' => ' <small id="edit-birthdays-dateformat-noyear-suffix"></small>',
        );
      }
      break;
    case 'birthdays_starsign':
      $element['starsign_with_yahoo_link'] = array(
        '#type' => 'checkbox',
        '#title' => t('Starsign with link to Yahoo Astrology'),
        '#default_value' => $settings['starsign_with_yahoo_link'],
      );
      break;
  }
  return $element;
}