You are here

function google_appliance_form_block_admin_configure_alter in Google Search Appliance 7

Implements hook_form_FORM_ID_alter().

This function adds a custom field to block editing forms to allow editors to conditionally hide content from the crawler using googleon/googleoff tags.

File

./google_appliance.module, line 291
Google Appliance module enables searching via a dedicated Google Search Appliance hardware device. See README.txt and the help page at admin/help/google_appliance.

Code

function google_appliance_form_block_admin_configure_alter(&$form, &$form_state, $form_id) {
  $settings = _google_appliance_get_settings();

  // Determine the default value for this block.
  $default = 'none';
  $module = $form['module']['#value'];
  $delta = $form['delta']['#value'];
  if (isset($settings['block_visibility_settings'][$module][$delta])) {
    $default = $settings['block_visibility_settings'][$module][$delta];
  }

  // Add a Google Appliance visibility fieldset.
  $read_more_link = 'https://developers.google.com/search-appliance/documentation/64/admin_crawl/Preparing';
  $form['visibility']['google_appliance'] = array(
    '#type' => 'fieldset',
    '#title' => t('Google Appliance'),
    '#collapsible' => 1,
    '#collapsed' => 1,
    '#group' => 'visibility',
    '#weight' => 30,
    'crawler' => array(
      '#type' => 'radios',
      '#title' => t('Visible to Google Appliance crawler'),
      '#description' => '<p>' . t('Configure how the Google Search Appliance crawler handles the contents of this block.') . '</p>' . '<p>' . t('For more information, see the relevant') . ' ' . l(t('Google Search Appliance documentation'), $read_more_link, array(
        'fragment' => 'pagepart',
        'attributes' => array(
          'target' => '_blank',
        ),
      )) . '.</p>',
      '#options' => array(
        'none' => t('No restrictions'),
        'index' => t('Exclude block contents from index'),
        'anchor' => t('Disassociate anchor text from target pages within this block'),
        'snippet' => t('Exclude block contents from search snippets'),
        'all' => t('All of the above'),
      ),
      '#default_value' => $default,
    ),
  );

  // Attach a submit handler to save our preferences.
  $form['#submit'][] = 'google_appliance_block_visibility_submit';
}