You are here

function popup_block_form_alter in Popup 7

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

Implementation of hook_form_alter Adds UI settings to block configuration

File

modules/popup_block/popup_block.module, line 9

Code

function popup_block_form_alter(&$form, $form_state, $form_id) {
  if ($form_id == 'block_admin_configure' && $form['module']['#value'] != 'popup_menu') {
    module_load_include('inc', 'popup_ui', 'includes/popup_ui.admin');
    $settings = _popup_block_settings();
    $block_settings = isset($settings[$form['module']['#value'] . ':' . $form['delta']['#value']]) ? $settings[$form['module']['#value'] . ':' . $form['delta']['#value']] : FALSE;
    $format_options = array_keys(_popup_ui_formatter_settings());
    array_unshift($format_options, 'Default');
    $display_format_options = array_combine($format_options, $format_options);
    $length_options = range(10, 200, 10);
    $length_options = array_combine($length_options, $length_options);
    $form['display_title'] = array(
      '#type' => 'item',
      '#title' => 'Display settings',
      '#weight' => 1,
    );
    $form['regions'] = array(
      '#type' => 'vertical_tabs',
      '#weight' => 2,
      '#attached' => array(
        'js' => array(
          'modules/block/block.js',
        ),
      ),
      'regions' => $form['regions'],
      'popup' => array(
        '#type' => 'fieldset',
        '#title' => t('Popup settings'),
        '#collapsible' => 0,
        '#group' => 'Display',
        'popup-block' => array(
          '#default_value' => $block_settings['active'],
          '#description' => t('This will render the block with the body initially invisible. When a user hovers over or clicks on the title, the body is displayed.'),
          '#title' => t('Display this block as a popup'),
          '#type' => 'checkbox',
        ),
        'popup-block-format' => array(
          '#default_value' => isset($block_settings['format']) ? $block_settings['format'] : '',
          '#title' => 'Display format',
          '#type' => 'select',
          '#options' => $display_format_options,
          '#description' => t('Select the format in which to display popups. You may manage popup formats !here.', array(
            '!here' => l('here', 'admin/config/user-interface/popup/formats'),
          )),
        ),
        'popup-title-length' => array(
          '#default_value' => isset($block_settings['title-length']) ? $block_settings['title-length'] : 10,
          '#title' => 'Title length',
          '#type' => 'select',
          '#options' => $length_options,
          '#description' => t('Select the length of text to use from the body if no title is present.', array(
            '!here' => l('here', 'admin/config/user-interface/popup/formats'),
          )),
        ),
      ),
    );
    $form['settings']['#weight'] = 0;
    $form['visibility_title']['#weight'] = 3;
    $form['visibility']['#weight'] = 4;
    $form['submit']['#weight'] = 10;
    $form['#submit'][] = 'popup_block_form_submit';
  }
}