function apachesolr_mlt_block_form in Apache Solr Search 6.2
Same name and namespace in other branches
- 5.2 apachesolr.admin.inc \apachesolr_mlt_block_form()
- 5 contrib/apachesolr_mlt/apachesolr_mlt.module \apachesolr_mlt_block_form()
- 6 apachesolr.admin.inc \apachesolr_mlt_block_form()
Form to edit moreLikeThis block settings.
Parameters
int $delta: If editing, the id of the block to edit.
Return value
array The form used for editing.
TODO: Add term boost settings. Enable the user to specify a query, rather then forcing suggestions based on the node id.
2 calls to apachesolr_mlt_block_form()
- apachesolr_block in ./
apachesolr.module - Implementation of hook_block().
- apachesolr_mlt_add_block_form in ./
apachesolr.admin.inc - MoreLikeThis administration and utility functions.
File
- ./
apachesolr.admin.inc, line 601 - Administrative pages for the Apache Solr framework.
Code
function apachesolr_mlt_block_form($delta = NULL) {
if (isset($delta)) {
$block = apachesolr_mlt_load_block($delta);
if (!$block) {
return array();
}
}
else {
$block = apachesolr_mlt_block_defaults();
}
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Block name'),
'#description' => t('The block name displayed to site users.'),
'#required' => TRUE,
'#default_value' => $block['name'],
'#weight' => '-2',
);
$form['num_results'] = array(
'#type' => 'select',
'#title' => t('Maximum number of related items to display'),
'#default_value' => $block['num_results'],
'#options' => drupal_map_assoc(array(
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
)),
'#weight' => -1,
);
$form['mlt_fl'] = array(
'#type' => 'checkboxes',
'#title' => t('Fields for finding related content'),
'#description' => t('Choose the fields to be used in calculating similarity. The default combination of %taxonomy_names and %title will provide relevant results for typical sites.', array(
"%taxonomy_names" => apachesolr_field_name_map("taxonomy_names"),
"%title" => apachesolr_field_name_map("title"),
)),
'#options' => apachesolr_mlt_get_fields(),
'#required' => TRUE,
'#default_value' => $block['mlt_fl'],
);
$form['advanced'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced configuration'),
'#weight' => '1',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$options = drupal_map_assoc(array(
1,
2,
3,
4,
5,
6,
7,
));
$form['advanced']['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' => $block['mlt_mintf'],
'#options' => $options,
);
$form['advanced']['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' => $block['mlt_mindf'],
'#options' => $options,
);
$form['advanced']['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' => $block['mlt_minwl'],
'#options' => $options,
);
$form['advanced']['mlt_maxwl'] = array(
'#type' => 'select',
'#title' => t('Maximum word 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' => $block['mlt_maxwl'],
'#options' => drupal_map_assoc(array(
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
)),
);
$form['advanced']['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(
3,
5,
7,
10,
12,
15,
20,
25,
30,
35,
40,
)),
'#default_value' => $block['mlt_maxqt'],
);
$form['restrictions'] = array(
'#type' => 'fieldset',
'#title' => t('Filters'),
'#weight' => '1',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$type_options = array();
foreach (node_get_types('types') as $key => $type) {
$type_options[$key] = $type->name;
}
$form['restrictions']['mlt_type_filters'] = array(
'#type' => 'checkboxes',
'#title' => t('Content Types'),
'#default_value' => is_array($block['mlt_type_filters']) ? $block['mlt_type_filters'] : array_keys($type_options),
'#options' => $type_options,
'#description' => t('Select the content types that similarity suggestions should be restricted to. Multiple types are joined with an OR query, so selecting more types results in more recommendations.'),
'#weight' => '-2',
);
$form['restrictions']['mlt_custom_filters'] = array(
'#type' => 'textfield',
'#title' => t('Additional Query'),
'#description' => t("An additional query, in Lucene syntax, which will further filter the similarity suggestions. Ex. 'title:strategy' will filter related content further to only those with strategy in the title. Likewise 'body:HDTV^3' will boost the term HDTV by a factor of 3. Here are some more examples:") . '<ul>
<li>language:fr</li>
<li>tid:5 OR tid 7</li>
<li>created:[2009-05-01T23:59:59Z TO 2009-07-28T12:30:00Z]</li>
<li>-uid:0 AND -uid:1</li>
</ul>',
'#required' => FALSE,
'#default_value' => $block['mlt_custom_filters'],
'#weight' => '-1',
);
return $form;
}