You are here

function _yashare_field_formatter_settings_form in Yandex.Share 7.2

Pseudo hook_field_formatter_settings_form().

1 call to _yashare_field_formatter_settings_form()
yashare_form_field_ui_display_overview_form_alter in ./yashare.module
Implements hook_form_FORM_ID_alter().

File

./yashare.module, line 266

Code

function _yashare_field_formatter_settings_form($build, $summary = NULL) {
  $display_stored = field_bundle_settings($build['#entity_type'], $build['#bundle']);
  $display_defaults = yashare_field_extra_fields(TRUE);
  if (!empty($summary)) {
    $settings = $summary;
  }
  elseif (isset($display_stored['extra_fields']['display']['yashare'][$build['#view_mode']])) {
    $settings = $display_stored['extra_fields']['display']['yashare'][$build['#view_mode']]['settings'];
  }
  else {
    $settings = $display_defaults['extra_fields']['display']['yashare']['settings'];
  }
  $options = array();
  $field_instances = field_info_instances($build['#entity_type'], $build['#bundle']);
  foreach ($field_instances as $field_name => $field) {
    $field_info = field_info_field($field_name);
    if (in_array($field_info['type'], array(
      'image',
    ))) {
      $options[$field_name] = $field_instances[$field_name]['label'];
    }
  }
  $form['image_field'] = array(
    '#type' => 'select',
    '#title' => t('Image field'),
    '#description' => t('Choose image field to use as image to share.'),
    '#default_value' => $settings['image_field'],
    '#empty_option' => t('None'),
    '#options' => $options,
  );
  $options = image_style_options(FALSE);
  $form['image_style'] = array(
    '#type' => 'select',
    '#title' => t('Image style'),
    '#default_value' => $settings['image_style'],
    '#empty_option' => t('None (original image)'),
    '#options' => $options,
    '#states' => array(
      'invisible' => array(
        ':input[name="fields[yashare][settings_edit_form][settings][image_field]"]' => array(
          'value' => '',
        ),
      ),
    ),
  );
  $form['description'] = array(
    '#type' => 'textfield',
    '#title' => t('Description'),
    '#description' => t('Text to share. This field supports tokens.'),
    '#default_value' => $settings['description'],
  );
  if (module_exists('token')) {
    $form['token_tree'] = array(
      '#theme' => 'token_tree',
      '#token_types' => array(
        $build['#entity_type'],
      ),
      '#global_types' => FALSE,
      '#dialog' => TRUE,
    );
  }
  return $form;
}