function apachesolr_form_block_admin_configure_alter in Apache Solr Search 6.2
Same name and namespace in other branches
- 6 apachesolr.module \apachesolr_form_block_admin_configure_alter()
Implementation of hook_form_[form_id]_alter().
Hide the core 'title' field in favor of our 'name' field. Add a checkbox to enable type-specific visibility.
File
- ./
apachesolr.module, line 1010 - Integration with the Apache Solr search application.
Code
function apachesolr_form_block_admin_configure_alter(&$form, $form_state) {
// Hide the core title field.
if ($form['module']['#value'] == 'apachesolr' && $form['delta']['#value'] != 'sort') {
$form['block_settings']['title']['#access'] = FALSE;
}
// Add a type-specific visibility checkbox.
$module = $form['module']['#value'];
$delta = $form['delta']['#value'];
$enabled_facets = apachesolr_get_enabled_facets();
// If this block isn't enabled as a facet, get out of here.
if (!isset($enabled_facets[$module][$delta])) {
return;
}
$facet_info = apachesolr_get_facet_definitions();
if (isset($facet_info[$module][$delta]['content_types'])) {
$type_filter_settings = variable_get('apachesolr_type_filter', array());
// Set up some variables for the verbiage of the form element.
$count = count($facet_info[$module][$delta]['content_types']);
$types = format_plural($count, t('type'), t('types'));
$are = format_plural($count, t('is'), t('are'));
$content_types = implode(', ', $facet_info[$module][$delta]['content_types']) . '.';
$form['block_settings']['apachesolr_type_filter'] = array(
'#type' => 'checkbox',
'#title' => t('Show this block only when the type filter is selected for: %content_types', array(
'%content_types' => $content_types,
)),
'#default_value' => isset($type_filter_settings[$module][$delta]) ? $type_filter_settings[$module][$delta] : FALSE,
'#description' => t('This filter is relevant only for specific content types. Check this to display the block only when the type filter has been selected for one of the relevant content types.'),
'#weight' => 11,
);
}
$operator_settings = variable_get('apachesolr_operator', array());
$form['block_settings']['apachesolr_operator'] = array(
'#type' => 'radios',
'#title' => t('Operator to use for facets'),
'#options' => drupal_map_assoc(array(
'AND',
'OR',
)),
'#default_value' => isset($operator_settings[$module][$delta]) ? $operator_settings[$module][$delta] : 'AND',
'#description' => t('AND filters are exclusive. OR filters are inclusive. Selecting more AND filters narrows the result set. Selecting more OR filters widens the result set.'),
'#weight' => 12,
);
// Add a submit handler to save the value.
$form['#validate'][] = 'apachesolr_block_admin_configure_submit';
}