function apachesolr_nan_nan_settings_form in Apache Solr Not-A-Node 7
Same name and namespace in other branches
- 7.2 apachesolr_nan.admin.inc \apachesolr_nan_nan_settings_form()
Builds the administration form for Apache Solr NAN search.
1 string reference to 'apachesolr_nan_nan_settings_form'
- apachesolr_nan_menu in ./
apachesolr_nan.module - Implements hook_menu().
File
- ./
apachesolr_nan.admin.inc, line 12 - Administrative functions and form builders for Apache Solr NAN Search.
Code
function apachesolr_nan_nan_settings_form($form, &$form_state) {
// We will have many fields with the same name, so we need to be able to
// access the form hierarchically.
$form['#tree'] = TRUE;
$environments = apachesolr_load_all_environments();
$env_options = array();
foreach ($environments as $machine_name => $env) {
$env_options[$machine_name] = $env['name'];
}
$form['environment'] = array(
'#type' => 'select',
'#options' => $env_options,
'#description' => t('Choose the solr server with which to index the content.'),
'#default_value' => apachesolr_default_environment(),
'#required' => TRUE,
);
$form['description'] = array(
'#type' => 'item',
'#title' => t('Define the paths you would like indexed along with names and descriptions for them.'),
);
if (empty($form_state['items'])) {
$results = db_select('apachesolr_nan_index_paths', 'p')
->fields('p')
->execute();
$items = array();
while ($item = $results
->fetchAssoc()) {
$items[] = $item;
}
$form_state['items'] = $items;
}
if (!empty($form_state['all_removed']) || empty($form_state['items'])) {
$form_state['items'] = NULL;
//array(0 => array());
}
if (!empty($form_state['items'])) {
// Build a fieldset for each item in the items array.
$c = 1;
foreach ($form_state['items'] as $i => $data) {
$form['item'][$i] = array(
'#type' => 'fieldset',
'#title' => t('Item #@num', array(
'@num' => $c,
)),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['item'][$i]['path'] = array(
'#type' => 'textfield',
'#title' => t('Path to Index'),
'#description' => t('Enter a path to index.'),
'#required' => TRUE,
'#default_value' => !empty($data['path']) ? $data['path'] : '',
);
$form['item'][$i]['title'] = array(
'#type' => 'textfield',
'#title' => t('Indexed Title'),
'#description' => t('A title to show on the search results page. This can be the name of the page or something else but users will see this in search results and the text will be used to boost result order.'),
'#default_value' => !empty($data['title']) ? $data['title'] : '',
);
$form['item'][$i]['description'] = array(
'#type' => 'textarea',
'#title' => t('Page description'),
'#description' => t('The description will show in search results only. It can be used to improve search results for certain pages.'),
'#default_value' => !empty($data['description']) ? $data['description'] : '',
);
$form['item'][$i]['frequency'] = array(
'#type' => 'select',
'#title' => t('Time between indexes'),
'#options' => array(
3600 => 'hourly',
86400 => 'daily',
604800 => 'weekly',
2419200 => 'monthly',
),
'#description' => t('The page will be reindexed at the set interval.'),
'#default_value' => isset($data['frequency']) ? $data['frequency'] : 86400,
'#required' => TRUE,
);
$form['item'][$i]['delete'] = array(
'#type' => 'submit',
'#name' => $i,
'#value' => 'Delete',
'#submit' => array(
'apachesolr_nan_remove_item',
),
'#limit_validation_errors' => array(),
);
$c++;
}
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
);
// Adds "Add another name" button
$form['add_item'] = array(
'#type' => 'submit',
'#value' => t('Add another item'),
'#submit' => array(
'apachesolr_nan_add_item',
),
);
return $form;
}