You are here

function popup_filter_form_alter in Popup 7.x

Same name and namespace in other branches
  1. 8 modules/popup_filter/popup_filter.module \popup_filter_form_alter()
  2. 7 modules/popup_filter/popup_filter.module \popup_filter_form_alter()
  3. 6.x modules/popup_filter/popup_filter.module \popup_filter_form_alter()

Implementation of hook_form_alter

Hooked to ad popup filter form to the bottom of filtered inputs

_state _id

Parameters

$form:

File

modules/popup_filter/popup_filter.module, line 75

Code

function popup_filter_form_alter(&$form, &$form_state, $form_id) {
  $block_form = in_array($form_id, array(
    'block_add_block_form',
    'block_admin_configure',
  ));
  $node_form = preg_match('/node_form$/', $form_id);
  if (user_access('administer popup elements') && ($block_form || $node_form)) {
    module_load_include('inc', 'popup', 'includes/popup.api');
    module_load_include('inc', 'popup_filter', 'includes/popup_filter.admin');
    $attributes = array(
      'activate' => 'click',
      'class' => 'popup-filter-admin-form',
      'close' => TRUE,
      'effect' => 'slide-down-fade',
      'expand' => 'bottom-left',
      'origin' => 'bottom-right',
      'width' => 650,
    );
    $popup_form = popup_filter_insert_form();
    $popup_form = popup_element(t('Insert popup element'), $popup_form, $attributes);
    if ($block_form) {
      if (isset($form['settings']['body_field'])) {
        $form['settings']['popup_form'] = array(
          '#markup' => $popup_form,
          '#weight' => $form['settings']['body_field']['#weight'] - 1,
        );
      }
    }
    else {
      if (isset($form['body'])) {
        $form['popup_form'] = array(
          '#markup' => $popup_form,
          '#weight' => $form['body']['#weight'] - 1,
        );
      }
    }
  }
}