public function similar_handler_argument_nid::options_form in Similar Entries 7.2
Same name and namespace in other branches
- 6.2 views/similar_handler_argument_nid.inc \similar_handler_argument_nid::options_form()
Defines the options form.
Overrides views_handler_argument_numeric::options_form
File
- views/
similar_handler_argument_nid.inc, line 58 - 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['default_argument_type']['#disabled'] = TRUE;
$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%',
);
foreach (entity_get_info('node')['view modes'] as $key => $values) {
$render_view_mode_options[$key] = $values['label'];
}
$form['adjust_relevance'] = array(
'#type' => 'checkbox',
'#title' => t('Adjust relevance of fields'),
'#default_value' => $this->options['adjust_relevance'],
'#description' => t('Adjust the relevance of content titles, bodies, and other fields in matching.'),
'#fieldset' => 'similar',
);
$form['title_relevance'] = array(
'#type' => 'select',
'#title' => t('Relevance of content\'s title.'),
'#options' => $relevance_options,
'#default_value' => $this->options['title_relevance'],
'#description' => t('Increase or decrease the relevance of matches in destination content\'s title field.'),
'#fieldset' => 'similar',
'#dependency' => array(
'edit-options-adjust-relevance' => array(
'1',
),
),
);
$form['body_relevance'] = array(
'#type' => 'select',
'#title' => t('Relevance of content\'s body.'),
'#options' => $relevance_options,
'#default_value' => $this->options['body_relevance'],
'#description' => t('Increase or decrease the relevance of matches in ' . 'destination content\'s body and other fields.'),
'#fieldset' => 'similar',
'#dependency' => array(
'edit-options-adjust-relevance' => array(
'1',
),
),
);
$form['rendered_content'] = array(
'#type' => 'checkbox',
'#title' => t('Use rendered source content instead of body'),
'#default_value' => $this->options['rendered_content'],
'#description' => t('Score similarity by comparing to source content rendered in a view mode, rather than body value.'),
'#fieldset' => 'similar',
);
$form['rendered_view_mode'] = array(
'#type' => 'select',
'#title' => t('View mode to render content'),
'#options' => $render_view_mode_options,
'#default_value' => $this->options['rendered_view_mode'],
'#fieldset' => 'similar',
'#dependency' => array(
'edit-options-rendered-content' => array(
'1',
),
),
);
// Add fields for enabling matching in fields defined by field module.
if (module_exists('field')) {
// Checkbox to enable fields in query.
$form['include_fields'] = array(
'#type' => 'checkbox',
'#title' => t('Include content fields in matching'),
'#default_value' => !empty($this->options['include_fields']),
'#description' => t('Enable FULLTEXT queries on fields defined with Field module.'),
'#fieldset' => 'similar',
);
// Add a weight select list for each field defined by Field module.
foreach (similar_get_indices() as $field => $info) {
$form['included_fields:' . $field] = array(
'#type' => 'select',
'#title' => isset($info['label']) ? $info['label'] : $field,
'#options' => $relevance_options,
'#default_value' => isset($this->options['included_fields:' . $field]) ? $this->options['included_fields:' . $field] : 1,
'#fieldset' => 'similar',
'#dependency' => array(
'edit-options-include-fields' => array(
'1',
),
'edit-options-adjust-relevance' => array(
'1',
),
),
'#dependency_count' => 2,
);
}
}
$form['boolean_mode'] = array(
'#type' => 'checkbox',
'#title' => t('Execute search in boolean mode'),
'#default_value' => !empty($this->options['boolean_mode']),
'#fieldset' => 'similar',
'#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.'),
);
// Add options for increasing or decreasing relevance of source node.
$form['source_relevance'] = array(
'#type' => 'checkbox',
'#title' => t('Adjust source relevance'),
'#default_value' => !empty($this->options['source_relevance']),
'#description' => t('Increase the relevance of words in the title of the content being viewed.'),
'#fieldset' => 'similar',
'#dependency' => array(
'edit-options-boolean-mode' => array(
'1',
),
),
);
$form['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['title_operator'],
'#fieldset' => 'similar',
'#dependency' => array(
'edit-options-boolean-mode' => array(
'1',
),
'edit-options-source-relevance' => array(
'1',
),
),
'#dependency_count' => 2,
);
// Add fields for creating custom relevance rules for specific words or phrases.
$form['enable_custom_operators'] = array(
'#type' => 'checkbox',
'#title' => t('Set custom operators in words and phrases'),
'#default_value' => !empty($this->options['enable_custom_operators']),
'#fieldset' => 'similar',
'#dependency' => array(
'edit-options-boolean-mode' => array(
'1',
),
),
);
$form['custom_operators'] = array(
'#type' => 'textfield',
'#title' => t('Operators'),
'#default_value' => $this->options['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,
'#fieldset' => 'similar',
'#dependency' => array(
'edit-options-boolean-mode' => array(
'1',
),
'edit-options-enable-custom-operators' => array(
'1',
),
),
'#dependency_count' => 2,
);
}