function facetapi_realm_settings_form_submit in Facet API 7.2
Same name and namespace in other branches
- 6.3 facetapi.admin.inc \facetapi_realm_settings_form_submit()
- 7 facetapi.admin.inc \facetapi_realm_settings_form_submit()
Form submission handler for facetapi_realm_settings_form().
1 string reference to 'facetapi_realm_settings_form_submit'
- facetapi_realm_settings_form in ./
facetapi.admin.inc - Form constructor for the realm settings form.
File
- ./
facetapi.admin.inc, line 175 - Admin page callbacks for the Facet API module.
Code
function facetapi_realm_settings_form_submit($form, &$form_state) {
$success = TRUE;
// Pulls variables for code readability.
$adapter = $form['#facetapi']['adapter'];
$realm = $form['#facetapi']['realm'];
$facet_info = $form['#facetapi']['facet_info'];
// Builds settings object, saves to database.
foreach ($facet_info as $facet_name => $facet) {
$status = empty($form_state['values']['enabled_facets'][$facet_name]) ? 0 : 1;
$weight = $realm['sortable'] ? $form_state['values']['weight'][$facet_name] : 0;
if (!facetapi_save_facet_status($adapter, $realm, $facet, $status, $weight, TRUE)) {
$success = FALSE;
$message = t('Error saving configuration options for the %label facet.', array(
'%label' => $facet['label'],
));
drupal_set_message($message, 'error');
}
}
// Sets message if all configurations were saved.
if ($success) {
drupal_set_message(t('The configuration options have been saved.'));
if ('block' == $form['#facetapi']['realm']['name']) {
drupal_set_message(t('To enable or arrange the facet blocks, visit the <a href="@block-page">blocks administration page</a>.', array(
'@block-page' => url('admin/structure/block', array(
'query' => array(
'destination' => current_path(),
),
)),
)));
}
}
// Saves block cache settings, clears block cache if setting was changed.
if (isset($form_state['values']['block_cache'])) {
$name = 'facetapi:block_cache:' . $adapter
->getSearcher();
$original = variable_get($name, DRUPAL_NO_CACHE);
variable_set($name, $form_state['values']['block_cache']);
if ($original != $form_state['values']['block_cache']) {
cache_clear_all(NULL, 'cache_block');
}
}
// Clears delta map cache.
cache_clear_all('facetapi:delta_map', 'cache');
}