public function similar_handler_argument_nid::options_form in Similar Entries 6.2
Same name and namespace in other branches
- 7.2 views/similar_handler_argument_nid.inc \similar_handler_argument_nid::options_form()
Defines the options form.
File
- views/
similar_handler_argument_nid.inc, line 68 - Defines the Similar entries node ID argument.
Class
- similar_handler_argument_nid
- Defines the similar entries View node ID argument.
Code
public function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
unset($form['not']);
$form['similar'] = array(
'#type' => 'fieldset',
'#title' => t('FULLTEXT search options'),
);
// Add fields for increasing or decreasing relevance of destination ndoe fields.
$relevance_options = array(
'0' => '0%',
'0.1' => '10%',
'0.2' => '20%',
'0.3' => '30%',
'0.4' => '40%',
'0.5' => '50%',
'0.6' => '60%',
'0.7' => '70%',
'0.8' => '80%',
'0.9' => '90%',
'1.0' => '100%',
'1.1' => '110%',
'1.2' => '120%',
'1.3' => '130%',
'1.4' => '140%',
'1.5' => '150%',
'1.6' => '160%',
'1.7' => '170%',
'1.8' => '180%',
'1.9' => '190%',
'2.0' => '200%',
);
$form['similar']['adjust_relevance'] = array(
'#type' => 'checkbox',
'#title' => t('Adjust relevance of fields'),
'#default_value' => $this->options['similar']['adjust_relevance'],
'#description' => t('Adjust the relevance of content titles, bodies, and other fields in matching.'),
);
$form['similar']['relevance'] = array(
'#type' => 'fieldset',
'#title' => t('Match Relevance'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['similar']['relevance']['title_relevance'] = array(
'#type' => 'select',
'#title' => t('Relevance of content\'s title'),
'#options' => $relevance_options,
'#default_value' => $this->options['similar']['relevance']['title_relevance'],
'#description' => t('Increase or decrease the relevance of matches in destination content\'s title field.'),
);
$form['similar']['relevance']['body_relevance'] = array(
'#type' => 'select',
'#title' => t('Relevance of content\'s body'),
'#options' => $relevance_options,
'#default_value' => $this->options['similar']['relevance']['body_relevance'],
'#description' => t('Increase or decrease the relevance of matches in destination content\'s body field.'),
);
// Add fields for enabling matching in fields defined by field module.
if (module_exists('content')) {
$field_options = self::get_field_options();
$form['similar']['include_fields'] = array(
'#type' => 'checkbox',
'#title' => t('Include CCK fields in matching'),
'#default_value' => !empty($this->options['similar']['include_fields']),
'#description' => t('Enable FULLTEXT queries on fields defined with Field module.'),
);
$form['similar']['cck_fields'] = array(
'#type' => 'fieldset',
'#title' => t('CCK Fields'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
foreach ($field_options as $table => $field) {
$form['similar']['cck_fields']['included_fields:' . $table] = array(
'#type' => 'select',
'#title' => $field,
'#options' => $relevance_options,
'#default_value' => isset($this->options['similar']['cck_fields']['included_fields:' . $table]) ? $this->options['similar']['cck_fields']['included_fields:' . $table] : 1,
'#fieldset' => 'similar',
);
}
}
$form['similar']['boolean_mode'] = array(
'#type' => 'checkbox',
'#title' => t('Execute search in boolean mode'),
'#default_value' => !empty($this->options['similar']['boolean_mode']),
'#description' => t('Boolean mode enables the ability to increase or decrease the relevance of certain fields.<br />' . 'Note: Boolean mode may negatively affect the accuracy of view results.'),
);
$form['similar']['boolean_options'] = array(
'#type' => 'fieldset',
'#title' => t('Boolean Mode Options'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// Add options for increasing or decreasing relevance of source node.
$form['similar']['boolean_options']['title_operator'] = array(
'#type' => 'select',
'#title' => t('Relevance of source content\'s title'),
'#options' => array(
'none' => t('No change'),
'increase' => t('Increase title relevance'),
'decrease' => t('Decrease title relevance'),
'require_all' => t('Require all terms'),
'require_some' => t('Require at least one term'),
'require_complete' => t('Require complete title'),
'exclude_all' => t('Exclude all terms'),
'exclude_some' => t('Exclude at least one term'),
'exclude_complete' => t('Exclude complete title'),
),
'#default_value' => $this->options['similar']['boolean_options']['title_operator'],
);
// Add fields for creating custom relevance rules for specific words or phrases.
$form['similar']['boolean_options']['enable_custom_operators'] = array(
'#type' => 'checkbox',
'#title' => t('Set custom operators in words and phrases'),
'#default_value' => !empty($this->options['similar']['boolean_options']['enable_custom_operators']),
);
$form['similar']['boolean_options']['operators_fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Custom Operators'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['similar']['boolean_options']['operators_fieldset']['custom_operators'] = array(
'#type' => 'textfield',
'#title' => t('Operators'),
'#default_value' => $this->options['similar']['boolean_options']['operators_fieldset']['custom_operators'],
'#description' => t('Use boolean logical operators to customize the FULLTEXT query. Each expression should ' . 'be separated by a vertical bar |.<br />' . 'Available operators: + - > < ( ) ~ "<br />' . 'See http://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html for more information.'),
'#maxlength' => 1024,
);
}