You are here

function easy_social_form_node_type_form_alter in Easy Social 7.2

Implements hook_form_FORM_ID_alter().

Adds Easy Social options to node type forms.

File

./easy_social.module, line 805
Easy social module.

Code

function easy_social_form_node_type_form_alter(&$form, $form_state) {
  $type = $form['#node_type']->type;
  if (!empty($type)) {
    $options = _easy_social_get_options();
    $form['#submit'][] = 'easy_social_node_type_form_submit';
    $form['easy_social'] = array(
      '#type' => 'fieldset',
      '#title' => t('Easy Social settings'),
      '#group' => 'additional_settings',
      '#tree' => TRUE,
      '#attached' => array(
        'js' => array(
          drupal_get_path('module', 'easy_social') . '/js/easy_social_settings_form.js',
        ),
      ),
      '#attributes' => array(
        'class' => array(
          'easysocial-settings-form',
        ),
      ),
    );
    $form['easy_social']["easy_social_{$type}_enable"] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable Easy Social'),
      '#description' => t('Check this option to enable easy social for this content type'),
      '#default_value' => variable_get_value("easy_social_{$type}_enable"),
      '#attributes' => array(
        'class' => array(
          'easy-social-current-type',
        ),
      ),
    );
    if (module_exists('comment') && variable_get_value("easy_social_{$type}_enable")) {
      $form['easy_social']["easy_social_comment_{$type}_enable"] = array(
        '#type' => 'checkbox',
        '#title' => t('Enable Easy Social on comments'),
        '#description' => t('Check this option to enable easy social for this content type\'s comments'),
        '#default_value' => variable_get_value("easy_social_comment_{$type}_enable"),
        '#attributes' => array(
          'class' => array(
            'easy-social-comment-type',
          ),
        ),
      );
    }
    $form['easy_social']["easy_social_{$type}_count"] = array(
      '#type' => 'select',
      '#title' => t('Number of Easy Social fields'),
      '#description' => t('You can add more than one Easy Social field to your nodes. This is useful, for example, to add the widget both at top and at the bottom of a node.'),
      '#options' => array(
        '1' => 1,
        '2' => 2,
      ),
      '#default_value' => variable_get_value("easy_social_{$type}_count"),
      '#attributes' => array(
        'class' => array(
          'easy-social-number-fields-type',
        ),
      ),
    );
    $form['easy_social']["easy_social_{$type}_type"] = array(
      '#type' => 'radios',
      '#title' => t('Type of buttons'),
      '#options' => array(
        EASY_SOCIAL_WIDGET_HORIZONTAL => t('Horizontal'),
        EASY_SOCIAL_WIDGET_VERTICAL => t('Vertical'),
      ),
      '#default_value' => _easy_social_variable_get_value("easy_social_{$type}_type"),
      '#attributes' => array(
        'class' => array(
          'easy-social-type-buttons',
        ),
      ),
    );
    $form['easy_social']["easy_social_{$type}_widgets"] = array(
      '#type' => 'checkboxes',
      '#title' => t('Social Widgets'),
      '#options' => $options,
      '#default_value' => _easy_social_variable_get_value("easy_social_{$type}_widgets"),
      '#attributes' => array(
        'class' => array(
          'easy-social-each-widget',
        ),
      ),
    );
  }
}