You are here

function shareaholic_form_node_form_alter in Share Buttons, Related Posts, Content Analytics - Shareaholic 7.3

Same name and namespace in other branches
  1. 8 includes/node.php \shareaholic_form_node_form_alter()

Implements hook_form_node_form_alter().

When the node form is presented, add additional options for Shareaholic Apps

Parameters

Array $form - Nested array of form elements:

Array $form_state - keyed array containing form state:

$form_id - String representing the name of the form itself:

File

includes/node.php, line 72
This file is responsible for containing hooks involving nodes

Code

function shareaholic_form_node_form_alter(&$form, &$form_state, $form_id) {
  $node = $form['#node'];
  $form['shareaholic_options'] = array(
    '#type' => 'fieldset',
    '#access' => TRUE,
    '#title' => 'Shareaholic Options',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#group' => 'additional_settings',
    '#weight' => 100,
  );

  // I have to namespace it this way because Drupal can't add
  // the shareholic_options name to it
  // when you process the form on submit!!!
  $form['shareaholic_options']['shareaholic_hide_share_buttons'] = array(
    '#type' => 'checkbox',
    '#title' => 'Hide Share Buttons',
  );
  $form['shareaholic_options']['shareaholic_hide_recommendations'] = array(
    '#type' => 'checkbox',
    '#title' => 'Hide Related Content',
  );
  $form['shareaholic_options']['shareaholic_exclude_from_recommendations'] = array(
    '#type' => 'checkbox',
    '#title' => 'Exclude from Related Content',
  );
  $form['shareaholic_options']['shareaholic_exclude_og_tags'] = array(
    '#type' => 'checkbox',
    '#title' => 'Do not include Open Graph tags',
  );
  if (!db_table_exists('shareaholic_content_settings')) {
    $form['shareaholic_options']['shareaholic_message'] = array(
      '#type' => 'markup',
      '#markup' => '<p style="color:#FF0000;">' . t('Action required: you have some pending updates required by Shareaholic. Please go to update.php for more information.') . '</p>',
    );
  }
  if ($node->shareaholic_options['shareaholic_exclude_from_recommendations']) {
    $form['shareaholic_options']['shareaholic_exclude_from_recommendations']['#attributes'] = array(
      'checked' => 'checked',
    );
  }
  if ($node->shareaholic_options['shareaholic_hide_recommendations']) {
    $form['shareaholic_options']['shareaholic_hide_recommendations']['#attributes'] = array(
      'checked' => 'checked',
    );
  }
  if ($node->shareaholic_options['shareaholic_hide_share_buttons']) {
    $form['shareaholic_options']['shareaholic_hide_share_buttons']['#attributes'] = array(
      'checked' => 'checked',
    );
  }
  if ($node->shareaholic_options['shareaholic_exclude_og_tags']) {
    $form['shareaholic_options']['shareaholic_exclude_og_tags']['#attributes'] = array(
      'checked' => 'checked',
    );
  }
}