function apachesolr_views_handler_argument_mlt::options_form in Apache Solr Views 6
Override options form to present specific stuffs
File
- handlers/
apachesolr_views_handler_argument_mlt.inc, line 23
Class
Code
function options_form(&$form, &$form_state) {
module_load_include('inc', 'apachesolr', 'apachesolr.admin');
// for apachesolr_mlt_get_fields()
parent::options_form($form, $form_state);
// TODO: figure out how to do this. cant do id: 123 id: 456 can we?
unset($form['break_phrase']);
// TODO: can we exclude this argument??
unset($form['not']);
$form['type'] = array(
'#type' => 'select',
'#title' => t('Object type'),
'#description' => t('Select the object type (node, user) that you will be present in the url '),
'#options' => array(
'node' => t('Node'),
'user' => t('User'),
),
'#default_value' => $this->options['type'],
);
// Grab the mlt fields.
$mlt_fields = apachesolr_mlt_get_fields();
$weights = drupal_map_assoc(array(
'21.0',
'13.0',
'8.0',
'5.0',
'3.0',
'2.0',
'1.0',
'0.8',
'0.5',
'0.3',
'0.2',
'0.1',
));
$weights['0'] = t('Omit');
$form['mlt_fl'] = array(
'#type' => 'fieldset',
'#tree' => TRUE,
'#title' => t('Fields'),
);
foreach ($mlt_fields as $key => $description) {
$form['mlt_fl'][$key] = array(
'#type' => 'select',
'#options' => $weights,
'#title' => $description,
'#default_value' => isset($this->options['mlt_fl'][$key]) ? $this->options['mlt_fl'][$key] : '0',
);
}
$options = drupal_map_assoc(array(
1,
2,
3,
4,
5,
6,
7,
));
$form['mlt_mintf'] = array(
'#type' => 'select',
'#title' => t('Minimum Term Frequency'),
'#description' => t('A word must appear this many times in any given document before the document is considered relevant for comparison.'),
'#default_value' => $this->options['mlt_mintf'],
'#options' => $options,
);
$form['mlt_mindf'] = array(
'#type' => 'select',
'#title' => t('Minimum Document Frequency'),
'#description' => t('A word must occur in at least this many documents before it will be used for similarity comparison.'),
'#default_value' => $this->options['mlt_mindf'],
'#options' => $options,
);
$form['mlt_minwl'] = array(
'#type' => 'select',
'#title' => t('Minimum Word Length'),
'#description' => 'You can use this to eliminate short words such as "the" and "it" from similarity comparisons. Words must be at least this number of characters or they will be ignored.',
'#default_value' => $this->options['mlt_minwl'],
'#options' => $options,
);
$form['mlt_maxwl'] = array(
'#type' => 'select',
'#title' => t('Maximum World Length'),
'#description' => t('You can use this to eliminate very long words from similarity comparisons. Words of more than this number of characters will be ignored.'),
'#default_value' => $this->options['mlt_maxwl'],
'#options' => drupal_map_assoc(array(
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
)),
);
$form['mlt_maxqt'] = array(
'#type' => 'select',
'#title' => t('Maximum number of query terms'),
'#description' => t('The maximum number of query terms that will be included in any query. Lower numbers will result in fewer recommendations but will get results faster. If a content recommendation is not returning any recommendations, you can either check more "Comparison fields" checkboxes or increase the maximum number of query terms here.'),
'#options' => drupal_map_assoc(array(
5,
10,
15,
20,
25,
30,
35,
40,
45,
50,
)),
'#default_value' => $this->options['mlt_maxqt'],
);
}