function apachesolr_enabled_facets_form in Apache Solr Search 5.2
Same name and namespace in other branches
- 6 apachesolr.admin.inc \apachesolr_enabled_facets_form()
- 6.2 apachesolr.admin.inc \apachesolr_enabled_facets_form()
Creates the form that allows the user to select which facets will be enabled.
Only enabled facets are sent to solr. Fewer enabled facets can reduce the load on the search server. Blocks are only offered for enabled facets, so this also reduces the clutter on the blocks admin page.
1 string reference to 'apachesolr_enabled_facets_form'
- apachesolr_menu in ./
apachesolr.module - Implementation of hook_menu().
File
- ./
apachesolr.admin.inc, line 241 - Administrative pages for the Apache Solr framework.
Code
function apachesolr_enabled_facets_form() {
$facets = array();
$module_facets = array();
$module_list = array();
foreach (module_implements('apachesolr_facets') as $module) {
$module_facets[$module] = module_invoke($module, 'apachesolr_facets');
uasort($module_facets[$module], '_apachesolr_sort_facets');
$module_list[$module] = $module;
}
$enabled_facets = apachesolr_get_enabled_facets();
$form = array();
$form['apachesolr_enabled_facets']['help'] = array(
'#type' => 'item',
'#value' => t('You can use this screen to select which search filter blocks should be created by enabling the corresponding filters on this page. For performance reasons, you should only enable filters that you intend to have available to users on the search page. After selecting which filter blocks to create, you will be sent to the blocks page where you can choose which of those blocks should be enabled when your users search by placing each block in a region.'),
);
foreach ($module_list as $module => $name) {
$module_list[$module] = _module_parse_info_file(drupal_get_path('module', $module) . '/' . $module . '.info');
}
foreach ($module_facets as $module => $facets) {
$form['apachesolr_enabled_facets'][$module] = array(
'#type' => 'fieldset',
'#title' => check_plain($module_list[$module]['name']),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
// We must use module + delta as the keys since that combination is
// guaranteed to be unique. A single module could, for example, have
// two different blocks that expose different faceting on the same
// field in the index.
foreach ($facets as $delta => $data) {
$form['apachesolr_enabled_facets'][$module][$delta] = array(
'#type' => 'checkbox',
'#title' => $data['info'],
'#return_value' => $data['facet_field'],
'#default_value' => isset($enabled_facets[$module][$delta]) ? $data['facet_field'] : 0,
);
}
}
$has_facets = (bool) $module_facets;
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#access' => $has_facets,
);
$form['no-facets-message'] = array(
'#value' => t('<em>No filters are available from your currently enabled modules</em>'),
'#access' => !$has_facets,
);
$form['#tree'] = TRUE;
$form['submit_message'] = array(
'#type' => 'value',
'#value' => t('The Apache Solr filters settings were changed. To arrange the blocks for your enabled filters, visit the <a href="@url">blocks administration page</a>.', array(
'@url' => url('admin/build/block'),
)),
);
return $form;
}