function apachesolr_search_custom_page_search_form in Apache Solr Search 6.3
Same name and namespace in other branches
- 8 apachesolr_search.pages.inc \apachesolr_search_custom_page_search_form()
- 7 apachesolr_search.pages.inc \apachesolr_search_custom_page_search_form()
Search for placed on user defined search pages.
2 string references to 'apachesolr_search_custom_page_search_form'
- apachesolr_search_custom_page in ./
apachesolr_search.pages.inc - Returns search results on user defined search pages.
- apachesolr_search_search_results in ./
apachesolr_search.module
File
- ./
apachesolr_search.pages.inc, line 49 - Provides the page callback for user defined search pages.
Code
function apachesolr_search_custom_page_search_form(&$form_state, $search_page, $keys = '') {
$form = array();
// Loads the core Search CSS file, use the core search module's classes.
drupal_add_css(drupal_get_path('module', 'search') . '/search.css');
$form = array();
$form['#id'] = 'search-form';
//$form['#attributes']['class'][] = 'search-form';
$form['#search_page'] = $search_page;
$form['basic']['keys'] = array(
'#type' => 'textfield',
'#title' => t('Enter terms'),
'#default_value' => $keys,
'#size' => 20,
'#maxlength' => 255,
);
$form['basic']['submit'] = array(
'#type' => 'submit',
'#value' => t('Search'),
);
$form['basic']['get'] = array(
'#type' => 'hidden',
'#default_value' => json_encode(array_diff_key($_GET, array(
'q' => 1,
'page' => 1,
'solrsort' => 1,
'retain-filters' => 1,
))),
);
$fq = NULL;
if (apachesolr_has_searched($search_page['env_id'])) {
$query = apachesolr_current_query($search_page['env_id']);
// We use the presence of filter query params as a flag for the retain filters checkbox.
$fq = $query
->getParam('fq');
}
if ($fq || !empty($form_state['post'])) {
$form['basic']['retain-filters'] = array(
'#type' => 'checkbox',
'#title' => t('Retain current filters'),
'#default_value' => (int) (!empty($_GET['retain-filters'])),
);
}
return $form;
}