function fac_settings_form in Fast Autocomplete 7
Fast AutoComplete settings form.
1 string reference to 'fac_settings_form'
- fac_menu in ./
fac.module - Implements hook_menu().
File
- inc/
fac.admin.inc, line 11 - This file contains the settings forms of the Fast Autocomplete module.
Code
function fac_settings_form($form, $form_state) {
$form = array();
$form['backend'] = array(
'#type' => 'fieldset',
'#title' => t('Backend'),
);
// Get all available backend service options.
$service_options = array();
$service_infos = fac_get_service_info();
foreach ($service_infos as $service_info) {
$service_options[$service_info['class']] = $service_info['name'];
}
$form['backend']['fac_backend_service'] = array(
'#type' => 'select',
'#title' => t('The backend service to use'),
'#description' => t('Select the backend service that is used by Fast Autocomplete. Note that if a service is dependent on another module (for example: the Search API backend service needs the Search API module to be enabled) it only shows up if that module is enabled.'),
'#options' => $service_options,
'#default_value' => variable_get('fac_backend_service', ''),
'#required' => TRUE,
);
$form['behavior'] = array(
'#type' => 'fieldset',
'#title' => t('Behavior'),
);
$form['behavior']['fac_input_selectors'] = array(
'#type' => 'textarea',
'#title' => t('Inputs to enable Fast Autocomplete on'),
'#description' => t('Enter the jQuery selector(s) for text input elements to enable the Fast Autocomplete functionality on those elements. You can provide multiple selectors divided by commas.'),
'#default_value' => variable_get('fac_input_selectors', ''),
'#attributes' => array(
'placeholder' => t('for example: input[name="search_block_form"], input[name="some_other_form"]'),
),
);
$form['behavior']['fac_empty_result'] = array(
'#type' => 'textarea',
'#title' => t('Text to show when the search input gets focus and there is no search term in the input.'),
'#description' => t('Enter the HTML to show when the search input gets focus and there is no search term in the input. Useful for "quick links" for instance.'),
'#default_value' => variable_get('fac_empty_result', ''),
);
$form['behavior']['fac_all_results_link'] = array(
'#type' => 'checkbox',
'#title' => t('Show a "view all results" link'),
'#description' => t('Enable this option to show a "view all results" link below the suggestions,'),
'#default_value' => variable_get('fac_all_results_link', TRUE),
);
$form['behavior']['fac_all_results_link_threshold'] = array(
'#type' => 'textfield',
'#title' => t('Minimum number of suggestions to show "view all results" link'),
'#description' => t('Enter the minimum number of suggestions to have to show the "view all results" link. Enter "0" to always show the "view all results" link.'),
'#default_value' => variable_get('fac_all_results_link_threshold', "0"),
'#size' => 3,
'#states' => array(
'visible' => array(
'input[name="fac_all_results_link"]' => array(
'checked' => TRUE,
),
),
'required' => array(
'input[name="fac_all_results_link"]' => array(
'checked' => TRUE,
),
),
),
);
// Get all available view modes and create the view modes option array.
$entities_info = entity_get_info();
$view_modes = array();
foreach ($entities_info as $entity_info) {
$view_modes = array_merge($view_modes, $entity_info['view modes']);
}
// Add two default view mode options (not returned by entity_get_info()).
$view_mode_options = array(
'default' => t('Default'),
'full' => t('Full'),
);
foreach ($view_modes as $system_name => $view_mode) {
$view_mode_options[$system_name] = $view_mode['label'];
}
$form['behavior']['fac_view_mode'] = array(
'#type' => 'select',
'#title' => t('Select which view mode to use for rendering the suggestions'),
'#description' => t('The view mode that is used to render the suggestions the search terms result in. Note that when you select a view mode that is not configured for the suggestion entity, the default view mode is used.'),
'#default_value' => variable_get('fac_view_mode', 'fac'),
'#options' => $view_mode_options,
);
$form['behavior']['fac_key_min_length'] = array(
'#type' => 'textfield',
'#title' => t('The minimum key length to trigger Fast Autocomplete'),
'#description' => t('Enter the minimum key length to trigger the Fast Autocomplete on an input field. The minimum value is 1.'),
'#default_value' => variable_get('fac_key_min_length', 1),
'#required' => TRUE,
'#size' => 2,
);
$form['behavior']['fac_key_max_length'] = array(
'#type' => 'textfield',
'#title' => t('The maximum key length to trigger Fast Autocomplete'),
'#description' => t('Enter the maximum key length to trigger the Fast Autocomplete on an input field. The minimum value is 1.'),
'#default_value' => variable_get('fac_key_max_length', 5),
'#required' => TRUE,
'#size' => 2,
);
$form['behavior']['fac_breakpoint'] = array(
'#type' => 'textfield',
'#title' => t('Breakpoint'),
'#description' => t('Enter a minimum width in pixels to disable the Fast Autocomplete behavior until this minimum width is reached. Insert 0 to always enable the Fast Autocomplete behavior.'),
'#default_value' => variable_get('fac_breakpoint', 0),
'#size' => 4,
);
$form['behavior']['fac_use_module_css'] = array(
'#type' => 'checkbox',
'#title' => t('Include the css provided by the module in the output'),
'#description' => t("Enable this option to include the css provided by the Fast Autocomplete module in the output. Don't forget to clear the Drupal cache after changing this option!"),
'#default_value' => variable_get('fac_use_module_css', TRUE),
);
$form['behavior']['fac_result_location'] = array(
'#type' => 'textfield',
'#title' => t('Result location'),
'#description' => t('Enter a jQuery selector for a single element that is used to append the results to. If left empty, the results will be appended to the form the input is in.'),
'#default_value' => variable_get('fac_result_location', ''),
);
$form['json_files'] = array(
'#type' => 'fieldset',
'#title' => t('Json files'),
);
$form['json_files']['fac_clean_up_files'] = array(
'#type' => 'checkbox',
'#title' => t('Periodically clean up json files'),
'#description' => t('Enable cleaning up json files on cron to refresh the contents of the json files that contain the autocomplete suggestions.'),
'#default_value' => variable_get('fac_clean_up_files', TRUE),
);
$form['json_files']['fac_files_expire_time'] = array(
'#type' => 'textfield',
'#title' => t('Expire time'),
'#description' => t('How old do the json files have to be to be considered expired? The value for this field should contain a relative string compared to now like "-1 month" or "-1 day"'),
'#default_value' => variable_get('fac_files_expire_time', '-1 day'),
'#size' => 20,
'#states' => array(
'visible' => array(
'input[name="fac_clean_up_files"]' => array(
'checked' => TRUE,
),
),
'required' => array(
'input[name="fac_clean_up_files"]' => array(
'checked' => TRUE,
),
),
),
);
$form['json_files']['fac_bulk_generate_json_enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Bulk generate json files'),
'#description' => t('Enable daily bulk generating and refreshing json files on cron instead of only generating json files on user request.'),
'#default_value' => variable_get('fac_bulk_generate_json_enabled', FALSE),
);
$form['json_files']['fac_bulk_generate_json_size'] = array(
'#type' => 'textfield',
'#title' => t('Size'),
'#description' => t('To what size of the search key should the json files be generated? CAUTION: setting a size larger than 2 rapidly increases the number of combinations to generate json files for!'),
'#default_value' => variable_get('fac_bulk_generate_json_size', 2),
'#size' => 3,
'#states' => array(
'visible' => array(
'input[name="fac_bulk_generate_json_enabled"]' => array(
'checked' => TRUE,
),
),
'required' => array(
'input[name="fac_bulk_generate_json_enabled"]' => array(
'checked' => TRUE,
),
),
),
);
$form['json_files']['fac_files_delete_all'] = array(
'#type' => 'button',
'#value' => t('Delete all json files'),
'#limit_validation_errors' => array(),
'#name' => 'delete',
);
return system_settings_form($form);
}