You are here

function addthis_form_block_admin_configure_alter in AddThis 7.4

Implements hook_form_FORM_ID_alter().

File

includes/addthis.block.inc, line 86
Block related hook implementations for the AddThis-module.

Code

function addthis_form_block_admin_configure_alter(&$form, &$form_state) {
  if ($form['module']['#value'] == 'addthis' && $form['delta']['#value'] == 'addthis_block') {
    form_load_include($form_state, 'inc', 'addthis', 'addthis.block');
    $form['#cache'] = TRUE;
    $form['settings']['addthis_settings'] = array(
      '#type' => 'fieldset',
      '#title' => 'Display settings',
    );

    // Retrieve settings.
    $addthis_settings['type'] = AddThis::getInstance()
      ->getBlockDisplayType();
    $addthis_settings['settings'] = AddThis::getInstance()
      ->getBlockDisplaySettings();

    // Create a addthis settings form based on the available configuration.
    $element = _addthis_settings_form(isset($form['addthis_settings']['form']) ? $form['addthis_settings']['form'] : array(), $form_state, isset($addthis_settings['type']) ? $addthis_settings['type'] : NULL, isset($addthis_settings['settings']) ? $addthis_settings['settings'] : NULL);

    // Change the submit and callback because our handling is different and the
    // form structure is different form the default implementation.
    $element['type']['#submit'] = array(
      '_addthis_settings_form_block_submit',
    );
    $element['type']['#ajax']['callback'] = '_addthis_settings_form_block_submit_callback';
    $form['settings']['addthis_settings']['form'] = $element;
    array_unshift($form['#submit'], '_addthis_settings_form_block_submit');
  }
  return $form;
}