You are here

function similar_handler_field_similarity::options_form in Similar Entries 7.2

Same name and namespace in other branches
  1. 6.2 views/similar_handler_field_similarity.inc \similar_handler_field_similarity::options_form()

Options form for selecting between number and percentage.

Overrides views_handler_field::options_form

File

views/similar_handler_field_similarity.inc, line 28
Provides a field for displaying the similarity score of similar entries.

Class

similar_handler_field_similarity
Similarity score field handler.

Code

function options_form(&$form, &$form_state) {
  parent::options_form($form, $form_state);
  $form['score_type'] = array(
    '#type' => 'radios',
    '#title' => t('Display type'),
    '#default_value' => $this->options['score_type'],
    '#options' => array(
      0 => t('Show similarity score'),
      1 => t('Show as percentage'),
    ),
  );
  $form['round_decimal'] = array(
    '#type' => 'select',
    '#title' => t('Round to nearest'),
    '#default_value' => $this->options['round_decimal'],
    '#options' => array(
      0 => t('Whole number') . ' (1)',
      1 => '10th (1.0)',
      2 => '100th (1.00)',
      3 => '1,000th (1.000)',
      4 => '10,000th (1.0000)',
    ),
  );
  $form['percent_suffix'] = array(
    '#type' => 'checkbox',
    '#title' => t('Append % when showing percentage'),
    '#default_value' => !empty($this->options['percent_suffix']),
  );
  $score_options = array(
    '0.1' => '0.1',
    '0.2' => '0.2',
    '0.3' => '0.3',
    '0.4' => '0.4',
    '0.5' => '0.5',
    '0.6' => '0.6',
    '0.7' => '0.7',
    '0.8' => '0.8',
    '0.9' => '0.9',
  );
  for ($i = 1; $i < 101; $i++) {
    $score_options[$i] = $i;
  }
  $form['multiply_score'] = array(
    '#type' => 'select',
    '#title' => t('Multiply score by'),
    '#options' => $score_options,
    '#default_value' => $this->options['multiply_score'],
  );
}